Overview
Comment:Added () to [] conversion when the variable is i j k or an integer or
combination
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: c6efb99edeff52fc50470326a66a4e21a92a8896ad4528da8128b4c45075e484
User & Date: gawthrop@users.sourceforge.net on 1998-07-25 14:03:30
Other Links: branch diff | manifest | tags
Context
1998-07-25
14:03:50
Initial revision check-in: b5ff3d237b user: gawthrop@users.sourceforge.net tags: origin/master, trunk
14:03:30
Added () to [] conversion when the variable is i j k or an integer or
combination
check-in: c6efb99ede user: gawthrop@users.sourceforge.net tags: origin/master, trunk
13:05:46
Reorganised initialisation check-in: b1d77fef00 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/mtt_m2p from [1a6aeb0003] to [63255fcfd0].

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.1  1998/07/25 09:42:52  peterg
## Initial revision
##
###############################################################










>
>
>







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.2  1998/07/25 12:39:57  peterg
## begin on same line as for and if
##
## Revision 1.1  1998/07/25 09:42:52  peterg
## Initial revision
##
###############################################################



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125

126
127
128
129
130
131
132
133
134
135
136
137
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)/" |\
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 = 1
  doing_globals = 0
  Nt = 9
  inc ="$I"
}
{
  if ($1=="global") 
    doing_globals = 1
  else{ 
    if (doing_globals==1){
      if (match($1,";")==0){
        global[++i]=$1;
      }
      else{
        doing_globals = 0

      }
    }
    else 
    {
      if ((doing_header==1)&&(doing_globals==0)) {
        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=0;k<Nt;k++) printf("t%i,", k)







|










|



>




|







107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
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)/" |\
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"
}
{
  if ($1=="global") 
    doing_globals = 1
  else{ 
    if (doing_globals==1){
      if (match($1,";")==0){
        global[++i]=$1; 
      }
      else{
        doing_globals = 0
        doing_header = 1
      }
    }
    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=0;k<Nt;k++) printf("t%i,", k)
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
        if (doing_header==1)
          comment[++j] = $0
        else
          printf("%s\n", $0)
      }
      else {
        if ($1=="if") {
          print tolower($0) " begin"
        }
        else{ 
          if ($1=="for"){
          sub(/:/," TO ",$0)
          sub(/=/,":=",$0)
          printf("%s DO\n", $0) " begin"
          }
          else {
            sub(/=/,":=",$0)
            sub(/\^/,"**",$0)
            printf("%s\n",$0)
          }
        }
      }
    }
  }
}
END{
  if (rep=="def"){
    printf("EULER = 1,\n")
    printf("IMPLICITL = 2;\n")
    printf("IMPLICIT3 = 3;\n")
    }
    else



      print "END;"
}' sys=$sys rep=$rep Nx=$Nx Nu=$Nu |\
sed 's/(\([0-9]*\))/\[\1\]/' \
>> $Filename

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









|





|


















>
>
>
|

|









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
        if (doing_header==1)
          comment[++j] = $0
        else
          printf("%s\n", $0)
      }
      else {
        if ($1=="if") {
          printf("%s THEN BEGIN", $0)
        }
        else{ 
          if ($1=="for"){
          sub(/:/," TO ",$0)
          sub(/=/,":=",$0)
          printf("%s DO BEGIN\n", $0) 
          }
          else {
            sub(/=/,":=",$0)
            sub(/\^/,"**",$0)
            printf("%s\n",$0)
          }
        }
      }
    }
  }
}
END{
  if (rep=="def"){
    printf("EULER = 1,\n")
    printf("IMPLICITL = 2;\n")
    printf("IMPLICIT3 = 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' \
>> $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 ]