Overview
Comment:Generates method-specific code for the ode2odeso rep.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: c5eae5f60d8bb5995e5c2260720ab8913bdb9f99e1a2ed54649741764b129193
User & Date: gawthrop@users.sourceforge.net on 1999-11-15 22:47:17
Other Links: branch diff | manifest | tags
Context
1999-11-15
22:47:53
Generates method-specific code. check-in: 24bf9aa64e user: gawthrop@users.sourceforge.net tags: origin/master, trunk
22:47:17
Generates method-specific code for the ode2odeso rep. check-in: c5eae5f60d user: gawthrop@users.sourceforge.net tags: origin/master, trunk
22:45:31
Reorganised integration method using -i switch
Introduced -r (reset) switch
check-in: 6b232a05be user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/mtt_m2p from [6cabf8be57] to [20c229ac1d].

11
12
13
14
15
16
17



18
19
20
21
22
23
24
# Copyright (c) P.J.Gawthrop 1998

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



## Revision 1.33  1999/09/17 04:25:01  peterg
## END --> END; in translation
##
## Revision 1.32  1999/08/29 06:54:42  peterg
## Added code (mtt_parameters, get args etc) to allow arguments to the
## a.out file
##







>
>
>







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

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.34  1999/10/28 05:08:48  peterg
## Added elseif
##
## Revision 1.33  1999/09/17 04:25:01  peterg
## END --> END; in translation
##
## Revision 1.32  1999/08/29 06:54:42  peterg
## Added code (mtt_parameters, get args etc) to allow arguments to the
## a.out file
##
128
129
130
131
132
133
134


135

136



137
138
139
140
141
142
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
rep=`echo $args  | awk '{print $2}'`
Sys_rep="$Sys""_""$rep"
Sys_smx="$Sys""_smx"
Sys_smxp="$Sys""_smx.p"
Filename="$Sys""_""$rep.p"
filename="$sys""_""$rep.p"



# Inform user

echo Creating $Filename




# 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/;//'`

if [ "$rep" = "simpar" ]; then
    mtt -q $Sys smx p
fi

# Heading
(case $rep in
    state)
        echo "PROCEDURE $Sys_rep(VAR mttx : StateVector);"
        ;;
    input)
        echo "PROCEDURE $Sys_rep(VAR mttu : InputVector;"
	echo "                       mttt : REAL;"
	echo "                       mttx : StateVector;"
	echo "                       mtty : OutputVector);"
	;;
    ode)
	echo "PROCEDURE $Sys_rep(VAR mttdx: StateVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL);"
	;;
    odeo)












	echo "PROCEDURE $Sys_rep(VAR mtty : OutputVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL);"
	;;
    smx)
	echo "PROCEDURE $Sys_rep(VAR mtta       : StateMatrix;"







>
>

>
|
>
>
>






|
|
|



















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







131
132
133
134
135
136
137
138
139
140
141
142
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
191
192
rep=`echo $args  | awk '{print $2}'`
Sys_rep="$Sys""_""$rep"
Sys_smx="$Sys""_smx"
Sys_smxp="$Sys""_smx.p"
Filename="$Sys""_""$rep.p"
filename="$sys""_""$rep.p"

Method=$2; # The integration method

# Inform user
if [ -z "$Method" ]; then
  echo Creating $Filename 
else
  echo Creating $Filename with $Method integration method 
fi

# 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/;//'`

#if [ "$rep" = "simpar" ]; then
#    mtt -q $Sys smx p
#fi

# Heading
(case $rep in
    state)
        echo "PROCEDURE $Sys_rep(VAR mttx : StateVector);"
        ;;
    input)
        echo "PROCEDURE $Sys_rep(VAR mttu : InputVector;"
	echo "                       mttt : REAL;"
	echo "                       mttx : StateVector;"
	echo "                       mtty : OutputVector);"
	;;
    ode)
	echo "PROCEDURE $Sys_rep(VAR mttdx: StateVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL);"
	;;
    odeo)
	echo "PROCEDURE $Sys_rep(VAR mtty : OutputVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL);"
	;;
    cse)
	echo "PROCEDURE $Sys_rep(VAR mttdx: StateVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL);"
	;;
    cseo)
	echo "PROCEDURE $Sys_rep(VAR mtty : OutputVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL);"
	;;
    smx)
	echo "PROCEDURE $Sys_rep(VAR mtta       : StateMatrix;"
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
	echo "    OutputVector = ARRAY[1..$Ny] OF REAL;"
	echo "    StateMatrix  = ARRAY[1..$Nx,1..$Nx] OF REAL;"
	echo "    glnparray    = StateVector;"
	echo "    glmparray    = StateVector;"
	echo "    glnarray     = StateVector;"
	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 "    mttAA, mttE                 : StateMatrix;"
	echo "    MTTi,MTTj,MTTit,MTTjt,MTTiLast: INTEGER;"
	echo "    mttSTEPFACTOR,mttWSTEPS,mttSTEPS,mttINPUT : INTEGER;"
	echo "    mttMETHOD : IntegrationMethod;"
	echo "    MTTopen  : StateVector;"
	echo "    mtt_parameters  : ARRAY[1..MTT_MaxParameters] OF REAL;"
	echo "    mtt_n_parameters  : INTEGER;"
	echo ""
        ;;
    switchopen)
	echo "PROCEDURE $Sys_rep(VAR open : StateVector; mttx : StateVector);"







|










|







204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
	echo "    OutputVector = ARRAY[1..$Ny] OF REAL;"
	echo "    StateMatrix  = ARRAY[1..$Nx,1..$Nx] OF REAL;"
	echo "    glnparray    = StateVector;"
	echo "    glmparray    = StateVector;"
	echo "    glnarray     = StateVector;"
	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 "    mttAA, mttE                 : StateMatrix;"
	echo "    MTTi,MTTj,MTTit,MTTjt,MTTiLast: INTEGER;"
	echo "    mttSTEPFACTOR,mttWSTEPS,mttSTEPS,mttINPUT : INTEGER;"
	## echo "    mttMETHOD : IntegrationMethod;"
	echo "    MTTopen  : StateVector;"
	echo "    mtt_parameters  : ARRAY[1..MTT_MaxParameters] OF REAL;"
	echo "    mtt_n_parameters  : INTEGER;"
	echo ""
        ;;
    switchopen)
	echo "PROCEDURE $Sys_rep(VAR open : StateVector; mttx : StateVector);"
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
cat<<EOF >> $Filename

{*** System $Sys, rep $rep, language Pascal, file $Filename ***}
{*** Translated by MTT from $Sys_rep.m on `date` ***}

EOF

#Regexps
  name="[a-zA-Z0-9_]*"
  fun_name="$Sys\_$name"
  mttfun_name=$name
  tab='	'
  space="[ $tab]*"
  spaces="[ $tab][ $tab]*"
  non_space="[^ ]*"







|







239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
cat<<EOF >> $Filename

{*** System $Sys, rep $rep, language Pascal, file $Filename ***}
{*** Translated by MTT from $Sys_rep.m on `date` ***}

EOF

# Regexps
  name="[a-zA-Z0-9_]*"
  fun_name="$Sys\_$name"
  mttfun_name=$name
  tab='	'
  space="[ $tab]*"
  spaces="[ $tab][ $tab]*"
  non_space="[^ ]*"
300
301
302
303
304
305
306

307
308


309

310


311
312
313
314
315
316
317
          printf("{%s $MTTPATH/trans/p/zero_input.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/zero_state.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/mtt_getargs.p}\n",inc)
          printf("{%s %s_simpar.p}\n",inc,Sys) 
          printf("{%s %s_numpar.p}\n",inc,Sys)
          printf("{%s %s_state.p}\n",inc,Sys)
          printf("{%s %s_input.p}\n",inc,Sys)

          printf("{%s %s_ode.p}\n",inc,Sys)
          printf("{%s %s_odeo.p}\n",inc,Sys)


          printf("{%s %s_switchopen.p}\n\n",inc,Sys)

          printf("\n{%s %s_smx.p}\n",inc,Sys)



          for (k=1;k<=j;k++) printf("%s\n", comment[k])
          printf("\n")
          printf("\nBEGIN{%s}\n", Sys_rep)
        }
        else{
          for (k=1;k<=j;k++) printf("%s\n", comment[k])







>
|
|
>
>
|
>
|
>
>







321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
          printf("{%s $MTTPATH/trans/p/zero_input.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/zero_state.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/mtt_getargs.p}\n",inc)
          printf("{%s %s_simpar.p}\n",inc,Sys) 
          printf("{%s %s_numpar.p}\n",inc,Sys)
          printf("{%s %s_state.p}\n",inc,Sys)
          printf("{%s %s_input.p}\n",inc,Sys)
          if (Method=="euler") {
            printf("{%s %s_ode.p}\n",inc,Sys)
            printf("{%s %s_odeo.p}\n",inc,Sys)
          }
          if (Method=="implicit") {
            printf("{%s %s_cse.p}\n",inc,Sys)
            printf("{%s %s_cseo.p}\n",inc,Sys)
            printf("\n{%s %s_smx.p}\n",inc,Sys);
          }
          printf("{%s %s_switchopen.p}\n\n",inc,Sys)

          for (k=1;k<=j;k++) printf("%s\n", comment[k])
          printf("\n")
          printf("\nBEGIN{%s}\n", Sys_rep)
        }
        else{
          for (k=1;k<=j;k++) printf("%s\n", comment[k])
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
    printf("IMPLICIT = 3;\n")
    }
    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 |\
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'  |\
sed 's/switcha(mttAA,/switcha(/g'   |\
sed 's/switch(MTTx,/switch(/g'  \







|







389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
    printf("IMPLICIT = 3;\n")
    }
    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|\
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'  |\
sed 's/switcha(mttAA,/switcha(/g'   |\
sed 's/switch(MTTx,/switch(/g'  \


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