Overview
Comment:Added mttpar to the arg list of cse and cseo
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 6a69646ca09aaf107b87e9a0ea13359280df8e56147842c2c1315eb3ac691873
User & Date: gawthrop@users.sourceforge.net on 2000-04-07 08:17:37
Other Links: branch diff | manifest | tags
Context
2000-04-07
11:01:15
Put in proper header etc check-in: e7fdcea11a user: gawthrop@users.sourceforge.net tags: origin/master, trunk
08:17:37
Added mttpar to the arg list of cse and cseo check-in: 6a69646ca0 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
2000-04-06
11:27:56
Removed the in _cr.r check-in: 83cefeec8f user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/mtt_m2p from [6090ec16a3] to [6466c7205a].

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.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
##
## Revision 1.33  1999/09/17 04:25:01  peterg







>
>
>







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.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
##
## Revision 1.33  1999/09/17 04:25:01  peterg
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

193
194
195
196
197
198
199
200
201
202
203
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
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;"
	echo "                   VAR mttax,mttx : StateVector;"
	echo "                   VAR mttu       : InputVector;"
	echo "                       mttdt      : REAL);"
	;;
    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 "    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;"







>

<
|
<
<
|


>
>
>
>
>
>
>

>
>
>
|
<
<




















>
|





>
|





>
|





>
|
>















>














>







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
193
194
195
196
197
198
199
200
201
202
203
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
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
Stdin=$3;  # Using standard input


if [ -n "$Method" ]; then


  MethodBlurb=" with $Method integration method"
fi

if [ -n "$Stdin" ]; then
   StdinBlurb=" using standard input"
fi

# Inform user
  echo Creating $Filename $MethodBlurb $StdinBlurb 

# Find system constants
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

# 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);"
	;;
    odeo)
	echo "PROCEDURE $Sys_rep(VAR mtty : OutputVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL;"
	echo "                       mttpar : ParameterVector);"
	;;
    cse)
	echo "PROCEDURE $Sys_rep(VAR mttdx: StateVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL;"
	echo "                       mttpar : ParameterVector);"
	;;
    cseo)
	echo "PROCEDURE $Sys_rep(VAR mtty : OutputVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL;"
	echo "                       mttpar : ParameterVector);"

	;;
    smx)
	echo "PROCEDURE $Sys_rep(VAR mtta       : StateMatrix;"
	echo "                   VAR mttax,mttx : StateVector;"
	echo "                   VAR mttu       : InputVector;"
	echo "                       mttdt      : REAL);"
	;;
    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 "    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 "    mtt_parameters  : ARRAY[1..MTT_MaxParameters] OF REAL;"
	echo "    mtt_n_parameters  : INTEGER;"
359
360
361
362
363
364
365
366



367




368
369
370

371
372
373
374
375
376
377
      else {
        if ($1=="if") {
          sub(/==/, "=", $0)
            gsub(/&&/," AND ",$0)
            gsub(/\|\|/," OR ",$0)
          printf("%s THEN BEGIN\n", $0)
        }
        else{ 



          if ($1=="for"){




          sub(/:/," TO ",$0)
          sub(/=/,":=",$0)
          printf("%s DO BEGIN\n", $0) 

          }
          else{
            sub(/=/,":=",$0)
            sub(/endif/,"END;{IF}",$0)
            sub(/endfor/,"END;{FOR}",$0)
            sub(/elseif/,"END ELSEIF BEGIN",$0)
            sub(/else/,"END ELSE BEGIN",$0)







|
>
>
>

>
>
>
>
|
|
|
>







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
      else {
        if ($1=="if") {
          sub(/==/, "=", $0)
            gsub(/&&/," AND ",$0)
            gsub(/\|\|/," OR ",$0)
          printf("%s THEN BEGIN\n", $0)
        }
        else { 
          if ((match($1,"mtt_write")>0)&&(length(Stdin)>0)) {
           sub(/mtt_write/, "if NOT eof THEN mtt_write");
          }
          if ($1=="for"){
            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)
            sub(/elseif/,"END ELSEIF BEGIN",$0)
            sub(/else/,"END ELSE BEGIN",$0)
392
393
394
395
396
397
398
399

400
401
402
403
404
405
406
    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'  \







|
>







416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
    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 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'  \


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