[396] | 1 | /******************************************************************************/ |
---|
| 2 | /* */ |
---|
| 3 | /* CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran) */ |
---|
| 4 | /* */ |
---|
[663] | 5 | /* Copyright or or Copr. Laurent Debreu (Laurent.Debreu@imag.fr) */ |
---|
| 6 | /* Cyril Mazauric (Cyril_Mazauric@yahoo.fr) */ |
---|
[530] | 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". */ |
---|
[396] | 12 | /* */ |
---|
[530] | 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. */ |
---|
[396] | 18 | /* */ |
---|
[530] | 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. */ |
---|
[396] | 29 | /* */ |
---|
[530] | 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. */ |
---|
[396] | 32 | /******************************************************************************/ |
---|
[663] | 33 | /* version 1.6 */ |
---|
[530] | 34 | /******************************************************************************/ |
---|
[396] | 35 | #include <stdio.h> |
---|
| 36 | #include <stdlib.h> |
---|
| 37 | #include <string.h> |
---|
| 38 | #include "decl.h" |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | /******************************************************************************/ |
---|
| 44 | /* FindAndChangeNameToTabvars */ |
---|
| 45 | /******************************************************************************/ |
---|
| 46 | /* */ |
---|
| 47 | /******************************************************************************/ |
---|
| 48 | /* if whichone = 0 ----> Agrif_tabvars(i) % var % array2 */ |
---|
| 49 | /* */ |
---|
| 50 | /* if whichone = 1 ----> Agrif_tabvars(i) % parentvar % var % array2 */ |
---|
| 51 | /* */ |
---|
| 52 | /******************************************************************************/ |
---|
| 53 | void FindAndChangeNameToTabvars(char name[LONGNOM],char toprint[LONGNOM], |
---|
| 54 | listvar * listtosee, int whichone) |
---|
| 55 | { |
---|
| 56 | listvar *newvar; |
---|
| 57 | int out; |
---|
[663] | 58 | |
---|
[396] | 59 | if ( strcasecmp(name,"") ) |
---|
| 60 | { |
---|
| 61 | newvar=listtosee; |
---|
| 62 | out=0; |
---|
| 63 | while( newvar && out == 0 ) |
---|
| 64 | { |
---|
[663] | 65 | if ( !strcasecmp(newvar->var->v_nomvar,name) ) |
---|
[396] | 66 | { |
---|
| 67 | out = 1; |
---|
| 68 | strcat(toprint,vargridcurgridtabvars(newvar->var,whichone)); |
---|
| 69 | } |
---|
| 70 | else newvar=newvar->suiv; |
---|
| 71 | } |
---|
| 72 | if ( out == 0 ) strcat(toprint,name); |
---|
| 73 | } |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | /******************************************************************************/ |
---|
| 78 | /* ChangeTheInitalvaluebyTabvarsName */ |
---|
| 79 | /******************************************************************************/ |
---|
| 80 | /* */ |
---|
| 81 | /******************************************************************************/ |
---|
| 82 | /* */ |
---|
| 83 | /* */ |
---|
| 84 | /* */ |
---|
| 85 | /******************************************************************************/ |
---|
[663] | 86 | char *ChangeTheInitalvaluebyTabvarsName(char *nom,listvar *listtoread, |
---|
| 87 | int whichone) |
---|
[396] | 88 | { |
---|
| 89 | char toprinttmp[LONGNOM]; |
---|
| 90 | int i; |
---|
| 91 | char chartmp[2]; |
---|
[663] | 92 | |
---|
[396] | 93 | i=0; |
---|
| 94 | strcpy(toprintglob,""); |
---|
| 95 | strcpy(toprinttmp,""); |
---|
| 96 | /* */ |
---|
| 97 | while ( i < strlen(nom) ) |
---|
| 98 | { |
---|
[663] | 99 | if ( nom[i] == '+' ) |
---|
[396] | 100 | { |
---|
| 101 | FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); |
---|
| 102 | strcpy(toprinttmp,""); |
---|
| 103 | strcat(toprintglob,"+"); |
---|
| 104 | } |
---|
[663] | 105 | else if ( nom[i] == '-' ) |
---|
[396] | 106 | { |
---|
| 107 | FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); |
---|
| 108 | strcpy(toprinttmp,""); |
---|
| 109 | strcat(toprintglob,"-"); |
---|
| 110 | } |
---|
| 111 | else if ( nom[i] == '*' ) |
---|
| 112 | { |
---|
| 113 | FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); |
---|
| 114 | strcpy(toprinttmp,""); |
---|
| 115 | strcat(toprintglob,"*"); |
---|
| 116 | } |
---|
| 117 | else if ( nom[i] == '/' ) |
---|
| 118 | { |
---|
| 119 | FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); |
---|
| 120 | strcpy(toprinttmp,""); |
---|
| 121 | strcat(toprintglob,"/"); |
---|
| 122 | } |
---|
| 123 | else if ( nom[i] == '(' ) |
---|
| 124 | { |
---|
| 125 | FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); |
---|
| 126 | strcpy(toprinttmp,""); |
---|
| 127 | strcat(toprintglob,"("); |
---|
| 128 | } |
---|
| 129 | else if ( nom[i] == ')' ) |
---|
| 130 | { |
---|
| 131 | FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); |
---|
| 132 | strcpy(toprinttmp,""); |
---|
| 133 | strcat(toprintglob,")"); |
---|
| 134 | } |
---|
| 135 | else if ( nom[i] == ':' ) |
---|
| 136 | { |
---|
| 137 | FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); |
---|
| 138 | strcpy(toprinttmp,""); |
---|
| 139 | strcat(toprintglob,":"); |
---|
| 140 | } |
---|
| 141 | else if ( nom[i] == ',' ) |
---|
| 142 | { |
---|
| 143 | FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); |
---|
| 144 | strcpy(toprinttmp,""); |
---|
| 145 | strcat(toprintglob,","); |
---|
| 146 | } |
---|
| 147 | else |
---|
| 148 | { |
---|
[663] | 149 | sprintf(chartmp,"%c",nom[i]); |
---|
[396] | 150 | strcat(toprinttmp,chartmp); |
---|
| 151 | } |
---|
| 152 | /* */ |
---|
| 153 | i=i+1; |
---|
| 154 | } |
---|
| 155 | FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); |
---|
| 156 | strcpy(toprinttmp,""); |
---|
[663] | 157 | |
---|
[396] | 158 | /* */ |
---|
| 159 | return toprintglob; |
---|
| 160 | } |
---|
| 161 | |
---|
[530] | 162 | /******************************************************************************/ |
---|
| 163 | /* IsVariableReal */ |
---|
| 164 | /******************************************************************************/ |
---|
| 165 | /* */ |
---|
| 166 | /******************************************************************************/ |
---|
| 167 | /* */ |
---|
| 168 | /* */ |
---|
| 169 | /* */ |
---|
| 170 | /******************************************************************************/ |
---|
| 171 | int IsVariableReal(char *nom) |
---|
| 172 | { |
---|
| 173 | int Real; |
---|
[663] | 174 | |
---|
[530] | 175 | Real = 0; |
---|
| 176 | if ( ( nom[0] >= 'a' && nom[0] <= 'h' ) || |
---|
| 177 | ( nom[0] >= 'A' && nom[0] <= 'H' ) || |
---|
| 178 | ( nom[0] >= 'o' && nom[0] <= 'z' ) || |
---|
| 179 | ( nom[0] >= 'O' && nom[0] <= 'Z' ) |
---|
| 180 | ) |
---|
| 181 | { |
---|
| 182 | Real = 1; |
---|
| 183 | } |
---|
| 184 | /* */ |
---|
| 185 | return Real; |
---|
| 186 | } |
---|
| 187 | /******************************************************************************/ |
---|
| 188 | /* IsVarInUseFile */ |
---|
| 189 | /******************************************************************************/ |
---|
| 190 | /* */ |
---|
| 191 | /******************************************************************************/ |
---|
| 192 | /* */ |
---|
| 193 | /* */ |
---|
| 194 | /* */ |
---|
| 195 | /******************************************************************************/ |
---|
[396] | 196 | void IsVarInUseFile(char *nom) |
---|
| 197 | { |
---|
| 198 | listvar *parcours; |
---|
| 199 | listparameter *parcoursparam; |
---|
| 200 | int out; |
---|
| 201 | |
---|
| 202 | out = 0; |
---|
| 203 | |
---|
[663] | 204 | parcours = List_Global_Var; |
---|
[396] | 205 | while( parcours && out == 0 ) |
---|
| 206 | { |
---|
[663] | 207 | if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out =1 ; |
---|
[396] | 208 | else parcours=parcours->suiv; |
---|
| 209 | } |
---|
| 210 | if ( out == 0 ) |
---|
| 211 | { |
---|
[663] | 212 | parcours = List_Common_Var; |
---|
[396] | 213 | while( parcours && out == 0 ) |
---|
| 214 | { |
---|
[663] | 215 | if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out =1 ; |
---|
[396] | 216 | else parcours=parcours->suiv; |
---|
| 217 | } |
---|
| 218 | } |
---|
| 219 | if ( out == 0 ) |
---|
| 220 | { |
---|
[663] | 221 | parcours = List_GlobalParameter_Var; |
---|
[396] | 222 | while( parcours && out == 0 ) |
---|
| 223 | { |
---|
[663] | 224 | if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out =1 ; |
---|
[396] | 225 | else parcours=parcours->suiv; |
---|
| 226 | } |
---|
| 227 | } |
---|
| 228 | if ( out == 0 ) |
---|
| 229 | { |
---|
[663] | 230 | parcours = List_Parameter_Var; |
---|
| 231 | while( parcours && out == 0 ) |
---|
| 232 | { |
---|
| 233 | if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out =1 ; |
---|
| 234 | else parcours=parcours->suiv; |
---|
| 235 | } |
---|
| 236 | } |
---|
| 237 | if ( out == 0 ) |
---|
| 238 | { |
---|
| 239 | parcoursparam = List_GlobParamModuleUsed_Var; |
---|
[396] | 240 | while( parcoursparam && out == 0 ) |
---|
| 241 | { |
---|
[663] | 242 | if ( !strcasecmp(nom,parcoursparam->p_name) ) out =2 ; |
---|
[396] | 243 | else parcoursparam=parcoursparam->suiv; |
---|
| 244 | } |
---|
| 245 | } |
---|
| 246 | if ( out == 0 ) |
---|
| 247 | { |
---|
[663] | 248 | parcours = List_ModuleUsed_Var; |
---|
[396] | 249 | while( parcours && out == 0 ) |
---|
| 250 | { |
---|
[663] | 251 | if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out =2 ; |
---|
[396] | 252 | else parcours=parcours->suiv; |
---|
| 253 | } |
---|
| 254 | } |
---|
| 255 | if ( out == 0 || out == 2 ) |
---|
| 256 | { |
---|
[663] | 257 | parcoursparam = List_GlobParamModuleUsedInModuleUsed_Var; |
---|
[396] | 258 | while( parcoursparam && out != 1 ) |
---|
| 259 | { |
---|
[663] | 260 | if ( !strcasecmp(nom,parcoursparam->p_name) ) out =1 ; |
---|
[396] | 261 | else parcoursparam=parcoursparam->suiv; |
---|
| 262 | } |
---|
[663] | 263 | if ( out == 1 ) |
---|
[396] | 264 | { |
---|
[663] | 265 | strcpy(charusemodule,parcoursparam->p_modulename); |
---|
| 266 | Addmoduletothelist(parcoursparam->p_modulename); |
---|
[396] | 267 | } |
---|
| 268 | } |
---|
[663] | 269 | if ( out == 0 && |
---|
| 270 | strcasecmp(nom,"MAX") && |
---|
| 271 | strcasecmp(nom,"mpi_status_size") |
---|
| 272 | ) |
---|
| 273 | { |
---|
| 274 | printf("--- in UtilCharacter we do not found the \n"); |
---|
| 275 | printf("--- variable %s, the module where this \n",nom); |
---|
| 276 | printf("--- variable has been defined has not been\n"); |
---|
| 277 | printf("--- found.\n"); |
---|
| 278 | } |
---|
[396] | 279 | } |
---|
| 280 | |
---|
| 281 | /******************************************************************************/ |
---|
| 282 | /* DecomposeTheNameinlistnom */ |
---|
| 283 | /******************************************************************************/ |
---|
| 284 | /* Firstpass 0 */ |
---|
| 285 | /******************************************************************************/ |
---|
| 286 | /* */ |
---|
| 287 | /* */ |
---|
| 288 | /******************************************************************************/ |
---|
| 289 | listnom *DecomposeTheNameinlistnom(char *nom, listnom * listout) |
---|
| 290 | { |
---|
| 291 | char toprinttmp[LONGNOM]; |
---|
| 292 | int i; |
---|
| 293 | char chartmp[2]; |
---|
[663] | 294 | |
---|
[396] | 295 | i=0; |
---|
| 296 | strcpy(toprinttmp,""); |
---|
| 297 | /* */ |
---|
| 298 | while ( i < strlen(nom) ) |
---|
| 299 | { |
---|
| 300 | if ( nom[i] == '+' || |
---|
| 301 | nom[i] == '-' || |
---|
| 302 | nom[i] == '*' || |
---|
| 303 | nom[i] == '/' || |
---|
| 304 | nom[i] == ')' || |
---|
| 305 | nom[i] == '(' || |
---|
| 306 | nom[i] == ',' || |
---|
[663] | 307 | nom[i] == ':' |
---|
| 308 | ) |
---|
[396] | 309 | { |
---|
| 310 | if (strcasecmp(toprinttmp,"") && ( toprinttmp[0] >= 'A' ) ) |
---|
[663] | 311 | { |
---|
| 312 | listout = Addtolistnom(toprinttmp,listout,0); |
---|
[396] | 313 | } |
---|
| 314 | strcpy(toprinttmp,""); |
---|
| 315 | } |
---|
| 316 | else |
---|
| 317 | { |
---|
[663] | 318 | sprintf(chartmp,"%c",nom[i]); |
---|
[396] | 319 | strcat(toprinttmp,chartmp); |
---|
| 320 | } |
---|
| 321 | /* */ |
---|
| 322 | i=i+1; |
---|
| 323 | } |
---|
[663] | 324 | if (strcasecmp(toprinttmp,"") && ( toprinttmp[0] >= 'A' ) ) |
---|
| 325 | { |
---|
| 326 | listout = Addtolistnom(toprinttmp,listout,0); |
---|
[396] | 327 | } |
---|
| 328 | strcpy(toprinttmp,""); |
---|
[663] | 329 | |
---|
| 330 | return listout; |
---|
[396] | 331 | } |
---|
| 332 | |
---|
| 333 | |
---|
| 334 | /******************************************************************************/ |
---|
| 335 | /* DecomposeTheName */ |
---|
| 336 | /******************************************************************************/ |
---|
| 337 | /* Firstpass 0 */ |
---|
| 338 | /******************************************************************************/ |
---|
| 339 | /* */ |
---|
| 340 | /* Agrif_<toto>(variable) ====> Agrif_<toto>(variable) */ |
---|
| 341 | /* */ |
---|
| 342 | /******************************************************************************/ |
---|
| 343 | void DecomposeTheName(char *nom) |
---|
| 344 | { |
---|
| 345 | char toprinttmp[LONGNOM]; |
---|
| 346 | int i; |
---|
| 347 | char chartmp[2]; |
---|
[663] | 348 | |
---|
[396] | 349 | i=0; |
---|
| 350 | strcpy(toprinttmp,""); |
---|
| 351 | /* */ |
---|
| 352 | while ( i < strlen(nom) ) |
---|
| 353 | { |
---|
| 354 | if ( nom[i] == '+' || |
---|
| 355 | nom[i] == '-' || |
---|
| 356 | nom[i] == '*' || |
---|
| 357 | nom[i] == '/' || |
---|
| 358 | nom[i] == ')' || |
---|
| 359 | nom[i] == '(' || |
---|
| 360 | nom[i] == ',' || |
---|
[663] | 361 | nom[i] == ':' |
---|
| 362 | ) |
---|
[396] | 363 | { |
---|
| 364 | if (strcasecmp(toprinttmp,"") && ( toprinttmp[0] >= 'A' ) ) |
---|
[663] | 365 | { |
---|
[396] | 366 | ajoutevarindoloop_definedimension (toprinttmp); |
---|
| 367 | /* Is this variable present in globvarofusefile */ |
---|
| 368 | IsVarInUseFile(toprinttmp); |
---|
| 369 | } |
---|
| 370 | strcpy(toprinttmp,""); |
---|
| 371 | } |
---|
| 372 | else |
---|
| 373 | { |
---|
[663] | 374 | sprintf(chartmp,"%c",nom[i]); |
---|
[396] | 375 | strcat(toprinttmp,chartmp); |
---|
| 376 | } |
---|
| 377 | /* */ |
---|
| 378 | i=i+1; |
---|
| 379 | } |
---|
[663] | 380 | if (strcasecmp(toprinttmp,"") && ( toprinttmp[0] >= 'A' ) ) |
---|
| 381 | { |
---|
[396] | 382 | ajoutevarindoloop_definedimension (toprinttmp); |
---|
| 383 | /* Is this variable present in globvarofusefile */ |
---|
| 384 | IsVarInUseFile(toprinttmp); |
---|
| 385 | } |
---|
| 386 | strcpy(toprinttmp,""); |
---|
[663] | 387 | |
---|
[396] | 388 | } |
---|
[663] | 389 | |
---|
| 390 | void convert2lower(char *name) |
---|
| 391 | { |
---|
| 392 | int l; |
---|
| 393 | int i; |
---|
| 394 | int caractere; |
---|
| 395 | |
---|
| 396 | l=strlen(name)-1; |
---|
| 397 | for (i=0;i<=l;i++) |
---|
| 398 | { |
---|
| 399 | caractere=name[i]; |
---|
| 400 | if ((caractere>=65 && caractere<=90)||(caractere>=192 && caractere<=221)) |
---|
| 401 | { |
---|
| 402 | name[i]+=32; |
---|
| 403 | } |
---|
| 404 | } |
---|
| 405 | } |
---|