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 | /* ajoutvarofsubroutine_1 */ |
---|
42 | /******************************************************************************/ |
---|
43 | /* Firstpass 1 */ |
---|
44 | /* We should complete the listvarofsubroutine */ |
---|
45 | /******************************************************************************/ |
---|
46 | /* */ |
---|
47 | /* */ |
---|
48 | /******************************************************************************/ |
---|
49 | void ajoutvarofsubroutine_1(listvar *listtoadd) |
---|
50 | { |
---|
51 | |
---|
52 | if ( firstpass == 1 && VariableIsParameter == 0 && SaveDeclare == 0) |
---|
53 | { |
---|
54 | listduplicated = (listvar *)NULL; |
---|
55 | duplicatelistvar(listtoadd); |
---|
56 | varofsubroutineliste = AddListvarToListvar |
---|
57 | (listduplicated,varofsubroutineliste,1); |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | /******************************************************************************/ |
---|
62 | /* CleanThelistvarofsubroutineliste */ |
---|
63 | /******************************************************************************/ |
---|
64 | /* This subroutine is to remove from the varofsubroutineliste */ |
---|
65 | /* all variables which are not located in the subroutine argument */ |
---|
66 | /******************************************************************************/ |
---|
67 | void CleanThelistvarofsubroutineliste() |
---|
68 | { |
---|
69 | listvar *newvar; |
---|
70 | listvar *newvarprec; |
---|
71 | listvar *tmpglobvar; |
---|
72 | int out; |
---|
73 | |
---|
74 | newvarprec = (listvar *)NULL; |
---|
75 | newvar = varofsubroutineliste; |
---|
76 | while ( newvar ) |
---|
77 | { |
---|
78 | |
---|
79 | out = 0; |
---|
80 | tmpglobvar = listargsubroutine; |
---|
81 | while ( tmpglobvar && out == 0 ) |
---|
82 | { |
---|
83 | if ( !strcasecmp(newvar->var->nomvar,tmpglobvar->var->nomvar) && |
---|
84 | !strcasecmp(newvar->var->modulename,subroutinename) ) |
---|
85 | { |
---|
86 | out = 1; |
---|
87 | } |
---|
88 | else |
---|
89 | { |
---|
90 | tmpglobvar = tmpglobvar->suiv; |
---|
91 | } |
---|
92 | } |
---|
93 | /* if the variable has not be found we should remove it */ |
---|
94 | if ( out == 0 && !strcasecmp(newvar->var->modulename,subroutinename) ) |
---|
95 | { |
---|
96 | /* remove the variable in the varofsubroutineliste */ |
---|
97 | if ( newvar == varofsubroutineliste ) |
---|
98 | { |
---|
99 | varofsubroutineliste = varofsubroutineliste->suiv; |
---|
100 | newvar = varofsubroutineliste; |
---|
101 | } |
---|
102 | else |
---|
103 | { |
---|
104 | newvarprec->suiv = newvar->suiv; |
---|
105 | newvar = newvarprec->suiv; |
---|
106 | } |
---|
107 | } |
---|
108 | else |
---|
109 | { |
---|
110 | newvarprec= newvar; |
---|
111 | newvar = newvar->suiv; |
---|
112 | } |
---|
113 | } |
---|
114 | } |
---|
115 | |
---|
116 | |
---|
117 | /******************************************************************************/ |
---|
118 | /* UpdatevarofsubroutinelisteWithcommonlist */ |
---|
119 | /******************************************************************************/ |
---|
120 | /* This subroutines is used to add the variable defined in common in the */ |
---|
121 | /* varofsubroutineliste */ |
---|
122 | /******************************************************************************/ |
---|
123 | /* */ |
---|
124 | /******************************************************************************/ |
---|
125 | void UpdatevarofsubroutinelisteWithcommonlist() |
---|
126 | { |
---|
127 | listvarcommon *parcours; |
---|
128 | listvar *parcours2; |
---|
129 | listvar *parcoursvar; |
---|
130 | listvar *parcoursvarprec; |
---|
131 | int out; |
---|
132 | |
---|
133 | parcoursvar = varofsubroutineliste; |
---|
134 | parcoursvarprec = (listvar *)NULL; |
---|
135 | while ( parcoursvar ) |
---|
136 | { |
---|
137 | /* We should look in the commonlist if this variable is present */ |
---|
138 | parcours=commonlist; |
---|
139 | out=0; |
---|
140 | while( parcours && out == 0 ) |
---|
141 | { |
---|
142 | if ( !strcasecmp(parcoursvar->var->nomvar,parcours->nomvar) && |
---|
143 | !strcasecmp(parcoursvar->var->subroutinename, |
---|
144 | parcours->subroutinename) |
---|
145 | ) |
---|
146 | { |
---|
147 | out = 1 ; |
---|
148 | } |
---|
149 | else |
---|
150 | { |
---|
151 | parcours = parcours->suiv; |
---|
152 | } |
---|
153 | } |
---|
154 | if ( out == 1 ) |
---|
155 | { |
---|
156 | /* we found it */ |
---|
157 | /* we should remove the variable from the varofsubroutineliste */ |
---|
158 | if ( parcoursvar == varofsubroutineliste ) |
---|
159 | { |
---|
160 | varofsubroutineliste = varofsubroutineliste->suiv; |
---|
161 | parcoursvar = varofsubroutineliste ; |
---|
162 | } |
---|
163 | else |
---|
164 | { |
---|
165 | parcoursvarprec->suiv = parcoursvar->suiv; |
---|
166 | parcoursvar = parcoursvarprec->suiv; |
---|
167 | } |
---|
168 | } |
---|
169 | else |
---|
170 | { |
---|
171 | parcoursvarprec = parcoursvar; |
---|
172 | parcoursvar = parcoursvar->suiv; |
---|
173 | } |
---|
174 | } |
---|
175 | |
---|
176 | /* now we should remove all parameters */ |
---|
177 | parcoursvar = varofsubroutineliste; |
---|
178 | while ( parcoursvar ) |
---|
179 | { |
---|
180 | /* We should look in the commonlist if this variable is present */ |
---|
181 | parcours2=parameterlist; |
---|
182 | out=0; |
---|
183 | while( parcours2 && out == 0 ) |
---|
184 | { |
---|
185 | if ( !strcasecmp(parcoursvar->var->nomvar,parcours2->var->nomvar) && |
---|
186 | !strcasecmp(parcoursvar->var->subroutinename, |
---|
187 | parcours2->var->subroutinename) |
---|
188 | ) |
---|
189 | { |
---|
190 | out = 1 ; |
---|
191 | /* */ |
---|
192 | } |
---|
193 | else |
---|
194 | { |
---|
195 | parcours2 = parcours2->suiv; |
---|
196 | } |
---|
197 | } |
---|
198 | if ( out == 1 ) |
---|
199 | { |
---|
200 | /* we did find it */ |
---|
201 | /* we should remove the variable from the varofsubroutineliste */ |
---|
202 | if ( parcoursvar == varofsubroutineliste ) |
---|
203 | { |
---|
204 | varofsubroutineliste = varofsubroutineliste->suiv; |
---|
205 | parcoursvar = varofsubroutineliste; |
---|
206 | } |
---|
207 | else |
---|
208 | { |
---|
209 | parcoursvarprec->suiv = parcoursvar->suiv; |
---|
210 | parcoursvar = parcoursvarprec->suiv; |
---|
211 | } |
---|
212 | } |
---|
213 | else |
---|
214 | { |
---|
215 | parcoursvarprec = parcoursvar; |
---|
216 | parcoursvar = parcoursvar->suiv; |
---|
217 | } |
---|
218 | } |
---|
219 | } |
---|
220 | |
---|
221 | |
---|
222 | /******************************************************************************/ |
---|
223 | /* UpdatevarsubroutineWithvarofsubroutinelist_1 */ |
---|
224 | /******************************************************************************/ |
---|
225 | /* This subroutines is used to add the variable defined in common in the */ |
---|
226 | /******************************************************************************/ |
---|
227 | /* */ |
---|
228 | /******************************************************************************/ |
---|
229 | void UpdatevarsubroutineWithvarofsubroutinelist_1() |
---|
230 | { |
---|
231 | listvar *parcours; |
---|
232 | listvar *parcours2; |
---|
233 | listvar *parcoursprec; |
---|
234 | int out; |
---|
235 | |
---|
236 | parcoursprec = (listvar * )NULL; |
---|
237 | parcours = varsubroutine; |
---|
238 | while ( parcours ) |
---|
239 | { |
---|
240 | /* We should look in the varofsubroutineliste if this variable is */ |
---|
241 | /* present */ |
---|
242 | parcours2=varofsubroutineliste; |
---|
243 | out=0; |
---|
244 | while( parcours2 && out == 0 ) |
---|
245 | { |
---|
246 | if ( !strcasecmp(parcours->var->nomvar,parcours2->var->nomvar) && |
---|
247 | !strcasecmp(parcours->var->subroutinename, |
---|
248 | parcours2->var->modulename) |
---|
249 | ) |
---|
250 | { |
---|
251 | out = 1 ; |
---|
252 | } |
---|
253 | else |
---|
254 | { |
---|
255 | parcours2 = parcours2->suiv; |
---|
256 | } |
---|
257 | } |
---|
258 | if ( out == 1 ) |
---|
259 | { |
---|
260 | /* we did not find it */ |
---|
261 | /* we should remove the variable from the varsubroutine */ |
---|
262 | if ( parcours == varsubroutine) |
---|
263 | { |
---|
264 | varsubroutine = varsubroutine->suiv; |
---|
265 | parcours = varsubroutine; |
---|
266 | } |
---|
267 | else |
---|
268 | { |
---|
269 | parcoursprec->suiv = parcours->suiv; |
---|
270 | parcours = parcoursprec->suiv; |
---|
271 | } |
---|
272 | } |
---|
273 | else |
---|
274 | { |
---|
275 | parcoursprec = parcours; |
---|
276 | parcours = parcours->suiv; |
---|
277 | } |
---|
278 | } |
---|
279 | } |
---|