Overview
Comment:Includes the sympar.c file.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: eca91ad38b7081a5db90d590e48bd24c0bc089d2171b132bd0b57820bfdce0ec
User & Date: gawthrop@users.sourceforge.net on 1997-03-20 14:51:11
Other Links: branch diff | manifest | tags
Context
1997-03-20
14:52:41
Initial revision check-in: 5eca2f682d user: gawthrop@users.sourceforge.net tags: origin/master, trunk
14:51:11
Includes the sympar.c file. check-in: eca91ad38b user: gawthrop@users.sourceforge.net tags: origin/master, trunk
14:36:56
Includes the sympar.h file check-in: 0f6bed5ddb user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/ode_r2c from [b5b6f49694] to [2a37f33be2].

16
17
18
19
20
21
22



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Copyright (c) P.J.Gawthrop 1997.

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



## Revision 1.1  1997/01/21 10:52:23  peterg
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_ode.c

# Remove the old  files
rm -f $1_ode.c1 $1_ode.c2 $1_ode.c3 $1_ode.c

# Remove the old log file
rm -f ode_r2c.log

# Use reduce to accomplish the transformation
reduce >ode_r2c.log << EOF








>
>
>









|







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Copyright (c) P.J.Gawthrop 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.2  1997/01/21  22:57:17  peterg
# Various bug fixes.
#
## Revision 1.1  1997/01/21 10:52:23  peterg
## Initial revision
##
###############################################################

# Inform user
echo Creating $1_ode.c

# Remove the old  files
rm -f  $1_ode.c1 $1_ode.c2 $1_ode.c

# Remove the old log file
rm -f ode_r2c.log

# Use reduce to accomplish the transformation
reduce >ode_r2c.log << EOF

51
52
53
54
55
56
57

58
59
60
61
62
63
64


ON BigFloat, NumVal;
PRECISION 16; %Compatible with Matlab
%OFF Nat;

ON NERO;        % Suppress zero elements


%Generate the Header part
OUT "$1_ode.c1";

write "/*"$
write "Differential algebraic eqns in c form for system $1"$
write "NB Arrays should be defined to be one larger than expected"$







>







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68


ON BigFloat, NumVal;
PRECISION 16; %Compatible with Matlab
%OFF Nat;

ON NERO;        % Suppress zero elements


%Generate the Header part
OUT "$1_ode.c1";

write "/*"$
write "Differential algebraic eqns in c form for system $1"$
write "NB Arrays should be defined to be one larger than expected"$
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

write "void $1_ode()"$

write "  "$
write "{"$

write "/* Declare standard arrays */"$
write "  extern float y[", MTTNy+1, "]; /* $1_ode output */"$
write "  extern float dx[", MTTNx+1, "]; /* $1_ode state derivative */"$ 
write "  extern float x[", MTTNx+1, "]; /* $1_ode state */"$ 
write "  extern float u[", MTTNu+1, "]; /* $1_ode input */"$

%External (global) variable list
write "/* External (global) variable list */ "$
IF MTTNvar>0 THEN
BEGIN
  FOR i := 1:MTTNvar DO
    IF numberp(MTTVar(i,1)) 
      THEN 
      BEGIN
      % Do nowt
      END
      ELSE
      BEGIN
         write "extern float ", MTTVar(i,1), ";"$
      END$
END$

%Declare the dummy variables t0--t9
write "/* Dummy variable list */ "$
write "  float t0;"$
FOR i := 1:9 DO
BEGIN
  write "  float t", i, ";"$
END$

%Declarations$
write "/* State variable list */ "$
FOR i := 1:MTTNx DO
BEGIN
  write "  float mttx", i, ";"$
END$

write "/* Input variable list */ "$
FOR i := 1:MTTNu DO
BEGIN
  write "  float mttu", i, ";"$
END$

write "/* Counter */ "$
write "  int i;"$




write "  "$
write "    /*====== Set up the state variables ======*/"$
FOR i := 1:MTTNx DO
BEGIN
  write "    mttx", i, " = x[", i, "];"$
END$







|
|
|
|

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


|


|






|





|





>
>







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

write "void $1_ode()"$

write "  "$
write "{"$

write "/* Declare standard arrays */"$
write "  extern double y[", MTTNy+1, "]; /* $1_ode output */"$
write "  extern double dx[", MTTNx+1, "]; /* $1_ode state derivative */"$ 
write "  extern double x[", MTTNx+1, "]; /* $1_ode state */"$ 
write "  extern double u[", MTTNu+1, "]; /* $1_ode input */"$

















%Declare the dummy variables t0--t9
write "/* Dummy variable list */ "$
write "  double t0;"$
FOR i := 1:9 DO
BEGIN
  write "  double t", i, ";"$
END$

%Declarations$
write "/* State variable list */ "$
FOR i := 1:MTTNx DO
BEGIN
  write "  double mttx", i, ";"$
END$

write "/* Input variable list */ "$
FOR i := 1:MTTNu DO
BEGIN
  write "  double mttu", i, ";"$
END$

write "/* Counter */ "$
write "  int i;"$

write "/* Parameter  list */ "$
write "#include ", """$1_sympar.c"""$

write "  "$
write "    /*====== Set up the state variables ======*/"$
FOR i := 1:MTTNx DO
BEGIN
  write "    mttx", i, " = x[", i, "];"$
END$
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
  END$
END$


write "  "$
write "    /*====== Compute the state derivative and output ======*/"$

SHUT "$1_ode.c1";

% Load the general translator package
LOAD GENTRAN;
GENTRANLANG!* := 'C;
ON GENTRANSEG;
MAXEXPPRINTLEN!* := 80;








|







131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
  END$
END$


write "  "$
write "    /*====== Compute the state derivative and output ======*/"$

SHUT $1_ode.c1

% Load the general translator package
LOAD GENTRAN;
GENTRANLANG!* := 'C;
ON GENTRANSEG;
MAXEXPPRINTLEN!* := 80;

177
178
179
180
181
182
183
184
185
186
187
END$


GENTRANSHUT "$1_ode.c2";

EOF

echo '};' > $1_ode.c3
cat $1_ode.c1 $1_ode.c2 $1_ode.c3> $1_ode.c









|



167
168
169
170
171
172
173
174
175
176
177
END$


GENTRANSHUT "$1_ode.c2";

EOF

echo '}' > $1_ode.c3
cat $1_ode.c1 $1_ode.c2 $1_ode.c3> $1_ode.c



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