Overview
Comment:Major revisions for new paprameter passing versions
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 56f4d4235d4f60d24bc842351de268b48cc4dd47ae580e7588a700edd44298f9
User & Date: gawthrop@users.sourceforge.net on 2000-05-11 19:35:16
Other Links: branch diff | manifest | tags
Context
2000-05-11
19:35:50
Put no glbs back check-in: 9d9d8be442 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
19:35:16
Major revisions for new paprameter passing versions check-in: 56f4d4235d user: gawthrop@users.sourceforge.net tags: origin/master, trunk
19:34:50
*** empty log message *** check-in: 83d4b71acd user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/mtt_m2p from [dc7682616f] to [5755c7df34].

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.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
##
## Revision 1.39  2000/04/07 13:38:13  peterg







>
>
>
>







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

###############################################################
## 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
##
## Revision 1.39  2000/04/07 13:38:13  peterg
183
184
185
186
187
188
189






190
191
192
193
194

195
196
197
198
199
200
201
#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;"
	echo "                       mttpar : ParameterVector);"







>
>
>
>
>
>




|
>







187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#fi

# 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 "                       mttw : InputVector);"
	;;
    ode)
	echo "PROCEDURE $Sys_rep(VAR mttdx: StateVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL;"
	echo "                       mttpar : ParameterVector);"
244
245
246
247
248
249
250


251
252
253
254
255



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270

271

272
273
274
275
276
277
278
279
280
281
282
283
284
285
	echo "                       mttt      : REAL;"
	echo "                       mttpar     : ParameterVector);"
	;;
    ode2odes)
	echo "PROGRAM $Sys_rep;"
	echo "CONST"
	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 "    StateMatrixVector  = ARRAY[1..$Nxx] 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 "    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;"
	echo "    mttpar  : ARRAY[1..MTT_MaxParameters] OF REAL;"
	echo "    mttnpar  : INTEGER;"
	echo ""
        ;;
    switchopen)
	echo "PROCEDURE $Sys_rep(VAR open : StateVector; mttx : StateVector);"
	echo "VAR"
	echo "    MTTi,MTTj :  INTEGER;"
	;;







>
>





>
>
>










|
|
|
|
|
>

>
|
|
|

|
<
<







255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294


295
296
297
298
299
300
301
	echo "                       mttt      : REAL;"
	echo "                       mttpar     : ParameterVector);"
	;;
    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;"
	echo "    glnpbynp     = StateMatrix;"
	echo "    glmpbynp     = StateMatrix;"
	## echo "    IntegrationMethod = 1..4;"
	echo ""
	echo "VAR"
	echo "    simpar                      : SimulationParameters;"
        echo "    t                           : REAL;"
	echo "    x,dx,AAx                    : StateVector;"
	echo "    u                           : InputVector;"
	echo "    y                           : OutputVector;"
	echo "    par                         : ParameterVector;"
	echo "    mttpar                      : ParameterVector;"
	echo "    mttnpar                     : INTEGER;"
	echo "    AA                          : StateMatrix;"
	echo "    MTTi,MTTj,it,iLast: INTEGER;"
	##echo "    mttSTEPFACTOR,mttWSTEPS,mttSTEPS,mttINPUT : INTEGER;"
	## echo "    mttMETHOD : IntegrationMethod;"
	echo "    open  : StateVector;"


	echo ""
        ;;
    switchopen)
	echo "PROCEDURE $Sys_rep(VAR open : StateVector; mttx : StateVector);"
	echo "VAR"
	echo "    MTTi,MTTj :  INTEGER;"
	;;
300
301
302
303
304
305
306

307
308




309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
  name="[a-zA-Z0-9_]*"
  fun_name="$Sys\_$name"
  mttfun_name=$name
  tab='	'
  space="[ $tab]*"
  spaces="[ $tab][ $tab]*"
  non_space="[^ ]*"


# Body	




grep -v '^[ ]*function' < $Sys_rep.m  | 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\)/\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\)/\2(\1)/"  |\
awk '
function printvar(Name,N) {
  if (N<1) return;
  width = 10;
  kk = 0; 
  for (k=1;k<=N;k++) {







>


>
>
>
>
|




|
|
|

|







316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
  name="[a-zA-Z0-9_]*"
  fun_name="$Sys\_$name"
  mttfun_name=$name
  tab='	'
  space="[ $tab]*"
  spaces="[ $tab][ $tab]*"
  non_space="[^ ]*"
  args="[a-zA-Z0-9,.]*"

# Body	
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\)(\($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\)(\($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;
  kk = 0; 
  for (k=1;k<=N;k++) {
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387

388
389
390
391
392
393
394
395
396
397








398
399
400
401

402
403
404
405
406
407
408
        doing_header = 1
      }
    }
    else 
    {
      if (doing_header==1){
        if (rep=="ode2odes"){
          printf("VAR \n");
          for (k=1;k<i;k++) printf("  %s,\n",global[k])
          printf("%s : REAL;\n", global[i])
          # printvar("x",Nx);
          # printvar("u",Nu);
          # printvar("y",Ny);
          printvar("_t",Nt);

          printf("\n{%s $MTTPATH/trans/p/mtt_write.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/sign.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/mtt_euler.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/mtt_solve.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/mtt_implicit.p}\n",inc)
          # printf("{%s $MTTPATH/trans/p/zero_matrix.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/zero_input.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/zero_state.p}\n",inc)
          printf("{%s %s_simpar.p}\n",inc,Sys) 
          printf("{%s %s_numpar.p}\n",inc,Sys)
          printf("{%s $MTTPATH/trans/p/mtt_getargs.p}\n",inc)
          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])
          printf("\n")








          printf("VAR mtt_i : INTEGER;\n");
          if ( (rep=="smxa")||(rep=="smxax") ) {
            printvar("_t",Nt);
          }

          printf("\nBEGIN{%s}\n", Sys_rep)
          if (rep=="smxa"){
            printf("FOR mtt_i:= 1 to %i DO\n\tmtta[mtt_i] := 0;\n", Nx*Nx);
          }
          if (rep=="smxax"){
            printf("FOR mtt_i:= 1 to %i DO\n\tmttax[mtt_i] := 0;\n", Nx);
          }







<
<
<
<
<
<
<
<




















|
>










>
>
>
>
>
>
>
>

|
|
<
>







373
374
375
376
377
378
379








380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422

423
424
425
426
427
428
429
430
        doing_header = 1
      }
    }
    else 
    {
      if (doing_header==1){
        if (rep=="ode2odes"){








          printf("\n{%s $MTTPATH/trans/p/mtt_write.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/sign.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/mtt_euler.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/mtt_solve.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/mtt_implicit.p}\n",inc)
          # printf("{%s $MTTPATH/trans/p/zero_matrix.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/zero_input.p}\n",inc)
          printf("{%s $MTTPATH/trans/p/zero_state.p}\n",inc)
          printf("{%s %s_simpar.p}\n",inc,Sys) 
          printf("{%s %s_numpar.p}\n",inc,Sys)
          printf("{%s $MTTPATH/trans/p/mtt_getargs.p}\n",inc)
          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_smxa.p}\n",inc,Sys);
            printf("\n{%s %s_smxax.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])
          printf("\n")
          printf("VAR \n");
          for (k=1;k<i;k++) printf("  %s,\n",global[k])
          printf("%s : REAL;\n", global[i])
          # printvar("x",Nx);
          # printvar("u",Nu);
          # printvar("y",Ny);
          printvar("_t",Nt);

          printf("VAR mtt_i : INTEGER;\n");
          #if ( (rep=="smxa")||(rep=="smxax") ) {
          #  printvar("_t",Nt);

          #}
          printf("\nBEGIN{%s}\n", Sys_rep)
          if (rep=="smxa"){
            printf("FOR mtt_i:= 1 to %i DO\n\tmtta[mtt_i] := 0;\n", Nx*Nx);
          }
          if (rep=="smxax"){
            printf("FOR mtt_i:= 1 to %i DO\n\tmttax[mtt_i] := 0;\n", Nx);
          }
467
468
469
470
471
472
473
474




475
476
477
478
479
480
481
   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'  |\
sed 's/switcha(mttAA,/switcha(/g'   |\
sed 's/switch(MTTx,/switch(/g'  \




>> $Filename

# p2c doesn't like mixed case filenames!
#if [ "$Filename" != "$filename" ]; then
#  echo Creating $filename
#  cp -f $Filename $filename
#fi







|
>
>
>
>







489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
   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'  |\
sed 's/switcha(mttAA,/switcha(/g'   |\
sed 's/switch(MTTx,/switch(/g'  |\
sed 's/nargin<1/mttnpar<1/'  |\
sed 's/if nargin<2 THEN//'  |\
sed 's/nargin<3/mttnpar<1/' | \
sed 's/if nargin<4/if mttnpar<1/'  \
>> $Filename

# p2c doesn't like mixed case filenames!
#if [ "$Filename" != "$filename" ]; then
#  echo Creating $filename
#  cp -f $Filename $filename
#fi


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