[396] | 1 | /******************************************************************************/ |
---|
| 2 | /* */ |
---|
| 3 | /* CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran) */ |
---|
| 4 | /* */ |
---|
[530] | 5 | /* Copyright or © or Copr. Laurent Debreu (Laurent.Debreu@imag.fr) */ |
---|
[396] | 6 | /* Cyril Mazauric (Cyril.Mazauric@imag.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 | /******************************************************************************/ |
---|
[530] | 33 | /* version 1.0 */ |
---|
| 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 | /******************************************************************************/ |
---|
| 52 | void WriteBeginDeclaration(variable *v,char ligne[LONGLIGNE]) |
---|
| 53 | { |
---|
| 54 | char tmpligne[LONGLIGNE]; |
---|
| 55 | |
---|
| 56 | sprintf (ligne, "%s", v->typevar); |
---|
| 57 | if ( v->c_star == 1 ) strcat(ligne,"*"); |
---|
| 58 | /* We should give the precision of the variable if it has been given */ |
---|
| 59 | if ( strcasecmp(v->precision,"") ) |
---|
| 60 | { |
---|
| 61 | sprintf(tmpligne,"(%s)",v->precision); |
---|
| 62 | strcat(ligne,tmpligne); |
---|
| 63 | } |
---|
| 64 | if (strcasecmp(v->dimchar,"")) |
---|
| 65 | { |
---|
| 66 | sprintf(tmpligne,"(%s)",v->dimchar); |
---|
| 67 | strcat(ligne,tmpligne); |
---|
| 68 | } |
---|
| 69 | if ( strcasecmp(v->nameinttypename,"") ) |
---|
| 70 | { |
---|
| 71 | sprintf(tmpligne,"*%s",v->nameinttypename); |
---|
| 72 | strcat(ligne,tmpligne); |
---|
| 73 | } |
---|
| 74 | if (strcasecmp (v->IntentSpec, "")) |
---|
| 75 | { |
---|
[530] | 76 | sprintf(tmpligne,",INTENT(%s) ",v->IntentSpec); |
---|
[396] | 77 | strcat(ligne,tmpligne); |
---|
| 78 | } |
---|
| 79 | if ( v->VariableIsParameter == 1 ) strcat(ligne, ", PARAMETER"); |
---|
| 80 | if ( v->PublicDeclare == 1 ) strcat(ligne, ", PUBLIC"); |
---|
| 81 | if ( v->PrivateDeclare == 1 ) strcat(ligne, ", PRIVATE"); |
---|
| 82 | if ( v->ExternalDeclare == 1 ) strcat(ligne, ", EXTERNAL"); |
---|
| 83 | if ( v->allocatable == 1 && v->save ==0 ) strcat(ligne,", ALLOCATABLE"); |
---|
| 84 | if ( v->optionaldeclare == 1 ) strcat(ligne,", OPTIONAL"); |
---|
| 85 | if ( v->pointerdeclare == 1 ) strcat(ligne,", POINTER"); |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | /******************************************************************************/ |
---|
| 90 | /* WriteScalarDeclaration */ |
---|
| 91 | /******************************************************************************/ |
---|
| 92 | /* This subroutine is used to write a scalar declaration */ |
---|
| 93 | /* taken in a variable record */ |
---|
| 94 | /* */ |
---|
| 95 | /******************************************************************************/ |
---|
| 96 | /* */ |
---|
| 97 | /* integer variable -----------> INTEGER :: VARIABLE */ |
---|
| 98 | /* */ |
---|
| 99 | /******************************************************************************/ |
---|
| 100 | void WriteScalarDeclaration(variable *v,char ligne[LONGLIGNE]) |
---|
| 101 | { |
---|
| 102 | |
---|
| 103 | strcat (ligne, " :: "); |
---|
| 104 | strcat (ligne, v->nomvar); |
---|
[530] | 105 | if ( strcasecmp(v->vallengspec,"") ) strcat(ligne,v->vallengspec); |
---|
[396] | 106 | if ( v->VariableIsParameter == 1 ) |
---|
| 107 | { |
---|
| 108 | strcat(ligne," = "); |
---|
| 109 | strcat(ligne,v->initialvalue); |
---|
| 110 | } |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | /******************************************************************************/ |
---|
| 115 | /* WriteTableDeclaration */ |
---|
| 116 | /******************************************************************************/ |
---|
| 117 | /* This subroutine is used to write a Table declaration */ |
---|
| 118 | /* taken in a variable record */ |
---|
| 119 | /* */ |
---|
| 120 | /******************************************************************************/ |
---|
| 121 | /* */ |
---|
| 122 | /* integer variable(nb) -----------> */ |
---|
| 123 | /* INTEGER, DIMENSION(1:nb) :: variable */ |
---|
| 124 | /* */ |
---|
| 125 | /******************************************************************************/ |
---|
| 126 | void WriteTableDeclaration(variable * v,char ligne[LONGLIGNE],int tmpok) |
---|
| 127 | { |
---|
| 128 | char newname[LONGNOM]; |
---|
| 129 | |
---|
| 130 | strcat (ligne, ", Dimension("); |
---|
| 131 | if ( v->dimensiongiven == 1 && tmpok == 1 ) |
---|
| 132 | strcat(ligne,v->readedlistdimension); |
---|
| 133 | if ( v->dimensiongiven == 1 && tmpok == 0 ) |
---|
| 134 | { |
---|
| 135 | strcpy(newname,ChangeTheInitalvaluebyTabvarsName |
---|
| 136 | (v->readedlistdimension,globliste,0)); |
---|
| 137 | if ( !strcasecmp(newname,v->readedlistdimension) ) |
---|
| 138 | { |
---|
| 139 | strcpy(newname,""); |
---|
| 140 | /* la liste des use de cette subroutine */ |
---|
| 141 | strcpy(newname,ChangeTheInitalvaluebyTabvarsName |
---|
| 142 | (v->readedlistdimension,globalvarofusefile,0)); |
---|
| 143 | if ( !strcasecmp(newname,"") ) strcat(newname,v->readedlistdimension); |
---|
| 144 | } |
---|
| 145 | strcat(ligne,newname); |
---|
| 146 | } |
---|
| 147 | strcat (ligne, ")"); |
---|
| 148 | strcat (ligne, " :: "); |
---|
| 149 | strcat (ligne, v->nomvar); |
---|
[530] | 150 | if ( strcasecmp(vallengspec,"") ) strcat(ligne,v->vallengspec); |
---|
[396] | 151 | if ( !strcasecmp (v->typevar, "character") ) strcat(ligne,vargridparam(v,0)); |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | /******************************************************************************/ |
---|
| 155 | /* writevardeclaration */ |
---|
| 156 | /******************************************************************************/ |
---|
| 157 | /* This subroutine is used to write the initial declaration in the file */ |
---|
| 158 | /* fileout of a variable */ |
---|
| 159 | /* */ |
---|
| 160 | /******************************************************************************/ |
---|
| 161 | /* */ |
---|
| 162 | /* integer variable(nb) -----------> */ |
---|
| 163 | /* INTEGER, DIMENSION(1:nb),Pointer :: variable */ |
---|
| 164 | /* */ |
---|
| 165 | /******************************************************************************/ |
---|
| 166 | void writevardeclaration (listvar * var_record, FILE *fileout) |
---|
| 167 | { |
---|
| 168 | FILE *filecommon; |
---|
| 169 | listvar *newvar; |
---|
| 170 | variable *v; |
---|
| 171 | char ligne[LONGNOM]; |
---|
| 172 | |
---|
| 173 | filecommon=fileout; |
---|
| 174 | newvar = var_record; |
---|
| 175 | |
---|
| 176 | if ( newvar->var->save == 0 || inmodulemeet == 0 ) |
---|
| 177 | { |
---|
| 178 | v = newvar->var; |
---|
| 179 | WriteBeginDeclaration(v,ligne); |
---|
| 180 | if ( v->nbdim == 0 ) WriteScalarDeclaration(v,ligne); |
---|
| 181 | else WriteTableDeclaration(v,ligne,0); |
---|
| 182 | |
---|
| 183 | if ( strcasecmp(v->initialvalue,"") ) |
---|
| 184 | { |
---|
| 185 | strcat(ligne," = "); |
---|
| 186 | strcat(ligne,v->initialvalue); |
---|
| 187 | } |
---|
| 188 | tofich (filecommon, ligne,1); |
---|
| 189 | } |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | |
---|
| 193 | /******************************************************************************/ |
---|
| 194 | /* NonGridDepDeclaration */ |
---|
| 195 | /******************************************************************************/ |
---|
| 196 | /* This subroutine is used to change the variables declaration */ |
---|
| 197 | /* */ |
---|
| 198 | /******************************************************************************/ |
---|
| 199 | /* */ |
---|
| 200 | /* integer variable(nb) -----------> */ |
---|
| 201 | /* INTEGER, DIMENSION(:),Pointer :: variable */ |
---|
| 202 | /* */ |
---|
| 203 | /******************************************************************************/ |
---|
| 204 | void NonGridDepDeclaration(listvar * deb_common) |
---|
| 205 | { |
---|
| 206 | listvar *newvar; |
---|
| 207 | |
---|
| 208 | if ( ( SaveDeclare == 0 || aftercontainsdeclare == 0 ) && listenotgriddepend ) |
---|
| 209 | { |
---|
| 210 | newvar = deb_common; |
---|
| 211 | while (newvar) |
---|
| 212 | { |
---|
| 213 | if ( VarIsNonGridDepend(newvar->var->nomvar) == 1 ) |
---|
| 214 | writevardeclaration (newvar, fortranout); |
---|
| 215 | newvar = newvar->suiv; |
---|
| 216 | } |
---|
| 217 | } |
---|
| 218 | } |
---|
| 219 | |
---|
| 220 | |
---|
| 221 | /******************************************************************************/ |
---|
| 222 | /* writedeclaration */ |
---|
| 223 | /******************************************************************************/ |
---|
| 224 | /* This subroutine is used to write the declaration if variable present in */ |
---|
| 225 | /* the deb_common and also in the presentinthislist list file */ |
---|
| 226 | /******************************************************************************/ |
---|
| 227 | /* */ |
---|
| 228 | /* integer variable(nb) -----------> */ |
---|
| 229 | /* INTEGER, DIMENSION(1:nb),Pointer :: variable */ |
---|
| 230 | /* */ |
---|
| 231 | /******************************************************************************/ |
---|
| 232 | void writedeclaration (listvar * deb_common, FILE *fileout, listvar *presentinthislist) |
---|
| 233 | { |
---|
| 234 | FILE *filecommon; |
---|
| 235 | listvar *newvar; |
---|
| 236 | listvar *parcours; |
---|
| 237 | variable *v; |
---|
| 238 | char ligne[LONGLIGNE]; |
---|
| 239 | int out; |
---|
| 240 | |
---|
| 241 | filecommon=fileout; |
---|
| 242 | |
---|
| 243 | newvar = deb_common; |
---|
| 244 | while (newvar) |
---|
| 245 | { |
---|
| 246 | if ( newvar->var->save == 0 || inmodulemeet == 0 ) |
---|
| 247 | { |
---|
| 248 | parcours = presentinthislist; |
---|
| 249 | /* we should write declaration of variable present in the list */ |
---|
| 250 | /* presentinthislist */ |
---|
| 251 | /* if presentinthislist is empty we should write all declarations */ |
---|
| 252 | out = 0 ; |
---|
| 253 | while ( parcours && out == 0 ) |
---|
| 254 | { |
---|
| 255 | /* if we find this variable in the presentinthislist, we */ |
---|
| 256 | /* could write it */ |
---|
| 257 | if ( !strcasecmp(parcours->var->nomvar,newvar->var->nomvar) && |
---|
| 258 | !strcasecmp(parcours->var->subroutinename, |
---|
| 259 | newvar->var->subroutinename) |
---|
| 260 | ) out = 1; |
---|
| 261 | else parcours =parcours ->suiv; |
---|
| 262 | } |
---|
| 263 | if ( out == 0 || !presentinthislist) |
---|
| 264 | { |
---|
| 265 | /* if the variable has not been found or if the */ |
---|
| 266 | /* presentinthislist is empty, we do not write the declaration */ |
---|
| 267 | } |
---|
| 268 | else |
---|
| 269 | { |
---|
| 270 | /* else we could write it */ |
---|
| 271 | v = newvar->var; |
---|
| 272 | WriteBeginDeclaration(v,ligne); |
---|
| 273 | if ( v->nbdim == 0 ) WriteScalarDeclaration(v,ligne); |
---|
| 274 | else WriteTableDeclaration(v,ligne,0); |
---|
| 275 | |
---|
| 276 | if ( strcasecmp(v->initialvalue,"") ) |
---|
| 277 | { |
---|
| 278 | strcat(ligne, "="); |
---|
| 279 | strcat(ligne, v->initialvalue); |
---|
| 280 | } |
---|
| 281 | tofich (filecommon, ligne,1); |
---|
| 282 | } |
---|
| 283 | } |
---|
| 284 | newvar = newvar->suiv; |
---|
| 285 | } |
---|
| 286 | } |
---|
| 287 | |
---|
| 288 | /******************************************************************************/ |
---|
| 289 | /* writesub_loopdeclaration */ |
---|
| 290 | /******************************************************************************/ |
---|
| 291 | /* This subroutine is used to write the declaration part of subloop */ |
---|
| 292 | /* subroutines */ |
---|
| 293 | /******************************************************************************/ |
---|
| 294 | /* */ |
---|
| 295 | /* integer variable(nb) -----------> */ |
---|
| 296 | /* */ |
---|
| 297 | /* INTEGER, DIMENSION(1:nb) :: variable */ |
---|
| 298 | /* */ |
---|
| 299 | /******************************************************************************/ |
---|
| 300 | void writesub_loopdeclaration (listvar * deb_common, FILE *fileout) |
---|
| 301 | { |
---|
| 302 | listvar *newvar; |
---|
| 303 | variable *v; |
---|
| 304 | char ligne[LONGLIGNE]; |
---|
| 305 | int changeval; |
---|
| 306 | |
---|
| 307 | tofich (fileout, "",1); |
---|
| 308 | newvar = deb_common; |
---|
| 309 | while (newvar) |
---|
| 310 | { |
---|
| 311 | if ( !strcasecmp(newvar->var->modulename,subroutinename) ) |
---|
| 312 | { |
---|
| 313 | changeval = 0; |
---|
| 314 | v = newvar->var; |
---|
| 315 | if ( v->allocatable == 1 && fortran77 == 0 ) |
---|
| 316 | { |
---|
| 317 | changeval = 1; |
---|
| 318 | v->allocatable = 0; |
---|
| 319 | } |
---|
| 320 | WriteBeginDeclaration(v,ligne); |
---|
| 321 | if ( v->nbdim == 0 ) WriteScalarDeclaration(v,ligne); |
---|
| 322 | else WriteTableDeclaration(v,ligne,1); |
---|
| 323 | |
---|
| 324 | tofich (fileout, ligne,1); |
---|
| 325 | if ( changeval == 1 ) |
---|
| 326 | { |
---|
| 327 | v->allocatable = 1; |
---|
| 328 | } |
---|
| 329 | } |
---|
| 330 | newvar = newvar->suiv; |
---|
| 331 | } |
---|
| 332 | } |
---|
| 333 | |
---|
| 334 | /******************************************************************************/ |
---|
| 335 | /* writedeclarationintoamr */ |
---|
| 336 | /******************************************************************************/ |
---|
| 337 | /* This subroutine is used to write the declaration of parameters needed in */ |
---|
| 338 | /* allocation subroutines creates in toamr.c */ |
---|
| 339 | /******************************************************************************/ |
---|
| 340 | /* */ |
---|
| 341 | /* */ |
---|
| 342 | /******************************************************************************/ |
---|
| 343 | void writedeclarationintoamr (listvar * deb_common, FILE *fileout, |
---|
| 344 | listvar *listin , char commonname[LONGNOM]) |
---|
| 345 | { |
---|
| 346 | listvar *newvar; |
---|
| 347 | variable *v; |
---|
| 348 | char ligne[LONGLIGNE]; |
---|
| 349 | int changeval; |
---|
| 350 | char firstmodule[LONGNOM]; |
---|
| 351 | int out; |
---|
| 352 | listnom *neededparameter; |
---|
| 353 | int writeit; |
---|
| 354 | listnom *parcours; |
---|
| 355 | listnom *parcoursprec; |
---|
| 356 | |
---|
[530] | 357 | parcoursprec = (listnom * )NULL; |
---|
[396] | 358 | neededparameter = (listnom * )NULL; |
---|
| 359 | /* we should list the needed parameter */ |
---|
| 360 | newvar = listin; |
---|
| 361 | out = 0 ; |
---|
| 362 | while ( newvar && out == 0 ) |
---|
| 363 | { |
---|
[530] | 364 | if ( strcasecmp(newvar->var->commonname,commonname) ) out = 1; |
---|
[396] | 365 | else |
---|
| 366 | { |
---|
| 367 | /* add the name to the list of needed parameter */ |
---|
| 368 | neededparameter = DecomposeTheNameinlistnom( |
---|
| 369 | newvar->var->readedlistdimension, |
---|
| 370 | neededparameter ); |
---|
| 371 | newvar = newvar->suiv; |
---|
| 372 | } |
---|
| 373 | } |
---|
| 374 | /* */ |
---|
| 375 | parcours = neededparameter; |
---|
| 376 | while (parcours) |
---|
| 377 | { |
---|
| 378 | newvar = deb_common; |
---|
| 379 | out = 0 ; |
---|
| 380 | while ( newvar && out == 0 ) |
---|
| 381 | { |
---|
| 382 | if ( !strcasecmp(parcours->nom,newvar->var->nomvar) ) |
---|
| 383 | { |
---|
| 384 | out=1; |
---|
| 385 | /* add the name to the list of needed parameter */ |
---|
| 386 | neededparameter = DecomposeTheNameinlistnom( |
---|
| 387 | newvar->var->initialvalue, |
---|
| 388 | neededparameter ); |
---|
| 389 | } |
---|
| 390 | else newvar=newvar->suiv; |
---|
| 391 | } |
---|
| 392 | parcours=parcours->suiv; |
---|
| 393 | } |
---|
| 394 | /* */ |
---|
| 395 | parcours = neededparameter; |
---|
| 396 | while (parcours) |
---|
| 397 | { |
---|
| 398 | newvar = deb_common; |
---|
| 399 | out = 0 ; |
---|
| 400 | while ( newvar && out == 0 ) |
---|
| 401 | { |
---|
| 402 | if ( !strcasecmp(parcours->nom,newvar->var->nomvar) ) |
---|
| 403 | { |
---|
| 404 | out=1; |
---|
| 405 | /* add the name to the list of needed parameter */ |
---|
| 406 | neededparameter = DecomposeTheNameinlistnom( |
---|
| 407 | newvar->var->initialvalue, |
---|
| 408 | neededparameter ); |
---|
| 409 | } |
---|
| 410 | else newvar=newvar->suiv; |
---|
| 411 | } |
---|
| 412 | parcours=parcours->suiv; |
---|
| 413 | } |
---|
| 414 | /* */ |
---|
| 415 | strcpy(firstmodule,""); |
---|
| 416 | tofich (fileout, "",1); |
---|
| 417 | newvar = deb_common; |
---|
| 418 | while (newvar) |
---|
| 419 | { |
---|
| 420 | writeit = 0; |
---|
| 421 | parcours = neededparameter; |
---|
| 422 | while ( parcours && writeit == 0 ) |
---|
| 423 | { |
---|
| 424 | if ( !strcasecmp(parcours->nom,newvar->var->nomvar) ) |
---|
| 425 | { |
---|
| 426 | writeit=1; |
---|
| 427 | if ( parcours == neededparameter ) |
---|
| 428 | { |
---|
| 429 | neededparameter = neededparameter->suiv; |
---|
| 430 | } |
---|
| 431 | else |
---|
| 432 | { |
---|
| 433 | parcoursprec->suiv= parcours->suiv; |
---|
| 434 | } |
---|
| 435 | } |
---|
| 436 | else |
---|
| 437 | { |
---|
| 438 | parcoursprec=parcours; |
---|
| 439 | parcours=parcours->suiv; |
---|
| 440 | } |
---|
| 441 | } |
---|
| 442 | |
---|
| 443 | if ( writeit == 1 ) |
---|
| 444 | { |
---|
| 445 | changeval = 0; |
---|
| 446 | v = newvar->var; |
---|
| 447 | if ( v->allocatable == 1 && fortran77 == 0 ) |
---|
| 448 | { |
---|
| 449 | changeval = 1; |
---|
| 450 | v->allocatable = 0; |
---|
| 451 | } |
---|
| 452 | WriteBeginDeclaration(v,ligne); |
---|
| 453 | if ( v->nbdim == 0 ) WriteScalarDeclaration(v,ligne); |
---|
| 454 | else WriteTableDeclaration(v,ligne,1); |
---|
| 455 | |
---|
| 456 | tofich (fileout, ligne,1); |
---|
| 457 | if ( changeval == 1 ) |
---|
| 458 | { |
---|
| 459 | v->allocatable = 1; |
---|
| 460 | } |
---|
| 461 | } |
---|
| 462 | newvar = newvar->suiv; |
---|
| 463 | } |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | |
---|
| 467 | |
---|
| 468 | /******************************************************************************/ |
---|
| 469 | /* writedeclarationsubroutinedeclaration */ |
---|
| 470 | /******************************************************************************/ |
---|
| 471 | /* This subroutine is used to write the declaration of parameters needed in */ |
---|
| 472 | /* in the table definition. This subroutine is used for the declaration */ |
---|
| 473 | /* part of original subroutines */ |
---|
| 474 | /******************************************************************************/ |
---|
| 475 | /* */ |
---|
| 476 | /* */ |
---|
| 477 | /******************************************************************************/ |
---|
| 478 | void writedeclarationsubroutinedeclaration(listvar * deb_common, FILE *fileout, |
---|
| 479 | listvar *listin) |
---|
| 480 | { |
---|
| 481 | listvar *newvar; |
---|
| 482 | variable *v; |
---|
| 483 | char ligne[LONGLIGNE]; |
---|
| 484 | int changeval; |
---|
| 485 | char firstmodule[LONGNOM]; |
---|
| 486 | int out; |
---|
| 487 | listnom *neededparameter; |
---|
| 488 | int writeit; |
---|
| 489 | listnom *parcours; |
---|
| 490 | listnom *parcoursprec; |
---|
| 491 | |
---|
[530] | 492 | parcoursprec = (listnom * )NULL; |
---|
[396] | 493 | neededparameter = (listnom * )NULL; |
---|
| 494 | /* we should list the needed parameter */ |
---|
| 495 | newvar = listin; |
---|
| 496 | while ( newvar ) |
---|
| 497 | { |
---|
[530] | 498 | if ( !strcasecmp(newvar->var->subroutinename,subroutinename) ) |
---|
[396] | 499 | { |
---|
| 500 | /* add the name to the list of needed parameter */ |
---|
| 501 | neededparameter = DecomposeTheNameinlistnom( |
---|
| 502 | newvar->var->readedlistdimension, |
---|
| 503 | neededparameter ); |
---|
| 504 | } |
---|
| 505 | newvar = newvar->suiv; |
---|
| 506 | } |
---|
| 507 | /* */ |
---|
| 508 | parcours = neededparameter; |
---|
| 509 | while (parcours) |
---|
| 510 | { |
---|
| 511 | newvar = deb_common; |
---|
| 512 | out = 0 ; |
---|
| 513 | while ( newvar && out == 0 ) |
---|
| 514 | { |
---|
| 515 | if ( !strcasecmp(parcours->nom,newvar->var->nomvar) ) |
---|
| 516 | { |
---|
| 517 | out=1; |
---|
| 518 | /* add the name to the list of needed parameter */ |
---|
| 519 | neededparameter = DecomposeTheNameinlistnom( |
---|
| 520 | newvar->var->initialvalue, |
---|
| 521 | neededparameter ); |
---|
| 522 | } |
---|
| 523 | else newvar=newvar->suiv; |
---|
| 524 | } |
---|
| 525 | parcours=parcours->suiv; |
---|
| 526 | } |
---|
| 527 | /* */ |
---|
| 528 | strcpy(firstmodule,""); |
---|
| 529 | tofich (fileout, "",1); |
---|
| 530 | newvar = deb_common; |
---|
| 531 | while (newvar) |
---|
| 532 | { |
---|
| 533 | writeit = 0; |
---|
| 534 | parcours = neededparameter; |
---|
| 535 | while ( parcours && writeit == 0 ) |
---|
| 536 | { |
---|
| 537 | if ( !strcasecmp(parcours->nom,newvar->var->nomvar) ) |
---|
| 538 | { |
---|
| 539 | writeit=1; |
---|
| 540 | if ( parcours == neededparameter ) |
---|
| 541 | { |
---|
| 542 | neededparameter = neededparameter->suiv; |
---|
| 543 | } |
---|
| 544 | else |
---|
| 545 | { |
---|
| 546 | parcoursprec->suiv= parcours->suiv; |
---|
| 547 | } |
---|
| 548 | } |
---|
| 549 | else |
---|
| 550 | { |
---|
| 551 | parcoursprec=parcours; |
---|
| 552 | parcours=parcours->suiv; |
---|
| 553 | } |
---|
| 554 | } |
---|
| 555 | |
---|
| 556 | if ( writeit == 1 ) |
---|
| 557 | { |
---|
| 558 | changeval = 0; |
---|
| 559 | v = newvar->var; |
---|
| 560 | if ( v->allocatable == 1 && fortran77 == 0 ) |
---|
| 561 | { |
---|
| 562 | changeval = 1; |
---|
| 563 | v->allocatable = 0; |
---|
| 564 | } |
---|
| 565 | WriteBeginDeclaration(v,ligne); |
---|
| 566 | if ( v->nbdim == 0 ) WriteScalarDeclaration(v,ligne); |
---|
| 567 | else WriteTableDeclaration(v,ligne,1); |
---|
| 568 | |
---|
| 569 | tofich (fileout, ligne,1); |
---|
| 570 | if ( changeval == 1 ) |
---|
| 571 | { |
---|
| 572 | v->allocatable = 1; |
---|
| 573 | } |
---|
| 574 | } |
---|
| 575 | newvar = newvar->suiv; |
---|
| 576 | } |
---|
| 577 | } |
---|