[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 | /******************************************************************************/ |
---|
[774] | 33 | /* version 1.7 */ |
---|
[530] | 34 | /******************************************************************************/ |
---|
[396] | 35 | #include <stdio.h> |
---|
| 36 | #include <stdlib.h> |
---|
| 37 | #include <string.h> |
---|
| 38 | |
---|
| 39 | #include "decl.h" |
---|
| 40 | |
---|
| 41 | /******************************************************************************/ |
---|
| 42 | /* WriteBeginDeclaration */ |
---|
| 43 | /******************************************************************************/ |
---|
| 44 | /* This subroutine is used to write the begin of a declaration */ |
---|
| 45 | /* taken in a variable record */ |
---|
| 46 | /* */ |
---|
| 47 | /******************************************************************************/ |
---|
| 48 | /* */ |
---|
| 49 | /* integer variable -----------> INTEGER */ |
---|
| 50 | /* */ |
---|
| 51 | /******************************************************************************/ |
---|
[1200] | 52 | void WriteBeginDeclaration(variable *v,char ligne[LONG_4C], int visibility) |
---|
[396] | 53 | { |
---|
[774] | 54 | char tmpligne[LONG_4C]; |
---|
[396] | 55 | |
---|
[663] | 56 | if ( !strcasecmp(v->v_typevar,"") ) |
---|
| 57 | { |
---|
| 58 | printf("WARNING : The type of the variable %s \n",v->v_nomvar); |
---|
| 59 | printf(" is unknown. CONV should define a type\n"); |
---|
| 60 | } |
---|
[1200] | 61 | |
---|
[663] | 62 | sprintf (ligne, "%s", v->v_typevar); |
---|
| 63 | if ( v->v_c_star == 1 ) strcat(ligne,"*"); |
---|
[1200] | 64 | |
---|
[396] | 65 | /* We should give the precision of the variable if it has been given */ |
---|
[663] | 66 | if ( strcasecmp(v->v_precision,"") ) |
---|
[396] | 67 | { |
---|
[663] | 68 | sprintf(tmpligne,"(%s)",v->v_precision); |
---|
[774] | 69 | Save_Length(tmpligne,49); |
---|
[396] | 70 | strcat(ligne,tmpligne); |
---|
| 71 | } |
---|
[1200] | 72 | |
---|
[663] | 73 | if (strcasecmp(v->v_dimchar,"")) |
---|
[396] | 74 | { |
---|
[663] | 75 | sprintf(tmpligne,"(%s)",v->v_dimchar); |
---|
[774] | 76 | Save_Length(tmpligne,49); |
---|
[396] | 77 | strcat(ligne,tmpligne); |
---|
| 78 | } |
---|
[1200] | 79 | |
---|
[663] | 80 | if ( strcasecmp(v->v_nameinttypename,"") ) |
---|
[396] | 81 | { |
---|
[663] | 82 | sprintf(tmpligne,"*%s",v->v_nameinttypename); |
---|
[774] | 83 | Save_Length(tmpligne,49); |
---|
[396] | 84 | strcat(ligne,tmpligne); |
---|
| 85 | } |
---|
[663] | 86 | if (strcasecmp (v->v_IntentSpec, "")) |
---|
[396] | 87 | { |
---|
[663] | 88 | sprintf(tmpligne,",INTENT(%s) ",v->v_IntentSpec); |
---|
[774] | 89 | Save_Length(tmpligne,49); |
---|
[396] | 90 | strcat(ligne,tmpligne); |
---|
[663] | 91 | } |
---|
| 92 | if ( v->v_VariableIsParameter == 1 ) strcat(ligne, ", PARAMETER"); |
---|
[1200] | 93 | if (visibility == 1) |
---|
| 94 | { |
---|
[663] | 95 | if ( v->v_PublicDeclare == 1 ) strcat(ligne, ", PUBLIC"); |
---|
| 96 | if ( v->v_PrivateDeclare == 1 ) strcat(ligne, ", PRIVATE"); |
---|
[1200] | 97 | } |
---|
[663] | 98 | if ( v->v_ExternalDeclare == 1 ) strcat(ligne, ", EXTERNAL"); |
---|
| 99 | if ( v->v_allocatable == 1 && |
---|
[1200] | 100 | v->v_save == 0 ) |
---|
| 101 | {strcat(ligne,", ALLOCATABLE"); |
---|
| 102 | } |
---|
[663] | 103 | if ( v->v_optionaldeclare == 1 ) strcat(ligne,", OPTIONAL"); |
---|
| 104 | if ( v->v_pointerdeclare == 1 ) strcat(ligne,", POINTER"); |
---|
[774] | 105 | Save_Length(ligne,45); |
---|
[396] | 106 | } |
---|
| 107 | |
---|
| 108 | |
---|
| 109 | /******************************************************************************/ |
---|
| 110 | /* WriteScalarDeclaration */ |
---|
| 111 | /******************************************************************************/ |
---|
| 112 | /* This subroutine is used to write a scalar declaration */ |
---|
| 113 | /* taken in a variable record */ |
---|
| 114 | /* */ |
---|
| 115 | /******************************************************************************/ |
---|
| 116 | /* */ |
---|
| 117 | /* integer variable -----------> INTEGER :: VARIABLE */ |
---|
| 118 | /* */ |
---|
| 119 | /******************************************************************************/ |
---|
[774] | 120 | void WriteScalarDeclaration(variable *v,char ligne[LONG_4C]) |
---|
[396] | 121 | { |
---|
| 122 | |
---|
| 123 | strcat (ligne, " :: "); |
---|
[663] | 124 | strcat (ligne, v->v_nomvar); |
---|
| 125 | if ( strcasecmp(v->v_vallengspec,"") ) strcat(ligne,v->v_vallengspec); |
---|
| 126 | if ( v->v_VariableIsParameter == 1 ) |
---|
[396] | 127 | { |
---|
| 128 | strcat(ligne," = "); |
---|
[663] | 129 | strcat(ligne,v->v_initialvalue); |
---|
[396] | 130 | } |
---|
[774] | 131 | Save_Length(ligne,45); |
---|
[396] | 132 | } |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | /******************************************************************************/ |
---|
| 136 | /* WriteTableDeclaration */ |
---|
| 137 | /******************************************************************************/ |
---|
| 138 | /* This subroutine is used to write a Table declaration */ |
---|
| 139 | /* taken in a variable record */ |
---|
| 140 | /* */ |
---|
| 141 | /******************************************************************************/ |
---|
| 142 | /* */ |
---|
| 143 | /* integer variable(nb) -----------> */ |
---|
| 144 | /* INTEGER, DIMENSION(1:nb) :: variable */ |
---|
| 145 | /* */ |
---|
| 146 | /******************************************************************************/ |
---|
[774] | 147 | void WriteTableDeclaration(variable * v,char ligne[LONG_4C],int tmpok) |
---|
[396] | 148 | { |
---|
[774] | 149 | char newname[LONG_4C]; |
---|
[396] | 150 | |
---|
| 151 | strcat (ligne, ", Dimension("); |
---|
[1200] | 152 | |
---|
[663] | 153 | if ( v->v_dimensiongiven == 1 && tmpok == 1 ) |
---|
[1200] | 154 | { |
---|
[663] | 155 | strcat(ligne,v->v_readedlistdimension); |
---|
[1200] | 156 | } |
---|
[663] | 157 | if ( v->v_dimensiongiven == 1 && tmpok == 0 ) |
---|
[396] | 158 | { |
---|
| 159 | strcpy(newname,ChangeTheInitalvaluebyTabvarsName |
---|
[663] | 160 | (v->v_readedlistdimension,List_Global_Var,0)); |
---|
[1200] | 161 | |
---|
| 162 | if ( !strcasecmp(newname,"") ) strcat(newname,v->v_readedlistdimension); |
---|
| 163 | |
---|
[663] | 164 | strcpy(newname,ChangeTheInitalvaluebyTabvarsName |
---|
[1200] | 165 | (newname,List_Common_Var,0)); |
---|
| 166 | |
---|
| 167 | if ( !strcasecmp(newname,"") ) strcat(newname,v->v_readedlistdimension); |
---|
| 168 | |
---|
[396] | 169 | strcpy(newname,ChangeTheInitalvaluebyTabvarsName |
---|
[1200] | 170 | (newname,List_ModuleUsed_Var,0)); |
---|
[663] | 171 | if ( !strcasecmp(newname,"") ) strcat(newname,v->v_readedlistdimension); |
---|
[1200] | 172 | |
---|
[774] | 173 | Save_Length(newname,47); |
---|
[396] | 174 | strcat(ligne,newname); |
---|
| 175 | } |
---|
| 176 | strcat (ligne, ")"); |
---|
| 177 | strcat (ligne, " :: "); |
---|
[663] | 178 | strcat (ligne, v->v_nomvar); |
---|
| 179 | if ( strcasecmp(vallengspec,"") ) strcat(ligne,v->v_vallengspec); |
---|
[774] | 180 | |
---|
[663] | 181 | if ( v->v_VariableIsParameter == 1 ) |
---|
| 182 | { |
---|
| 183 | strcat(ligne," = "); |
---|
| 184 | strcat(ligne,v->v_initialvalue); |
---|
| 185 | } |
---|
[774] | 186 | Save_Length(ligne,45); |
---|
[396] | 187 | } |
---|
| 188 | |
---|
| 189 | /******************************************************************************/ |
---|
| 190 | /* writevardeclaration */ |
---|
| 191 | /******************************************************************************/ |
---|
| 192 | /* This subroutine is used to write the initial declaration in the file */ |
---|
| 193 | /* fileout of a variable */ |
---|
| 194 | /* */ |
---|
| 195 | /******************************************************************************/ |
---|
| 196 | /* */ |
---|
| 197 | /* integer variable(nb) -----------> */ |
---|
| 198 | /* INTEGER, DIMENSION(1:nb),Pointer :: variable */ |
---|
| 199 | /* */ |
---|
| 200 | /******************************************************************************/ |
---|
[1200] | 201 | void writevardeclaration (listvar * var_record, FILE *fileout, int value, int visibility) |
---|
[396] | 202 | { |
---|
| 203 | FILE *filecommon; |
---|
| 204 | listvar *newvar; |
---|
| 205 | variable *v; |
---|
[774] | 206 | char ligne[LONG_4C]; |
---|
[396] | 207 | |
---|
| 208 | filecommon=fileout; |
---|
| 209 | newvar = var_record; |
---|
[1200] | 210 | |
---|
[663] | 211 | if ( newvar->var->v_save == 0 || inmodulemeet == 0 ) |
---|
[396] | 212 | { |
---|
| 213 | v = newvar->var; |
---|
[1200] | 214 | |
---|
| 215 | WriteBeginDeclaration(v,ligne,visibility); |
---|
| 216 | |
---|
[663] | 217 | if ( v->v_nbdim == 0 ) WriteScalarDeclaration(v,ligne); |
---|
| 218 | else WriteTableDeclaration(v,ligne,value); |
---|
[396] | 219 | |
---|
[663] | 220 | if ( v->v_VariableIsParameter != 1 && strcasecmp(v->v_initialvalue,"") ) |
---|
[396] | 221 | { |
---|
| 222 | strcat(ligne," = "); |
---|
[663] | 223 | strcat(ligne,v->v_initialvalue); |
---|
| 224 | } |
---|
[1200] | 225 | |
---|
[396] | 226 | tofich (filecommon, ligne,1); |
---|
| 227 | } |
---|
[774] | 228 | Save_Length(ligne,45); |
---|
[1200] | 229 | |
---|
[396] | 230 | } |
---|
| 231 | |
---|
| 232 | |
---|
[663] | 233 | void WriteLocalParamDeclaration() |
---|
[396] | 234 | { |
---|
[663] | 235 | listvar *parcours; |
---|
[396] | 236 | |
---|
[663] | 237 | parcours = List_Parameter_Var; |
---|
| 238 | while ( parcours ) |
---|
| 239 | { |
---|
| 240 | if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) ) |
---|
| 241 | { |
---|
[1200] | 242 | writevardeclaration(parcours,fortranout,0,1); |
---|
[663] | 243 | } |
---|
| 244 | parcours = parcours -> suiv; |
---|
| 245 | } |
---|
[396] | 246 | } |
---|
| 247 | |
---|
[1200] | 248 | void WriteFunctionDeclaration(int value) |
---|
[663] | 249 | { |
---|
| 250 | listvar *parcours; |
---|
[396] | 251 | |
---|
[663] | 252 | parcours = List_FunctionType_Var; |
---|
| 253 | while ( parcours ) |
---|
| 254 | { |
---|
| 255 | if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) && |
---|
| 256 | strcasecmp(parcours->var->v_typevar,"") |
---|
| 257 | ) |
---|
| 258 | { |
---|
[1200] | 259 | writevardeclaration(parcours,fortranout,value,1); |
---|
[663] | 260 | } |
---|
| 261 | parcours = parcours -> suiv; |
---|
| 262 | } |
---|
| 263 | } |
---|
| 264 | |
---|
| 265 | void WriteSubroutineDeclaration(int value) |
---|
[396] | 266 | { |
---|
[663] | 267 | listvar *parcours; |
---|
[396] | 268 | |
---|
[663] | 269 | parcours = List_SubroutineDeclaration_Var; |
---|
| 270 | while ( parcours ) |
---|
| 271 | { |
---|
| 272 | if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) && |
---|
| 273 | parcours->var->v_save == 0 && |
---|
[1200] | 274 | (parcours->var->v_allocatable == 0 || !strcasecmp(parcours->var->v_typevar,"type")) && |
---|
[663] | 275 | parcours->var->v_pointerdeclare == 0 && |
---|
| 276 | parcours->var->v_VariableIsParameter == 0 && |
---|
| 277 | parcours->var->v_common == 0 |
---|
| 278 | ) |
---|
| 279 | { |
---|
[1200] | 280 | writevardeclaration(parcours,fortranout,value,1); |
---|
| 281 | |
---|
[663] | 282 | } |
---|
| 283 | else if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) && |
---|
| 284 | parcours->var->v_save == 0 && |
---|
| 285 | parcours->var->v_VariableIsParameter == 0 && |
---|
| 286 | parcours->var->v_common == 0 |
---|
| 287 | ) |
---|
| 288 | { |
---|
[1200] | 289 | writevardeclaration(parcours,fortranout,value,1); |
---|
| 290 | |
---|
[663] | 291 | } |
---|
| 292 | parcours = parcours -> suiv; |
---|
| 293 | } |
---|
[396] | 294 | } |
---|
| 295 | |
---|
[663] | 296 | void WriteArgumentDeclaration_beforecall() |
---|
[396] | 297 | { |
---|
[663] | 298 | int position; |
---|
| 299 | listnom *neededparameter; |
---|
| 300 | FILE *paramtoamr; |
---|
| 301 | listvar *newvar; |
---|
[774] | 302 | char ligne[LONG_4C]; |
---|
[396] | 303 | |
---|
[663] | 304 | fprintf(fortranout,"#include \"Param_BeforeCall_%s.h\" \n",subroutinename); |
---|
| 305 | /* */ |
---|
| 306 | sprintf(ligne,"Param_BeforeCall_%s.h",subroutinename); |
---|
| 307 | paramtoamr = associate (ligne); |
---|
| 308 | /* */ |
---|
| 309 | neededparameter = (listnom * )NULL; |
---|
| 310 | /* */ |
---|
| 311 | position = 1; |
---|
| 312 | newvar = List_SubroutineArgument_Var; |
---|
| 313 | while ( newvar ) |
---|
| 314 | { |
---|
| 315 | if ( !strcasecmp(newvar->var->v_subroutinename,subroutinename) && |
---|
| 316 | newvar->var->v_positioninblock == position |
---|
| 317 | ) |
---|
| 318 | { |
---|
| 319 | position = position + 1; |
---|
[1200] | 320 | |
---|
| 321 | writevardeclaration(newvar,fortranout,0,1); |
---|
[663] | 322 | neededparameter = writedeclarationintoamr(List_Parameter_Var, |
---|
| 323 | paramtoamr,newvar->var,newvar->var->v_subroutinename, |
---|
| 324 | neededparameter,subroutinename); |
---|
[396] | 325 | |
---|
[663] | 326 | newvar = List_SubroutineArgument_Var; |
---|
| 327 | } |
---|
| 328 | else newvar = newvar -> suiv; |
---|
| 329 | } |
---|
[774] | 330 | Save_Length(ligne,45); |
---|
[663] | 331 | fclose(paramtoamr); |
---|
[396] | 332 | } |
---|
| 333 | |
---|
[663] | 334 | void WriteArgumentDeclaration_Sort() |
---|
| 335 | { |
---|
| 336 | int position; |
---|
| 337 | listvar *newvar; |
---|
| 338 | |
---|
| 339 | /* */ |
---|
| 340 | position = 1; |
---|
| 341 | newvar = List_SubroutineArgument_Var; |
---|
| 342 | while ( newvar ) |
---|
| 343 | { |
---|
| 344 | if ( !strcasecmp(newvar->var->v_subroutinename,subroutinename) && |
---|
| 345 | newvar->var->v_positioninblock == position |
---|
| 346 | ) |
---|
| 347 | { |
---|
| 348 | position = position + 1; |
---|
[1200] | 349 | |
---|
| 350 | writevardeclaration(newvar,fortranout,1,1); |
---|
[663] | 351 | /* */ |
---|
| 352 | newvar = List_SubroutineArgument_Var; |
---|
| 353 | } |
---|
| 354 | else newvar = newvar -> suiv; |
---|
| 355 | } |
---|
| 356 | /* */ |
---|
| 357 | newvar = List_SubroutineArgument_Var; |
---|
| 358 | while ( newvar ) |
---|
| 359 | { |
---|
| 360 | if ( !strcasecmp(newvar->var->v_subroutinename,subroutinename) && |
---|
| 361 | newvar->var->v_positioninblock == 0 && |
---|
| 362 | newvar->var->v_nbdim == 0 |
---|
| 363 | ) |
---|
| 364 | { |
---|
[1200] | 365 | |
---|
| 366 | writevardeclaration(newvar,fortranout,1,1); |
---|
[663] | 367 | } |
---|
| 368 | newvar = newvar -> suiv; |
---|
| 369 | } |
---|
| 370 | /* */ |
---|
| 371 | newvar = List_SubroutineArgument_Var; |
---|
| 372 | while ( newvar ) |
---|
| 373 | { |
---|
| 374 | if ( !strcasecmp(newvar->var->v_subroutinename,subroutinename) && |
---|
| 375 | newvar->var->v_positioninblock == 0 && |
---|
| 376 | newvar->var->v_nbdim != 0 |
---|
| 377 | ) |
---|
| 378 | { |
---|
[1200] | 379 | writevardeclaration(newvar,fortranout,1,1); |
---|
[663] | 380 | } |
---|
| 381 | newvar = newvar -> suiv; |
---|
| 382 | } |
---|
| 383 | } |
---|
| 384 | |
---|
[396] | 385 | /******************************************************************************/ |
---|
| 386 | /* writedeclarationintoamr */ |
---|
| 387 | /******************************************************************************/ |
---|
| 388 | /* This subroutine is used to write the declaration of parameters needed in */ |
---|
| 389 | /* allocation subroutines creates in toamr.c */ |
---|
| 390 | /******************************************************************************/ |
---|
| 391 | /* */ |
---|
| 392 | /* */ |
---|
| 393 | /******************************************************************************/ |
---|
[663] | 394 | listnom *writedeclarationintoamr (listvar * deb_common, FILE *fileout, |
---|
[774] | 395 | variable *var , char commonname[LONG_C], |
---|
| 396 | listnom *neededparameter, char name_common[LONG_C]) |
---|
[396] | 397 | { |
---|
| 398 | listvar *newvar; |
---|
| 399 | variable *v; |
---|
[774] | 400 | char ligne[LONG_4C]; |
---|
[396] | 401 | int changeval; |
---|
| 402 | int out; |
---|
| 403 | int writeit; |
---|
| 404 | listnom *parcours; |
---|
| 405 | listnom *parcoursprec; |
---|
[663] | 406 | |
---|
[530] | 407 | parcoursprec = (listnom * )NULL; |
---|
[396] | 408 | /* we should list the needed parameter */ |
---|
[663] | 409 | if ( !strcasecmp(name_common,commonname) ) |
---|
| 410 | neededparameter = DecomposeTheNameinlistnom(var->v_readedlistdimension, |
---|
| 411 | neededparameter); |
---|
[396] | 412 | /* */ |
---|
| 413 | parcours = neededparameter; |
---|
| 414 | while (parcours) |
---|
| 415 | { |
---|
| 416 | newvar = deb_common; |
---|
| 417 | out = 0 ; |
---|
| 418 | while ( newvar && out == 0 ) |
---|
| 419 | { |
---|
[663] | 420 | if ( !strcasecmp(parcours->o_nom,newvar->var->v_nomvar) ) |
---|
[396] | 421 | { |
---|
[663] | 422 | out=1; |
---|
[396] | 423 | /* add the name to the list of needed parameter */ |
---|
| 424 | neededparameter = DecomposeTheNameinlistnom( |
---|
[663] | 425 | newvar->var->v_initialvalue, |
---|
[396] | 426 | neededparameter ); |
---|
| 427 | } |
---|
| 428 | else newvar=newvar->suiv; |
---|
| 429 | } |
---|
| 430 | parcours=parcours->suiv; |
---|
[663] | 431 | } |
---|
[396] | 432 | /* */ |
---|
| 433 | parcours = neededparameter; |
---|
| 434 | while (parcours) |
---|
| 435 | { |
---|
| 436 | newvar = deb_common; |
---|
| 437 | out = 0 ; |
---|
| 438 | while ( newvar && out == 0 ) |
---|
| 439 | { |
---|
[663] | 440 | if ( !strcasecmp(parcours->o_nom,newvar->var->v_nomvar) ) |
---|
[396] | 441 | { |
---|
[663] | 442 | out=1; |
---|
[396] | 443 | /* add the name to the list of needed parameter */ |
---|
| 444 | neededparameter = DecomposeTheNameinlistnom( |
---|
[663] | 445 | newvar->var->v_initialvalue, |
---|
[396] | 446 | neededparameter ); |
---|
| 447 | } |
---|
| 448 | else newvar=newvar->suiv; |
---|
| 449 | } |
---|
| 450 | parcours=parcours->suiv; |
---|
[663] | 451 | } |
---|
[396] | 452 | /* */ |
---|
| 453 | tofich (fileout, "",1); |
---|
[663] | 454 | parcours = neededparameter; |
---|
| 455 | while (parcours) |
---|
[396] | 456 | { |
---|
| 457 | writeit = 0; |
---|
[663] | 458 | newvar = deb_common; |
---|
| 459 | while ( newvar && writeit == 0 ) |
---|
[396] | 460 | { |
---|
[663] | 461 | if ( !strcasecmp(parcours->o_nom,newvar->var->v_nomvar) && |
---|
| 462 | parcours->o_val == 0 ) |
---|
[396] | 463 | { |
---|
| 464 | writeit=1; |
---|
[663] | 465 | parcours->o_val = 1; |
---|
[396] | 466 | } |
---|
[663] | 467 | else newvar = newvar->suiv; |
---|
[396] | 468 | } |
---|
[663] | 469 | |
---|
[396] | 470 | if ( writeit == 1 ) |
---|
| 471 | { |
---|
| 472 | changeval = 0; |
---|
| 473 | v = newvar->var; |
---|
[1200] | 474 | if ( v->v_allocatable == 1 && strcasecmp(v->v_typevar,"type") ) |
---|
[396] | 475 | { |
---|
| 476 | changeval = 1; |
---|
[663] | 477 | v->v_allocatable = 0; |
---|
[396] | 478 | } |
---|
[1200] | 479 | WriteBeginDeclaration(v,ligne,1); |
---|
[663] | 480 | if ( v->v_nbdim == 0 ) WriteScalarDeclaration(v,ligne); |
---|
[396] | 481 | else WriteTableDeclaration(v,ligne,1); |
---|
| 482 | |
---|
| 483 | tofich (fileout, ligne,1); |
---|
[663] | 484 | if ( changeval == 1 ) |
---|
[396] | 485 | { |
---|
[663] | 486 | v->v_allocatable = 1; |
---|
[396] | 487 | } |
---|
| 488 | } |
---|
[663] | 489 | else |
---|
| 490 | { |
---|
| 491 | if ( strncasecmp(parcours->o_nom,"mpi_",4) == 0 && |
---|
| 492 | shouldincludempif == 1 ) |
---|
| 493 | { |
---|
| 494 | shouldincludempif = 0; |
---|
| 495 | fprintf(fileout," include \'mpif.h\' \n"); |
---|
| 496 | } |
---|
| 497 | } |
---|
| 498 | parcours=parcours->suiv; |
---|
[396] | 499 | } |
---|
[774] | 500 | Save_Length(ligne,45); |
---|
[663] | 501 | return neededparameter; |
---|
[396] | 502 | } |
---|
| 503 | |
---|
| 504 | |
---|
| 505 | /******************************************************************************/ |
---|
[663] | 506 | /* writesub_loopdeclaration_scalar */ |
---|
[396] | 507 | /******************************************************************************/ |
---|
[663] | 508 | /* This subroutine is used to write the declaration part of subloop */ |
---|
| 509 | /* subroutines */ |
---|
[396] | 510 | /******************************************************************************/ |
---|
| 511 | /* */ |
---|
[663] | 512 | /* integer variable(nb) -----------> */ |
---|
[396] | 513 | /* */ |
---|
[663] | 514 | /* INTEGER, DIMENSION(1:nb) :: variable */ |
---|
| 515 | /* */ |
---|
[396] | 516 | /******************************************************************************/ |
---|
[663] | 517 | void writesub_loopdeclaration_scalar (listvar * deb_common, FILE *fileout) |
---|
[396] | 518 | { |
---|
| 519 | listvar *newvar; |
---|
| 520 | variable *v; |
---|
[774] | 521 | char ligne[LONG_4C]; |
---|
[663] | 522 | |
---|
| 523 | tofich (fileout, "",1); |
---|
| 524 | newvar = deb_common; |
---|
| 525 | while (newvar) |
---|
[396] | 526 | { |
---|
[663] | 527 | if ( newvar->var->v_nbdim == 0 && |
---|
| 528 | !strcasecmp(newvar->var->v_subroutinename,subroutinename) && |
---|
[1200] | 529 | (newvar->var->v_allocatable == 0 || !strcasecmp(newvar->var->v_typevar,"type")) && |
---|
[663] | 530 | newvar->var->v_pointerdeclare == 0 |
---|
| 531 | ) |
---|
[396] | 532 | { |
---|
[663] | 533 | v = newvar->var; |
---|
| 534 | |
---|
[1200] | 535 | WriteBeginDeclaration(v,ligne,1); |
---|
[663] | 536 | WriteScalarDeclaration(v,ligne); |
---|
| 537 | tofich (fileout, ligne,1); |
---|
[396] | 538 | } |
---|
| 539 | newvar = newvar->suiv; |
---|
| 540 | } |
---|
[774] | 541 | Save_Length(ligne,45); |
---|
[663] | 542 | } |
---|
| 543 | |
---|
| 544 | /******************************************************************************/ |
---|
| 545 | /* writesub_loopdeclaration_tab */ |
---|
| 546 | /******************************************************************************/ |
---|
| 547 | /* This subroutine is used to write the declaration part of subloop */ |
---|
| 548 | /* subroutines */ |
---|
| 549 | /******************************************************************************/ |
---|
| 550 | /* */ |
---|
| 551 | /* integer variable(nb) -----------> */ |
---|
| 552 | /* */ |
---|
| 553 | /* INTEGER, DIMENSION(1:nb) :: variable */ |
---|
| 554 | /* */ |
---|
| 555 | /******************************************************************************/ |
---|
| 556 | void writesub_loopdeclaration_tab (listvar * deb_common, FILE *fileout) |
---|
| 557 | { |
---|
| 558 | listvar *newvar; |
---|
| 559 | variable *v; |
---|
[774] | 560 | char ligne[LONG_4C]; |
---|
[663] | 561 | int changeval; |
---|
| 562 | |
---|
[396] | 563 | tofich (fileout, "",1); |
---|
| 564 | newvar = deb_common; |
---|
| 565 | while (newvar) |
---|
| 566 | { |
---|
[663] | 567 | if ( newvar->var->v_nbdim != 0 && |
---|
| 568 | !strcasecmp(newvar->var->v_subroutinename,subroutinename) && |
---|
[1200] | 569 | (newvar->var->v_allocatable == 0 || !strcasecmp(newvar->var->v_typevar,"type")) && |
---|
[663] | 570 | newvar->var->v_pointerdeclare == 0 |
---|
| 571 | ) |
---|
[396] | 572 | { |
---|
| 573 | changeval = 0; |
---|
| 574 | v = newvar->var; |
---|
[1200] | 575 | if ( v->v_allocatable == 1) |
---|
[396] | 576 | { |
---|
[1200] | 577 | if (strcasecmp(v->v_typevar,"type")) |
---|
| 578 | { |
---|
[396] | 579 | changeval = 1; |
---|
[663] | 580 | v->v_allocatable = 0; |
---|
[1200] | 581 | } |
---|
| 582 | else |
---|
| 583 | { |
---|
| 584 | changeval = 2; |
---|
| 585 | v->v_allocatable = 0; |
---|
| 586 | v->v_pointerdeclare = 1; |
---|
| 587 | } |
---|
[396] | 588 | } |
---|
[1200] | 589 | |
---|
| 590 | WriteBeginDeclaration(v,ligne,1); |
---|
[663] | 591 | WriteTableDeclaration(v,ligne,1); |
---|
[396] | 592 | tofich (fileout, ligne,1); |
---|
[1200] | 593 | if ( changeval >= 1 ) v->v_allocatable = 1; |
---|
| 594 | if ( changeval == 2 ) v->v_pointerdeclare = 0; |
---|
[396] | 595 | } |
---|
| 596 | newvar = newvar->suiv; |
---|
| 597 | } |
---|
[774] | 598 | Save_Length(ligne,45); |
---|
[396] | 599 | } |
---|
[1200] | 600 | |
---|
| 601 | |
---|
| 602 | void ReWriteDeclarationAndAddTosubroutine_01(listvar *listdecl) |
---|
| 603 | { |
---|
| 604 | listvar *parcours; |
---|
| 605 | listvar *parcours2; |
---|
| 606 | listvar *parcours3; |
---|
| 607 | int out; |
---|
| 608 | |
---|
| 609 | if (insubroutinedeclare == 1) |
---|
| 610 | { |
---|
| 611 | parcours = listdecl; |
---|
| 612 | while (parcours) |
---|
| 613 | { |
---|
| 614 | /* |
---|
| 615 | parcours2 = List_SubroutineArgument_Var; |
---|
| 616 | out = 0; |
---|
| 617 | while (parcours2 && out == 0) |
---|
| 618 | { |
---|
| 619 | if (!strcasecmp(parcours2->var->v_subroutinename,subroutinename) && !strcasecmp(parcours2->var->v_nomvar,parcours->var->v_nomvar)) |
---|
| 620 | { |
---|
| 621 | out = 1; |
---|
| 622 | } |
---|
| 623 | parcours2 = parcours2->suiv; |
---|
| 624 | } |
---|
| 625 | */ |
---|
| 626 | out = LookingForVariableInList(List_SubroutineArgument_Var,parcours->var); |
---|
| 627 | if (out == 0) out = VariableIsInListCommon(parcours,List_Common_Var); |
---|
| 628 | if (out == 0) out = LookingForVariableInList(List_Parameter_Var,parcours->var); |
---|
| 629 | if (out == 0) out = LookingForVariableInList(List_FunctionType_Var,parcours->var); |
---|
| 630 | |
---|
| 631 | /* |
---|
| 632 | parcours2 = List_Common_Var; |
---|
| 633 | while (parcours2 && out == 0) |
---|
| 634 | { |
---|
| 635 | if (!strcasecmp(parcours2->var->v_commoninfile,mainfile) && !strcasecmp(parcours2->var->v_nomvar,parcours->var->v_nomvar)) |
---|
| 636 | { |
---|
| 637 | out = 1; |
---|
| 638 | } |
---|
| 639 | parcours2 = parcours2->suiv; |
---|
| 640 | } |
---|
| 641 | */ |
---|
| 642 | //printf("nom = %s %d %d %d\n",parcours->var->v_nomvar,out,VariableIsParameter,SaveDeclare); |
---|
| 643 | if (firstpass == 0 && out == 0 && VariableIsParameter == 0 && SaveDeclare == 0) |
---|
| 644 | |
---|
| 645 | { |
---|
| 646 | writevardeclaration(parcours,fortranout,1,1); |
---|
| 647 | } |
---|
| 648 | //if (firstpass == 1 && out == 1) |
---|
| 649 | if (firstpass == 1) |
---|
| 650 | { |
---|
| 651 | if (VariableIsParameter == 0 && SaveDeclare == 0) |
---|
| 652 | { |
---|
| 653 | List_SubroutineDeclaration_Var = insertvar(List_SubroutineDeclaration_Var,parcours->var); |
---|
| 654 | } |
---|
| 655 | } |
---|
| 656 | parcours = parcours->suiv; |
---|
| 657 | } |
---|
| 658 | } |
---|
| 659 | } |
---|