[1901] | 1 | /******************************************************************************/ |
---|
| 2 | /* */ |
---|
| 3 | /* CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran) */ |
---|
| 4 | /* */ |
---|
| 5 | /* Copyright or or Copr. Laurent Debreu (Laurent.Debreu@imag.fr) */ |
---|
| 6 | /* Cyril Mazauric (Cyril_Mazauric@yahoo.fr) */ |
---|
| 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". */ |
---|
| 12 | /* */ |
---|
| 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. */ |
---|
| 18 | /* */ |
---|
| 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. */ |
---|
| 29 | /* */ |
---|
| 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. */ |
---|
| 32 | /******************************************************************************/ |
---|
| 33 | /* version 1.7 */ |
---|
| 34 | /******************************************************************************/ |
---|
| 35 | #include <stdio.h> |
---|
| 36 | #include <stdlib.h> |
---|
| 37 | #include <string.h> |
---|
| 38 | #include "decl.h" |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | /******************************************************************************/ |
---|
| 42 | /* preparation and write of the argument list of a subroutine */ |
---|
| 43 | /******************************************************************************/ |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | /******************************************************************************/ |
---|
| 47 | /* writeheadnewsub_0 */ |
---|
| 48 | /******************************************************************************/ |
---|
| 49 | /* Firstpass 0 */ |
---|
| 50 | /* We should write the head of the subroutine sub_loop_<subroutinename> */ |
---|
| 51 | /******************************************************************************/ |
---|
| 52 | /* */ |
---|
| 53 | /******************************************************************************/ |
---|
| 54 | void writeheadnewsub_0() |
---|
| 55 | { |
---|
| 56 | char ligne[LONG_C]; |
---|
| 57 | |
---|
| 58 | if ( firstpass == 0 && IsTabvarsUseInArgument_0() == 1 ) |
---|
| 59 | { |
---|
| 60 | if ( todebug == 1 ) printf("Enter in writeheadnewsub_0\n"); |
---|
| 61 | /* we should add the use agrif_uti l if it is necessary */ |
---|
| 62 | WriteHeadofSubroutineLoop(); |
---|
[2715] | 63 | WriteUsemoduleDeclaration(subroutinename); |
---|
[1901] | 64 | if ( ImplicitNoneInSubroutine() == 1 ) fprintf(fortranout, |
---|
| 65 | " IMPLICIT NONE\n"); |
---|
| 66 | WriteIncludeDeclaration(); |
---|
| 67 | /* */ |
---|
| 68 | /* We should write once the declaration of tables (extract */ |
---|
| 69 | /* from pointer) in the new subroutine */ |
---|
| 70 | if ( mark == 1 ) fprintf(fortranout,"!!! 000000000000000 \n"); |
---|
[2715] | 71 | |
---|
[1901] | 72 | if ( SubInList_ContainsSubroutine() == 0 ) WriteLocalParamDeclaration(); |
---|
| 73 | if ( mark == 1 ) fprintf(fortranout,"!!! 111111111111111 \n"); |
---|
| 74 | |
---|
| 75 | sprintf(ligne,"\n#include \"ParamFile%s.h\" \n",subroutinename); |
---|
| 76 | tofich(fortranout,ligne,1); |
---|
| 77 | |
---|
| 78 | WriteArgumentDeclaration_Sort(); |
---|
| 79 | |
---|
| 80 | if ( mark == 1 ) fprintf(fortranout,"!!! 222222222222222 \n"); |
---|
| 81 | writesub_loopdeclaration_tab(List_UsedInSubroutine_Var,fortranout); |
---|
| 82 | if ( mark == 1 ) fprintf(fortranout,"!!! 333333333333333 \n"); |
---|
| 83 | writesub_loopdeclaration_scalar(List_UsedInSubroutine_Var,paramout); |
---|
| 84 | if ( mark == 1 ) fprintf(fortranout,"!!! 444444444444444 \n"); |
---|
| 85 | /* now we should write the function declaration */ |
---|
| 86 | /* case if it is the */ |
---|
| 87 | WriteFunctionDeclaration(1); |
---|
| 88 | if ( mark == 1 ) fprintf(fortranout,"!!! 555555555555555 \n"); |
---|
| 89 | |
---|
| 90 | // if ( SubInList_ContainsSubroutine() == 0 ) WriteSubroutineDeclaration(1); |
---|
| 91 | |
---|
| 92 | if ( mark == 1 ) fprintf(fortranout,"!!! 666666666666666 \n"); |
---|
| 93 | if ( todebug == 1 ) printf("Out of writeheadnewsub_0\n"); |
---|
| 94 | } |
---|
| 95 | else if ( firstpass == 0 ) |
---|
| 96 | { |
---|
| 97 | AddUseAgrifUtil_0(fortranout); |
---|
[2715] | 98 | WriteUsemoduleDeclaration(subroutinename); |
---|
[1901] | 99 | WriteIncludeDeclaration(); |
---|
| 100 | if ( ImplicitNoneInSubroutine() == 1 ) fprintf(fortranout, |
---|
| 101 | " IMPLICIT NONE\n"); |
---|
| 102 | if ( mark == 1 ) fprintf(fortranout,"!!! aaaaaaaaaaaaaaa \n"); |
---|
| 103 | WriteLocalParamDeclaration(); |
---|
[4147] | 104 | if ( mark == 1 ) fprintf(fortranout,"!!! bbbbbbbbbbbbbbb \n"); |
---|
| 105 | WriteArgumentDeclaration_beforecall(); |
---|
| 106 | if ( mark == 1 ) fprintf(fortranout,"!!! bbbbbbccccccccc \n"); |
---|
[1901] | 107 | if ( functiondeclarationisdone == 0 ) WriteFunctionDeclaration(1); |
---|
| 108 | /* writesub_loopdeclaration_scalar(List_SubroutineArgument_Var,fortranout); |
---|
| 109 | writesub_loopdeclaration_tab(List_SubroutineArgument_Var,fortranout);*/ |
---|
| 110 | if ( mark == 1 ) fprintf(fortranout,"!!! ccccccccccccccc \n"); |
---|
| 111 | if ( mark == 1 ) fprintf(fortranout,"!!! ddddddddddddddd \n"); |
---|
| 112 | // WriteSubroutineDeclaration(1); |
---|
| 113 | if ( mark == 1 ) fprintf(fortranout,"!!! eeeeeeeeeeeeeee \n"); |
---|
| 114 | } |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | |
---|
| 118 | /******************************************************************************/ |
---|
| 119 | /* WriteVariablelist_subloop */ |
---|
| 120 | /******************************************************************************/ |
---|
| 121 | /* This subroutine is used to write the list of the variable which */ |
---|
| 122 | /* should be called by the sub_loop_<name> subroutine */ |
---|
| 123 | /* The first part is composed by the list of the local variables */ |
---|
| 124 | /******************************************************************************/ |
---|
| 125 | /* */ |
---|
| 126 | /* List_SubroutineDeclaration_Var a,b,c, & */ |
---|
| 127 | /* d,e,f, & */ |
---|
| 128 | /* a,b,c,d,e,f,g,h ========> g,h */ |
---|
| 129 | /* */ |
---|
| 130 | /******************************************************************************/ |
---|
[2715] | 131 | void WriteVariablelist_subloop(FILE *outputfile,char *ligne) |
---|
[1901] | 132 | { |
---|
| 133 | listvar *parcours; |
---|
| 134 | int compteur; |
---|
| 135 | |
---|
| 136 | if ( todebug == 1 ) printf("Enter in WriteVariablelist_subloop\n"); |
---|
| 137 | parcours = List_SubroutineArgument_Var; |
---|
| 138 | didvariableadded = 0; |
---|
| 139 | compteur = 0 ; |
---|
| 140 | |
---|
| 141 | while ( parcours ) |
---|
| 142 | { |
---|
| 143 | |
---|
| 144 | /* if the readed variable is a variable of the subroutine */ |
---|
| 145 | /* subroutinename we should write the name of this variable */ |
---|
| 146 | /* in the output file */ |
---|
| 147 | if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) ) |
---|
| 148 | { |
---|
[2715] | 149 | if ( didvariableadded == 1 ) |
---|
[1901] | 150 | { |
---|
| 151 | strcat(ligne,","); |
---|
| 152 | } |
---|
| 153 | strcat(ligne,parcours->var->v_nomvar); |
---|
| 154 | didvariableadded = 1; |
---|
| 155 | } |
---|
| 156 | parcours = parcours -> suiv; |
---|
| 157 | } |
---|
| 158 | parcours = List_FunctionType_Var; |
---|
| 159 | while ( parcours ) |
---|
| 160 | { |
---|
| 161 | if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) ) |
---|
| 162 | { |
---|
[2715] | 163 | if ( didvariableadded == 1 ) |
---|
[1901] | 164 | { |
---|
| 165 | strcat(ligne,","); |
---|
| 166 | } |
---|
| 167 | strcat(ligne,parcours->var->v_nomvar); |
---|
| 168 | didvariableadded = 1; |
---|
| 169 | } |
---|
| 170 | parcours = parcours -> suiv; |
---|
| 171 | } |
---|
| 172 | if ( todebug == 1 ) printf("Out of WriteVariablelist_subloop\n"); |
---|
| 173 | } |
---|
| 174 | |
---|
| 175 | |
---|
| 176 | /******************************************************************************/ |
---|
| 177 | /* WriteVariablelist_subloop_Call */ |
---|
| 178 | /******************************************************************************/ |
---|
| 179 | /* This subroutine is used to write the list of the variable which */ |
---|
| 180 | /* should be called by the sub_loop_<name> subroutine into the called */ |
---|
| 181 | /* The second part is composed by the list of the global table */ |
---|
| 182 | /******************************************************************************/ |
---|
| 183 | /* */ |
---|
| 184 | /* List_UsedInSubroutine_Var SubloopScalar = 0 | SubloopScalar = 1 */ |
---|
| 185 | /* a,b,c, & | a,b(1,1),c, & */ |
---|
| 186 | /* a,b,c,d,e,f,g,h =====> d,e,f, & | d(1),e(1,1,1),f, & */ |
---|
| 187 | /* g,h | g,h(1,1) */ |
---|
| 188 | /* */ |
---|
| 189 | /******************************************************************************/ |
---|
[2715] | 190 | void WriteVariablelist_subloop_Call(FILE *outputfile,char *ligne) |
---|
[1901] | 191 | { |
---|
| 192 | listvar *parcours; |
---|
| 193 | char ligne2[10]; |
---|
| 194 | int i; |
---|
| 195 | int compteur ; |
---|
| 196 | |
---|
| 197 | if ( todebug == 1 ) printf("Enter in WriteVariablelist_subloop_Call\n"); |
---|
| 198 | parcours = List_UsedInSubroutine_Var; |
---|
| 199 | compteur = 0 ; |
---|
| 200 | while ( parcours ) |
---|
| 201 | { |
---|
| 202 | /* if the readed variable is a variable of the subroutine */ |
---|
| 203 | /* subroutinename we should write the name of this variable */ |
---|
| 204 | /* in the output file */ |
---|
| 205 | if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) && |
---|
[2715] | 206 | (parcours->var->v_pointerdeclare == 0 || !strcasecmp(parcours->var->v_typevar,"type")) |
---|
[1901] | 207 | ) |
---|
| 208 | { |
---|
[2715] | 209 | if ( didvariableadded == 1 ) |
---|
[1901] | 210 | { |
---|
| 211 | strcat(ligne," , "); |
---|
| 212 | } |
---|
| 213 | strcat(ligne,vargridcurgridtabvars(parcours->var,0)); |
---|
| 214 | /* if it is asked in the call of the conv we should give */ |
---|
| 215 | /* scalar in argument, so we should put (1,1,1) after the */ |
---|
| 216 | /* the name of the variable */ |
---|
| 217 | if ( SubloopScalar != 0 && |
---|
[2715] | 218 | ( |
---|
| 219 | (parcours->var->v_pointerdeclare == 0 || !strcasecmp(parcours->var->v_typevar,"type"))) && |
---|
[1901] | 220 | parcours->var->v_nbdim != 0 ) |
---|
| 221 | { |
---|
| 222 | i = 1; |
---|
| 223 | while ( i <= parcours->var->v_nbdim ) |
---|
| 224 | { |
---|
| 225 | if ( i == 1 ) strcat(ligne,"( "); |
---|
| 226 | if ( SubloopScalar == 2 ) |
---|
| 227 | { |
---|
| 228 | strcat(ligne,":"); |
---|
| 229 | if ( i != parcours->var->v_nbdim ) strcat(ligne,","); |
---|
| 230 | } |
---|
| 231 | else |
---|
| 232 | { |
---|
| 233 | strcat(ligne," lbound( "); |
---|
| 234 | strcat(ligne,vargridcurgridtabvars(parcours->var,0)); |
---|
| 235 | strcat(ligne,","); |
---|
| 236 | strcpy(ligne2,""); |
---|
| 237 | sprintf(ligne2,"%d",i); |
---|
| 238 | strcat(ligne,ligne2); |
---|
| 239 | if ( i != parcours->var->v_nbdim ) strcat(ligne,"),"); |
---|
| 240 | } |
---|
| 241 | if ( i == parcours->var->v_nbdim ) strcat(ligne,"))"); |
---|
| 242 | i++; |
---|
| 243 | } |
---|
| 244 | } |
---|
| 245 | didvariableadded = 1; |
---|
| 246 | compteur = compteur +1 ; |
---|
| 247 | /*if ( retour77 == 0 ) |
---|
| 248 | { |
---|
| 249 | strcat(ligne," &"); |
---|
| 250 | fprintf(outputfile,"\n"); |
---|
| 251 | } |
---|
| 252 | else fprintf(outputfile,"\n & ");*/ |
---|
| 253 | /*tofich(outputfile,ligne,0);*/ |
---|
| 254 | } |
---|
| 255 | parcours = parcours -> suiv; |
---|
| 256 | } |
---|
| 257 | |
---|
[2715] | 258 | // Save_Length(ligne,41); |
---|
| 259 | // tofich(outputfile,ligne,0); |
---|
[1901] | 260 | /* Now we should replace the last ", &" by " &" */ |
---|
| 261 | /* if ( didvariableadded != 0 && retour77 == 0 ) fseek(outputfile,-1,SEEK_CUR); |
---|
| 262 | if ( didvariableadded == 0 ) fseek(outputfile,-1,SEEK_CUR);*/ |
---|
| 263 | if ( todebug == 1 ) printf("Out of WriteVariablelist_subloop_Call\n"); |
---|
| 264 | } |
---|
| 265 | |
---|
| 266 | |
---|
| 267 | /******************************************************************************/ |
---|
| 268 | /* WriteVariablelist_subloop_Def */ |
---|
| 269 | /******************************************************************************/ |
---|
| 270 | /* This subroutine is used to write the list of the variable which */ |
---|
| 271 | /* should be called by the sub_loop_<name> subroutine into the def */ |
---|
| 272 | /* The second part is composed by the list of the global table */ |
---|
| 273 | /* <name>_tmp */ |
---|
| 274 | /******************************************************************************/ |
---|
| 275 | /* */ |
---|
| 276 | /* List_UsedInSubroutine_Var */ |
---|
| 277 | /* a-tmp,b-tmp,c_tmp, & */ |
---|
| 278 | /* a,b,c,d,e,f,g,h =====> d_tmp,e_tmp,f_tmp, & */ |
---|
| 279 | /* g_tmp,h_tmp */ |
---|
| 280 | /* */ |
---|
| 281 | /******************************************************************************/ |
---|
[2715] | 282 | void WriteVariablelist_subloop_Def(FILE *outputfile, char *ligne) |
---|
[1901] | 283 | { |
---|
| 284 | listvar *parcours; |
---|
| 285 | /* char ligne[LONG_40M];*/ |
---|
| 286 | int compteur; |
---|
| 287 | |
---|
| 288 | if ( todebug == 1 ) printf("Enter in WriteVariablelist_subloop_Def\n"); |
---|
| 289 | parcours = List_UsedInSubroutine_Var; |
---|
| 290 | compteur = 0 ; |
---|
| 291 | while ( parcours ) |
---|
| 292 | { |
---|
| 293 | /* if the readed variable is a variable of the subroutine */ |
---|
| 294 | /* subrotinename we should write the name of this variable */ |
---|
| 295 | /* in the output file */ |
---|
| 296 | if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) && |
---|
[2715] | 297 | (parcours->var->v_pointerdeclare == 0 || !strcasecmp(parcours->var->v_typevar,"type")) |
---|
[1901] | 298 | ) |
---|
| 299 | { |
---|
[2715] | 300 | if ( didvariableadded == 1 ) |
---|
[1901] | 301 | { |
---|
| 302 | strcat(ligne,","); |
---|
| 303 | } |
---|
| 304 | strcat(ligne,parcours->var->v_nomvar); |
---|
| 305 | didvariableadded = 1; |
---|
| 306 | } |
---|
| 307 | parcours = parcours -> suiv; |
---|
| 308 | } |
---|
| 309 | /* if ( compteur != 3 && compteur != 0 ) |
---|
| 310 | { |
---|
| 311 | if ( retour77 == 0 ) fprintf(outputfile,"\n %s &",ligne); |
---|
| 312 | else fprintf(outputfile,"\n & %s",ligne); |
---|
| 313 | }*/ |
---|
| 314 | Save_Length(ligne,41); |
---|
[2715] | 315 | // tofich(outputfile,ligne,0); |
---|
[1901] | 316 | |
---|
| 317 | /* Now we should replace the last ", &" by " &" */ |
---|
| 318 | /* if ( didvariableadded != 0 && retour77 == 0 ) fseek(outputfile,-1,SEEK_CUR); |
---|
| 319 | if ( didvariableadded == 0 ) fseek(outputfile,-1,SEEK_CUR);*/ |
---|
| 320 | if ( todebug == 1 ) printf("Out of WriteVariablelist_subloop_Def\n"); |
---|
| 321 | |
---|
| 322 | } |
---|
| 323 | |
---|
| 324 | |
---|
| 325 | |
---|
| 326 | /******************************************************************************/ |
---|
| 327 | /* WriteHeadofSubroutineLoop */ |
---|
| 328 | /******************************************************************************/ |
---|
| 329 | /* This subroutine is used to write the head of the subroutine */ |
---|
| 330 | /* Sub_Loop_<name> */ |
---|
| 331 | /******************************************************************************/ |
---|
| 332 | /* Sub_loop_subroutine.h */ |
---|
| 333 | /* */ |
---|
| 334 | /* subroutine Sub_Loop_subroutine ( & */ |
---|
| 335 | /* a,b,c, & */ |
---|
| 336 | /* SubLoopScalar d,e(1,1),f(1,1,1), & */ |
---|
| 337 | /* g,h & */ |
---|
| 338 | /* ) */ |
---|
| 339 | /******************************************************************************/ |
---|
| 340 | void WriteHeadofSubroutineLoop() |
---|
| 341 | { |
---|
[2715] | 342 | char ligne[LONG_40M]; |
---|
[1901] | 343 | FILE * subloop; |
---|
| 344 | |
---|
| 345 | if ( todebug == 1 ) printf("Enter in WriteHeadofSubroutineLoop\n"); |
---|
| 346 | tofich(fortranout,"\n",1); |
---|
| 347 | /* Open this newfile */ |
---|
| 348 | sprintf(ligne,"Sub_Loop_%s.h",subroutinename); |
---|
| 349 | subloop = associate(ligne); |
---|
| 350 | /* */ |
---|
[2715] | 351 | if (isrecursive) |
---|
| 352 | { |
---|
| 353 | sprintf(ligne," recursive subroutine Sub_Loop_%s(",subroutinename); |
---|
| 354 | } |
---|
| 355 | else |
---|
| 356 | { |
---|
| 357 | sprintf(ligne," subroutine Sub_Loop_%s(",subroutinename); |
---|
| 358 | } |
---|
[1901] | 359 | /* */ |
---|
[2715] | 360 | WriteVariablelist_subloop(subloop,ligne); |
---|
| 361 | WriteVariablelist_subloop_Def(subloop,ligne); |
---|
[1901] | 362 | /* */ |
---|
[2715] | 363 | strcat(ligne,")"); |
---|
| 364 | tofich(subloop,ligne,1); |
---|
[1901] | 365 | /* if USE agrif_Uti l should be add */ |
---|
| 366 | AddUseAgrifUtil_0(subloop); |
---|
| 367 | /* */ |
---|
| 368 | oldfortranout = fortranout; |
---|
| 369 | fortranout = subloop; |
---|
| 370 | if ( todebug == 1 ) printf("Out of WriteHeadofSubroutineLoop\n"); |
---|
| 371 | } |
---|
| 372 | |
---|
| 373 | /******************************************************************************/ |
---|
| 374 | /* closeandcallsubloopandincludeit_0 */ |
---|
| 375 | /******************************************************************************/ |
---|
| 376 | /* Firstpass 0 */ |
---|
| 377 | /* We should close the sub_loop subroutine, call it and close the */ |
---|
| 378 | /* function (suborfun = 0) */ |
---|
| 379 | /* subroutine (suborfun = 1) */ |
---|
| 380 | /* end (suborfun = 2) */ |
---|
| 381 | /* end program (suborfun = 3) */ |
---|
| 382 | /* and include the sub_loop subroutine after */ |
---|
| 383 | /******************************************************************************/ |
---|
| 384 | /* */ |
---|
| 385 | /******************************************************************************/ |
---|
| 386 | void closeandcallsubloopandincludeit_0(int suborfun) |
---|
| 387 | { |
---|
[2715] | 388 | char ligne[LONG_40M]; |
---|
[1901] | 389 | |
---|
| 390 | if ( firstpass == 0 ) |
---|
| 391 | { |
---|
[2715] | 392 | |
---|
[1901] | 393 | if ( todebug == 1 ) printf("Enter in closeandcallsubloopandincludeit_0\n"); |
---|
| 394 | if ( IsTabvarsUseInArgument_0() == 1 ) |
---|
| 395 | { |
---|
| 396 | /* We should remove the key word end subroutine */ |
---|
| 397 | RemoveWordCUR_0(fortranout,(long)(-(pos_cur-pos_endsubroutine)), |
---|
| 398 | pos_cur-pos_endsubroutine); |
---|
| 399 | /* We should close the loop subroutine */ |
---|
| 400 | sprintf(ligne,"\n end subroutine Sub_Loop_%s",subroutinename); |
---|
| 401 | tofich(fortranout,ligne,1); |
---|
| 402 | fclose(fortranout); |
---|
| 403 | fortranout = oldfortranout; |
---|
| 404 | |
---|
| 405 | |
---|
| 406 | AddUseAgrifUtilBeforeCall_0(fortranout); |
---|
[4147] | 407 | WriteArgumentDeclaration_beforecall(); |
---|
[1901] | 408 | if ( functiondeclarationisdone == 0 ) WriteFunctionDeclaration(0); |
---|
| 409 | if ( !strcasecmp(subofagrifinitgrids,subroutinename) ) |
---|
| 410 | fprintf(oldfortranout," Call Agrif_Init_Grids () \n"); |
---|
| 411 | /* Now we add the call af the new subroutine */ |
---|
[2715] | 412 | sprintf(ligne,"\n Call Sub_Loop_%s( ",subroutinename); |
---|
[1901] | 413 | /* Write the list of the local variables used in this new subroutine */ |
---|
[2715] | 414 | WriteVariablelist_subloop(fortranout,ligne); |
---|
[1901] | 415 | /* Write the list of the global tables used in this new subroutine */ |
---|
| 416 | /* in doloop */ |
---|
[2715] | 417 | WriteVariablelist_subloop_Call(fortranout,ligne); |
---|
[1901] | 418 | /* Close the parenthesis of the new subroutine called */ |
---|
[2715] | 419 | strcat(ligne,")"); |
---|
| 420 | |
---|
| 421 | tofich(fortranout,ligne,1); |
---|
| 422 | |
---|
[1901] | 423 | /* We should close the original subroutine */ |
---|
| 424 | if ( suborfun == 3 ) sprintf(ligne,"\n end program %s" |
---|
| 425 | ,subroutinename); |
---|
| 426 | if ( suborfun == 2 ) sprintf(ligne,"\n end"); |
---|
| 427 | if ( suborfun == 1 ) sprintf(ligne,"\n end subroutine %s" |
---|
| 428 | ,subroutinename); |
---|
| 429 | if ( suborfun == 0 ) sprintf(ligne,"\n end function %s" |
---|
| 430 | ,subroutinename); |
---|
| 431 | tofich(fortranout,ligne,1); |
---|
| 432 | /* we should include the above file in the original code */ |
---|
| 433 | sprintf(ligne,"\n#include \"Sub_Loop_%s.h\" \n",subroutinename); |
---|
| 434 | tofich(fortranout,ligne,1); |
---|
| 435 | } |
---|
| 436 | oldfortranout = (FILE *)NULL; |
---|
| 437 | if ( todebug == 1 ) printf("Out of closeandcallsubloopandincludeit_0\n"); |
---|
| 438 | } |
---|
| 439 | |
---|
| 440 | } |
---|
| 441 | |
---|
| 442 | |
---|
| 443 | |
---|
| 444 | |
---|
| 445 | void closeandcallsubloop_contains_0() |
---|
| 446 | { |
---|
[2715] | 447 | char ligne[LONG_40M]; |
---|
[1901] | 448 | |
---|
| 449 | if ( firstpass == 0 ) |
---|
| 450 | { |
---|
| 451 | if ( todebug == 1 ) printf("Enter in closeandcallsubloopandincludeit_0\n"); |
---|
| 452 | if ( IsTabvarsUseInArgument_0() == 1 ) |
---|
| 453 | { |
---|
| 454 | Remove_Word_Contains_0(); |
---|
| 455 | sprintf(ligne,"\n end subroutine Sub_Loop_%s",subroutinename); |
---|
| 456 | tofich(fortranout,ligne,1); |
---|
| 457 | fclose(fortranout); |
---|
| 458 | fortranout = oldfortranout; |
---|
| 459 | |
---|
| 460 | AddUseAgrifUtilBeforeCall_0(fortranout); |
---|
| 461 | if ( ImplicitNoneInSubroutine() == 1 ) fprintf(fortranout, |
---|
| 462 | " IMPLICIT NONE\n"); |
---|
| 463 | WriteLocalParamDeclaration(); |
---|
[4147] | 464 | WriteArgumentDeclaration_beforecall(); |
---|
[1901] | 465 | if ( functiondeclarationisdone == 0 ) WriteFunctionDeclaration(0); |
---|
| 466 | WriteSubroutineDeclaration(0); |
---|
| 467 | if ( !strcasecmp(subofagrifinitgrids,subroutinename) ) |
---|
| 468 | fprintf(oldfortranout," Call Agrif_Init_Grids () \n"); |
---|
| 469 | /* Now we add the call af the new subroutine */ |
---|
| 470 | if ( retour77 == 0 ) sprintf(ligne,"\n Call Sub_Loop_%s( &" |
---|
| 471 | ,subroutinename); |
---|
| 472 | else sprintf(ligne,"\n Call Sub_Loop_%s( ",subroutinename); |
---|
| 473 | fprintf(fortranout,ligne); |
---|
| 474 | /* Write the list of the local variables used in this new subroutine */ |
---|
[2715] | 475 | WriteVariablelist_subloop(fortranout,ligne); |
---|
[1901] | 476 | /* Write the list of the global tables used in this new subroutine */ |
---|
| 477 | /* in doloop */ |
---|
[2715] | 478 | WriteVariablelist_subloop_Call(fortranout,ligne); |
---|
[1901] | 479 | /* Close the parenthesis of the new subroutine called */ |
---|
| 480 | sprintf(ligne,")"); |
---|
| 481 | tofich(fortranout,ligne,1); |
---|
| 482 | /* We should close the original subroutine */ |
---|
| 483 | sprintf(ligne,"\n contains"); |
---|
| 484 | tofich(fortranout,ligne,1); |
---|
| 485 | /* we should include the above file in the original code */ |
---|
| 486 | sprintf(ligne,"\n#include \"Sub_Loop_%s.h\" \n",subroutinename); |
---|
| 487 | tofich(fortranout,ligne,1); |
---|
| 488 | } |
---|
| 489 | oldfortranout = (FILE *)NULL; |
---|
| 490 | if ( todebug == 1 ) printf("Out of closeandcallsubloopandincludeit_0\n"); |
---|
| 491 | } |
---|
| 492 | } |
---|