Index: mttroot/mtt/bin/trans/mtt_m2p ================================================================== --- mttroot/mtt/bin/trans/mtt_m2p +++ mttroot/mtt/bin/trans/mtt_m2p @@ -13,10 +13,14 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.42 2000/04/18 11:11:44 peterg +## mtt_parameters ---> mttpar +## mtt_n_parameters ---> mttnpar +## ## Revision 1.41 2000/04/18 10:13:43 peterg ## Getargs now after numpar file ## ## Revision 1.40 2000/04/07 19:09:04 peterg ## New smxa and smxax reps @@ -185,15 +189,22 @@ # Heading (case $rep in state) echo "PROCEDURE $Sys_rep(VAR mttx : StateVector);" ;; + numpar) + echo "PROCEDURE $Sys_rep(VAR mttpar : ParameterVector);" + ;; + simpar) + echo "PROCEDURE $Sys_rep(VAR mttsimpar : SimulationParameters);" + ;; input) echo "PROCEDURE $Sys_rep(VAR mttu : InputVector;" echo " mttt : REAL;" echo " mttx : StateVector;" - echo " mtty : OutputVector);" + echo " mtty : OutputVector;" + echo " mttw : InputVector);" ;; ode) echo "PROCEDURE $Sys_rep(VAR mttdx: StateVector;" echo " mttx : StateVector;" echo " mttu : InputVector;" @@ -246,15 +257,20 @@ ;; ode2odes) echo "PROGRAM $Sys_rep;" echo "CONST" echo " MTT_MaxParameters = 100;" + echo " MTT_Npar = $Npar;" + echo " MTT_Nx = $Nx;" 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 " SimulationParameters = RECORD" + echo " dt, first, input, last, stepfactor, wmax, wmin, wsteps: REAL" + echo " END;" echo " StateMatrix = ARRAY[1..$Nx,1..$Nx] OF REAL;" echo " StateMatrixVector = ARRAY[1..$Nxx] OF REAL;" echo " glnparray = StateVector;" echo " glmparray = StateVector;" echo " glnarray = StateVector;" @@ -261,23 +277,23 @@ echo " glnpbynp = StateMatrix;" echo " glmpbynp = StateMatrix;" ## echo " IntegrationMethod = 1..4;" echo "" echo "VAR" - echo " MTTt,mttLAST,mttDT,mttDDT : REAL;" - echo " MTTWMIN,mttWMAX : REAL;" - echo " mttx,mttdx,mttxx,mttAAx : StateVector;" - echo " mttu : InputVector;" - echo " mtty : OutputVector;" + echo " simpar : SimulationParameters;" + echo " t : REAL;" + echo " x,dx,AAx : StateVector;" + echo " u : InputVector;" + echo " y : OutputVector;" + echo " par : ParameterVector;" echo " mttpar : ParameterVector;" - echo " mttAA, mttE : StateMatrix;" - echo " MTTi,MTTj,MTTit,MTTjt,MTTiLast: INTEGER;" - echo " mttSTEPFACTOR,mttWSTEPS,mttSTEPS,mttINPUT : INTEGER;" + echo " mttnpar : INTEGER;" + echo " AA : StateMatrix;" + echo " MTTi,MTTj,it,iLast: INTEGER;" + ##echo " mttSTEPFACTOR,mttWSTEPS,mttSTEPS,mttINPUT : INTEGER;" ## echo " mttMETHOD : IntegrationMethod;" - echo " MTTopen : StateVector;" - echo " mttpar : ARRAY[1..MTT_MaxParameters] OF REAL;" - echo " mttnpar : INTEGER;" + echo " open : StateVector;" echo "" ;; switchopen) echo "PROCEDURE $Sys_rep(VAR open : StateVector; mttx : StateVector);" echo "VAR" @@ -302,22 +318,27 @@ mttfun_name=$name tab=' ' space="[ $tab]*" spaces="[ $tab][ $tab]*" non_space="[^ ]*" + args="[a-zA-Z0-9,.]*" # Body -grep -v '^[ ]*function' < $Sys_rep.m | sed "s/^$space%/#/" | sed "s/\([;)]$space\)%/\1#/" |\ +cat $Sys_rep.m |\ +grep -v '^[ ]*function' |\ +grep -v '^[ ]*endfunction' |\ +grep -v 'MTT_data' |\ +sed "s/^$space%/#/" | sed "s/\([;)]$space\)%/\1#/" |\ awk -F# '{printf("%s",$1) if (NF>1) printf("{* %s *}", $2) printf("\n") }' |\ -sed "s/$space\[\($non_space\)\]$spaces=$spaces\($fun_name\)(\([a-zA-Z0-9,]*\))/\2(\1,\3)/" |\ -sed "s/$space\[\($non_space\)\]$spaces=$spaces\($mttfun_name\)(\([a-zA-Z0-9,]*\))/\2(\1,\3)/" |\ -sed "s/$space\[\($non_space\)\]$spaces=$spaces\(zeros\)(\([a-zA-Z0-9,]*\))/\2(\1,\3)/" |\ +sed "s/$space\[\($non_space\)\]$spaces=$spaces\($fun_name\)(\($args\))/\2(\1,\3)/" |\ +sed "s/$space\[\($non_space\)\]$spaces=$spaces\($mttfun_name\)(\($args\))/\2(\1,\3)/" |\ +sed "s/$space\[\($non_space\)\]$spaces=$spaces\(zeros\)(\($args\))/\2(\1,\3)/" |\ sed "s/$space\[\($non_space\)\]$spaces=$spaces\($fun_name\)/\2(\1)/" |\ -sed "s/$space\($non_space\)$spaces=$spaces\($fun_name\)(\([a-zA-Z0-9,]*\))/\2(\1,\3)/" |\ +sed "s/$space\($non_space\)$spaces=$spaces\($fun_name\)(\($args\))/\2(\1,\3)/" |\ sed "s/$space\($non_space\)$spaces=$spaces\($fun_name\)/\2(\1)/" |\ awk ' function printvar(Name,N) { if (N<1) return; width = 10; @@ -354,18 +375,10 @@ } else { if (doing_header==1){ if (rep=="ode2odes"){ - printf("VAR \n"); - for (k=1;k> $Filename # p2c doesn't like mixed case filenames! #if [ "$Filename" != "$filename" ]; then # echo Creating $filename