Changeset 9817 for branches/UKMO/dev_r5518_nemo2cice_prints/NEMOGCM/EXTERNAL/AGRIF/LIB/UtilCharacter.c
- Timestamp:
- 2018-06-21T11:58:42+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/UKMO/dev_r5518_nemo2cice_prints/NEMOGCM/EXTERNAL/AGRIF/LIB/UtilCharacter.c
r9816 r9817 46 46 /* */ 47 47 /******************************************************************************/ 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(c har 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 /******************************************************************************/ 53 void FindAndChangeNameToTabvars(const char name[LONG_M],char toprint[LONG_M], 54 54 listvar * listtosee, int whichone) 55 55 { … … 71 71 { 72 72 out = 1; 73 strcat(toprint,vargridcurgridtabvars(newvar->var, whichone));73 strcat(toprint,vargridcurgridtabvars(newvar->var, whichone)); 74 74 } 75 75 else newvar=newvar->suiv; … … 92 92 /* */ 93 93 /******************************************************************************/ 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; 94 const 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; 172 127 } 173 128 … … 181 136 /* */ 182 137 /******************************************************************************/ 183 int IsVariableReal(char *nom) 184 { 185 int Real; 186 187 Real = 0; 188 if ( ( nom[0] >= 'a' && nom[0] <= 'h' ) || 138 int IsVariableReal(const char *nom) 139 { 140 return ( ( nom[0] >= 'a' && nom[0] <= 'h' ) || 189 141 ( nom[0] >= 'A' && nom[0] <= 'H' ) || 190 142 ( 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' ) ); 198 144 } 199 145 /******************************************************************************/ … … 206 152 /* */ 207 153 /******************************************************************************/ 208 void IsVarInUseFile(c har *nom)154 void IsVarInUseFile(const char *nom) 209 155 { 210 156 listvar *parcours; … … 217 163 while( parcours && out == 0 ) 218 164 { 219 if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out = 1 ;165 if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out = 1 ; 220 166 else parcours=parcours->suiv; 221 167 } … … 225 171 while( parcours && out == 0 ) 226 172 { 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 { 227 182 if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out =1 ; 228 183 else parcours=parcours->suiv; … … 231 186 if ( out == 0 ) 232 187 { 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 {242 188 parcours = List_Parameter_Var; 243 189 while( parcours && out == 0 ) 244 190 { 245 if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out = 1 ;191 if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out = 1 ; 246 192 else parcours=parcours->suiv; 247 193 } … … 252 198 while( parcoursparam && out == 0 ) 253 199 { 254 if ( !strcasecmp(nom,parcoursparam->p_name) ) out = 2 ;200 if ( !strcasecmp(nom,parcoursparam->p_name) ) out = 2 ; 255 201 else parcoursparam=parcoursparam->suiv; 256 202 } … … 261 207 while( parcours && out == 0 ) 262 208 { 263 if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out = 2 ;209 if ( !strcasecmp(nom,parcours->var->v_nomvar) ) out = 2 ; 264 210 else parcours=parcours->suiv; 265 211 } … … 270 216 while( parcoursparam && out != 1 ) 271 217 { 272 if ( !strcasecmp(nom,parcoursparam->p_name) ) out = 1 ;218 if ( !strcasecmp(nom,parcoursparam->p_name) ) out = 1 ; 273 219 else parcoursparam=parcoursparam->suiv; 274 220 } … … 299 245 /* */ 300 246 /******************************************************************************/ 301 listnom *DecomposeTheNameinlistnom(char *nom, listnom * listout) 302 { 303 char toprinttmp[LONG_4C]; 304 int i; 247 listnom *DecomposeTheNameinlistnom(const char *nom, listnom * listout) 248 { 249 char toprinttmp[LONG_M]; 305 250 char chartmp[2]; 306 307 i=0; 251 size_t i = 0; 252 308 253 strcpy(toprinttmp,""); 309 /* */ 254 310 255 while ( i < strlen(nom) ) 311 256 { … … 320 265 ) 321 266 { 322 323 267 if (strcasecmp(toprinttmp,"") && ( toprinttmp[0] >= 'A' ) ) 324 268 { … … 331 275 sprintf(chartmp,"%c",nom[i]); 332 276 strcat(toprinttmp,chartmp); 333 334 } 335 /* */ 277 } 336 278 i=i+1; 337 279 } … … 340 282 listout = Addtolistnom(toprinttmp,listout,0); 341 283 } 284 Save_Length(toprinttmp,44); 342 285 strcpy(toprinttmp,""); 343 Save_Length(toprinttmp,44);344 286 345 287 return listout; … … 356 298 /* */ 357 299 /******************************************************************************/ 358 void DecomposeTheName(char *nom) 359 { 360 char toprinttmp[LONG_4C]; 361 int i; 300 void DecomposeTheName(const char *nom) 301 { 302 char toprinttmp[LONG_M]; 362 303 char chartmp[2]; 363 364 i=0;304 size_t i = 0; 305 365 306 strcpy(toprinttmp,""); 366 /* */ 307 367 308 while ( i < strlen(nom) ) 368 309 { … … 390 331 strcat(toprinttmp,chartmp); 391 332 } 392 /* */393 333 i=i+1; 394 334 } 395 Save_Length(toprinttmp,44);396 335 if (strcasecmp(toprinttmp,"") && ( toprinttmp[0] >= 'A' ) ) 397 336 { … … 400 339 IsVarInUseFile(toprinttmp); 401 340 } 341 Save_Length(toprinttmp,44); 402 342 strcpy(toprinttmp,""); 403 343 404 344 } 405 345 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(c har *name)346 void 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 363 int convert2int(const char *name) 424 364 { 425 365 int i;
Note: See TracChangeset
for help on using the changeset viewer.