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

Ignore:
Timestamp:
2007-12-18T17:45:53+01:00 (16 years ago)
Author:
rblod
Message:

Update Agrif, see ticket:#39

File:
1 edited

Legend:

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

    r663 r774  
    3131/* knowledge of the CeCILL-C license and that you accept its terms.           */ 
    3232/******************************************************************************/ 
    33 /* version 1.6                                                                */ 
     33/* version 1.7                                                                */ 
    3434/******************************************************************************/ 
    3535#include <stdio.h> 
     
    6666      newvar->suiv = NULL; 
    6767      strcpy(newvar->var->v_nomvar,ident); 
     68      Save_Length(ident,4); 
    6869      strcpy(newvar->var->v_modulename,curmodulename); 
     70      Save_Length(curmodulename,6); 
    6971      strcpy(newvar->var->v_commoninfile,mainfile); 
     72      Save_Length(mainfile,10); 
    7073      strcpy(newvar->var->v_subroutinename,subroutinename); 
     74      Save_Length(subroutinename,11); 
    7175      newvar->var->v_pointedvar=pointedvar; 
    7276      List_UsedInSubroutine_Var = newvar ; 
     
    9296         /*                                                                   */ 
    9397         strcpy(newvar->var->v_nomvar,ident); 
     98         Save_Length(ident,4); 
    9499         strcpy(newvar->var->v_commoninfile,mainfile); 
     100         Save_Length(mainfile,10); 
    95101         strcpy(newvar->var->v_modulename,curmodulename); 
     102         Save_Length(curmodulename,6); 
    96103         strcpy(newvar->var->v_subroutinename,subroutinename); 
     104         Save_Length(subroutinename,11); 
    97105         newvar->var->v_pointedvar=pointedvar; 
    98106         newvar->suiv = List_UsedInSubroutine_Var; 
     
    126134      newvar->suiv = NULL; 
    127135      strcpy(newvar->var->v_nomvar,name); 
     136      Save_Length(name,4); 
    128137      strcpy(newvar->var->v_modulename,curmodulename); 
     138      Save_Length(curmodulename,6); 
    129139      strcpy(newvar->var->v_commoninfile,mainfile); 
     140      Save_Length(mainfile,10); 
    130141      strcpy(newvar->var->v_subroutinename,subroutinename); 
     142      Save_Length(subroutinename,11); 
    131143      newvar->var->v_pointedvar=pointedvar; 
    132144      List_UsedInSubroutine_Var = newvar ; 
     
    169181         /*                                                                   */ 
    170182         strcpy(newvar->var->v_nomvar,name); 
     183         Save_Length(name,4); 
    171184         strcpy(newvar->var->v_modulename,curmodulename); 
     185         Save_Length(curmodulename,6); 
    172186         strcpy(newvar->var->v_commoninfile,mainfile); 
     187         Save_Length(mainfile,10); 
    173188         strcpy(newvar->var->v_subroutinename,subroutinename); 
     189         Save_Length(subroutinename,11); 
    174190         newvar->var->v_pointedvar=pointedvar; 
    175191         /* we should find this new variable to know the tabvars indice       */ 
     
    390406   int out; 
    391407 
     408   parcoursprec = (listvar *)NULL; 
    392409   parcours = list_to_modify; 
    393410   while( parcours ) 
     
    453470   listvar *parcours; 
    454471   listvar *newvar; 
    455    listvar *parcours1; 
    456    char ligne[LONGNOM]; 
    457    int out; 
     472   char ligne[LONG_C]; 
    458473 
    459474   parcours = List_Save_Var; 
     
    475490         Add_NameOfCommon_1(ligne); 
    476491         strcpy(newvar->var->v_commonname,ligne); 
     492         Save_Length(ligne,7); 
    477493         List_Common_Var = AddListvarToListvar(newvar,List_Common_Var,1); 
    478494      } 
     
    751767} 
    752768 
     769int LookingForVariableInListName(listvar *listin,char *name) 
     770{ 
     771   listvar *parcours1; 
     772   int out; 
     773 
     774   parcours1 = listin; 
     775   out = 0 ; 
     776   while ( parcours1 && out == 0 ) 
     777   { 
     778      if ( !strcasecmp(name,parcours1->var->v_nomvar) && 
     779           ( !strcasecmp(subroutinename,parcours1->var->v_subroutinename) || 
     780             !strcasecmp(subroutinename,"") ) 
     781         ) out = 1 ; 
     782      else parcours1 = parcours1 -> suiv; 
     783   } 
     784 
     785   return out; 
     786} 
     787 
    753788int LookingForVariableInListGlob(listvar *listin,variable *var) 
    754789{ 
     
    809844   int remove; 
    810845 
     846   parcoursprec = (listvar *)NULL; 
    811847   parcours = List_UsedInSubroutine_Var; 
    812848   while ( parcours ) 
     
    865901 
    866902 
     903void Clean_List_ModuleUsed_Var() 
     904{ 
     905   listvar *parcours; 
     906   listvar *parcours1; 
     907   listvar *parcoursprec; 
     908   int remove; 
     909 
     910   parcoursprec = (listvar *)NULL; 
     911   parcours = List_ModuleUsed_Var; 
     912   while ( parcours ) 
     913   { 
     914      /*                                                                      */ 
     915      parcours1 = List_GlobalParameter_Var; 
     916      remove = 0 ; 
     917      while ( parcours1 && remove == 0 ) 
     918      { 
     919         if ( !strcasecmp(parcours->var->v_nomvar,parcours1->var->v_nomvar) 
     920            ) remove = 1 ; 
     921         else parcours1 = parcours1 -> suiv; 
     922      } 
     923      /************************************************************************/ 
     924      /*                         Remove                                       */ 
     925      /************************************************************************/ 
     926      if ( remove == 1 ) 
     927      { 
     928         if ( parcours == List_ModuleUsed_Var ) 
     929         { 
     930           List_ModuleUsed_Var = List_ModuleUsed_Var -> suiv; 
     931           parcours = List_ModuleUsed_Var; 
     932         } 
     933         else 
     934         { 
     935            parcoursprec->suiv = parcours->suiv; 
     936            parcours = parcoursprec -> suiv ; 
     937         } 
     938      } 
     939      else 
     940      { 
     941         parcoursprec = parcours; 
     942         parcours = parcours -> suiv ; 
     943      } 
     944   } 
     945 
     946} 
     947 
    867948void Clean_List_SubroutineDeclaration_Var() 
    868949{ 
     
    872953   int out ; 
    873954 
     955   parcoursprec = (listvar *)NULL; 
    874956   parcours = List_SubroutineDeclaration_Var; 
    875957   while ( parcours ) 
     
    9231005} 
    9241006 
     1007void Clean_List_Global_Var() 
     1008{ 
     1009   listvar *parcours; 
     1010   listvar *parcours2; 
     1011   listvar *parcoursprec; 
     1012   listvar *parcours2prec; 
     1013 
     1014   parcoursprec = (listvar *)NULL; 
     1015   parcours2prec = (listvar *)NULL; 
     1016   parcours = List_Global_Var; 
     1017   while ( parcours ) 
     1018   { 
     1019      if ( parcours->var->v_VariableIsParameter == 1 ) 
     1020      { 
     1021         /* remove                                                            */ 
     1022         if ( parcours == List_Global_Var ) 
     1023         { 
     1024            List_Global_Var = List_Global_Var->suiv; 
     1025            free(parcours); 
     1026            parcours = List_Global_Var; 
     1027         } 
     1028         else 
     1029         { 
     1030            parcoursprec->suiv = parcours->suiv; 
     1031            free(parcours); 
     1032            parcours = parcoursprec->suiv; 
     1033         } 
     1034      } 
     1035      else 
     1036      { 
     1037         parcoursprec = parcours; 
     1038         parcours = parcours->suiv; 
     1039      } 
     1040   } 
     1041   /* looking for sevral declaration of the same variable                     */ 
     1042   parcours = List_Global_Var; 
     1043   while ( parcours ) 
     1044   { 
     1045      parcours2prec = parcours; 
     1046      parcours2 = parcours->suiv; 
     1047      while ( parcours2 ) 
     1048      { 
     1049         if ( !strcasecmp(parcours->var->v_nomvar, 
     1050                         parcours2->var->v_nomvar)     && 
     1051              !strcasecmp(parcours->var->v_modulename, 
     1052                         parcours2->var->v_modulename) ) 
     1053         { 
     1054            CopyRecord(parcours->var,parcours2->var); 
     1055            /* remove var from the parcours2                                  */ 
     1056            parcours2prec ->suiv = parcours2->suiv; 
     1057            free(parcours2); 
     1058            parcours2 = parcours2prec ->suiv; 
     1059         } 
     1060         else 
     1061         { 
     1062            parcours2prec = parcours2; 
     1063            parcours2 = parcours2->suiv; 
     1064         } 
     1065      } 
     1066      parcours = parcours->suiv; 
     1067   } 
     1068} 
    9251069/******************************************************************************/ 
    9261070/*                             ListClean                                      */ 
     
    9321076   listvar *newvar; 
    9331077 
    934  
     1078   Clean_List_ModuleUsed_Var(); 
    9351079   Clean_List_UsedInSubroutine_Var(); 
    9361080   Clean_List_SubroutineDeclaration_Var(); 
    937  
    9381081 
    9391082   newvar = (listvar *)NULL; 
     
    9781121/*   newvar = List_Common_Var;*/ 
    9791122/*   newvar = List_UsedInSubroutine_Var;*/ 
    980    while(newvar) 
    981    { 
    982       printf("----- %s --- %s ---%s---\n",newvar->var->v_nomvar, 
    983          newvar->var->v_commonname,newvar->var->v_readedlistdimension 
    984       ); 
    985       newvar = newvar -> suiv; 
     1123   while ( newvar ) 
     1124   { 
     1125      printf("++++ %s %d %s %s %s\n", 
     1126      newvar->var->v_nomvar, 
     1127      newvar->var->v_VariableIsParameter, 
     1128      newvar->var->v_subroutinename, 
     1129      newvar->var->v_modulename, 
     1130      newvar->var->v_typevar 
     1131            ); 
     1132      newvar = newvar->suiv; 
    9861133   } 
    9871134} 
     
    10491196   int position; 
    10501197   int out; 
    1051    char name_sub[LONGNOM]; 
     1198   char name_sub[LONG_C]; 
    10521199 
    10531200   parcours = List_SubroutineArgument_Var; 
     
    11251272   listindice *newindice; 
    11261273   int out; 
     1274 
     1275   parcoursprec = (listvar *)NULL; 
    11271276 
    11281277   if ( mark == 1 ) printf("MODULE Treated %s \n",nom); 
     
    12581407   int out; 
    12591408 
     1409   parcoursprec = (listvar *)NULL; 
     1410 
    12601411   if ( mark == 1 ) printf("COMMON Treated %s \n",nom); 
    12611412 
     
    13731524void IndiceTabvarsIdentification() 
    13741525{ 
    1375    listvar *parcours; 
    13761526   listnom *parcours_nom; 
    13771527 
     
    14731623void NewModule_Creation_0() 
    14741624{ 
    1475    listvar *parcours; 
    14761625   listnom *parcours_nom; 
    1477    char name_tmp[LONGNOM]; 
    1478    char ligne[LONGNOM]; 
     1626   char ligne[LONG_C]; 
    14791627 
    14801628   if ( firstpass == 0 ) 
     
    15291677   listvar *parcours4; 
    15301678   int out; 
    1531    char name_module[LONGNOM]; 
     1679   char name_module[LONG_C]; 
    15321680 
    15331681   /* We should integrate allocate and pointer variables                      */ 
Note: See TracChangeset for help on using the changeset viewer.