source: LMDZ6/trunk/libf/phylmd/infotrac_phy.F90 @ 4984

Last change on this file since 4984 was 4984, checked in by crisi, 12 days ago

plenty of files that I forgot to commit last time.

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