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