Index: mttroot/mtt/bin/trans/mtt_r2m ================================================================== --- mttroot/mtt/bin/trans/mtt_r2m +++ mttroot/mtt/bin/trans/mtt_r2m @@ -14,10 +14,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.18 2000/08/24 17:11:40 peterg +## Now optimises as well as segmenting - uses the SCOPE package +## ## Revision 1.17 2000/05/20 15:23:56 peterg ## Paramererised version of sm etc etc (using -parameter switch) ## ## Revision 1.16 2000/04/18 11:14:18 peterg ## Put in the -parameters option @@ -103,10 +106,11 @@ Nx=`grep "MTTNx " <$1_def.r | awk '{print $3}' | sed 's/;//'` #Set up gentran cat <mtt_setreduce.r % Set up the code generator + % Load the general translator package LOAD GENTRAN; LOAD SCOPE; GENTRANLANG!* := '$codegenerator; ON GENTRANSEG; % Segmentation @@ -114,17 +118,12 @@ OFF GENDECS; % No declarations MAXEXPPRINTLEN!* := 80; TEMPVARNUM!* := 1; TEMPVARNAME!* := 'mtt_s; -% Output control -ON DIV; -ON EXP; - % Matrix output function in"$MTTPATH/trans/lang_matrix.r"; - %Read the reduce definitions file in "$1_def.r"; %Read the reduce $REP file @@ -131,11 +130,27 @@ in "$1_$rep.r"; %Read the substitution file in "$1_subs.r"; +%%% The following is a bug fix from ZIB to fix +%%% segmentation violation problem +symbolic procedure maxtype type; +% ------------------------------------------------------------------- ; +% A type may be a pair (l u) wher l is the minimum type for a variable; +% and u is the maximum type. This procedure returns the maximum type.; +% ------------------------------------------------------------------- ; + if atom type + then type + else if pairp cdr type then cadr type else car type; + +% This fix handles the case that the type is a list with ONE entry. +% Should never happen ?? W.N. +%%%%%% End of bug fix + +END; EOF #Inform user echo Creating $outfile.m @@ -176,11 +191,11 @@ EOF if [ "$rep" = "ode" ]; then # Use reduce to accomplish the transformation -$SYMBOLIC > mtt_r2m.log <> mtt_r2m.log < mtt_r2m.log <> mtt_r2m.log <mtt_r2m.log - + $SYMBOLIC << EOF >>mtt_r2m.log + write "Doing ", "$Symbol"; %Set up the code generator in"mtt_setreduce.r"; - OUT "mtt_zero.m"; write "mtt$Symbol = zeros(", $N, ",", $M , ");" ; SHUT "mtt_zero.m"; GENTRANOUT "$outfile.1"; @@ -336,18 +350,21 @@ mtt_matrix := MTT$Symbol; mtt_matrix_n := $N; mtt_matrix_m := $M; lang_matrix(); GENTRANSHUT "$outfile.1"; +END; EOF echo "%$Symbol matrix#" >> $outfile.pas cat mtt_zero.m >> $outfile.pas sed "s/mtt_matrix/mtt$Symbol/" < $outfile.1 |\ grep -v '=0\.0;' >> $outfile.pas + +echo Done $Symbol done fi @@ -355,11 +372,13 @@ # Convert from Pascal syntax to Octave syntax mtt_p2m <$outfile.pas > $outfile.m rm -f $outfile.pas rm -f mtt_zero.m -rm -f $outfile.1 +#rm -f $outfile.1 +# Now invoke the standard error handling. +mtt_error_r mtt_r2m.log