9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
+
+
+
|
# Copyright (C) 2000 by Peter J. Gawthrop
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5 2000/05/17 16:01:42 peterg
## Fixed bug for n_y>1
##
## Revision 1.4 2000/05/16 18:57:15 peterg
## Still debugging
##
## Revision 1.3 2000/05/16 11:59:34 peterg
## Stard new version with data files not argv.
##
## Revision 1.2 2000/05/11 19:32:29 peterg
|
134
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
|
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
|
-
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
+
+
+
-
+
-
-
-
-
+
-
-
-
+
+
+
-
+
|
dtime = time-tim;
T = [T; num2str(dtime)];
## main simulation loop
n_sim = max(1,n_sens);
for i_sim=1:n_sim
if i_sim==1
i_1 = 2;
i_1 = 2;
else
i_1 = 2+n_y;
endif;
if doing_state
i_2 = i_1 + n_y - 1;
i_3 = i_1 + n_y + 1;
i_4 = i_1 + n_y + $Nx;
else
if doing_sensitivities
i_2 = 1 + 2*n_y;
ipars = [ipar; [sensitivities(i_sim) 1]];
save -ascii $1_numpar.dat ipars
else
i_2 = i_1 + n_y -1;
endif
endif;
if doing_state # Need to cut twice
command = sprintf("./$1_ode2odes.out< $1_input.dat | cut -f %i-%i,%i-%i | tail -%i;", i_1,i_2,i_3,i_4,n_t);
else
command = sprintf("./$1_ode2odes.out< $1_input.dat | cut -f %i-%i | tail -%i;", i_1,i_2,n_t);
end;
if doing_state # Need to cut twice
command = sprintf("./$1_ode2odes.out< $1_input.dat | cut -f %i-%i,%i-%i | tail -%i;", i_1,i_2,i_3,i_4,n_t);
else # not doing_state
command = sprintf("./$1_ode2odes.out< $1_input.dat | cut -f %i-%i | tail -%i;", i_1,i_2,n_t);
endif
## Execute external programme
S = [S;sprintf("Run %i\t",i_sim)];
tim = time;
yy_str=system(command);
dtime = time-tim;
T = [T; num2str(dtime)];
## Convert data
S = [S;sprintf("Conv %i\t",i_sim)];
tim = time;
yy = str2num(yy_str)'; #'
dtime = time-tim;
T = [T; num2str(dtime)];
[N_yy,M_yy] = size(yy);
if i_sim==1
if doing_sensitivities
y = yy(1:n_y:2*n_y,:); # Output
ys = yy(2:n_y:2*n_y,:);
else
y = yy(1:n_y,:); # Output
i_1 = n_y+1;
y = yy(1:n_y,:);
endif;
if doing_state
i_1 = n_y+1;
i_2 = i_1 + $Nx - 1;
ys = yy(i_1:i_2,:);
endif;
else
else # i_sim>1
i_1 = 1;
endif
if doing_sensitivities
if doing_sensitivities
i_2 = i_1 - 1 + n_y;
ys = [ys; yy(i_1:i_2,:)];
endif;
ys = [ys; yy(2:n_y:2*n_y,:)];
endif;
endif
endfor;
endfor;
##RealTime = [S T]
endfunction
EOF
else
|