Ignore:
Timestamp:
Sep 23, 2024, 12:42:02 PM (17 months ago)
Author:
dcugnet
Message:
  • Remove INCA retro-compatibility with "traceur.def" (containing only water tracers but getting chemical species from an internal INCA routine).
  • Introduce in dynamics a "is_master" variable that works also in sequential mode. It allows to avoid repeating messages for each process and task.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/libf/phylmd/infotrac_phy.F90

    r5200 r5216  
    33MODULE infotrac_phy
    44
    5    USE       strings_mod, ONLY: msg, fmsg, maxlen, cat, dispTable, int2str, bool2str, strStack, strParse, strIdx
    6    USE readTracFiles_mod, ONLY: trac_type, readTracersFiles, tracers, setGeneration, itZonIso, nzone, tran0, isoZone, &
    7         delPhase, niso, getKey, isot_type, processIsotopes,  isotope, maxTableWidth, iqIsoPha, nphas, ixIso, isoPhas, &
    8         addPhase, iH2O, addKey, isoSelect, testTracersFiles, isoKeys, indexUpdate,  iqWIsoPha, nbIso, ntiso, isoName, isoCheck
     5   USE       strings_mod, ONLY: msg, maxlen, cat, dispTable, int2str, bool2str, strStack, strParse, strCount, strIdx
     6   USE readTracFiles_mod, ONLY: readTracersFiles, maxTableWidth, isot_type, addPhase, addKey, iH2O, &
     7        indexUpdate, trac_type, testTracersFiles, processIsotopes, tracers, delPhase, getKey, tran0, &
     8        isoKeys, isoName, isoZone, isoPhas, isoSelect, itZonIso, nbIso, isotope, & 
     9           niso,   ntiso,   nzone,   nphas, iqWIsoPha, iqIsoPha, ixIso, isoCheck
    910   USE readTracFiles_mod, ONLY: new2oldH2O
    1011   IMPLICIT NONE
     
    135136SUBROUTINE init_infotrac_phy
    136137   USE ioipsl_getin_p_mod, ONLY: getin_p
     138   USE mod_phys_lmdz_para, ONLY: is_master, is_omp_master
    137139#ifdef REPROBUS
    138140   USE CHEM_REP, ONLY: Init_chem_rep_trac
     
    196198
    197199   CALL getin_p('type_trac',type_trac)
    198 
    199    lerr=strParse(type_trac, '|', types_trac, n=nt)
    200    IF (nt .GT. 1) THEN
    201       IF (nt .GT. 2) CALL abort_physic(modname, 'you need to modify type_trac, this version is not supported by lmdz', 1)
    202       IF (nt .EQ. 2) type_trac=types_trac(2)
    203    ENDIF
     200   CALL msg('type_trac = "'//TRIM(type_trac)//'"', modname, is_master)
     201   IF(strCount(type_trac, '|', nt)) CALL abort_physic(modname, 'Could''nt parse the "type_trac" string with delimiter "|"', 1)
     202   IF(nt >= 3) CALL abort_physic(modname, 'you need to modify type_trac, this version is not supported by lmdz', 1)
     203   IF(strParse(type_trac, '|', types_trac, n=nt)) CALL abort_physic(modname, "couldn't parse "//'"type_trac"', 1)
     204   IF(nt == 2) type_trac = types_trac(2) ! TO BE DELETED SOON
    204205
    205206   CALL msg('type_trac = "'//TRIM(type_trac)//'"', modname)
     
    207208
    208209!##############################################################################################################################
    209    IF(lInit) THEN                                                    !=== SKIPED IF ALREADY DONE IN dyn3d_common/infotrac  ####
     210   IF(lInit .AND. is_master) THEN                                    !=== SKIPED IF ALREADY DONE
    210211!##############################################################################################################################
    211212   !--- MESSAGE ABOUT THE CHOSEN CONFIGURATION
     
    240241!##############################################################################################################################
    241242
    242    nqCO2 = COUNT( [type_trac == 'inco', type_trac == 'co2i'] )
    243 
    244243!==============================================================================================================================
    245244! 0) DETERMINE THE TYPE OF THE INPUT TRACERS DESCRIPTION FILE AND READ IT
     
    248247   IF(texp == 'inco') texp = 'co2i|inca'
    249248   IF(texp /= 'lmdz') texp = 'lmdz|'//TRIM(texp)
    250    IF(testTracersFiles(modname, texp, fType, lInit)) CALL abort_physic(modname, 'problem with tracers file(s)',1)
     249   IF(testTracersFiles(modname, texp, fType, lInit.AND.is_master)) CALL abort_physic(modname, 'problem with tracers file(s)',1)
    251250   ttp = type_trac; IF(fType /= 1) ttp = texp
    252 
    253 !##############################################################################################################################
    254    IF(lInit) THEN
    255       IF(readTracersFiles(ttp, lRepr=type_trac=='repr')) CALL abort_physic(modname, 'problem with tracers file(s)',1)
    256    ELSE
    257       CALL msg('No tracers description file(s) reading needed: already done in the dynamics', modname)
    258    END IF
    259 !##############################################################################################################################
    260 
    261 !==============================================================================================================================
    262 ! 1) Get various numbers: "nqtrue" (first order only tracers), "nqo" (water phases), 'nbtr' (tracers passed to physics), etc.
    263 !==============================================================================================================================
    264251   !---------------------------------------------------------------------------------------------------------------------------
    265252   IF(fType == 0) CALL abort_physic(modname, 'Missing "traceur.def", "tracer.def" or "tracer_<keyword>.def tracers file.',1)
    266253   !---------------------------------------------------------------------------------------------------------------------------
    267    IF(fType == 1 .AND. ANY(['inca', 'inco'] == type_trac) .AND. lInit) THEN  !=== FOUND OLD STYLE INCA "traceur.def"
     254   IF(fType == 1 .AND. ANY(['inca', 'inco'] == type_trac)) &                   !=== FOUND OLD STYLE INCA "traceur.def"
     255      CALL abort_physic(modname, 'retro-compatibility with old-style INCA traceur.def files has been disabled.', 1)
    268256   !---------------------------------------------------------------------------------------------------------------------------
    269 #ifdef INCA
    270       nqo = SIZE(tracers) - nqCO2
    271       CALL Init_chem_inca_trac(nqINCA)                               !--- Get nqINCA from INCA
    272       nbtr = nqINCA + nqCO2                                          !--- Number of tracers passed to phytrac
    273       nqtrue = nbtr + nqo                                            !--- Total number of "true" tracers
    274       IF(ALL([2,3] /= nqo)) CALL abort_physic(modname, 'Only 2 or 3 water phases allowed ; found nqo='//TRIM(int2str(nqo)), 1)
    275       ALLOCATE(hadv(nqtrue), hadv_inca(nqINCA), conv_flg_inca(nqINCA), solsym_inca(nqINCA))
    276       ALLOCATE(vadv(nqtrue), vadv_inca(nqINCA),  pbl_flg_inca(nqINCA))
    277       CALL init_transport(solsym_inca, conv_flg_inca, pbl_flg_inca, hadv_inca, vadv_inca)
    278       ALLOCATE(ttr(nqtrue))
    279       ttr(1:nqo+nqCO2)                  = tracers
    280       ttr(1    :      nqo   )%component = 'lmdz'
    281       ttr(1+nqo:nqCO2+nqo   )%component = 'co2i'
    282       ttr(1+nqo+nqCO2:nqtrue)%component = 'inca'
    283       ttr(1+nqo      :nqtrue)%name      = [('CO2     ', iq=1, nqCO2), solsym_inca]
    284       ttr(1+nqo+nqCO2:nqtrue)%parent    = tran0
    285       ttr(1+nqo+nqCO2:nqtrue)%phase     = 'g'
    286       lerr = getKey('hadv', had, ky=tracers(:)%keys)
    287       lerr = getKey('vadv', vad, ky=tracers(:)%keys)
    288       hadv(1:nqo+nqCO2) = had(:); hadv(1+nqo+nqCO2:nqtrue) = hadv_inca
    289       vadv(1:nqo+nqCO2) = vad(:); vadv(1+nqo+nqCO2:nqtrue) = vadv_inca
    290       CALL MOVE_ALLOC(FROM=ttr, TO=tracers)
    291       DO iq = 1, nqtrue
    292          t1 => tracers(iq)
    293          CALL addKey('name',      t1%name,      t1%keys)
    294          CALL addKey('component', t1%component, t1%keys)
    295          CALL addKey('parent',    t1%parent,    t1%keys)
    296          CALL addKey('phase',     t1%phase,     t1%keys)
    297       END DO
    298       IF(setGeneration(tracers)) CALL abort_physic(modname,'See below',1) !- SET FIELDS %iGeneration, %gen0Name
    299       DEALLOCATE(had, hadv_inca, vad, vadv_inca, conv_flg_inca, pbl_flg_inca, solsym_inca)
    300 #endif
    301    !---------------------------------------------------------------------------------------------------------------------------
    302    ELSE                                                              !=== OTHER CASES (OLD OR NEW FORMAT, NO INCA MODULE)
    303    !---------------------------------------------------------------------------------------------------------------------------
     257
     258!##############################################################################################################################
     259   IF(lInit) THEN
     260      IF(readTracersFiles(ttp, lRepr=type_trac == 'repr')) CALL abort_physic(modname, 'problem with tracers file(s)',1)
     261   END IF
     262   CALL msg('No tracers description file(s) reading needed: already done', modname, .NOT.lInit.AND.is_master)
     263!##############################################################################################################################
     264
     265!==============================================================================================================================
     266! 1) Get various numbers: "nqtrue" (first order only tracers), "nqo" (water phases), 'nbtr' (tracers passed to physics), etc.
     267!==============================================================================================================================
    304268   nqtrue = SIZE(tracers)                                                                               !--- "true" tracers
    305269   nqo    =      COUNT(tracers(:)%component == 'lmdz' .AND. delPhase(tracers(:)%name)     == 'H2O')     !--- Water phases
     
    309273   nqINCA =      COUNT(tracers(:)%component == 'inca')
    310274#endif
     275#ifdef REPROBUS
     276   CALL Init_chem_rep_trac(nbtr, nqo, tracers(:)%name)                         !--- Transfert the number of tracers to Reprobus
     277#endif
     278
     279!##############################################################################################################################
     280   IF(lInit) THEN                                                    !=== SKIPED IF ALREADY DONE IN dyn3d_common/infotrac  ####
     281!##############################################################################################################################
     282
     283!==============================================================================================================================
     284! 2) Calculate nqtot, number of tracers needed (greater if advection schemes 20 or 30 have been chosen).
     285!==============================================================================================================================
    311286   IF(getKey('hadv', hadv, ky=tracers(:)%keys)) CALL abort_physic(modname, 'missing key "hadv"', 1)
    312287   IF(getKey('vadv', vadv, ky=tracers(:)%keys)) CALL abort_physic(modname, 'missing key "vadv"', 1)
    313    !---------------------------------------------------------------------------------------------------------------------------
    314    END IF
    315    !---------------------------------------------------------------------------------------------------------------------------
    316 
    317 #ifdef REPROBUS
    318    CALL Init_chem_rep_trac(nbtr, nqo, tracers(:)%name)                         !--- Transfert the number of tracers to Reprobus
    319 #endif
    320 
    321 !##############################################################################################################################
    322    IF(lInit) THEN                                                    !=== SKIPED IF ALREADY DONE IN dyn3d_common/infotrac  ####
    323 !##############################################################################################################################
    324 
    325 !==============================================================================================================================
    326 ! 2) Calculate nqtot, number of tracers needed (greater if advection schemes 20 or 30 have been chosen).
    327 !==============================================================================================================================
    328288   DO iq = 1, nqtrue
    329289      IF( hadv(iq)<20 .OR. (ANY(hadv(iq)==[20,30]) .AND. hadv(iq)==vadv(iq)) ) CYCLE
     
    412372
    413373   !=== DISPLAY THE RESULTS
     374   IF(.NOT.is_master) RETURN
    414375   CALL msg('nqo    = '//TRIM(int2str(nqo)),    modname)
    415376   CALL msg('nbtr   = '//TRIM(int2str(nbtr)),   modname)
     
    431392                  t%iso_iName, t%iso_iZone, t%iso_iPhase), nColMax=maxTableWidth, nHead=2, sub=modname))   &
    432393      CALL abort_physic(modname, "problem with the tracers table content", 1)
    433    IF(niso > 0) THEN
    434       CALL msg('Where, for isotopes family "'//TRIM(isotope%parent)//'":', modname)
     394   CALL msg('No isotopes identified.', modname, nbIso == 0)
     395   IF(nbIso == 0) RETURN
     396      CALL msg('For isotopes family "H2O":', modname)
    435397      CALL msg('  isoKeys%name = '//strStack(isoKeys%name), modname)
    436       CALL msg('  isoName = '//strStack(isoName),      modname)
    437       CALL msg('  isoZone = '//strStack(isoZone),      modname)
    438       CALL msg('  isoPhas = '//TRIM(isoPhas),          modname)
    439    ELSE
    440       CALL msg('No isotopes identified.', modname)
    441    END IF
     398      CALL msg('  isoName = '//strStack(isoName),  modname)
     399      CALL msg('  isoZone = '//strStack(isoZone),  modname)
     400      CALL msg('  isoPhas = '//    TRIM(isoPhas),  modname)
    442401
    443402#ifdef ISOVERIF
     
    463422   END IF
    464423#endif
    465    CALL msg('end', modname)
    466424
    467425END SUBROUTINE init_infotrac_phy
Note: See TracChangeset for help on using the changeset viewer.