1 | /******************************************************************************/ |
---|
2 | /* */ |
---|
3 | /* CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran) */ |
---|
4 | /* */ |
---|
5 | /* Copyright or © or Copr. Laurent Debreu (Laurent.Debreu@imag.fr) */ |
---|
6 | /* Cyril Mazauric (Cyril.Mazauric@imag.fr) */ |
---|
7 | /* This software is governed by the CeCILL-C license under French law and */ |
---|
8 | /* abiding by the rules of distribution of free software. You can use, */ |
---|
9 | /* modify and/ or redistribute the software under the terms of the CeCILL-C */ |
---|
10 | /* license as circulated by CEA, CNRS and INRIA at the following URL */ |
---|
11 | /* "http://www.cecill.info". */ |
---|
12 | /* */ |
---|
13 | /* As a counterpart to the access to the source code and rights to copy, */ |
---|
14 | /* modify and redistribute granted by the license, users are provided only */ |
---|
15 | /* with a limited warranty and the software's author, the holder of the */ |
---|
16 | /* economic rights, and the successive licensors have only limited */ |
---|
17 | /* liability. */ |
---|
18 | /* */ |
---|
19 | /* In this respect, the user's attention is drawn to the risks associated */ |
---|
20 | /* with loading, using, modifying and/or developing or reproducing the */ |
---|
21 | /* software by the user in light of its specific status of free software, */ |
---|
22 | /* that may mean that it is complicated to manipulate, and that also */ |
---|
23 | /* therefore means that it is reserved for developers and experienced */ |
---|
24 | /* professionals having in-depth computer knowledge. Users are therefore */ |
---|
25 | /* encouraged to load and test the software's suitability as regards their */ |
---|
26 | /* requirements in conditions enabling the security of their systems and/or */ |
---|
27 | /* data to be ensured and, more generally, to use and operate it in the */ |
---|
28 | /* same conditions as regards security. */ |
---|
29 | /* */ |
---|
30 | /* The fact that you are presently reading this means that you have had */ |
---|
31 | /* knowledge of the CeCILL-C license and that you accept its terms. */ |
---|
32 | /******************************************************************************/ |
---|
33 | /* version 1.0 */ |
---|
34 | /******************************************************************************/ |
---|
35 | #include <stdio.h> |
---|
36 | #include <stdlib.h> |
---|
37 | #include <string.h> |
---|
38 | #include "decl.h" |
---|
39 | |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | /******************************************************************************/ |
---|
44 | /* FindAndChangeNameToTabvars */ |
---|
45 | /******************************************************************************/ |
---|
46 | /* */ |
---|
47 | /******************************************************************************/ |
---|
48 | /* if whichone = 0 ----> Agrif_tabvars(i) % var % array2 */ |
---|
49 | /* */ |
---|
50 | /* if whichone = 1 ----> Agrif_tabvars(i) % parentvar % var % array2 */ |
---|
51 | /* */ |
---|
52 | /******************************************************************************/ |
---|
53 | void FindAndChangeNameToTabvars(char name[LONGNOM],char toprint[LONGNOM], |
---|
54 | listvar * listtosee, int whichone) |
---|
55 | { |
---|
56 | listvar *newvar; |
---|
57 | int out; |
---|
58 | |
---|
59 | if ( strcasecmp(name,"") ) |
---|
60 | { |
---|
61 | newvar=listtosee; |
---|
62 | out=0; |
---|
63 | while( newvar && out == 0 ) |
---|
64 | { |
---|
65 | if ( !strcasecmp(newvar->var->nomvar,name) ) |
---|
66 | { |
---|
67 | out = 1; |
---|
68 | strcat(toprint,vargridcurgridtabvars(newvar->var,whichone)); |
---|
69 | } |
---|
70 | else newvar=newvar->suiv; |
---|
71 | } |
---|
72 | if ( out == 0 ) strcat(toprint,name); |
---|
73 | } |
---|
74 | } |
---|
75 | |
---|
76 | |
---|
77 | /******************************************************************************/ |
---|
78 | /* ChangeTheInitalvaluebyTabvarsName */ |
---|
79 | /******************************************************************************/ |
---|
80 | /* */ |
---|
81 | /******************************************************************************/ |
---|
82 | /* */ |
---|
83 | /* */ |
---|
84 | /* */ |
---|
85 | /******************************************************************************/ |
---|
86 | char *ChangeTheInitalvaluebyTabvarsName(char *nom,listvar *listtoread, int whichone) |
---|
87 | { |
---|
88 | char toprinttmp[LONGNOM]; |
---|
89 | int i; |
---|
90 | char chartmp[2]; |
---|
91 | |
---|
92 | i=0; |
---|
93 | strcpy(toprintglob,""); |
---|
94 | strcpy(toprinttmp,""); |
---|
95 | /* */ |
---|
96 | while ( i < strlen(nom) ) |
---|
97 | { |
---|
98 | if ( nom[i] == '+' ) |
---|
99 | { |
---|
100 | FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); |
---|
101 | strcpy(toprinttmp,""); |
---|
102 | strcat(toprintglob,"+"); |
---|
103 | } |
---|
104 | else if ( nom[i] == '-' ) |
---|
105 | { |
---|
106 | FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); |
---|
107 | strcpy(toprinttmp,""); |
---|
108 | strcat(toprintglob,"-"); |
---|
109 | } |
---|
110 | else if ( nom[i] == '*' ) |
---|
111 | { |
---|
112 | FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); |
---|
113 | strcpy(toprinttmp,""); |
---|
114 | strcat(toprintglob,"*"); |
---|
115 | } |
---|
116 | else if ( nom[i] == '/' ) |
---|
117 | { |
---|
118 | FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); |
---|
119 | strcpy(toprinttmp,""); |
---|
120 | strcat(toprintglob,"/"); |
---|
121 | } |
---|
122 | else if ( nom[i] == '(' ) |
---|
123 | { |
---|
124 | FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); |
---|
125 | strcpy(toprinttmp,""); |
---|
126 | strcat(toprintglob,"("); |
---|
127 | } |
---|
128 | else if ( nom[i] == ')' ) |
---|
129 | { |
---|
130 | FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); |
---|
131 | strcpy(toprinttmp,""); |
---|
132 | strcat(toprintglob,")"); |
---|
133 | } |
---|
134 | else if ( nom[i] == ':' ) |
---|
135 | { |
---|
136 | FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); |
---|
137 | strcpy(toprinttmp,""); |
---|
138 | strcat(toprintglob,":"); |
---|
139 | } |
---|
140 | else if ( nom[i] == ',' ) |
---|
141 | { |
---|
142 | FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); |
---|
143 | strcpy(toprinttmp,""); |
---|
144 | strcat(toprintglob,","); |
---|
145 | } |
---|
146 | else |
---|
147 | { |
---|
148 | sprintf(chartmp,"%c",nom[i]); |
---|
149 | strcat(toprinttmp,chartmp); |
---|
150 | } |
---|
151 | /* */ |
---|
152 | i=i+1; |
---|
153 | } |
---|
154 | FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); |
---|
155 | strcpy(toprinttmp,""); |
---|
156 | |
---|
157 | /* */ |
---|
158 | return toprintglob; |
---|
159 | } |
---|
160 | |
---|
161 | /******************************************************************************/ |
---|
162 | /* IsVariableReal */ |
---|
163 | /******************************************************************************/ |
---|
164 | /* */ |
---|
165 | /******************************************************************************/ |
---|
166 | /* */ |
---|
167 | /* */ |
---|
168 | /* */ |
---|
169 | /******************************************************************************/ |
---|
170 | int IsVariableReal(char *nom) |
---|
171 | { |
---|
172 | int Real; |
---|
173 | |
---|
174 | Real = 0; |
---|
175 | if ( ( nom[0] >= 'a' && nom[0] <= 'h' ) || |
---|
176 | ( nom[0] >= 'A' && nom[0] <= 'H' ) || |
---|
177 | ( nom[0] >= 'o' && nom[0] <= 'z' ) || |
---|
178 | ( nom[0] >= 'O' && nom[0] <= 'Z' ) |
---|
179 | ) |
---|
180 | { |
---|
181 | Real = 1; |
---|
182 | } |
---|
183 | /* */ |
---|
184 | return Real; |
---|
185 | } |
---|
186 | /******************************************************************************/ |
---|
187 | /* IsVarInUseFile */ |
---|
188 | /******************************************************************************/ |
---|
189 | /* */ |
---|
190 | /******************************************************************************/ |
---|
191 | /* */ |
---|
192 | /* */ |
---|
193 | /* */ |
---|
194 | /******************************************************************************/ |
---|
195 | void IsVarInUseFile(char *nom) |
---|
196 | { |
---|
197 | listvar *parcours; |
---|
198 | listparameter *parcoursparam; |
---|
199 | int out; |
---|
200 | |
---|
201 | out = 0; |
---|
202 | |
---|
203 | parcours = globliste; |
---|
204 | while( parcours && out == 0 ) |
---|
205 | { |
---|
206 | if ( !strcasecmp(nom,parcours->var->nomvar) ) out =1 ; |
---|
207 | else parcours=parcours->suiv; |
---|
208 | } |
---|
209 | if ( out == 0 ) |
---|
210 | { |
---|
211 | parcours = globparam; |
---|
212 | while( parcours && out == 0 ) |
---|
213 | { |
---|
214 | if ( !strcasecmp(nom,parcours->var->nomvar) ) out =1 ; |
---|
215 | else parcours=parcours->suiv; |
---|
216 | } |
---|
217 | } |
---|
218 | if ( out == 0 ) |
---|
219 | { |
---|
220 | parcours = parameterlist; |
---|
221 | while( parcours && out == 0 ) |
---|
222 | { |
---|
223 | if ( !strcasecmp(nom,parcours->var->nomvar) ) out =1 ; |
---|
224 | else parcours=parcours->suiv; |
---|
225 | } |
---|
226 | } |
---|
227 | if ( out == 0 ) |
---|
228 | { |
---|
229 | parcoursparam = tmpparameterlocallist; |
---|
230 | while( parcoursparam && out == 0 ) |
---|
231 | { |
---|
232 | if ( !strcasecmp(nom,parcoursparam->name) ) out =2 ; |
---|
233 | else parcoursparam=parcoursparam->suiv; |
---|
234 | } |
---|
235 | } |
---|
236 | if ( out == 0 ) |
---|
237 | { |
---|
238 | parcours = globalvarofusefile; |
---|
239 | while( parcours && out == 0 ) |
---|
240 | { |
---|
241 | if ( !strcasecmp(nom,parcours->var->nomvar) ) out =2 ; |
---|
242 | else parcours=parcours->suiv; |
---|
243 | } |
---|
244 | } |
---|
245 | if ( out == 0 || out == 2 ) |
---|
246 | { |
---|
247 | parcoursparam = tmpparameterlocallist2; |
---|
248 | while( parcoursparam && out != 1 ) |
---|
249 | { |
---|
250 | if ( !strcasecmp(nom,parcoursparam->name) ) out =1 ; |
---|
251 | else parcoursparam=parcoursparam->suiv; |
---|
252 | } |
---|
253 | if ( out == 1 ) |
---|
254 | { |
---|
255 | strcpy(charusemodule,parcoursparam->modulename); |
---|
256 | Addmoduletothelist(parcoursparam->modulename); |
---|
257 | } |
---|
258 | } |
---|
259 | if ( out == 0 ) printf("--- in UtilCharacter we do not found the \n"); |
---|
260 | if ( out == 0 ) printf("--- variable %s, the module where this \n",nom); |
---|
261 | if ( out == 0 ) printf("--- variable has been defined has not been\n"); |
---|
262 | if ( out == 0 ) printf("--- found.\n"); |
---|
263 | } |
---|
264 | |
---|
265 | /******************************************************************************/ |
---|
266 | /* DecomposeTheNameinlistnom */ |
---|
267 | /******************************************************************************/ |
---|
268 | /* Firstpass 0 */ |
---|
269 | /******************************************************************************/ |
---|
270 | /* */ |
---|
271 | /* */ |
---|
272 | /******************************************************************************/ |
---|
273 | listnom *DecomposeTheNameinlistnom(char *nom, listnom * listout) |
---|
274 | { |
---|
275 | char toprinttmp[LONGNOM]; |
---|
276 | int i; |
---|
277 | char chartmp[2]; |
---|
278 | |
---|
279 | i=0; |
---|
280 | strcpy(toprinttmp,""); |
---|
281 | /* */ |
---|
282 | while ( i < strlen(nom) ) |
---|
283 | { |
---|
284 | if ( nom[i] == '+' || |
---|
285 | nom[i] == '-' || |
---|
286 | nom[i] == '*' || |
---|
287 | nom[i] == '/' || |
---|
288 | nom[i] == ')' || |
---|
289 | nom[i] == '(' || |
---|
290 | nom[i] == ',' || |
---|
291 | nom[i] == ':' |
---|
292 | ) |
---|
293 | { |
---|
294 | if (strcasecmp(toprinttmp,"") && ( toprinttmp[0] >= 'A' ) ) |
---|
295 | { |
---|
296 | listout = Addtolistnom(toprinttmp,listout); |
---|
297 | |
---|
298 | } |
---|
299 | strcpy(toprinttmp,""); |
---|
300 | } |
---|
301 | else |
---|
302 | { |
---|
303 | sprintf(chartmp,"%c",nom[i]); |
---|
304 | strcat(toprinttmp,chartmp); |
---|
305 | } |
---|
306 | /* */ |
---|
307 | i=i+1; |
---|
308 | } |
---|
309 | if (strcasecmp(toprinttmp,"") && ( toprinttmp[0] >= 'A' ) ) |
---|
310 | { |
---|
311 | listout = Addtolistnom(toprinttmp,listout); |
---|
312 | } |
---|
313 | strcpy(toprinttmp,""); |
---|
314 | |
---|
315 | return listout; |
---|
316 | } |
---|
317 | |
---|
318 | |
---|
319 | /******************************************************************************/ |
---|
320 | /* DecomposeTheName */ |
---|
321 | /******************************************************************************/ |
---|
322 | /* Firstpass 0 */ |
---|
323 | /******************************************************************************/ |
---|
324 | /* */ |
---|
325 | /* Agrif_<toto>(variable) ====> Agrif_<toto>(variable) */ |
---|
326 | /* */ |
---|
327 | /******************************************************************************/ |
---|
328 | void DecomposeTheName(char *nom) |
---|
329 | { |
---|
330 | char toprinttmp[LONGNOM]; |
---|
331 | int i; |
---|
332 | char chartmp[2]; |
---|
333 | |
---|
334 | i=0; |
---|
335 | strcpy(toprinttmp,""); |
---|
336 | /* */ |
---|
337 | while ( i < strlen(nom) ) |
---|
338 | { |
---|
339 | if ( nom[i] == '+' || |
---|
340 | nom[i] == '-' || |
---|
341 | nom[i] == '*' || |
---|
342 | nom[i] == '/' || |
---|
343 | nom[i] == ')' || |
---|
344 | nom[i] == '(' || |
---|
345 | nom[i] == ',' || |
---|
346 | nom[i] == ':' |
---|
347 | ) |
---|
348 | { |
---|
349 | if (strcasecmp(toprinttmp,"") && ( toprinttmp[0] >= 'A' ) ) |
---|
350 | { |
---|
351 | ajoutevarindoloop_definedimension (toprinttmp); |
---|
352 | /* Is this variable present in globvarofusefile */ |
---|
353 | IsVarInUseFile(toprinttmp); |
---|
354 | } |
---|
355 | strcpy(toprinttmp,""); |
---|
356 | } |
---|
357 | else |
---|
358 | { |
---|
359 | sprintf(chartmp,"%c",nom[i]); |
---|
360 | strcat(toprinttmp,chartmp); |
---|
361 | } |
---|
362 | /* */ |
---|
363 | i=i+1; |
---|
364 | } |
---|
365 | if (strcasecmp(toprinttmp,"") && ( toprinttmp[0] >= 'A' ) ) |
---|
366 | { |
---|
367 | ajoutevarindoloop_definedimension (toprinttmp); |
---|
368 | /* Is this variable present in globvarofusefile */ |
---|
369 | IsVarInUseFile(toprinttmp); |
---|
370 | } |
---|
371 | strcpy(toprinttmp,""); |
---|
372 | |
---|
373 | } |
---|