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 2715 for trunk/NEMOGCM/EXTERNAL/AGRIF/LIB/WorkWithlistvarindoloop.c – NEMO

Ignore:
Timestamp:
2011-03-30T17:58:35+02:00 (13 years ago)
Author:
rblod
Message:

First attempt to put dynamic allocation on the trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEMOGCM/EXTERNAL/AGRIF/LIB/WorkWithlistvarindoloop.c

    r2528 r2715  
    6666      newvar->suiv = NULL; 
    6767      strcpy(newvar->var->v_nomvar,ident); 
     68 
    6869      Save_Length(ident,4); 
    6970      strcpy(newvar->var->v_modulename,curmodulename); 
    7071      Save_Length(curmodulename,6); 
     72     printf("ICI %d\n",newvar->var->v_module); 
     73 
    7174      strcpy(newvar->var->v_commoninfile,mainfile); 
    7275      Save_Length(mainfile,10); 
     
    7578      newvar->var->v_pointedvar=pointedvar; 
    7679      List_UsedInSubroutine_Var = newvar ; 
     80       printf("jaoute %s\n",newvar->var->v_nomvar); 
    7781  } 
    7882  else 
     
    96100         /*                                                                   */ 
    97101         strcpy(newvar->var->v_nomvar,ident); 
     102 
    98103         Save_Length(ident,4); 
    99104         strcpy(newvar->var->v_commoninfile,mainfile); 
     
    101106         strcpy(newvar->var->v_modulename,curmodulename); 
    102107         Save_Length(curmodulename,6); 
     108       printf("ICI %d\n",newvar->var->v_module); 
    103109         strcpy(newvar->var->v_subroutinename,subroutinename); 
    104110         Save_Length(subroutinename,11); 
    105111         newvar->var->v_pointedvar=pointedvar; 
    106112         newvar->suiv = List_UsedInSubroutine_Var; 
    107          List_UsedInSubroutine_Var = newvar; 
     113         printf("jaoute %s\n",newvar->var->v_nomvar); 
     114         List_UsedInSubroutine_Var = newvar;         
    108115      } 
    109116  } 
     
    134141      newvar->suiv = NULL; 
    135142      strcpy(newvar->var->v_nomvar,name); 
     143 
    136144      Save_Length(name,4); 
    137145      strcpy(newvar->var->v_modulename,curmodulename); 
     
    181189         /*                                                                   */ 
    182190         strcpy(newvar->var->v_nomvar,name); 
     191 
    183192         Save_Length(name,4); 
    184193         strcpy(newvar->var->v_modulename,curmodulename); 
     
    189198         Save_Length(subroutinename,11); 
    190199         newvar->var->v_pointedvar=pointedvar; 
     200 
    191201         /* we should find this new variable to know the tabvars indice       */ 
    192202         if ( variableisglobal(newvar, List_Global_Var) == 1 ) 
     
    303313                                  strcpy(var1->v_commonname,var2->v_commonname); 
    304314   else strcpy(var2->v_commonname,var1->v_commonname); 
     315    
     316   printf("modulenameII = %s %s %d %s\n",var1->v_modulename,var2->v_modulename,var1->v_module,var1->v_nomvar); 
     317 
     318   if ( !strcasecmp(var1->v_modulename,"") || (var1->v_module ==0)) 
     319                                  strcpy(var1->v_modulename,var2->v_modulename); 
     320   else strcpy(var2->v_modulename,var1->v_modulename); 
    305321 
    306322   if ( !strcasecmp(var1->v_vallengspec,"") ) 
     
    350366   if ( var1->v_save == 0 ) var1->v_save = var2->v_save ; 
    351367   else var2->v_save = var1->v_save ; 
    352  
     368    
    353369   if ( var1->v_VariableIsParameter == 0 ) 
    354370                     var1->v_VariableIsParameter = var2->v_VariableIsParameter ; 
     371                     
    355372   else var2->v_VariableIsParameter = var1->v_VariableIsParameter ; 
    356  
    357373   if ( var1->v_indicetabvars == 0 ) 
     374   { 
     375    
    358376                                 var1->v_indicetabvars = var2->v_indicetabvars ; 
     377       printf("HERHEHR %s mm %s mm %d\n",var1->v_nomvar,var2->v_modulename,var2->v_indicetabvars); 
     378                                 } 
    359379   else var2->v_indicetabvars = var1->v_indicetabvars ; 
    360380 
     
    387407   if ( var1->v_allocatable == 0 ) var1->v_allocatable = var2->v_allocatable ; 
    388408   else var2->v_allocatable = var1->v_allocatable ; 
     409    
     410   if ( var1->v_target == 0 ) var1->v_target = var2->v_target ; 
     411   else var2->v_target = var1->v_target ; 
    389412 
    390413   if ( var1->v_dimsempty == 0 ) var1->v_dimsempty = var2->v_dimsempty ; 
     
    424447      } 
    425448      /* if variable has been found                                           */ 
    426        
     449 
    427450      if ( out == 1 ) CopyRecord(parcours->var,parcours1->var); 
    428451       
     
    489512         strcpy(newvar->var->v_subroutinename,parcours->var->v_subroutinename); 
    490513         strcpy(newvar->var->v_nomvar,parcours->var->v_nomvar); 
     514 
    491515         sprintf(ligne,"save_%s",parcours->var->v_subroutinename); 
    492          Add_NameOfCommon_1(ligne); 
     516         Add_NameOfCommon_1(ligne,parcours->var->v_subroutinename); 
    493517         strcpy(newvar->var->v_commonname,ligne); 
    494518         Save_Length(ligne,7); 
     
    504528         /*                                                                   */ 
    505529         newvar->suiv = NULL; 
     530 
    506531         CopyRecord(parcours->var,newvar->var); 
    507          strcpy(newvar->var->v_subroutinename,""); 
     532         strcpy(newvar->var->v_subroutinename,parcours->var->v_subroutinename); 
     533 
    508534         strcpy(newvar->var->v_nomvar,parcours->var->v_nomvar); 
     535 
    509536         strcpy(newvar->var->v_modulename,parcours->var->v_modulename); 
    510537         List_Global_Var = AddListvarToListvar(newvar,List_Global_Var,1); 
     
    532559      while ( parcours1 && out == 0 ) 
    533560      { 
     561 
    534562         if ( !strcasecmp(parcours->var->v_nomvar, 
    535563                          parcours1->var->v_nomvar)         && 
    536564              !strcasecmp(parcours->var->v_subroutinename, 
    537565                          parcours1->var->v_subroutinename) 
    538             ) out = 1; 
     566            ) { 
     567            out = 1;      
     568            } 
    539569         else parcours1 = parcours1->suiv; 
    540570      } 
     
    543573      { 
    544574         strcpy(parcours->var->v_commoninfile,parcours1->var->v_commoninfile); 
     575              
    545576         CopyRecord(parcours->var,parcours1->var); 
    546577      } 
     
    559590   listvar *parcours1; 
    560591   int out; 
     592   int out2; 
    561593    
    562594   parcours = list_to_modify; 
     595 
    563596   while( parcours ) 
    564597   { 
     598     printf("LE NOM EST %s\n",parcours->var->v_nomvar); 
    565599      /* looking in List_Global_Var                                           */ 
    566600       
    567601      out = 0; 
    568       if (list_to_modify != List_SubroutineDeclaration_Var) { 
     602       
     603//       if (list_to_modify != List_SubroutineDeclaration_Var && list_to_modify != List_UsedInSubroutine_Var) { 
     604//       parcours1 = List_Global_Var; 
     605//       while ( parcours1 && out == 0 ) 
     606//       { 
     607//          if ( !strcasecmp(parcours->var->v_nomvar, 
     608//                           parcours1->var->v_nomvar)         && 
     609//               !strcasecmp(parcours->var->v_modulename, 
     610//                           parcours1->var->v_modulename) 
     611//             ) out = 1; 
     612//          else parcours1 = parcours1->suiv; 
     613//       } 
     614//       } 
     615       
     616  //    if (list_to_modify == List_UsedInSubroutine_Var) { 
    569617      parcours1 = List_Global_Var; 
    570618      while ( parcours1 && out == 0 ) 
    571619      { 
     620      printf("lenombis est %s\n",parcours1->var->v_nomvar); 
    572621         if ( !strcasecmp(parcours->var->v_nomvar, 
    573622                          parcours1->var->v_nomvar)         && 
     623                 !strcasecmp(parcours->var->v_subroutinename, 
     624                             parcours1->var->v_subroutinename) && 
    574625              !strcasecmp(parcours->var->v_modulename, 
    575626                          parcours1->var->v_modulename) 
    576             ) out = 1; 
     627            ) { 
     628            out = 1; 
     629            } 
    577630         else parcours1 = parcours1->suiv; 
    578631      } 
    579       } 
    580            
     632//      }       
     633 
    581634      /* if variable has been found                                           */ 
    582635      if ( out == 1 ) { 
     
    588641         parcours1 = List_SubroutineDeclaration_Var ; 
    589642         out = 0; 
    590          while ( parcours1 && out == 0 ) 
     643         while ( parcours1) 
    591644         { 
    592645            if ( !strcasecmp(parcours->var->v_nomvar, 
     
    596649                 !strcasecmp(parcours->var->v_modulename, 
    597650                             parcours1->var->v_modulename) 
    598                ) out = 1; 
     651               ) { 
     652 
     653               out = 1; 
     654               break; 
     655               } 
    599656            else parcours1 = parcours1->suiv; 
    600657         } 
     
    603660         if ( out == 1 ) { 
    604661         CopyRecord(parcours->var,parcours1->var); 
     662         
    605663         } 
    606664         else 
     
    620678            } 
    621679            /* if variable has been found                                     */ 
    622             if ( out == 1 ) CopyRecord(parcours->var,parcours1->var);        
    623          } 
     680            if ( out == 1 ) { 
     681            CopyRecord(parcours->var,parcours1->var);        
     682         } 
     683      } 
    624684      } 
    625685      parcours = parcours->suiv; 
     
    636696   int out; 
    637697 
     698    
    638699   parcours = List_UsedInSubroutine_Var; 
    639700   while( parcours ) 
    640701   { 
    641702      out = 0 ; 
     703      printf("OIEROZEIR %s %s\n",parcours->var->v_nomvar,parcours->var->v_modulename); 
    642704      if ( parcours->var->v_indicetabvars == 0 ) 
    643705      { 
     706       printf("OIEROZEIR %s\n",parcours->var->v_nomvar); 
    644707         parcours2 = List_NameOfModuleUsed; 
    645708         while( parcours2 ) 
     
    864927           remove = LookingForVariableInList(List_SubroutineDeclaration_Var, 
    865928                                                                 parcours->var); 
     929 
    866930      if ( remove == 0 ) 
    867931           remove = LookingForVariableInList(List_Parameter_Var, 
     
    873937           remove = LookingForVariableInListGlob(List_GlobalParameter_Var, 
    874938                                                                 parcours->var); 
     939       
    875940      if ( remove == 0 ) 
    876941           remove = LookingForVariableInListParamGlob( 
    877942                                    List_GlobParamModuleUsed_Var,parcours->var); 
     943 
     944   
    878945      if ( remove == 0 ) 
    879946      { 
     
    885952         else remove = 1; 
    886953      } 
     954 
    887955      /************************************************************************/ 
    888956      /*                         Remove                                       */ 
    889957      /************************************************************************/ 
     958 
    890959      if ( remove == 1 ) 
    891960      { 
     
    907976      } 
    908977   } 
     978    
    909979 
    910980} 
     
    11361206/*   newvar = List_Common_Var;*/ 
    11371207/*   newvar = List_UsedInSubroutine_Var;*/ 
     1208/*   newvar = List_Data_Var;*/ 
    11381209   while ( newvar ) 
    11391210   { 
    1140       printf("++++ %s %d %s %s %s\n", 
     1211      printf("++++ %s - %d - %s - %s - %s - %s\n", 
    11411212      newvar->var->v_nomvar, 
    11421213      newvar->var->v_VariableIsParameter, 
    11431214      newvar->var->v_subroutinename, 
    11441215      newvar->var->v_modulename, 
    1145       newvar->var->v_typevar 
     1216      newvar->var->v_typevar, 
     1217      newvar->var->v_initialvalue       
    11461218            ); 
    11471219      newvar = newvar->suiv; 
     
    16421714   listnom *parcours_nom; 
    16431715   char ligne[LONG_C]; 
    1644  
    16451716   if ( firstpass == 0 ) 
    16461717   { 
     
    16501721         if ( parcours_nom->o_val == 1 ) 
    16511722         { 
     1723            strcpy(ligne,""); 
     1724            tofich(fortranout,ligne,1); 
    16521725            sprintf (ligne, "module %s",parcours_nom->o_nom); 
    16531726            tofich(fortranout,ligne,1); 
     1727            WriteUsemoduleDeclaration(parcours_nom->o_subroutinename); 
    16541728            strcpy(ligne,"implicit none"); 
    16551729            tofich(fortranout,ligne,1); 
     
    18441918   } 
    18451919   if ( mark == 1 ) printf("Indicemaxtabvars = %d \n",indicemaxtabvars); 
     1920    
    18461921} 
    18471922 
Note: See TracChangeset for help on using the changeset viewer.