10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
+
+
+
|
# Copyright (c) P.J.Gawthrop, 1991, 1994, 1996
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5 2000/09/01 12:14:57 peterg
## Added connecti9ng inputs
##
## Revision 1.4 1998/04/07 15:06:46 peterg
## Correct log file name
##
## Revision 1.3 1998/03/07 12:57:19 peterg
## Fixed logname bug
##
## Revision 1.2 1998/03/07 12:51:20 peterg
|
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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
114
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
|
## General error handling.
##
## Revision 1.2 1996/08/25 08:31:28 peter
## Error handling added.
##
###############################################################
while [ -n "`echo $1 | grep '^-'`" ]; do
case $1 in
-I )
info=info;;
-partition )
partition=yes;
blurb='with partitioning';
;;
*)
echo "$1 is an invalid argument - ignoring" ;;
esac
shift
done
#Create the top-level system name
topname=$1
#Create the system names
if [ -z "$2" ];
then
sysname=$topname;
else
sysname=$1_$2;
fi
defname=$topname"_def.r"
crname=$topname"_cr.r"
paramname=$topname"_params.r"
daename=$sysname"_rdae.r"
esename=$sysname"_ese.r"
logname=ese2rdae.log
# Inform user
echo Creating $daename
echo Creating $daename $blurb
# Remove the old log file
rm -f $logname
# Use symbolic algebra to accomplish the transformation
$SYMBOLIC >$logname << EOF
|
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
-
+
|
% Zero outputs
MTT_Matrix := MTTYz$
MTT_Matrix_name := "MTTYz"$
MTT_Matrix_n := MTTNyz$
MTT_Matrix_m := 1$
Reduce_Matrix()$
SHUT "$daename";
quit;
EOF
if [ -n "$partition" ]; then
rm -f mtt_junk
# Now for the subsystems
# Find subsystems
subsystems=`sh rc2_type.sh 'echo ' ' ' | awk '{if (NR>1) print $2}'`
for subsystem in $subsystems; do
echo Doing $subsystem
ucname="MTT_"$subsystem"_uc"
Nu=`mtt_getsize -internal $subsystem"_1" u`
echo Nu $Nu
# Use symbolic algebra to accomplish the transformation
$SYMBOLIC >$logname << EOF
%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";
% Definitions
in "$defname";
% Elementary system equations
in "$esename";
OFF Echo;
OFF Nat;
%Create the output file
OUT "mtt_junk";
% Connecting inputs
MTT_Matrix := MTTuc$
MTT_Matrix_name := "MTTuc"$
MTT_Matrix_n := MTTNuc$
MTT_Matrix_m := 1$
Reduce_Matrix()$
% Connecting inputs
MTT_Matrix := $ucname $
MTT_Matrix_name := "$ucname" $
MTT_Matrix_n := $Nu $
MTT_Matrix_m := 1$
Reduce_Matrix()$
write ";END;";
SHUT "$daename";
quit;
shut "mtt_junk";
EOF
echo >> $1_rdae.r
echo %Connections for subsystem $subsystem >> $1_rdae.r
cat mtt_junk >> $1_rdae.r
rm -rf mtt_junk
done
fi
EOF
echo "END;" >> $1_rdae.r
# Now invoke the standard error handling.
mtt_error_r $logname
|