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.7 */ |
---|
34 | /******************************************************************************/ |
---|
35 | #include <stdio.h> |
---|
36 | #include <stdlib.h> |
---|
37 | #include <string.h> |
---|
38 | |
---|
39 | #include "decl.h" |
---|
40 | |
---|
41 | /******************************************************************************/ |
---|
42 | /* WriteBeginDeclaration */ |
---|
43 | /******************************************************************************/ |
---|
44 | /* This subroutine is used to write the begin of a declaration */ |
---|
45 | /* taken in a variable record */ |
---|
46 | /* */ |
---|
47 | /******************************************************************************/ |
---|
48 | /* */ |
---|
49 | /* integer variable -----------> INTEGER */ |
---|
50 | /* */ |
---|
51 | /******************************************************************************/ |
---|
52 | void WriteBeginDeclaration(variable *v,char ligne[LONG_4C], int visibility) |
---|
53 | { |
---|
54 | char tmpligne[LONG_4C]; |
---|
55 | |
---|
56 | if ( !strcasecmp(v->v_typevar,"") ) |
---|
57 | { |
---|
58 | printf("WARNING : The type of the variable %s \n",v->v_nomvar); |
---|
59 | printf(" is unknown. CONV should define a type\n"); |
---|
60 | } |
---|
61 | |
---|
62 | sprintf (ligne, "%s", v->v_typevar); |
---|
63 | if ( v->v_c_star == 1 ) strcat(ligne,"*"); |
---|
64 | |
---|
65 | /* We should give the precision of the variable if it has been given */ |
---|
66 | if ( strcasecmp(v->v_precision,"") ) |
---|
67 | { |
---|
68 | sprintf(tmpligne,"(%s)",v->v_precision); |
---|
69 | Save_Length(tmpligne,49); |
---|
70 | strcat(ligne,tmpligne); |
---|
71 | } |
---|
72 | |
---|
73 | if (strcasecmp(v->v_dimchar,"")) |
---|
74 | { |
---|
75 | sprintf(tmpligne,"(%s)",v->v_dimchar); |
---|
76 | Save_Length(tmpligne,49); |
---|
77 | strcat(ligne,tmpligne); |
---|
78 | } |
---|
79 | |
---|
80 | if ( strcasecmp(v->v_nameinttypename,"") ) |
---|
81 | { |
---|
82 | sprintf(tmpligne,"*%s",v->v_nameinttypename); |
---|
83 | Save_Length(tmpligne,49); |
---|
84 | strcat(ligne,tmpligne); |
---|
85 | } |
---|
86 | if (strcasecmp (v->v_IntentSpec, "")) |
---|
87 | { |
---|
88 | sprintf(tmpligne,",INTENT(%s) ",v->v_IntentSpec); |
---|
89 | Save_Length(tmpligne,49); |
---|
90 | strcat(ligne,tmpligne); |
---|
91 | } |
---|
92 | if ( v->v_VariableIsParameter == 1 ) strcat(ligne, ", PARAMETER"); |
---|
93 | if (visibility == 1) |
---|
94 | { |
---|
95 | if ( v->v_PublicDeclare == 1 ) strcat(ligne, ", PUBLIC"); |
---|
96 | if ( v->v_PrivateDeclare == 1 ) strcat(ligne, ", PRIVATE"); |
---|
97 | } |
---|
98 | if ( v->v_ExternalDeclare == 1 ) strcat(ligne, ", EXTERNAL"); |
---|
99 | if ( v->v_allocatable == 1 && |
---|
100 | v->v_save == 0 ) |
---|
101 | {strcat(ligne,", ALLOCATABLE"); |
---|
102 | } |
---|
103 | if ( v->v_optionaldeclare == 1 ) strcat(ligne,", OPTIONAL"); |
---|
104 | if ( v->v_pointerdeclare == 1 ) strcat(ligne,", POINTER"); |
---|
105 | Save_Length(ligne,45); |
---|
106 | } |
---|
107 | |
---|
108 | |
---|
109 | /******************************************************************************/ |
---|
110 | /* WriteScalarDeclaration */ |
---|
111 | /******************************************************************************/ |
---|
112 | /* This subroutine is used to write a scalar declaration */ |
---|
113 | /* taken in a variable record */ |
---|
114 | /* */ |
---|
115 | /******************************************************************************/ |
---|
116 | /* */ |
---|
117 | /* integer variable -----------> INTEGER :: VARIABLE */ |
---|
118 | /* */ |
---|
119 | /******************************************************************************/ |
---|
120 | void WriteScalarDeclaration(variable *v,char ligne[LONG_4C]) |
---|
121 | { |
---|
122 | |
---|
123 | strcat (ligne, " :: "); |
---|
124 | strcat (ligne, v->v_nomvar); |
---|
125 | if ( strcasecmp(v->v_vallengspec,"") ) strcat(ligne,v->v_vallengspec); |
---|
126 | if ( v->v_VariableIsParameter == 1 ) |
---|
127 | { |
---|
128 | strcat(ligne," = "); |
---|
129 | strcat(ligne,v->v_initialvalue); |
---|
130 | } |
---|
131 | Save_Length(ligne,45); |
---|
132 | } |
---|
133 | |
---|
134 | |
---|
135 | /******************************************************************************/ |
---|
136 | /* WriteTableDeclaration */ |
---|
137 | /******************************************************************************/ |
---|
138 | /* This subroutine is used to write a Table declaration */ |
---|
139 | /* taken in a variable record */ |
---|
140 | /* */ |
---|
141 | /******************************************************************************/ |
---|
142 | /* */ |
---|
143 | /* integer variable(nb) -----------> */ |
---|
144 | /* INTEGER, DIMENSION(1:nb) :: variable */ |
---|
145 | /* */ |
---|
146 | /******************************************************************************/ |
---|
147 | void WriteTableDeclaration(variable * v,char ligne[LONG_4C],int tmpok) |
---|
148 | { |
---|
149 | char newname[LONG_4C]; |
---|
150 | |
---|
151 | strcat (ligne, ", Dimension("); |
---|
152 | |
---|
153 | if ( v->v_dimensiongiven == 1 && tmpok == 1 ) |
---|
154 | { |
---|
155 | strcat(ligne,v->v_readedlistdimension); |
---|
156 | } |
---|
157 | if ( v->v_dimensiongiven == 1 && tmpok == 0 ) |
---|
158 | { |
---|
159 | strcpy(newname,ChangeTheInitalvaluebyTabvarsName |
---|
160 | (v->v_readedlistdimension,List_Global_Var,0)); |
---|
161 | |
---|
162 | if ( !strcasecmp(newname,"") ) strcat(newname,v->v_readedlistdimension); |
---|
163 | |
---|
164 | strcpy(newname,ChangeTheInitalvaluebyTabvarsName |
---|
165 | (newname,List_Common_Var,0)); |
---|
166 | |
---|
167 | if ( !strcasecmp(newname,"") ) strcat(newname,v->v_readedlistdimension); |
---|
168 | |
---|
169 | strcpy(newname,ChangeTheInitalvaluebyTabvarsName |
---|
170 | (newname,List_ModuleUsed_Var,0)); |
---|
171 | if ( !strcasecmp(newname,"") ) strcat(newname,v->v_readedlistdimension); |
---|
172 | |
---|
173 | Save_Length(newname,47); |
---|
174 | strcat(ligne,newname); |
---|
175 | } |
---|
176 | strcat (ligne, ")"); |
---|
177 | strcat (ligne, " :: "); |
---|
178 | strcat (ligne, v->v_nomvar); |
---|
179 | if ( strcasecmp(vallengspec,"") ) strcat(ligne,v->v_vallengspec); |
---|
180 | |
---|
181 | if ( v->v_VariableIsParameter == 1 ) |
---|
182 | { |
---|
183 | strcat(ligne," = "); |
---|
184 | strcat(ligne,v->v_initialvalue); |
---|
185 | } |
---|
186 | Save_Length(ligne,45); |
---|
187 | } |
---|
188 | |
---|
189 | /******************************************************************************/ |
---|
190 | /* writevardeclaration */ |
---|
191 | /******************************************************************************/ |
---|
192 | /* This subroutine is used to write the initial declaration in the file */ |
---|
193 | /* fileout of a variable */ |
---|
194 | /* */ |
---|
195 | /******************************************************************************/ |
---|
196 | /* */ |
---|
197 | /* integer variable(nb) -----------> */ |
---|
198 | /* INTEGER, DIMENSION(1:nb),Pointer :: variable */ |
---|
199 | /* */ |
---|
200 | /******************************************************************************/ |
---|
201 | void writevardeclaration (listvar * var_record, FILE *fileout, int value, int visibility) |
---|
202 | { |
---|
203 | FILE *filecommon; |
---|
204 | listvar *newvar; |
---|
205 | variable *v; |
---|
206 | char ligne[LONG_4C]; |
---|
207 | |
---|
208 | filecommon=fileout; |
---|
209 | newvar = var_record; |
---|
210 | |
---|
211 | if ( newvar->var->v_save == 0 || inmodulemeet == 0 ) |
---|
212 | { |
---|
213 | v = newvar->var; |
---|
214 | |
---|
215 | WriteBeginDeclaration(v,ligne,visibility); |
---|
216 | |
---|
217 | if ( v->v_nbdim == 0 ) WriteScalarDeclaration(v,ligne); |
---|
218 | else WriteTableDeclaration(v,ligne,value); |
---|
219 | |
---|
220 | if ( v->v_VariableIsParameter != 1 && strcasecmp(v->v_initialvalue,"") ) |
---|
221 | { |
---|
222 | strcat(ligne," = "); |
---|
223 | strcat(ligne,v->v_initialvalue); |
---|
224 | } |
---|
225 | |
---|
226 | tofich (filecommon, ligne,1); |
---|
227 | } |
---|
228 | Save_Length(ligne,45); |
---|
229 | |
---|
230 | } |
---|
231 | |
---|
232 | |
---|
233 | void WriteLocalParamDeclaration() |
---|
234 | { |
---|
235 | listvar *parcours; |
---|
236 | |
---|
237 | parcours = List_Parameter_Var; |
---|
238 | while ( parcours ) |
---|
239 | { |
---|
240 | if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) ) |
---|
241 | { |
---|
242 | writevardeclaration(parcours,fortranout,0,1); |
---|
243 | } |
---|
244 | parcours = parcours -> suiv; |
---|
245 | } |
---|
246 | } |
---|
247 | |
---|
248 | void WriteFunctionDeclaration(int value) |
---|
249 | { |
---|
250 | listvar *parcours; |
---|
251 | |
---|
252 | parcours = List_FunctionType_Var; |
---|
253 | while ( parcours ) |
---|
254 | { |
---|
255 | if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) && |
---|
256 | strcasecmp(parcours->var->v_typevar,"") |
---|
257 | ) |
---|
258 | { |
---|
259 | writevardeclaration(parcours,fortranout,value,1); |
---|
260 | } |
---|
261 | parcours = parcours -> suiv; |
---|
262 | } |
---|
263 | } |
---|
264 | |
---|
265 | void WriteSubroutineDeclaration(int value) |
---|
266 | { |
---|
267 | listvar *parcours; |
---|
268 | |
---|
269 | parcours = List_SubroutineDeclaration_Var; |
---|
270 | while ( parcours ) |
---|
271 | { |
---|
272 | if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) && |
---|
273 | parcours->var->v_save == 0 && |
---|
274 | (parcours->var->v_allocatable == 0 || !strcasecmp(parcours->var->v_typevar,"type")) && |
---|
275 | parcours->var->v_pointerdeclare == 0 && |
---|
276 | parcours->var->v_VariableIsParameter == 0 && |
---|
277 | parcours->var->v_common == 0 |
---|
278 | ) |
---|
279 | { |
---|
280 | writevardeclaration(parcours,fortranout,value,1); |
---|
281 | |
---|
282 | } |
---|
283 | else if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) && |
---|
284 | parcours->var->v_save == 0 && |
---|
285 | parcours->var->v_VariableIsParameter == 0 && |
---|
286 | parcours->var->v_common == 0 |
---|
287 | ) |
---|
288 | { |
---|
289 | writevardeclaration(parcours,fortranout,value,1); |
---|
290 | |
---|
291 | } |
---|
292 | parcours = parcours -> suiv; |
---|
293 | } |
---|
294 | } |
---|
295 | |
---|
296 | void WriteArgumentDeclaration_beforecall() |
---|
297 | { |
---|
298 | int position; |
---|
299 | listnom *neededparameter; |
---|
300 | FILE *paramtoamr; |
---|
301 | listvar *newvar; |
---|
302 | char ligne[LONG_4C]; |
---|
303 | |
---|
304 | fprintf(fortranout,"#include \"Param_BeforeCall_%s.h\" \n",subroutinename); |
---|
305 | /* */ |
---|
306 | sprintf(ligne,"Param_BeforeCall_%s.h",subroutinename); |
---|
307 | paramtoamr = associate (ligne); |
---|
308 | /* */ |
---|
309 | neededparameter = (listnom * )NULL; |
---|
310 | /* */ |
---|
311 | position = 1; |
---|
312 | newvar = List_SubroutineArgument_Var; |
---|
313 | while ( newvar ) |
---|
314 | { |
---|
315 | if ( !strcasecmp(newvar->var->v_subroutinename,subroutinename) && |
---|
316 | newvar->var->v_positioninblock == position |
---|
317 | ) |
---|
318 | { |
---|
319 | position = position + 1; |
---|
320 | |
---|
321 | writevardeclaration(newvar,fortranout,0,1); |
---|
322 | neededparameter = writedeclarationintoamr(List_Parameter_Var, |
---|
323 | paramtoamr,newvar->var,newvar->var->v_subroutinename, |
---|
324 | neededparameter,subroutinename); |
---|
325 | |
---|
326 | newvar = List_SubroutineArgument_Var; |
---|
327 | } |
---|
328 | else newvar = newvar -> suiv; |
---|
329 | } |
---|
330 | Save_Length(ligne,45); |
---|
331 | fclose(paramtoamr); |
---|
332 | } |
---|
333 | |
---|
334 | void WriteArgumentDeclaration_Sort() |
---|
335 | { |
---|
336 | int position; |
---|
337 | listvar *newvar; |
---|
338 | |
---|
339 | /* */ |
---|
340 | position = 1; |
---|
341 | newvar = List_SubroutineArgument_Var; |
---|
342 | while ( newvar ) |
---|
343 | { |
---|
344 | if ( !strcasecmp(newvar->var->v_subroutinename,subroutinename) && |
---|
345 | newvar->var->v_positioninblock == position |
---|
346 | ) |
---|
347 | { |
---|
348 | position = position + 1; |
---|
349 | |
---|
350 | writevardeclaration(newvar,fortranout,1,1); |
---|
351 | /* */ |
---|
352 | newvar = List_SubroutineArgument_Var; |
---|
353 | } |
---|
354 | else newvar = newvar -> suiv; |
---|
355 | } |
---|
356 | /* */ |
---|
357 | newvar = List_SubroutineArgument_Var; |
---|
358 | while ( newvar ) |
---|
359 | { |
---|
360 | if ( !strcasecmp(newvar->var->v_subroutinename,subroutinename) && |
---|
361 | newvar->var->v_positioninblock == 0 && |
---|
362 | newvar->var->v_nbdim == 0 |
---|
363 | ) |
---|
364 | { |
---|
365 | |
---|
366 | writevardeclaration(newvar,fortranout,1,1); |
---|
367 | } |
---|
368 | newvar = newvar -> suiv; |
---|
369 | } |
---|
370 | /* */ |
---|
371 | newvar = List_SubroutineArgument_Var; |
---|
372 | while ( newvar ) |
---|
373 | { |
---|
374 | if ( !strcasecmp(newvar->var->v_subroutinename,subroutinename) && |
---|
375 | newvar->var->v_positioninblock == 0 && |
---|
376 | newvar->var->v_nbdim != 0 |
---|
377 | ) |
---|
378 | { |
---|
379 | writevardeclaration(newvar,fortranout,1,1); |
---|
380 | } |
---|
381 | newvar = newvar -> suiv; |
---|
382 | } |
---|
383 | } |
---|
384 | |
---|
385 | /******************************************************************************/ |
---|
386 | /* writedeclarationintoamr */ |
---|
387 | /******************************************************************************/ |
---|
388 | /* This subroutine is used to write the declaration of parameters needed in */ |
---|
389 | /* allocation subroutines creates in toamr.c */ |
---|
390 | /******************************************************************************/ |
---|
391 | /* */ |
---|
392 | /* */ |
---|
393 | /******************************************************************************/ |
---|
394 | listnom *writedeclarationintoamr (listvar * deb_common, FILE *fileout, |
---|
395 | variable *var , char commonname[LONG_C], |
---|
396 | listnom *neededparameter, char name_common[LONG_C]) |
---|
397 | { |
---|
398 | listvar *newvar; |
---|
399 | variable *v; |
---|
400 | char ligne[LONG_4C]; |
---|
401 | int changeval; |
---|
402 | int out; |
---|
403 | int writeit; |
---|
404 | listnom *parcours; |
---|
405 | listnom *parcoursprec; |
---|
406 | |
---|
407 | parcoursprec = (listnom * )NULL; |
---|
408 | /* we should list the needed parameter */ |
---|
409 | if ( !strcasecmp(name_common,commonname) ) |
---|
410 | neededparameter = DecomposeTheNameinlistnom(var->v_readedlistdimension, |
---|
411 | neededparameter); |
---|
412 | /* */ |
---|
413 | parcours = neededparameter; |
---|
414 | while (parcours) |
---|
415 | { |
---|
416 | newvar = deb_common; |
---|
417 | out = 0 ; |
---|
418 | while ( newvar && out == 0 ) |
---|
419 | { |
---|
420 | if ( !strcasecmp(parcours->o_nom,newvar->var->v_nomvar) ) |
---|
421 | { |
---|
422 | out=1; |
---|
423 | /* add the name to the list of needed parameter */ |
---|
424 | neededparameter = DecomposeTheNameinlistnom( |
---|
425 | newvar->var->v_initialvalue, |
---|
426 | neededparameter ); |
---|
427 | } |
---|
428 | else newvar=newvar->suiv; |
---|
429 | } |
---|
430 | parcours=parcours->suiv; |
---|
431 | } |
---|
432 | /* */ |
---|
433 | parcours = neededparameter; |
---|
434 | while (parcours) |
---|
435 | { |
---|
436 | newvar = deb_common; |
---|
437 | out = 0 ; |
---|
438 | while ( newvar && out == 0 ) |
---|
439 | { |
---|
440 | if ( !strcasecmp(parcours->o_nom,newvar->var->v_nomvar) ) |
---|
441 | { |
---|
442 | out=1; |
---|
443 | /* add the name to the list of needed parameter */ |
---|
444 | neededparameter = DecomposeTheNameinlistnom( |
---|
445 | newvar->var->v_initialvalue, |
---|
446 | neededparameter ); |
---|
447 | } |
---|
448 | else newvar=newvar->suiv; |
---|
449 | } |
---|
450 | parcours=parcours->suiv; |
---|
451 | } |
---|
452 | /* */ |
---|
453 | tofich (fileout, "",1); |
---|
454 | parcours = neededparameter; |
---|
455 | while (parcours) |
---|
456 | { |
---|
457 | writeit = 0; |
---|
458 | newvar = deb_common; |
---|
459 | while ( newvar && writeit == 0 ) |
---|
460 | { |
---|
461 | if ( !strcasecmp(parcours->o_nom,newvar->var->v_nomvar) && |
---|
462 | parcours->o_val == 0 ) |
---|
463 | { |
---|
464 | writeit=1; |
---|
465 | parcours->o_val = 1; |
---|
466 | } |
---|
467 | else newvar = newvar->suiv; |
---|
468 | } |
---|
469 | |
---|
470 | if ( writeit == 1 ) |
---|
471 | { |
---|
472 | changeval = 0; |
---|
473 | v = newvar->var; |
---|
474 | if ( v->v_allocatable == 1 && strcasecmp(v->v_typevar,"type") ) |
---|
475 | { |
---|
476 | changeval = 1; |
---|
477 | v->v_allocatable = 0; |
---|
478 | } |
---|
479 | WriteBeginDeclaration(v,ligne,1); |
---|
480 | if ( v->v_nbdim == 0 ) WriteScalarDeclaration(v,ligne); |
---|
481 | else WriteTableDeclaration(v,ligne,1); |
---|
482 | |
---|
483 | tofich (fileout, ligne,1); |
---|
484 | if ( changeval == 1 ) |
---|
485 | { |
---|
486 | v->v_allocatable = 1; |
---|
487 | } |
---|
488 | } |
---|
489 | else |
---|
490 | { |
---|
491 | if ( strncasecmp(parcours->o_nom,"mpi_",4) == 0 && |
---|
492 | shouldincludempif == 1 ) |
---|
493 | { |
---|
494 | shouldincludempif = 0; |
---|
495 | fprintf(fileout," include \'mpif.h\' \n"); |
---|
496 | } |
---|
497 | } |
---|
498 | parcours=parcours->suiv; |
---|
499 | } |
---|
500 | Save_Length(ligne,45); |
---|
501 | return neededparameter; |
---|
502 | } |
---|
503 | |
---|
504 | |
---|
505 | /******************************************************************************/ |
---|
506 | /* writesub_loopdeclaration_scalar */ |
---|
507 | /******************************************************************************/ |
---|
508 | /* This subroutine is used to write the declaration part of subloop */ |
---|
509 | /* subroutines */ |
---|
510 | /******************************************************************************/ |
---|
511 | /* */ |
---|
512 | /* integer variable(nb) -----------> */ |
---|
513 | /* */ |
---|
514 | /* INTEGER, DIMENSION(1:nb) :: variable */ |
---|
515 | /* */ |
---|
516 | /******************************************************************************/ |
---|
517 | void writesub_loopdeclaration_scalar (listvar * deb_common, FILE *fileout) |
---|
518 | { |
---|
519 | listvar *newvar; |
---|
520 | variable *v; |
---|
521 | char ligne[LONG_4C]; |
---|
522 | |
---|
523 | tofich (fileout, "",1); |
---|
524 | newvar = deb_common; |
---|
525 | while (newvar) |
---|
526 | { |
---|
527 | if ( newvar->var->v_nbdim == 0 && |
---|
528 | !strcasecmp(newvar->var->v_subroutinename,subroutinename) && |
---|
529 | (newvar->var->v_allocatable == 0 || !strcasecmp(newvar->var->v_typevar,"type")) && |
---|
530 | newvar->var->v_pointerdeclare == 0 |
---|
531 | ) |
---|
532 | { |
---|
533 | v = newvar->var; |
---|
534 | |
---|
535 | WriteBeginDeclaration(v,ligne,1); |
---|
536 | WriteScalarDeclaration(v,ligne); |
---|
537 | tofich (fileout, ligne,1); |
---|
538 | } |
---|
539 | newvar = newvar->suiv; |
---|
540 | } |
---|
541 | Save_Length(ligne,45); |
---|
542 | } |
---|
543 | |
---|
544 | /******************************************************************************/ |
---|
545 | /* writesub_loopdeclaration_tab */ |
---|
546 | /******************************************************************************/ |
---|
547 | /* This subroutine is used to write the declaration part of subloop */ |
---|
548 | /* subroutines */ |
---|
549 | /******************************************************************************/ |
---|
550 | /* */ |
---|
551 | /* integer variable(nb) -----------> */ |
---|
552 | /* */ |
---|
553 | /* INTEGER, DIMENSION(1:nb) :: variable */ |
---|
554 | /* */ |
---|
555 | /******************************************************************************/ |
---|
556 | void writesub_loopdeclaration_tab (listvar * deb_common, FILE *fileout) |
---|
557 | { |
---|
558 | listvar *newvar; |
---|
559 | variable *v; |
---|
560 | char ligne[LONG_4C]; |
---|
561 | int changeval; |
---|
562 | |
---|
563 | tofich (fileout, "",1); |
---|
564 | newvar = deb_common; |
---|
565 | while (newvar) |
---|
566 | { |
---|
567 | if ( newvar->var->v_nbdim != 0 && |
---|
568 | !strcasecmp(newvar->var->v_subroutinename,subroutinename) && |
---|
569 | (newvar->var->v_allocatable == 0 || !strcasecmp(newvar->var->v_typevar,"type")) && |
---|
570 | newvar->var->v_pointerdeclare == 0 |
---|
571 | ) |
---|
572 | { |
---|
573 | changeval = 0; |
---|
574 | v = newvar->var; |
---|
575 | if ( v->v_allocatable == 1) |
---|
576 | { |
---|
577 | if (strcasecmp(v->v_typevar,"type")) |
---|
578 | { |
---|
579 | changeval = 1; |
---|
580 | v->v_allocatable = 0; |
---|
581 | } |
---|
582 | else |
---|
583 | { |
---|
584 | changeval = 2; |
---|
585 | v->v_allocatable = 0; |
---|
586 | v->v_pointerdeclare = 1; |
---|
587 | } |
---|
588 | } |
---|
589 | |
---|
590 | WriteBeginDeclaration(v,ligne,1); |
---|
591 | WriteTableDeclaration(v,ligne,1); |
---|
592 | tofich (fileout, ligne,1); |
---|
593 | if ( changeval >= 1 ) v->v_allocatable = 1; |
---|
594 | if ( changeval == 2 ) v->v_pointerdeclare = 0; |
---|
595 | } |
---|
596 | newvar = newvar->suiv; |
---|
597 | } |
---|
598 | Save_Length(ligne,45); |
---|
599 | } |
---|
600 | |
---|
601 | |
---|
602 | void ReWriteDeclarationAndAddTosubroutine_01(listvar *listdecl) |
---|
603 | { |
---|
604 | listvar *parcours; |
---|
605 | listvar *parcours2; |
---|
606 | listvar *parcours3; |
---|
607 | int out; |
---|
608 | |
---|
609 | if (insubroutinedeclare == 1) |
---|
610 | { |
---|
611 | parcours = listdecl; |
---|
612 | while (parcours) |
---|
613 | { |
---|
614 | /* |
---|
615 | parcours2 = List_SubroutineArgument_Var; |
---|
616 | out = 0; |
---|
617 | while (parcours2 && out == 0) |
---|
618 | { |
---|
619 | if (!strcasecmp(parcours2->var->v_subroutinename,subroutinename) && !strcasecmp(parcours2->var->v_nomvar,parcours->var->v_nomvar)) |
---|
620 | { |
---|
621 | out = 1; |
---|
622 | } |
---|
623 | parcours2 = parcours2->suiv; |
---|
624 | } |
---|
625 | */ |
---|
626 | out = LookingForVariableInList(List_SubroutineArgument_Var,parcours->var); |
---|
627 | if (out == 0) out = VariableIsInListCommon(parcours,List_Common_Var); |
---|
628 | if (out == 0) out = LookingForVariableInList(List_Parameter_Var,parcours->var); |
---|
629 | if (out == 0) out = LookingForVariableInList(List_FunctionType_Var,parcours->var); |
---|
630 | |
---|
631 | /* |
---|
632 | parcours2 = List_Common_Var; |
---|
633 | while (parcours2 && out == 0) |
---|
634 | { |
---|
635 | if (!strcasecmp(parcours2->var->v_commoninfile,mainfile) && !strcasecmp(parcours2->var->v_nomvar,parcours->var->v_nomvar)) |
---|
636 | { |
---|
637 | out = 1; |
---|
638 | } |
---|
639 | parcours2 = parcours2->suiv; |
---|
640 | } |
---|
641 | */ |
---|
642 | //printf("nom = %s %d %d %d\n",parcours->var->v_nomvar,out,VariableIsParameter,SaveDeclare); |
---|
643 | if (firstpass == 0 && out == 0 && VariableIsParameter == 0 && SaveDeclare == 0) |
---|
644 | |
---|
645 | { |
---|
646 | writevardeclaration(parcours,fortranout,1,1); |
---|
647 | } |
---|
648 | //if (firstpass == 1 && out == 1) |
---|
649 | if (firstpass == 1) |
---|
650 | { |
---|
651 | if (VariableIsParameter == 0 && SaveDeclare == 0) |
---|
652 | { |
---|
653 | List_SubroutineDeclaration_Var = insertvar(List_SubroutineDeclaration_Var,parcours->var); |
---|
654 | } |
---|
655 | } |
---|
656 | parcours = parcours->suiv; |
---|
657 | } |
---|
658 | } |
---|
659 | } |
---|