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 | /* ajoutenotgriddep */ |
---|
42 | /******************************************************************************/ |
---|
43 | /* This subroutine is used to add a record into listenotgriddepend */ |
---|
44 | /* This variable is add only if it is not present in the list */ |
---|
45 | /* This variable is add at the end of the list */ |
---|
46 | /******************************************************************************/ |
---|
47 | /* _______ _______ _______ _______ _______ */ |
---|
48 | /* + not + + not + + not + + not + + + */ |
---|
49 | /* + grid +--->+ grid +--->+ grid +--->+ grid +--->+ NEW + */ |
---|
50 | /* +______+ +______+ +______+ +______+ +______+ */ |
---|
51 | /* */ |
---|
52 | /******************************************************************************/ |
---|
53 | void ajoutenotgriddep (char *name) |
---|
54 | { |
---|
55 | /* */ |
---|
56 | variabletempo =(variable *)NULL; |
---|
57 | listvartempo=(listvar *)NULL; |
---|
58 | /* create the record */ |
---|
59 | variabletempo=createvar(name,NULL); |
---|
60 | /* look in the listenotgriddepend if this variable exist */ |
---|
61 | listvartempo = listenotgriddepend; |
---|
62 | while (listvartempo) |
---|
63 | { |
---|
64 | if (!strcasecmp(listvartempo->var->nomvar,name)) |
---|
65 | { |
---|
66 | /* if this variable exist -> exit of the program */ |
---|
67 | printf(" The variable %s\n",name); |
---|
68 | printf(" has been declared twice \n"); |
---|
69 | printf(" as a non grid dependent variable \n"); |
---|
70 | exit(1); |
---|
71 | } |
---|
72 | listvartempo= listvartempo->suiv; |
---|
73 | } |
---|
74 | /* if variable does not exist, we add it */ |
---|
75 | listvartempo = insertvar(listenotgriddepend,variabletempo); |
---|
76 | listenotgriddepend = listvartempo; |
---|
77 | } |
---|
78 | |
---|
79 | /******************************************************************************/ |
---|
80 | /* RemoveNotgriddependFromGlobliste */ |
---|
81 | /******************************************************************************/ |
---|
82 | /* This subroutine is used to remove from the globliste all variables */ |
---|
83 | /* which are not grid dependent */ |
---|
84 | /******************************************************************************/ |
---|
85 | /* _______ _______ _______ _______ _______ */ |
---|
86 | /* + + + + + + + + + + */ |
---|
87 | /* + glob +--->+ glob +--->+ glob +--->+ glob +--->+ glob + */ |
---|
88 | /* +______+ +______+ +______+ +______+ +______+ */ |
---|
89 | /* not grid */ |
---|
90 | /* remove */ |
---|
91 | /* */ |
---|
92 | /******************************************************************************/ |
---|
93 | void RemoveNotgriddependFromGlobliste() |
---|
94 | { |
---|
95 | listvar *newvarglobliste; |
---|
96 | listvar *newvargloblistePrec; |
---|
97 | listvar *newvarnotgriddepend; |
---|
98 | listvar *newvarnotgriddependPrec; |
---|
99 | int Out; |
---|
100 | int Out1; |
---|
101 | |
---|
102 | if ( listenotgriddepend ) |
---|
103 | { |
---|
104 | newvargloblistePrec = (listvar *)NULL; |
---|
105 | newvarnotgriddependPrec = (listvar *)NULL; |
---|
106 | /* Read of the globliste */ |
---|
107 | newvarglobliste = globliste; |
---|
108 | Out1 = 1 ; |
---|
109 | while ( newvarglobliste && Out1 == 1 ) |
---|
110 | { |
---|
111 | newvarnotgriddepend = listenotgriddepend; |
---|
112 | Out = 1 ; |
---|
113 | /* Read of the notgriddepend */ |
---|
114 | while ( newvarnotgriddepend && Out == 1 ) |
---|
115 | { |
---|
116 | /* If the variable is in the notgriddepend list */ |
---|
117 | if ( ! strcasecmp(newvarglobliste->var->nomvar, |
---|
118 | newvarnotgriddepend->var->nomvar) ) |
---|
119 | { |
---|
120 | /* We should go out of the loop so Out = 0 */ |
---|
121 | Out = 0 ; |
---|
122 | /* We remove the variable from the globliste */ |
---|
123 | /* If we are at the beginning of the globliste */ |
---|
124 | if ( newvarglobliste == globliste ) |
---|
125 | { |
---|
126 | globliste = globliste->suiv; |
---|
127 | } |
---|
128 | else |
---|
129 | { |
---|
130 | newvargloblistePrec->suiv = newvarglobliste->suiv; |
---|
131 | newvarglobliste = newvargloblistePrec; |
---|
132 | } |
---|
133 | /* We remove the variable from the notgriddepend list */ |
---|
134 | if ( newvarnotgriddepend == listenotgriddepend ) |
---|
135 | { |
---|
136 | listenotgriddepend = listenotgriddepend->suiv; |
---|
137 | } |
---|
138 | else |
---|
139 | { |
---|
140 | newvarnotgriddependPrec->suiv = newvarnotgriddepend->suiv; |
---|
141 | newvarnotgriddepend = newvarnotgriddependPrec; |
---|
142 | } |
---|
143 | } |
---|
144 | /* If the variable is not in the notgriddepend list */ |
---|
145 | else |
---|
146 | { |
---|
147 | newvarnotgriddependPrec = newvarnotgriddepend; |
---|
148 | newvarnotgriddepend = newvarnotgriddepend->suiv; |
---|
149 | } |
---|
150 | } |
---|
151 | /* If the notgriddepend list is empty we go out of this subroutine */ |
---|
152 | if ( !listenotgriddepend ) |
---|
153 | { |
---|
154 | Out1 = 0; |
---|
155 | } |
---|
156 | newvargloblistePrec = newvarglobliste; |
---|
157 | newvarglobliste = newvarglobliste->suiv; |
---|
158 | } |
---|
159 | } |
---|
160 | } |
---|
161 | |
---|
162 | /******************************************************************************/ |
---|
163 | /* VarIsNonGridDepend */ |
---|
164 | /******************************************************************************/ |
---|
165 | /* This subroutine is used to know if a variable has been declared as non */ |
---|
166 | /* grid dependent */ |
---|
167 | /******************************************************************************/ |
---|
168 | /* */ |
---|
169 | /* notgriddepend variable; -----------> VarIsNonGridDepend = 1 */ |
---|
170 | /* */ |
---|
171 | /* */ |
---|
172 | /******************************************************************************/ |
---|
173 | int VarIsNonGridDepend(char *name) |
---|
174 | { |
---|
175 | listvar *newvar; |
---|
176 | int out; |
---|
177 | |
---|
178 | newvar = listenotgriddepend; |
---|
179 | out=0; |
---|
180 | while (newvar && out == 0 ) |
---|
181 | { |
---|
182 | if ( !strcasecmp(newvar->var->nomvar,name) ) out = 1; |
---|
183 | else newvar = newvar->suiv; |
---|
184 | } |
---|
185 | return out; |
---|
186 | } |
---|
187 | |
---|
188 | |
---|
189 | /******************************************************************************/ |
---|
190 | /* NonGridDepDeclaration_0 */ |
---|
191 | /******************************************************************************/ |
---|
192 | /* Firstpass 0 */ |
---|
193 | /* We should modify this declaration in the file fortranout */ |
---|
194 | /******************************************************************************/ |
---|
195 | void NonGridDepDeclaration_0(listvar *listtomodify) |
---|
196 | { |
---|
197 | if ( (aftercontainsdeclare == 0 && VariableIsParameter == 0) ) |
---|
198 | { |
---|
199 | if (firstpass == 0) |
---|
200 | { |
---|
201 | pos_end = setposcur(); |
---|
202 | RemoveWordSET_0(fortranout,pos_cur, |
---|
203 | pos_end-pos_cur); |
---|
204 | /* Modifications of declarations */ |
---|
205 | NonGridDepDeclaration(listtomodify); |
---|
206 | } |
---|
207 | } |
---|
208 | } |
---|