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@yahoo.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.6 */ |
---|
34 | /******************************************************************************/ |
---|
35 | #include <stdio.h> |
---|
36 | #include <stdlib.h> |
---|
37 | #include <string.h> |
---|
38 | #include "decl.h" |
---|
39 | |
---|
40 | |
---|
41 | /******************************************************************************/ |
---|
42 | /* Creation and modification of .dependfile */ |
---|
43 | /******************************************************************************/ |
---|
44 | /* .dependnbxnby : this file contains tabvars indices of variables*/ |
---|
45 | /* given in agrif.in as number of cells */ |
---|
46 | /* .dependuse<module> : this file contains all modules used in the */ |
---|
47 | /* current file */ |
---|
48 | /* .dependparameter<module> : this file contains all parmeters defined in */ |
---|
49 | /* the current file */ |
---|
50 | /* .depend<module name> : this file contains all globals variables */ |
---|
51 | /* informations (name, dim, etc ...) */ |
---|
52 | /* .dependavailable : this file contains all tabvars indices which */ |
---|
53 | /* are not used. */ |
---|
54 | /******************************************************************************/ |
---|
55 | |
---|
56 | |
---|
57 | /******************************************************************************/ |
---|
58 | /* Writethedependnbxnbyfile */ |
---|
59 | /******************************************************************************/ |
---|
60 | /* This subroutine is used to create the .dependnbxnby */ |
---|
61 | /******************************************************************************/ |
---|
62 | /* */ |
---|
63 | /* .dependnbxnby */ |
---|
64 | /* */ |
---|
65 | /* nbmaillesX */ |
---|
66 | /* nbmaillesY */ |
---|
67 | /* nbmaillesZ */ |
---|
68 | /* */ |
---|
69 | /******************************************************************************/ |
---|
70 | void Writethedependnbxnbyfile() |
---|
71 | { |
---|
72 | FILE *dependfileoutput; |
---|
73 | listvar *parcours; |
---|
74 | int out; |
---|
75 | |
---|
76 | /* We are looking for all the variable of the current filetoparse file */ |
---|
77 | /* in the List_Global_Var */ |
---|
78 | parcours =List_Global_Var; |
---|
79 | out = 0; |
---|
80 | while (parcours && out == 0 ) |
---|
81 | { |
---|
82 | if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesX) ) out = 1; |
---|
83 | else parcours = parcours->suiv; |
---|
84 | } |
---|
85 | if ( out == 0 ) |
---|
86 | { |
---|
87 | parcours =List_Common_Var; |
---|
88 | while (parcours && out == 0 ) |
---|
89 | { |
---|
90 | if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesX) ) out = 1; |
---|
91 | else parcours = parcours->suiv; |
---|
92 | } |
---|
93 | } |
---|
94 | if ( out == 1 ) |
---|
95 | { |
---|
96 | dependfileoutput = fopen(".dependnbxnby","w"); |
---|
97 | fprintf(dependfileoutput,"%d\n",parcours->var->v_indicetabvars); |
---|
98 | IndicenbmaillesX = parcours->var->v_indicetabvars; |
---|
99 | |
---|
100 | if ( dimprob > 1 ) |
---|
101 | { |
---|
102 | parcours =List_Global_Var; |
---|
103 | out = 0; |
---|
104 | while (parcours && out == 0 ) |
---|
105 | { |
---|
106 | if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesY) ) out = 1; |
---|
107 | else parcours = parcours->suiv; |
---|
108 | } |
---|
109 | if ( out == 0 ) |
---|
110 | { |
---|
111 | parcours =List_Common_Var; |
---|
112 | while (parcours && out == 0 ) |
---|
113 | { |
---|
114 | if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesY) ) out = 1; |
---|
115 | else parcours = parcours->suiv; |
---|
116 | } |
---|
117 | } |
---|
118 | if ( out == 1 ) |
---|
119 | { |
---|
120 | fprintf(dependfileoutput,"%d\n",parcours->var->v_indicetabvars); |
---|
121 | IndicenbmaillesY = parcours->var->v_indicetabvars; |
---|
122 | } |
---|
123 | } |
---|
124 | |
---|
125 | if ( dimprob > 2 ) |
---|
126 | { |
---|
127 | parcours =List_Global_Var; |
---|
128 | out = 0; |
---|
129 | while (parcours && out == 0 ) |
---|
130 | { |
---|
131 | if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesZ) ) out = 1; |
---|
132 | else parcours = parcours->suiv; |
---|
133 | } |
---|
134 | if ( out == 0 ) |
---|
135 | { |
---|
136 | parcours =List_Common_Var; |
---|
137 | while (parcours && out == 0 ) |
---|
138 | { |
---|
139 | if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesZ) ) out = 1; |
---|
140 | else parcours = parcours->suiv; |
---|
141 | } |
---|
142 | } |
---|
143 | if ( out == 1 ) |
---|
144 | { |
---|
145 | fprintf(dependfileoutput,"%d\n",parcours->var->v_indicetabvars); |
---|
146 | IndicenbmaillesZ = parcours->var->v_indicetabvars; |
---|
147 | } |
---|
148 | } |
---|
149 | |
---|
150 | if ( out == 1 ) fclose(dependfileoutput); |
---|
151 | } |
---|
152 | } |
---|
153 | |
---|
154 | /******************************************************************************/ |
---|
155 | /* Readthedependnbxnbyfile */ |
---|
156 | /******************************************************************************/ |
---|
157 | /* This subroutine is used to create the .dependnbxnby */ |
---|
158 | /******************************************************************************/ |
---|
159 | /* */ |
---|
160 | /* .dependnbxnby */ |
---|
161 | /* */ |
---|
162 | /* nbmaillesX */ |
---|
163 | /* nbmaillesY */ |
---|
164 | /* nbmaillesZ */ |
---|
165 | /* */ |
---|
166 | /******************************************************************************/ |
---|
167 | void Readthedependnbxnbyfile() |
---|
168 | { |
---|
169 | FILE *dependfileoutput; |
---|
170 | |
---|
171 | if ((dependfileoutput = fopen(".dependnbxnby","r"))!=NULL) |
---|
172 | { |
---|
173 | fscanf(dependfileoutput,"%d\n",&IndicenbmaillesX); |
---|
174 | if ( dimprob > 1 ) fscanf(dependfileoutput,"%d\n",&IndicenbmaillesY); |
---|
175 | if ( dimprob > 2 ) fscanf(dependfileoutput,"%d\n",&IndicenbmaillesZ); |
---|
176 | fclose(dependfileoutput); |
---|
177 | } |
---|
178 | } |
---|
179 | |
---|
180 | /******************************************************************************/ |
---|
181 | /* Writethedependlistofmoduleused */ |
---|
182 | /******************************************************************************/ |
---|
183 | /* This subroutine is used to create the .dependuse<module> */ |
---|
184 | /******************************************************************************/ |
---|
185 | /* */ |
---|
186 | /* .dependuse<name> */ |
---|
187 | /* */ |
---|
188 | /* mod1 */ |
---|
189 | /* mod2 */ |
---|
190 | /* */ |
---|
191 | /******************************************************************************/ |
---|
192 | void Writethedependlistofmoduleused(char *NameTampon ) |
---|
193 | { |
---|
194 | FILE *dependfileoutput; |
---|
195 | listusemodule *parcours; |
---|
196 | char ligne[LONGNOM]; |
---|
197 | |
---|
198 | |
---|
199 | if ( List_NameOfModuleUsed ) |
---|
200 | { |
---|
201 | convert2lower(NameTampon); |
---|
202 | sprintf(ligne,".dependuse%s",NameTampon); |
---|
203 | dependfileoutput = fopen(ligne,"w"); |
---|
204 | /* */ |
---|
205 | parcours = List_NameOfModuleUsed; |
---|
206 | while (parcours) |
---|
207 | { |
---|
208 | if ( !strcasecmp(NameTampon,parcours->u_modulename) && |
---|
209 | !strcasecmp(parcours->u_cursubroutine,"") |
---|
210 | ) |
---|
211 | { |
---|
212 | /* We are looking for all the variable of the current */ |
---|
213 | /* filetoparse file in the List_Global_Var */ |
---|
214 | fprintf(dependfileoutput,"%s\n",parcours->u_usemodule); |
---|
215 | } |
---|
216 | parcours = parcours->suiv; |
---|
217 | } |
---|
218 | fclose(dependfileoutput); |
---|
219 | } |
---|
220 | } |
---|
221 | |
---|
222 | /******************************************************************************/ |
---|
223 | /* Readthedependlistofmoduleused */ |
---|
224 | /******************************************************************************/ |
---|
225 | /* This subroutine is used to create the .dependuse<module> */ |
---|
226 | /******************************************************************************/ |
---|
227 | /* */ |
---|
228 | /* .dependuse<name> */ |
---|
229 | /* */ |
---|
230 | /* mod1 */ |
---|
231 | /* mod2 */ |
---|
232 | /* */ |
---|
233 | /******************************************************************************/ |
---|
234 | void Readthedependlistofmoduleused(char *NameTampon) |
---|
235 | { |
---|
236 | FILE *dependfileoutput; |
---|
237 | listusemodule *parcours; |
---|
238 | char ligne[LONGNOM]; |
---|
239 | |
---|
240 | convert2lower(NameTampon); |
---|
241 | sprintf(ligne,".dependuse%s",NameTampon); |
---|
242 | |
---|
243 | tmpuselocallist = (listusemodule *)NULL; |
---|
244 | if ((dependfileoutput = fopen(ligne,"r"))==NULL) |
---|
245 | { |
---|
246 | } |
---|
247 | else |
---|
248 | { |
---|
249 | /* if the file exist we should verify that this file has changed */ |
---|
250 | while (!feof(dependfileoutput)) |
---|
251 | { |
---|
252 | parcours=(listusemodule *)malloc(sizeof(listusemodule)); |
---|
253 | fscanf(dependfileoutput,"%s\n",parcours->u_usemodule); |
---|
254 | |
---|
255 | parcours->suiv = tmpuselocallist; |
---|
256 | tmpuselocallist = parcours; |
---|
257 | |
---|
258 | parcours = NULL; |
---|
259 | } |
---|
260 | fclose(dependfileoutput); |
---|
261 | } |
---|
262 | } |
---|
263 | |
---|
264 | |
---|
265 | /******************************************************************************/ |
---|
266 | /* WritedependParameterList */ |
---|
267 | /******************************************************************************/ |
---|
268 | /* This subroutine is used to create the .dependparameter<name> */ |
---|
269 | /******************************************************************************/ |
---|
270 | /* */ |
---|
271 | /* .dependparameter<name> */ |
---|
272 | /* */ |
---|
273 | /* mod1 */ |
---|
274 | /* mod2 */ |
---|
275 | /* */ |
---|
276 | /******************************************************************************/ |
---|
277 | void WritedependParameterList(char *NameTampon ) |
---|
278 | { |
---|
279 | FILE *dependfileoutput; |
---|
280 | listvar *parcours; |
---|
281 | char ligne[LONGNOM]; |
---|
282 | |
---|
283 | if ( List_GlobalParameter_Var ) |
---|
284 | { |
---|
285 | convert2lower(NameTampon); |
---|
286 | sprintf(ligne,".dependparameter%s",NameTampon); |
---|
287 | dependfileoutput = fopen(ligne,"w"); |
---|
288 | /* */ |
---|
289 | parcours = List_GlobalParameter_Var; |
---|
290 | while (parcours) |
---|
291 | { |
---|
292 | if ( !strcasecmp(NameTampon,parcours->var->v_modulename) ) |
---|
293 | { |
---|
294 | fprintf(dependfileoutput,"%s\n",parcours->var->v_nomvar); |
---|
295 | fprintf(dependfileoutput,"%s\n",parcours->var->v_modulename); |
---|
296 | } |
---|
297 | parcours = parcours->suiv; |
---|
298 | } |
---|
299 | fclose(dependfileoutput); |
---|
300 | } |
---|
301 | } |
---|
302 | |
---|
303 | |
---|
304 | /******************************************************************************/ |
---|
305 | /* ReaddependParameterList */ |
---|
306 | /******************************************************************************/ |
---|
307 | /* This subroutine is used to create the .dependparameter<name> */ |
---|
308 | /******************************************************************************/ |
---|
309 | /* */ |
---|
310 | /* .dependparameter<name> */ |
---|
311 | /* */ |
---|
312 | /* mod1 */ |
---|
313 | /* mod2 */ |
---|
314 | /* */ |
---|
315 | /******************************************************************************/ |
---|
316 | listparameter *ReaddependParameterList(char *NameTampon,listparameter *listout) |
---|
317 | { |
---|
318 | FILE *dependfileoutput; |
---|
319 | listparameter *parcours; |
---|
320 | char ligne[LONGNOM]; |
---|
321 | |
---|
322 | convert2lower(NameTampon); |
---|
323 | sprintf(ligne,".dependparameter%s",NameTampon); |
---|
324 | |
---|
325 | if ((dependfileoutput = fopen(ligne,"r"))==NULL) |
---|
326 | { |
---|
327 | } |
---|
328 | else |
---|
329 | { |
---|
330 | /* if the file exist we should verify that this file has changed */ |
---|
331 | while (!feof(dependfileoutput)) |
---|
332 | { |
---|
333 | parcours=(listparameter *)malloc(sizeof(listparameter)); |
---|
334 | fscanf(dependfileoutput,"%s\n",parcours->p_name); |
---|
335 | fscanf(dependfileoutput,"%s\n",parcours->p_modulename); |
---|
336 | |
---|
337 | parcours->suiv = listout; |
---|
338 | listout = parcours; |
---|
339 | |
---|
340 | parcours = NULL; |
---|
341 | } |
---|
342 | fclose(dependfileoutput); |
---|
343 | } |
---|
344 | return listout; |
---|
345 | } |
---|
346 | |
---|
347 | /******************************************************************************/ |
---|
348 | /* Writethedependfile */ |
---|
349 | /******************************************************************************/ |
---|
350 | /* This subroutine is used to create the .depend<name> */ |
---|
351 | /******************************************************************************/ |
---|
352 | /* */ |
---|
353 | /* .depend<name> */ |
---|
354 | /* */ |
---|
355 | /* REAL */ |
---|
356 | /* Variable */ |
---|
357 | /* char dimension or T */ |
---|
358 | /* table dimension */ |
---|
359 | /* is type given */ |
---|
360 | /* precision or T */ |
---|
361 | /* initial value or T */ |
---|
362 | /* indice in the tabvars */ |
---|
363 | /* listdimension or T */ |
---|
364 | /* ------------------------- */ |
---|
365 | /* */ |
---|
366 | /******************************************************************************/ |
---|
367 | void Writethedependfile(char *NameTampon, listvar *input ) |
---|
368 | { |
---|
369 | FILE *dependfileoutput; |
---|
370 | listvar *parcours; |
---|
371 | listdim *dims; |
---|
372 | char ligne[LONGNOM]; |
---|
373 | char listdimension[LONGNOM]; |
---|
374 | char curname[LONGNOM]; |
---|
375 | int out; |
---|
376 | |
---|
377 | if ( input ) |
---|
378 | { |
---|
379 | convert2lower(NameTampon); |
---|
380 | |
---|
381 | sprintf(ligne,".depend%s",NameTampon); |
---|
382 | dependfileoutput = fopen(ligne,"w"); |
---|
383 | /* We are looking for all the variable of the current filetoparse file */ |
---|
384 | /* in the input */ |
---|
385 | parcours =input; |
---|
386 | out = 0; |
---|
387 | strcpy(curname,""); |
---|
388 | while (parcours && out == 0 ) |
---|
389 | { |
---|
390 | if ( !strcasecmp(parcours->var->v_modulename,NameTampon) || |
---|
391 | !strcasecmp(parcours->var->v_commonname,NameTampon) ) |
---|
392 | { |
---|
393 | /* */ |
---|
394 | if ( strcasecmp(curname,"") && |
---|
395 | !strcasecmp(curname,parcours->var->v_nomvar) ) out = 1 ; |
---|
396 | if ( !strcasecmp(curname,"") ) strcpy(curname,parcours->var->v_nomvar); |
---|
397 | /* */ |
---|
398 | if ( out == 0 ) |
---|
399 | { |
---|
400 | /********** TYPEVAR ************************************************/ |
---|
401 | fprintf(dependfileoutput,"%s\n",parcours->var->v_typevar); |
---|
402 | /********** NOMVAR *************************************************/ |
---|
403 | fprintf(dependfileoutput,"%s\n",parcours->var->v_nomvar); |
---|
404 | /********** DIMCHAR ************************************************/ |
---|
405 | if ( strcasecmp(parcours->var->v_dimchar,"") ) |
---|
406 | { |
---|
407 | fprintf(dependfileoutput,"%s\n",parcours->var->v_dimchar); |
---|
408 | } |
---|
409 | else |
---|
410 | { |
---|
411 | fprintf(dependfileoutput,"T\n"); |
---|
412 | } |
---|
413 | /********** COMMONINFILE *******************************************/ |
---|
414 | if ( strcasecmp(parcours->var->v_commoninfile,"") ) |
---|
415 | { |
---|
416 | fprintf(dependfileoutput,"%s\n",parcours->var->v_commoninfile); |
---|
417 | } |
---|
418 | else |
---|
419 | { |
---|
420 | fprintf(dependfileoutput,"T\n"); |
---|
421 | } |
---|
422 | /********** COMMONNAME *********************************************/ |
---|
423 | if ( strcasecmp(parcours->var->v_commonname,"") ) |
---|
424 | { |
---|
425 | fprintf(dependfileoutput,"%s\n",parcours->var->v_commonname); |
---|
426 | } |
---|
427 | else |
---|
428 | { |
---|
429 | fprintf(dependfileoutput,"T\n"); |
---|
430 | } |
---|
431 | /********** NBDIM **************************************************/ |
---|
432 | /* fprintf(dependfileoutput,"%d\n",parcours->var->v_nbdim);*/ |
---|
433 | /********** DIMENSIONGIVEN *****************************************/ |
---|
434 | /* fprintf(dependfileoutput,"%d\n",parcours->var->v_dimensiongiven);*/ |
---|
435 | /********** ALLOCATABLE ********************************************/ |
---|
436 | fprintf(dependfileoutput,"%d\n",parcours->var->v_allocatable); |
---|
437 | /********** POINTERDECLARE *****************************************/ |
---|
438 | fprintf(dependfileoutput,"%d\n",parcours->var->v_pointerdeclare); |
---|
439 | /********** PRECISION **********************************************/ |
---|
440 | if ( strcasecmp(parcours->var->v_precision,"") ) |
---|
441 | { |
---|
442 | fprintf(dependfileoutput,"%s\n",parcours->var->v_precision); |
---|
443 | } |
---|
444 | else |
---|
445 | { |
---|
446 | fprintf(dependfileoutput,"T\n"); |
---|
447 | } |
---|
448 | /********** INITIALVALUE *******************************************/ |
---|
449 | /* if ( strcasecmp(parcours->var->v_initialvalue,"") ) |
---|
450 | { |
---|
451 | fprintf(dependfileoutput,"%s\n",parcours->var->v_initialvalue); |
---|
452 | } |
---|
453 | else |
---|
454 | { |
---|
455 | fprintf(dependfileoutput,"T\n"); |
---|
456 | }*/ |
---|
457 | /********** NAMEINTYPENAME *****************************************/ |
---|
458 | if ( strcasecmp(parcours->var->v_nameinttypename,"") ) |
---|
459 | { |
---|
460 | fprintf(dependfileoutput,"%s\n",parcours->var->v_nameinttypename); |
---|
461 | } |
---|
462 | else |
---|
463 | { |
---|
464 | fprintf(dependfileoutput,"T\n"); |
---|
465 | } |
---|
466 | /********** INDICETABVARS ******************************************/ |
---|
467 | fprintf(dependfileoutput,"%d\n",parcours->var->v_indicetabvars); |
---|
468 | /********** READEDLISTDIMENSION ************************************/ |
---|
469 | if ( parcours->var->v_dimensiongiven == 1 ) |
---|
470 | { |
---|
471 | dims = parcours->var->v_dimension; |
---|
472 | strcpy(listdimension,""); |
---|
473 | while (dims) |
---|
474 | { |
---|
475 | sprintf(ligne,"%s:%s",dims->dim.first,dims->dim.last); |
---|
476 | strcat(listdimension,ligne); |
---|
477 | if ( dims->suiv ) |
---|
478 | { |
---|
479 | strcat(listdimension,","); |
---|
480 | } |
---|
481 | dims = dims->suiv; |
---|
482 | } |
---|
483 | fprintf(dependfileoutput,"%s\n",listdimension); |
---|
484 | } |
---|
485 | else |
---|
486 | { |
---|
487 | fprintf(dependfileoutput,"T\n"); |
---|
488 | } |
---|
489 | /*******************************************************************/ |
---|
490 | fprintf(dependfileoutput,"------------------------\n"); |
---|
491 | } |
---|
492 | } |
---|
493 | parcours = parcours->suiv; |
---|
494 | } |
---|
495 | fclose(dependfileoutput); |
---|
496 | } |
---|
497 | } |
---|
498 | |
---|
499 | /******************************************************************************/ |
---|
500 | /* Readthedependfile */ |
---|
501 | /******************************************************************************/ |
---|
502 | /* This subroutine is used to read the .dependfile<name> and to insert new */ |
---|
503 | /* information in the listout list. */ |
---|
504 | /******************************************************************************/ |
---|
505 | /* */ |
---|
506 | /* .dependmodule --------> = list of var */ |
---|
507 | /* */ |
---|
508 | /* not.dependmodule --------> */ |
---|
509 | /* */ |
---|
510 | /******************************************************************************/ |
---|
511 | listvar *Readthedependfile( char *NameTampon , listvar *listout) |
---|
512 | { |
---|
513 | char ligne[LONGNOM]; |
---|
514 | FILE *dependfileoutput; |
---|
515 | listvar *parcours0; |
---|
516 | listvar *parcours; |
---|
517 | listvar *parcoursprec; |
---|
518 | char nothing[LONGNOM]; |
---|
519 | int i; |
---|
520 | |
---|
521 | parcoursprec = (listvar *)NULL; |
---|
522 | |
---|
523 | convert2lower(NameTampon); |
---|
524 | sprintf(ligne,".depend%s",NameTampon); |
---|
525 | if ((dependfileoutput = fopen(ligne,"r"))==NULL) |
---|
526 | { |
---|
527 | /* if the file doesn't exist it means that it is the first time */ |
---|
528 | /* we tried to parse this file */ |
---|
529 | } |
---|
530 | else |
---|
531 | { |
---|
532 | /* if the file exist we should verify that this file has changed */ |
---|
533 | while (!feof(dependfileoutput)) |
---|
534 | { |
---|
535 | parcours=(listvar *)malloc(sizeof(listvar)); |
---|
536 | parcours->var=(variable *)malloc(sizeof(variable)); |
---|
537 | /* */ |
---|
538 | Init_Variable(parcours->var); |
---|
539 | /* */ |
---|
540 | /********** TYPEVAR ************************************************/ |
---|
541 | fscanf(dependfileoutput,"%s\n",parcours->var->v_typevar); |
---|
542 | /********** NOMVAR *************************************************/ |
---|
543 | fscanf(dependfileoutput,"%s\n",parcours->var->v_nomvar); |
---|
544 | /********** DIMCHAR ************************************************/ |
---|
545 | fscanf(dependfileoutput,"%s\n",parcours->var->v_dimchar); |
---|
546 | if ( !strcasecmp(parcours->var->v_dimchar,"T") ) |
---|
547 | { |
---|
548 | strcpy(parcours->var->v_dimchar,""); |
---|
549 | } |
---|
550 | /********** COMMONINFILE *******************************************/ |
---|
551 | fscanf(dependfileoutput,"%s\n",parcours->var->v_commoninfile); |
---|
552 | if ( !strcasecmp(parcours->var->v_commoninfile,"T") ) |
---|
553 | { |
---|
554 | strcpy(parcours->var->v_commoninfile,""); |
---|
555 | } |
---|
556 | /********** COMMONNAME *********************************************/ |
---|
557 | fscanf(dependfileoutput,"%s\n",parcours->var->v_commonname); |
---|
558 | if ( !strcasecmp(parcours->var->v_commonname,"T") ) |
---|
559 | { |
---|
560 | strcpy(parcours->var->v_commonname,""); |
---|
561 | } |
---|
562 | /********** NBDIM **************************************************/ |
---|
563 | /* fscanf(dependfileoutput,"%d\n",&parcours->var->v_nbdim);*/ |
---|
564 | /********** DIMENSIONGIVEN *****************************************/ |
---|
565 | /* fscanf(dependfileoutput,"%d\n",&parcours->var->v_dimensiongiven);*/ |
---|
566 | /********** ALLOCATABLE ********************************************/ |
---|
567 | fscanf(dependfileoutput,"%d\n",&parcours->var->v_allocatable); |
---|
568 | if ( parcours->var->v_allocatable == 1 ) |
---|
569 | { |
---|
570 | Add_Allocate_Var_1(parcours->var->v_nomvar, |
---|
571 | parcours->var->v_commonname); |
---|
572 | } |
---|
573 | /********** POINTERDECLARE *****************************************/ |
---|
574 | fscanf(dependfileoutput,"%d\n",&parcours->var->v_pointerdeclare); |
---|
575 | if ( parcours->var->v_pointerdeclare == 1 ) |
---|
576 | { |
---|
577 | Add_Pointer_Var_1(parcours->var->v_nomvar); |
---|
578 | } |
---|
579 | /********** PRECISION **********************************************/ |
---|
580 | fscanf(dependfileoutput,"%[^\n] \n",parcours->var->v_precision); |
---|
581 | if ( !strcasecmp(parcours->var->v_precision,"T") ) |
---|
582 | { |
---|
583 | strcpy(parcours->var->v_precision,""); |
---|
584 | } |
---|
585 | /********** INITIALVALUE *******************************************/ |
---|
586 | /* fscanf(dependfileoutput,"%[^\n] \n",parcours->var->v_initialvalue); |
---|
587 | if ( !strcasecmp(parcours->var->v_initialvalue,"T") ) |
---|
588 | { |
---|
589 | strcpy(parcours->var->v_initialvalue,""); |
---|
590 | }*/ |
---|
591 | /********** NAMEINTYPENAME *****************************************/ |
---|
592 | fscanf(dependfileoutput,"%[^\n] \n",parcours->var->v_nameinttypename); |
---|
593 | if ( !strcasecmp(parcours->var->v_nameinttypename,"T") ) |
---|
594 | { |
---|
595 | strcpy(parcours->var->v_nameinttypename,""); |
---|
596 | } |
---|
597 | /********** INDICETABVARS ******************************************/ |
---|
598 | fscanf(dependfileoutput,"%d\n",&parcours->var->v_indicetabvars); |
---|
599 | /********** READEDLISTDIMENSION ************************************/ |
---|
600 | fscanf(dependfileoutput,"%s\n",parcours->var->v_readedlistdimension); |
---|
601 | if ( !strcasecmp(parcours->var->v_readedlistdimension,"T") ) |
---|
602 | { |
---|
603 | strcpy(parcours->var->v_readedlistdimension,""); |
---|
604 | } |
---|
605 | else |
---|
606 | { |
---|
607 | parcours->var->v_dimensiongiven = 1; |
---|
608 | parcours->var->v_nbdim = 1; |
---|
609 | i = 1; |
---|
610 | /* */ |
---|
611 | while ( i < strlen(parcours->var->v_readedlistdimension) ) |
---|
612 | { |
---|
613 | if ( parcours->var->v_readedlistdimension[i] == ',' ) |
---|
614 | { |
---|
615 | parcours->var->v_nbdim = parcours->var->v_nbdim + 1 ; |
---|
616 | } |
---|
617 | /* */ |
---|
618 | i=i+1; |
---|
619 | } |
---|
620 | } |
---|
621 | /*******************************************************************/ |
---|
622 | fscanf(dependfileoutput,"%s\n",nothing); |
---|
623 | parcours->suiv = NULL; |
---|
624 | if ( !listout ) |
---|
625 | { |
---|
626 | listout = parcours; |
---|
627 | parcoursprec = parcours; |
---|
628 | } |
---|
629 | else |
---|
630 | { |
---|
631 | if ( parcoursprec ) |
---|
632 | { |
---|
633 | parcoursprec->suiv = parcours; |
---|
634 | parcoursprec = parcours; |
---|
635 | } |
---|
636 | else |
---|
637 | { |
---|
638 | parcours0 = listout; |
---|
639 | while ( parcours0->suiv ) parcours0=parcours0->suiv; |
---|
640 | parcours0->suiv = parcours; |
---|
641 | parcoursprec = parcours0->suiv; |
---|
642 | } |
---|
643 | } |
---|
644 | parcours = NULL; |
---|
645 | } |
---|
646 | fclose(dependfileoutput); |
---|
647 | } |
---|
648 | return listout; |
---|
649 | } |
---|
650 | |
---|
651 | void Write_Subroutine_For_Alloc() |
---|
652 | { |
---|
653 | FILE *dependfileoutput; |
---|
654 | listnom *parcours; |
---|
655 | |
---|
656 | if ( List_Subroutine_For_Alloc ) |
---|
657 | { |
---|
658 | if ((dependfileoutput=fopen(".dependAllocAgrif","w"))!=NULL) |
---|
659 | { |
---|
660 | parcours = List_Subroutine_For_Alloc; |
---|
661 | while (parcours) |
---|
662 | { |
---|
663 | fprintf(dependfileoutput,"%s\n",parcours->o_nom); |
---|
664 | parcours = parcours->suiv; |
---|
665 | } |
---|
666 | fclose(dependfileoutput); |
---|
667 | } |
---|
668 | } |
---|
669 | } |
---|
670 | |
---|
671 | void Read_Subroutine_For_Alloc() |
---|
672 | { |
---|
673 | FILE *dependfileoutput; |
---|
674 | listnom *parcours; |
---|
675 | listnom *ref; |
---|
676 | |
---|
677 | if ((dependfileoutput=fopen(".dependAllocAgrif","r"))!=NULL) |
---|
678 | { |
---|
679 | List_Subroutine_For_Alloc = (listnom *)NULL; |
---|
680 | while (!feof(dependfileoutput)) |
---|
681 | { |
---|
682 | parcours=(listnom *)malloc(sizeof(listnom)); |
---|
683 | fscanf(dependfileoutput,"%s\n",&parcours->o_nom); |
---|
684 | parcours->suiv = NULL; |
---|
685 | |
---|
686 | if ( !List_Subroutine_For_Alloc ) |
---|
687 | { |
---|
688 | List_Subroutine_For_Alloc = parcours; |
---|
689 | ref = parcours; |
---|
690 | } |
---|
691 | else |
---|
692 | { |
---|
693 | ref->suiv = parcours; |
---|
694 | ref = parcours; |
---|
695 | } |
---|
696 | } |
---|
697 | fclose(dependfileoutput); |
---|
698 | } |
---|
699 | } |
---|
700 | |
---|
701 | /******************************************************************************/ |
---|
702 | /* Writethedependavailablefile */ |
---|
703 | /******************************************************************************/ |
---|
704 | /* This subroutine is used to write the .dependfileavailable file */ |
---|
705 | /******************************************************************************/ |
---|
706 | /* */ |
---|
707 | /* .dependavailable */ |
---|
708 | /* tabvars(1) = var1 */ |
---|
709 | /* tabvars(3) = var1 2 */ |
---|
710 | /* tabvars(4) = var1 =====> 5 */ |
---|
711 | /* tabvars(6) = var1 */ |
---|
712 | /* tabvars(7) = var1 */ |
---|
713 | /* */ |
---|
714 | /* */ |
---|
715 | /* */ |
---|
716 | /******************************************************************************/ |
---|
717 | void Writethedependavailablefile() |
---|
718 | { |
---|
719 | FILE *dependfileoutput; |
---|
720 | listindice *parcours; |
---|
721 | |
---|
722 | if ((dependfileoutput=fopen(".dependavailable","w"))!=NULL) |
---|
723 | { |
---|
724 | /* We are looking for all the indices of the Listofavailableindices */ |
---|
725 | parcours = Listofavailableindices; |
---|
726 | while (parcours) |
---|
727 | { |
---|
728 | if ( parcours->i_indice != 0 ) |
---|
729 | { |
---|
730 | fprintf(dependfileoutput,"%d\n",parcours->i_indice); |
---|
731 | } |
---|
732 | parcours = parcours->suiv; |
---|
733 | } |
---|
734 | fclose(dependfileoutput); |
---|
735 | } |
---|
736 | } |
---|
737 | |
---|
738 | /******************************************************************************/ |
---|
739 | /* Readthedependavailablefile */ |
---|
740 | /******************************************************************************/ |
---|
741 | /* This subroutine is used to read the .dependfileavailable file */ |
---|
742 | /******************************************************************************/ |
---|
743 | /* */ |
---|
744 | /* .dependavailable */ |
---|
745 | /* tabvars(1) = var1 */ |
---|
746 | /* tabvars(3) = var1 2 */ |
---|
747 | /* tabvars(4) = var1 =====> 5 ==> Listofavailableindices */ |
---|
748 | /* tabvars(6) = var1 */ |
---|
749 | /* tabvars(7) = var1 */ |
---|
750 | /* */ |
---|
751 | /* */ |
---|
752 | /* */ |
---|
753 | /******************************************************************************/ |
---|
754 | void Readthedependavailablefile() |
---|
755 | { |
---|
756 | FILE *dependfileoutput; |
---|
757 | listindice *parcours; |
---|
758 | |
---|
759 | if ((dependfileoutput=fopen(".dependavailable","r"))!=NULL) |
---|
760 | { |
---|
761 | /* We are looking for all the indices of the Listofavailableindices */ |
---|
762 | Listofavailableindices = (listindice *)NULL; |
---|
763 | while (!feof(dependfileoutput)) |
---|
764 | { |
---|
765 | parcours=(listindice *)malloc(sizeof(listindice)); |
---|
766 | fscanf(dependfileoutput,"%d\n",&parcours->i_indice); |
---|
767 | if ( parcours->i_indice != 0 && parcours->i_indice < 10000000 ) |
---|
768 | { |
---|
769 | parcours -> suiv = Listofavailableindices; |
---|
770 | Listofavailableindices = parcours; |
---|
771 | } |
---|
772 | else |
---|
773 | { |
---|
774 | free(parcours); |
---|
775 | } |
---|
776 | } |
---|
777 | fclose(dependfileoutput); |
---|
778 | } |
---|
779 | } |
---|
780 | |
---|
781 | |
---|
782 | /******************************************************************************/ |
---|
783 | /* Did_filetoparse_readed */ |
---|
784 | /******************************************************************************/ |
---|
785 | /* This subroutine is used to know if the .depend<NameTampon> exist */ |
---|
786 | /* it means if the file has been ever parsed */ |
---|
787 | /******************************************************************************/ |
---|
788 | /* */ |
---|
789 | /******************************************************************************/ |
---|
790 | int Did_filetoparse_readed(char *NameTampon) |
---|
791 | { |
---|
792 | FILE *dependfileoutput; |
---|
793 | char ligne[LONGNOM]; |
---|
794 | int out; |
---|
795 | |
---|
796 | convert2lower(NameTampon); |
---|
797 | sprintf(ligne,".depend%s",NameTampon); |
---|
798 | if ((dependfileoutput = fopen(ligne,"r"))==NULL) |
---|
799 | { |
---|
800 | out = 0; |
---|
801 | } |
---|
802 | else |
---|
803 | { |
---|
804 | out = 1; |
---|
805 | fclose(dependfileoutput); |
---|
806 | } |
---|
807 | return out; |
---|
808 | } |
---|
809 | |
---|
810 | |
---|
811 | /******************************************************************************/ |
---|
812 | /* Did_module_common_treaded */ |
---|
813 | /******************************************************************************/ |
---|
814 | /* This subroutine is used to know if the .depend<NameTampon> exist */ |
---|
815 | /* it means if the file has been ever parsed */ |
---|
816 | /******************************************************************************/ |
---|
817 | /* */ |
---|
818 | /******************************************************************************/ |
---|
819 | int Did_module_common_treaded(char *NameTampon) |
---|
820 | { |
---|
821 | FILE *dependfileoutput; |
---|
822 | char ligne[LONGNOM]; |
---|
823 | int out; |
---|
824 | |
---|
825 | convert2lower(NameTampon); |
---|
826 | sprintf(ligne,".depend%s",NameTampon); |
---|
827 | if ((dependfileoutput = fopen(ligne,"r"))==NULL) |
---|
828 | { |
---|
829 | out = 0; |
---|
830 | } |
---|
831 | else |
---|
832 | { |
---|
833 | out = 1; |
---|
834 | fclose(dependfileoutput); |
---|
835 | } |
---|
836 | return out; |
---|
837 | } |
---|