Changes In Branch origin/merging-ode2odes-exe Excluding Merge-Ins

This is equivalent to a diff from fe41f9074c to 16d57ddb07

2001-03-19
02:28:53
Branch merge: merging-ode2odes-exe back to MAIN. check-in: f837714420 user: geraint@users.sourceforge.net tags: origin/master, trunk
01:35:31
Reverted forced update check to main branch form, ready for merge. Leaf check-in: 16d57ddb07 user: geraint@users.sourceforge.net tags: origin/merging-ode2odes-exe, trunk
00:29:08
Parse switches (-A) before calling def2write_r.
Update $1_def.* instead of removing.
check-in: a58166ede2 user: geraint@users.sourceforge.net tags: origin/merging-ode2odes-exe, trunk
2001-02-19
06:33:20
Created branch merging-ode2odes-exe check-in: 97dc03b3f3 user: gawthrop@users.sourceforge.net tags: origin/merging-ode2odes-exe, trunk
06:33:19
Removed operation form loop. check-in: fe41f9074c user: geraint@users.sourceforge.net tags: origin/master, trunk
06:32:02
Octave path change, remove libblas check-in: b352ebad6c user: geraint@users.sourceforge.net tags: origin/master, trunk

Deleted CVSROOT/checkoutlist version [3854d49239].

1
2
3
4
5
6
7
8
9
10
11
12
13
# The "checkoutlist" file is used to support additional version controlled
# administrative files in $CVSROOT/CVSROOT, such as template files.
#
# The first entry on a line is a filename which will be checked out from
# the corresponding RCS file in the $CVSROOT/CVSROOT directory.
# The remainder of the line is an error message to use if the file cannot
# be checked out.
#
# File format:
#
#	[<whitespace>]<filename><whitespace><error message><end-of-line>
#
# comment lines begin with '#'
<
<
<
<
<
<
<
<
<
<
<
<
<


























Deleted CVSROOT/commitinfo version [85654ac9a8].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# The "commitinfo" file is used to control pre-commit checks.
# The filter on the right is invoked with the repository and a list 
# of files to check.  A non-zero exit of the filter program will 
# cause the commit to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT.  For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























Deleted CVSROOT/config version [28e7a42550].

1
2
3
4
5
6
7
8
9
10
11
# Set this to "no" if pserver shouldn't check system users/passwords
#SystemAuth=no

# Set `PreservePermissions' to `yes' to save file status information
# in the repository.
#PreservePermissions=no

# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top
# level of the new working directory when using the `cvs checkout'
# command.
#TopLevelAdmin=no
<
<
<
<
<
<
<
<
<
<
<






















Deleted CVSROOT/cvswrappers version [9d41597c29].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# This file affects handling of files based on their names.
#
# The -t/-f options allow one to treat directories of files
# as a single file, or to transform a file in other ways on
# its way in and out of CVS.
#
# The -m option specifies whether CVS attempts to merge files.
#
# The -k option specifies keyword expansion (e.g. -kb for binary).
#
# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers)
#
#  wildcard	[option value][option value]...
#
#  where option is one of
#  -f		from cvs filter		value: path to filter
#  -t		to cvs filter		value: path to filter
#  -m		update methodology	value: MERGE or COPY
#  -k		expansion mode		value: b, o, kkv, &c
#
#  and value is a single-quote delimited value.
# For example:
#*.gif -k 'b'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































Deleted CVSROOT/editinfo version [dfa5fb459c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# The "editinfo" file is used to allow verification of logging
# information.  It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure.  Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
#   Making sure that the entered bug-id number is correct.
#   Validating that the code that was reviewed is indeed the code being
#       checked in (using the bug-id number or a seperate review
#       number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported.  There can be only one entry that matches a given
# repository.
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































Deleted CVSROOT/loginfo version [4503d4cd47].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# The "loginfo" file controls where "cvs commit" log information
# is sent.  The first entry on a line is a regular expression which must match
# the directory that the change is being made to, relative to the
# $CVSROOT.  If a match is found, then the remainder of the line is a filter
# program that should expect log information on its standard input.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name ALL appears as a regular expression it is always used
# in addition to the first matching regex or DEFAULT.
#
# You may specify a format string as part of the
# filter.  The string is composed of a `%' followed
# by a single format character, or followed by a set of format
# characters surrounded by `{' and `}' as separators.  The format
# characters are:
#
#   s = file name
#   V = old version number (pre-checkin)
#   v = new version number (post-checkin)
#
# For example:
#DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog
# or
#DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































Deleted CVSROOT/modules version [84b74e5335].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Three different line formats are valid:
#	key	-a    aliases...
#	key [options] directory
#	key [options] directory files...
#
# Where "options" are composed of:
#	-i prog		Run "prog" on "cvs commit" from top-level of module.
#	-o prog		Run "prog" on "cvs checkout" of module.
#	-e prog		Run "prog" on "cvs export" of module.
#	-t prog		Run "prog" on "cvs rtag" of module.
#	-u prog		Run "prog" on "cvs update" of module.
#	-d dir		Place module in directory "dir" instead of module name.
#	-l		Top-level directory only -- do not recurse.
#
# NOTE:  If you change any of the "Run" options above, you'll have to
# release and re-checkout any working directories of these modules.
#
# And "directory" is a path to a directory relative to $CVSROOT.
#
# The "-a" option specifies an alias.  An alias is interpreted as if
# everything on the right of the "-a" had been typed on the command line.
#
# You can encode a module within a module by using the special '&'
# character to interpose another module into the current module.  This
# can be useful for creating a module that consists of many directories
# spread out over the entire source repository.
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































Deleted CVSROOT/notify version [2a5259e3c5].

1
2
3
4
5
6
7
8
9
10
11
12
# The "notify" file controls where notifications from watches set by
# "cvs watch add" or "cvs edit" are sent.  The first entry on a line is
# a regular expression which is tested against the directory that the
# change is being made to, relative to the $CVSROOT.  If it matches,
# then the remainder of the line is a filter program that should contain
# one occurrence of %s for the user to notify, and information on its
# standard input.
#
# "ALL" or "DEFAULT" can be used in place of the regular expression.
#
# For example:
#ALL mail %s -s "CVS notification"
<
<
<
<
<
<
<
<
<
<
<
<
























Deleted CVSROOT/rcsinfo version [c276b88ba1].

1
2
3
4
5
6
7
8
9
10
11
12
13
# The "rcsinfo" file is used to control templates with which the editor
# is invoked on commit and import.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being made to, relative to the
# $CVSROOT.  For the first match that is found, then the remainder of the
# line is the name of the file that contains the template.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".
<
<
<
<
<
<
<
<
<
<
<
<
<


























Deleted CVSROOT/taginfo version [364dad5373].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# The "taginfo" file is used to control pre-tag checks.
# The filter on the right is invoked with the following arguments:
#
# $1 -- tagname
# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d
# $3 -- repository
# $4->  file revision [file revision ...]
#
# A non-zero exit of the filter program will cause the tag to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT.  For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































Deleted CVSROOT/verifymsg version [cbc796537d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# The "verifymsg" file is used to allow verification of logging
# information.  It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure.  Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
#   Making sure that the entered bug-id number is correct.
#   Validating that the code that was reviewed is indeed the code being
#       checked in (using the bug-id number or a seperate review
#       number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported.  There can be only one entry that matches a given
# repository.
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































Modified mttroot/mtt/bin/mtt from [7a138278c5] to [ae0b057ffb].

11
12
13
14
15
16
17

























18
19
20
21
22
23
24
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Header$
## $Log$

























## Revision 1.292  2001/02/05 17:27:40  gawthrop
## Make sure _def.r exists before creating _state.txt
##
## Revision 1.291  2000/12/27 14:50:40  peterg
## This is the first CVS version (4.9).
## Commented out code now deleted
##







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Header$
## $Log$
## Revision 1.293.2.7  2001/03/17 09:51:06  geraint
## Implemented Runge-Kutta IV fixed-step method (-i rk4).
##
## Revision 1.293.2.6  2001/03/03 06:50:38  geraint
## Added #SUMMARY lines for ode2odes.
##
## Revision 1.293.2.5  2001/03/03 00:27:14  geraint
## Fixed ar options to work with GNU ar. Allow mtt to create dependencies for mtt_%.cc when making mtt_%.oct.
##
## Revision 1.293.2.4  2001/03/02 00:45:21  geraint
## Separated Euler and Implicit methods in .cc code and dependencies.
##
## Revision 1.293.2.3  2001/03/01 05:05:53  geraint
## Minor revisions.
##
## Revision 1.293.2.2  2001/02/23 03:53:53  geraint
## Minor revisions. (ode2odes.exe works on GNU/Linux and ~GNU/Irix)
##
## Revision 1.293.2.1  2001/02/22 06:41:40  geraint
## Initial merge of ode2odes.exe into main mtt.
## standalone_rep.make deleted: rules moved to mtt, variables to mttrc.
##
## Revision 1.293  2001/02/06 04:39:08  geraint
## Added _standalone.exe representation.
##
## Revision 1.292  2001/02/05 17:27:40  gawthrop
## Make sure _def.r exists before creating _state.txt
##
## Revision 1.291  2000/12/27 14:50:40  peterg
## This is the first CVS version (4.9).
## Commented out code now deleted
##
1060
1061
1062
1063
1064
1065
1066




1067
1068
1069
1070
1071
1072
1073
1074
1075
			integration_method=euler;
                        mtt_switches="$mtt_switches euler";
			;;
		    implicit)
			integration_method=implicit;
                        mtt_switches="$mtt_switches implicit";
			;;




		    *)
			echo $1 is an unknown integration method - use euler or implicit;
                        exit;;
		esac;;
	-s )
                mtt_switches="$mtt_switches $1";
		sensitivity=sensitivity ;;
	-ss )
                mtt_switches="$mtt_switches $1";







>
>
>
>

|







1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
			integration_method=euler;
                        mtt_switches="$mtt_switches euler";
			;;
		    implicit)
			integration_method=implicit;
                        mtt_switches="$mtt_switches implicit";
			;;
		    rk4)
			integration_method=rk4;
			mtt_switches="$mtt_switches rk4";
			;;
		    *)
			echo $1 is an unknown integration method - use euler, rk4 or implicit;
                        exit;;
		esac;;
	-s )
                mtt_switches="$mtt_switches $1";
		sensitivity=sensitivity ;;
	-ss )
                mtt_switches="$mtt_switches $1";
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
    echo '         -D  debug -- leave log files etc'
    echo '         -I  prints more information'
    echo '         -abg start at abg.m representation'
    echo '         -c  c-code generation'
    echo '         -d  <dir>  use directory <dir>'
    echo '         -dc Maximise derivative (not integral) causality'
    echo '         -dc Maximise derivative (not integral) causality'
    echo '         -i <implicit|euler>   Use implicit or euler integration'
    echo '         -o ode is same as dae'
    echo '         -oct use oct files in place of m files where appropriate'
    echo '         -opt optimise code generation'
    echo '         -p  print environment variables'
    echo '         -partition partition hierachical system'
    echo '         -r  reset time stamp on representation'
    echo '         -s  try to generate sensitivity BG (experimental)'







|







1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
    echo '         -D  debug -- leave log files etc'
    echo '         -I  prints more information'
    echo '         -abg start at abg.m representation'
    echo '         -c  c-code generation'
    echo '         -d  <dir>  use directory <dir>'
    echo '         -dc Maximise derivative (not integral) causality'
    echo '         -dc Maximise derivative (not integral) causality'
    echo '         -i <implicit|euler|rk4>   Use implicit, euler or rk4 integration'
    echo '         -o ode is same as dae'
    echo '         -oct use oct files in place of m files where appropriate'
    echo '         -opt optimise code generation'
    echo '         -p  print environment variables'
    echo '         -partition partition hierachical system'
    echo '         -r  reset time stamp on representation'
    echo '         -s  try to generate sensitivity BG (experimental)'
1790
1791
1792
1793
1794
1795
1796







1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815




1816
1817
1818
1819
1820
1821
1822













1823
1824
1825
1826
1827
1828
1829
fi


if [ -n "$sensitivity" ]; then
  sys=`echo $1 | cut -c 2-`
  sys_abg=$sys"_abg"
fi








################################
# This is the main mtt programme
################################


##echo Target is $target, Subsystem is $Subsystem, options are $mtt_switches
$MAKE -S $verbose  -f  -  $target << EOF

# Cancel implicit rules I don't want
%.dvi: %.tex

# MTT implicit rules
## .oct files
ifneq ($2,ode2odes)
%.oct:  %.cc $1_def.h $1_sympar.h $1_cr.h
	echo Creating $1_$2.oct; $MKOCTFILE  $< 
endif






## .cc files
.PRECIOUS: %.cc # Don't let mtt delete them
ifneq ($2,ode2odes)
%.cc:  %.m
	mtt_m2cc.sh  $1 $2 cat 
endif














# Generates code to write reduce code
$1_ode_write.r: $1_def.m
	def2write_r  $1 $2

ifeq ("$sensitivity","sensitivity")
ifeq ("$level","0")







>
>
>
>
>
>
>














<
|
|
<

>
>
>
>



<
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>







1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846

1847
1848

1849
1850
1851
1852
1853
1854
1855
1856

1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
fi


if [ -n "$sensitivity" ]; then
  sys=`echo $1 | cut -c 2-`
  sys_abg=$sys"_abg"
fi

## Check octave version
if [ `octave --version | awk -F\. '{print $2}'` ]; then
    define_octave_dev="-DOCTAVE_DEV"
else
    define_octave_dev=""
fi

################################
# This is the main mtt programme
################################


##echo Target is $target, Subsystem is $Subsystem, options are $mtt_switches
$MAKE -S $verbose  -f  -  $target << EOF

# Cancel implicit rules I don't want
%.dvi: %.tex

# MTT implicit rules
## .oct files

$1_%.oct:  $1_%.cc $1_def.h $1_sympar.h $1_cr.h
	echo Creating $1_\$*.oct; $MKOCTFILE  $1_\$*.cc


.PRECIOUS: mtt_%.oct
mtt_%.oct: mtt_%.cc
	echo Compiling \$<
	${MKOCTFILE} $define_octave_dev \$<

## .cc files
.PRECIOUS: %.cc # Don't let mtt delete them

$1_%.cc:  $1_%.m
	mtt_m2cc.sh  $1 \$* cat 

mtt_%.cc: ${MTT_LIB}/cc/mtt_%.cc
	cp ${MTT_LIB}/cc/mtt_\$*.cc mtt_\$*.cc

## .o files
.PRECIOUS: $1_%.o
$1_%.o: $1_%.cc $1_def.h $1_sympar.h $1_cr.h
	echo Compiling $1_\$*.cc
	${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $< -DSTANDALONE

.PRECIOUS: mtt_%.o
mtt_%.o: mtt_%.cc
	echo Compiling mtt_\$*.cc
	${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $< -DSTANDALONE $define_octave_dev

# Generates code to write reduce code
$1_ode_write.r: $1_def.m
	def2write_r  $1 $2

ifeq ("$sensitivity","sensitivity")
ifeq ("$level","0")
2051
2052
2053
2054
2055
2056
2057































2058
2059
2060
2061
2062
2063
2064
	mtt_update $1 logic update
else
	mtt_update $1 logic
endif

# Dummy target
FORCE:
































#SUMMARY numpar	numerical parameter declaration (m) 
$1_numpar.m:  $1_numpar.txt $1_sympars.txt
	mtt_txt2m $1 numpar

#SUMMARY numpar	numerical parameter declaration (c) 
#SUMMARY numpar	numerical parameter declaration (view) 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
	mtt_update $1 logic update
else
	mtt_update $1 logic
endif

# Dummy target
FORCE:

$1_ode2odes_common.m    : $1_input.m   $1_logic.m   $1_numpar.m   $1_simpar.m   $1_state.m
	@echo > /dev/null
$1_ode2odes_common.cc   : $1_input.cc  $1_logic.cc  $1_numpar.cc  $1_simpar.cc  $1_state.cc
	@echo > /dev/null
$1_ode2odes_common.o    : $1_input.o   $1_logic.o   $1_numpar.o   $1_simpar.o   $1_state.o
	@echo "Creating $1_ode2odes_common.o"
	ar -cr \$@ \$^
$1_ode2odes_common.oct  : $1_input.oct $1_logic.oct $1_numpar.oct $1_simpar.oct $1_state.oct
	@echo > /dev/null

$1_ode2odes_euler.m  $1_ode2odes_rk4.m    : $1_ode.m     $1_odeo.m
	@echo > /dev/null
$1_ode2odes_euler.cc $1_ode2odes_rk4.cc   : $1_ode.cc    $1_odeo.cc
	@echo > /dev/null
$1_ode2odes_euler.o  $1_ode2odes_rk4.o    : $1_ode.o     $1_odeo.o   mtt_euler.o
	@echo "Creating \$@"
	ar -cr \$@ \$^
$1_ode2odes_euler.oct   : $1_ode.oct   $1_odeo.oct mtt_euler.oct
	@echo > /dev/null

$1_ode2odes_implicit.m  : $1_cseo.m    $1_csex.m   $1_smxa.m   $1_smxax.m
	@echo > /dev/null
$1_ode2odes_implicit.cc : $1_cseo.cc   $1_csex.cc  $1_smxa.cc  $1_smxax.cc
	@echo > /dev/null
$1_ode2odes_implicit.o  : $1_cseo.o    $1_csex.o   $1_smxa.o   $1_smxax.o   mtt_implicit.o
	@echo "Creating $1_ode2odes_implicit.o"
	ar -cr \$@ \$^
$1_ode2odes_implicit.oct: $1_cseo.oct  $1_csex.oct $1_smxa.oct $1_smxax.oct mtt_implicit.oct
	@echo > /dev/null


#SUMMARY numpar	numerical parameter declaration (m) 
$1_numpar.m:  $1_numpar.txt $1_sympars.txt
	mtt_txt2m $1 numpar

#SUMMARY numpar	numerical parameter declaration (c) 
#SUMMARY numpar	numerical parameter declaration (view) 
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
	touch $1_aliased.txt
$1_struc.tex: $1_struc.txt
	struc_txt2tex $1
$1_struc.m: $1_struc.txt 
	struc_txt2m $1
$1_def.m: $1_def.r
	def_r2m $1; matlab_tidy $1_def.m;
$1_def.h: $1_def.m
	def_m2h.sh $1

#SUMMARY rdae	raw differential-algebraic equations (r)
#SUMMARY dae	differential-algebraic equations (r)
#SUMMARY dae*	differential-algebraic equations (m)
#SUMMARY dae	differential-algebraic equations (tex)
#SUMMARY dae*	differential-algebraic equations (view)







|







2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
	touch $1_aliased.txt
$1_struc.tex: $1_struc.txt
	struc_txt2tex $1
$1_struc.m: $1_struc.txt 
	struc_txt2m $1
$1_def.m: $1_def.r
	def_r2m $1; matlab_tidy $1_def.m;
$1_def.h: $1_def.m $1_sympar.txt
	def_m2h.sh $1

#SUMMARY rdae	raw differential-algebraic equations (r)
#SUMMARY dae	differential-algebraic equations (r)
#SUMMARY dae*	differential-algebraic equations (m)
#SUMMARY dae	differential-algebraic equations (tex)
#SUMMARY dae*	differential-algebraic equations (view)
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363

2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383

2384
2385
2386
2387
2388
2389

























2390
2391
2392
2393
2394
2395
2396
# The main simulation programme
ifeq ($integration_method,implicit)
$1_ode2odes.m : $1_def.r $1_sympars.txt \
                $1_smxa.m $1_smxax.m\
                $1_simpar.m $1_numpar.m $1_state.m $1_input.m \
                $1_csex.m $1_cseo.m  $1_logic.m
ifeq ($using_oct,yes)
	mtt $mtt_switches -q -u $1 smxa oct
	mtt $mtt_switches -q -u $1 smxax oct
	mtt $mtt_switches -q -u $1 simpar oct
	mtt $mtt_switches -q -u $1 numpar oct
	mtt $mtt_switches -q -u $1 state oct
	mtt $mtt_switches -q -u $1 input oct
	mtt $mtt_switches -q -u $1 csex oct
	mtt $mtt_switches -q -u $1 cseo oct
	mtt $mtt_switches -q -u $1 logic oct
	make_ode2odes $1 cc $integration_method
	echo Creating $1_ode2odes.oct
	mkoctfile $1_ode2odes.cc
	touch $1_ode2odes.m # Create a dummy which wont' be used

else
	make_ode2odes $1 m $integration_method
endif
endif
ifeq ($integration_method,euler)
$1_ode2odes.m : $1_def.r $1_sympars.txt\
		$1_simpar.m $1_numpar.m $1_state.m $1_input.m \
		$1_ode.m $1_odeo.m  $1_logic.m
ifeq ($using_oct,yes)
	mtt $mtt_switches -q -u $1 simpar oct
	mtt $mtt_switches -q -u $1 numpar oct
	mtt $mtt_switches -q -u $1 state oct
	mtt $mtt_switches -q -u $1 input oct
	mtt $mtt_switches -q -u $1 ode oct
	mtt $mtt_switches -q -u $1 odeo oct
	mtt $mtt_switches -q -u $1 logic oct
	make_ode2odes $1 cc $integration_method
	echo Creating $1_ode2odes.oct
	mkoctfile $1_ode2odes.cc
	touch $1_ode2odes.m # Create a dummy which wont' be used

else
	make_ode2odes $1 m $integration_method
endif

endif



























#Conversion of m to p to c
#SUMMARY ode	ordinary differential equations (c)
#SUMMARY ode	ordinary differential equations (p)
#SUMMARY state	state declaration (c) 
#SUMMARY state	state declaration (p) 
$1_simpar.p : $1_def.r $1_simpar.m







<
<
<
<
<
<
<
<
<
<
<
<

>




|




<
<
<
<
<
<
<
<
<
|

>






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2425
2426
2427
2428
2429
2430
2431












2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442









2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
# The main simulation programme
ifeq ($integration_method,implicit)
$1_ode2odes.m : $1_def.r $1_sympars.txt \
                $1_smxa.m $1_smxax.m\
                $1_simpar.m $1_numpar.m $1_state.m $1_input.m \
                $1_csex.m $1_cseo.m  $1_logic.m
ifeq ($using_oct,yes)












	touch $1_ode2odes.m # Create a dummy which wont' be used
	mtt $mtt_switches -q -u $1 ode2odes oct
else
	make_ode2odes $1 m $integration_method
endif
endif
ifneq ($integration_method,implicit)
$1_ode2odes.m : $1_def.r $1_sympars.txt\
		$1_simpar.m $1_numpar.m $1_state.m $1_input.m \
		$1_ode.m $1_odeo.m  $1_logic.m
ifeq ($using_oct,yes)









	echo "*** Warning: Shouldn't be here! Creating dummy $1_ode2odes.m"
	touch $1_ode2odes.m # Create a dummy which wont' be used
	mtt $mtt_switches -q -u $1 ode2odes oct
else
	make_ode2odes $1 m $integration_method
endif

endif

#SUMMARY ode2odes Simulation function (m)
#SUMMARY ode2odes Simulation function (cc)
#SUMMARY ode2odes Simulation function (oct)
#SUMMARY ode2odes Simulation function (exe)
$1_ode2odes.exe: $1_def.h $1_sympar.h\
		 $1_ode2odes.o $1_ode2odes_common.o $1_ode2odes_${integration_method}.o
	echo Creating $1_ode2odes.exe
	${MTT_CXX} ${MTT_CXXFLAGS} -o $1_ode2odes.exe\
	$1_ode2odes.o $1_ode2odes_common.o $1_ode2odes_${integration_method}.o\
	${MTT_LDFLAGS} ${MTT_CXXLIBS}

$1_ode2odes.o: $1_ode2odes.cc $1_ode2odes_common.o $1_ode2odes_${integration_method}.o
	echo Creating $1_ode2odes.o
	${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $1_ode2odes.cc -DSTANDALONE

$1_ode2odes.oct: $1_ode2odes.cc $1_ode2odes_common.oct $1_ode2odes_${integration_method}.oct
	touch $1_ode2odes.m
	echo Creating $1_ode2odes.oct
	$MKOCTFILE $1_ode2odes.cc

$1_ode2odes.cc: $1_def.r $1_sympars.txt\
		$1_ode2odes_common.m $1_ode2odes_common.cc\
		$1_ode2odes_${integration_method}.m $1_ode2odes_${integration_method}.cc
	touch $1_ode2odes.m
	make_ode2odes $1 cc $integration_method

#Conversion of m to p to c
#SUMMARY ode	ordinary differential equations (c)
#SUMMARY ode	ordinary differential equations (p)
#SUMMARY state	state declaration (c) 
#SUMMARY state	state declaration (p) 
$1_simpar.p : $1_def.r $1_simpar.m
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441

ifeq ($integration_method,implicit)
$1_ode2odes.p : $1_ode2odes.m $1_def.r $1_smxa.p $1_smxax.p\
		$1_simpar.p $1_numpar.p $1_state.p $1_input.p \
		$1_csex.p $1_cseo.p  $1_logic.p
	mtt_m2p $1_ode2odes.m $integration_method $stdin
endif
ifeq ($integration_method,euler)
$1_ode2odes.p : $1_ode2odes.m $1_def.r\
		$1_simpar.p $1_numpar.p $1_state.p $1_input.p \
		$1_ode.p $1_odeo.p  $1_logic.p
	mtt_m2p $1_ode2odes.m $integration_method $stdin
endif

$1_ode2odes.c: $1_ode2odes.p 







|







2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528

ifeq ($integration_method,implicit)
$1_ode2odes.p : $1_ode2odes.m $1_def.r $1_smxa.p $1_smxax.p\
		$1_simpar.p $1_numpar.p $1_state.p $1_input.p \
		$1_csex.p $1_cseo.p  $1_logic.p
	mtt_m2p $1_ode2odes.m $integration_method $stdin
endif
ifneq ($integration_method,implicit)
$1_ode2odes.p : $1_ode2odes.m $1_def.r\
		$1_simpar.p $1_numpar.p $1_state.p $1_input.p \
		$1_ode.p $1_odeo.p  $1_logic.p
	mtt_m2p $1_ode2odes.m $integration_method $stdin
endif

$1_ode2odes.c: $1_ode2odes.p 
2728
2729
2730
2731
2732
2733
2734




2735
2736

2737
2738
2739
2740
2741
2742
2743
	m2dat $1_sro
1_odes.c: $1_ode.c $1_def.r $1_sympar.r
	ode2odes_r2c $1 
$1_sms.c: $1_sm.c $1_def.r $1_sympar.r
	sm2sms_r2c $1

ifeq ($computation,octave)




$1_odes.dat2: $1_ode2odes.m
	time octave_ode2odes $1

endif

ifeq ($computation,c)
$1_ode2odes.out: $1_ode2odes.c
	echo Creating $1_odes.out
	$CC $1_ode2odes.c -lp2c -lm -o $1_ode2odes.out








>
>
>
>


>







2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
	m2dat $1_sro
1_odes.c: $1_ode.c $1_def.r $1_sympar.r
	ode2odes_r2c $1 
$1_sms.c: $1_sm.c $1_def.r $1_sympar.r
	sm2sms_r2c $1

ifeq ($computation,octave)
ifeq ($using_oct,yes)
$1_odes.dat2: $1_ode2odes.oct
	time octave_ode2odes $1
else
$1_odes.dat2: $1_ode2odes.m
	time octave_ode2odes $1
endif
endif

ifeq ($computation,c)
$1_ode2odes.out: $1_ode2odes.c
	echo Creating $1_odes.out
	$CC $1_ode2odes.c -lp2c -lm -o $1_ode2odes.out

Modified mttroot/mtt/bin/mtt_check_vars from [65d9a8cff0] to [f001c2c57d].

11
12
13
14
15
16
17



18
19
20
21
22
23
24


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.7  2000/08/04 15:48:30  peterg
## Added PDF
##
## Revision 1.6  2000/05/22 12:37:24  peterg
## *** empty log message ***
##
## Revision 1.5  2000/05/22 12:34:07  peterg







>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.8  2000/12/27 13:11:42  peterg
## *** empty log message ***
##
## Revision 1.7  2000/08/04 15:48:30  peterg
## Added PDF
##
## Revision 1.6  2000/05/22 12:37:24  peterg
## *** empty log message ***
##
## Revision 1.5  2000/05/22 12:34:07  peterg
71
72
73
74
75
76
77
78





79
80
mtt_check_var "$FIG" "FIG" "$print" "MTT"
mtt_check_var "$PSVIEW" "PSVIEW" "$print" "MTT"
mtt_check_var "$PDFVIEW" "PDFVIEW" "$print" "MTT"
mtt_check_var "$HTMLVIEW" "HTMLVIEW" "$print" "MTT"
mtt_check_var "$DVIVIEW" "DVIVIEW" "$print" "MTT"
mtt_check_var "$CC" "CC" "$print" "MTT"
mtt_check_var "$LATEX2HTML" "LATEX2HTML" "$print" "MTT"















|
>
>
>
>
>


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
mtt_check_var "$FIG" "FIG" "$print" "MTT"
mtt_check_var "$PSVIEW" "PSVIEW" "$print" "MTT"
mtt_check_var "$PDFVIEW" "PDFVIEW" "$print" "MTT"
mtt_check_var "$HTMLVIEW" "HTMLVIEW" "$print" "MTT"
mtt_check_var "$DVIVIEW" "DVIVIEW" "$print" "MTT"
mtt_check_var "$CC" "CC" "$print" "MTT"
mtt_check_var "$LATEX2HTML" "LATEX2HTML" "$print" "MTT"
mtt_check_var "$MKOCTFILE" "MKOCTFILE" "$print" "MTT"
mtt_check_var "$MTT_CXX" "MTT_CXX" "$print" "MTT"
mtt_check_var "$MTT_CXXFLAGS" "MTT_CXXFLAGS" "$print" "MTT"
mtt_check_var "$MTT_CXXLIBS" "MTT_CXXLIBS" "$print" "MTT"
mtt_check_var "$MTT_CXXINCS" "MTT_CXXINCS" "$print" "MTT"
mtt_check_var "$MTT_LDFLAGS" "MTT_LDFLAGS" "$print" "MTT"


Modified mttroot/mtt/bin/mttrc from [7b899869da] to [3ae226d26c].

11
12
13
14
15
16
17













18
19
20
21
22
23
24


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$













## Revision 1.16  2000/12/27 15:16:44  peterg
## If then else format
##
## Revision 1.15  2000/12/27 14:57:43  peterg
## Now takes the base path as an argument
##
## Revision 1.14  2000/12/27 13:11:43  peterg







>
>
>
>
>
>
>
>
>
>
>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37


###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.17.2.3  2001/03/01 05:05:53  geraint
## Minor revisions.
##
## Revision 1.17.2.2  2001/02/23 03:53:53  geraint
## Minor revisions. (ode2odes.exe works on GNU/Linux and ~GNU/Irix)
##
## Revision 1.17.2.1  2001/02/22 06:41:40  geraint
## Initial merge of ode2odes.exe into main mtt.
## standalone_rep.make deleted: rules moved to mtt, variables to mttrc.
##
## Revision 1.17  2000/12/27 16:46:13  peterg
## Stripped the mtt- from paths
##
## Revision 1.16  2000/12/27 15:16:44  peterg
## If then else format
##
## Revision 1.15  2000/12/27 14:57:43  peterg
## Now takes the base path as an argument
##
## Revision 1.14  2000/12/27 13:11:43  peterg
130
131
132
133
134
135
136








































137
  export LATEX2HTML="latex2html -contents_in_navigation -index_in_navigation -address http://mtt.sourceforge.net"
  
  # Ascend stuff
  export ASCENDLIBRARY=$MTTPATH/ascend/lib
  
  # Oct file generation - use version with no optimisation.
  export MKOCTFILE=$MTT_LIB/octave/mkoctfile








































fi







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
  export LATEX2HTML="latex2html -contents_in_navigation -index_in_navigation -address http://mtt.sourceforge.net"
  
  # Ascend stuff
  export ASCENDLIBRARY=$MTTPATH/ascend/lib
  
  # Oct file generation - use version with no optimisation.
  export MKOCTFILE=$MTT_LIB/octave/mkoctfile

  # ode2odes.exe stuff

    # local system

    PLAT="i686-pc-linux-gnu"
    PREFIX="/usr/local"
    GCCVERS="2.95.2"
    SRCOCTAVE="/cvs/octave"

#    PLAT="mips-sgi-irix6.5"
#    PREFIX="/usr/people/bevangp/GNU"
#    GCCVERS="2.95.2"
#    SRCOCTAVE="${PREFIX}/../build/octave-2.1.33"

    # include paths

    IOCTAVE="-I${PREFIX}/include/octave"

    # library paths

    LOCTAVE="-L${PREFIX}/lib/octave -loctave -lcruft -loctinterp"
    LKPATHSEA="-L${SRCOCTAVE}/kpathsea -lkpathsea"
    LREADLINE=" -L${SRCOCTAVE}/readline -lreadline"
    LSYSTEM="-ldl -lm -lncurses"
    LF2C="-L${PREFIX}/lib/gcc-lib/${PLAT}/${GCCVERS} -lg2c"

    # compiler options

    DEBUG="-g"
    OPTIM="-O3"
    FLAGS="-fno-rtti -fno-exceptions -fno-implicit-templates"

    # exported variables

    export MTT_CXX="g++"
    export MTT_CXXFLAGS="${DEBUG} ${OPTIM} ${FLAGS}"
    export MTT_CXXLIBS="${LOCTAVE} ${LKPATHSEA} ${LREADLINE} ${LF2C} ${LSYSTEM}"
    export MTT_CXXINCS="-I. ${IOCTAVE}"
    export MTT_LDFLAGS=" "
fi

Modified mttroot/mtt/bin/trans/dae2cse_r from [14e2313fd2] to [8fd15b37a6].

11
12
13
14
15
16
17



18
19
20
21
22
23
24
# Copyright (c) P.J.Gawthrop 1991, 1992, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.13  2000/10/11 08:52:46  peterg
## Creates csex (cse with dxe only) rep.
##
## Revision 1.12  2000/10/10 21:00:58  peterg
## New code genration
##
## Revision 1.11  1998/11/26 09:18:55  peterg







>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Copyright (c) P.J.Gawthrop 1991, 1992, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.14  2000/12/28 12:24:35  peterg
## *** empty log message ***
##
## Revision 1.13  2000/10/11 08:52:46  peterg
## Creates csex (cse with dxe only) rep.
##
## Revision 1.12  2000/10/10 21:00:58  peterg
## New code genration
##
## Revision 1.11  1998/11/26 09:18:55  peterg
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89





90
91
92
93
94
95
96
## Sorted out bug when MTTNz=0
##
## Revision 1.1  1996/08/15 16:47:02  peter
## Initial revision
##
###############################################################

# Create the reduce output code
def2write_r $1 cse      
def2write_r $1 csex  # Version without E matrix
def2write_r $1 cseo

#Explicit solution option
solve=0
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
        -A )
                solve=1;;
        *)
                echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done






if [ "$solve" = "1" ]; then
    echo "Creating $1_cse.r (with explicit solution of algebraic equations)"
else
    echo "Creating $1_cse.r"
fi








<
<
<
<
<











>
>
>
>
>







70
71
72
73
74
75
76





77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
## Sorted out bug when MTTNz=0
##
## Revision 1.1  1996/08/15 16:47:02  peter
## Initial revision
##
###############################################################






#Explicit solution option
solve=0
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
        -A )
                solve=1;;
        *)
                echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

# Create the reduce output code
def2write_r $1 cse      
def2write_r $1 csex  # Version without E matrix
def2write_r $1 cseo

if [ "$solve" = "1" ]; then
    echo "Creating $1_cse.r (with explicit solution of algebraic equations)"
else
    echo "Creating $1_cse.r"
fi

375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392






393
394
395
396
397
touch $1_cseo.r1
touch $1_cseo.r2
cat $1_cse.r1 $1_cse.r2  > $1_cse.r
cat $1_csex.r1 $1_csex.r2  > $1_csex.r
cat $1_cseo.r1 $1_cseo.r2  > $1_cseo.r

if [ "$solve" = "1" ]; then
    echo "Setting MTTNyz=0 in $1_def.r and removing other $1_def files"
    awk '{
     if ($1=="MTTNyz") 
       print "MTTNyz := 0;" 
     else print $0
    }' $1_def.r > mtt_junk
  # Make sure it preserves the time stamp!!
  # and remove dependent reps
   touch -r $1_def.r mtt_junk
   rm $1_def.*
   mv mtt_junk $1_def.r






fi


# Now invoke the standard error handling.
mtt_error_r dae2cse_r.log







|








<

>
>
>
>
>
>





378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393

394
395
396
397
398
399
400
401
402
403
404
405
touch $1_cseo.r1
touch $1_cseo.r2
cat $1_cse.r1 $1_cse.r2  > $1_cse.r
cat $1_csex.r1 $1_csex.r2  > $1_csex.r
cat $1_cseo.r1 $1_cseo.r2  > $1_cseo.r

if [ "$solve" = "1" ]; then
    echo "Setting MTTNyz=0 in $1_def.r and updating other $1_def files"
    awk '{
     if ($1=="MTTNyz") 
       print "MTTNyz := 0;" 
     else print $0
    }' $1_def.r > mtt_junk
  # Make sure it preserves the time stamp!!
  # and remove dependent reps
   touch -r $1_def.r mtt_junk

   mv mtt_junk $1_def.r
   for file in `ls $1_def.*`; do
      if [ $file != $1_def.r ]; then
          ext=`echo $file|awk -F\. '{print $2}'`
          mtt -q $1 def $ext
      fi
   done
fi


# Now invoke the standard error handling.
mtt_error_r dae2cse_r.log

Modified mttroot/mtt/bin/trans/m/args2arg.m from [88e206959b] to [b6ee5ada28].

24
25
26
27
28
29
30
31






















% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Field separator
if nargin<3
  FS = ';';
end;































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Field separator
if nargin<3
  FS = ';';
end;

arg = '';
if strcmp(args, '')==0
  L = length(args);
  args_count = 0;
  for i=1:n
    arg_count = 0;
    arg = '';
    if args_count == L
      break;
    end;  
    while args_count < L
      args_count = args_count+1;
      arg_count = arg_count+1;
      ch = str2ch(args,args_count);
      if ch==FS
	break;
      end;
      arg = [arg ch];
    end;
  end;
end;

Modified mttroot/mtt/bin/trans/make_ode2odes from [9dc2d47b21] to [1a5aa47365].

1
2
3
4
5
6
7
8
9
10
11
























12
13
14
15
16
17
18
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
    ######################################

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
























## Revision 1.50  2001/02/18 09:18:49  geraint
## Removed temporary Matrices from mtt_implicit.cc
##
## Revision 1.49  2001/02/14 06:06:34  geraint
## Removed octave_value_list wrappers from standalone.exe - speed improvements
##
## Revision 1.48  2001/02/11 07:08:59  geraint











>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
    ######################################

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.51.2.6  2001/03/16 03:56:13  geraint
## Removed psignal/siginfo.h - problematic and unnecessary.
##
## Revision 1.51.2.5  2001/03/12 23:16:37  geraint
## Minor improvements to signal handling (.exe).
##
## Revision 1.51.2.4  2001/03/12 03:59:30  geraint
## SIGINT  (C-c C-c) now causes simulation data to be dumped to MTT.core.
## SIGQUIT (C-c C-\) as for SIGINT, then raises default SIGQUIT.
## SIGFPE  as for SIGINT, then raises default SIGABRT.
##
## Revision 1.51.2.3  2001/03/07 04:06:55  geraint
## Irix: catch SIGFPE and write data before aborting (.exe).
## GNU/Linux: nada.
##
## Revision 1.51.2.2  2001/03/02 00:45:21  geraint
## Separated Euler and Implicit methods in .cc code and dependencies.
##
## Revision 1.51.2.1  2001/03/01 05:05:53  geraint
## Minor revisions.
##
## Revision 1.51  2001/02/19 06:33:19  geraint
## Removed operation form loop.
##
## Revision 1.50  2001/02/18 09:18:49  geraint
## Removed temporary Matrices from mtt_implicit.cc
##
## Revision 1.49  2001/02/14 06:06:34  geraint
## Removed octave_value_list wrappers from standalone.exe - speed improvements
##
## Revision 1.48  2001/02/11 07:08:59  geraint
231
232
233
234
235
236
237












238
239

240
241
242
243
244
245
246
  mttj = 0;
    for it = 1:ilast		#Integration loop
    [u] = ${sys}_input(x,y,t,par);	# Input
    [y] = ${sys}_$odeo(x,u,t,par);  # Output 
    if mttj==0
     mtt_write(t,x,y,$Nx,$Ny);   # Write it out
    endif












    [dx] = ${sys}_$ode(x,u,t,par);	# State derivative
EOF


if [ "$method" = "implicit" ]; then
cat<< EOF >> $filename

    [AA] = ${sys}_smxa(x,u,ddt,par);	# (I-Adt) and (I-Adt)x
    [AAx] = ${sys}_smxax(x,u,ddt,par); # (I-Adt) and (I-Adt)x








>
>
>
>
>
>
>
>
>
>
>
>


>







255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
  mttj = 0;
    for it = 1:ilast		#Integration loop
    [u] = ${sys}_input(x,y,t,par);	# Input
    [y] = ${sys}_$odeo(x,u,t,par);  # Output 
    if mttj==0
     mtt_write(t,x,y,$Nx,$Ny);   # Write it out
    endif
EOF

if [ "$method" = "rk4" ]; then
cat << EOF >> $filename
    [k1] = ddt * ${sys}_${ode}(x,u,t,par);
    [k2] = ddt * ${sys}_${ode}(x+k1/2,u,t+ddt/2,par);
    [k3] = ddt * ${sys}_${ode}(x+k2/2,u,t+ddt/2,par);
    [k4] = ddt * ${sys}_${ode}(x+k3,u,t+ddt,par);
    [dx] = [k1 + 2.0 * [k2 + k3] + k4] / (6.0 * ddt);
EOF
else
cat << EOF >> $filename
    [dx] = ${sys}_$ode(x,u,t,par);	# State derivative
EOF
fi

if [ "$method" = "implicit" ]; then
cat<< EOF >> $filename

    [AA] = ${sys}_smxa(x,u,ddt,par);	# (I-Adt) and (I-Adt)x
    [AAx] = ${sys}_smxax(x,u,ddt,par); # (I-Adt) and (I-Adt)x

278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296



297
298
299
300
301
302
303
304
305
306
307
308
309


310




311
312
313
314
315
316
317
318
319
320
321
322
323
324



325
326
327
328

329
330



331


332
333
334

335

336
337
338
339
340
341
342
343
344
345
346
347
348








349

350
351













352
353
354
355
356











357
358













































359
360
361
362
363
364
365
    vector_value=vector_value
    feval_header=toplev.h
fi

cat <<EOF  > $filename
#include <octave/oct.h>
#include <octave/ov-struct.h>
#include <octave/oct-map.h>
#include <octave/lo-mappers.h>
#include <octave/variables.h>

#ifndef STANDALONE
#include <octave/${feval_header}>
#endif

#include "${sys}_def.h"
#include "${sys}_sympar.h"

#ifdef STANDALONE



extern ColumnVector Fmtt_euler (
	ColumnVector &x,
	const ColumnVector &dx,
	const double &ddt,
	const int &nx,
	const ColumnVector &open_switches);
 
extern ColumnVector Fmtt_implicit (
	ColumnVector &x,
	ColumnVector &dx,
	Matrix &AA,
	ColumnVector &AAx,
	const double &ddt,


	const int &nx,




	const ColumnVector &open_switches);

extern ColumnVector F${sys}_${ode} (
	ColumnVector &x,
	ColumnVector &u,
	const double &t,
	ColumnVector &par);

extern ColumnVector F${sys}_${odeo} (
	ColumnVector &x,
	ColumnVector &u,
	const double &t,
	ColumnVector &par);




extern ColumnVector F${sys}_input (
	ColumnVector &x,
	ColumnVector &y,
	const double &t,

	ColumnVector &par);




extern ColumnVector F${sys}_numpar (


	void);

extern Octave_map F${sys}_simpar (

     	void);


extern Matrix F${sys}_smxa (
	ColumnVector &x,
	ColumnVector &u,
	const double &t,
	ColumnVector &par);

extern ColumnVector F${sys}_smxax (
	ColumnVector &x,
	ColumnVector &u,
	const double &t,
	ColumnVector &par);
 








extern ColumnVector F${sys}_state (

	ColumnVector &x);














extern ColumnVector F${sys}_logic (
	ColumnVector &x,
	ColumnVector &u,
	const double &t,
	ColumnVector &par);











#endif // STANDALONE















































inline ColumnVector
mtt_${ode} (ColumnVector &x,
	    ColumnVector &u,
	    const double &t,
	    ColumnVector &par)
{







|











>
>
>
|

|
|
<
|
|
|

|
|
|
|
>
>
|
>
>
>
>
|













>
>
>
|

|
|
>
|
|
>
>
>
|
>
>
|
|
<
>
|
>













>
>
>
>
>
>
>
>
|
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340

341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387

388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
    vector_value=vector_value
    feval_header=toplev.h
fi

cat <<EOF  > $filename
#include <octave/oct.h>
#include <octave/ov-struct.h>
#include <octave/load-save.h>
#include <octave/lo-mappers.h>
#include <octave/variables.h>

#ifndef STANDALONE
#include <octave/${feval_header}>
#endif

#include "${sys}_def.h"
#include "${sys}_sympar.h"

#ifdef STANDALONE
#include <csignal>
#include <fstream>

extern ColumnVector F${sys}_input (
	ColumnVector &x,
	ColumnVector &y,
	const double &t,

	ColumnVector &par);

extern ColumnVector F${sys}_logic (
	ColumnVector &x,
	ColumnVector &u,
	const double &t,
	ColumnVector &par);

extern ColumnVector F${sys}_numpar (
	void);

extern Octave_map F${sys}_simpar (
     	void);

extern ColumnVector F${sys}_state (
	ColumnVector &x);

extern ColumnVector F${sys}_${ode} (
	ColumnVector &x,
	ColumnVector &u,
	const double &t,
	ColumnVector &par);

extern ColumnVector F${sys}_${odeo} (
	ColumnVector &x,
	ColumnVector &u,
	const double &t,
	ColumnVector &par);

EOF
if [ "$method" != "implicit" ]; then
cat <<EOF >> $filename
extern ColumnVector Fmtt_euler (
	ColumnVector &x,
	const ColumnVector &dx,
	const double &ddt,
	const int &nx,
	const ColumnVector &open_switches);
 
EOF
else
cat <<EOF >> $filename
extern ColumnVector Fmtt_implicit (
	ColumnVector &x,
	ColumnVector &dx,
	Matrix &AA,
	ColumnVector &AAx,

	const double &ddt,
	const int &nx,
	const ColumnVector &open_switches);

extern Matrix F${sys}_smxa (
	ColumnVector &x,
	ColumnVector &u,
	const double &t,
	ColumnVector &par);

extern ColumnVector F${sys}_smxax (
	ColumnVector &x,
	ColumnVector &u,
	const double &t,
	ColumnVector &par);
 
EOF
fi
cat <<EOF >> $filename
#endif // STANDALONE


inline ColumnVector
mtt_input (ColumnVector &x,
	   ColumnVector &y,
	   const double &t,
	   ColumnVector &par)
{
#ifdef STANDALONE
  return F${sys}_input (x, y, t, par);
#else
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (y);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_input", args, 1);
  return f(0).${vector_value} ();
#endif
}

inline ColumnVector
mtt_logic (ColumnVector &x,
	   ColumnVector &u,
	   const double &t,
	   ColumnVector &par)
{
#ifdef STANDALONE
  return F${sys}_logic (x, u, t, par);
#else
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (u);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_logic", args, 1);
  return f(0).${vector_value} ();
#endif
}

inline ColumnVector
mtt_numpar (void)
{
#ifdef STANDALONE
  return F${sys}_numpar ();
#else
  static octave_value_list args, f;
  f = feval ("${sys}_numpar", args, 1);
  return f(0).${vector_value} ();
#endif
}

inline Octave_map
mtt_simpar (void)
{
#ifdef STANDALONE
  return F${sys}_simpar ();
#else
  static octave_value_list args;
  static Octave_map f;
  f["first"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["first"];
  f["dt"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["dt"];
  f["last"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["last"];
  f["stepfactor"]     	= feval ("${sys}_simpar", args, 1)(0).map_value ()["stepfactor"];
  f["wmin"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["wmin"];
  f["wmax"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["wmax"];
  f["wsteps"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["wsteps"];
  f["input"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["input"];
  return (f);
#endif
}

inline ColumnVector
mtt_state (ColumnVector &x)
{
#ifdef STANDALONE
  return F${sys}_state (x);
#else
  static octave_value_list args, f;
  args (0) = octave_value (x);
  f = feval ("${sys}_state", args, 1);
  return f(0).${vector_value} ();
#endif
}

inline ColumnVector
mtt_${ode} (ColumnVector &x,
	    ColumnVector &u,
	    const double &t,
	    ColumnVector &par)
{
391
392
393
394
395
396
397



























398
399
400
401
402
403
404
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_${odeo}", args, 1);
  return f(0).${vector_value} ();
#endif
}




























inline ColumnVector
mtt_implicit (ColumnVector &x,
	      ColumnVector &dx,
	      Matrix &AA,
	      ColumnVector &AAx,
	      const double &ddt,
	      const int &nx,







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_${odeo}", args, 1);
  return f(0).${vector_value} ();
#endif
}

EOF
if [ "$method" != "implicit" ];then
cat <<EOF >> $filename
inline ColumnVector
mtt_euler (ColumnVector &x,
	   const ColumnVector &dx,
	   const double &ddt,
	   const int &nx,
	   const ColumnVector &open_switches)
{
#ifdef STANDALONE
  return Fmtt_euler (x, dx, ddt, nx, open_switches);
#else
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (dx);
  args (2) = octave_value (ddt);
  args (3) = octave_value ((double)nx);
  args (4) = octave_value (open_switches);
  f = feval ("mtt_euler", args, 1);
  return f(0).${vector_value} ();
#endif
}

EOF
else
cat <<EOF >> $filename
inline ColumnVector
mtt_implicit (ColumnVector &x,
	      ColumnVector &dx,
	      Matrix &AA,
	      ColumnVector &AAx,
	      const double &ddt,
	      const int &nx,
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
  args (5) = octave_value ((double)nx);
  args (6) = octave_value (open_switches);
  f = feval ("mtt_implicit", args, 1);
  return f(0).${vector_value} ();
#endif
}

inline ColumnVector
mtt_euler (ColumnVector &x,
	   const ColumnVector &dx,
	   const double &ddt,
	   const int &nx,
	   const ColumnVector &open_switches)
{
#ifdef STANDALONE
  return Fmtt_euler (x, dx, ddt, nx, open_switches);
#else
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (dx);
  args (2) = octave_value (ddt);
  args (3) = octave_value ((double)nx);
  args (4) = octave_value (open_switches);
  f = feval ("mtt_euler", args, 1);
  return f(0).${vector_value} ();
#endif
}

inline ColumnVector
mtt_input (ColumnVector &x,
	   ColumnVector &y,
	   const double &t,
	   ColumnVector &par)
{
#ifdef STANDALONE
  return F${sys}_input (x, y, t, par);
#else
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (y);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_input", args, 1);
  return f(0).${vector_value} ();
#endif
}

inline ColumnVector
mtt_numpar (void)
{
#ifdef STANDALONE
  return F${sys}_numpar ();
#else
  static octave_value_list args, f;
  f = feval ("${sys}_numpar", args, 1);
  return f(0).${vector_value} ();
#endif
}

inline Octave_map
mtt_simpar (void)
{
#ifdef STANDALONE
  return F${sys}_simpar ();
#else
  static octave_value_list args;
  static Octave_map f;
  f["first"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["first"];
  f["dt"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["dt"];
  f["last"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["last"];
  f["stepfactor"]     	= feval ("${sys}_simpar", args, 1)(0).map_value ()["stepfactor"];
  f["wmin"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["wmin"];
  f["wmax"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["wmax"];
  f["wsteps"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["wsteps"];
  f["input"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["input"];
  return (f);
#endif
}

inline Matrix
mtt_smxa (ColumnVector &x,
	  ColumnVector &u,
	  const double &t,
	  ColumnVector &par)
{
#ifdef STANDALONE







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







576
577
578
579
580
581
582








































































583
584
585
586
587
588
589
  args (5) = octave_value ((double)nx);
  args (6) = octave_value (open_switches);
  f = feval ("mtt_implicit", args, 1);
  return f(0).${vector_value} ();
#endif
}









































































inline Matrix
mtt_smxa (ColumnVector &x,
	  ColumnVector &u,
	  const double &t,
	  ColumnVector &par)
{
#ifdef STANDALONE
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570


571
572
573








574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589

590

591
592
593
594
595
596
597
598











































599

600
601
602
603
604
605
606
607
608
609
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_smxax", args, 1);
  return f(0).${vector_value} ();
#endif
}

inline ColumnVector
mtt_state (ColumnVector &x)
{
#ifdef STANDALONE
  return F${sys}_state (x);
#else
  static octave_value_list args, f;
  args (0) = octave_value (x);
  f = feval ("${sys}_state", args, 1);
  return f(0).${vector_value} ();
#endif
}

inline ColumnVector
mtt_logic (ColumnVector &x,
	   ColumnVector &u,
	   const double &t,
	   ColumnVector &par)
{
#ifdef STANDALONE
  return F${sys}_logic (x, u, t, par);
#else
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (u);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_logic", args, 1);
  return f(0).${vector_value} ();
#endif
}


inline void
mtt_write (const double &t,
	   ColumnVector &x,
	   ColumnVector &y,
	   const int &nrows)


{
  static Matrix data;
  static int row;








  const int nx = x.length (), ny = y.length ();
  register int col = 0;

  if (0 == row)
    data = Matrix (nrows, 1+ny+1+nx, 0.0);

  data.elem (row, col) = t;
  for (register int i = 0; i < ny; i++)
    data.elem (row, ++col) = y.elem (i);
  data.elem (row, ++col) = t;
  for (register int i = 0; i < nx; i++)
    data.elem (row, ++col) = x.elem (i);

  row++;

  if (nrows == row)

#ifdef STANDALONE

    cout << data << endl;
#else // ! STANDALONE
  set_global_value ("MTT_data", data);
#endif

}

#ifdef STANDALONE











































int main (void) {

#else
DEFUN_DLD (${sys}_ode2odes, args, ,
"Octave ode2odes representation of system 
Usage: ${sys}_ode2odes (x, par, simpar)
")
{
  static octave_value_list retval;
#endif // STANDALONE
  static ColumnVector	x;
  static ColumnVector	par;







<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
|





|
>
>



>
>
>
>
>
>
>
>
















>

>
|



|



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>


|







614
615
616
617
618
619
620












621
















622

623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
  args (2) = octave_value (t);
  args (3) = octave_value (par);
  f = feval ("${sys}_smxax", args, 1);
  return f(0).${vector_value} ();
#endif
}













EOF
















fi

cat <<EOF >> $filename

inline void
mtt_write (const double &t,
	   ColumnVector &x,
	   ColumnVector &y,
	   const int &nrows,
	   const bool dump_data = false,
	   ostream &file = cout)
{
  static Matrix data;
  static int row;

  if (dump_data)
    {
       Matrix written_data = data.extract (0, 0, row-1, data.cols ()-1);
       save_ascii_data_for_plotting (file, written_data, "MTT_data");
       return;
    }

  const int nx = x.length (), ny = y.length ();
  register int col = 0;

  if (0 == row)
    data = Matrix (nrows, 1+ny+1+nx, 0.0);

  data.elem (row, col) = t;
  for (register int i = 0; i < ny; i++)
    data.elem (row, ++col) = y.elem (i);
  data.elem (row, ++col) = t;
  for (register int i = 0; i < nx; i++)
    data.elem (row, ++col) = x.elem (i);

  row++;

  if (nrows == row)
    {
#ifdef STANDALONE
      save_ascii_data_for_plotting (file, data, "MTT_data");
//    cout << data << endl;
#else // ! STANDALONE
  set_global_value ("MTT_data", data);
#endif
    }
}

#ifdef STANDALONE
void dump_data (ostream &file)
{
  ColumnVector null (0.0);
  mtt_write (0.0, null, null, 0, true, file);
}

void set_signal_handlers (void);

void handle_signal (int signum)
{
  // handle some signals to ensure data is written.
  cerr << "# Writing data to MTT.core (signal " << signum << ")" << endl;
  ofstream corefile ("MTT.core");
  dump_data (corefile);
  switch (signum)
    {
      case SIGFPE:
        // Intel chips do not raise SIGFPE for DIVZERO :-(
        raise (SIGABRT);
        break;
      case SIGINT:
	break;
      case SIGQUIT:
	signal (SIGQUIT, SIG_DFL);
	raise (SIGQUIT);
	break;
      default:
        cerr << "# Warning: make_ode2odes needs updating!" << endl;
	signal (signum, SIG_DFL);
	raise (signum);
        break;
    }
  corefile.close ();
  set_signal_handlers ();
}

void set_signal_handlers (void)
{
  signal (SIGFPE,	handle_signal);
  signal (SIGINT,	handle_signal);
  signal (SIGQUIT,	handle_signal);
}

int main (void) {
  set_signal_handlers ();
#else
DEFUN_DLD (${sys}_ode2odes, args, ,
"Octave ode2odes representation of system with $method integration method
Usage: ${sys}_ode2odes (x, par, simpar)
")
{
  static octave_value_list retval;
#endif // STANDALONE
  static ColumnVector	x;
  static ColumnVector	par;
667
668
669
670
671
672
673





674
675
676
677
678
679
680
681
682




























683
684

685
686
687
688
689
690
691
  static ColumnVector	open_switches (MTTNX);

  register double t	= 0.0;

  const double	ddt	= dt / stepfactor;
  const int	ilast	= static_cast<int> (round ((last - first) / ddt)) + 1;
  const int	nrows	= static_cast<int> (round ((last - first) / dt)) + 1;






  for (register int j = 0, i = 1; i <= ilast; i++)
    {
      y	= mtt_${odeo} (x, u, t, par);
      u	= mtt_input (x, y, t, par);
      if (0 == j)
	{
           mtt_write (t, x, y, nrows);
	}




























      dx = mtt_${ode} (x, u, t, par);
EOF


if [ "$method" = "implicit" ]; then
cat <<EOF >> $filename

      AA = mtt_smxa (x, u, ddt, par);
      AAx = mtt_smxax (x, u, ddt, par);
EOF







>
>
>
>
>









>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


>







782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
  static ColumnVector	open_switches (MTTNX);

  register double t	= 0.0;

  const double	ddt	= dt / stepfactor;
  const int	ilast	= static_cast<int> (round ((last - first) / ddt)) + 1;
  const int	nrows	= static_cast<int> (round ((last - first) / dt)) + 1;

  for (register int i = 0; i < MTTNU; i++)
    {
      u (i) = 0.0;
    }

  for (register int j = 0, i = 1; i <= ilast; i++)
    {
      y	= mtt_${odeo} (x, u, t, par);
      u	= mtt_input (x, y, t, par);
      if (0 == j)
	{
           mtt_write (t, x, y, nrows);
	}
EOF
if [ "$method" = "rk4" ]; then
cat << EOF >> $filename
      {
        static ColumnVector
          k1 (MTTNX,0.0),
          k2 (MTTNX,0.0),
          k3 (MTTNX,0.0),
          k4 (MTTNX,0.0);

        const double
          t1 = t + ddt/2.0,
          t2 = t + ddt;

        ColumnVector
          x1 (x),
          x2 (x),
          x3 (x);

        k1 = ddt * mtt_${ode} (x , u, t , par); x1 += k1 * 0.5;
        k2 = ddt * mtt_${ode} (x1, u, t1, par); x2 += k2 * 0.5;
        k3 = ddt * mtt_${ode} (x2, u, t1, par); x3 += k3;
        k4 = ddt * mtt_${ode} (x3, u, t2, par);
        dx = (k1 + 2.0 * (k2 + k3) + k4) / (6.0 * ddt);
      }
EOF
else
cat << EOF >> $filename
      dx = mtt_${ode} (x, u, t, par);
EOF
fi

if [ "$method" = "implicit" ]; then
cat <<EOF >> $filename

      AA = mtt_smxa (x, u, ddt, par);
      AAx = mtt_smxax (x, u, ddt, par);
EOF

Added mttroot/mtt/bin/trans/struc_txt2m version [da921fb492].





























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: struc_txt2m

# Structure file - txt to m conversion
# P.J.Gawthrop April 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################



# Inform user
echo "Creating $1_struc.m"

rm -f mtt_error

#Write some file headers
echo "function [input_name,output_name,state_name] = $1_struc" > $1_struc.m
echo "%% Structure file ($1_struc.m)" >> $1_struc.m
echo "%% Generated by MTT at `date`" >> $1_struc.m

# This is the main transformation using awk
awk '
function header(what){
  print what "_name = [";
}

function footer(what){
  print "];";
}

BEGIN{
Which="";
apostrophe = "\047";
}
{
  if ($1!=Which) {
    if (Which!="") footer(Which);
    header($1);
  }
  print  apostrophe $4 "_" $3 apostrophe;
  Which = $1;
}
END{
  footer(Which)
}
'  SYSTEM=$1  < $1_struc.txt >> $1_struc.m 2>mtt_error.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt


Modified mttroot/mtt/cc/Makefile from [10f25bc91c] to [873ef71cfa].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
	mkoctfile $<
endif



all:	$(sys)_$(rep).cc

parser: parse_m2cc.cc
	g++ $< $(CFLAGS) -o parser

ifeq ($(rep),ode2odes)
$(sys)_ode2odes.cc: ode2odes.cc
	cat ode2odes.cc | sed 's/\$$/$(sys)/' > $(sys)_ode2odes.cc
else
$(sys)_$(rep).cc: $(sys)_def.h $(sys)_sympar.h $(sys)_def.r $(sys)_$(rep).m
	mtt_m2cc.sh ${sys} ${rep} parser







|
|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
	mkoctfile $<
endif



all:	$(sys)_$(rep).cc

parser.exe: parse_m2cc.cc
	g++ $< $(CFLAGS) -o ${MTTPATH}/trans/parser.exe -I${MTTPATH}/../cc/include

ifeq ($(rep),ode2odes)
$(sys)_ode2odes.cc: ode2odes.cc
	cat ode2odes.cc | sed 's/\$$/$(sys)/' > $(sys)_ode2odes.cc
else
$(sys)_$(rep).cc: $(sys)_def.h $(sys)_sympar.h $(sys)_def.r $(sys)_$(rep).m
	mtt_m2cc.sh ${sys} ${rep} parser

Modified mttroot/mtt/cc/include/useful-functions.hh from [bc3e893dc8] to [6bacf30342].



1


2




3
4





5
6
7





8

9
10


11
12

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64





template <class T>




inline T max (const T &x1, const T &x2)
{





  return (x1 >= x2) ? x1 : (x2 < x1) ? x2 : 0;
}






template <class T>

inline T min (const T &x1, const T &x2)
{


  return (x1 <= x2) ? x1 : (x2 > x1) ? x2 : 0;
}


inline Matrix
ones (const int r = 1, const int c = 1)
{
  Matrix m (r, c, 1.0);
  return m;
}

inline ColumnVector
nozeros (const ColumnVector v0, const double tol = 0.0)
{
  ColumnVector v (v0.length ());
  register int i, j;
  for (i = j = 0; i < v.length (); i++)
    if (tol < abs (v0 (i)))
      {
	v (j) = v0 (i);
	j++;
      }
  if (0 == j)
    {
      return *new ColumnVector ();
    }
  else
    {
      return (v.extract (0, --j));
    }
}

inline ColumnVector
zeros (const int r)
{
  ColumnVector v (r, 0.0);
  return v;
}

inline Matrix
zeros (const int r, const int c)
{
  Matrix m (r, c, 0.0);
  return m;
}

template <class T>
inline int
sign (T x)
{
  return
    (0 < x) ? +1 :
    (0 > x) ? -1 :
    0;
}
>
>

>
>
|
>
>
>
>
|
|
>
>
>
>
>
|


>
>
>
>
>
|
>
|

>
>
|
|
>

|






|




















|






|






|
<
<
<
<
<
<
<
<
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78








#ifndef HAVE_USEFUL_FUNCTIONS_HH
#define HAVE_USEFUL_FUNCTIONS_HH


#ifdef __CPLUSPLUS
template <class class_t>
#else
#define inline			// strip from pre-processed file
#define class_t double
#endif // __CPLUSPLUS


// == Template functions ==

static inline class_t
max (const class_t &x1, const class_t &x2)
{
  return ((x1 >= x2) ? x1 : (x1 < x2) ? x2 : 0);
}

static inline class_t
min (const class_t &x1, const class_t &x2)
{
  return ((x1 <= x2) ? x1 : (x1 > x2) ? x2 : 0);
}

static inline class_t
sign (const class_t &x)
{
  return ((x > 0) ? +1 : (x < 0) ? -1 : 0);
}


// == Octave functions ==

static inline Matrix
ones (const int r = 1, const int c = 1)
{
  Matrix m (r, c, 1.0);
  return m;
}

static inline ColumnVector
nozeros (const ColumnVector v0, const double tol = 0.0)
{
  ColumnVector v (v0.length ());
  register int i, j;
  for (i = j = 0; i < v.length (); i++)
    if (tol < abs (v0 (i)))
      {
	v (j) = v0 (i);
	j++;
      }
  if (0 == j)
    {
      return *new ColumnVector ();
    }
  else
    {
      return (v.extract (0, --j));
    }
}

static inline ColumnVector
zeros (const int r)
{
  ColumnVector v (r, 0.0);
  return v;
}

static inline Matrix
zeros (const int r, const int c)
{
  Matrix m (r, c, 0.0);
  return m;
}

#endif // HAVE_USEFUL_FUNCTIONS_HH








Modified mttroot/mtt/cc/parse_m2cc.cc from [3b05b7d2a2] to [6a7d5a9a81].

1
2






3
4
5
6
7
8
9
/* $Id$
 * $Log$






 * Revision 1.1  2000/10/31 04:29:50  geraint
 * Initial revision
 *
 */





>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* $Id$
 * $Log$
 * Revision 1.1.2.1  2001/03/09 02:59:26  geraint
 * got_comment: (char)c no longer compared to (int)EOF.
 *
 * Revision 1.1  2000/12/28 09:46:05  peterg
 * put under RCS
 *
 * Revision 1.1  2000/10/31 04:29:50  geraint
 * Initial revision
 *
 */



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
{
  /*
   * get remainder of line in case there are any commented keywords
   */
  char c;
  cout << " // ";
  cin >> c;
  while (c != '\n' && c != EOF)
    {
      cout << c;
      cin >> c;
    }
  cout << endl
       << indent () << ';' << endl
       << indent ();
}
  









|
<
|
|
<







203
204
205
206
207
208
209
210

211
212

213
214
215
216
217
218
219
{
  /*
   * get remainder of line in case there are any commented keywords
   */
  char c;
  cout << " // ";
  cin >> c;
  do {

    cout << c;
  } while (c != '\n' && cin >> c);

  cout << endl
       << indent () << ';' << endl
       << indent ();
}
  


307
308
309
310
311
312
313












314
315
316
317
318
319
320
		/*
		 * EOL is end-of-statement in Octave, add ;
		 */
		   << indent () << ';' << endl
		   << indent ();
	    }
	  buf = "";












	  break;
	default:
	  buf += c;
	}
      if (lbrace->get_nesting_depth ())
	{
	  cout.setf (ios::skipws);







>
>
>
>
>
>
>
>
>
>
>
>







311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
		/*
		 * EOL is end-of-statement in Octave, add ;
		 */
		   << indent () << ';' << endl
		   << indent ();
	    }
	  buf = "";
	  break;
	case '\\':
	  cin >> c;
	  if ('\n' == c)
	    {
	      buf += '\n';
	    }
	  else
	    {
	      buf += '\\';
	      buf += c;
	    }
	  break;
	default:
	  buf += c;
	}
      if (lbrace->get_nesting_depth ())
	{
	  cout.setf (ios::skipws);

Modified mttroot/mtt/cc/sympar_txt2h.sh from [9ef7c9027a] to [21b8e13116].

1
2
3




4
5
6
7
8
9
10
#! /bin/sh
# $Id$
# $Log$




# Revision 1.7  2001/01/09 15:43:50  geraint
# Warn gcc that variables may be unused.
#
# Revision 1.6  2001/01/08 05:47:56  geraint
# Restrict scope of variables to file (static)
#
# Revision 1.5  2000/12/05 12:44:55  peterg



>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
#! /bin/sh
# $Id$
# $Log$
# Revision 1.2  2001/02/05 13:03:19  geraint
# Restrict scope of variables to file (static).
# Warn GCC that variables may be unused.
#
# Revision 1.7  2001/01/09 15:43:50  geraint
# Warn gcc that variables may be unused.
#
# Revision 1.6  2001/01/08 05:47:56  geraint
# Restrict scope of variables to file (static)
#
# Revision 1.5  2000/12/05 12:44:55  peterg
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
TMP_VAR_NAMES="mtt_tmp mtt_o $*"

IN=${SYS}_sympar.txt
OUT=${SYS}_sympar.h

declare_sys_param ()
{
cat ${IN} | awk '{printf ("static double %s MTT_UNUSED;\t// %s\n", $1, $2)}'
}

declare_temp_vars ()
{
for name in ${TMP_VAR_NAMES}
do
    echo ""







|







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
TMP_VAR_NAMES="mtt_tmp mtt_o $*"

IN=${SYS}_sympar.txt
OUT=${SYS}_sympar.h

declare_sys_param ()
{
cat ${IN} | awk '{printf ("static double %s MTT_UNUSED;\t// %s\n", tolower($1), $2)}'
}

declare_temp_vars ()
{
for name in ${TMP_VAR_NAMES}
do
    echo ""

Modified mttroot/mtt/lib/cc/mtt_implicit.cc from [66ec9e6cff] to [a2b6319245].

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{
#else // !STANDALONE
DEFUN_DLD (mtt_implicit, args, ,
	   "implicit integration method")
{
#ifdef OCTAVE_DEV
  static ColumnVector  	x	= args(0).column_vector_value ();
  const ColumnVector	dx	= args(1).column_vector_value ();
  const Matrix		AA	= args(2).matrix_value ();
  const ColumnVector	AAx	= args(3).column_vector_value ();
  const double		t	= args(4).double_value ();
  const int		Nx	= (int) (args(5).double_value ());
  const ColumnVector	openx	= args(6).column_vector_value ();
#else // !OCTAVE_DEV
  static ColumnVector	x	= args(0).vector_value ();
  const ColumnVector	dx	= args(1).vector_value ();
  const Matrix		AA	= args(2).matrix_value ();
  const ColumnVector	AAx	= args(3).vector_value ();
  const double		t	= args(4).double_value ();
  const int		Nx	= (int) (args(5).double_value ());
  const ColumnVector	openx	= args(6).vector_value ();
#endif // OCTAVE_DEV
#endif // STANDALONE

  register int row, col;

  for (row = 0; row < Nx; row++)
    {
      if (0 != openx (row))
	{
	  AAx (row) = 0.0;
          dx (row) = 0.0;
	  for (col = 0; col < Nx; col++)
	    {
	      AA (row,col) = 0.0;

	    }
	}
    }

  x = static_cast<ColumnVector> (xleftdiv (AA, static_cast<Matrix>(AAx + dx * t)));
  
  for (row = 0; row < Nx; row++)
    {
      if (0 != openx (row))
	{
	  x (row) = 0.0;
	}
    }

#ifdef STANDALONE
  return x;
#else // !STANDALONE
  return octave_value (x);
#endif // STANDALONE
}







|
|
|
|
|
|


|
|
|
|
|
|







|






>








|











12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{
#else // !STANDALONE
DEFUN_DLD (mtt_implicit, args, ,
	   "implicit integration method")
{
#ifdef OCTAVE_DEV
  static ColumnVector  	x	= args(0).column_vector_value ();
  static ColumnVector	dx	= args(1).column_vector_value ();
  static Matrix		AA	= args(2).matrix_value ();
  static ColumnVector	AAx	= args(3).column_vector_value ();
  const  double		t	= args(4).double_value ();
  const  int		Nx	= (int) (args(5).double_value ());
  const  ColumnVector	openx	= args(6).column_vector_value ();
#else // !OCTAVE_DEV
  static ColumnVector	x	= args(0).vector_value ();
  static ColumnVector	dx	= args(1).vector_value ();
  static Matrix		AA	= args(2).matrix_value ();
  static ColumnVector	AAx	= args(3).vector_value ();
  const  double		t	= args(4).double_value ();
  const  int		Nx	= (int) (args(5).double_value ());
  const  ColumnVector	openx	= args(6).vector_value ();
#endif // OCTAVE_DEV
#endif // STANDALONE

  register int row, col;

  for (row = 0; row < Nx; row++)
    {
      if (openx (row) > 0.5)
	{
	  AAx (row) = 0.0;
          dx (row) = 0.0;
	  for (col = 0; col < Nx; col++)
	    {
	      AA (row,col) = 0.0;
	      AA (col,row) = 0.0;
	    }
	}
    }

  x = static_cast<ColumnVector> (xleftdiv (AA, static_cast<Matrix>(AAx + dx * t)));
  
  for (row = 0; row < Nx; row++)
    {
      if (openx (row) > 0.5)
	{
	  x (row) = 0.0;
	}
    }

#ifdef STANDALONE
  return x;
#else // !STANDALONE
  return octave_value (x);
#endif // STANDALONE
}

Deleted mttroot/mtt/lib/rep/standalone_rep.make version [6e1ac4004e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*-makefile-*-

.POSIX:

MTTFLAGS	= -q -u -oct $(OPTS)

# Adapt according to local set-up and mkoctfile
CXX		= g++
CXXFLAGS	= $(DEBUG) $(OPTIM) $(DEFINES) $(ARCHFLAGS) -fno-rtti -fno-exceptions -fno-implicit-templates

DEBUG		= -g
OPTIM		= -O3

PREFIX		= /usr/local

INCLUDES	= -I$(PREFIX)/include/octave

OCTAVE_SRC_PATH	= /cvs/octave

LIBOCTAVE	= -L$(PREFIX)/lib/octave			-loctave -lcruft -loctinterp
LIBKPATHSEA	= -L$(OCTAVE_SRC_PATH)/kpathsea			-lkpathsea
LIBREADLINE	= -L$(OCTAVE_SRC_PATH)/readline			-lreadline
#LIBBLAS		= -L/usr/local/src/ATLAS/lib/Linux_PIII		-lcblas -lf77blas -llapack -latlas -ltstatlas
#LIBBLAS		= 						-lblas -llapack
LIBF2C		= 						-lg2c
LIBRARIES	= 						-ldl -lm -lncurses

ARCHFLAGS	= $(i386FLAGS)
i386FLAGS	=  -mieee-fp 

# Define -DOCTAVE_DEV for octave 2.1.x
ifeq (0, $(shell octave --version | awk -F\. '{print $2}'))
DEFINES   = -DSTANDALONE
else
DEFINES   = -DSTANDALONE -DOCTAVE_DEV
endif

all: $(SYS)_standalone.$(LANG)

$(SYS)_standalone.exe: $(SYS)_ode2odes.cc $(SYS)_def.h $(SYS)_sympar.h
	cp $(MTT_LIB)/cc/*.cc .
	echo Creating $(SYS)_standalone.exe
	$(CXX) *.cc -o $@ $(CXXFLAGS) $(INCLUDES) $(LIBOCTAVE) $(LIBKPATHSEA) $(LIBREADLINE) $(LIBBLAS) $(LIBF2C) $(LIBRARIES)

.PHONY: $(SYS)_standalone.clean

$(SYS)_ode2odes.cc:
	mtt $(MTTFLAGS) $(SYS) ode2odes m

$(SYS)_def.h:
	mtt $(MTTFLAGS) $(SYS) def h

$(SYS)_sympar.h:
	mtt $(MTTFLAGS) $(SYS) sympar h 


$(SYS)_standalone.clean:
	cd .. ; mtt Clean
	rm -f ../$(SYS)_standalone.exe
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<























































































































MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]