Index: LMDZ6/branches/LMDZ-ECRAD/libf/phylmd/infotrac_phy.F90
===================================================================
--- LMDZ6/branches/LMDZ-ECRAD/libf/phylmd/infotrac_phy.F90	(revision 3879)
+++ LMDZ6/branches/LMDZ-ECRAD/libf/phylmd/infotrac_phy.F90	(revision 4171)
@@ -4,239 +4,258 @@
 MODULE infotrac_phy
 
-! Infotrac for physics; for now contains the same information as infotrac for
-! the dynamics (could be further cleaned) and is initialized using values
-! provided by the dynamics
-
-! nqtot : total number of tracers and higher order of moment, water vapor and liquid included
-  INTEGER, SAVE :: nqtot
-!$OMP THREADPRIVATE(nqtot)
-
-!CR: on ajoute le nombre de traceurs de l eau
-  INTEGER, SAVE :: nqo
-!$OMP THREADPRIVATE(nqo)
-
-! nbtr : number of tracers not including higher order of moment or water vapor or liquid
-!        number of tracers used in the physics
-  INTEGER, SAVE :: nbtr
-!$OMP THREADPRIVATE(nbtr)
+   USE       strings_mod, ONLY: msg, maxlen, strStack, strHead, strParse, strIdx, int2str
+   USE readTracFiles_mod, ONLY: trac_type, isot_type, keys_type, delPhase, getKey, tnom_iso => newH2OIso
+
+   IMPLICIT NONE
+
+   PRIVATE
+
+   !=== FOR TRACERS:
+   PUBLIC :: init_infotrac_phy                             !--- Initialization of the tracers
+   PUBLIC :: tracers, type_trac, types_trac                !--- Full tracers database, tracers type keyword
+   PUBLIC :: nqtot,   nbtr,   nqo,   nqCO2,   nqtottr      !--- Main dimensions
+   PUBLIC :: conv_flg, pbl_flg                             !--- Convection & boundary layer activation keys
+
+   !=== FOR ISOTOPES: General
+   PUBLIC :: isotopes,  nbIso                              !--- Derived type, full isotopes families database + nb of families
+   PUBLIC :: isoSelect, ixIso                              !--- Isotopes family selection tool + selected family index
+   !=== FOR ISOTOPES: Specific to water
+   PUBLIC :: iH2O                                          !--- H2O isotopes index
+   !=== FOR ISOTOPES: Depending on the selected isotopes family
+   PUBLIC :: isotope, isoKeys                              !--- Selected isotopes database + associated keys (cf. getKey)
+   PUBLIC :: isoName, isoZone, isoPhas                     !--- Isotopes and tagging zones names, phases
+   PUBLIC :: niso,    nzone,   nphas,   ntiso              !---  " " numbers + isotopes & tagging tracers number
+   PUBLIC :: itZonIso                                      !--- iq = function(tagging zone idx, isotope idx)
+   PUBLIC :: iqIsoPha                                      !--- idx of tagging tracer in iName = function(isotope idx, phase idx)
+   PUBLIC :: isoCheck                                      !--- Run isotopes checking routines
+   !=== FOR BOTH TRACERS AND ISOTOPES
+   PUBLIC :: getKey                                        !--- Get a key from "tracers" or "isotope"
+
+   INTERFACE isoSelect; MODULE PROCEDURE isoSelectByIndex, isoSelectByName; END INTERFACE isoSelect
+
+!=== CONVENTIONS FOR TRACERS NUMBERS:
+!  |--------------------+-----------------------+-----------------+---------------+----------------------------|
+!  | water in different |    water tagging      |  water isotopes | other tracers | additional tracers moments |
+!  | phases: H2O_[gls]  |      isotopes         |                 |               |  for higher order schemes  |
+!  |--------------------+-----------------------+-----------------+---------------+----------------------------|
+!  |                    |                       |                 |               |                            |
+!  |<--     nqo      -->|<-- nqo*niso* nzone -->|<-- nqo*niso  -->|<--  nbtr   -->|<--        (nmom)        -->|         
+!  |                    |                                         |                                            |
+!  |                    |<-- nqo*niso*(nzone+1)  =   nqo*ntiso -->|<--    nqtottr = nbtr + nmom             -->|
+!  |                                                                              = nqtot - nqo*(ntiso+1)      |
+!  |                                                                                                           |
+!  |<--                        nqtrue  =  nbtr + nqo*(ntiso+1)                 -->|                            |
+!  |                                                                                                           |
+!  |<--                        nqtot   =  nqtrue + nmom                                                     -->|
+!  |                                                                                                           |
+!  |-----------------------------------------------------------------------------------------------------------|
+!  NOTES FOR THIS TABLE:
+!  * Used "niso", "nzone" and "ntiso" are components of "isotopes(ip)" for water (isotopes(ip)%parent == 'H2O'),
+!    since water is so far the sole tracers family, except passive CO2, removed from the main tracers table.
+!  * For water, "nqo" is equal to the more general field "isotopes(ip)%nphas".
+!  * "niso", "nzone", "ntiso", "nphas" are defined for other isotopic tracers families, if any.
+!
+!=== DERIVED TYPE EMBEDDING MOST OF THE TRACERS-RELATED QUANTITIES (LENGTH: nqtot)
+!    Each entry is accessible using "%" sign.
+!  |-------------+------------------------------------------------------+-------------+------------------------+
+!  |  entry      | Meaning                                              | Former name | Possible values        |
+!  |-------------+------------------------------------------------------+-------------+------------------------+
+!  | name        | Name (short)                                         | tname       |                        |
+!  | gen0Name    | Name of the 1st generation ancestor                  | /           |                        |
+!  | parent      | Name of the parent                                   | /           |                        |
+!  | longName    | Long name (with adv. scheme suffix) for outputs      | ttext       |                        |
+!  | type        | Type (so far: tracer or tag)                         | /           | tracer,tag             |
+!  | phase       | Phases list ("g"as / "l"iquid / "s"olid)             | /           | [g][l][s]              |
+!  | component   | Name(s) of the merged/cumulated section(s)           | /           | coma-separated names   |
+!  | iadv        | Advection scheme number                              | iadv        | 1-20,30 exc. 3-9,15,19 |
+!  | iGeneration | Generation (>=1)                                     | /           |                        |
+!  | isAdvected  | advected tracers flag (.TRUE. if iadv >= 0)          | /           | nqtrue  .TRUE. values  |
+!  | isInPhysics | tracers not extracted from the main table in physics | /           | nqtottr .TRUE. values  |
+!  | iqParent    | Index of the parent tracer                           | iqpere      | 1:nqtot                |
+!  | iqDescen    | Indexes of the childs       (all generations)        | iqfils      | 1:nqtot                |
+!  | nqDescen    | Number of the descendants   (all generations)        | nqdesc      | 1:nqtot                |
+!  | nqChilds    | Number of childs            (1st generation only)    | nqfils      | 1:nqtot                |
+!  | iso_iGroup  | Isotopes group index in isotopes(:)                  | /           | 1:nbIso                |
+!  | iso_iName   | Isotope  name  index in isotopes(iso_iGroup)%trac(:) | iso_indnum  | 1:niso                 |
+!  | iso_iZone   | Isotope  zone  index in isotopes(iso_iGroup)%zone(:) | zone_num    | 1:nzone                |
+!  | iso_iPhas   | Isotope  phase index in isotopes(iso_iGroup)%phas(:) | phase_num   | 1:nphas                |
+!  | keys        | key/val pairs accessible with "getKey" routine       | /           |                        |
+!  +-------------+------------------------------------------------------+-------------+------------------------+
+!
+!=== DERIVED TYPE EMBEDDING MOST OF THE ISOTOPES-RELATED QUANTITIES (LENGTH: nbIso, NUMBER OF ISOTOPES FAMILIES)
+!    Each entry is accessible using "%" sign.
+!  |-----------------+--------------------------------------------------+--------------------+-----------------+
+!  |  entry | length | Meaning                                          |    Former name     | Possible values |
+!  |-----------------+--------------------------------------------------+--------------------+-----------------+
+!  | parent          | Parent tracer (isotopes family name)             |                    |                 |
+!  | keys   | niso   | Isotopes keys/values pairs list + number         |                    |                 |
+!  | trac   | ntiso  | Isotopes + tagging tracers list + number         | / | ntraciso       |                 |
+!  | zone   | nzone  | Geographic tagging zones   list + number         | / | ntraceurs_zone |                 |
+!  | phase  | nphas  | Phases                     list + number         |                    | [g][l][s], 1:3  |
+!  | iqIsoPha        | Index in "qx"           = f(name(1:ntiso)),phas) | iqiso              | 1:nqtot         |
+!  | itZonIso        | Index in "trac(1:ntiso)"= f(zone, name(1:niso))  | index_trac         | 1:ntiso         |
+!  +-----------------+--------------------------------------------------+--------------------+-----------------+
+
+   !=== DIMENSIONS OF THE TRACERS TABLES AND OTHER SCALAR VARIABLES
+   INTEGER,                 SAVE :: nqtot,  &                   !--- Tracers nb in dynamics (incl. higher moments + H2O)
+                                    nbtr,   &                   !--- Tracers nb in physics  (excl. higher moments + H2O)
+                                    nqo,    &                   !--- Number of water phases
+                                    nbIso,  &                   !--- Number of available isotopes family
+                                    nqtottr, &                  !--- Number of tracers passed to phytrac (TO BE DELETED ?)
+                                    nqCO2                       !--- Number of tracers of CO2  (ThL)
+   CHARACTER(LEN=maxlen),   SAVE :: type_trac                   !--- Keyword for tracers type
+   CHARACTER(LEN=maxlen),   SAVE, ALLOCATABLE :: types_trac(:)  !--- Keyword for tracers type
+
+!$OMP THREADPRIVATE(nqtot, nbtr, nqo, nbIso, nqtottr, nqCO2, type_trac, types_trac)
+
+   !=== DERIVED TYPES EMBEDDING MOST INFORMATIONS ABOUT TRACERS AND ISOTOPES FAMILIES
+   TYPE(trac_type), TARGET, SAVE, ALLOCATABLE ::  tracers(:)    !=== TRACERS DESCRIPTORS VECTOR
+   TYPE(isot_type), TARGET, SAVE, ALLOCATABLE :: isotopes(:)    !=== ISOTOPES PARAMETERS VECTOR
+!$OMP THREADPRIVATE(tracers, isotopes)
+
+   !=== ALIASES FOR CURRENTLY SELECTED ISOTOPES FAMILY OF VARIABLES EMBEDDED IN THE VECTOR "isotopes"
+   TYPE(isot_type),         SAVE, POINTER :: isotope            !--- CURRENTLY SELECTED ISOTOPES FAMILY DESCRIPTOR
+   INTEGER,                 SAVE          :: ixIso, iH2O        !--- Index of the selected isotopes family and H2O family
+   LOGICAL,                 SAVE          :: isoCheck           !--- Flag to trigger the checking routines
+   TYPE(keys_type),         SAVE, POINTER :: isoKeys(:)         !--- ONE SET OF KEYS FOR EACH ISOTOPE (LISTED IN isoName)
+   CHARACTER(LEN=maxlen),   SAVE, POINTER :: isoName(:),   &    !--- ISOTOPES NAMES FOR THE CURRENTLY SELECTED FAMILY
+                                             isoZone(:),   &    !--- TAGGING ZONES  FOR THE CURRENTLY SELECTED FAMILY
+                                             isoPhas            !--- USED PHASES    FOR THE CURRENTLY SELECTED FAMILY
+   INTEGER,                 SAVE          ::  niso, nzone, &    !--- NUMBER OF ISOTOPES, TAGGING ZONES AND PHASES
+                                             nphas, ntiso       !--- NUMBER OF PHASES AND ISOTOPES + ISOTOPIC TAGGING TRACERS
+   INTEGER,                 SAVE, POINTER ::itZonIso(:,:), &    !--- INDEX IN "isoTrac" AS f(tagging zone idx,  isotope idx)
+                                            iqIsoPha(:,:)       !--- INDEX IN "qx"      AS f(isotopic tracer idx, phase idx)
+!$OMP THREADPRIVATE(isotope, ixIso,iH2O, isoCheck, isoKeys, isoName,isoZone,isoPhas, niso,nzone,nphas,ntiso, itZonIso,iqIsoPha)
+
+   !=== VARIABLES FOR ISOTOPES INITIALIZATION AND FOR INCA
+   INTEGER,          SAVE,    ALLOCATABLE ::conv_flg(:),  &     !--- Convection     activation ; needed for INCA        (nbtr)
+                                             pbl_flg(:)         !--- Boundary layer activation ; needed for INCA        (nbtr)
+!$OMP THREADPRIVATE(conv_flg, pbl_flg)
 
 #ifdef CPP_StratAer
-! nbtr_bin: number of aerosol bins for StratAer model
-! nbtr_sulgas: number of sulfur gases for StratAer model
-  INTEGER, SAVE :: nbtr_bin, nbtr_sulgas
-!$OMP THREADPRIVATE(nbtr_bin,nbtr_sulgas)
-  INTEGER, SAVE :: id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat
-!$OMP THREADPRIVATE(id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat)
-#endif
-
-! CRisi: nb traceurs pères= directement advectés par l'air
-  INTEGER, SAVE :: nqperes
-!$OMP THREADPRIVATE(nqperes)
-
-! Name variables
-  CHARACTER(len=20), ALLOCATABLE, DIMENSION(:), SAVE :: tname ! tracer short name for restart and diagnostics
-  CHARACTER(len=23), ALLOCATABLE, DIMENSION(:), SAVE :: ttext ! tracer long name for diagnostics
-!$OMP THREADPRIVATE(tname,ttext)
-
-!! iadv  : index of trasport schema for each tracer
-!  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE    :: iadv
-
-! niadv : vector keeping the coorspondance between all tracers(nqtot) treated in the 
-!         dynamic part of the code and the tracers (nbtr+2) used in the physics part of the code. 
-  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE    :: niadv ! equivalent dyn / physique
-!$OMP THREADPRIVATE(niadv)
-
-! CRisi: tableaux de fils
-  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE    :: nqfils
-  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE    :: nqdesc ! nombres de fils + nombre de tous les petits fils sur toutes les générations
-  INTEGER, SAVE :: nqdesc_tot
-  INTEGER, ALLOCATABLE, DIMENSION(:,:), SAVE    :: iqfils
-  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE    :: iqpere
-!$OMP THREADPRIVATE(nqfils,nqdesc,nqdesc_tot,iqfils,iqpere)
-
-! conv_flg(it)=0 : convection desactivated for tracer number it 
-  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE  :: conv_flg
-!$OMP THREADPRIVATE(conv_flg)
-
-! pbl_flg(it)=0  : boundary layer diffusion desactivaded for tracer number it 
-  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE  :: pbl_flg
-!$OMP THREADPRIVATE(pbl_flg)
-
-  CHARACTER(len=4),SAVE :: type_trac
-!$OMP THREADPRIVATE(type_trac)
-  CHARACTER(len=8),DIMENSION(:),ALLOCATABLE, SAVE :: solsym
-!$OMP THREADPRIVATE(solsym)
-   
-    ! CRisi: cas particulier des isotopes
-    LOGICAL,SAVE :: ok_isotopes,ok_iso_verif,ok_isotrac,ok_init_iso
-!$OMP THREADPRIVATE(ok_isotopes,ok_iso_verif,ok_isotrac,ok_init_iso)
-    INTEGER :: niso_possibles   
-    PARAMETER ( niso_possibles=5)
-    real, DIMENSION (niso_possibles),SAVE :: tnat,alpha_ideal
-!$OMP THREADPRIVATE(tnat,alpha_ideal)
-    LOGICAL, DIMENSION(niso_possibles),SAVE ::  use_iso
-!$OMP THREADPRIVATE(use_iso)
-    INTEGER, ALLOCATABLE, DIMENSION(:,:), SAVE ::  iqiso ! donne indice iq en fn de (ixt,phase) 
-!$OMP THREADPRIVATE(iqiso)
-    INTEGER, ALLOCATABLE, DIMENSION(:), SAVE ::  iso_num ! donne numéro iso entre 1 et niso_possibles en fn de nqtot
-!$OMP THREADPRIVATE(iso_num)
-    INTEGER, ALLOCATABLE, DIMENSION(:), SAVE ::  iso_indnum ! donne numéro iso entre 1 et niso effectif en fn de nqtot
-!$OMP THREADPRIVATE(iso_indnum)
-    INTEGER, ALLOCATABLE, DIMENSION(:), SAVE ::  zone_num ! donne numéro de la zone de tracage en fn de nqtot
-!$OMP THREADPRIVATE(zone_num)
-    INTEGER, ALLOCATABLE, DIMENSION(:), SAVE ::  phase_num ! donne numéro de la zone de tracage en fn de nqtot
-!$OMP THREADPRIVATE(phase_num)
-    INTEGER, DIMENSION(niso_possibles), SAVE :: indnum_fn_num ! donne indice entre entre 1 et niso en fonction du numéro d isotope entre 1 et niso_possibles
-!$OMP THREADPRIVATE(indnum_fn_num)
-    INTEGER, ALLOCATABLE, DIMENSION(:,:), SAVE ::  index_trac ! numéro ixt en fn izone, indnum entre 1 et niso
-!$OMP THREADPRIVATE(index_trac)
-    INTEGER,SAVE :: niso,ntraceurs_zone,ntraciso
-!$OMP THREADPRIVATE(niso,ntraceurs_zone,ntraciso)
- 
+  !=== SPECIFIC TO STRATOSPHERIC AEROSOLS (CK/OB)
+  INTEGER, SAVE ::  nbtr_bin, nbtr_sulgas         !--- number of aerosols bins and sulfur gases for StratAer model
+!$OMP THREADPRIVATE(nbtr_bin, nbtr_sulgas)
+  INTEGER, SAVE ::  id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat, id_TEST_strat
+!$OMP THREADPRIVATE(id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat, id_TEST_strat)
+#endif
+
 CONTAINS
 
-  SUBROUTINE init_infotrac_phy(nqtot_,nqo_,nbtr_,tname_,ttext_,type_trac_,&
-                               niadv_,conv_flg_,pbl_flg_,solsym_,&
-                               nqfils_,nqdesc_,nqdesc_tot_,iqfils_,iqpere_,&
-                               ok_isotopes_,ok_iso_verif_,ok_isotrac_,&
-                               ok_init_iso_,niso_possibles_,tnat_,&
-                               alpha_ideal_,use_iso_,iqiso_,iso_num_,&
-                               iso_indnum_,zone_num_,phase_num_,&
-                               indnum_fn_num_,index_trac_,&
-                               niso_,ntraceurs_zone_,ntraciso_&
+SUBROUTINE init_infotrac_phy(type_trac_, tracers_, isotopes_, nqtottr_, nqCO2_, pbl_flg_, conv_flg_)
+
+   USE print_control_mod, ONLY: prt_level, lunout
+
+   IMPLICIT NONE
+   CHARACTER(LEN=*),INTENT(IN) :: type_trac_
+   TYPE(trac_type), INTENT(IN) ::  tracers_(:)
+   TYPE(isot_type), INTENT(IN) :: isotopes_(:)
+   INTEGER,         INTENT(IN) :: nqtottr_
+   INTEGER,         INTENT(IN) :: nqCO2_
+   INTEGER,         INTENT(IN) :: conv_flg_(:)
+   INTEGER,         INTENT(IN) ::  pbl_flg_(:)
+
+   INTEGER :: iq, ixt
 #ifdef CPP_StratAer
-                               ,nbtr_bin_,nbtr_sulgas_&
-                               ,id_OCS_strat_,id_SO2_strat_,id_H2SO4_strat_,id_BIN01_strat_&
-#endif
-                               )
-
-    ! transfer information on tracers from dynamics to physics
-    USE print_control_mod, ONLY: prt_level, lunout
-    IMPLICIT NONE
-
-    INTEGER,INTENT(IN) :: nqtot_
-    INTEGER,INTENT(IN) :: nqo_
-    INTEGER,INTENT(IN) :: nbtr_
+   CHARACTER(LEN=maxlen), ALLOCATABLE :: tnames(:)
+#endif
+   CHARACTER(LEN=maxlen) :: modname="init_infotrac_phy"
+
+   type_trac = type_trac_
+   IF(strParse(type_trac, '|', types_trac)) CALL abort_gcm(modname,'can''t parse "type_trac = '//TRIM(type_trac)//'"',1)
+   tracers   = tracers_
+   isotopes  = isotopes_
+   nqtottr   = nqtottr_
+   nqCO2     = nqCO2_
+   pbl_flg   =  pbl_flg_
+   conv_flg  = conv_flg_
+   nqtot     = SIZE(tracers_)
+   nqo       = COUNT(delPhase(tracers%name)=='H2O' .AND. tracers%iGeneration==0 .AND. tracers%component=='lmdz')
+   nbtr      = SIZE(conv_flg)
+   nbIso     = SIZE(isotopes_)
+
+   !=== Determine selected isotopes class related quantities:
+   !    ixIso, isotope, niso,isoKeys, ntiso,isoName, nzone,isoZone, nphas,isoPhas, itZonIso, iqIsoPha, isoCheck
+   IF(.NOT.isoSelect('H2O')) iH2O = ixIso
+   IF(prt_level > 1) THEN
+      CALL msg('nqtot   = '//TRIM(int2str(nqtot)),   modname)
+      CALL msg('nbtr    = '//TRIM(int2str(nbtr )),   modname)
+      CALL msg('nqo     = '//TRIM(int2str(nqo  )),   modname)
+      CALL msg('niso    = '//TRIM(int2str(niso )),   modname)
+      CALL msg('ntiso   = '//TRIM(int2str(ntiso)),   modname)
+      CALL msg('nqtottr = '//TRIM(int2str(nqtottr)), modname)
+      CALL msg('nqCO2   = '//TRIM(int2str(nqCO2)),   modname)
+   END IF
+
 #ifdef CPP_StratAer
-    INTEGER,INTENT(IN) :: nbtr_bin_
-    INTEGER,INTENT(IN) :: nbtr_sulgas_
-    INTEGER,INTENT(IN) :: id_OCS_strat_
-    INTEGER,INTENT(IN) :: id_SO2_strat_
-    INTEGER,INTENT(IN) :: id_H2SO4_strat_
-    INTEGER,INTENT(IN) :: id_BIN01_strat_
-#endif
-    CHARACTER(len=20),INTENT(IN) :: tname_(nqtot_) ! tracer short name for restart and diagnostics
-    CHARACTER(len=23),INTENT(IN) :: ttext_(nqtot_) ! tracer long name for diagnostics
-    CHARACTER(len=4),INTENT(IN) :: type_trac_
-    INTEGER,INTENT(IN) :: niadv_ (nqtot_) ! equivalent dyn / physique
-    INTEGER,INTENT(IN) :: conv_flg_(nbtr_)
-    INTEGER,INTENT(IN) :: pbl_flg_(nbtr_)
-    CHARACTER(len=8),INTENT(IN) :: solsym_(nbtr_)
-    ! Isotopes:
-    INTEGER,INTENT(IN) :: nqfils_(nqtot_)
-    INTEGER,INTENT(IN) :: nqdesc_(nqtot_)
-    INTEGER,INTENT(IN) :: nqdesc_tot_
-    INTEGER,INTENT(IN) :: iqfils_(nqtot_,nqtot_)
-    INTEGER,INTENT(IN) :: iqpere_(nqtot_)
-    LOGICAL,INTENT(IN) :: ok_isotopes_
-    LOGICAL,INTENT(IN) :: ok_iso_verif_
-    LOGICAL,INTENT(IN) :: ok_isotrac_
-    LOGICAL,INTENT(IN) :: ok_init_iso_
-    INTEGER,INTENT(IN) :: niso_possibles_
-    REAL,INTENT(IN) :: tnat_(niso_possibles_)
-    REAL,INTENT(IN) :: alpha_ideal_(niso_possibles_)
-    LOGICAL,INTENT(IN) :: use_iso_(niso_possibles_)
-    INTEGER,INTENT(IN) :: iqiso_(ntraciso_,nqo_)
-    INTEGER,INTENT(IN) :: iso_num_(nqtot_)
-    INTEGER,INTENT(IN) :: iso_indnum_(nqtot_)
-    INTEGER,INTENT(IN) :: zone_num_(nqtot_)
-    INTEGER,INTENT(IN) :: phase_num_(nqtot_)
-    INTEGER,INTENT(IN) :: indnum_fn_num_(niso_possibles_)
-    INTEGER,INTENT(IN) :: index_trac_(ntraceurs_zone_,niso_)
-    INTEGER,INTENT(IN) :: niso_
-    INTEGER,INTENT(IN) :: ntraceurs_zone_
-    INTEGER,INTENT(IN) :: ntraciso_
-
-    CHARACTER(LEN=30) :: modname="init_infotrac_phy"
-
-    nqtot=nqtot_
-    nqo=nqo_
-    nbtr=nbtr_
-#ifdef CPP_StratAer
-    nbtr_bin=nbtr_bin_
-    nbtr_sulgas=nbtr_sulgas_
-    id_OCS_strat=id_OCS_strat_
-    id_SO2_strat=id_SO2_strat_
-    id_H2SO4_strat=id_H2SO4_strat_
-    id_BIN01_strat=id_BIN01_strat_
-#endif
-    ALLOCATE(tname(nqtot))
-    tname(:) = tname_(:)
-    ALLOCATE(ttext(nqtot))
-    ttext(:) = ttext_(:)
-    type_trac = type_trac_
-    ALLOCATE(niadv(nqtot))
-    niadv(:)=niadv_(:)
-    ALLOCATE(conv_flg(nbtr))
-    conv_flg(:)=conv_flg_(:)
-    ALLOCATE(pbl_flg(nbtr))
-    pbl_flg(:)=pbl_flg_(:)
-    ALLOCATE(solsym(nbtr))
-    solsym(:)=solsym_(:)
-  
-    IF(prt_level.ge.1) THEN
-      write(lunout,*) TRIM(modname)//": nqtot,nqo,nbtr",nqtot,nqo,nbtr
-    ENDIF
-    
-    ! Isotopes:
-    
-    ! First check that the "niso_possibles" has the correct value
-    IF (niso_possibles.ne.niso_possibles_) THEN
-      CALL abort_physic(modname,&
-           "wrong value for parameter niso_possibles in infotrac_phy",1)
-    ENDIF
-    
-    ok_isotopes=ok_isotopes_
-    ok_iso_verif=ok_iso_verif_
-    ok_isotrac=ok_isotrac_
-    ok_init_iso=ok_init_iso_
-    
-    niso=niso_
-    ntraceurs_zone=ntraceurs_zone_
-    ntraciso=ntraciso_
-    
-    IF (ok_isotopes) THEN
-      ALLOCATE(nqfils(nqtot))
-      nqfils(:)=nqfils_(:)
-      ALLOCATE(nqdesc(nqtot))
-      nqdesc(:)=nqdesc_(:)
-      nqdesc_tot=nqdesc_tot_
-      ALLOCATE(iqfils(nqtot,nqtot))
-      iqfils(:,:)=iqfils_(:,:)
-      ALLOCATE(iqpere(nqtot))
-      iqpere(:)=iqpere_(:)
-    
-      tnat(:)=tnat_(:)
-      alpha_ideal(:)=alpha_ideal_(:)
-      use_iso(:)=use_iso_(:)
-    
-      ALLOCATE(iqiso(ntraciso,nqo))
-      iqiso(:,:)=iqiso_(:,:)
-      ALLOCATE(iso_num(nqtot))
-      iso_num(:)=iso_num_(:)
-      ALLOCATE(iso_indnum(nqtot))
-      iso_indnum(:)=iso_indnum_(:)
-      ALLOCATE(zone_num(nqtot))
-      zone_num(:)=zone_num_(:)
-      ALLOCATE(phase_num(nqtot))
-      phase_num(:)=phase_num_(:)
-      
-      indnum_fn_num(:)=indnum_fn_num_(:)
-      
-      ALLOCATE(index_trac(ntraceurs_zone,niso))
-      index_trac(:,:)=index_trac_(:,:)
-    ENDIF ! of IF(ok_isotopes)
-  
-  END SUBROUTINE init_infotrac_phy
+   IF (ANY(types_trac == 'coag')) THEN
+      nbtr_bin    = COUNT([(tracers(iq)%name(1:3)=='BIN', iq=1, nqtot)])
+      nbtr_sulgas = COUNT([(tracers(iq)%name(1:3)=='GAS', iq=1, nqtot)])
+      tnames = PACK(tracers(:)%name, MASK=tracers(:)%isInPhysics)
+      id_BIN01_strat = strIdx(tnames, 'BIN01'   )
+      id_OCS_strat   = strIdx(tnames, 'GASOSC'  )
+      id_SO2_strat   = strIdx(tnames, 'GASSO2'  )
+      id_H2SO4_strat = strIdx(tnames, 'GASH2SO4')
+      id_TEST_strat  = strIdx(tnames, 'GASTEST' )
+      CALL msg('nbtr_bin       ='//TRIM(int2str(nbtr_bin      )), modname)
+      CALL msg('nbtr_sulgas    ='//TRIM(int2str(nbtr_sulgas   )), modname)
+      CALL msg('id_BIN01_strat ='//TRIM(int2str(id_BIN01_strat)), modname)
+      CALL msg('id_OCS_strat   ='//TRIM(int2str(id_OCS_strat  )), modname)
+      CALL msg('id_SO2_strat   ='//TRIM(int2str(id_SO2_strat  )), modname)
+      CALL msg('id_H2SO4_strat ='//TRIM(int2str(id_H2SO4_strat)), modname)
+      CALL msg('id_TEST_strat  ='//TRIM(int2str(id_TEST_strat )), modname)
+   END IF
+#endif
+#ifdef ISOVERIF
+   CALL msg('iso_iName = '//strStack(int2str(PACK(tracers(:)%iso_iName, MASK=tracers(:)%iso_iGroup==iH2O))), modname)
+#endif
+
+END SUBROUTINE init_infotrac_phy
+
+
+!==============================================================================================================================
+!=== THE ROUTINE isoSelect IS USED TO SWITCH FROM AN ISOTOPE FAMILY TO ANOTHER: ISOTOPES DEPENDENT PARAMETERS ARE UPDATED
+!     Single generic "isoSelect" routine, using the predefined index of the parent (fast version) or its name (first call).
+!==============================================================================================================================
+LOGICAL FUNCTION isoSelectByName(iName, lVerbose) RESULT(lerr)
+   IMPLICIT NONE
+   CHARACTER(LEN=*),  INTENT(IN)  :: iName
+   LOGICAL, OPTIONAL, INTENT(IN) :: lVerbose
+   INTEGER :: iIso
+   LOGICAL :: lV
+   lV = .FALSE.; IF(PRESENT(lVerbose)) lV = lVerbose
+   iIso = strIdx(isotopes(:)%parent, iName)
+   lerr = iIso == 0
+   IF(lerr) THEN
+      niso = 0; ntiso = 0; nzone=0; nphas=nqo; isoCheck=.FALSE.
+      CALL msg('no isotope family named "'//TRIM(iName)//'"', ll=lV)
+      RETURN
+   END IF
+   lerr = isoSelectByIndex(iIso, lV)
+END FUNCTION isoSelectByName
+!==============================================================================================================================
+LOGICAL FUNCTION isoSelectByIndex(iIso, lVerbose) RESULT(lerr)
+   IMPLICIT NONE
+   INTEGER,           INTENT(IN) :: iIso
+   LOGICAL, OPTIONAL, INTENT(IN) :: lVerbose
+   LOGICAL :: lv
+   lv = .FALSE.; IF(PRESENT(lVerbose)) lv = lVerbose
+   lerr = .FALSE.
+   IF(iIso == ixIso) RETURN                                      !--- Nothing to do if the index is already OK
+   lerr = iIso<=0 .OR. iIso>nbIso
+   CALL msg('Inconsistent isotopes family index '//TRIM(int2str(iIso))//': should be > 0 and <= '//TRIM(int2str(nbIso))//'"',&
+            ll=lerr .AND. lV)
+   IF(lerr) RETURN
+   ixIso = iIso                                                  !--- Update currently selected family index
+   isotope  => isotopes(ixIso)                                   !--- Select corresponding component
+   isoKeys  => isotope%keys;     niso     = isotope%niso
+   isoName  => isotope%trac;     ntiso    = isotope%ntiso
+   isoZone  => isotope%zone;     nzone    = isotope%nzone
+   isoPhas  => isotope%phase;    nphas    = isotope%nphas
+   itZonIso => isotope%itZonIso; isoCheck = isotope%check
+   iqIsoPha => isotope%iqIsoPha
+END FUNCTION isoSelectByIndex
+!==============================================================================================================================
+
 
 END MODULE infotrac_phy
