Changeset 663 for trunk/AGRIF/LIB/WorkWithvarofsubroutineliste.c
- Timestamp:
- 2007-05-25T18:00:33+02:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/AGRIF/LIB/WorkWithvarofsubroutineliste.c
r530 r663 3 3 /* CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran) */ 4 4 /* */ 5 /* Copyright or ©or Copr. Laurent Debreu (Laurent.Debreu@imag.fr) */6 /* Cyril Mazauric (Cyril .Mazauric@imag.fr)*/5 /* Copyright or or Copr. Laurent Debreu (Laurent.Debreu@imag.fr) */ 6 /* Cyril Mazauric (Cyril_Mazauric@yahoo.fr) */ 7 7 /* This software is governed by the CeCILL-C license under French law and */ 8 8 /* abiding by the rules of distribution of free software. You can use, */ … … 31 31 /* knowledge of the CeCILL-C license and that you accept its terms. */ 32 32 /******************************************************************************/ 33 /* version 1. 0*/33 /* version 1.6 */ 34 34 /******************************************************************************/ 35 35 #include <stdio.h> … … 39 39 40 40 /******************************************************************************/ 41 /* ajoutvarofsubroutine_1 */ 41 /* Add_SubroutineArgument_Var_1 */ 42 /******************************************************************************/ 43 /* Firstpass 1 */ 44 /* We should complete the */ 45 /******************************************************************************/ 46 /* */ 47 /* */ 48 /******************************************************************************/ 49 void Add_SubroutineArgument_Var_1(listvar *listtoadd) 50 { 51 52 if ( firstpass == 1 ) 53 { 54 List_SubroutineArgument_Var = AddListvarToListvar 55 (listtoadd,List_SubroutineArgument_Var,1); 56 } 57 } 58 59 /******************************************************************************/ 60 /* Add_FunctionType_Var_1 */ 61 /******************************************************************************/ 62 /* Firstpass 1 */ 63 /* We should complete the */ 64 /******************************************************************************/ 65 /* */ 66 /* */ 67 /******************************************************************************/ 68 void Add_FunctionType_Var_1(char *nom) 69 { 70 listvar *newvar; 71 72 if ( firstpass == 1 ) 73 { 74 curvar=createvar(nom,NULL); 75 strcpy(curvar->v_typevar,DeclType); 76 newvar = insertvar(NULL,curvar); 77 List_FunctionType_Var = AddListvarToListvar 78 (newvar,List_FunctionType_Var,1); 79 } 80 } 81 82 83 /******************************************************************************/ 84 /* Add_SubroutineDeclaration_Var_1 */ 42 85 /******************************************************************************/ 43 86 /* Firstpass 1 */ … … 47 90 /* */ 48 91 /******************************************************************************/ 49 void ajoutvarofsubroutine_1(listvar *listtoadd)92 void Add_SubroutineDeclaration_Var_1 (listvar *listtoadd) 50 93 { 51 52 if ( firstpass == 1 && VariableIsParameter == 0 && SaveDeclare == 0) 94 if ( firstpass == 1 ) 53 95 { 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 ) 96 if ( VariableIsParameter == 0 && 97 SaveDeclare == 0 ) 141 98 { 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; 99 listduplicated = (listvar *)NULL; 100 duplicatelistvar(listtoadd); 101 List_SubroutineDeclaration_Var = AddListvarToListvar 102 (listduplicated,List_SubroutineDeclaration_Var,1); 217 103 } 218 104 } 219 105 } 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 else254 {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 else268 {269 parcoursprec->suiv = parcours->suiv;270 parcours = parcoursprec->suiv;271 }272 }273 else274 {275 parcoursprec = parcours;276 parcours = parcours->suiv;277 }278 }279 }
Note: See TracChangeset
for help on using the changeset viewer.