Overview
Comment:Major changes towards partioning

- generates sub ese, def and struc
- generates indices for conversion of subsystem in/out/state - but not used yet

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 70a215f13eb1178589663547d4e2535e0070b8c25d31798851e3b0e9a49f31bc
User & Date: gawthrop@users.sourceforge.net on 2000-12-01 14:51:26
Other Links: branch diff | manifest | tags
Context
2000-12-01
16:04:24
More partitioning achieved -- now needs the connections to be properly
sorted in cbg2ese_r
check-in: 3b133eb48f user: gawthrop@users.sourceforge.net tags: origin/master, trunk
14:51:26
Major changes towards partioning

- generates sub ese, def and struc
- generates indices for conversion of subsystem in/out/state - but not used yet check-in: 70a215f13e user: gawthrop@users.sourceforge.net tags: origin/master, trunk

14:28:34
Initial revision check-in: 685c3eb122 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/cbg2ese_m2r from [c0a65b5d9e] to [f835ebd14a].

12
13
14
15
16
17
18




19
20
21
22
23
24
25

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




## Revision 1.23  2000/11/30 15:07:28  peterg
## Sorted out mtt_getsize
##
## Revision 1.22  2000/11/12 17:18:30  peterg
## Changed ' to "
##
## Revision 1.21  2000/10/16 08:40:35  peterg







>
>
>
>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

###############################################################
## Version control history
###############################################################
## $Id$
##
## $Log$
## Revision 1.24  2000/11/30 15:12:55  peterg
## Zapped the declaration of subsystem connections - now in individual
## .def files
##
## Revision 1.23  2000/11/30 15:07:28  peterg
## Sorted out mtt_getsize
##
## Revision 1.22  2000/11/12 17:18:30  peterg
## Changed ' to "
##
## Revision 1.21  2000/10/16 08:40:35  peterg
124
125
126
127
128
129
130

131
132
133
134
135
136
137

#Inform user
echo Creating $eqnfile $blurb
echo Creating $deffile
echo Creating $structurefile

# Use matrix manipulation to accomplish the transformation

$MATRIX << EOF > cbg2ese_m2r.log 2>mtt_error.txt

infofile = "$infofile";;
infofilenum = fopen(infofile,"w");
structurefile = "$structurefile";;
structurefilenum = fopen(structurefile,"w");
deffile = "$1_def.r";







>







128
129
130
131
132
133
134
135
136
137
138
139
140
141
142

#Inform user
echo Creating $eqnfile $blurb
echo Creating $deffile
echo Creating $structurefile

# Use matrix manipulation to accomplish the transformation
# This creates an ese file for every subsystem.
$MATRIX << EOF > cbg2ese_m2r.log 2>mtt_error.txt

infofile = "$infofile";;
infofilenum = fopen(infofile,"w");
structurefile = "$structurefile";;
structurefilenum = fopen(structurefile,"w");
deffile = "$1_def.r";
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
structure = zeros(1,7);  # Initialise structure vector

structure = cbg2ese(system_name, system_type, system_cr, ...
                     system_args, full_name, full_name_repetition, ...
                     1, structure, structurefilenum, infofilenum);
makedef(structure,deffilenum);
EOF



if [ "$info" = "info" ]; then
  cat $infofile
fi

if [ -z "$partition" ]; then
  # Don't partition

  # Create the composite ese file
  cat $1_ese.r $1_*_ese.r  > $1_ese.tmp 2>> /dev/null

  mv $1_ese.tmp $1_ese.r

  # Zap the sub ese files
  rm -f $1_*_ese.r



else # Partition the system
  # Find subsystems

  subsystems=`mtt_get_subsystems $1`



  # Top level  

# The top-level definition file
Nx=`mtt_getsize -external $1 dX`
Nz=`mtt_getsize -external $1 z`
Ny=`mtt_getsize -external $1 y`
Nu=`mtt_getsize -external $1 u`
Nui=`mtt_getsize -external $1 ui`
Nuc=`mtt_getsize -internal $1 u`








>
>






|
>







>
>
>

|
>
|

>
>
|
>
|







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
structure = zeros(1,7);  # Initialise structure vector

structure = cbg2ese(system_name, system_type, system_cr, ...
                     system_args, full_name, full_name_repetition, ...
                     1, structure, structurefilenum, infofilenum);
makedef(structure,deffilenum);
EOF

echo "END;" >> $1_def.r

if [ "$info" = "info" ]; then
  cat $infofile
fi

if [ -z "$partition" ]; then
  ## Don't partition

  # Create the composite ese file
  cat $1_ese.r $1_*_ese.r  > $1_ese.tmp 2>> /dev/null

  mv $1_ese.tmp $1_ese.r

  # Zap the sub ese files
  rm -f $1_*_ese.r

  echo "END;" >> $1_ese.r

else # Partition the system

  # Save up the full def file
  mv $1_def.r mtt_all_def.r

## Recreate def file from the ese file directly
function makedef {

echo Creating $1_def.r

Nx=`mtt_getsize -external $1 dX`
Nz=`mtt_getsize -external $1 z`
Ny=`mtt_getsize -external $1 y`
Nu=`mtt_getsize -external $1 u`
Nui=`mtt_getsize -external $1 ui`
Nuc=`mtt_getsize -internal $1 u`

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
  structure(5) = 0;   # Zero outputs
  structure(6) = $Nui; #Internal inputs 
  structure(7) = $Nuc; # Connecting inputs

  makedef(structure,deffilenum);  #Create definitions
EOF





  ## Extra bits for the ese file to define connections





  for subsystem in $subsystems; do
    echo Connecting $subsystem
#    Ny=`mtt_getsize -internal ${subsystem}_1 y`
#    Nu=`mtt_getsize -internal ${subsystem}_1 u`
#    Nx=`mtt_getsize -internal ${subsystem}_1 u`
#    echo Ny $Ny Nu $Nu Nx $Nx


#    echo MATRIX "MTT_"$subsystem"_uc("$Nu",1);"  >> $1_def.r

    echo >> $1_ese.r
    echo %Subsystem input connections for $subsystem  >> $1_ese.r
    octave -q <<EOF                            >> $1_ese.r
    for i=1:$Nu
      printf("MTT_%s_uc(%i,1) := %s_1_MTTu%i;\n", "$subsystem", i, "$subsystem", i);
    endfor;
EOF



















done


fi

echo "END;" >> $1_ese.r
echo "END;" >> $1_def.r

# Create the _alised file
touch mtt_aliased.txt
echo Creating $1_aliased.txt
mv mtt_aliased.txt $1_aliased.txt

# Sort the struc file
mv $structurefile junk
sort -k 1,1 -k 2,2n junk >$structurefile

# Now invoke the standard error handling.
mtt_error mtt_error.txt














>
>
>
>
|
>
>
>
>
>

















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>



<
<












>
>
>
>



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
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
286
287
  structure(5) = 0;   # Zero outputs
  structure(6) = $Nui; #Internal inputs 
  structure(7) = $Nuc; # Connecting inputs

  makedef(structure,deffilenum);  #Create definitions
EOF

echo "END;" >> $1_def.r
}
  # Find subsystems
  subsystems=`mtt_get_subsystems $1`

  # Top level  
  makedef $1;
  echo "END;" >> $1_ese.r

  ## Subsystems
  for subsystem in $subsystems; do
    echo Connecting $subsystem
#    Ny=`mtt_getsize -internal ${subsystem}_1 y`
#    Nu=`mtt_getsize -internal ${subsystem}_1 u`
#    Nx=`mtt_getsize -internal ${subsystem}_1 u`
#    echo Ny $Ny Nu $Nu Nx $Nx


#    echo MATRIX "MTT_"$subsystem"_uc("$Nu",1);"  >> $1_def.r

    echo >> $1_ese.r
    echo %Subsystem input connections for $subsystem  >> $1_ese.r
    octave -q <<EOF                            >> $1_ese.r
    for i=1:$Nu
      printf("MTT_%s_uc(%i,1) := %s_1_MTTu%i;\n", "$subsystem", i, "$subsystem", i);
    endfor;
EOF
  ## Subsystems (Only works when no repetitions at this level)
  esefile=${subsystem}_ese.r
  echo Creating $esefile
  cat ${subsystem}_1_ese.r ${subsystem}_1_*_ese.r > $esefile 2> /dev/null
  echo "END;" >> $esefile

  ## Def file for subsystem
  #makedef ${subsystem}
  
  echo Creating ${subsystem}_def.r
  cp mtt_all_def.r ${subsystem}_def.r

  echo Creating ${subsystem}_struc.txt
  grep $subsystem < $1_struc.txt > ${subsystem}_struc.txt
  echo "Creating indices (needs more work to convert subsystem indices)"
  whichs="input output state"
  for which in $whichs; do
    indices=`mtt_get_subindex $subsystem $which`
    echo "  $which $indices"
  done
  done

fi




# Create the _alised file
touch mtt_aliased.txt
echo Creating $1_aliased.txt
mv mtt_aliased.txt $1_aliased.txt

# Sort the struc file
mv $structurefile junk
sort -k 1,1 -k 2,2n junk >$structurefile

# Now invoke the standard error handling.
mtt_error mtt_error.txt








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