Index: /LMDZ6/branches/LMDZ-tracers/libf/dyn3d/check_isotopes.F90
===================================================================
--- /LMDZ6/branches/LMDZ-tracers/libf/dyn3d/check_isotopes.F90	(revision 3890)
+++ /LMDZ6/branches/LMDZ-tracers/libf/dyn3d/check_isotopes.F90	(revision 3891)
@@ -23,4 +23,5 @@
   modname = 'check_isotopes'
   IF(first) THEN
+    iH2O = -1
     IF(isoSelect('H2O')) RETURN
     ixH2O = strIdx(isoName,'H2[16]O')
@@ -29,4 +30,5 @@
     first = .FALSE.
   ELSE
+    IF(iH2O == -1)      RETURN
     IF(isoSelect(iH2O)) RETURN
   END IF
Index: /LMDZ6/branches/LMDZ-tracers/libf/dyn3d_common/infotrac.F90
===================================================================
--- /LMDZ6/branches/LMDZ-tracers/libf/dyn3d_common/infotrac.F90	(revision 3890)
+++ /LMDZ6/branches/LMDZ-tracers/libf/dyn3d_common/infotrac.F90	(revision 3891)
@@ -1,8 +1,8 @@
 MODULE infotrac
 
-  USE       strings_mod, ONLY: msg, find, strIdx,  strFind,  strHead, dispTable, cat, get_in,  &
-                              fmsg, test, int2str, strParse, strTail, strReduce, strStack, modname, testFile
+  USE       strings_mod, ONLY: msg, find, strIdx,  strFind,  strHead, dispTable, testFile, cat, get_in,  &
+                              fmsg, test, int2str, strParse, strTail, strReduce, strStack, modname
   USE readTracFiles_mod, ONLY: readTracersFiles, getKey_init, nphases, delPhase, aliasTracer, &
-                        tran0, readIsotopesFile, getKey, known_phases, addPhase, indexUpdate
+                        tran0, readIsotopesFile, getKey, known_phases, addPhase, indexUpdate, initIsotopes
   USE trac_types_mod,    ONLY: tra, iso, kys
 
@@ -23,4 +23,5 @@
   PUBLIC :: iso, isotopes, nbIso                           !--- Derived type, full isotopes families database + nb of families
   PUBLIC :: isoSelect , ixIso                              !--- Isotopes family selection tool + selected family index
+  PUBLIC :: qprntmin, massqmin, ratiomin                   !--- Min. values
   !=== FOR ISOTOPES: Specific to H2O isotopes
   PUBLIC :: iH2O, tnat, alpha_ideal                        !--- H2O isotopes index, natural abundance, fractionning coeff.
@@ -31,5 +32,4 @@
   PUBLIC :: iZonIso, iTraPha                               !--- 2D index tables to get "iq" index
   PUBLIC :: isoCheck                                       !--- Run isotopes checking routines
-
   !=== FOR BOTH TRACERS AND ISOTOPES
   PUBLIC :: getKey                                         !--- Get a key from "tracers" or "isotope"
@@ -75,4 +75,5 @@
 !  | type       | Type (so far: tracer or tag)                    | /           | tracer,tag             |
 !  | phas       | Phases list ("g"as / "l"iquid / "s"olid)        | /           | [g][l][s]              |
+!  | comp       | Name(s) of the merged/cumulated section(s)      | /           | coma-separated names   |
 !  | iadv       | Advection scheme number                         | iadv        | 1-20,30 exc. 3-9,15,19 |
 !  | igen       | Generation (>=1)                                | /           |                        |
@@ -103,4 +104,5 @@
 
 
+  REAL, PARAMETER :: qprntmin=1.E-12, massqmin=1.E-12, ratiomin=1.E-12
 
   !=== DIMENSIONS OF THE TRACERS TABLES AND OTHER SCALAR VARIABLES
@@ -113,20 +115,20 @@
 
   !=== DERIVED TYPES EMBEDDING MOST INFORMATIONS ABOUT TRACERS AND ISOTOPES FAMILIES
-  TYPE(tra), TARGET,  SAVE, ALLOCATABLE ::  tracers(:)      !=== TRACERS DESCRIPTORS VECTOR
-  TYPE(iso), TARGET,  SAVE, ALLOCATABLE :: isotopes(:)      !=== ISOTOPES PARAMETERS VECTOR
+  TYPE(tra), TARGET,  SAVE, ALLOCATABLE ::  tracers(:)     !=== TRACERS DESCRIPTORS VECTOR
+  TYPE(iso), 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(iso),          SAVE, POINTER :: isotope             !--- CURRENTLY SELECTED ISOTOPES FAMILY DESCRIPTOR
-  INTEGER,            SAVE          :: ixIso, iH2O         !--- Index of the selected isotopes family and H2O family
-  LOGICAL,            SAVE, POINTER :: isoCheck            !--- Flag to trigger the checking routines
-  TYPE(kys),          SAVE, POINTER :: isoKeys(:)          !--- ONE SET OF KEYS FOR EACH ISOTOPE (LISTED IN isoName)
-  CHARACTER(LEN=256), 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, nzon, npha, & !--- NUMBER OF ISOTOPES, TAGGING ZONES AND PHASES
-                                       nitr                !--- NUMBER OF ISOTOPES + ISOTOPIC TAGGING TRACERS
-  INTEGER,            SAVE, POINTER :: iZonIso(:,:)        !--- INDEX IN "isoTrac" AS f(tagging zone, isotope)
-  INTEGER,            SAVE, POINTER :: iTraPha(:,:)        !=== INDEX IN "isoTrac" AS f(isotopic tracer, phase)
+  TYPE(iso),          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(kys),          SAVE, POINTER     :: isoKeys(:)      !--- ONE SET OF KEYS FOR EACH ISOTOPE (LISTED IN isoName)
+  CHARACTER(LEN=256), 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, nzon,   & !--- NUMBER OF ISOTOPES, TAGGING ZONES AND PHASES
+                                           npha, nitr      !--- NUMBER OF PHASES AND ISOTOPES + ISOTOPIC TAGGING TRACERS
+  INTEGER,            SAVE, POINTER     :: iZonIso(:,:)    !--- INDEX IN "isoTrac" AS f(tagging zone, isotope)
+  INTEGER,            SAVE, POINTER     :: iTraPha(:,:)    !--- INDEX IN "isoTrac" AS f(isotopic tracer, phase)
 !$OMP THREADPRIVATE(isotope, ixIso,iH2O, isoCheck, isoKeys, isoName,isoZone,isoPhas, niso,nzon,npha,nitr, iZonIso,iTraPha)
 
@@ -137,7 +139,7 @@
                                             pbl_flg(:),  & !--- Boundary layer activation ; needed for INCA        (nbtr)
                                          itr_indice(:),  & !--- Indexes of the tracers passed to phytrac        (nqtottr)
-                                              niadv(:)
+                                              niadv(:)     !--- Indexes of true tracers  (<=nqtot, such that iadv(idx)>0)
   CHARACTER(LEN=8),   SAVE, ALLOCATABLE ::   solsym(:)     !--- Names from INCA                                    (nbtr)
-!OMP THREADPRIVATE(tnat, alpha_ideal, conv_flg, pbl_flg, itr_indice, solsym)
+!OMP THREADPRIVATE(tnat, alpha_ideal, conv_flg, pbl_flg, itr_indice, niadv, solsym)
 
 #ifdef CPP_StratAer
@@ -153,4 +155,5 @@
 #ifdef REPROBUS
   USE chem_rep,    ONLY: Init_chem_rep_trac
+  IMPLICIT NONE
 #endif
 !==============================================================================================================================
@@ -178,25 +181,19 @@
 ! Local variables
   INTEGER, ALLOCATABLE :: hadv(:), hadv_inca(:), &                   !--- Horizontal/vertical transport scheme number
-                          vadv(:), vadv_inca(:)                      !--- + specific INCA versions
-  CHARACTER(LEN=1)   :: ph                                           !--- Phase
+                          vadv(:), vadv_inca(:)                      !---   + specific INCA versions
   CHARACTER(LEN=2)   ::   suff(9)                                    !--- Suffixes for schemes of order 3 or 4 (Prather)
-  CHARACTER(LEN=3)   :: descrq(30)                                   !--- Advection scheme description
-  CHARACTER(LEN=4)   :: oldH2O(3)                                    !--- Old water names
-  CHARACTER(LEN=256) :: newH2O, iname, isoPhase                      !--- New water and isotope names, phases list
+  CHARACTER(LEN=3)   :: descrq(30)                                   !--- Advection scheme description tags
+  CHARACTER(LEN=4)   :: oldH2O(3)                                    !--- Old water name for the three phases
+  CHARACTER(LEN=256) :: newH2O                                       !--- New water name
   CHARACTER(LEN=256) :: msg1, msg2                                   !--- Strings for messages
-  CHARACTER(LEN=256), ALLOCATABLE, DIMENSION(:) :: &                 !--- Temporary storage
-             isoName, isoZone, tra0, zon0, tag0, n, p, z, str
+  CHARACTER(LEN=256), ALLOCATABLE :: str(:)                          !--- Temporary storage
   INTEGER :: fType                                                   !--- Tracers description file type ; 0: none
                                                                      !--- 1: "traceur.def"  2: "tracer.def"  3: "tracer_*.def"
   INTEGER :: nqtrue                                                  !--- Tracers nb from tracer.def (no higher order moments)
-  INTEGER :: iad                                                     !--- Advection scheme
-  INTEGER :: iH2O                                                    !--- Index in "isotopes(:)" of H2O family
-  INTEGER :: ic,ip,iq,jq, it,nt, im,nm, ix, iz, niso, nzone, ntiso   !--- Indexes and temporary variables
-  LOGICAL, ALLOCATABLE :: lisoGen2(:), &                             !--- Mask for second generation isotopes
-                          lisoName(:), &                             !--- Mask for water isotopes
-                          lisoZone(:), ll(:)                         !--- Mask for water isotopes tagging tracers
+  INTEGER :: iad                                                     !--- Advection scheme number
+  INTEGER :: ic, ip, iq, jq, it, nt, im, nm, ix, iz                  !--- Indexes and temporary variables
   LOGICAL :: lerr
   TYPE(tra), ALLOCATABLE, TARGET :: ttr(:)
-  TYPE(tra), POINTER             :: t1, t(:)
+  TYPE(tra), POINTER             :: t1
   TYPE(iso), POINTER             :: s
 !------------------------------------------------------------------------------------------------------------------------------
@@ -204,5 +201,4 @@
 !------------------------------------------------------------------------------------------------------------------------------
   modname = 'infotrac_init'
-  type_trac='lmdz'!'lmdz,inca'
   suff          = ['x ','y ','z ','xx','xy','xz','yy','yz','zz']
   descrq( 1: 2) = ['LMV','BAK']
@@ -310,5 +306,5 @@
         IF(nqo/=2 .AND. nqo/=3) CALL abort_gcm(modname,TRIM(msg1),1)
 #ifdef INCA
-        CALL Init_chem_inca_trac(nbtr)                                   !--- Get nbtr from INCA
+        CALL Init_chem_inca_trac(nbtr)                               !--- Get nbtr from INCA
 #endif
         ALLOCATE(hadv_inca(nbtr), vadv_inca(nbtr), conv_flg(nbtr), pbl_flg(nbtr), solsym(nbtr))
@@ -317,5 +313,5 @@
         CALL init_transport(hadv_inca, vadv_inca, conv_flg,   pbl_flg,   solsym)
 #endif
-        nqtrue = nbtr + nqo                                              !--- Total number of tracers
+        nqtrue = nbtr + nqo                                          !--- Total number of tracers
         ALLOCATE(ttr(nqtrue)); ttr(1:nqo) = tracers(1:nqo)
         DO iq = nqo+1, nqtrue
@@ -405,4 +401,7 @@
     CALL msg('The total number of tracers needed is '//TRIM(int2str(nqtot)))
   END IF
+  CALL msg('nqtot = '//TRIM(int2str(nqtot)))
+  CALL msg('nbtr  = '//TRIM(int2str(nbtr)))
+  CALL msg('nqo   = '//TRIM(int2str(nqo)))
   ALLOCATE(ttr(nqtot))
 
@@ -424,5 +423,5 @@
     t1%lnam = t1%name; IF(iad /= 0) t1%lnam=TRIM(t1%name)//descrq(iad)
 
-    !--- Defining most fields of the tracer derived type
+    !--- Define most fields of the tracers derived type
     ttr(jq)%name = t1%name
     ttr(jq)%nam1 = t1%nam1
@@ -478,79 +477,20 @@
 
   CALL MOVE_ALLOC(FROM=ttr, TO=tracers)
-  t => tracers
-
-  !=== VARIABLES RELATED TO GENERATIONS
-  niadv = PACK( [(iq,iq=1,nqtot)], MASK=t(:)%iadv>=0)           !--- Indexes of "true" tracers
-
-  p = PACK(delPhase(t%prnt),MASK=t%type=='tracer'.AND.t%igen==2)!--- Parents of 2nd generation isotopes
-  CALL strReduce(p, nbIso)
-  ALLOCATE(isotopes(nbIso))
-
-  IF(nbIso==0) RETURN                                           !=== NO ISOTOPES: FINISHED
-
-  CALL msg('Isotopes families required: '//strStack(p))
-
-  !--- ISOTOPES RELATED VARIABLES ; NULL OR EMPTY IF NO ISOTOPES
-  isotopes(:)%prnt = p
-  DO ip = 1, SIZE(p)                                            !--- Loop on isotopes categories
-    s => isotopes(ip)
-    iname = s%prnt
-
-    !=== Geographic tagging tracers descending on tracer "iname": mask, names, number
-    lisoZone = t(:)%type=='tag'    .AND. delPhase(t(:)%nam1) == iname .AND. t(:)%igen == 3
-    s%zone = PACK(strTail(t(:)%name,'_'), MASK = lisoZone)      !--- Tagging zones names  for isotopes category "iname"
-    CALL strReduce(s%zone)
-    s%nzon = SIZE(s%zone)                                       !--- Tagging zones number for isotopes category "iname"
-
-    !=== Isotopes childs of tracer "iname": mask, names, number (same for each phase of "iname")
-    lisoName = t(:)%type=='tracer' .AND. delPhase(t(:)%prnt) == iname .AND. t(:)%phas == 'g'
-    ALLOCATE(s%keys(COUNT(lisoName)))
-    s%keys(:)%name = PACK(delPhase(t(:)%name), MASK = lisoName)    !--- Effectively found isotopes of "iname"
-    s%niso = SIZE(s%keys)                                       !--- Number of "effectively found isotopes of "iname"
-    s%trac = [s%keys%name, ((TRIM(s%keys(it)%name)//'_'//TRIM(s%zone(iz)), it=1, s%niso), iz=1, s%nzon)]
-    s%nitr = SIZE(s%trac)                                       !--- " + their geographic tracers               [ntraciso]
-
-    !=== Phases for tracer "iname"
-    s%phas = ''
-    DO ix = 1, nphases; IF(strIdx(t%name,addPhase(iname, known_phases(ix:ix))) /= 0) s%phas = TRIM(s%phas)//ph; END DO
-    s%npha = LEN_TRIM(s%phas)                                   !--- Equal to "nqo" for water
-
-    !=== Tables giving the index in a table of effectively found items for each dynamical tracer (1<=iq<=nqtot)
-    DO iq = 1, nqtot
-      t1 => tracers(iq)
-      IF(t1%nam1 /= iname) CYCLE                                 !--- Only deal with tracers descending on "iname"
-      t1%iso_igr = ip                                            !--- Index of isotopes family in list "isotopes(:)%prnt"
-      t1%iso_num = strIdx(s%trac, delPhase(strHead(t1%name,'_')))!--- Index of current isotope       in effective isotopes list
-      t1%iso_zon = strIdx(s%zone,          strTail(t1%name,'_') )!--- Index of current isotope zone  in effective zones    list
-      t1%iso_pha =  INDEX(s%phas,TRIM(t1%phas))                  !--- Index of current isotope phase in effective phases   list
-      IF(t1%igen /= 3) t1%iso_zon = 0                            !--- Skip possible generation 2 tagging tracers
-    END DO
-
-    !=== Table used to get iq (index in dyn array, size nqtot) from the isotope and phase indexes ; the full isotopes list
-    !    (including tagging tracers) is sorted this way:  iso1, iso2, ..., iso1_zone1, iso2_zone1, ..., iso1_zoneN, iso2_zoneN
-    s%iTraPha = RESHAPE( [( (strIdx(t(:)%name,  addPhase(s%trac(it),s%phas(ip:ip))),     it=1, s%nitr), ip=1, s%npha)], &
-                         [s%nitr, s%npha] )
-
-    !=== Table used to get ix (index in tagging tracers isotopes list, size nitr) from the zone and isotope indexes
-    s%iZonIso = RESHAPE( [( (strIdx(s%trac(:), TRIM(s%trac(it))//'_'//TRIM(s%zone(iz))), iz=1, s%nzon), it=1, s%niso)], &
-                         [s%nzon, s%niso] )
-  END DO
-
-  !=== Indexes, in dynamical tracers list, of the tracers transmitted to phytrac (nqtottr non-vanishing elements)
-  ll = delPhase(t%name)/='H2O' .AND. t%iso_num ==0              !--- Mask of tracers passed to the physics
-  t(:)%itr = UNPACK([(iq,iq=1,COUNT(ll))], ll, [(0, iq=1, nqtot)])
-  itr_indice = PACK(t(:)%itr, MASK = t(:)%itr/=0)               !--- Might be removed (t%itr should be enough)
-
-  !=== READ PHYSICAL PARAMETERS FROM "isotopes_params.def" FILE
+
+  !=== Indexes of: "true" tracers, in the dynamical table of tracers transmitted to phytrac (nqtottr non-vanishing elements)
+  niadv      = PACK([(iq,iq=1,nqtot)], MASK=tracers(:)%iadv>=0) !--- Indexes of "true" tracers
+  itr_indice = PACK(tracers(:)%itr,    MASK=tracers(:)%itr /=0) !--- Might be removed (t%itr should be enough)
+
+  CALL initIsotopes(tracers, isotopes)
+  nbIso = SIZE(isotopes); IF(nbIso==0) RETURN                   !--- No isotopes: finished.
+
+
+  !=== READ PHYSICAL PARAMETERS FROM "isotopes_params.def" FILE SPECIFIC TO WATER ISOTOPES
   !    DONE HERE, AND NOT ONLY IN "infotrac_phy", BECAUSE SOME PHYSICAL PARAMS ARE NEEDED FOR RESTARTS (tnat AND alpha_ideal)
-  IF(readIsotopesFile('isotopes_params.def',isotopes)) CALL abort_gcm(modname,'Problem when reading isotopes parameters',1)
-print*,'coincoin'
-
-  !=== Specific to water
   CALL getKey_init(tracers, isotopes)
   IF(isoSelect('H2O')) RETURN                                   !--- Select water isotopes ; finished if no water isotopes.
   iH2O = ixIso                                                  !--- Keep track of water family index
-  lerr = getKey('tnat' ,tnat,        isoName)
-  lerr = getKey('alpha',alpha_ideal, isoName)
+  IF(getKey('tnat' ,tnat,        isoName(1:niso))) CALL abort_gcm(modname,'can''t read "tnat"',1)
+  IF(getKey('alpha',alpha_ideal, isoName(1:niso))) CALL abort_gcm(modname,'can''t read "alpha_ideal"',1)
   CALL msg('end')
 
@@ -560,26 +500,40 @@
 !==============================================================================================================================
 !=== THE ROUTINE isoSelect IS USED TO SWITCH FROM AN ISOTOPE FAMILY TO ANOTHER: ISOTOPES DEPENDENT PARAMETERS ARE UPDATED
-!     Singe generic "isoSelect" routine, using the predefined parent index (fast version) or its name (first time).
+!     Singe generic "isoSelect" routine, using the predefined parent index (fast version) or its name (first call).
 !==============================================================================================================================
-LOGICAL FUNCTION isoSelectByName(iName) RESULT(lerr)
-  CHARACTER(LEN=*), INTENT(IN)  :: iName
+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(:)%prnt, iName)
-  IF(test(fmsg(iIso == 0,'no isotope family named "'//TRIM(iName)//'"'),lerr)) RETURN
-  IF(isoSelectByIndex(iIso)) RETURN
+  lerr = iIso == 0
+  CALL msg(lerr .AND. lV, 'no isotope family named "'//TRIM(iName)//'"')
+  IF(lerr) RETURN
+  lerr = isoSelectByIndex(iIso)
 END FUNCTION isoSelectByName
 !==============================================================================================================================
-LOGICAL FUNCTION isoSelectByIndex(iIso) RESULT(lerr)
-  INTEGER, INTENT(IN) :: iIso
+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
-  IF(test(fmsg(iIso<=0 .OR. iIso>=nbIso,'Inconsistent isotopes family index '//TRIM(int2str(iIso))),lerr)) RETURN
+  lerr = iIso<=0 .OR. iIso>nbIso
+  CALL msg(lerr .AND. lV, 'Inconsistent isotopes family index '//TRIM(int2str(iIso))//': should be > 0 and <= ' &
+                                                               //TRIM(int2str(nbIso))//'"')
+  IF(lerr) RETURN
   ixIso = iIso                                                  !--- Update currently selected family index
   isotope => isotopes(ixIso)                                    !--- Select corresponding component
-  !--- VARIOUS ALIASES
-  isoKeys => isotope%keys; niso = isotope%niso
-  isoName => isotope%trac; nitr = isotope%nitr; isoCheck => isotope%check
-  isoZone => isotope%zone; nzon = isotope%nzon; iZonIso  => isotope%iZonIso
-  isoPhas => isotope%phas; npha = isotope%npha; iTraPha  => isotope%iTraPha
+  isoKeys => isotope%keys;    niso     = isotope%niso
+  isoName => isotope%trac;    nitr     = isotope%nitr
+  isoZone => isotope%zone;    nzon     = isotope%nzon
+  isoPhas => isotope%phas;    npha     = isotope%npha
+  iZonIso => isotope%iZonIso; isoCheck = isotope%check
+  iTraPha => isotope%iTraPha
 END FUNCTION isoSelectByIndex
 !==============================================================================================================================
Index: /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/check_isotopes_loc.F90
===================================================================
--- /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/check_isotopes_loc.F90	(revision 3890)
+++ /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/check_isotopes_loc.F90	(revision 3891)
@@ -26,4 +26,5 @@
   modname = 'check_isotopes'
   IF(first) THEN
+    iH2O = -1
     IF(isoSelect('H2O')) RETURN
     ixH2O = strIdx(isoName,'H2[16]O')
@@ -32,4 +33,5 @@
     first = .FALSE.
   ELSE
+    IF(iH2O == -1)      RETURN
     IF(isoSelect(iH2O)) RETURN
   END IF
Index: /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/dynetat0_loc.F90
===================================================================
--- /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/dynetat0_loc.F90	(revision 3890)
+++ /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/dynetat0_loc.F90	(revision 3891)
@@ -46,4 +46,5 @@
   REAL,             ALLOCATABLE :: ucov_glo(:,:),    q_glo(:,:), phis_glo(:)
   REAL,             ALLOCATABLE :: teta_glo(:,:)
+  TYPE(tra), POINTER :: tr
 !-------------------------------------------------------------------------------
   modname="dynetat0_loc"
Index: /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/dynredem_loc.F90
===================================================================
--- /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/dynredem_loc.F90	(revision 3890)
+++ /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/dynredem_loc.F90	(revision 3891)
@@ -151,5 +151,5 @@
   CALL cre_var(nid,"teta" ,"Temperature",[rlonvID,rlatuID,sID,timID])
   DO iq=1,nqtot
-    CALL cre_var(nid,tracers(iq)%name(iq),tracers(iq)%lnam,[rlonvID,rlatuID,sID,timID])
+    CALL cre_var(nid,tracers(iq)%name,tracers(iq)%lnam,[rlonvID,rlatuID,sID,timID])
   END DO
   CALL cre_var(nid,"masse","Masse d air"    ,[rlonvID,rlatuID,sID,timID])
Index: /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/iniacademic_loc.F90
===================================================================
--- /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/iniacademic_loc.F90	(revision 3890)
+++ /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/iniacademic_loc.F90	(revision 3891)
@@ -283,5 +283,5 @@
               IF(niso > 0 .AND. tr%iso_num > 0) THEN
                 IF(tr%iso_zon == 0) &
-                  q(ijb_u:ije_u,:,i) = q(ijb_u:ije_u,:,tr%iprnt)         *        tnat(tr%iso_num)
+                  q(ijb_u:ije_u,:,i) = q(ijb_u:ije_u,:,tr%iprnt)         *        tnat(tr%iso_num) &
                                      *(q(ijb_u:ije_u,:,tr%iprnt)/30.e-3)**(alpha_ideal(tr%iso_num)-1)
                 IF(tr%iso_zon == 1) &
Index: /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/qminimum_loc.F
===================================================================
--- /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/qminimum_loc.F	(revision 3890)
+++ /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/qminimum_loc.F	(revision 3891)
@@ -4,5 +4,5 @@
       SUBROUTINE qminimum_loc( q,nqtot,deltap )
       USE parallel_lmdz
-      USE infotrac, ONLY: nitr, iTraPha, qperemin ! CRisi 23nov2020
+      USE infotrac, ONLY: nitr, iTraPha, qprntmin ! CRisi 23nov2020
       IMPLICIT none
 c
@@ -166,5 +166,5 @@
 !              write(lunout,*) 'i,k,q_follow(i,k-1,iq_vap)=',
 !     :                 i,k,q_follow(i,k-1,iq_vap)          
-              if (q_follow(i,k-1,iq_vap).lt.qperemin) then
+              if (q_follow(i,k-1,iq_vap).lt.qprntmin) then
                 write(lunout,*) 'tmp qmin: on stoppe'
                 write(lunout,*) 'zx_pump(i)=',zx_pump(i)
Index: /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/vlsplt_loc.F
===================================================================
--- /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/vlsplt_loc.F	(revision 3890)
+++ /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/vlsplt_loc.F	(revision 3891)
@@ -14,6 +14,6 @@
 c   --------------------------------------------------------------------
       USE parallel_lmdz
-      USE infotrac, ONLY : nqtot,tracers, tra,         ! CRisi                 &
-     &                     qperemin,masseqmin,ratiomin ! MVals et CRisi
+      USE infotrac, ONLY : nqtot,tracers, tra,          ! CRisi                &
+     &                     qprntmin, massqmin, ratiomin ! MVals et CRisi
       IMPLICIT NONE
 c
@@ -346,6 +346,6 @@
            ! les calcule donc que de ijb à ije
            !MVals: veiller a ce qu'on n'ait pas de denominateur nul
-           masse(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),masseqmin)
-           if (q(ij,l,iq).gt.qperemin) then ! modif 13 nov 2020
+           masse(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),massqmin)
+           if (q(ij,l,iq).gt.qprntmin) then ! modif 13 nov 2020
              Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
            else
@@ -369,5 +369,5 @@
          DO ij=ijb+1,ije
             !MVals: veiller a ce qu'on n'ait pas de denominateur nul
-            new_m=max(masse(ij,l,iq)+u_m(ij-1,l)-u_m(ij,l),masseqmin)
+            new_m=max(masse(ij,l,iq)+u_m(ij-1,l)-u_m(ij,l),massqmin)
             q(ij,l,iq)=(q(ij,l,iq)*masse(ij,l,iq)+
      &        u_mq(ij-1,l)-u_mq(ij,l))
@@ -425,6 +425,6 @@
 c   --------------------------------------------------------------------
       USE parallel_lmdz
-      USE infotrac, ONLY : nqtot, tracers, tra,        ! CRisi                 &
-     &                     qperemin,masseqmin,ratiomin ! MVals et CRisi    
+      USE infotrac, ONLY : nqtot, tracers, tra,         ! CRisi                &
+     &                     qprntmin, massqmin, ratiomin ! MVals et CRisi    
       USE comconst_mod, ONLY: pi
       IMPLICIT NONE
@@ -759,5 +759,5 @@
           DO ij=ijbm,ijem 
            !MVals: veiller a ce qu'on n'ait pas de denominateur nul
-           masse(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),masseqmin)
+           masse(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),massqmin)
           enddo !DO ij=ijbm,ijem 
 
@@ -765,5 +765,5 @@
          DO ij=ijb,ije
            !MVals: veiller a ce qu'on n'ait pas de denominateur nul
-           if (q(ij,l,iq).gt.qperemin) then ! modif 13 nov 2020
+           if (q(ij,l,iq).gt.qprntmin) then ! modif 13 nov 2020
              Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
            else
@@ -901,6 +901,6 @@
       USE parallel_lmdz
       USE vlz_mod
-      USE infotrac, ONLY : nqtot, tracers, tra,        ! CRisi                 &
-     &                     qperemin,masseqmin,ratiomin ! MVals et CRisi
+      USE infotrac, ONLY : nqtot, tracers, tra,         ! CRisi                &
+     &                     qprntmin, massqmin, ratiomin ! MVals et CRisi
       
       IMPLICIT NONE
@@ -949,9 +949,10 @@
 !$OMP THREADPRIVATE(first)
 
-      !REAL masseq(ijb_u:ije_u,llm,nqtot),Ratio(ijb_u:ije_u,llm,nqtot) ! CRisi
+      !REAL massq(ijb_u:ije_u,llm,nqtot),Ratio(ijb_u:ije_u,llm,nqtot) ! CRisi
       ! Ces varibles doivent être déclarées en pointer et en save dans
       ! vlz_loc si on veut qu'elles soient vues par tous les threads.  
       INTEGER ichld,iq2 ! CRisi
-
+      TYPE(tra), POINTER :: tr
+      tr => tracers(iq)
 
       IF (first) THEN
@@ -1174,6 +1175,6 @@
           DO ij=ijb,ije
            !MVals: veiller a ce qu'on n'ait pas de denominateur nul
-           masse(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),masseqmin)
-           if (q(ij,l,iq).gt.qperemin) then
+           masse(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),massqmin)
+           if (q(ij,l,iq).gt.qprntmin) then
              Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
            else
Index: /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/vlspltqs_loc.F
===================================================================
--- /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/vlspltqs_loc.F	(revision 3890)
+++ /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/vlspltqs_loc.F	(revision 3891)
@@ -12,6 +12,6 @@
 c   --------------------------------------------------------------------
       USE parallel_lmdz
-      USE infotrac, ONLY : nqtot, tracers, tra,        ! CRisi                 &
-     &                     qperemin,masseqmin,ratiomin ! MVals et CRisi
+      USE infotrac, ONLY : nqtot, tracers, tra,         ! CRisi                &
+     &                     qprntmin, massqmin, ratiomin ! MVals et CRisi
       IMPLICIT NONE
 c
@@ -349,6 +349,6 @@
           DO ij=ijb,ije
            !MVals: veiller a ce qu'on n'ait pas de denominateur nul
-           masse(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),masseqmin)
-           if (q(ij,l,iq).gt.qperemin) then ! modif 13 nov 2020
+           masse(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),massqmin)
+           if (q(ij,l,iq).gt.qprntmin) then ! modif 13 nov 2020
              Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
            else
@@ -374,5 +374,5 @@
          DO ij=ijb+1,ije
             !MVals: veiller a ce qu'on n'ait pas de denominateur nul
-            new_m=max(masse(ij,l,iq)+u_m(ij-1,l)-u_m(ij,l),masseqmin)
+            new_m=max(masse(ij,l,iq)+u_m(ij-1,l)-u_m(ij,l),massqmin)
             q(ij,l,iq)=(q(ij,l,iq)*masse(ij,l,iq)+
      &      u_mq(ij-1,l)-u_mq(ij,l))
@@ -428,6 +428,6 @@
 c   --------------------------------------------------------------------
       USE parallel_lmdz
-      USE infotrac, ONLY : nqtot, tracers, tra,        ! CRisi                 &
-     &                     qperemin,masseqmin,ratiomin ! MVals et CRisi
+      USE infotrac, ONLY : nqtot, tracers, tra,         ! CRisi                &
+     &                     qprntmin, massqmin, ratiomin ! MVals et CRisi
       USE comconst_mod, ONLY: pi
       IMPLICIT NONE
@@ -759,5 +759,5 @@
           DO ij=ijbm,ijem 
            !MVals: veiller a ce qu'on n'ait pas de denominateur nul
-           masse(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),masseqmin)
+           masse(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),massqmin)
           enddo !DO ij=ijbm,ijem 
 
@@ -766,5 +766,5 @@
            !MVals: veiller a ce qu'on n'ait pas de denominateur nul
            !write(lunout,*) 'ij,l,q(ij,l,iq)=',ij,l,q(ij,l,iq)
-           if (q(ij,l,iq).gt.qperemin) then ! modif 13 nov 2020
+           if (q(ij,l,iq).gt.qprntmin) then ! modif 13 nov 2020
              Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
            else
Index: /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/vlz_mod.F90
===================================================================
--- /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/vlz_mod.F90	(revision 3890)
+++ /LMDZ6/branches/LMDZ-tracers/libf/dyn3dmem/vlz_mod.F90	(revision 3891)
@@ -25,5 +25,5 @@
     CALL allocate_u(dzqw,llm,d)
     CALL allocate_u(adzqw,llm,d)
-    IF(ANY(tracers(:)%ndesc > 0) THEN
+    IF(ANY(tracers(:)%ndesc > 0)) THEN
       !CALL allocate_u(masseq,llm,nqtot,d)
       CALL allocate_u(Ratio,llm,nqtot,d)
@@ -45,5 +45,5 @@
     CALL switch_u(adzqw,distrib_vanleer,dist)
     ! CRisi:
-    if (nqdesc_tot.gt.0) then    
+    IF(ANY(tracers(:)%ndesc > 0)) then    
     !CALL switch_u(masseq,distrib_vanleer,dist)
     CALL switch_u(Ratio,distrib_vanleer,dist)
Index: /LMDZ6/branches/LMDZ-tracers/libf/misc/readTracFiles_mod.f90
===================================================================
--- /LMDZ6/branches/LMDZ-tracers/libf/misc/readTracFiles_mod.f90	(revision 3890)
+++ /LMDZ6/branches/LMDZ-tracers/libf/misc/readTracFiles_mod.f90	(revision 3891)
@@ -1,6 +1,6 @@
 MODULE readTracFiles_mod
 
-  USE strings_mod,    ONLY: msg, testFile,  strFind, strStack, strCount,   strHead, removeComment, dispTable, fmsg, &
-                            cat, checkList, strIdx,  strParse, strReplace, strTail,  reduceExpr, modname, find, test
+  USE strings_mod, ONLY: msg, testFile,  strFind, strStack, strReduce,  strHead, strCount,   find, dispTable, fmsg, &
+          removeComment, cat, checkList, strIdx,  strParse, strReplace, strTail, reduceExpr, test, modname, get_in
   USE trac_types_mod, ONLY : tra, iso, db, kys
 
@@ -9,4 +9,5 @@
   PRIVATE
 
+  PUBLIC :: initIsotopes
   PUBLIC :: readTracersFiles, aliasTracer, tracersSubset, indexUpdate     !--- TOOLS ASSOCIATED TO TRACERS  DESCRIPTORS
   PUBLIC :: readIsotopesFile                                              !--- TOOLS ASSOCIATED TO ISOTOPES DESCRIPTORS
@@ -82,5 +83,5 @@
 !------------------------------------------------------------------------------------------------------------------------------
   lerr = .FALSE.
-  modname = 'readTracersFiles'
+!  modname = 'readTracersFiles'
   IF(.NOT.ALLOCATED(dBase)) ALLOCATE(dBase(0))
 
@@ -225,5 +226,5 @@
   CHARACTER(LEN=256), ALLOCATABLE :: sec(:)
   INTEGER,            ALLOCATABLE ::  ix(:)
-  INTEGER :: n0, idb, ndb
+  INTEGER :: n0, idb, ndb, i, j
   LOGICAL :: ll
 !------------------------------------------------------------------------------------------------------------------------------
@@ -272,5 +273,5 @@
       ll = strParse(str,' ', keys = s, vals = v, n = n)              !--- Parse <key>=<val> pairs
       tt = dBase(ndb)%trac(:)
-      tmp%name = s(1); tmp%keys = kys(s(1), s(2:n), v(2:n))
+      tmp%name = s(1); tmp%comp=secn; tmp%keys = kys(s(1), s(2:n), v(2:n))
       dBase(ndb)%trac = [tt(:), tmp]
       DEALLOCATE(tt)
@@ -294,14 +295,14 @@
   TYPE(tra), ALLOCATABLE, TARGET, INTENT(INOUT) :: t(:)
   CHARACTER(LEN=*),               INTENT(IN)    :: defName
-  INTEGER :: i0, it, k
-  TYPE(kys), POINTER     :: k0
+  INTEGER :: jd, it, k
+  TYPE(kys), POINTER :: ky
   TYPE(tra), ALLOCATABLE :: tt(:)
-  i0 = strIdx(t(:)%name, defName)
-  IF(i0 == 0) RETURN
-  k0 => t(i0)%keys
-  DO k = 1, SIZE(k0%key)                                             !--- Loop on the keys of the tracer named "defName"
-    CALL addKey_tra(TRIM(k0%key(k)), TRIM(k0%val(k)), t)             !--- Add key to all the tracers (no overwriting)
-  END DO
-  tt = [t(1:i0-1),t(i0+1:SIZE(t))]; CALL MOVE_ALLOC(FROM=tt, TO=t)   !--- Remove the virtual tracer named "defName"
+  jd = strIdx(t(:)%name, defName)
+  IF(jd == 0) RETURN
+  ky => t(jd)%keys
+  DO k = 1, SIZE(ky%key)                                             !--- Loop on the keys of the tracer named "defName"
+    CALL addKey_m(ky%key(k), ky%val(k), t(:)%keys)                   !--- Add key to all the tracers (no overwriting)
+  END DO
+  tt = [t(1:jd-1),t(jd+1:SIZE(t))]; CALL MOVE_ALLOC(FROM=tt, TO=t)   !--- Remove the virtual tracer named "defName"
 END SUBROUTINE addDefault
 !==============================================================================================================================
@@ -338,6 +339,4 @@
 
 
-
-
 !==============================================================================================================================
 LOGICAL FUNCTION expandSection(tr, sname, fname) RESULT(lerr)
@@ -451,5 +450,5 @@
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: fname                    !--- File name
   CHARACTER(LEN=256) :: mesg
-  CHARACTER(LEN=256) :: bp(SIZE(tr, DIM=1)), pha
+  CHARACTER(LEN=256) :: bp(SIZE(tr, DIM=1)), pha                     !--- Bad phases list, phases of current tracer
   CHARACTER(LEN=1) :: p
   INTEGER :: ip, np, iq, nq
@@ -814,17 +813,20 @@
   
 !==============================================================================================================================
-!=== READ THE ISOTOPES NAMED "iso" FROM THE TRACERS SECTIONS "tr" IN THE FILE "fnam" ; PUT RESULT IN A TRACERS DESCRIPTOR ====
-!===  * SYNTAX IS THE SAME AS IN THE "tracer.def" FILE ; EACH TRACER SECTION CONTAINS ONE LINE EACH OF ITS KNOWN ISOTOPES  ====
-!===  * EACH TRACERS SECTION CAN CONTAIN A "params" VIRTUAL ISOTOPE LINE CONTAINING DEFAULT PARAMETERS FOR THE ISOTOPES    ====
-!===  * IF SOME KEYS ARE FOUND BOTH IN THE "*.def" FILES AND THE "params" SECTION, TEH VALUE FROM "*.def" FILE IS RETAINED ====
-!===  * ON EACH ISOTOPE LINE, A DEFINED KEY CAN BE USED IN THE OTHER KEYS AS A PARAMETER (SIGNLE LEVEL DEPENDENCY !)       ====
-!===  * THE DIFFERENT ISOTOPES SETS (ONE EACH PARENT TRACER) ARE MERGED INTO A SINGLE TRACERS DESCRIPTOR VECTOR            ====
-!===  * THE ROUTINE GIVES AN ERROR IF A REQUIRED ISOTOPE IS NOT AVAILABLE IN THE DATABASE STORED IN "fnam"                 ====
-!==============================================================================================================================
-
+!=== READ FILE "fnam" TO APPEND THE "dBase" TRACERS DATABASE WITH AS MUCH SECTIONS AS PARENTS NAMES IN "isot(:)%prnt":     ====
+!===  * Each section dBase(i)%name contains the isotopes "dBase(i)%trac(:)" descending on "dBase(i)%name"="iso(i)%prnt"    ====
+!===  * For each isotopes class, the <key>=<val> vector of each tracer is moved into the isotopes descriptor "isot"        ====
+!=== NOTES:                                                                                                                ====
+!===  * Most of the "isot" components have been defined in the calling routine (initIsotopes):                             ====
+!===      prnt,   nzon, zone(:),   niso, keys(:)%name,   nitr, trac(:),   npha, phas,  iTraPha(:,:),  iZonPhi(:,:)         ====
+!===  * Same syntax for isotopes file and "tracer.def": a tracers section contains one line for each of its isotopes       ====
+!===  * Each tracers section can contain a "params" virtual isotope line of isotopes parameters default values             ====
+!===  * In case keys are found both in the "params" section and the "*.def" file, the later value is retained              ====
+!===  * On each isotope line, defined keys can be used for other keys defintions (single level depth substitution)         ====
+!===  * The routine gives an error if a required isotope is not available in the database stored in "fnam"                 ====
+!==============================================================================================================================
 LOGICAL FUNCTION readIsotopesFile(fnam, isot) RESULT(lerr)
   CHARACTER(LEN=*),  INTENT(IN)    :: fnam                           !--- Input file name
   TYPE(iso), TARGET, INTENT(INOUT) :: isot(:)                        !--- Isotopes descriptors (field "prnt" must be defined !)
-  INTEGER :: ik, is, it, idb, nk0, i
+  INTEGER :: ik, is, it, idb, nk0, i, iis
   INTEGER :: nk, ns, nt, ndb, nb0, i0
   CHARACTER(LEN=256), POINTER     :: k(:), v(:), k0(:), v0(:)
@@ -832,6 +834,5 @@
   CHARACTER(LEN=256)     :: val
   TYPE(kys),    POINTER  ::   ky(:)
-  TYPE(tra),    POINTER  ::    t(:)
-  TYPE(tra), ALLOCATABLE ::   tt(:)
+  TYPE(tra),    POINTER  ::   tt(:), t
   TYPE(db),  ALLOCATABLE ::  tdb(:)
   LOGICAL,   ALLOCATABLE :: liso(:)
@@ -844,12 +845,7 @@
   IF(test(readSections(fnam,strStack(isot(:)%prnt,',')),lerr)) RETURN!--- Read sections, one each parent tracer
   ndb = SIZE(dBase, DIM=1)                                           !--- Current database size
-
   DO idb = nb0, ndb
-    t => dBase(idb)%trac(:)
-    nt = SIZE(t)                                                     !--- Number of isotopes in the current database section
-
-PRINT*
-PRINT*,'AVANT:'
-DO it=1,SIZE(t); print*,TRIM(t(it)%name)//':  '//strStack([(TRIM(t(it)%keys%key(i))//'='//TRIM(t(it)%keys%val(i)), i=1, SIZE(t(it)%keys%key))]); END DO
+   iis = idb-nb0+1
+
     !--- GET FEW GLOBAL KEYS FROM "def" FILES AND ADD THEM TO THE 'params' SECTION
     CALL addKeysFromDef(dBase(idb)%trac, 'params')
@@ -858,45 +854,20 @@
     CALL subDefault(dBase(idb)%trac, 'params', .TRUE.)
 
-PRINT*
-PRINT*,'AVANT REDUCTION:'
-    t => dBase(idb)%trac(:)
-    DO it=1,SIZE(t); print*,TRIM(t(it)%name)//':  '//strStack([(TRIM(t(it)%keys%key(i))//'='//TRIM(t(it)%keys%val(i)), i=1, SIZE(t(it)%keys%key))]); END DO
-
-    !--- REDUCE THE EXPRESSIONS TO OBTAIN SCALARS
-    DO it=1, nt
-      v => dBase(idb)%trac(it)%keys%val(:)
-      WHERE(reduceExpr(v, vals)) v = vals
+    tt => dBase(idb)%trac
+
+    !--- REDUCE THE EXPRESSIONS TO OBTAIN SCALARS AND TRANSFER THEM TO THE "isot" ISOTOPES DESCRIPTORS VECTOR
+    DO it = 1, SIZE(dBase(idb)%trac)
+      is = strIdx(isot(iis)%keys(:)%name, dBase(idb)%trac(it)%name)  !--- Index of the "isot(iis)%keys(:)%name" tracer named "t%name"
+      IF(is == 0) CYCLE
+      t => dBase(idb)%trac(it)
+      liso = reduceExpr(t%keys%val, vals)                            !--- Reduce expressions (for substituted variables)
+      isot(iis)%keys(is)%key = PACK(t%keys%key, MASK=liso)
+      isot(iis)%keys(is)%val = PACK(  vals,     MASK=liso)
     END DO
 
-PRINT*
-PRINT*,'APRES:'
-    t => dBase(idb)%trac(:)
-    DO it=1,SIZE(t); print*,TRIM(t(it)%name)//':  '//strStack([(TRIM(t(it)%keys%key(i))//'='//TRIM(t(it)%keys%val(i)), i=1, SIZE(t(it)%keys%key))]); END DO
-
-    !--- TRANSFER THE key=val PAIRS TO THE ISOTOPES DESCRIPTOR
-print*
-print*,'isot%prnt = '//strStack(isot%prnt)
-
-    ky => isot(strIdx(isot(:)%prnt, dBase(idb)%name))%keys           !--- Keys of "isot" tracers with parent "dBase(idb)%name"
-print*,'ky%name = '//strStack(ky%name)
-    is=1
-    DO it = 1, nt; IF(it == i0) CYCLE
-print*,'AAAAAA '//strStack(ky%name)
-print*,'       '//TRIM(t(it)%name)
-      is = strIdx(ky(:)%name, t(it)%name)                            !--- Index of the "isot(:)" tracer named "t(it)%name"
-      IF(is == 0) CYCLE                                              !--- Current isotope is not present in "isot" => not needed
-      k => ky(is)%key; k = t(it)%keys%key
-      v => ky(is)%val; v = t(it)%keys%val
-      WHERE(reduceExpr(v, vals)) v = vals
-      DO ik=1, SIZE(k); IF(reduceExpr(v(ik),val)) v(ik) = val; END DO!--- Reduce operations (for substituted variables)
-print*,'(4) '//strStack([(TRIM(k(i))//'='//TRIM(v(i)), i=1, SIZE(k))])
-    END DO
-print*,'(7) i0=',i0
-
     !--- CHECK FOR MISSING ISOTOPES (NO KEYS ALLOCATED)
-    liso = [( ALLOCATED(ky(is)%key), is=1, SIZE(ky) )]
-print*,'liso=',liso
-    IF(test(checkList(ky(:)%name, &
-      .NOT.liso, 'Check file "'//TRIM(fnam)//'" in section "'//TRIM(dBase(idb)%name)//'"', 'isotopes', 'missing'),lerr)) RETURN
+    liso = [( ALLOCATED(isot(iis)%keys(is)%key), is=1, SIZE(isot(iis)%keys) )]
+    IF(test(checkList(isot(iis)%keys(:)%name, .NOT.liso, &
+      'Check file "'//TRIM(fnam)//'" in section "'//TRIM(dBase(idb)%name)//'"', 'isotopes', 'missing'),lerr)) RETURN
   END DO
 
@@ -907,8 +878,100 @@
     ALLOCATE(tdb(nb0-1)); tdb(1:nb0-1)=dBase(1:nb0-1); CALL MOVE_ALLOC(FROM=tdb, TO=dBase)
   END IF
-  lerr = dispIsotopes(isot,'isotopes parameters read from file')
+  lerr = dispIsotopes(isot, 'Isotopes parameters read from file')
 
 END FUNCTION readIsotopesFile
 !==============================================================================================================================
+
+!==============================================================================================================================
+!=== IF ISOTOPES (2ND GENERATION TRACERS) ARE DETECTED:                                                                     ===
+!===    * COMPUTE MOST OF THE RELATED QUANTITIES ("isot" COMPONENTS).                                                       ===
+!===    * COMPUTE FEW ISOTOPES-DEDICATED "trac" COMPONENTS                                                                  ===
+!===    * CALL readIsotopesFile TO GET PHYSICAL QUANTITIES (<key>=<val> PAIRS)                                              ===
+!===      NOTE: THIS IS DONE HERE (IN A ROUTINE CALLED BY THE DYNAMIC), BECAUSE THE DYNAMIC NEEDS FEW PHYSICAL PARAMETERS.  ===
+!==============================================================================================================================
+SUBROUTINE initIsotopes(trac, isot)
+  TYPE(tra), ALLOCATABLE, TARGET, INTENT(INOUT) :: trac(:)
+  TYPE(iso), ALLOCATABLE, TARGET, INTENT(INOUT) :: isot(:)
+  CHARACTER(LEN=256), ALLOCATABLE :: p(:), str(:)                    !--- Temporary storage
+  CHARACTER(LEN=256) :: iname
+  CHARACTER(LEN=1)   :: ph                                           !--- Phase
+  INTEGER :: nbIso, ic, ip, iq, it, iz
+  LOGICAL, ALLOCATABLE :: ll(:)                                      !--- Mask
+  TYPE(tra), POINTER   ::  t(:), t1
+  TYPE(iso), POINTER   ::  s
+
+  t => trac
+
+  p = PACK(delPhase(t%prnt), MASK = t%type=='tracer' .AND. t%igen==2)!--- Parents of 2nd generation isotopes
+  CALL strReduce(p, nbIso)
+  ALLOCATE(isot(nbIso))
+
+  IF(nbIso==0) RETURN                                                !=== NO ISOTOPES: FINISHED
+
+  !--- ISOTOPES RELATED VARIABLES ; NULL OR EMPTY IF NO ISOTOPES
+  isot(:)%prnt = p
+  DO ic = 1, SIZE(p)                                                 !--- Loop on isotopes classes
+    s => isot(ic)
+    iname = s%prnt                                                   !--- Current isotopes class name (parent tracer name)
+
+    !=== Isotopes childs of tracer "iname": mask, names, number (same for each phase of "iname")
+    ll = t(:)%type=='tracer' .AND. delPhase(t(:)%prnt) == iname .AND. t(:)%phas == 'g'
+    str = PACK(delPhase(t(:)%name), MASK = ll)                       !--- Effectively found isotopes of "iname"
+    s%niso = SIZE(str)                                               !--- Number of "effectively found isotopes of "iname"
+    ALLOCATE(s%keys(s%niso))
+    FORALL(it = 1:s%niso) s%keys(it)%name = str(it)
+
+    !=== Geographic tagging tracers descending on tracer "iname": mask, names, number
+    ll = t(:)%type=='tag'    .AND. delPhase(t(:)%nam1) == iname .AND. t(:)%igen == 3
+    s%zone = PACK(strTail(t(:)%name,'_'), MASK = ll)                 !--- Tagging zones names  for isotopes category "iname"
+    CALL strReduce(s%zone)
+    s%nzon = SIZE(s%zone)                                            !--- Tagging zones number for isotopes category "iname"
+
+    !=== Geographic tracers of the isotopes childs of tracer "iname" (same for each phase of "iname")
+    !    NOTE: One might like to create a similar variable for 2nd generation tagging tracers (tagging the gen1 tracers)
+    str = PACK(delPhase(t(:)%name), MASK=ll)
+    CALL strReduce(str)
+    s%nitr = s%niso + SIZE(str)                                      !--- Number of isotopes + their geographic tracers [ntraciso]
+    ALLOCATE(s%trac(s%nitr))
+    FORALL(it = 1:s%niso) s%trac(it) = s%keys(it)%name
+    FORALL(it = s%niso+1:s%nitr) s%trac(it) = str(it-s%niso)
+
+    !=== Phases for tracer "iname"
+    s%phas = ''
+    DO ip = 1, nphases; ph = known_phases(ip:ip); IF(strIdx(t%name,addPhase(iname, ph)) /= 0) s%phas = TRIM(s%phas)//ph; END DO
+    s%npha = LEN_TRIM(s%phas)                                        !--- Equal to "nqo" for water
+
+    !=== Tables giving the index in a table of effectively found items for each dynamical tracer (1<=iq<=nqtot)
+    DO iq = 1, SIZE(t)
+      t1 => trac(iq)
+      IF(delPhase(t1%nam1) /= iname) CYCLE                            !--- Only deal with tracers descending on "iname"
+      t1%iso_igr = ic                                                 !--- Isotopes family       idx in list "isotopes(:)%prnt"
+      t1%iso_num = strIdx(s%trac, delPhase(strHead(t1%name,'_')))     !--- Current isotope       idx in effective isotopes list
+      t1%iso_zon = strIdx(s%zone,          strTail(t1%name,'_') )     !--- Current isotope zone  idx in effective zones    list
+      t1%iso_pha =  INDEX(s%phas,TRIM(t1%phas))                       !--- Current isotope phase idx in effective phases   list
+      IF(t1%igen /= 3) t1%iso_zon = 0                                 !--- Skip possible generation 2 tagging tracers
+    END DO
+
+    !=== Table used to get iq (index in dyn array, size nqtot) from the isotope and phase indexes ; the full isotopes list
+    !    (including tagging tracers) is sorted this way:  iso1, iso2, ..., iso1_zone1, iso2_zone1, ..., iso1_zoneN, iso2_zoneN
+    s%iTraPha = RESHAPE( [( (strIdx(t(:)%name,  addPhase(s%trac(it),s%phas(ip:ip))),     it=1, s%nitr), ip=1, s%npha)], &
+                         [s%nitr, s%npha] )
+
+    !=== Table used to get ix (index in tagging tracers isotopes list, size nitr) from the zone and isotope indexes
+    s%iZonIso = RESHAPE( [( (strIdx(s%trac(:), TRIM(s%trac(it))//'_'//TRIM(s%zone(iz))), iz=1, s%nzon), it=1, s%niso)], &
+                         [s%nzon, s%niso] )
+  END DO
+  
+  !=== Indexes, in dynamical tracers list, of the tracers transmitted to phytrac (nqtottr non-vanishing elements)
+  ll = delPhase(t%name)/='H2O' .AND. t%iso_num ==0              !--- Mask of tracers passed to the physics
+  t(:)%itr = UNPACK([(iq,iq=1,COUNT(ll))], ll, [(0, iq=1, SIZE(t))])
+
+  !=== READ PHYSICAL PARAMETERS FROM "isotopes_params.def" FILE
+  !    DONE HERE, AND NOT ONLY IN "infotrac_phy", BECAUSE SOME PHYSICAL PARAMS ARE NEEDED FOR RESTARTS (tnat AND alpha_ideal)
+  IF(readIsotopesFile('isotopes_params.def',isot)) CALL abort_gcm(modname,'Problem when reading isotopes parameters',1)
+
+END SUBROUTINE initIsotopes
+!==============================================================================================================================
+
 
 !==============================================================================================================================
@@ -955,49 +1018,37 @@
   IF(iky == 0) THEN
     nky = SIZE(ky%key)
-    IF(nky == 0) THEN
-      ky%key = TRIM(key); ky%val = TRIM(val)
-    ELSE
-      ALLOCATE(k(nky+1)); k(1:nky) = ky%key; k(nky+1) = TRIM(key); CALL MOVE_ALLOC(FROM=k, TO=ky%key)
-      ALLOCATE(v(nky+1)); v(1:nky) = ky%val; v(nky+1) = TRIM(val); CALL MOVE_ALLOC(FROM=v, TO=ky%val)
-    END IF
+    IF(nky == 0) THEN; ky%key = [key]; ky%val = [val]; ELSE; ky%key = [ky%key, key]; ky%val = [ky%val, val]; END IF
   ELSE IF(lo) THEN                                                   !--- Overwriting
-    ky%key(iky) = TRIM(key); ky%val(iky) = TRIM(val)
+    ky%key(iky) = key; ky%val(iky) = val
   END IF
 END SUBROUTINE addKey_1
 !==============================================================================================================================
-SUBROUTINE addKey_tra(key, val, tr, lOverWrite, tname)
-!------------------------------------------------------------------------------------------------------------------------------
-! Purpose: Add the <key>=<val> pair in all the components of the "tr(itr)%keys" keys descriptor:
-!          * "tname"   specified: for the index "itr" of the tracer named "tname"
-!          * "tname" unspecified: for all the tracers
-!------------------------------------------------------------------------------------------------------------------------------
-  CHARACTER(LEN=*),           INTENT(IN)    :: key, val
-  TYPE(tra),                  INTENT(INOUT) :: tr(:)
-  LOGICAL,          OPTIONAL, INTENT(IN)    :: lOverWrite
-  CHARACTER(LEN=*), OPTIONAL, INTENT(IN)    :: tname
+SUBROUTINE addKey_m(key, val, ky, lOverWrite)
+!------------------------------------------------------------------------------------------------------------------------------
+! Purpose: Add the <key>=<val> pair in all the components of the "ky" keys descriptor.
+!------------------------------------------------------------------------------------------------------------------------------
+  CHARACTER(LEN=*),  INTENT(IN)    :: key, val
+  TYPE(kys),         INTENT(INOUT) :: ky(:)
+  LOGICAL, OPTIONAL, INTENT(IN)    :: lOverWrite
   INTEGER :: itr
   LOGICAL :: lo
 !------------------------------------------------------------------------------------------------------------------------------
   lo=.FALSE.; IF(PRESENT(lOverWrite)) lo=lOverWrite
-  IF(PRESENT(tname)) THEN
-    itr = strIdx(tr%name, tname)
-    IF(itr == 0) RETURN
-    CALL addKey_1(key, val, tr(itr)%keys, lo)
-  ELSE
-    DO itr = 1, SIZE(tr); CALL addKey_1(key, val, tr(itr)%keys, lo); END DO
-  END IF
-END SUBROUTINE addKey_tra
-!==============================================================================================================================
-SUBROUTINE addKeysFromDef(tr, tr0)
-  USE ioipsl_getin_p_mod, ONLY : getin_p
-  TYPE(tra), ALLOCATABLE, INTENT(INOUT) :: tr(:)
+  DO itr = 1, SIZE(ky); CALL addKey_1(key, val, ky(itr), lo); END DO
+END SUBROUTINE addKey_m
+!==============================================================================================================================
+SUBROUTINE addKeysFromDef(t, tr0)
+!------------------------------------------------------------------------------------------------------------------------------
+! Purpose: The values of the keys of the tracer named "tr0" are overwritten by the values found in the *.def files, if any.
+!------------------------------------------------------------------------------------------------------------------------------
+  TYPE(tra), ALLOCATABLE, INTENT(INOUT) :: t(:)
   CHARACTER(LEN=*),       INTENT(IN)    :: tr0
   CHARACTER(LEN=256) :: val
-  INTEGER            :: ik, i0
-  i0 = strIdx(tr%name, tr0)
-  IF(i0 == 0) RETURN
-  DO ik = 1, SIZE(tr(i0)%keys%key)
-    val   =   'zzzz'; CALL  getin_p(tr(i0)%keys%key(ik), val)
-    IF(val /= 'zzzz') CALL addKey_1(tr(i0)%keys%key(ik), val, tr(i0)%keys, .TRUE.)
+  INTEGER            :: ik, jd
+  jd = strIdx(t%name, tr0)
+  IF(jd == 0) RETURN
+  DO ik = 1, SIZE(t(jd)%keys%key)
+    CALL get_in(t(jd)%keys%key(ik), val, 'zzzz')
+    IF(val /= 'zzzz') CALL addKey_1(t(jd)%keys%key(ik), val, t(jd)%keys, .TRUE.)
   END DO
 END SUBROUTINE addKeysFromDef
@@ -1064,6 +1115,6 @@
 LOGICAL FUNCTION getKeyByName_s1(keyn, val, tname, ky) RESULT(lerr)
   !--- Purpose: Get the value of the key named "keyn" for the tracer named "tnam".
-  !     * "ky" unspecified: try in "tracers" for "tnam" with phase suffix, then in "isotopes" without.
-  !     * "ky"   specified: try in "ky"      for "tnam" with, then without phase suffix.
+  !     * "ky" unspecified: try in "tracers" for "tnam" with phase and tagging suffixes, then in "isotopes" without.
+  !     * "ky"   specified: try in "ky"      for "tnam" with phase and tagging suffixes, then without.
   !    The returned error code is always .FALSE.: an empty string is returned when the key hasn't been found.
   CHARACTER(LEN=*),    INTENT(IN)  :: keyn
@@ -1074,6 +1125,6 @@
   lerr = .FALSE.
   IF(PRESENT(ky)) THEN
-    val = getKeyByName_prv(keyn,          tname , ky);    IF(val /= '') RETURN !--- "ky" and "tnam"
-    val = getKeyByName_prv(keyn, delPhase(tname), ky)                          !--- "ky" and "tnam" without phase
+    val = getKeyByName_prv(keyn, tname , ky);    IF(val /= '') RETURN          !--- "ky" and "tnam"
+    val = getKeyByName_prv(keyn, delPhase(strHead(tname,'_')), ky)             !--- "ky" and "tnam" without phase
   ELSE
     IF(.NOT.ALLOCATED(tracers))  RETURN
@@ -1081,5 +1132,5 @@
     IF(.NOT.ALLOCATED(isotopes)) RETURN
     IF(SIZE(isotopes) == 0)      RETURN
-    DO is = 1, SIZE(isotopes); IF(strIdx(isotopes(is)%keys(:)%name, tname) /= 0) EXIT; END DO
+    DO is = 1, SIZE(isotopes); IF(strIdx(isotopes(is)%keys(:)%name, delPhase(strHead(tname,'_'))) /= 0) EXIT; END DO
     IF(is /= 0) val = getKeyByName_prv(keyn, tname, isotopes(is)%keys(:))      !--- "isotopes" and "tnam" without phase
   END IF
@@ -1175,9 +1226,13 @@
 ELEMENTAL CHARACTER(LEN=256) FUNCTION delPhase(s) RESULT(out)
   CHARACTER(LEN=*), INTENT(IN) :: s
-  INTEGER :: l
+  INTEGER :: l, i
   out = s
   IF(s == '') RETURN
-  l=LEN_TRIM(s)
-  IF(s(l-1:l-1)=='-' .AND. INDEX(known_phases,s(l:l))/=0) out = s(1:l-2)
+  i = INDEX(s, '_'); l = LEN_TRIM(s)
+  IF(i == 0) THEN
+    IF(s(l-1:l-1)=='-' .AND. INDEX(known_phases,s(l:l)) /= 0) out = s(1:l-2)
+  ELSE; i=i-1
+    IF(s(i-1:i-1)=='-' .AND. INDEX(known_phases,s(i:i)) /= 0) out = s(1:i-2)//s(i+1:l)
+  END IF
 END FUNCTION delPhase
 !------------------------------------------------------------------------------------------------------------------------------
@@ -1185,6 +1240,10 @@
   CHARACTER(LEN=*), INTENT(IN) :: s
   CHARACTER(LEN=1), INTENT(IN) :: pha
-  IF(INDEX(s,'_')==0) THEN; out = TRIM(s)//'-'//pha; RETURN; END IF
-  out = TRIM(strHead(s,'_'))//'-'//pha//TRIM(strTail(s,'_'))
+  INTEGER :: l, i
+  out = s
+  IF(s == '') RETURN
+  i = INDEX(s, '_'); l = LEN_TRIM(s)
+  IF(i == 0) out =  TRIM(s)//'-'//pha
+  IF(i /= 0) out = s(1:i-1)//'-'//pha//'_'//s(i+1:l)
 END FUNCTION addPhase_1
 !------------------------------------------------------------------------------------------------------------------------------
Index: /LMDZ6/branches/LMDZ-tracers/libf/phylmd/infotrac_phy.F90
===================================================================
--- /LMDZ6/branches/LMDZ-tracers/libf/phylmd/infotrac_phy.F90	(revision 3890)
+++ /LMDZ6/branches/LMDZ-tracers/libf/phylmd/infotrac_phy.F90	(revision 3891)
@@ -3,5 +3,5 @@
   USE       strings_mod, ONLY: msg, fmsg, test, strIdx, int2str
 
-  USE readTracFiles_mod, ONLY: getKey_init, getKey, indexUpdate
+  USE readTracFiles_mod, ONLY: getKey_init, getKey, indexUpdate, delPhase
 
   USE trac_types_mod,    ONLY: tra, iso, kys
@@ -75,4 +75,5 @@
 !  | type       | Type (so far: tracer or tag)                    | /           | tracer,tag             |
 !  | phas       | Phases list ("g"as / "l"iquid / "s"olid)        | /           | [g][l][s]              |
+!  | comp       | Name(s) of the merged/cumulated section(s)      | /           | coma-separated names   |
 !  | iadv       | Advection scheme number                         | iadv        | 1-20,30 exc. 3-9,15,19 |
 !  | igen       | Generation (>=1)                                | /           |                        |
@@ -108,4 +109,5 @@
                               nbIso                        !--- Number of available isotopes family
   CHARACTER(LEN=256), SAVE :: type_trac                    !--- Keyword for tracers type
+!$OMP THREADPRIVATE(nqtot, nbtr, nqo, nbIso, type_trac)
 
   !=== DERIVED TYPES EMBEDDING MOST INFORMATIONS ABOUT TRACERS AND ISOTOPES FAMILIES
@@ -115,15 +117,15 @@
 
   !=== ALIASES FOR CURRENTLY SELECTED ISOTOPES FAMILY OF VARIABLES EMBEDDED IN THE VECTOR "isotopes"
-  TYPE(iso),          SAVE, POINTER :: isotope             !--- CURRENTLY SELECTED ISOTOPES FAMILY DESCRIPTOR
-  INTEGER,            SAVE          :: ixIso, iH2O         !--- Index of the selected isotopes family and H2O family
-  LOGICAL,            SAVE, POINTER :: isoCheck            !--- Flag to trigger the checking routines
-  TYPE(kys),          SAVE, POINTER :: isoKeys(:)          !--- ONE SET OF KEYS FOR EACH ISOTOPE (LISTED IN isoName)
-  CHARACTER(LEN=256), 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, nzon, npha, & !--- NUMBER OF ISOTOPES, TAGGING ZONES AND PHASES
-                                       nitr                !--- NUMBER OF ISOTOPES + ISOTOPIC TAGGING TRACERS
-  INTEGER,            SAVE, POINTER :: iZonIso(:,:)        !--- INDEX IN "isoTrac" AS f(tagging zone, isotope)
-  INTEGER,            SAVE, POINTER :: iTraPha(:,:)        !=== INDEX IN "isoTrac" AS f(isotopic tracer, phase)
+  TYPE(iso),          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(kys),          SAVE, POINTER     :: isoKeys(:)      !--- ONE SET OF KEYS FOR EACH ISOTOPE (LISTED IN isoName)
+  CHARACTER(LEN=256), 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, nzon,   & !--- NUMBER OF ISOTOPES, TAGGING ZONES AND PHASES
+                                           npha, nitr      !--- NUMBER OF PHASES AND ISOTOPES + ISOTOPIC TAGGING TRACERS
+  INTEGER,            SAVE, POINTER     :: iZonIso(:,:)    !--- INDEX IN "isoTrac" AS f(tagging zone, isotope)
+  INTEGER,            SAVE, POINTER     :: iTraPha(:,:)    !--- INDEX IN "isoTrac" AS f(isotopic tracer, phase)
 !$OMP THREADPRIVATE(isotope, ixIso,iH2O, isoCheck, isoKeys, isoName,isoZone,isoPhas, niso,nzon,npha,nitr, iZonIso,iTraPha)
 
@@ -132,9 +134,9 @@
                                         alpha_ideal(:)     !--- Ideal fractionning coefficient (for initial state) (niso)
   INTEGER,            SAVE, ALLOCATABLE :: conv_flg(:),  & !--- Convection     activation ; needed for INCA        (nbtr)
-                                            pbl_flg(:)     !---  Boundary layer activation ; needed for INCA        (nbtr)
-  INTEGER,            SAVE, ALLOCATABLE ::    niadv(:),  &
-                                         itr_indice(:)     !--- Indexes of the tracers passed to phytrac        (nqtottr)
-  CHARACTER(LEN=256), SAVE, ALLOCATABLE ::   solsym(:)     !--- Names from INCA                                    (nbtr)
-!OMP THREADPRIVATE(tnat, alpha_ideal, conv_flg, pbl_flg, niadv, itr_indice, solsym)
+                                            pbl_flg(:),  & !--- Boundary layer activation ; needed for INCA        (nbtr)
+                                         itr_indice(:),  & !--- Indexes of the tracers passed to phytrac        (nqtottr)
+                                              niadv(:)     !--- Indexes of true tracers  (<=nqtot, such that iadv(idx)>0)
+  CHARACTER(LEN=8),   SAVE, ALLOCATABLE ::   solsym(:)     !--- Names from INCA                                    (nbtr)
+!OMP THREADPRIVATE(tnat, alpha_ideal, conv_flg, pbl_flg, itr_indice, niadv, solsym)
 
 #ifdef CPP_StratAer
@@ -163,4 +165,5 @@
   solsym    = solsym_
   nqtot     = SIZE(tracers_)
+  nqo       = COUNT(delPhase(tracers%name)=='H2O' .AND. tracers%igen==1)
   nbtr      = nbtr_
   niadv     = niadv_
@@ -169,18 +172,17 @@
   conv_flg = conv_flg_
 
+  CALL msg('nqtot = '//TRIM(int2str(nqtot)))
+  CALL msg('nbtr  = '//TRIM(int2str(nbtr)))
+  CALL msg('nqo   = '//TRIM(int2str(nqo)))
+
   !=== Specific to water
   CALL getKey_init(tracers, isotopes)
   IF(.NOT.isoSelect('H2O')) THEN
     iH2O = ixIso
-    lerr = getKey('tnat' ,tnat,        isoName)
-    lerr = getKey('alpha',alpha_ideal, isoName)
-    nqo  = isotope%npha
+    lerr = getKey('tnat' ,tnat,        isoName(1:isotope%niso))
+    lerr = getKey('alpha',alpha_ideal, isoName(1:isotope%niso))
   END IF
-  IF(prt_level > 1) WRITE(lunout,*) TRIM(modname)//": nqtot, nqo, nbtr = ",nqtot, nqo, nbtr
   itr_indice = PACK(tracers(:)%itr, MASK = tracers(:)%itr/=0)
-print*,'66'
-
-  !? conv_flg, pbl_flg, solsym
-  !? isoInit
+  !? CDC isoInit => A VOIR !!
 
 #ifdef CPP_StratAer
@@ -196,5 +198,5 @@
         CASE('GASSO2');   id_SO2_strat   = iq - nqo; CALL msg('id_SO2_strat  =', id_SO2_strat)
         CASE('GASH2SO4'); id_H2SO4_strat = iq - nqo; CALL msg('id_H2SO4_strat=', id_H2SO4_strat)
-        CASE('GASTEST');  id_TEST_strat  = iq - nqo; CALL msg('id_TEST_strat=' , id_TEST_strat)
+        CASE('GASTEST');  id_TEST_strat  = iq - nqo; CALL msg('id_TEST_strat =', id_TEST_strat)
       END SELECT
     END DO
@@ -209,26 +211,40 @@
 !==============================================================================================================================
 !=== THE ROUTINE isoSelect IS USED TO SWITCH FROM AN ISOTOPE FAMILY TO ANOTHER: ISOTOPES DEPENDENT PARAMETERS ARE UPDATED
-!     Singe generic "isoSelect" routine, using the predefined parent index (fast version) or its name (first time).
-!==============================================================================================================================
-LOGICAL FUNCTION isoSelectByName(iName) RESULT(lerr)
-  CHARACTER(LEN=*), INTENT(IN)  :: iName
+!     Singe generic "isoSelect" routine, using the predefined parent index (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(:)%prnt, iName)
-  IF(test(fmsg(iIso == 0,'no isotope family named "'//TRIM(iName)//'"'),lerr)) RETURN
-  IF(isoSelectByIndex(iIso)) RETURN
+  lerr = iIso == 0
+  CALL msg(lerr .AND. lV, 'no isotope family named "'//TRIM(iName)//'"')
+  IF(lerr) RETURN
+  lerr = isoSelectByIndex(iIso)
 END FUNCTION isoSelectByName
 !==============================================================================================================================
-LOGICAL FUNCTION isoSelectByIndex(iIso) RESULT(lerr)
-  INTEGER, INTENT(IN) :: iIso
+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
-  IF(test(fmsg(iIso<=0 .OR. iIso>=nbIso,'Inconsistent isotopes family index '//TRIM(int2str(iIso))),lerr)) RETURN
+  lerr = iIso<=0 .OR. iIso>nbIso
+  CALL msg(lerr .AND. lV, 'Inconsistent isotopes family index '//TRIM(int2str(iIso))//': should be > 0 and <= ' &
+                                                               //TRIM(int2str(nbIso))//'"')
+  IF(lerr) RETURN
   ixIso = iIso                                                  !--- Update currently selected family index
   isotope => isotopes(ixIso)                                    !--- Select corresponding component
-  !--- VARIOUS ALIASES
-  isoKeys => isotope%keys; niso = isotope%niso
-  isoName => isotope%trac; nitr = isotope%nitr; isoCheck => isotope%check
-  isoZone => isotope%zone; nzon = isotope%nzon; iZonIso  => isotope%iZonIso
-  isoPhas => isotope%phas; npha = isotope%npha; iTraPha  => isotope%iTraPha
+  isoKeys => isotope%keys;    niso     = isotope%niso
+  isoName => isotope%trac;    nitr     = isotope%nitr
+  isoZone => isotope%zone;    nzon     = isotope%nzon
+  isoPhas => isotope%phas;    npha     = isotope%npha
+  iZonIso => isotope%iZonIso; isoCheck = isotope%check
+  iTraPha => isotope%iTraPha
 END FUNCTION isoSelectByIndex
 !==============================================================================================================================
Index: /LMDZ6/branches/LMDZ-tracers/libf/phylmd/phyetat0.F90
===================================================================
--- /LMDZ6/branches/LMDZ-tracers/libf/phylmd/phyetat0.F90	(revision 3890)
+++ /LMDZ6/branches/LMDZ-tracers/libf/phylmd/phyetat0.F90	(revision 3891)
@@ -443,6 +443,6 @@
 !!        iiq=niadv(it+2)                                                           ! jyg
         iiq=niadv(it+nqo)                                                           ! jyg
-        found=phyetat0_get(1,trs(:,it),"trs_"//tracers(iiq)%name, &
-              "Surf trac"//tracers(iiq)%name,0.)
+        found=phyetat0_get(1,trs(:,it),"trs_"//TRIM(tracers(iiq)%name), &
+              "Surf trac"//TRIM(tracers(iiq)%name),0.)
      ENDDO
      CALL traclmdz_from_restart(trs)
@@ -591,9 +591,9 @@
    CALL get_field(name, field, found)
    IF (.NOT. found) THEN
-     WRITE(lunout,*) "phyetat0: Le champ <",name,"> est absent"
+     WRITE(lunout,*) "phyetat0: Le champ <",TRIM(name),"> est absent"
      WRITE(lunout,*) "Depart legerement fausse. Mais je continue"
      field(:,:)=default
    ENDIF
-   WRITE(lunout,*) name, descr, MINval(field),MAXval(field)
+   WRITE(lunout,*) TRIM(name), descr, MINval(field),MAXval(field)
    phyetat0_get=found
 
