Index: /trunk/LMDZ.COMMON/libf/dyn3d_common/infotrac.F90
===================================================================
--- /trunk/LMDZ.COMMON/libf/dyn3d_common/infotrac.F90	(revision 2435)
+++ /trunk/LMDZ.COMMON/libf/dyn3d_common/infotrac.F90	(revision 2436)
@@ -115,8 +115,9 @@
     INTEGER :: ifils,ipere,generation ! CRisi
     LOGICAL :: continu,nouveau_traceurdef
+    LOGICAL :: moderntracdef=.false. ! JVO, YJ : For planets modern traceur.def
     INTEGER :: IOstatus ! gestion de la retrocompatibilite de traceur.def
     CHARACTER(len=30) :: tchaine    
     
-    character(len=80) :: line ! to store a line of text
+    character(len=500) :: line ! to store a line of text
  
     character(len=*),parameter :: modname="infotrac_init"
@@ -240,7 +241,29 @@
     ELSE  ! not Earth
        OPEN(90,file='traceur.def',form='formatted',status='old', iostat=ierr)
-       IF(ierr.EQ.0) THEN
+       IF (ierr.EQ.0) THEN
           WRITE(lunout,*) 'Open traceur.def : ok'
-          READ(90,*) nqtrue
+!! - Modif. by JVO and YJ for modern planetary traceur.def ---------------
+          READ(90,'(A)') line
+          IF (trim(line).ne.'#ModernTrac-v1') THEN ! Test modern traceur.def
+             READ(line,*) nqtrue ! Try standard traceur.def
+          ELSE
+             moderntracdef = .true.
+             DO
+               READ(90,'(A)',iostat=ierr1) line
+               IF (ierr1==0) THEN
+                 IF (index(line,'#').ne.1) THEN ! Allows arbitary number of comments lines in the header
+                   READ(line,*) nbtr
+                   WRITE(lunout,*) trim(modname),': Number of tracers in the physics: nbtr=',nbtr
+                   EXIT
+                   ! JVO 20 : Here nbtr corresponds to ALL what we consider as modern 'tracers' (species)
+                   ! from physics, including non-dynamic species (radiative, compo..), and nqtrue will be set
+                   ! below, according to the flags in traceur.def, by read and rewind.
+                 ENDIF
+               ELSE ! If pb, or if reached EOF without having found nbtr
+                 CALL abort_gcm('infotrac_init','Unable to read numbers of tracers in traceur.def',1)
+               ENDIF
+             ENDDO
+          ENDIF ! if modern or standard traceur.def
+!! -----------------------------------------------------------------------
        ELSE 
           WRITE(lunout,*) 'Problem in opening traceur.def'
@@ -257,5 +280,5 @@
 ! Allocate variables depending on nqtrue and nbtr
 !
-    ALLOCATE(tnom_0(nqtrue), hadv(nqtrue), vadv(nqtrue),tnom_transp(nqtrue))
+    IF (.NOT.moderntracdef) ALLOCATE(tnom_0(nqtrue), hadv(nqtrue), vadv(nqtrue),tnom_transp(nqtrue))
 !
 !jyg<
@@ -526,50 +549,112 @@
 
     ELSE  ! not Earth
-       ! Other planets (for now); we have the same number of tracers
-       ! in the dynamics than in the physics
-       nbtr=nqtrue
-       ! NB: Reading a traceur.def with isotopes remains to be done...
-       IF(ierr.EQ.0) THEN
-          ! Continue to read tracer.def
-          DO iq=1,nqtrue
-             !READ(90,*) hadv(iq),vadv(iq),tnom_0(iq)
-            ! try to be smart when reading traceur.def
-            read(90,'(80a)') line ! store the line from traceur.def
-            ! if format is hadv, vadv, tnom_0, tnom_transp
-            read(line,*,iostat=ierr1) hadv(iq),vadv(iq),tnom_0(iq),tnom_transp(iq)
-            if (ierr1.ne.0) then
-            ! assume format is hadv,vadv,tnom_0
-             read(line,*,iostat=ierr2) hadv(iq),vadv(iq),tnom_0(iq)
-             if (ierr2.ne.0) then
-              ! maybe format is tnom0,hadv,vadv
-              read(line,*,iostat=ierr3) tnom_0(iq),hadv(iq),vadv(iq)
-              if (ierr3.ne.0) then
-                !assuming values of hadv et vadv
-                hadv(iq)=10
-                vadv(iq)=10
-                read(line,*, iostat=ierr4) tnom_0(iq), tnom_transp(iq)
-                if (ierr4.ne.0) then
-                ! assume only tnom0 is provided (hadv and vadv default to 10)
-                  read(line,*) tnom_0(iq)
-                  tnom_transp(iq)='air' 
-                endif
-              else
-                !format is tnom0,hadv,vadv
-                tnom_transp(iq)='air' ! no isotopes
-              endif ! of if (ierr3.ne.0)
-             else
-               ! format is hadv,vadv,tnom_0
-               tnom_transp(iq)='air' ! no isotopes
-             endif ! of if (ierr2.ne.0)
-            endif ! of if(ierr1.ne.0)
-          END DO ! of DO iq=1,nqtrue
-          CLOSE(90)  
-       ELSE ! Without tracer.def
-          hadv(1) = 10
-          vadv(1) = 10
-          tnom_0(1) = 'dummy'
-          tnom_transp(1)='air'
-       END IF
+
+       IF (.not.moderntracdef) THEN ! Standard traceur.def or no traceur.def file
+
+         ! Other planets (for now); we have the same number of tracers
+         ! in the dynamics than in the physics
+         nbtr=nqtrue
+         ! NB: Reading a traceur.def with isotopes remains to be done...
+         IF(ierr.EQ.0) THEN
+            ! Continue to read tracer.def
+            DO iq=1,nqtrue
+               !READ(90,*) hadv(iq),vadv(iq),tnom_0(iq)
+              ! try to be smart when reading traceur.def
+              read(90,'(80a)') line ! store the line from traceur.def
+              ! if format is hadv, vadv, tnom_0, tnom_transp
+              read(line,*,iostat=ierr1) hadv(iq),vadv(iq),tnom_0(iq),tnom_transp(iq)
+              if (ierr1.ne.0) then
+              ! assume format is hadv,vadv,tnom_0
+               read(line,*,iostat=ierr2) hadv(iq),vadv(iq),tnom_0(iq)
+               if (ierr2.ne.0) then
+                ! maybe format is tnom0,hadv,vadv
+                read(line,*,iostat=ierr3) tnom_0(iq),hadv(iq),vadv(iq)
+                if (ierr3.ne.0) then
+                  !assuming values of hadv et vadv
+                  hadv(iq)=10
+                  vadv(iq)=10
+                  read(line,*, iostat=ierr4) tnom_0(iq), tnom_transp(iq)
+                  if (ierr4.ne.0) then
+                  ! assume only tnom0 is provided (hadv and vadv default to 10)
+                    read(line,*) tnom_0(iq)
+                    tnom_transp(iq)='air' 
+                  endif
+                else
+                  !format is tnom0,hadv,vadv
+                  tnom_transp(iq)='air' ! no isotopes
+                endif ! of if (ierr3.ne.0)
+               else
+                 ! format is hadv,vadv,tnom_0
+                 tnom_transp(iq)='air' ! no isotopes
+               endif ! of if (ierr2.ne.0)
+              endif ! of if(ierr1.ne.0)
+            END DO ! of DO iq=1,nqtrue
+            CLOSE(90)  
+         ELSE ! Without tracer.def
+            hadv(1) = 10
+            vadv(1) = 10
+            tnom_0(1) = 'dummy'
+            tnom_transp(1)='air'
+         END IF
        
+       ELSE ! Modern traceur.def (moderntracdef=true) - Authors : JVO, YJ - 2020
+
+         nqtrue = 0
+         DO iq=1,nbtr ! This loops on ALL the 'tracers' including the non-dyn ones.
+           READ(90,'(A)') line ! store the line from traceur.def
+           IF (index(line,'is_dyn=0').ne.0) CYCLE ! Only if explicitly not dyn., otherwise default behaviour
+           nqtrue = nqtrue + 1
+         ENDDO
+         WRITE(lunout,*) trim(modname),': Number of tracers in the dynamics: nqtrue=',nqtrue
+         ALLOCATE(tnom_0(nqtrue), hadv(nqtrue), vadv(nqtrue),tnom_transp(nqtrue))
+
+         ! Now that we know the dyn. tracers and allocated variables, let's read again the file.
+         REWIND(90)
+         DO
+           READ(90,'(A)') line ! no need to check on iostat, already done at first read
+           IF (index(line,'#').ne.1) THEN ! Skip arbitary number of commented lines in the header
+             READ(line,*) ! This is the line of nbtr (see above)
+             EXIT
+           ENDIF
+         ENDDO
+         iiq=0
+         DO iq=1,nbtr ! This loops on ALL the 'tracers' including the non-dyn ones.
+           
+           READ(90,'(A)') line ! store the line from traceur.def
+           IF (index(line,'is_dyn=0').ne.0) CYCLE ! Skip the non-dyn ones
+           iiq = iiq +  1 ! This ensure that iiq is on 1:nqtrue and not 1:nbtr
+           ! Name must be first parameter in this version, but all others can be in any order
+           read(line,*) tnom_0(iiq)
+           write(*,*)"infotrac_init: iq=",iiq,"noms(iq)=",trim(tnom_0(iiq))
+
+           if (index(line,'vadv=') /= 0) then
+             read(line(index(line,'vadv='   )+len('vadv='):),*) vadv(iiq)
+             write(*,*) ' Parameter value (traceur.def) : vadv=', vadv(iiq)
+           else
+             vadv(iiq)=10
+             write(*,*) ' Parameter value (default)     : vadv=',vadv(iiq)
+           end if
+
+           if (index(line,'hadv=') /= 0) then
+             read(line(index(line,'hadv='   )+len('hadv='):),*) hadv(iiq)
+             write(*,*) ' Parameter value (traceur.def) : hadv=', hadv(iiq)
+           else
+             hadv(iiq)=10
+             write(*,*) ' Parameter value (default)     : hadv=',hadv(iiq)
+           end if
+
+           if (index(line,'tnom_transp=' ) /= 0) then
+             read(line(index(line,'tnom_transp='   )+len('tnom_transp='):),*) tnom_transp(iiq)
+             write(*,*) ' Parameter value (traceur.def) : tnom_transp=', tnom_transp(iiq)
+           else
+             tnom_transp(iiq)='air'
+             write(*,*) ' Parameter value (default)     : tnom_transp=',tnom_transp(iiq)
+           end if
+
+         ENDDO
+         CLOSE(90)
+
+       ENDIF ! if (moderntracdef)
+
        WRITE(lunout,*) trim(modname),': Valeur de traceur.def :'
        WRITE(lunout,*) trim(modname),': nombre de traceurs ',nqtrue
Index: /trunk/LMDZ.GENERIC/README
===================================================================
--- /trunk/LMDZ.GENERIC/README	(revision 2435)
+++ /trunk/LMDZ.GENERIC/README	(revision 2436)
@@ -1606,2 +1606,7 @@
 Bug fix on mass_redistribution; argument rnat should be real, not integer.
 Turned it into a mass_redistribution_mod module.
+
+== 24/11/2020 == YJ + JVO
+Implementation of an option for a new reading process of "traceur.def"
+Use "#ModernTrac-v1" flag as first line of "traceur.def" to use this option
+Further details in "LMDZ.GENERIC/deftank/traceur.def.modern"
Index: /trunk/LMDZ.GENERIC/deftank/traceur.def.modern
===================================================================
--- /trunk/LMDZ.GENERIC/deftank/traceur.def.modern	(revision 2436)
+++ /trunk/LMDZ.GENERIC/deftank/traceur.def.modern	(revision 2436)
@@ -0,0 +1,56 @@
+#ModernTrac-v1
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# !! README !!
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#  Welcome, this is the modern traceur.def !
+# 
+#         ---> DON'T TOUCH/REMOVE THE FIRST LINE OF HEADER #ModernTrac-v1 <---
+#
+# * You can use this area to write as many comments as you want starting lines with #.
+# * You cannot have comment lines in the middle nor at the end, only at the top.
+#
+#
+# 0. Philosophy  This modern version of traceur.def gather in a single file what was
+# ~~~~~~~~~~~~~  previously in traceur.def AND gases.def plus some hard-coded things.
+#
+# 1. Structure  After the header, first line is the total number of modern tracers in
+# ~~~~~~~~~~~~  your file, ie not only tracers sent to dynamics, but also species that
+#               takes part in the composition, radiative transfer, chemistry, etc.
+#
+#               Then, each line needs to start with the specie name ... and that's the
+#               only mandatory information ! But you can specify all the options you
+#               want in separate blocks following 'option=value', assuming this option
+#               is defined in traceur_h.F90 & initracer.F for physics or infotrac.F90 
+#               for dynamics. Indeed this file is read once by dynamics who keep only
+#               the information needed and re-read by physics.
+#
+#               Note that by default a tracer listed below will be sent to dynamics
+#               except if you specify is_dyn=0. If nothing is given, then is_dyn=1.
+#
+# 3. Options.   Implemented options listed below.
+# ~~~~~~~~~~~~  For dynamic see "infotrac.F90".
+#               For physic see "initracer.F90".
+#
+# Dynamic:      vadv        ! index of vertical trasport schema
+#               hadv        ! index of horizontal trasport schema
+#               tnom_transp ! transporting fluid short name: CRisi
+#
+# Physic:       mmol        ! mole mass of tracer (g/mol-1)
+#
+#
+#
+#
+# Random Ex :
+#               4
+#               n2 is_dyn=0
+#               co2 cpi=450.0 is_dyn=1 mmol=44.
+#               hdo hadv=14 vadv=10 tnom_transp=air
+#               h2s
+#
+# Insert your tracers list and options below !
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+3
+n2 is_dyn=0
+co2 cpi=450.0 is_dyn=1 mmol=44.
+h2s
Index: /trunk/LMDZ.GENERIC/libf/phystd/dyn1d/kcm1d.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/dyn1d/kcm1d.F90	(revision 2435)
+++ /trunk/LMDZ.GENERIC/libf/phystd/dyn1d/kcm1d.F90	(revision 2436)
@@ -90,4 +90,8 @@
   real :: latitude(1), longitude(1), cell_area(1), phisfi(1)
   
+  !     added by JVO and YJ to read modern traceur.def
+  character(len=500) :: line ! to store a line of text
+  LOGICAL :: moderntracdef=.false. ! JVO, YJ : modern traceur.def
+
   ! --------------
   ! Initialisation
@@ -162,5 +166,24 @@
         write(*,*) "kcm1d: Reading file traceur.def"
         ! read number of tracers:
-        read(90,*,iostat=ierr) nq
+        !! - Modif. by JVO and YJ for modern planetary traceur.def ---------------
+        READ(90,'(A)') line
+        IF (trim(line).ne.'#ModernTrac-v1') THEN ! Test modern traceur.def
+           READ(line,*,iostat=ierr) nq ! Try standard traceur.def
+        ELSE
+           moderntracdef = .true.
+           DO
+             READ(90,'(A)',iostat=ierr) line
+             IF (ierr.eq.0) THEN
+               IF (index(line,'#').ne.1) THEN ! Allows arbitary number of comments lines in the header
+                 READ(line,*,iostat=ierr) nq
+                 EXIT
+               ENDIF
+             ELSE ! If pb, or if reached EOF without having found nbtr
+                write(*,*) "rcm1d: error reading number of tracers"
+                write(*,*) "   (first line of traceur.def) "
+                stop
+             ENDIF
+           ENDDO
+        ENDIF ! if modern or standard traceur.def
         if (ierr.ne.0) then
            write(*,*) "kcm1d: error reading number of tracers"
@@ -184,4 +207,5 @@
            endif
         enddo !of do iq=1,nq
+        close(90)
      endif
 
Index: /trunk/LMDZ.GENERIC/libf/phystd/dyn1d/rcm1d.F
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/dyn1d/rcm1d.F	(revision 2435)
+++ /trunk/LMDZ.GENERIC/libf/phystd/dyn1d/rcm1d.F	(revision 2436)
@@ -144,4 +144,8 @@
       real :: latitude(1), longitude(1), cell_area(1)
 
+      !     added by JVO and YJ to read modern traceur.def
+      character(len=500) :: line ! to store a line of text
+      LOGICAL :: moderntracdef=.false. ! JVO, YJ : modern traceur.def
+
 c=======================================================================
 c INITIALISATION
@@ -152,5 +156,25 @@
      &       iostat=ierr)
       if (ierr.eq.0) then
-        read(90,*,iostat=ierr) nq
+        ! read number of tracers:
+        !! - Modif. by JVO and YJ for modern planetary traceur.def ---------------
+            READ(90,'(A)') line
+            IF (trim(line).ne.'#ModernTrac-v1') THEN ! Test modern traceur.def
+               READ(line,*,iostat=ierr) nq ! Try standard traceur.def
+            ELSE
+               moderntracdef = .true.
+               DO
+                 READ(90,'(A)',iostat=ierr) line
+                 IF (ierr.eq.0) THEN
+                   IF (index(line,'#').ne.1) THEN ! Allows arbitary number of comments lines in the header
+                     READ(line,*,iostat=ierr) nq
+                     EXIT
+                   ENDIF
+                 ELSE ! If pb, or if reached EOF without having found nbtr
+                    write(*,*) "rcm1d: error reading number of tracers"
+                    write(*,*) "   (first line of traceur.def) "
+                    stop
+                 ENDIF
+               ENDDO
+            ENDIF ! if modern or standard traceur.def
       else
         nq=0
@@ -243,5 +267,24 @@
           write(*,*) "rcm1d: Reading file traceur.def"
           ! read number of tracers:
-          read(90,*,iostat=ierr) nq
+          !! - Modif. by JVO and YJ for modern planetary traceur.def ---------------
+          READ(90,'(A)') line
+          IF (trim(line).ne.'#ModernTrac-v1') THEN ! Test modern traceur.def
+             READ(line,*,iostat=ierr) nq ! Try standard traceur.def
+          ELSE
+             moderntracdef = .true.
+             DO
+               READ(90,'(A)',iostat=ierr) line
+               IF (ierr.eq.0) THEN
+                 IF (index(line,'#').ne.1) THEN ! Allows arbitary number of comments lines in the header
+                   READ(line,*,iostat=ierr) nq
+                   EXIT
+                 ENDIF
+               ELSE ! If pb, or if reached EOF without having found nbtr
+                  write(*,*) "rcm1d: error reading number of tracers"
+                  write(*,*) "   (first line of traceur.def) "
+                  stop
+               ENDIF
+             ENDDO
+          ENDIF ! if modern or standard traceur.def
           nqtot=nq ! set value of nqtot (in infotrac module) as nq
           if (ierr.ne.0) then
Index: /trunk/LMDZ.GENERIC/libf/phystd/initracer.F
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/initracer.F	(revision 2435)
+++ /trunk/LMDZ.GENERIC/libf/phystd/initracer.F	(revision 2436)
@@ -20,4 +20,5 @@
 c   ------
 c            Ehouarn Millour (oct. 2008) identify tracers by their names
+c            Y Jaziri & J. Vatant d'Ollone (2020) : Modern traceur.def
 c=======================================================================
 
@@ -25,7 +26,7 @@
       character(len=30),intent(in) :: nametrac(nq) ! name of the tracer from dynamics
 
-      character(len=30) :: txt ! to store some text
-      integer iq,ig,count
-      real r0_lift , reff_lift
+      character(len=500) :: tracline   ! to read traceur.def lines
+      character(len=30)  :: txt        ! to store some text
+      integer iq,ig,count,ierr
 
 
@@ -43,4 +44,38 @@
 c-----------------------------------------------------------------------
 
+      moderntracdef=.false. ! For modern traceur.def (default false, old type)
+
+      open(407, form = 'formatted', status = 'old',
+     $          file = 'traceur.def', iostat=ierr)
+      if (ierr /=0) then
+        call abort_physic('initracer',
+     $  'Problem in opening traceur.def',1)
+      end if
+!! - Modif. by JVO and YJ for modern planetary traceur.def ---------------
+       READ(407,'(A)') tracline
+       IF (trim(tracline).ne.'#ModernTrac-v1') THEN ! Test modern traceur.def
+          READ(tracline,*) nqtot ! Try standard traceur.def
+       ELSE
+         moderntracdef = .true.
+         DO
+           READ(407,'(A)',iostat=ierr) tracline
+           IF (ierr==0) THEN
+             IF (index(tracline,'#').ne.1) THEN ! Allows arbitary number of comments lines in the header
+               READ(tracline,*) nqtot
+               ! Temporary not implemented solution
+               if (nqtot/=nq) then
+                 call abort_physic('initracer','Different number of&
+     & tracers in dynamics and physics not managed yet',1)
+               endif
+               EXIT
+             ENDIF
+           ELSE ! If pb, or if reached EOF without having found nqtot
+             call abort_physic('initracer','Unable to read numbers&
+     & of tracers in traceur.def',1)
+           ENDIF
+         ENDDO
+       ENDIF ! if modern or standard traceur.def
+!! -----------------------------------------------------------------------
+       !! For the moment number of tracers in dynamics and physics are equal
        nqtot=nq
        !! we allocate once for all arrays in common in tracer_h.F90
@@ -339,4 +374,11 @@
       endif
 
+      ! Get data of tracers
+      do iq=1,nqtot
+        read(407,'(A)') tracline
+        call get_tracdat(iq, tracline)
+      enddo
+
+      close(407)
 
 c------------------------------------------------------------
@@ -410,3 +452,32 @@
       write(*,*)
 
+      contains
+
+      subroutine get_tracdat(iq,tracline)
+        !-------------------ADDING NEW OPTIONS-------------------
+        ! Duplicate if sentence for adding new options
+        ! Do not forget to add the new variables in tracer_h.F90
+        ! Do not forget to allocate and initialize the new variables above
+        ! Please update list of options in "LMDZ.GENERIC/deftank/traceur.def.modern"
+        !-------------------------------------------------------
+          use tracer_h
+          implicit none
+          integer,           intent(in) :: iq       ! tracer index
+          character(len=500),intent(in) :: tracline ! traceur.def lines with parameters
+  
+          read(tracline,*) noms(iq)
+          ! JVO 20 : We should add a sanity check aborting when duplicates in names !
+          write(*,*)"initracer: iq=",iq,"noms(iq)=",trim(noms(iq))
+          if (index(tracline,'mmol='   ) /= 0) then
+              read(tracline(index(tracline,'mmol=')+len('mmol='):),*)
+     $             mmol(iq)
+              write(*,*) ' Parameter value (traceur.def) : mmol=',
+     $             mmol(iq)
+          else
+              write(*,*) ' Parameter value (default)     : mmol=',
+     $             mmol(iq)
+          end if
+      end subroutine get_tracdat
+
       end
+
Index: /trunk/LMDZ.GENERIC/libf/phystd/tracer_h.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/tracer_h.F90	(revision 2435)
+++ /trunk/LMDZ.GENERIC/libf/phystd/tracer_h.F90	(revision 2436)
@@ -6,4 +6,7 @@
        integer, save :: nqtot ! total number of tracers
 !$OMP THREADPRIVATE(nqtot)
+
+       logical :: moderntracdef=.false. ! Standard or modern traceur.def
+!$OMP THREADPRIVATE(moderntracdef)
 
        character*30, save, allocatable :: noms(:)   ! name of the tracer
