Changeset 4067 for LMDZ6/trunk/libf/misc


Ignore:
Timestamp:
Jan 27, 2022, 8:47:29 PM (3 years ago)
Author:
dcugnet
Message:

Fixes mainly for isotopes (more to be done).
Fix (to be confirmed) in physiq to avoid attempting to send a non-transported (iadv==0) tracer to the physics.

Location:
LMDZ6/trunk/libf/misc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/libf/misc/readTracFiles_mod.f90

    r4063 r4067  
    1515
    1616  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
    1819
    1920  PUBLIC :: tran0, idxAncestor, ancestor                             !--- GENERATION 0 TRACER + TOOLS FOR GENERATIONS
     
    12551256  CHARACTER(LEN=*), INTENT(IN) :: s
    12561257  INTEGER :: l, i, ix
     1258  CHARACTER(LEN=maxlen) :: sh, st
    12571259  out = s
    12581260  IF(s == '') RETURN                                                           !--- Empty string: nothing to do
    12591261
    12601262  !--- 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
    12621265
    12631266  !--- Index of found phase in "known_phases"
     
    13001303!------------------------------------------------------------------------------------------------------------------------------
    13011304
     1305CHARACTER(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))
     1308END FUNCTION old2newPhase
     1309
     1310CHARACTER(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))
     1313END FUNCTION new2oldPhase
    13021314
    13031315!==============================================================================================================================
  • LMDZ6/trunk/libf/misc/strings_mod.F90

    r4063 r4067  
    55  PRIVATE
    66  PUBLIC :: maxlen, init_printout, msg, fmsg, get_in, lunout, prt_level
    7   PUBLIC :: strLower, strHead, strStack,  strClean,  strIdx,  strCount, strReplace
    8   PUBLIC :: strUpper, strTail, strStackm, strReduce, strFind, strParse, cat, find
     7  PUBLIC :: strLower, strHead, strStack,  strReduce,  strClean, strFind,  strIdx, find
     8  PUBLIC :: strUpper, strTail, strStackm, strReducef, strParse, strCount, strReplace, cat
    99  PUBLIC :: dispTable, dispOutliers, dispNameList
    1010  PUBLIC :: is_numeric, bool2str, int2str, real2str, dble2str
     
    343343!=== strReduce_2(str1,str2): Append str1 with new elements of str2. ===========================================================
    344344!==============================================================================================================================
    345 SUBROUTINE strReduce_1(str1, nb)
    346   CHARACTER(LEN=*), ALLOCATABLE, INTENT(INOUT) :: str1(:)
     345SUBROUTINE strReduce_1(str, nb)
     346  CHARACTER(LEN=*), ALLOCATABLE, INTENT(INOUT) :: str(:)
    347347  INTEGER,          OPTIONAL,    INTENT(OUT)   :: nb
    348348  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)
    356351  IF(PRESENT(nb)) nb = n
    357352END SUBROUTINE strReduce_1
     
    375370  END IF
    376371END SUBROUTINE strReduce_2
     372!==============================================================================================================================
     373FUNCTION 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
     386END FUNCTION strReducef
    377387!==============================================================================================================================
    378388
Note: See TracChangeset for help on using the changeset viewer.