Changeset 2671 for vendors/AGRIF/current/LIB/SubLoopCreation.c
- Timestamp:
- 2011-03-08T15:08:49+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendors/AGRIF/current/LIB/SubLoopCreation.c
r1901 r2671 61 61 /* we should add the use agrif_uti l if it is necessary */ 62 62 WriteHeadofSubroutineLoop(); 63 WriteUsemoduleDeclaration( );63 WriteUsemoduleDeclaration(subroutinename); 64 64 if ( ImplicitNoneInSubroutine() == 1 ) fprintf(fortranout, 65 65 " IMPLICIT NONE\n"); … … 69 69 /* from pointer) in the new subroutine */ 70 70 if ( mark == 1 ) fprintf(fortranout,"!!! 000000000000000 \n"); 71 71 72 if ( SubInList_ContainsSubroutine() == 0 ) WriteLocalParamDeclaration(); 72 73 if ( mark == 1 ) fprintf(fortranout,"!!! 111111111111111 \n"); … … 95 96 { 96 97 AddUseAgrifUtil_0(fortranout); 97 WriteUsemoduleDeclaration( );98 WriteUsemoduleDeclaration(subroutinename); 98 99 WriteIncludeDeclaration(); 99 100 if ( ImplicitNoneInSubroutine() == 1 ) fprintf(fortranout, … … 103 104 if ( mark == 1 ) fprintf(fortranout,"!!! bbbbbbbbbbbbbbb \n"); 104 105 if ( functiondeclarationisdone == 0 ) WriteFunctionDeclaration(1); 106 if ( mark == 1 ) fprintf(fortranout,"!!! bbbbbbccccccccc \n"); 105 107 WriteArgumentDeclaration_beforecall(); 106 108 /* writesub_loopdeclaration_scalar(List_SubroutineArgument_Var,fortranout); … … 127 129 /* */ 128 130 /******************************************************************************/ 129 void WriteVariablelist_subloop(FILE *outputfile )131 void WriteVariablelist_subloop(FILE *outputfile,char *ligne) 130 132 { 131 133 listvar *parcours; 132 char ligne[LONG_C];133 134 int compteur; 134 135 … … 146 147 if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) ) 147 148 { 148 if ( didvariableadded == 0 ) 149 { 150 strcpy(ligne,""); 151 } 152 else 153 { 154 if ( compteur == 0 ) strcpy(ligne,""); 149 if ( didvariableadded == 1 ) 150 { 155 151 strcat(ligne,","); 156 152 } 157 153 strcat(ligne,parcours->var->v_nomvar); 158 154 didvariableadded = 1; 159 compteur = compteur + 1;160 if ( compteur == 3 )161 {162 if ( retour77 == 0 )163 {164 strcat(ligne," &");165 fprintf(outputfile,"\n %s",ligne);166 }167 else fprintf(outputfile,"\n & %s",ligne);168 compteur = 0;169 }170 155 } 171 156 parcours = parcours -> suiv; … … 176 161 if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) ) 177 162 { 178 if ( didvariableadded == 0 ) 179 { 180 strcpy(ligne,""); 181 } 182 else 183 { 184 if ( compteur == 0 ) strcpy(ligne,""); 163 if ( didvariableadded == 1 ) 164 { 185 165 strcat(ligne,","); 186 166 } 187 167 strcat(ligne,parcours->var->v_nomvar); 188 168 didvariableadded = 1; 189 compteur = compteur + 1;190 if ( compteur == 3 )191 {192 if ( retour77 == 0 )193 {194 strcat(ligne," &");195 fprintf(outputfile,"\n %s",ligne);196 }197 else fprintf(outputfile,"\n & %s",ligne);198 compteur = 0;199 }200 169 } 201 170 parcours = parcours -> suiv; 202 }203 if ( compteur != 3 && compteur != 0 )204 {205 if ( retour77 == 0 ) fprintf(outputfile,"\n %s &",ligne);206 else fprintf(outputfile,"\n & %s ",ligne);207 171 } 208 172 if ( todebug == 1 ) printf("Out of WriteVariablelist_subloop\n"); … … 224 188 /* */ 225 189 /******************************************************************************/ 226 void WriteVariablelist_subloop_Call(FILE *outputfile )190 void WriteVariablelist_subloop_Call(FILE *outputfile,char *ligne) 227 191 { 228 192 listvar *parcours; 229 char ligne[LONG_40M];230 193 char ligne2[10]; 231 194 int i; 232 195 int compteur ; 233 196 234 strcpy(ligne,"");235 236 197 if ( todebug == 1 ) printf("Enter in WriteVariablelist_subloop_Call\n"); 237 198 parcours = List_UsedInSubroutine_Var; … … 243 204 /* in the output file */ 244 205 if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) && 245 (parcours->var->v_allocatable == 0 || !strcasecmp(parcours->var->v_typevar,"type")) && 246 parcours->var->v_pointerdeclare == 0 206 (parcours->var->v_pointerdeclare == 0 || !strcasecmp(parcours->var->v_typevar,"type")) 247 207 ) 248 208 { 249 if ( didvariableadded == 0 ) 250 { 251 if ( retour77 == 1 ) strcpy(ligne,"\n & "); 252 else strcpy(ligne,"\n "); 253 } 254 else 255 { 256 if ( compteur == 0 ) 257 { 258 if ( retour77 == 1 ) strcpy(ligne,"\n & "); 259 else strcpy(ligne,"\n "); 260 } 209 if ( didvariableadded == 1 ) 210 { 261 211 strcat(ligne," , "); 262 212 } … … 266 216 /* the name of the variable */ 267 217 if ( SubloopScalar != 0 && 268 ( IsVarAllocatable_0(parcours->var->v_nomvar) == 0 &&269 parcours->var->v_pointerdeclare == 0) &&218 ( 219 (parcours->var->v_pointerdeclare == 0 || !strcasecmp(parcours->var->v_typevar,"type"))) && 270 220 parcours->var->v_nbdim != 0 ) 271 221 { … … 306 256 } 307 257 308 Save_Length(ligne,41);309 tofich(outputfile,ligne,0);258 // Save_Length(ligne,41); 259 // tofich(outputfile,ligne,0); 310 260 /* Now we should replace the last ", &" by " &" */ 311 261 /* if ( didvariableadded != 0 && retour77 == 0 ) fseek(outputfile,-1,SEEK_CUR); … … 330 280 /* */ 331 281 /******************************************************************************/ 332 void WriteVariablelist_subloop_Def(FILE *outputfile )282 void WriteVariablelist_subloop_Def(FILE *outputfile, char *ligne) 333 283 { 334 284 listvar *parcours; 335 285 /* char ligne[LONG_40M];*/ 336 char *ligne;337 286 int compteur; 338 287 339 /* strcpy(ligne," ");*/340 341 ligne=(char *)malloc(LONG_40M*sizeof(char));342 343 288 if ( todebug == 1 ) printf("Enter in WriteVariablelist_subloop_Def\n"); 344 289 parcours = List_UsedInSubroutine_Var; … … 350 295 /* in the output file */ 351 296 if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) && 352 (parcours->var->v_allocatable == 0 || !strcasecmp(parcours->var->v_typevar,"type")) && 353 parcours->var->v_pointerdeclare == 0 297 (parcours->var->v_pointerdeclare == 0 || !strcasecmp(parcours->var->v_typevar,"type")) 354 298 ) 355 299 { 356 if ( didvariableadded == 0 ) 357 { 358 if ( retour77 == 1 ) strcpy(ligne,"\n &"); 359 else strcpy(ligne,"\n "); 360 } 361 else 362 { 363 if ( compteur == 0 ) 364 { 365 if ( retour77 == 1 ) strcpy(ligne,"\n & "); 366 else strcpy(ligne,"\n "); 367 } 300 if ( didvariableadded == 1 ) 301 { 368 302 strcat(ligne,","); 369 303 } 370 304 strcat(ligne,parcours->var->v_nomvar); 371 compteur = compteur + 1;372 305 didvariableadded = 1; 373 /* if ( compteur == 3 )374 {375 if ( retour77 == 0 )376 {377 strcat(ligne," &");378 fprintf(outputfile,"\n %s",ligne);379 }380 else fprintf(outputfile,"\n & %s",ligne);381 compteur = 0;382 }*/383 306 } 384 307 parcours = parcours -> suiv; … … 390 313 }*/ 391 314 Save_Length(ligne,41); 392 tofich(outputfile,ligne,0);315 // tofich(outputfile,ligne,0); 393 316 394 317 /* Now we should replace the last ", &" by " &" */ … … 396 319 if ( didvariableadded == 0 ) fseek(outputfile,-1,SEEK_CUR);*/ 397 320 if ( todebug == 1 ) printf("Out of WriteVariablelist_subloop_Def\n"); 398 strcpy(ligne,"");399 321 400 free(ligne);401 322 } 402 323 … … 419 340 void WriteHeadofSubroutineLoop() 420 341 { 421 char ligne[LONG_ C];342 char ligne[LONG_40M]; 422 343 FILE * subloop; 423 344 … … 428 349 subloop = associate(ligne); 429 350 /* */ 430 if ( retour77 == 0 ) sprintf(ligne," subroutine Sub_Loop_%s( &" 431 ,subroutinename); 432 else sprintf(ligne," subroutine Sub_Loop_%s( ",subroutinename); 433 fprintf(subloop,ligne); 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 } 434 359 /* */ 435 WriteVariablelist_subloop(subloop );436 WriteVariablelist_subloop_Def(subloop );360 WriteVariablelist_subloop(subloop,ligne); 361 WriteVariablelist_subloop_Def(subloop,ligne); 437 362 /* */ 438 sprintf(ligne,")");439 fprintf(subloop,ligne);363 strcat(ligne,")"); 364 tofich(subloop,ligne,1); 440 365 /* if USE agrif_Uti l should be add */ 441 366 AddUseAgrifUtil_0(subloop); … … 461 386 void closeandcallsubloopandincludeit_0(int suborfun) 462 387 { 463 char ligne[LONG_ C];388 char ligne[LONG_40M]; 464 389 465 390 if ( firstpass == 0 ) 466 391 { 392 467 393 if ( todebug == 1 ) printf("Enter in closeandcallsubloopandincludeit_0\n"); 468 394 if ( IsTabvarsUseInArgument_0() == 1 ) … … 484 410 fprintf(oldfortranout," Call Agrif_Init_Grids () \n"); 485 411 /* Now we add the call af the new subroutine */ 486 if ( retour77 == 0 ) sprintf(ligne,"\n Call Sub_Loop_%s( &" 487 ,subroutinename); 488 else sprintf(ligne,"\n Call Sub_Loop_%s( ",subroutinename); 489 fprintf(fortranout,ligne); 412 sprintf(ligne,"\n Call Sub_Loop_%s( ",subroutinename); 490 413 /* Write the list of the local variables used in this new subroutine */ 491 WriteVariablelist_subloop(fortranout );414 WriteVariablelist_subloop(fortranout,ligne); 492 415 /* Write the list of the global tables used in this new subroutine */ 493 416 /* in doloop */ 494 WriteVariablelist_subloop_Call(fortranout );417 WriteVariablelist_subloop_Call(fortranout,ligne); 495 418 /* Close the parenthesis of the new subroutine called */ 496 sprintf(ligne,")"); 497 fprintf(fortranout,ligne); 419 strcat(ligne,")"); 420 421 tofich(fortranout,ligne,1); 422 498 423 /* We should close the original subroutine */ 499 424 if ( suborfun == 3 ) sprintf(ligne,"\n end program %s" … … 520 445 void closeandcallsubloop_contains_0() 521 446 { 522 char ligne[LONG_ C];447 char ligne[LONG_40M]; 523 448 524 449 if ( firstpass == 0 ) … … 548 473 fprintf(fortranout,ligne); 549 474 /* Write the list of the local variables used in this new subroutine */ 550 WriteVariablelist_subloop(fortranout );475 WriteVariablelist_subloop(fortranout,ligne); 551 476 /* Write the list of the global tables used in this new subroutine */ 552 477 /* in doloop */ 553 WriteVariablelist_subloop_Call(fortranout );478 WriteVariablelist_subloop_Call(fortranout,ligne); 554 479 /* Close the parenthesis of the new subroutine called */ 555 480 sprintf(ligne,")");
Note: See TracChangeset
for help on using the changeset viewer.