Differences From Artifact [0c5cb052d3]:

To Artifact [f362dd6f57]:


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.10  1998/07/27 20:26:15  peterg
## Added new VARs mttWSTEPS, MTTWMIN,mttWMAX
##
## Revision 1.9  1998/07/27 17:20:42  peterg
## Allow , between ()
##
## Revision 1.8  1998/07/26 19:38:17  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.11  1998/07/29 14:18:34  peterg
## Reorganised rep dependednt output
##
## Revision 1.10  1998/07/27 20:26:15  peterg
## Added new VARs mttWSTEPS, MTTWMIN,mttWMAX
##
## Revision 1.9  1998/07/27 17:20:42  peterg
## Allow , between ()
##
## Revision 1.8  1998/07/26 19:38:17  peterg
85
86
87
88
89
90
91





92
93
94
95
96
97

98
99
100
101
102
103
104

105
106
107
108
109
110
111
112
113
	;;
    odeo)
	echo "PROCEDURE $Sys_rep(VAR mtty : OutputVector;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector;"
	echo "                       mttt : REAL);"
	;;





    ode2odes)
	echo "PROGRAM $Sys_rep;"
	echo "TYPE"
	echo "    StateVector  =ARRAY[1..$Nx] OF REAL;"
	echo "    InputVector  =ARRAY[1..$Nu] OF REAL;"
	echo "    OutputVector =ARRAY[1..$Ny] OF REAL;"

	echo "    IntegrationMethod = (Euler,ImplicitL,Implicit);"
	echo "VAR"
        echo "    MTTt,mttLAST,mttDT,mttDDT   : REAL;"
        echo "    MTTWMIN,mttWMAX             : REAL;"
	echo "    mttx,mttdx                  : StateVector;"
	echo "    mttu                        : InputVector;"
	echo "    mtty                        : OutputVector;"

	echo "    MTTi,MTTj,MTTit,MTTiLast,mttSTEPFACTOR,mttWSTEPS : INTEGER;"
	echo "    mttMETHOD : STRING;"
        ;;
    switch)
	echo "PROCEDURE $Sys_rep(VAR mttxs : StateVector;"
	echo "                       mttx  : StateVector);"
	echo "VAR"
	echo "    MTTi,MTTj :  INTEGER;"
	;;







>
>
>
>
>






>
|






>

|







88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
	;;
    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;"
	echo "                       mttx : StateVector;"
	echo "                       mttu : InputVector);"
	;;
    ode2odes)
	echo "PROGRAM $Sys_rep;"
	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 "    IntegrationMethod = 1..3;"
	echo "VAR"
        echo "    MTTt,mttLAST,mttDT,mttDDT   : REAL;"
        echo "    MTTWMIN,mttWMAX             : REAL;"
	echo "    mttx,mttdx                  : StateVector;"
	echo "    mttu                        : InputVector;"
	echo "    mtty                        : OutputVector;"
	echo "    mttA                        : StateMatrix;"
	echo "    MTTi,MTTj,MTTit,MTTiLast,mttSTEPFACTOR,mttWSTEPS : INTEGER;"
	echo "    mttMETHOD : IntegrationMethod;"
        ;;
    switch)
	echo "PROCEDURE $Sys_rep(VAR mttxs : StateVector;"
	echo "                       mttx  : StateVector);"
	echo "VAR"
	echo "    MTTi,MTTj :  INTEGER;"
	;;
136
137
138
139
140
141
142

143
144
145
146















147
148
149
150
151
152
153
grep -v '^[ ]*function' < $Sys_rep.m  | sed "s/^$space%/#/" |\
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\($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 '















BEGIN{
  comment_regexp = "{"
  doing_header = 0
  doing_globals = 0
  Nt = 9
  inc ="$I"
}







>




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







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
grep -v '^[ ]*function' < $Sys_rep.m  | sed "s/^$space%/#/" |\
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; 
  printf("VAR\n");
  for (k=1;k<=N;k++) {
    printf("mtt%s%i", Name, k);
    if (k==N)
      printf(" : REAL;\n")
    else
      printf(", "); 
    kk++;
    if (kk==width){printf("\n"); kk=0}
  }
}
BEGIN{
  comment_regexp = "{"
  doing_header = 0
  doing_globals = 0
  Nt = 9
  inc ="$I"
}
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
    else 
    {
      if (doing_header==1){
        if (rep=="ode2odes"){
          printf("VAR ");
          for (k=1;k<i;k++) printf("%s,",global[k])
          printf("%s : REAL;\n", global[i])
          printf("VAR "); for (k=1;k<=Nx;k++) printf("mttx%i,", k)
          for (k=1;k<=Nu;k++) printf("mttu%i,", k)
          for (k=1;k<=Nt;k++) printf("mtt_temp%i,", k)

          printf("t%i : REAL;\n",Nt) 
          printf("{%s sign.p}\n",inc,sys)
          printf("{%s mtt_update.p}\n",inc,sys)
          printf("{%s mtt_write.p}\n",inc,sys)

          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_switch.p}\n",inc,sys)
          for (k=1;k<=j;k++) printf("%s\n", comment[k])
          printf("\n")
          printf("\nBEGIN\n")
        }
        else{
          for (k=1;k<=j;k++) printf("%s\n", comment[k])







|
|
|
>
|

|
|
>






>







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
    else 
    {
      if (doing_header==1){
        if (rep=="ode2odes"){
          printf("VAR ");
          for (k=1;k<i;k++) printf("%s,",global[k])
          printf("%s : REAL;\n", global[i])
          printvar("x",Nx);
          printvar("u",Nu);
          printvar("y",Ny);
          printvar("t",Nt);

          printf("{%s sign.p}\n",inc,sys)
          printf("{%s mtt_update.p}\n",inc)
          printf("{%s mtt_write.p}\n",inc)
          printf("{%s zeros.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_smx.p}\n",inc,sys)
          printf("{%s %s_switch.p}\n",inc,sys)
          for (k=1;k<=j;k++) printf("%s\n", comment[k])
          printf("\n")
          printf("\nBEGIN\n")
        }
        else{
          for (k=1;k<=j;k++) printf("%s\n", comment[k])
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
    printf("IMPLICIT = 3;\n")
    }
    else
      if (rep=="ode2odes")
        print "END."
      else
        print "END;"
}' sys=$sys rep=$rep Nx=$Nx Nu=$Nu |\
sed 's/(\([ijk0-9,]*\))/\[\1\]/g'  |\
sed 's/(\(MTT[ijk0-9,]*\))/\[\1\]/g' \
>> $Filename

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









|











261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
    printf("IMPLICIT = 3;\n")
    }
    else
      if (rep=="ode2odes")
        print "END."
      else
        print "END;"
}' sys=$sys rep=$rep Nx=$Nx Nu=$Nu Ny=$Ny |\
sed 's/(\([ijk0-9,]*\))/\[\1\]/g'  |\
sed 's/(\(MTT[ijk0-9,]*\))/\[\1\]/g' \
>> $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 ]