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 9987 for branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/EXTERNAL/AGRIF/LIB/UtilCharacter.c – NEMO

Ignore:
Timestamp:
2018-07-23T11:33:03+02:00 (6 years ago)
Author:
emmafiedler
Message:

Merge with GO6 FOAMv14 package branch r9288

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/EXTERNAL/AGRIF/LIB/UtilCharacter.c

    r7960 r9987  
    4646/*                                                                            */ 
    4747/******************************************************************************/ 
    48 /* if  whichone = 0 ----> Agrif_tabvars(i) % var % array2                     */ 
    49 /*                                                                            */ 
    50 /* if  whichone = 1 ----> Agrif_tabvars(i) % parentvar % var % array2         */ 
    51 /*                                                                            */ 
    52 /******************************************************************************/ 
    53 void FindAndChangeNameToTabvars(char name[LONG_C],char toprint[LONG_4C], 
     48/* if  whichone = 0 ----> Agrif_tabvars(i) % array2                           */ 
     49/*                                                                            */ 
     50/* if  whichone = 1 ----> Agrif_tabvars(i) % parentvar % array2               */ 
     51/*                                                                            */ 
     52/******************************************************************************/ 
     53void FindAndChangeNameToTabvars(const char name[LONG_M],char toprint[LONG_M], 
    5454                                              listvar * listtosee, int whichone) 
    5555{ 
     
    7171            { 
    7272               out = 1; 
    73                strcat(toprint,vargridcurgridtabvars(newvar->var,whichone)); 
     73               strcat(toprint,vargridcurgridtabvars(newvar->var, whichone)); 
    7474            } 
    7575            else newvar=newvar->suiv; 
     
    9292/*                                                                            */ 
    9393/******************************************************************************/ 
    94 char *ChangeTheInitalvaluebyTabvarsName(char *nom,listvar *listtoread, 
    95                                                                    int whichone) 
    96 { 
    97    char toprinttmp[LONG_4C]; 
    98    int i; 
    99    char chartmp[2]; 
    100  
    101    i=0; 
    102    strcpy(toprintglob,""); 
    103    strcpy(toprinttmp,""); 
    104  
    105    /*                                                                         */ 
    106    while ( i < strlen(nom) ) 
    107    { 
    108       if ( nom[i] == '+' ) 
    109       { 
    110         FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); 
    111          strcpy(toprinttmp,""); 
    112          strcat(toprintglob,"+"); 
    113       } 
    114       else if ( nom[i] == '-' ) 
    115       { 
    116          FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); 
    117          strcpy(toprinttmp,""); 
    118          strcat(toprintglob,"-"); 
    119       } 
    120       else if ( nom[i] == '*' ) 
    121       { 
    122          FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); 
    123          strcpy(toprinttmp,""); 
    124          strcat(toprintglob,"*"); 
    125       } 
    126       else if ( nom[i] == '/' ) 
    127       { 
    128          FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); 
    129          strcpy(toprinttmp,""); 
    130          strcat(toprintglob,"/"); 
    131       } 
    132       else if ( nom[i] == '(' ) 
    133       { 
    134          FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); 
    135          strcpy(toprinttmp,""); 
    136          strcat(toprintglob,"("); 
    137       } 
    138       else if ( nom[i] == ')' ) 
    139       { 
    140          FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); 
    141          strcpy(toprinttmp,""); 
    142          strcat(toprintglob,")"); 
    143       } 
    144       else if ( nom[i] == ':' ) 
    145       { 
    146          FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); 
    147          strcpy(toprinttmp,""); 
    148          strcat(toprintglob,":"); 
    149       } 
    150       else if ( nom[i] == ',' ) 
    151       { 
    152          FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); 
    153          strcpy(toprinttmp,""); 
    154          strcat(toprintglob,","); 
    155       } 
    156       else 
    157       { 
    158          sprintf(chartmp,"%c",nom[i]); 
    159          strcat(toprinttmp,chartmp); 
    160       } 
    161       /*                                                                      */ 
    162       i=i+1; 
    163    } 
    164    FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,whichone); 
    165    strcpy(toprinttmp,""); 
    166  
    167    Save_Length(toprinttmp,44); 
    168    Save_Length(toprintglob,39); 
    169  
    170    /*                                                                         */ 
    171    return toprintglob; 
     94const char *ChangeTheInitalvaluebyTabvarsName(const char *nom, listvar *listtoread) 
     95{ 
     96    char toprinttmp[LONG_M]; 
     97    char chartmp[2]; 
     98    size_t i = 0; 
     99 
     100    strcpy(toprintglob, ""); 
     101    strcpy(toprinttmp,  ""); 
     102 
     103    while ( i < strlen(nom) ) 
     104    { 
     105        if ( (nom[i] == '+') || (nom[i] == '-') || (nom[i] == '*') || (nom[i] == '/') || 
     106             (nom[i] == '(') || (nom[i] == ')') || (nom[i] == ':') || (nom[i] == ',') ) 
     107        { 
     108            FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,0); 
     109            strcpy(toprinttmp, ""); 
     110            sprintf(chartmp, "%c", nom[i]); 
     111            strcat(toprintglob, chartmp); 
     112        } 
     113        else 
     114        { 
     115            sprintf(chartmp, "%c", nom[i]); 
     116            strcat(toprinttmp, chartmp); 
     117        } 
     118        i += 1; 
     119    } 
     120    FindAndChangeNameToTabvars(toprinttmp,toprintglob,listtoread,0); 
     121    strcpy(toprinttmp,""); 
     122 
     123    Save_Length(toprinttmp,44); 
     124    Save_Length(toprintglob,39); 
     125 
     126    return toprintglob; 
    172127} 
    173128 
     
    181136/*                                                                            */ 
    182137/******************************************************************************/ 
    183 int IsVariableReal(char *nom) 
    184 { 
    185    int Real; 
    186  
    187    Real = 0; 
    188    if ( ( nom[0] >= 'a' && nom[0] <= 'h' ) || 
     138int IsVariableReal(const char *nom) 
     139{ 
     140    return ( ( nom[0] >= 'a' && nom[0] <= 'h' ) || 
    189141        ( nom[0] >= 'A' && nom[0] <= 'H' ) || 
    190142        ( nom[0] >= 'o' && nom[0] <= 'z' ) || 
    191         ( nom[0] >= 'O' && nom[0] <= 'Z' ) 
    192        ) 
    193        { 
    194           Real = 1; 
    195        } 
    196    /*                                                                         */ 
    197    return Real; 
     143        ( nom[0] >= 'O' && nom[0] <= 'Z' ) ); 
    198144} 
    199145/******************************************************************************/ 
     
    206152/*                                                                            */ 
    207153/******************************************************************************/ 
    208 void IsVarInUseFile(char *nom) 
     154void IsVarInUseFile(const char *nom) 
    209155{ 
    210156   listvar *parcours; 
     
    217163   while( parcours && out == 0 ) 
    218164   { 
    219       if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out =1 ; 
     165      if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out = 1 ; 
    220166     else parcours=parcours->suiv; 
    221167   } 
     
    225171      while( parcours && out == 0 ) 
    226172      { 
     173         if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out = 1 ; 
     174        else parcours=parcours->suiv; 
     175      } 
     176   } 
     177   if ( out == 0 ) 
     178   { 
     179      parcours = List_GlobalParameter_Var; 
     180      while( parcours && out == 0 ) 
     181      { 
    227182         if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out =1 ; 
    228183        else parcours=parcours->suiv; 
     
    231186   if ( out == 0 ) 
    232187   { 
    233       parcours = List_GlobalParameter_Var; 
    234       while( parcours && out == 0 ) 
    235       { 
    236          if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out =1 ; 
    237         else parcours=parcours->suiv; 
    238       } 
    239    } 
    240    if ( out == 0 ) 
    241    { 
    242188      parcours = List_Parameter_Var; 
    243189      while( parcours && out == 0 ) 
    244190      { 
    245          if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out =1 ; 
     191         if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out = 1 ; 
    246192        else parcours=parcours->suiv; 
    247193      } 
     
    252198      while( parcoursparam && out == 0 ) 
    253199      { 
    254          if ( !strcasecmp(nom,parcoursparam->p_name) ) out =2 ; 
     200         if ( !strcasecmp(nom,parcoursparam->p_name) ) out = 2 ; 
    255201         else parcoursparam=parcoursparam->suiv; 
    256202      } 
     
    261207      while( parcours && out == 0 ) 
    262208      { 
    263          if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out =2 ; 
     209         if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out = 2 ; 
    264210        else parcours=parcours->suiv; 
    265211      } 
     
    270216      while( parcoursparam && out != 1 ) 
    271217      { 
    272          if ( !strcasecmp(nom,parcoursparam->p_name) ) out =1 ; 
     218         if ( !strcasecmp(nom,parcoursparam->p_name) ) out = 1 ; 
    273219         else parcoursparam=parcoursparam->suiv; 
    274220      } 
     
    299245/*                                                                            */ 
    300246/******************************************************************************/ 
    301 listnom *DecomposeTheNameinlistnom(char *nom, listnom * listout) 
    302 { 
    303    char toprinttmp[LONG_4C]; 
    304    int i; 
     247listnom *DecomposeTheNameinlistnom(const char *nom, listnom * listout) 
     248{ 
     249   char toprinttmp[LONG_M]; 
    305250   char chartmp[2]; 
    306  
    307    i=0; 
     251   size_t i = 0; 
     252 
    308253   strcpy(toprinttmp,""); 
    309    /*                                                                         */ 
     254 
    310255   while ( i < strlen(nom) ) 
    311256   { 
     
    320265         ) 
    321266      { 
    322  
    323267         if (strcasecmp(toprinttmp,"") && ( toprinttmp[0] >= 'A' ) ) 
    324268         { 
     
    331275         sprintf(chartmp,"%c",nom[i]); 
    332276         strcat(toprinttmp,chartmp); 
    333  
    334       } 
    335       /*                                                                      */ 
     277      } 
    336278      i=i+1; 
    337279   } 
     
    340282      listout = Addtolistnom(toprinttmp,listout,0); 
    341283   } 
     284   Save_Length(toprinttmp,44); 
    342285   strcpy(toprinttmp,""); 
    343    Save_Length(toprinttmp,44); 
    344286 
    345287   return listout; 
     
    356298/*                                                                            */ 
    357299/******************************************************************************/ 
    358 void DecomposeTheName(char *nom) 
    359 { 
    360    char toprinttmp[LONG_4C]; 
    361    int i; 
     300void DecomposeTheName(const char *nom) 
     301{ 
     302   char toprinttmp[LONG_M]; 
    362303   char chartmp[2]; 
    363  
    364    i=0; 
     304   size_t i = 0; 
     305    
    365306   strcpy(toprinttmp,""); 
    366    /*                                                                         */ 
     307 
    367308   while ( i < strlen(nom) ) 
    368309   { 
     
    390331         strcat(toprinttmp,chartmp); 
    391332      } 
    392       /*                                                                      */ 
    393333      i=i+1; 
    394334   } 
    395    Save_Length(toprinttmp,44); 
    396335   if (strcasecmp(toprinttmp,"") && ( toprinttmp[0] >= 'A' ) ) 
    397336   { 
     
    400339      IsVarInUseFile(toprinttmp); 
    401340   } 
     341   Save_Length(toprinttmp,44); 
    402342   strcpy(toprinttmp,""); 
    403343 
    404344} 
    405345 
    406 void convert2lower(char *name) 
    407 { 
    408    int l; 
    409    int i; 
    410    int caractere; 
    411  
    412    l=strlen(name)-1; 
    413    for (i=0;i<=l;i++) 
    414    { 
    415       caractere=name[i]; 
    416       if ((caractere>=65 && caractere<=90)||(caractere>=192 && caractere<=221)) 
    417       { 
    418          name[i]+=32; 
    419       } 
    420    } 
    421 } 
    422  
    423 int convert2int(char *name) 
     346void convert2lower(char *lowername, const char* inputname) 
     347{ 
     348    int i, l, caractere; 
     349 
     350    strcpy(lowername, inputname); 
     351    l = strlen(lowername)-1; 
     352 
     353    for ( i=0 ; i<=l ; i++) 
     354    { 
     355        caractere = lowername[i]; 
     356        if ( (caractere>=65 && caractere<=90) || (caractere>=192 && caractere<=221) ) 
     357        { 
     358            lowername[i] += 32; 
     359        } 
     360    } 
     361} 
     362 
     363int convert2int(const char *name) 
    424364{ 
    425365   int i; 
Note: See TracChangeset for help on using the changeset viewer.