1 | /******************************************************************************/ |
---|
2 | /* */ |
---|
3 | /* CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran) */ |
---|
4 | /* */ |
---|
5 | /* Copyright (C) 2005 Laurent Debreu (Laurent.Debreu@imag.fr) */ |
---|
6 | /* Cyril Mazauric (Cyril.Mazauric@imag.fr) */ |
---|
7 | /* */ |
---|
8 | /* This program is free software; you can redistribute it and/or modify */ |
---|
9 | /* it */ |
---|
10 | /* */ |
---|
11 | /* This program is distributed in the hope that it will be useful, */ |
---|
12 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
---|
13 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ |
---|
14 | /* GNU General Public License for more details. */ |
---|
15 | /* */ |
---|
16 | /******************************************************************************/ |
---|
17 | #include <stdio.h> |
---|
18 | #include <stdlib.h> |
---|
19 | #include <string.h> |
---|
20 | #include "decl.h" |
---|
21 | |
---|
22 | |
---|
23 | /******************************************************************************/ |
---|
24 | /* OPTI_1_AddIdentToTheAllocateList */ |
---|
25 | /******************************************************************************/ |
---|
26 | /* Firstpass 1 */ |
---|
27 | /******************************************************************************/ |
---|
28 | /* */ |
---|
29 | /******************************************************************************/ |
---|
30 | void OPTI_1_AddIdentToTheAllocateList(char *nom) |
---|
31 | { |
---|
32 | listallocate *newvar; |
---|
33 | listallocate *parcours; |
---|
34 | int out; |
---|
35 | |
---|
36 | if ( firstpass == 1 ) |
---|
37 | { |
---|
38 | if ( !AllocateList ) |
---|
39 | { |
---|
40 | newvar = (listallocate *)malloc(sizeof(listallocate)); |
---|
41 | strcpy(newvar->nomvar,nom); |
---|
42 | strcpy(newvar->subroutine,subroutinename); |
---|
43 | strcpy(newvar->module,curmodulename); |
---|
44 | newvar->suiv = NULL; |
---|
45 | AllocateList = newvar; |
---|
46 | } |
---|
47 | else |
---|
48 | { |
---|
49 | parcours = AllocateList; |
---|
50 | out = 0 ; |
---|
51 | while ( parcours->suiv && out == 0 ) |
---|
52 | { |
---|
53 | if ( !strcasecmp(parcours->nomvar,nom) && |
---|
54 | !strcasecmp(parcours->subroutine,subroutinename) && |
---|
55 | !strcasecmp(parcours->module,curmodulename) ) out = 1; |
---|
56 | else |
---|
57 | parcours=parcours->suiv; |
---|
58 | } |
---|
59 | if ( out == 0 ) |
---|
60 | { |
---|
61 | if ( !strcasecmp(parcours->nomvar,nom) && |
---|
62 | !strcasecmp(parcours->subroutine,subroutinename) && |
---|
63 | !strcasecmp(parcours->module,curmodulename) ) out = 1; |
---|
64 | else |
---|
65 | { |
---|
66 | /* add the record */ |
---|
67 | newvar = (listallocate *)malloc(sizeof(listallocate)); |
---|
68 | strcpy(newvar->nomvar,nom); |
---|
69 | strcpy(newvar->subroutine,subroutinename); |
---|
70 | strcpy(newvar->module,curmodulename); |
---|
71 | newvar->suiv = NULL; |
---|
72 | parcours->suiv = newvar; |
---|
73 | } |
---|
74 | } |
---|
75 | } |
---|
76 | } |
---|
77 | } |
---|
78 | |
---|
79 | /******************************************************************************/ |
---|
80 | /* OPTI_0_IsAllocateInThisSubroutine */ |
---|
81 | /******************************************************************************/ |
---|
82 | /* Firstpass 0 */ |
---|
83 | /******************************************************************************/ |
---|
84 | /* */ |
---|
85 | /******************************************************************************/ |
---|
86 | int OPTI_0_IsAllocateInThisSubroutine() |
---|
87 | { |
---|
88 | listallocate *parcours; |
---|
89 | int out; |
---|
90 | |
---|
91 | out = 0 ; |
---|
92 | if ( firstpass == 0 ) |
---|
93 | { |
---|
94 | parcours = AllocateList; |
---|
95 | while ( parcours && out == 0 ) |
---|
96 | { |
---|
97 | if ( !strcasecmp(parcours->subroutine,subroutinename) ) |
---|
98 | { |
---|
99 | out = 1 ; |
---|
100 | } |
---|
101 | else parcours=parcours->suiv; |
---|
102 | } |
---|
103 | } |
---|
104 | return out; |
---|
105 | } |
---|
106 | |
---|
107 | /******************************************************************************/ |
---|
108 | /* OPTI_0_IsVarAllocatable */ |
---|
109 | /******************************************************************************/ |
---|
110 | /* Firstpass 0 */ |
---|
111 | /******************************************************************************/ |
---|
112 | /* */ |
---|
113 | /******************************************************************************/ |
---|
114 | int OPTI_0_IsVarAllocatable(char *ident) |
---|
115 | { |
---|
116 | listallocate *parcours; |
---|
117 | int out; |
---|
118 | |
---|
119 | out = 0 ; |
---|
120 | if ( firstpass == 0 ) |
---|
121 | { |
---|
122 | parcours = AllocateList; |
---|
123 | while ( parcours && out == 0 ) |
---|
124 | { |
---|
125 | if ( !strcasecmp(parcours->nomvar,ident) ) out = 1 ; |
---|
126 | else parcours=parcours->suiv; |
---|
127 | } |
---|
128 | } |
---|
129 | return out; |
---|
130 | } |
---|
131 | |
---|
132 | |
---|
133 | /******************************************************************************/ |
---|
134 | /* OPTI_0_varisallocatable */ |
---|
135 | /******************************************************************************/ |
---|
136 | /* Firstpass 0 */ |
---|
137 | /******************************************************************************/ |
---|
138 | /* */ |
---|
139 | /******************************************************************************/ |
---|
140 | int OPTI_0_varisallocatable(char *ident) |
---|
141 | { |
---|
142 | listvar *newvar; |
---|
143 | listallocate *newvaralloc; |
---|
144 | int out; |
---|
145 | |
---|
146 | out =0; |
---|
147 | if (firstpass == 0 ) |
---|
148 | { |
---|
149 | newvar = globalvarofusefile; |
---|
150 | while ( newvar && out == 0 ) |
---|
151 | { |
---|
152 | if ( !strcmp(ident,newvar->var->nomvar) && |
---|
153 | newvar->var->allocatable == 1 ) out = 1; |
---|
154 | else newvar = newvar->suiv; |
---|
155 | } |
---|
156 | if ( out == 0 ) |
---|
157 | { |
---|
158 | newvar = globliste; |
---|
159 | while ( newvar && out == 0 ) |
---|
160 | { |
---|
161 | if ( !strcmp(ident,newvar->var->nomvar) && |
---|
162 | newvar->var->allocatable == 1 ) out = 1; |
---|
163 | else newvar = newvar->suiv; |
---|
164 | } |
---|
165 | } |
---|
166 | if ( out == 0 ) |
---|
167 | { |
---|
168 | newvaralloc = AllocateList; |
---|
169 | while ( newvar && out == 0 ) |
---|
170 | { |
---|
171 | if ( !strcasecmp(ident,newvaralloc->nomvar) && |
---|
172 | !strcasecmp(newvaralloc->subroutine,subroutinename) |
---|
173 | ) out = 1; |
---|
174 | else newvaralloc = newvaralloc->suiv; |
---|
175 | } |
---|
176 | } |
---|
177 | } |
---|
178 | return out; |
---|
179 | } |
---|