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/UtilFortran.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/UtilFortran.c

    r774 r1200  
    167167/* This subroutine is to know if a variable is global                         */ 
    168168/******************************************************************************/ 
    169 void variableisglobalinmodule(listcouple *listin, char *module, FILE *fileout) 
     169void variableisglobalinmodule(listcouple *listin, char *module, FILE *fileout, long int oldposcuruse) 
    170170{ 
    171171  int Globalite; 
     
    175175  listvar *newvar2; 
    176176  int out; 
     177  char truename[LONG_C];   
    177178 
    178179  Globalite = 1; 
     
    181182  tempo = Readthedependfile(module,tempo); 
    182183  newvar = listin; 
     184 
    183185  while ( newvar ) 
    184186  { 
     187     if (!strcmp(newvar->c_namepointedvar,"")) { 
     188       strcpy(truename,newvar->c_namevar); 
     189     } 
     190     else 
     191     { 
     192       strcpy(truename,newvar->c_namepointedvar); 
     193     } 
     194      
    185195     out = 0; 
    186196     newvar2 = tempo; 
    187197     while ( newvar2 && out == 0 ) 
    188198     { 
    189         if ( !strcasecmp(newvar2->var->v_nomvar,newvar->c_namevar) ) out = 1; 
     199        if ( !strcasecmp(newvar2->var->v_nomvar,truename) ) out = 1; 
    190200        else newvar2 = newvar2 ->suiv; 
    191201     } 
     
    213223  if ( Globalite == 0 || !newvar) 
    214224  { 
    215      pos_end = setposcur(); 
    216      RemoveWordSET_0(fileout,pos_curuse, 
    217                                 pos_end-pos_curuse); 
     225     pos_end = setposcurname(fileout); 
     226     RemoveWordSET_0(fileout,oldposcuruse, 
     227                                pos_end-oldposcuruse); 
     228                                   
    218229     newvar = listin; 
    219230     while ( newvar ) 
     
    234245} 
    235246 
    236 void Remove_Word_end_module_0() 
    237 { 
    238    if ( firstpass == 0 ) 
    239    { 
    240       RemoveWordCUR_0(fortranout,(long)(-strlen(curmodulename)-12), 
    241                                          strlen(curmodulename)+11); 
     247void Remove_Word_end_module_0(int modulenamelength) 
     248{ 
     249   if ( firstpass == 0 ) 
     250   { 
     251      RemoveWordCUR_0(fortranout,(long)(-modulenamelength-12), 
     252                                         modulenamelength+11); 
    242253   } 
    243254} 
     
    470481         if ( !strcasecmp(parcours->var->v_modulename,curmodulename) ) 
    471482         { 
    472             writevardeclaration(parcours,module_declar,0); 
     483            writevardeclaration(parcours,module_declar,0,1); 
    473484         } 
    474485         parcours = parcours -> suiv; 
    475486      } 
     487   } 
     488} 
     489 
     490void Write_GlobalType_Declaration_0() 
     491{ 
     492   listvar *parcours; 
     493   int out = 0; 
     494   int headtypewritten = 0; 
     495   char ligne[LONGNOM]; 
     496   int changeval; 
     497 
     498   if ( firstpass == 0 ) 
     499   { 
     500      parcours = List_Global_Var; 
     501      while( parcours ) 
     502      { 
     503         if ( !strcasecmp(parcours->var->v_modulename,curmodulename) ) 
     504         { 
     505           if (!strcasecmp(parcours->var->v_typevar,"type")) 
     506           { 
     507            out = 1; 
     508            if (headtypewritten == 0) 
     509              { 
     510                sprintf(ligne,"TYPE :: Agrif_%s",curmodulename); 
     511                tofich(module_declar,ligne,1); 
     512                headtypewritten = 1; 
     513              } 
     514            changeval = 0; 
     515            if (parcours->var->v_allocatable == 1) 
     516             { 
     517               changeval = 1; 
     518               parcours->var->v_allocatable = 0; 
     519               parcours->var->v_pointerdeclare = 1; 
     520             } 
     521            writevardeclaration(parcours,module_declar,0,0); 
     522            if (changeval == 1) 
     523              { 
     524               parcours->var->v_allocatable = 1; 
     525               parcours->var->v_pointerdeclare = 0; 
     526              } 
     527            } 
     528         } 
     529         parcours = parcours -> suiv; 
     530      } 
     531      if (out == 1) 
     532        { 
     533                sprintf(ligne,"END TYPE Agrif_%s",curmodulename); 
     534                tofich(module_declar,ligne,1); 
     535                sprintf(ligne,"TYPE(Agrif_%s), DIMENSION(:), ALLOCATABLE :: Agrif_%s_var",curmodulename,curmodulename);  
     536                tofich(module_declar,ligne,1); 
     537        } 
    476538   } 
    477539} 
     
    488550         if ( !strcasecmp(parcours->var->v_modulename,curmodulename) ) 
    489551         { 
    490             writevardeclaration(parcours,fortranout,0); 
     552            writevardeclaration(parcours,fortranout,0,1); 
    491553         } 
    492554         parcours = parcours -> suiv; 
     
    648710} 
    649711 
     712/******************************************************************************/ 
     713/*                          varistyped_0                                    */ 
     714/******************************************************************************/ 
     715/* Firstpass 0                                                                */ 
     716/******************************************************************************/ 
     717/*                                                                            */ 
     718/******************************************************************************/ 
     719int varistyped_0(char *ident) 
     720{ 
     721   listvar *parcours; 
     722   int out; 
     723 
     724   out =0; 
     725   if ( firstpass == 0 ) 
     726   { 
     727      parcours = List_Global_Var; 
     728      while( parcours && out == 0 ) 
     729      { 
     730         if ( !strcasecmp(ident,parcours->var->v_nomvar) )  
     731             { 
     732             if (!strcasecmp(parcours->var->v_typevar,"type")) out = 1; 
     733             } 
     734         parcours = parcours->suiv; 
     735      } 
     736   } 
     737   return out; 
     738} 
     739 
    650740 
    651741/******************************************************************************/ 
Note: See TracChangeset for help on using the changeset viewer.