Index: mttroot/mtt/bin/trans/mtt_m2p ================================================================== --- mttroot/mtt/bin/trans/mtt_m2p +++ mttroot/mtt/bin/trans/mtt_m2p @@ -13,10 +13,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.36 1999/11/29 06:49:26 peterg +## Upped number of mtt_tnn +## ## Revision 1.35 1999/11/15 22:47:17 peterg ## Generates method-specific code for the ode2odeso rep. ## ## Revision 1.34 1999/10/28 05:08:48 peterg ## Added elseif @@ -137,22 +140,28 @@ Sys_smxp="$Sys""_smx.p" Filename="$Sys""_""$rep.p" filename="$sys""_""$rep.p" Method=$2; # The integration method +Stdin=$3; # Using standard input + +if [ -n "$Method" ]; then + MethodBlurb=" with $Method integration method" +fi -# Inform user -if [ -z "$Method" ]; then - echo Creating $Filename -else - echo Creating $Filename with $Method integration method +if [ -n "$Stdin" ]; then + StdinBlurb=" using standard input" fi +# Inform user + echo Creating $Filename $MethodBlurb $StdinBlurb + # Find system constants -Nx=`grep "MTTNx " <$Sys\_def.r | awk '{print $3}' | sed 's/;//'` -Nu=`grep "MTTNu " <$Sys\_def.r | awk '{print $3}' | sed 's/;//'` -Ny=`grep "MTTNy " <$Sys\_def.r | awk '{print $3}' | sed 's/;//'` +Nx=`mtt_getsize $Sys x` # States +Nu=`mtt_getsize $Sys u` # Inputs +Ny=`mtt_getsize $Sys y` # Inputs +Npar=`wc -l $Sys\_sympar.txt | awk '{print $1}'` #if [ "$rep" = "simpar" ]; then # mtt -q $Sys smx p #fi @@ -169,29 +178,34 @@ ;; ode) echo "PROCEDURE $Sys_rep(VAR mttdx: StateVector;" echo " mttx : StateVector;" echo " mttu : InputVector;" - echo " mttt : REAL);" + echo " mttt : REAL;" + echo " mttpar : ParameterVector);" ;; odeo) echo "PROCEDURE $Sys_rep(VAR mtty : OutputVector;" echo " mttx : StateVector;" echo " mttu : InputVector;" - echo " mttt : REAL);" + echo " mttt : REAL;" + echo " mttpar : ParameterVector);" ;; cse) echo "PROCEDURE $Sys_rep(VAR mttdx: StateVector;" echo " mttx : StateVector;" echo " mttu : InputVector;" - echo " mttt : REAL);" + echo " mttt : REAL;" + echo " mttpar : ParameterVector);" ;; cseo) echo "PROCEDURE $Sys_rep(VAR mtty : OutputVector;" echo " mttx : StateVector;" echo " mttu : InputVector;" - echo " mttt : REAL);" + echo " mttt : REAL;" + echo " mttpar : ParameterVector);" + ;; smx) echo "PROCEDURE $Sys_rep(VAR mtta : StateMatrix;" echo " VAR mttax,mttx : StateVector;" echo " VAR mttu : InputVector;" @@ -203,10 +217,11 @@ echo " MTT_MaxParameters = 100;" echo "TYPE" echo " StateVector = ARRAY[1..$Nx] OF REAL;" echo " InputVector = ARRAY[1..$Nu] OF REAL;" echo " OutputVector = ARRAY[1..$Ny] OF REAL;" + echo " ParameterVector = ARRAY[1..$Npar] OF REAL;" echo " StateMatrix = ARRAY[1..$Nx,1..$Nx] OF REAL;" echo " glnparray = StateVector;" echo " glmparray = StateVector;" echo " glnarray = StateVector;" echo " glnpbynp = StateMatrix;" @@ -217,10 +232,11 @@ echo " MTTt,mttLAST,mttDT,mttDDT : REAL;" echo " MTTWMIN,mttWMAX : REAL;" echo " mttx,mttdx,mttxx,mttAAx : StateVector;" echo " mttu : InputVector;" echo " mtty : OutputVector;" + echo " mttpar : ParameterVector;" echo " mttAA, mttE : StateMatrix;" echo " MTTi,MTTj,MTTit,MTTjt,MTTiLast: INTEGER;" echo " mttSTEPFACTOR,mttWSTEPS,mttSTEPS,mttINPUT : INTEGER;" ## echo " mttMETHOD : IntegrationMethod;" echo " MTTopen : StateVector;" @@ -361,15 +377,23 @@ sub(/==/, "=", $0) gsub(/&&/," AND ",$0) gsub(/\|\|/," OR ",$0) printf("%s THEN BEGIN\n", $0) } - else{ + else { + if ((match($1,"mtt_write")>0)&&(length(Stdin)>0)) { + sub(/mtt_write/, "if NOT eof THEN mtt_write"); + } if ($1=="for"){ - sub(/:/," TO ",$0) - sub(/=/,":=",$0) - printf("%s DO BEGIN\n", $0) + if (($2=="MTTit")&&(length(Stdin)>0)){ + printf("WHILE NOT eof DO BEGIN {Integration loop}") + } + else { + sub(/:/," TO ",$0) + sub(/=/,":=",$0) + printf("%s DO BEGIN\n", $0) + } } else{ sub(/=/,":=",$0) sub(/endif/,"END;{IF}",$0) sub(/endfor/,"END;{FOR}",$0) @@ -394,11 +418,12 @@ else if (rep=="ode2odes") printf("END{%s}.\n", Sys_rep) else printf("END{%s};\n", Sys_rep) -}' Sys=$Sys sys=$sys Sys_rep=$Sys_rep rep=$rep Nx=$Nx Nu=$Nu Ny=$Ny Method=$Method|\ +}' Sys=$Sys sys=$sys Sys_rep=$Sys_rep rep=$rep \ + Nx=$Nx Nu=$Nu Ny=$Ny Method=$Method Stdin=$Stdin |\ sed 's/(\([ijk0-9,]*\))/\[\1\]/g' |\ sed 's/(\(MTT[ijk0-9],[0-9]*\))/\[\1\]/g' |\ sed 's/(\([0-9]*,MTT[ijk0-9]\))/\[\1\]/g' |\ sed 's/(\(MTT[ijk0-9],MTT[ijk0-9]\))/\[\1\]/g' |\ sed 's/(\(MTT[ijk0-9,]*\))/\[\1\]/g' |\