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 1200 for trunk/AGRIF/LIB/UtilAgrif.c – NEMO

Ignore:
Timestamp:
2008-09-24T15:05:20+02:00 (16 years ago)
Author:
rblod
Message:

Adapt Agrif to the new SBC and correct several bugs for agrif (restart writing and reading), see ticket #133
Note : this fix does not work yet on NEC computerq (sxf90/360)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/AGRIF/LIB/UtilAgrif.c

    r774 r1200  
    103103/*                                                                            */ 
    104104/******************************************************************************/ 
    105 void ModifyTheVariableName_0(char *ident) 
     105void ModifyTheVariableName_0(char *ident, int lengthname) 
    106106{ 
    107107   listvar *newvar; 
    108108   int out; 
    109  
     109    
    110110   if ( firstpass == 0 ) 
    111111   { 
     
    150150      { 
    151151         /* remove the variable                                               */ 
    152          RemoveWordCUR_0(fortranout,(long)(-strlen(ident)), 
    153                                strlen(ident)); 
    154          fseek(fortranout,(long)(-strlen(ident)),SEEK_CUR); 
     152         RemoveWordCUR_0(fortranout,(long)(-lengthname), 
     153                               lengthname); 
     154         fseek(fortranout,(long)(-lengthname),SEEK_CUR); 
    155155         /* then write the new name                                           */ 
    156156         if ( inagrifcallargument == 1 && agrif_parentcall == 0 ) 
     
    181181            { 
    182182               if ( !strcasecmp(newvar->var->v_nomvar,ident) ) out = 1; 
     183               else newvar=newvar->suiv; 
     184            } 
     185            if ( out == 1 ) 
     186            { 
     187               /* remove the variable                                         */ 
     188               RemoveWordCUR_0(fortranout,(long)(-lengthname), 
     189                                     lengthname); 
     190               fseek(fortranout,(long)(-lengthname),SEEK_CUR); 
     191               /* then write the new name                                     */ 
     192               if ( retour77 == 0 ) 
     193               { 
     194                  fprintf(fortranout," Agrif_tabvars & \n      "); 
     195               } 
     196               else 
     197               { 
     198                  fprintf(fortranout," \n     & Agrif_tabvars"); 
     199               } 
     200               fprintf(fortranout,"%s", 
     201                             vargridcurgridtabvarswithoutAgrif_Gr(newvar->var)); 
     202               colnum = strlen( 
     203                             vargridcurgridtabvarswithoutAgrif_Gr(newvar->var)); 
     204            } 
     205         } 
     206      } 
     207   } 
     208} 
     209 
     210/******************************************************************************/ 
     211/*                     ModifyTheVariableName_0                                */ 
     212/******************************************************************************/ 
     213/* Firstpass 0                                                                */ 
     214/******************************************************************************/ 
     215/*                                                                            */ 
     216/*               Agrif_<toto>(variable) ====>     Agrif_<toto>(variable)      */ 
     217/*                                                                            */ 
     218/******************************************************************************/ 
     219void ModifyTheVariableNamecoupled_0(char *ident, char* coupledident) 
     220{ 
     221   listvar *newvar; 
     222   int out; 
     223    
     224   if ( firstpass == 0 ) 
     225   { 
     226      newvar = List_Global_Var; 
     227      out=0; 
     228      while ( newvar && out == 0 ) 
     229      { 
     230         if ( !strcasecmp(newvar->var->v_nomvar,coupledident) ) out = 1; 
     231         else newvar=newvar->suiv; 
     232      } 
     233 
     234      if ( out == 0 ) 
     235      { 
     236         newvar = List_ModuleUsed_Var; 
     237         while ( newvar && out == 0 ) 
     238         { 
     239            if ( !strcasecmp(newvar->var->v_nomvar,coupledident) ) out = 1; 
     240            else newvar=newvar->suiv; 
     241         } 
     242      } 
     243      if ( out == 0 ) 
     244      { 
     245         newvar = List_Common_Var; 
     246         while ( newvar && out == 0 ) 
     247         { 
     248            if ( !strcasecmp(newvar->var->v_nomvar,coupledident) ) out = 1; 
     249            else newvar=newvar->suiv; 
     250         } 
     251      } 
     252 
     253      if ( out == 0 ) 
     254      { 
     255         newvar = List_ModuleUsedInModuleUsed_Var; 
     256         while ( newvar && out == 0 ) 
     257         { 
     258            if ( !strcasecmp(newvar->var->v_nomvar,coupledident) ) out = 1; 
     259            else newvar=newvar->suiv; 
     260         } 
     261      } 
     262 
     263      if ( out == 1 ) 
     264      { 
     265         /* remove the variable                                               */ 
     266         RemoveWordCUR_0(fortranout,(long)(-strlen(ident)), 
     267                               strlen(ident)); 
     268         fseek(fortranout,(long)(-strlen(ident)),SEEK_CUR); 
     269         /* then write the new name                                           */ 
     270         if ( inagrifcallargument == 1 && agrif_parentcall == 0 ) 
     271            fprintf(fortranout,"%d",newvar->var->v_indicetabvars); 
     272         else 
     273         { 
     274            if ( retour77 == 0 ) 
     275            { 
     276               fprintf(fortranout," Agrif_tabvars & \n      "); 
     277            } 
     278            else 
     279            { 
     280               fprintf(fortranout,"Agrif_tabvars"); 
     281               fprintf(fortranout," \n     & "); 
     282            } 
     283            fprintf(fortranout,"%s", 
     284                             vargridcurgridtabvarswithoutAgrif_Gr(newvar->var)); 
     285            colnum = strlen(vargridcurgridtabvarswithoutAgrif_Gr(newvar->var)); 
     286         } 
     287      } 
     288      else 
     289      { 
     290         /* we should look in the List_ModuleUsed_Var                         */ 
     291         if ( inagrifcallargument != 1 ) 
     292         { 
     293            newvar = List_ModuleUsed_Var; 
     294            while ( newvar && out == 0 ) 
     295            { 
     296               if ( !strcasecmp(newvar->var->v_nomvar,coupledident) ) out = 1; 
    183297               else newvar=newvar->suiv; 
    184298            } 
     
    207321   } 
    208322} 
     323 
    209324 
    210325 
     
    581696{ 
    582697   char toprint[LONG_C]; 
    583  
    584698   if ( firstpass == 0 ) 
    585699   { 
Note: See TracChangeset for help on using the changeset viewer.