Changeset 4067 for LMDZ6/trunk/libf/misc
- Timestamp:
- Jan 27, 2022, 8:47:29 PM (3 years ago)
- Location:
- LMDZ6/trunk/libf/misc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
LMDZ6/trunk/libf/misc/readTracFiles_mod.f90
r4063 r4067 15 15 16 16 PUBLIC :: known_phases, old_phases, nphases, phases_names, & !--- VARIABLES RELATED TO THE PHASES 17 phases_sep, delPhase, addPhase !--- + ROUTINES TO ADD/REMOVE PHASE TO/FROM A NAME 17 phases_sep, delPhase, addPhase, & !--- + ROUTINES TO ADD/REMOVE PHASE TO/FROM A NAME 18 old2newPhase, new2oldPhase 18 19 19 20 PUBLIC :: tran0, idxAncestor, ancestor !--- GENERATION 0 TRACER + TOOLS FOR GENERATIONS … … 1255 1256 CHARACTER(LEN=*), INTENT(IN) :: s 1256 1257 INTEGER :: l, i, ix 1258 CHARACTER(LEN=maxlen) :: sh, st 1257 1259 out = s 1258 1260 IF(s == '') RETURN !--- Empty string: nothing to do 1259 1261 1260 1262 !--- Special case: old phases for water, no phases separator 1261 IF(ANY([('H2O'//old_phases(ix:ix), ix=1, nphases)] == s)) THEN; out='H2O'; RETURN; END IF 1263 i = INDEX(s,'_'); sh = s; IF(i/=0) sh=s(1:i-1); st='H2O'; IF(i/=0) st='H2O_'//s(i+1:LEN_TRIM(s)) 1264 IF(ANY([('H2O'//old_phases(ix:ix), ix=1, nphases)] == sh)) THEN; out=st; RETURN; END IF 1262 1265 1263 1266 !--- Index of found phase in "known_phases" … … 1300 1303 !------------------------------------------------------------------------------------------------------------------------------ 1301 1304 1305 CHARACTER(LEN=1) FUNCTION old2newPhase(op) RESULT(np) 1306 CHARACTER(LEN=1), INTENT(IN) :: op 1307 np = known_phases(INDEX(old_phases,op):INDEX(old_phases,op)) 1308 END FUNCTION old2newPhase 1309 1310 CHARACTER(LEN=1) FUNCTION new2oldPhase(np) RESULT(op) 1311 CHARACTER(LEN=1), INTENT(IN) :: np 1312 op = old_phases(INDEX(known_phases,np):INDEX(known_phases,np)) 1313 END FUNCTION new2oldPhase 1302 1314 1303 1315 !============================================================================================================================== -
LMDZ6/trunk/libf/misc/strings_mod.F90
r4063 r4067 5 5 PRIVATE 6 6 PUBLIC :: maxlen, init_printout, msg, fmsg, get_in, lunout, prt_level 7 PUBLIC :: strLower, strHead, strStack, str Clean, strIdx, strCount, strReplace8 PUBLIC :: strUpper, strTail, strStackm, strReduce , strFind, strParse, cat, find7 PUBLIC :: strLower, strHead, strStack, strReduce, strClean, strFind, strIdx, find 8 PUBLIC :: strUpper, strTail, strStackm, strReducef, strParse, strCount, strReplace, cat 9 9 PUBLIC :: dispTable, dispOutliers, dispNameList 10 10 PUBLIC :: is_numeric, bool2str, int2str, real2str, dble2str … … 343 343 !=== strReduce_2(str1,str2): Append str1 with new elements of str2. =========================================================== 344 344 !============================================================================================================================== 345 SUBROUTINE strReduce_1(str 1, nb)346 CHARACTER(LEN=*), ALLOCATABLE, INTENT(INOUT) :: str 1(:)345 SUBROUTINE strReduce_1(str, nb) 346 CHARACTER(LEN=*), ALLOCATABLE, INTENT(INOUT) :: str(:) 347 347 INTEGER, OPTIONAL, INTENT(OUT) :: nb 348 348 CHARACTER(LEN=maxlen), ALLOCATABLE :: s1(:) 349 INTEGER :: k, n, n1 350 IF(PRESENT(nb)) nb = 0 351 CALL MOVE_ALLOC(FROM = str1, TO = s1); CALL strClean(s1) 352 n1 = SIZE(s1, DIM=1) !--- Total nb of elements in "s1" 353 n = COUNT( [( ALL(s1(1:k-1)/=s1(k)), k=1, n1 )] ) !--- Nb of unique elements in "s1" 354 ALLOCATE(str1(n)); IF(n==0) RETURN; str1(1) = s1(1) 355 n=1; DO k=2,n1; IF(ANY(s1(1:k-1)==s1(k))) CYCLE; n=n+1; str1(n)=s1(k); END DO 349 INTEGER :: n 350 s1 = strReducef(str, n); CALL MOVE_ALLOC(FROM=s1, TO=str) 356 351 IF(PRESENT(nb)) nb = n 357 352 END SUBROUTINE strReduce_1 … … 375 370 END IF 376 371 END SUBROUTINE strReduce_2 372 !============================================================================================================================== 373 FUNCTION strReducef(str_in, nb) RESULT(str_ou) 374 CHARACTER(LEN=*), INTENT(IN) :: str_in(:) 375 INTEGER, OPTIONAL, INTENT(OUT) :: nb 376 CHARACTER(LEN=LEN(str_in)), ALLOCATABLE :: str_ou(:) 377 CHARACTER(LEN=LEN(str_in)), ALLOCATABLE :: s1(:) 378 INTEGER :: k, n, n1 379 IF(PRESENT(nb)) nb = 0 380 s1 = str_in; CALL strClean(s1) 381 n1 = SIZE(s1, DIM=1) !--- Total nb of elements in "s1" 382 n = COUNT( [( ALL(s1(1:k-1)/=s1(k)), k=1, n1 )] ) !--- Nb of unique elements in "s1" 383 ALLOCATE(str_ou(n)); IF(n==0) RETURN; str_ou(1) = s1(1) 384 n=1; DO k=2,n1; IF(ANY(s1(1:k-1)==s1(k))) CYCLE; n=n+1; str_ou(n)=s1(k); END DO 385 IF(PRESENT(nb)) nb = n 386 END FUNCTION strReducef 377 387 !============================================================================================================================== 378 388
Note: See TracChangeset
for help on using the changeset viewer.