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