New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 2671 for vendors/AGRIF/current/LIB/SubLoopCreation.c – NEMO

Ignore:
Timestamp:
2011-03-08T15:08:49+01:00 (13 years ago)
Author:
rblod
Message:

Load working_directory into vendors/AGRIF/current.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendors/AGRIF/current/LIB/SubLoopCreation.c

    r1901 r2671  
    6161      /* we should add the use agrif_uti l if it is necessary                 */ 
    6262      WriteHeadofSubroutineLoop(); 
    63       WriteUsemoduleDeclaration(); 
     63      WriteUsemoduleDeclaration(subroutinename); 
    6464      if ( ImplicitNoneInSubroutine() == 1 ) fprintf(fortranout, 
    6565                                                       "      IMPLICIT NONE\n"); 
     
    6969      /*    from pointer) in the new subroutine                               */ 
    7070      if ( mark == 1 ) fprintf(fortranout,"!!! 000000000000000 \n"); 
     71 
    7172      if ( SubInList_ContainsSubroutine() == 0 ) WriteLocalParamDeclaration(); 
    7273      if ( mark == 1 ) fprintf(fortranout,"!!! 111111111111111 \n"); 
     
    9596   { 
    9697      AddUseAgrifUtil_0(fortranout); 
    97       WriteUsemoduleDeclaration(); 
     98      WriteUsemoduleDeclaration(subroutinename); 
    9899      WriteIncludeDeclaration(); 
    99100      if ( ImplicitNoneInSubroutine() == 1 ) fprintf(fortranout, 
     
    103104      if ( mark == 1 ) fprintf(fortranout,"!!! bbbbbbbbbbbbbbb \n"); 
    104105      if ( functiondeclarationisdone == 0 ) WriteFunctionDeclaration(1); 
     106      if ( mark == 1 ) fprintf(fortranout,"!!! bbbbbbccccccccc \n");       
    105107      WriteArgumentDeclaration_beforecall(); 
    106108/*      writesub_loopdeclaration_scalar(List_SubroutineArgument_Var,fortranout); 
     
    127129/*                                                                            */ 
    128130/******************************************************************************/ 
    129 void WriteVariablelist_subloop(FILE *outputfile) 
     131void WriteVariablelist_subloop(FILE *outputfile,char *ligne) 
    130132{ 
    131133   listvar *parcours; 
    132    char ligne[LONG_C]; 
    133134   int compteur; 
    134135 
     
    146147      if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) ) 
    147148      { 
    148          if ( didvariableadded == 0 ) 
    149          { 
    150             strcpy(ligne,""); 
    151          } 
    152          else 
    153          { 
    154             if ( compteur == 0 ) strcpy(ligne,""); 
     149         if ( didvariableadded == 1 ) 
     150         { 
    155151            strcat(ligne,","); 
    156152         } 
    157153         strcat(ligne,parcours->var->v_nomvar); 
    158154         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          } 
    170155      } 
    171156      parcours = parcours -> suiv; 
     
    176161      if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) ) 
    177162      { 
    178          if ( didvariableadded == 0 ) 
    179          { 
    180             strcpy(ligne,""); 
    181          } 
    182          else 
    183          { 
    184             if ( compteur == 0 ) strcpy(ligne,""); 
     163         if ( didvariableadded == 1 ) 
     164         { 
    185165            strcat(ligne,","); 
    186166         } 
    187167         strcat(ligne,parcours->var->v_nomvar); 
    188168         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          } 
    200169      } 
    201170      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); 
    207171   } 
    208172   if ( todebug == 1 ) printf("Out of WriteVariablelist_subloop\n"); 
     
    224188/*                                                                            */ 
    225189/******************************************************************************/ 
    226 void WriteVariablelist_subloop_Call(FILE *outputfile) 
     190void WriteVariablelist_subloop_Call(FILE *outputfile,char *ligne) 
    227191{ 
    228192   listvar *parcours; 
    229    char ligne[LONG_40M]; 
    230193   char ligne2[10]; 
    231194   int i; 
    232195   int compteur ; 
    233196 
    234    strcpy(ligne,""); 
    235     
    236197   if ( todebug == 1 ) printf("Enter in WriteVariablelist_subloop_Call\n"); 
    237198   parcours = List_UsedInSubroutine_Var; 
     
    243204      /*    in the output file                                                */ 
    244205      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")) 
    247207         ) 
    248208      { 
    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         { 
    261211            strcat(ligne," , "); 
    262212         } 
     
    266216         /* the name of the variable                                          */ 
    267217         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"))) && 
    270220               parcours->var->v_nbdim != 0 ) 
    271221         { 
     
    306256   } 
    307257    
    308    Save_Length(ligne,41); 
    309    tofich(outputfile,ligne,0); 
     258//   Save_Length(ligne,41); 
     259//   tofich(outputfile,ligne,0); 
    310260   /* Now we should replace the last ", &" by " &"                            */ 
    311261/*   if ( didvariableadded != 0 && retour77 == 0 ) fseek(outputfile,-1,SEEK_CUR); 
     
    330280/*                                                                            */ 
    331281/******************************************************************************/ 
    332 void WriteVariablelist_subloop_Def(FILE *outputfile) 
     282void WriteVariablelist_subloop_Def(FILE *outputfile, char *ligne) 
    333283{ 
    334284   listvar *parcours; 
    335285/*   char ligne[LONG_40M];*/ 
    336    char *ligne; 
    337286   int compteur; 
    338287 
    339 /*   strcpy(ligne," ");*/ 
    340  
    341    ligne=(char *)malloc(LONG_40M*sizeof(char)); 
    342     
    343288   if ( todebug == 1 ) printf("Enter in WriteVariablelist_subloop_Def\n"); 
    344289   parcours = List_UsedInSubroutine_Var; 
     
    350295      /*    in the output file                                                */ 
    351296      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")) 
    354298         ) 
    355299      { 
    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         { 
    368302            strcat(ligne,","); 
    369303         } 
    370304         strcat(ligne,parcours->var->v_nomvar); 
    371          compteur = compteur + 1; 
    372305         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          }*/ 
    383306      } 
    384307      parcours = parcours -> suiv; 
     
    390313   }*/ 
    391314   Save_Length(ligne,41); 
    392    tofich(outputfile,ligne,0); 
     315 //  tofich(outputfile,ligne,0); 
    393316 
    394317   /* Now we should replace the last ", &" by " &"                            */ 
     
    396319   if ( didvariableadded == 0 ) fseek(outputfile,-1,SEEK_CUR);*/ 
    397320   if ( todebug == 1 ) printf("Out of WriteVariablelist_subloop_Def\n"); 
    398    strcpy(ligne,""); 
    399321    
    400    free(ligne); 
    401322} 
    402323 
     
    419340void WriteHeadofSubroutineLoop() 
    420341{ 
    421    char ligne[LONG_C]; 
     342   char ligne[LONG_40M]; 
    422343   FILE * subloop; 
    423344 
     
    428349   subloop = associate(ligne); 
    429350   /*                                                                         */ 
    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   } 
    434359   /*                                                                         */ 
    435    WriteVariablelist_subloop(subloop); 
    436    WriteVariablelist_subloop_Def(subloop); 
     360   WriteVariablelist_subloop(subloop,ligne); 
     361   WriteVariablelist_subloop_Def(subloop,ligne); 
    437362   /*                                                                         */ 
    438    sprintf(ligne,")"); 
    439    fprintf(subloop,ligne); 
     363     strcat(ligne,")"); 
     364   tofich(subloop,ligne,1); 
    440365   /* if USE agrif_Uti l should be add                                        */ 
    441366   AddUseAgrifUtil_0(subloop); 
     
    461386void closeandcallsubloopandincludeit_0(int suborfun) 
    462387{ 
    463    char ligne[LONG_C]; 
     388   char ligne[LONG_40M]; 
    464389 
    465390   if ( firstpass == 0 ) 
    466391   { 
     392 
    467393   if ( todebug == 1 ) printf("Enter in closeandcallsubloopandincludeit_0\n"); 
    468394   if ( IsTabvarsUseInArgument_0() == 1 ) 
     
    484410                     fprintf(oldfortranout,"      Call Agrif_Init_Grids () \n"); 
    485411      /* 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); 
    490413      /* Write the list of the local variables used in this new subroutine    */ 
    491       WriteVariablelist_subloop(fortranout); 
     414      WriteVariablelist_subloop(fortranout,ligne); 
    492415      /* Write the list of the global tables used in this new subroutine      */ 
    493416      /*    in doloop                                                         */ 
    494       WriteVariablelist_subloop_Call(fortranout); 
     417      WriteVariablelist_subloop_Call(fortranout,ligne); 
    495418      /* 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 
    498423      /* We should close the original subroutine                              */ 
    499424      if ( suborfun == 3 ) sprintf(ligne,"\n      end program %s" 
     
    520445void closeandcallsubloop_contains_0() 
    521446{ 
    522    char ligne[LONG_C]; 
     447   char ligne[LONG_40M]; 
    523448 
    524449   if ( firstpass == 0 ) 
     
    548473      fprintf(fortranout,ligne); 
    549474      /* Write the list of the local variables used in this new subroutine    */ 
    550       WriteVariablelist_subloop(fortranout); 
     475      WriteVariablelist_subloop(fortranout,ligne); 
    551476      /* Write the list of the global tables used in this new subroutine      */ 
    552477      /*    in doloop                                                         */ 
    553       WriteVariablelist_subloop_Call(fortranout); 
     478      WriteVariablelist_subloop_Call(fortranout,ligne); 
    554479      /* Close the parenthesis of the new subroutine called                   */ 
    555480      sprintf(ligne,")"); 
Note: See TracChangeset for help on using the changeset viewer.