Changeset 4067


Ignore:
Timestamp:
Jan 27, 2022, 8:47:29 PM (2 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
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/libf/dyn3d_common/infotrac.F90

    r4064 r4067  
    33MODULE infotrac
    44
    5    USE       strings_mod, ONLY: msg, find, strIdx,  strFind, strParse, dispTable, int2str,  reduceExpr, &
    6                           cat, fmsg, test, strTail, strHead, strStack, strReduce, bool2str, maxlen, testFile
     5   USE       strings_mod, ONLY: msg, find, strIdx,  strFind, strParse, dispTable,  int2str,  reduceExpr, &
     6                          cat, fmsg, test, strTail, strHead, strStack, strReducef, bool2str, maxlen, testFile
    77   USE readTracFiles_mod, ONLY: trac_type, readTracersFiles, addPhase,  phases_sep,  nphases, ancestor,  &
    88                                isot_type, readIsotopesFile, delPhase,   old_phases, getKey_init, tran0, &
    9                                 keys_type, initIsotopes,  indexUpdate, known_phases, getKey, setGeneration
     9                                keys_type, initIsotopes,  indexUpdate, known_phases, getKey, setGeneration, &
     10                                new2oldPhase
    1011
    1112   IMPLICIT NONE
     
    225226   descrq(30)    =  'PRA'
    226227   
    227    CALL msg('type_trac='//TRIM(type_trac), modname)
     228   CALL msg('type_trac = "'//TRIM(type_trac)//'"', modname)
    228229   IF(lOldCode) THEN
    229230      str = [type_trac]; nt = 1
     
    377378   tracers(:)%phase     = 'g'
    378379   tracers(:)%component = type_trac
    379    DO ip = 1, nphases
    380       p = old_phases(ip:ip)
    381       iq = strIdx(tracers(:)%name, 'H2O'//p)
    382       IF(iq /= 0) CYCLE
    383       tracers(iq)%phase = p
     380   DO iq = 1, nqtrue
    384381      IF(lINCA) tracers(iq)%component = 'lmdz'
     382      ip = strIdx([('H2O'//old_phases(ix:ix), ix=1, nphases)], strHead(tracers(iq)%name,'_'))
     383      IF(ip == 0) CYCLE
     384      tracers(iq)%phase = known_phases(ip:ip)
    385385   END DO
    386386   IF(lINCA) tracers(1+nqo:nqCO2+nqo)%component = 'co2i'
    387387   CALL setGeneration(tracers)                                       !--- SET FIELDS %iGeneration, %gen0Name
    388 
    389388! manque "type"
    390389
     
    709708   IMPLICIT NONE
    710709   CHARACTER(LEN=3)      :: tnom_iso(niso_possibles)
    711    INTEGER, ALLOCATABLE  :: nb_iso(:,:), nb_traciso(:,:)
    712    INTEGER               :: ii, ip, iq, it, iz, ixt, nb_isoind, nzone_prec
     710   INTEGER, ALLOCATABLE  :: nb_iso(:,:), nb_traciso(:,:), nb_isoind(:)
     711   INTEGER               :: ii, ip, iq, it, iz, ixt, nzone_prec
    713712   TYPE(isot_type), POINTER :: i
    714713   TYPE(trac_type), POINTER :: t(:)
    715714   CHARACTER(LEN=maxlen)    :: tnom_trac
    716715   CHARACTER(LEN=maxlen), ALLOCATABLE :: str(:)
     716   LOGICAL, DIMENSION(:), ALLOCATABLE :: mask
    717717   INCLUDE "iniprint.h"
    718718
     
    723723   ALLOCATE(indnum_fn_num(niso_possibles))
    724724   ALLOCATE(iso_indnum(nqtot))
     725   ALLOCATE(nb_isoind(nqo))
    725726
    726727   iso_indnum   (:) = 0
     
    729730   nb_iso     (:,:) = 0 
    730731   nb_traciso (:,:) = 0
     732   nb_isoind    (:) = 0
    731733
    732734   DO iq=1, nqtot
    733735      IF(delPhase(tracers(iq)%name) == 'H2O' .OR. .NOT.tracers(iq)%isAdvected) CYCLE
    734736outer:DO ip = 1, nqo
    735          nb_isoind = 0
    736737         DO ixt= 1,niso_possibles
    737738            tnom_trac = 'H2O'//old_phases(ip:ip)//'_'//TRIM(tnom_iso(ixt))
    738739            IF (tracers(iq)%name == tnom_trac) THEN
    739740               nb_iso(ixt,ip)         = nb_iso(ixt,ip)+1
    740                nb_isoind              = nb_isoind+1
     741               nb_isoind (ip)         = nb_isoind (ip)+1
    741742               tracers(iq)%type       = 'tracer'
    742743               tracers(iq)%iso_iGroup = 1
    743744               tracers(iq)%iso_iName  = ixt
    744                iso_indnum(iq)         = nb_isoind
     745               iso_indnum(iq)         = nb_isoind(ip)
    745746               indnum_fn_num(ixt)     = iso_indnum(iq)
    746747               tracers(iq)%iso_iPhase = ip
     
    748749            ELSE IF(tracers(iq)%iqParent> 0) THEN
    749750               IF(tracers(tracers(iq)%iqParent)%name == tnom_trac) THEN
    750                   nb_traciso(ixt,ip)  = nb_traciso(ixt,ip)+1
     751                  nb_traciso(ixt,ip)     = nb_traciso(ixt,ip)+1
    751752                  iso_indnum(iq)         = indnum_fn_num(ixt)
    752                   tracers(iq)%type    = 'tag'
     753                  tracers(iq)%type       = 'tag'
    753754                  tracers(iq)%iso_iGroup = 1
    754755                  tracers(iq)%iso_iName  = ixt
     
    814815   ALLOCATE(isotopes(1))                                             !--- Only water
    815816   nbIso = 1
     817   t => tracers
    816818   i => isotopes(1)
    817    t => tracers
    818    str = PACK(delPhase(t%name), MASK = t%type=='tracer' .AND. delPhase(t%parent) == 'H2O' .AND. t%phase == 'g')
    819819   i%parent = 'H2O'
    820    i%niso  = SIZE(str)
     820
     821   !--- Isotopes names list (embedded in the "keys" field)
     822   i%niso  = niso
     823   ALLOCATE(i%keys(i%niso))
     824   mask = t%type=='tracer' .AND. delPhase(t%gen0Name)=='H2O' .AND. t%phase == 'g' .AND. t%iGeneration==1
     825   i%keys(:)%name = strReducef(strTail(PACK(delPhase(t%name), MASK = mask), '_'))
     826
     827   !--- Full isotopes list, with isotopes tagging tracers (if any) following the previous list
     828   i%ntiso = ntiso; ALLOCATE(i%trac(i%ntiso))
     829   mask = t%type=='tag'    .AND. delPhase(t%gen0Name)=='H2O' .AND. t%phase == 'g' .AND. t%iGeneration==2
     830   i%trac(:) = [i%keys(:)%name, strReducef(PACK(delPhase(t%name), MASK = mask))]
     831
     832   !--- Tagging zones names list
    821833   i%nzone = nzone
     834   i%zone = strTail(str, '_', .TRUE.)
     835
     836   !--- Effective phases list
    822837   i%nphas = nqo
    823    FORALL(it = 1:i%niso) i%keys(it)%name = str(it)
    824    i%zone = PACK(strTail(t%name,'_',.TRUE.), MASK = t%type=='tag' .AND. delPhase(t%gen0Name)=='H2O' .AND. t%iGeneration==3)
    825    CALL strReduce(i%zone)
    826    i%phase = strStack([(known_phases(ip:ip), ip=1, nphases)], MASK=[(strIdx(t%name,addPhase('H2O',known_phases(ip:ip)))/=0)])
    827    i%iTraPha = RESHAPE([((strIdx(t(:)%name,addPhase(i%trac(it),i%phase(ip:ip))) ,it=1,i%ntiso),ip=1,i%nphas)],[i%ntiso,i%nphas])
     838   i%phase = ''
     839   DO ip=1,nphases; IF(strIdx(t%name, addPhase('H2O',old_phases(ip:ip),''))/=0) i%phase=TRIM(i%phase)//known_phases(ip:ip); END DO
     840
     841   !--- Table: index in "qx" of an isotope, knowing its indices "it","ip" in "isotope%iName,%iPhase"
     842   i%iTraPha = RESHAPE([((strIdx(t%name, TRIM(addPhase('H2O', new2oldPhase(i%phase(ip:ip)), ''))//'_'//TRIM(i%trac(it))), &
     843                          it=1,i%ntiso), ip=1,i%nphas)], [i%ntiso,i%nphas])
     844
     845   !--- Table: index in "isotope%tracs(:)%name" of an isotopic tagging tracer, knowing its indices "iz","ip" in "isotope%iZone,%iName"
    828846   i%iZonIso = RESHAPE([((strIdx(i%trac,TRIM(i%trac(it))//'_'//TRIM(i%zone(iz))),iz=1,i%nzone),it=1,i%niso )],[i%nzone,i%niso ])
    829847   DO it=1,ntiso
  • 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
  • LMDZ6/trunk/libf/phylmd/physiq_mod.F90

    r4066 r4067  
    22702270       itr = 0
    22712271       DO iq = 1, nqtot
    2272          IF(tracers(iq)%isH2Ofamily) CYCLE
     2272         IF(tracers(iq)%isH2Ofamily .OR. .NOT.tracers(iq)%isAdvected) CYCLE
    22732273         itr = itr+1
    22742274          DO  k = 1, klev
Note: See TracChangeset for help on using the changeset viewer.