Overview
Comment:Still debugging
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: ab8dd4dd755ff0096ea18477449f5b201821be81a1e02afe9aeced039202990e
User & Date: gawthrop@users.sourceforge.net on 2000-05-16 18:57:15
Other Links: branch diff | manifest | tags
Context
2000-05-16
18:58:44
Neater comment zapping check-in: f16ab3a818 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
18:57:15
Still debugging check-in: ab8dd4dd75 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
18:56:58
Now realised that libp2c.a avoids many probs - so simplified it. check-in: 7bbb3f938f user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/mtt_make_sim from [dfe57882cc] to [66e152333a].

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.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
## Put in c version + sensitivity computation
##
## Revision 1.1  2000/04/08 10:43:26  peterg
## Initial revision
##
###############################################################
60
61
62
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
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
124
125





126

127
128


129
130
131



132
133
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
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
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
124
125
126
127




128
129
130
131
132
133
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







+
-
+



+














+
-
+
-




+
+
+
+
+
+



-

-

+
+
-
+

-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+

-
+

-
+

-
+
+
+

+
+
+
+
+
-
+
+


-
-
-
+
+
+
+
+

+
-
-
+
+
-
-
-
+
+
+

-
-
-
-
+
+
+
+
+
+
+
+


-
+
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+

+
-
+







  endif;

  ##Sizes
  N = length(t);
  [n_u,N_u] = size(u);

  ## Doing sensitivities (assumes sensitivity system is invoked)
  n_sens = length(sensitivities);
  doing_sensitivities = (length(sensitivities)>0);
  doing_sensitivities = (n_sens>0);
  if doing_sensitivities
    n_y = $Ny/2;
    doing_state=0;
    ys = [];
  else
    n_y = $Ny;
    doing_state=(nargout>1);
  endif;



  ## Initialise
  ui = zeros(n_u,1);	# Initial control
  [xi] = x0;	        # Read in initial state

  ## Timing parameters
  first = t(1);
  dt = t(2) - t(1);
  n_t = length(t);
  last = t(length(t));
  last = t(n_t);
  n_sens = length(sensitivities);
EOF

if [ "$computation" = "c" ]; then
cat >> $1_sim.m <<EOF
  T = "";
  S = "";

  S = [S;"Save\t"];
  tim = time;

  ## Create the system input file
  t1 = [0:N_u-1]*dt; # Create time vector from zero (to fit u);
  ut = [t1' u'];
##  tick1=time;
  save -ascii $1_input.dat ut 
##  save_time = time-tick1

  ## Create the state file
  xi = [[1:$Nx]' x0]; #'
  ##system("strip_comments <mtt_junk.dat >mtt_u.dat;"); #Strip the leading comments
  save -ascii   $1_state.dat xi

  ## Create the command string
##  tick1=time;
  command = "";
  for sensitivity_index = [0 sensitivities]
    args = "";
    for i=1:$Nx
      args = sprintf("%s %g", args, x0(i));
    endfor
  ## Create the sympar file
  save -ascii   $1_simpar.dat dt

  ## Create the numpar file
  [n_par,m_par] = size(par);
  if m_par==1
    if n_par!=$Npar
      error(sprintf("Number of parameters is %i, should be %i", n_par, $Npar));
    else
      ipar= [[1:$Npar]' par]; #' 
    endif
  elseif m_par==2
    ipar = par;
  else
    error(sprintf("Number of parameter columns is %i, should be 1 or 2", m_par));
  endif;

    par(sensitivities) = zeros(1,n_sens);
    if sensitivity_index>0
      par(sensitivity_index) = 1;
      i_1 = 2+n_y;
  if !doing_sensitivities
      save -ascii   $1_numpar.dat ipar 
  endif;

  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;
    else
      i_1 = 2;
      i_1 = 2+n_y;
    endif;
 

    if doing_state
      i_2 = i_1 + n_y + $Nx;
      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 = 2 + n_y;
        ipars = [ipar; [sensitivities(i_sim) 1]];
        save -ascii   $1_numpar.dat ipars 
      else
      i_2 = i_1 + n_y -1;
        i_2 = i_1 + n_y -1;
      endif
    endif;

    for i=1:$Npar
      args = sprintf("%s %g", args, par(i));
    endfor
    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;

  ## Execute external programme
    args = sprintf("%s %g %g %g", args, first, dt, last);
  
  S = [S;sprintf("Run %i\t",i_sim)];
  tim = time;
    command = sprintf("%s ./$1_ode2odes.out< $1_input.dat %s | cut -f %i-%i;", command, args, i_1, i_2);
  endfor;
##  string_time = time-tick1
  yy_str=system(command);
  dtime = time-tim;
  T = [T; num2str(dtime)];

  ## And execute it ...
##  tick1=time;
  yy=str2num(system(command));
##  command_time = time-tick1
  ## 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);

  ## Reshape
  if i_sim==1
  yy = reshape(yy,N,M_yy*(1+n_sens))';  
  y = yy(1:n_y,:);              # Output

  if doing_sensitivities
    y = yy(1:n_y,:);              # Output
    i_1 = n_y+1;
    if doing_state 
    i_1 = n_y+1;
    i_2 = i_1 + n_y*n_sens - 1;
    ys = yy(i_1:i_2,:);		# sensitivity
  endif;
  if doing_state
    i_1 = n_y+2;
    i_2 = i_1 + $Nx - 1;
    ys = yy(i_1:i_2,:);		# state
  endif;
      i_2 = i_1 + $Nx - 1;
      ys = yy(i_1:i_2,:);
    endif;
  else
    i_1 = 1;
  endif

  if doing_sensitivities
    i_2 = i_1 - 1 + n_y;
    ys =  [ys; yy(i_1:i_2,:)];
  endif; 

  endfor;
##  sim_time = time-tick
  ##RealTime = [S T]
endfunction

EOF
    
else

cat >> $1_sim.m <<EOF    


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