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.8 1999/07/26 06:07:19 peterg +## Reinstated removal of the odeo.p file +## ## Revision 1.7 1999/03/16 00:38:06 peterg ## Done some more tidying up ## ## Revision 1.6 1999/03/15 07:29:25 peterg ## Fixed various obscure reduce bugs @@ -38,10 +41,11 @@ ## Revision 1.1 1998/07/27 16:30:26 peterg ## Initial revision ## ############################################################### + # Set up the language specific stuff rep=$2 ext='m'; codegenerator='PASCAL' @@ -50,10 +54,13 @@ Lb='('; Rb=')'; outfile=$1"_"$rep +## Find som constants +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; @@ -83,22 +90,42 @@ # Remove the old log file rm -f mtt_r2m.log #Remove the temporary files -if [ "$rep" = "ode" ]; then +if [ "$rep" = "ode" ]||[ "$rep" = "cse" ]; then #echo Creating $1_odea.$ext outfileo=$outfile"o" echo Creating $outfileo.m #rm -f $1_odea.$ext.1; #Header - lang_header $1 $rep $ext 'mttx,mttu,t' mttdx > $1_ode.p - lang_header $1 odeo $ext 'mttx,mttu,t' mtty > $1_odeo.p + lang_header $1 $rep $ext 'mttx,mttu,t' mttdx > $1_$2.p + lang_header $1 $2o $ext 'mttx,mttu,t' mtty > $1_$2o.p + + rm -f mtt_ode mtt_odeo + + # Use reduce to accomplish the transformation +$SYMBOLIC > mtt_r2m.log < mtt_r2m.log < mtt_r2m.log <> $1_$2.p +sed 's/mtt_matrix/mtte/' > $1_$2.p +sed 's/mtt_matrix/mtty/' > $1_$2o.p + +if [ "$rep" = "cse" ]; then +cat <>$1_$2.p + ## Solve E dx = dxe;; + mtt_solve(mttdx,mttE,mttdx,$Nx);; EOF - - -# cat $1_odeo.$ext.1 - -## # Algebraic bits -## $MATRIX -q <> $1_ode.$ext -## %System structure -## [nx,ny,nu,nz,nyz] = $1_def; -## if nyz>0 -## printf("global mttxx mttt;\n"); -## printf("mttxx = mttx; mttt=t;\n"); -## -## printf("$Lc====== Extract the internal input variables ======$Rc\n"); -## for i = 1:nyz -## printf(" mttui$Lb%i$Rb = mttx$Lb%i$Rb;\n",i,i+nx); -## end; -## printf("\n"); -## -## printf("[mttui,info] = fsolve('$1_odea',mttui);\n"); -## printf("if (info!=1)\n"); -## printf(" error('fsolve has not converged')\n"); -## printf("end\n"); -## printf("\n"); -## -## printf("$Lc====== Set up the internal input variables ======$Rc\n"); -## for i = 1:nyz -## printf(" mttui%i = mttui$Lb%i$Rb;\n",i,i); -## end; -## printf("\n"); -## -## printf("$Lc====== Put internal input variables at end of state derivative ======$Rc\n"); -## for i = 1:nyz -## printf(" mttdx$Lb%i$Rb = mttui%i;\n",i+nx,i); -## end; -## printf("\n"); -## end; -## -##EOF -## - - -## # Create the odea.$ext function -## lang_header $1 odea $ext 'mttui' mttyz 'global mttxx mttt; mttx = mttxx; t=mttt;' > $1_odea.$ext -## -## $MATRIX -q <> $1_odea.$ext -## %System structure -## [nx,ny,nu,nz,nyz] = $1_def; -## if nyz>0 -## printf("$Lc====== Set up the internal input variables ======$Rc\n"); -## for i = 1:nyz -## printf(" mttui%i = mttui$Lb%i$Rb;\n",i,i); -## end; -## printf("\n"); -## end; -##EOF -## -## cat <> $1_odea.$ext -## -## % The algebraic equations -##EOF -## sed 's/mtt_matrix/mttyz/' $1_odea.$ext.1 >> $1_odea.$ext - - - # Create the odeo function - -##$MATRIX -q <> $1_odeo.p -## %System structure -## [nx,ny,nu,nz,nyz] = $1_def; -## if nyz>0 -## printf("$Lc====== Extract the internal input variables ======$Rc\n"); -## for i = 1:nyz -## printf(" mttui$Lb%i$Rb = mttx$Lb%i$Rb;\n",i,i+nx); -## end; -## printf("\n"); -## -## printf("$Lc====== Set up the internal input variables ======$Rc\n"); -## for i = 1:nyz -## printf(" mttui%i = mttui$Lb%i$Rb;\n",i,i); -## end; -## printf("\n"); -## end; -##EOF - -sed 's/mtt_matrix/mttdx/' > $1_ode.p -sed 's/mtt_matrix/mtty/' > $1_odeo.p - -rm -f mtt_odeo mtt_ode +fi +rm -f mtt_odeo mtt_ode mtt_odee # Convert from Pascal syntax to Octave syntax - mtt_p2m<$1_odeo.p > $1_odeo.m + mtt_p2m<$1_$2o.p > $1_$2o.m rm -f $1_odeo.p fi if [ "$rep" = "sm" ]||[ "$rep" = "dm" ]; then