| 1 | !$Id: infotrac.F90 4301 2022-10-20 11:57:21Z dcugnet $ |
|---|
| 2 | ! |
|---|
| 3 | MODULE infotrac_phy |
|---|
| 4 | |
|---|
| 5 | USE strings_mod, ONLY: msg, maxlen, cat, dispTable, int2str, bool2str, strStack, strParse, strCount, strIdx |
|---|
| 6 | USE readTracFiles_mod, ONLY: trac_type, readTracersFiles, tracers, addPhase, addKey, iH2O, & |
|---|
| 7 | isoSelect, indexUpdate, isot_type, testTracersFiles, isotope, delPhase, getKey, tran0, & |
|---|
| 8 | isoKeys, isoName, isoZone, isoPhas, processIsotopes, isoCheck, itZonIso, nbIso, & |
|---|
| 9 | niso, ntiso, nzone, nphas, maxTableWidth, iqIsoPha, iqWIsoPha, ixIso, new2oldH2O |
|---|
| 10 | IMPLICIT NONE |
|---|
| 11 | |
|---|
| 12 | PRIVATE |
|---|
| 13 | |
|---|
| 14 | !=== FOR TRACERS: |
|---|
| 15 | PUBLIC :: init_infotrac_phy !--- Initialization of the tracers |
|---|
| 16 | PUBLIC :: tracers, type_trac !--- Full tracers database, tracers type keyword |
|---|
| 17 | PUBLIC :: nqtot, nbtr, nqo, nqCO2, nqtottr !--- Main dimensions |
|---|
| 18 | PUBLIC :: conv_flg, pbl_flg !--- Convection & boundary layer activation keys |
|---|
| 19 | PUBLIC :: new2oldH2O !--- For backwards compatibility in phyetat0 |
|---|
| 20 | PUBLIC :: addPhase, delPhase !--- Add/remove the phase from the name of a tracer |
|---|
| 21 | PUBLIC :: nbtr_bin, nbtr_sulgas !--- Number of aerosols bins and sulfur gases for StratAer model |
|---|
| 22 | PUBLIC :: id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat, id_TEST_strat |
|---|
| 23 | |
|---|
| 24 | !=== FOR ISOTOPES: General |
|---|
| 25 | PUBLIC :: isot_type, nbIso !--- Derived type, full isotopes families database + nb of families |
|---|
| 26 | PUBLIC :: isoSelect, ixIso !--- Isotopes family selection tool + selected family index |
|---|
| 27 | !=== FOR ISOTOPES: Specific to water |
|---|
| 28 | PUBLIC :: iH2O !--- Value of "ixIso" for "H2O" isotopes class |
|---|
| 29 | PUBLIC :: ivap, iliq, isol, ibs, icf, iqvc, icfc, iqtc, inic |
|---|
| 30 | !=== FOR ISOTOPES: Depending on the selected isotopes family |
|---|
| 31 | PUBLIC :: isotope !--- Selected isotopes database (argument of getKey) |
|---|
| 32 | PUBLIC :: isoKeys, isoName, isoZone, isoPhas !--- Isotopes keys & names, tagging zones names, phases |
|---|
| 33 | PUBLIC :: niso, ntiso, nzone, nphas !--- Number of " " |
|---|
| 34 | PUBLIC :: itZonIso !--- Index "it" in "isoName(1:niso)" = f(tagging idx, isotope idx) |
|---|
| 35 | PUBLIC :: iqIsoPha !--- Index "iq" in "qx" = f(isotope idx, phase idx) |
|---|
| 36 | PUBLIC :: iqWIsoPha !--- Same as iqIsoPha but with normal water phases |
|---|
| 37 | PUBLIC :: isoCheck !--- Run isotopes checking routines |
|---|
| 38 | !=== FOR BOTH TRACERS AND ISOTOPES |
|---|
| 39 | PUBLIC :: getKey !--- Get a key from "tracers" or "isotope" |
|---|
| 40 | |
|---|
| 41 | !=== CONVENTIONS FOR TRACERS NUMBERS: |
|---|
| 42 | ! |--------------------+-----------------------+-----------------+---------------+----------------------------| |
|---|
| 43 | ! | water in different | water tagging | water isotopes | other tracers | additional tracers moments | |
|---|
| 44 | ! | phases: H2O_[glsrb]| isotopes | | | for higher order schemes | |
|---|
| 45 | ! |--------------------+-----------------------+-----------------+---------------+----------------------------| |
|---|
| 46 | ! | | | | | | |
|---|
| 47 | ! |<-- nqo -->|<-- nqo*niso* nzone -->|<-- nqo*niso -->|<-- nbtr -->|<-- (nmom) -->| |
|---|
| 48 | ! | | | | |
|---|
| 49 | ! | |<-- nqo*niso*(nzone+1) = nqo*ntiso -->|<-- nqtottr = nbtr + nmom -->| |
|---|
| 50 | ! | = nqtot - nqo*(ntiso+1) | |
|---|
| 51 | ! | | |
|---|
| 52 | ! |<-- nqtrue = nbtr + nqo*(ntiso+1) -->| | |
|---|
| 53 | ! | | |
|---|
| 54 | ! |<-- nqtot = nqtrue + nmom -->| |
|---|
| 55 | ! | | |
|---|
| 56 | ! |-----------------------------------------------------------------------------------------------------------| |
|---|
| 57 | ! NOTES FOR THIS TABLE: |
|---|
| 58 | ! * Used "niso", "nzone" and "ntiso" are components of "isotopes(ip)" for water (isotopes(ip)%parent == 'H2O'), |
|---|
| 59 | ! since water is so far the sole tracers family, except passive CO2, removed from the main tracers table. |
|---|
| 60 | ! * For water, "nqo" is equal to the more general field "isotopes(ip)%nphas". |
|---|
| 61 | ! * "niso", "nzone", "ntiso", "nphas" are defined for other isotopic tracers families, if any. |
|---|
| 62 | ! |
|---|
| 63 | !=== DERIVED TYPE EMBEDDING MOST OF THE TRACERS-RELATED QUANTITIES (LENGTH: nqtot) |
|---|
| 64 | ! Each entry is accessible using "%" sign. |
|---|
| 65 | ! |-------------+------------------------------------------------------+-------------+------------------------+ |
|---|
| 66 | ! | entry | Meaning | Former name | Possible values | |
|---|
| 67 | ! |-------------+------------------------------------------------------+-------------+------------------------+ |
|---|
| 68 | ! | name | Name (short) | tname | | |
|---|
| 69 | ! | keys | key/val pairs accessible with "getKey" routine | / | | |
|---|
| 70 | ! | gen0Name | Name of the 1st generation ancestor | / | | |
|---|
| 71 | ! | parent | Name of the parent | / | | |
|---|
| 72 | ! | longName | Long name (with adv. scheme suffix) for outputs | ttext | | |
|---|
| 73 | ! | type | Type (so far: tracer or tag) | / | tracer,tag | |
|---|
| 74 | ! | phase | Phases list ("g"as / "l"iquid / "s"olid | | [g|l|s|r|b] | |
|---|
| 75 | ! | | "r"(cloud) / "b"lowing) | / | | |
|---|
| 76 | ! | component | Name(s) of the merged/cumulated section(s) | / | coma-separated names | |
|---|
| 77 | ! | iGeneration | Generation (>=1) | / | | |
|---|
| 78 | ! | iqParent | Index of the parent tracer | iqpere | 1:nqtot | |
|---|
| 79 | ! | iqDescen | Indexes of the childs (all generations) | iqfils | 1:nqtot | |
|---|
| 80 | ! | nqDescen | Number of the descendants (all generations) | nqdesc | 1:nqtot | |
|---|
| 81 | ! | nqChildren | Number of childs (1st generation only) | nqfils | 1:nqtot | |
|---|
| 82 | ! | isInPhysics | Advected tracers from the main table kept in physics | / | nqtottr .TRUE. values | |
|---|
| 83 | ! | iso_iGroup | Isotopes group index in isotopes(:) | / | 1:nbIso | |
|---|
| 84 | ! | iso_iName | Isotope name index in isotopes(iso_iGroup)%trac(:) | iso_indnum | 1:niso | |
|---|
| 85 | ! | iso_iZone | Isotope zone index in isotopes(iso_iGroup)%zone(:) | zone_num | 1:nzone | |
|---|
| 86 | ! | iso_iPhas | Isotope phase index in isotopes(iso_iGroup)%phas(:) | phase_num | 1:nphas | |
|---|
| 87 | ! +-------------+------------------------------------------------------+-------------+------------------------+ |
|---|
| 88 | ! |
|---|
| 89 | !=== DERIVED TYPE EMBEDDING MOST OF THE ISOTOPES-RELATED QUANTITIES (LENGTH: nbIso, NUMBER OF ISOTOPES FAMILIES) |
|---|
| 90 | ! Each entry is accessible using "%" sign. |
|---|
| 91 | ! |-----------------+--------------------------------------------------+--------------------+-----------------+ |
|---|
| 92 | ! | entry | length | Meaning | Former name | Possible values | |
|---|
| 93 | ! |-----------------+--------------------------------------------------+--------------------+-----------------+ |
|---|
| 94 | ! | parent | Parent tracer (isotopes family name) | | | |
|---|
| 95 | ! | keys | niso | Isotopes keys/values pairs list + number | | | |
|---|
| 96 | ! | trac | ntiso | Isotopes + tagging tracers list + number | / | ntraciso | | |
|---|
| 97 | ! | zone | nzone | Geographic tagging zones list + number | / | ntraceurs_zone | | |
|---|
| 98 | ! | phase | nphas | Phases list + number | | [g|l|s|r|b] 1:5 | |
|---|
| 99 | ! | iqIsoPha | Index in "qx" = f(name(1:ntiso)),phas) | iqiso | 1:nqtot | |
|---|
| 100 | ! | iqWIsoPha | Index in "qx" = f(name(1:ntiso+nqo)),phas) | / | 1:nqtot | |
|---|
| 101 | ! | itZonIso | Index in "trac(1:ntiso)"= f(zone, name(1:niso)) | index_trac | 1:ntiso | |
|---|
| 102 | ! +-----------------+--------------------------------------------------+--------------------+-----------------+ |
|---|
| 103 | |
|---|
| 104 | !=== INDICES FOR WATER |
|---|
| 105 | INTEGER, SAVE :: ivap, iliq, isol, ibs, icf, iqvc, icfc, iqtc, inic |
|---|
| 106 | !$OMP THREADPRIVATE(ivap, iliq, isol, ibs, icf, iqvc, icfc, iqtc, inic) |
|---|
| 107 | |
|---|
| 108 | !=== DIMENSIONS OF THE TRACERS TABLES AND OTHER SCALAR VARIABLES |
|---|
| 109 | INTEGER, SAVE :: nqtot !--- Tracers nb in dynamics (incl. higher moments + H2O) |
|---|
| 110 | INTEGER, SAVE :: nbtr !--- Tracers nb in physics (excl. higher moments + H2O) |
|---|
| 111 | INTEGER, SAVE :: nqo !--- Number of water phases |
|---|
| 112 | INTEGER, SAVE :: nqtottr !--- Number of tracers passed to phytrac (TO BE DELETED ?) |
|---|
| 113 | INTEGER, SAVE :: nqCO2 !--- Number of tracers of CO2 (ThL) |
|---|
| 114 | CHARACTER(LEN=maxlen), SAVE :: type_trac !--- Keyword for tracers type(s) |
|---|
| 115 | !$OMP THREADPRIVATE(nqtot, nbtr, nqo, nqtottr, nqCO2, type_trac) |
|---|
| 116 | |
|---|
| 117 | !=== VARIABLES FOR INCA |
|---|
| 118 | INTEGER, SAVE, ALLOCATABLE :: conv_flg(:), pbl_flg(:) !--- Convection / boundary layer activation (nbtr) |
|---|
| 119 | !$OMP THREADPRIVATE(conv_flg, pbl_flg) |
|---|
| 120 | |
|---|
| 121 | !=== SPECIFIC TO STRATOSPHERIC AEROSOLS (CK/OB) |
|---|
| 122 | INTEGER, SAVE :: nbtr_bin, nbtr_sulgas !--- number of aerosols bins and sulfur gases for StratAer model |
|---|
| 123 | !$OMP THREADPRIVATE(nbtr_bin, nbtr_sulgas) |
|---|
| 124 | INTEGER, SAVE :: id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat, id_TEST_strat |
|---|
| 125 | !$OMP THREADPRIVATE(id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat, id_TEST_strat) |
|---|
| 126 | |
|---|
| 127 | CONTAINS |
|---|
| 128 | |
|---|
| 129 | SUBROUTINE init_infotrac_phy |
|---|
| 130 | USE iniprint_mod_h |
|---|
| 131 | USE ioipsl_getin_p_mod, ONLY: getin_p |
|---|
| 132 | USE lmdz_reprobus_wrappers, ONLY: Init_chem_rep_trac |
|---|
| 133 | USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA, CPPKEY_REPROBUS, CPPKEY_STRATAER |
|---|
| 134 | USE mod_phys_lmdz_para, ONLY: is_master, is_omp_master |
|---|
| 135 | IMPLICIT NONE |
|---|
| 136 | !============================================================================================================================== |
|---|
| 137 | ! |
|---|
| 138 | ! Auteur: P. Le Van /L. Fairhead/F.Hourdin |
|---|
| 139 | ! ------- |
|---|
| 140 | ! |
|---|
| 141 | ! Modifications: |
|---|
| 142 | ! -------------- |
|---|
| 143 | ! 05/94: F.Forget Modif special traceur |
|---|
| 144 | ! 02/02: M-A Filiberti Lecture de traceur.def |
|---|
| 145 | ! 01/22: D. Cugnet Nouveaux tracer.def et tracer_*.def + encapsulation (types trac_type et isot_type) |
|---|
| 146 | ! |
|---|
| 147 | ! Objet: |
|---|
| 148 | ! ------ |
|---|
| 149 | ! GCM LMD nouvelle grille |
|---|
| 150 | ! |
|---|
| 151 | !============================================================================================================================== |
|---|
| 152 | ! ... modification de l'integration de q ( 26/04/94 ) .... |
|---|
| 153 | !------------------------------------------------------------------------------------------------------------------------------ |
|---|
| 154 | ! Declarations: |
|---|
| 155 | |
|---|
| 156 | |
|---|
| 157 | !------------------------------------------------------------------------------------------------------------------------------ |
|---|
| 158 | ! Local variables |
|---|
| 159 | INTEGER, ALLOCATABLE :: hadv(:), vadv(:) !--- Horizontal/vertical transport scheme number |
|---|
| 160 | INTEGER :: nqINCA |
|---|
| 161 | CHARACTER(LEN=maxlen), ALLOCATABLE :: tnames(:) |
|---|
| 162 | CHARACTER(LEN=2) :: suff(9) !--- Suffixes for schemes of order 3 or 4 (Prather) |
|---|
| 163 | CHARACTER(LEN=3) :: descrq(30) !--- Advection scheme description tags |
|---|
| 164 | CHARACTER(LEN=maxlen) :: msg1, texp, ttp !--- Strings for messages and expanded tracers type |
|---|
| 165 | INTEGER :: fType !--- Tracers description file type ; 0: none |
|---|
| 166 | !--- 1/2/3: "traceur.def"/"tracer.def"/"tracer_*.def" |
|---|
| 167 | INTEGER :: nqtrue !--- Tracers nb from tracer.def (no higher order moments) |
|---|
| 168 | INTEGER :: iad !--- Advection scheme number |
|---|
| 169 | INTEGER :: iq, jq, nt, im, nm !--- Indexes and temporary variables |
|---|
| 170 | LOGICAL :: lerr, lInit |
|---|
| 171 | TYPE(trac_type), ALLOCATABLE, TARGET :: ttr(:) |
|---|
| 172 | TYPE(trac_type), POINTER :: t1, t(:) |
|---|
| 173 | CHARACTER(LEN=maxlen), ALLOCATABLE :: types_trac(:) !--- Keywords for tracers type(s), parsed version |
|---|
| 174 | CHARACTER(LEN=*), PARAMETER :: modname="init_infotrac_phy" |
|---|
| 175 | !------------------------------------------------------------------------------------------------------------------------------ |
|---|
| 176 | ! Initialization : |
|---|
| 177 | !------------------------------------------------------------------------------------------------------------------------------ |
|---|
| 178 | suff = ['x ','y ','z ','xx','xy','xz','yy','yz','zz'] |
|---|
| 179 | descrq( 1:30) = ' ' |
|---|
| 180 | descrq( 1: 2) = ['LMV','BAK'] |
|---|
| 181 | descrq(10:20) = ['VL1','VLP','FH1','FH2','VLH',' ','PPM','PPS','PPP',' ','SLP'] |
|---|
| 182 | descrq(30) = 'PRA' |
|---|
| 183 | |
|---|
| 184 | CALL getin_p('type_trac',type_trac) |
|---|
| 185 | |
|---|
| 186 | CALL msg('type_trac = "'//TRIM(type_trac)//'"', modname, is_master) |
|---|
| 187 | IF(strCount(type_trac, '|', nt)) CALL abort_physic(modname, 'Could''nt parse the "type_trac" string with delimiter "|"', 1) |
|---|
| 188 | IF(nt >= 3) CALL abort_physic(modname, 'you need to modify type_trac, this version is not supported by lmdz', 1) |
|---|
| 189 | IF(strParse(type_trac, '|', types_trac, n=nt)) CALL abort_physic(modname, "couldn't parse "//'"type_trac"', 1) |
|---|
| 190 | IF(nt == 2) type_trac = types_trac(2) ! TO BE DELETED SOON |
|---|
| 191 | |
|---|
| 192 | CALL msg('type_trac = "'//TRIM(type_trac)//'"', modname) |
|---|
| 193 | lInit = .NOT.ALLOCATED(tracers) |
|---|
| 194 | |
|---|
| 195 | !############################################################################################################################## |
|---|
| 196 | IF(lInit .AND. is_master) THEN !=== SKIPED IF ALREADY DONE IN dyn3d_common/infotrac #### |
|---|
| 197 | !############################################################################################################################## |
|---|
| 198 | !--- MESSAGE ABOUT THE CHOSEN CONFIGURATION |
|---|
| 199 | msg1 = 'For type_trac = "'//TRIM(type_trac)//'":' |
|---|
| 200 | SELECT CASE(type_trac) |
|---|
| 201 | CASE('inca'); CALL msg(TRIM(msg1)//' coupling with INCA chemistry model', modname) |
|---|
| 202 | CASE('inco'); CALL msg(TRIM(msg1)//' coupling jointly with INCA and CO2 cycle', modname) |
|---|
| 203 | CASE('repr'); CALL msg(TRIM(msg1)//' coupling with REPROBUS chemistry model', modname) |
|---|
| 204 | CASE('co2i'); CALL msg(TRIM(msg1)//' you have chosen to run with CO2 cycle', modname) |
|---|
| 205 | CASE('coag'); CALL msg(TRIM(msg1)//' tracers are treated for COAGULATION tests', modname) |
|---|
| 206 | CASE('lmdz'); CALL msg(TRIM(msg1)//' tracers are treated in LMDZ only', modname) |
|---|
| 207 | CASE DEFAULT; CALL abort_physic(modname,'type_trac='//TRIM(type_trac)//' not possible yet.',1) |
|---|
| 208 | END SELECT |
|---|
| 209 | |
|---|
| 210 | !--- COHERENCE TEST BETWEEN "type_trac" AND PREPROCESSING KEYS |
|---|
| 211 | SELECT CASE(type_trac) |
|---|
| 212 | CASE('inca', 'inco') |
|---|
| 213 | IF(.NOT.CPPKEY_INCA) CALL abort_physic(modname, 'You must add cpp key INCA and compile with INCA code', 1) |
|---|
| 214 | CASE('repr') |
|---|
| 215 | IF(.NOT.CPPKEY_REPROBUS) CALL abort_physic(modname, 'You must add cpp key REPROBUS and compile with REPROBUS code', 1) |
|---|
| 216 | CASE('coag') |
|---|
| 217 | IF(.NOT.CPPKEY_STRATAER) CALL abort_physic(modname, 'You must add cpp key StratAer and compile with StratAer code', 1) |
|---|
| 218 | END SELECT |
|---|
| 219 | !############################################################################################################################## |
|---|
| 220 | END IF |
|---|
| 221 | !############################################################################################################################## |
|---|
| 222 | |
|---|
| 223 | !============================================================================================================================== |
|---|
| 224 | ! 0) DETERMINE THE TYPE OF THE INPUT TRACERS DESCRIPTION FILE AND READ IT |
|---|
| 225 | !============================================================================================================================== |
|---|
| 226 | texp = type_trac !=== EXPANDED (WITH "|" SEPARATOR) "type_trac" |
|---|
| 227 | IF(texp == 'inco') texp = 'co2i|inca' |
|---|
| 228 | IF(texp /= 'lmdz') texp = 'lmdz|'//TRIM(texp) |
|---|
| 229 | IF(testTracersFiles(modname, texp, fType, lInit.AND.is_master)) CALL abort_physic(modname, 'problem with tracers file(s)',1) |
|---|
| 230 | ttp = type_trac; IF(fType /= 1) ttp = texp |
|---|
| 231 | !--------------------------------------------------------------------------------------------------------------------------- |
|---|
| 232 | IF(fType == 0) CALL abort_physic(modname, 'Missing "traceur.def", "tracer.def" or "tracer_<keyword>.def tracers file.',1) |
|---|
| 233 | !--------------------------------------------------------------------------------------------------------------------------- |
|---|
| 234 | IF(fType == 1 .AND. ANY(['inca', 'inco'] == type_trac)) & !=== FOUND OLD STYLE INCA "traceur.def" |
|---|
| 235 | CALL abort_physic(modname, 'retro-compatibility with old-style INCA traceur.def files has been disabled.', 1) |
|---|
| 236 | !--------------------------------------------------------------------------------------------------------------------------- |
|---|
| 237 | |
|---|
| 238 | !############################################################################################################################## |
|---|
| 239 | IF(lInit) THEN |
|---|
| 240 | IF(readTracersFiles(ttp, lRepr=type_trac == 'repr')) CALL abort_physic(modname, 'problem with tracers file(s)',1) |
|---|
| 241 | END IF |
|---|
| 242 | CALL msg('No tracers description file(s) reading needed: already done', modname, .NOT.lInit.AND.is_master) |
|---|
| 243 | !############################################################################################################################## |
|---|
| 244 | |
|---|
| 245 | !============================================================================================================================== |
|---|
| 246 | ! 1) Get various numbers: "nqtrue" (first order only tracers), "nqo" (water phases), 'nbtr' (tracers passed to physics), etc. |
|---|
| 247 | !============================================================================================================================== |
|---|
| 248 | nqtrue = SIZE(tracers) !--- "true" tracers |
|---|
| 249 | nqo = COUNT(tracers(:)%component == 'lmdz' .AND. & |
|---|
| 250 | ((delPhase(tracers(:)%name) == 'H2O') .OR. & !--- Water phases |
|---|
| 251 | (delPhase(tracers(:)%name) == 'CLDFRA'))) |
|---|
| 252 | nbtr = nqtrue-COUNT(tracers(:)%component == 'lmdz' .AND. & |
|---|
| 253 | ((delPhase(tracers(:)%gen0Name) == 'H2O') .OR. & !--- Passed to phytrac |
|---|
| 254 | (delPhase(tracers(:)%gen0Name) == 'CLDFRA'))) |
|---|
| 255 | nqCO2 = COUNT( [type_trac == 'inco', type_trac == 'co2i'] ) |
|---|
| 256 | IF(CPPKEY_INCA) & |
|---|
| 257 | nqINCA = COUNT(tracers(:)%component == 'inca') |
|---|
| 258 | IF(CPPKEY_REPROBUS) CALL Init_chem_rep_trac(nbtr, nqo, tracers(:)%name) !--- Transfert the number of tracers to Reprobus |
|---|
| 259 | |
|---|
| 260 | !============================================================================================================================== |
|---|
| 261 | ! 2) Calculate nqtot, number of tracers needed (greater if advection schemes 20 or 30 have been chosen). |
|---|
| 262 | !============================================================================================================================== |
|---|
| 263 | IF(getKey('hadv', hadv, ky=tracers(:)%keys)) CALL abort_physic(modname, 'missing key "hadv"', 1) |
|---|
| 264 | IF(getKey('vadv', vadv, ky=tracers(:)%keys)) CALL abort_physic(modname, 'missing key "vadv"', 1) |
|---|
| 265 | DO iq = 1, nqtrue |
|---|
| 266 | IF( hadv(iq)<20 .OR. (ANY(hadv(iq)==[20,30]) .AND. hadv(iq)==vadv(iq)) ) CYCLE |
|---|
| 267 | WRITE(msg1,'("The choice hadv=",i0,", vadv=",i0,a)')hadv(iq),vadv(iq),' for "'//TRIM(tracers(iq)%name)//'" is not available' |
|---|
| 268 | CALL abort_physic(modname, TRIM(msg1), 1) |
|---|
| 269 | END DO |
|---|
| 270 | nqtot = COUNT( hadv< 20 .AND. vadv< 20 ) & !--- No additional tracer |
|---|
| 271 | + 4*COUNT( hadv==20 .AND. vadv==20 ) & !--- 3 additional tracers |
|---|
| 272 | + 10*COUNT( hadv==30 .AND. vadv==30 ) !--- 9 additional tracers |
|---|
| 273 | |
|---|
| 274 | !--- More tracers due to the choice of advection scheme => assign total number of tracers |
|---|
| 275 | IF( nqtot /= nqtrue ) THEN |
|---|
| 276 | CALL msg('The choice of advection scheme for one or more tracers makes it necessary to add tracers') |
|---|
| 277 | CALL msg('The number of true tracers is '//TRIM(int2str(nqtrue))) |
|---|
| 278 | CALL msg('The total number of tracers needed is '//TRIM(int2str(nqtot))) |
|---|
| 279 | END IF |
|---|
| 280 | |
|---|
| 281 | !############################################################################################################################## |
|---|
| 282 | IF(lInit) THEN !=== SKIPED IF ALREADY DONE IN dyn3d_common/infotrac #### |
|---|
| 283 | !############################################################################################################################## |
|---|
| 284 | |
|---|
| 285 | !============================================================================================================================== |
|---|
| 286 | ! 3) Determine the advection scheme ; needed to compute the full tracers list, the long names and nqtot |
|---|
| 287 | !============================================================================================================================== |
|---|
| 288 | ALLOCATE(ttr(nqtot)) |
|---|
| 289 | jq = nqtrue+1 |
|---|
| 290 | DO iq = 1, nqtrue |
|---|
| 291 | t1 => tracers(iq) |
|---|
| 292 | |
|---|
| 293 | !--- VERIFY THE CHOICE OF ADVECTION SCHEME |
|---|
| 294 | iad = -1 |
|---|
| 295 | IF(hadv(iq) == vadv(iq) ) iad = hadv(iq) |
|---|
| 296 | IF(hadv(iq)==10 .AND. vadv(iq)==16) iad = 11 |
|---|
| 297 | WRITE(msg1,'("Bad choice of advection scheme for ",a,": hadv = ",i0,", vadv = ",i0)')TRIM(t1%name), hadv(iq), vadv(iq) |
|---|
| 298 | IF(iad == -1) CALL abort_physic(modname, msg1, 1) |
|---|
| 299 | |
|---|
| 300 | !--- SET FIELDS longName, isInPhysics |
|---|
| 301 | t1%longName = t1%name; IF(iad > 0) t1%longName=TRIM(t1%name)//descrq(iad) |
|---|
| 302 | t1%isInPhysics= iad >= 0 .AND. (t1%component /= 'lmdz' .OR. & |
|---|
| 303 | ((delPhase(t1%gen0Name) /= 'H2O') .AND. & |
|---|
| 304 | (delPhase(t1%gen0Name) /= 'CLDFRA'))) |
|---|
| 305 | ttr(iq) = t1 |
|---|
| 306 | |
|---|
| 307 | !--- DEFINE THE HIGHER ORDER TRACERS, IF ANY |
|---|
| 308 | nm = 0 |
|---|
| 309 | IF(iad == 20) nm = 3 !--- 2nd order scheme |
|---|
| 310 | IF(iad == 30) nm = 9 !--- 3rd order scheme |
|---|
| 311 | IF(nm == 0) CYCLE !--- No higher moments |
|---|
| 312 | ttr(jq+1:jq+nm) = t1 |
|---|
| 313 | ttr(jq+1:jq+nm)%name = [ (TRIM(t1%name) //'-'//TRIM(suff(im)), im=1, nm) ] |
|---|
| 314 | ttr(jq+1:jq+nm)%gen0Name = [ (TRIM(t1%name) //'-'//TRIM(suff(im)), im=1, nm) ] |
|---|
| 315 | ttr(jq+1:jq+nm)%parent = [ (TRIM(t1%parent) //'-'//TRIM(suff(im)), im=1, nm) ] |
|---|
| 316 | ttr(jq+1:jq+nm)%longName = [ (TRIM(t1%longName)//'-'//TRIM(suff(im)), im=1, nm) ] |
|---|
| 317 | ttr(jq+1:jq+nm)%isInPhysics = [ (.FALSE., im=1, nm) ] |
|---|
| 318 | jq = jq + nm |
|---|
| 319 | END DO |
|---|
| 320 | DEALLOCATE(hadv, vadv) |
|---|
| 321 | CALL MOVE_ALLOC(FROM=ttr, TO=tracers) |
|---|
| 322 | |
|---|
| 323 | !--- SET FIELDS iqParent, iqDescen, nqDescen, nqChildren, iGeneration |
|---|
| 324 | IF(indexUpdate(tracers)) CALL abort_physic(modname, 'problem with tracers indices update', 1) |
|---|
| 325 | |
|---|
| 326 | !=== READ PHYSICAL PARAMETERS FOR ISOTOPES |
|---|
| 327 | niso = 0; nzone = 0; nphas = nqo; ntiso = 0; isoCheck = .FALSE. |
|---|
| 328 | IF(processIsotopes()) CALL abort_physic(modname, 'Problem when processing isotopes parameters', 1) |
|---|
| 329 | |
|---|
| 330 | !############################################################################################################################## |
|---|
| 331 | ELSE |
|---|
| 332 | !############################################################################################################################## |
|---|
| 333 | DO iq = 1, nqtrue |
|---|
| 334 | t1 => tracers(iq) |
|---|
| 335 | IF(hadv(iq) == vadv(iq) ) iad = hadv(iq) |
|---|
| 336 | IF(hadv(iq)==10 .AND. vadv(iq)==16) iad = 11 |
|---|
| 337 | tracers(iq)%isInPhysics= iad >= 0 .AND. (t1%component /= 'lmdz' .OR. & |
|---|
| 338 | ((delPhase(t1%gen0Name) /= 'H2O') .AND. & |
|---|
| 339 | (delPhase(t1%gen0Name) /= 'CLDFRA'))) |
|---|
| 340 | END DO |
|---|
| 341 | !############################################################################################################################## |
|---|
| 342 | END IF |
|---|
| 343 | !############################################################################################################################## |
|---|
| 344 | |
|---|
| 345 | !--- Convection / boundary layer activation for all tracers |
|---|
| 346 | IF(.NOT.ALLOCATED(conv_flg)) ALLOCATE(conv_flg(nbtr)); conv_flg(1:nbtr) = 1 |
|---|
| 347 | IF(.NOT.ALLOCATED( pbl_flg)) ALLOCATE( pbl_flg(nbtr)); pbl_flg(1:nbtr) = 1 |
|---|
| 348 | |
|---|
| 349 | !--- Note: nqtottr can differ from nbtr when nmom/=0 |
|---|
| 350 | ! nqtottr = nqtot - COUNT(delPhase(tracers%gen0Name) == 'H2O' .AND. tracers%component == 'lmdz') |
|---|
| 351 | nqtottr = nqtot - COUNT(tracers(:)%component == 'lmdz' .AND. & |
|---|
| 352 | ((delPhase(tracers(:)%gen0Name) == 'H2O') .OR. & |
|---|
| 353 | (delPhase(tracers(:)%gen0Name) == 'CLDFRA'))) |
|---|
| 354 | ! IF(COUNT(tracers%iso_iName == 0) - COUNT(delPhase(tracers%name) == 'H2O' .AND. tracers%component == 'lmdz') /= nqtottr) & |
|---|
| 355 | !IF(COUNT(tracers%iso_iName == 0) - COUNT(tracers(:)%component == 'lmdz' .AND. & |
|---|
| 356 | ! ((delPhase(tracers(:)%name) == 'H2O') .OR. & |
|---|
| 357 | ! (delPhase(tracers(:)%name) == 'CLDFRA'))) /= nqtottr) & |
|---|
| 358 | ! CALL abort_physic(modname, 'problem with the computation of nqtottr', 1) |
|---|
| 359 | |
|---|
| 360 | !--- Compute indices for water |
|---|
| 361 | ivap = strIdx(tracers(:)%name, addPhase('H2O', 'g')) |
|---|
| 362 | iliq = strIdx(tracers(:)%name, addPhase('H2O', 'l')) |
|---|
| 363 | isol = strIdx(tracers(:)%name, addPhase('H2O', 's')) |
|---|
| 364 | ibs = strIdx(tracers(:)%name, addPhase('H2O', 'b')) |
|---|
| 365 | icf = strIdx(tracers(:)%name, 'CLDFRA') |
|---|
| 366 | iqvc = strIdx(tracers(:)%name, 'CLDVAP') |
|---|
| 367 | icfc = strIdx(tracers(:)%name, 'CONTFRA') |
|---|
| 368 | iqtc = strIdx(tracers(:)%name, 'CONTWATER') |
|---|
| 369 | inic = strIdx(tracers(:)%name, 'CONTNICE') |
|---|
| 370 | !--Two ways of declaring tracers - the way below should be deleted in the future |
|---|
| 371 | IF (icf.EQ.0) icf = strIdx(tracers(:)%name, addPhase('H2O', 'f')) |
|---|
| 372 | IF (iqvc.EQ.0) iqvc = strIdx(tracers(:)%name, addPhase('H2O', 'c')) |
|---|
| 373 | IF (icfc.EQ.0) icfc = strIdx(tracers(:)%name, addPhase('H2O', 'x')) |
|---|
| 374 | IF (iqtc.EQ.0) iqtc = strIdx(tracers(:)%name, addPhase('H2O', 'y')) |
|---|
| 375 | IF (inic.EQ.0) inic = strIdx(tracers(:)%name, addPhase('H2O', 'z')) |
|---|
| 376 | |
|---|
| 377 | IF(CPPKEY_STRATAER .AND. type_trac == 'coag') THEN |
|---|
| 378 | nbtr_bin = COUNT([(tracers(iq)%name(1:3)=='BIN', iq=1, nqtot)]) |
|---|
| 379 | nbtr_sulgas = COUNT([(tracers(iq)%name(1:3)=='GAS', iq=1, nqtot)]) |
|---|
| 380 | tnames = PACK(tracers(:)%name, MASK=tracers(:)%isInPhysics) |
|---|
| 381 | id_BIN01_strat = strIdx(tnames, 'BIN01' ) |
|---|
| 382 | id_OCS_strat = strIdx(tnames, 'GASOCS' ) |
|---|
| 383 | id_SO2_strat = strIdx(tnames, 'GASSO2' ) |
|---|
| 384 | id_H2SO4_strat = strIdx(tnames, 'GASH2SO4') |
|---|
| 385 | id_TEST_strat = strIdx(tnames, 'GASTEST' ) |
|---|
| 386 | END IF |
|---|
| 387 | |
|---|
| 388 | !=== DISPLAY THE RESULTS |
|---|
| 389 | IF(.NOT.is_master) RETURN |
|---|
| 390 | CALL msg('nqo = '//TRIM(int2str(nqo)), modname) |
|---|
| 391 | CALL msg('nbtr = '//TRIM(int2str(nbtr)), modname) |
|---|
| 392 | CALL msg('nqtrue = '//TRIM(int2str(nqtrue)), modname) |
|---|
| 393 | CALL msg('nqtot = '//TRIM(int2str(nqtot)), modname) |
|---|
| 394 | CALL msg('niso = '//TRIM(int2str(niso)), modname) |
|---|
| 395 | CALL msg('ntiso = '//TRIM(int2str(ntiso)), modname) |
|---|
| 396 | CALL msg('nqCO2 = '//TRIM(int2str(nqCO2)), modname, CPPKEY_INCA) |
|---|
| 397 | CALL msg('nqINCA = '//TRIM(int2str(nqINCA)), modname, CPPKEY_INCA) |
|---|
| 398 | t => tracers |
|---|
| 399 | CALL msg('Information stored in '//TRIM(modname)//': ', modname) |
|---|
| 400 | IF(dispTable('issssssssiiiiiiii', ['iq ', 'name', 'lNam', 'g0Nm', 'prnt', 'type', 'phas', 'comp', & |
|---|
| 401 | 'isPh', 'iGen', 'iqPr', 'nqDe', 'nqCh', 'iGrp', 'iNam', 'iZon', 'iPha'], & |
|---|
| 402 | cat(t%name, t%longName, t%gen0Name, t%parent, t%type, t%phase, t%component, bool2str(t%isInPhysics)),& |
|---|
| 403 | cat([(iq, iq=1, nqtot)], t%iGeneration, t%iqParent, t%nqDescen, t%nqChildren, t%iso_iGroup, & |
|---|
| 404 | t%iso_iName, t%iso_iZone, t%iso_iPhase), nColMax=maxTableWidth, nHead=2, sub=modname)) & |
|---|
| 405 | CALL abort_physic(modname, "problem with the tracers table content", 1) |
|---|
| 406 | CALL msg('No isotopes identified.', modname, nbIso == 0) |
|---|
| 407 | IF(nbIso == 0) RETURN |
|---|
| 408 | CALL msg('For isotopes family "H2O":', modname) |
|---|
| 409 | CALL msg(' isoKeys%name = '//strStack(isoKeys%name), modname) |
|---|
| 410 | CALL msg(' isoName = '//strStack(isoName), modname) |
|---|
| 411 | CALL msg(' isoZone = '//strStack(isoZone), modname) |
|---|
| 412 | CALL msg(' isoPhas = '//TRIM(isoPhas), modname) |
|---|
| 413 | |
|---|
| 414 | IF(CPPKEY_STRATAER .AND. type_trac == 'coag') THEN |
|---|
| 415 | CALL msg('nbtr_bin ='//TRIM(int2str(nbtr_bin )), modname) |
|---|
| 416 | CALL msg('nbtr_sulgas ='//TRIM(int2str(nbtr_sulgas )), modname) |
|---|
| 417 | CALL msg('id_BIN01_strat ='//TRIM(int2str(id_BIN01_strat)), modname) |
|---|
| 418 | CALL msg('id_OCS_strat ='//TRIM(int2str(id_OCS_strat )), modname) |
|---|
| 419 | CALL msg('id_SO2_strat ='//TRIM(int2str(id_SO2_strat )), modname) |
|---|
| 420 | CALL msg('id_H2SO4_strat ='//TRIM(int2str(id_H2SO4_strat)), modname) |
|---|
| 421 | CALL msg('id_TEST_strat ='//TRIM(int2str(id_TEST_strat )), modname) |
|---|
| 422 | END IF |
|---|
| 423 | |
|---|
| 424 | END SUBROUTINE init_infotrac_phy |
|---|
| 425 | |
|---|
| 426 | END MODULE infotrac_phy |
|---|