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.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.