Index: LMDZ6/branches/Portage_acc/libf/dyn3d/advtrac.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d/advtrac.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d/advtrac.F90	(revision 4446)
@@ -11,5 +11,5 @@
    !            M.A Filiberti (04/2002)
    !
-   USE infotrac,     ONLY: nqtot, tracers,ok_iso_verif
+   USE infotrac,     ONLY: nqtot, tracers, isoCheck
    USE control_mod,  ONLY: iapp_tracvl, day_step
    USE comconst_mod, ONLY: dtvr
@@ -215,8 +215,6 @@
 #endif
 
-   IF(ok_iso_verif) THEN
-      WRITE(*,*) 'advtrac 227'
-      CALL check_isotopes_seq(q,ip1jmp1,'advtrac 162')
-   END IF
+   IF(isoCheck) WRITE(*,*) 'advtrac 227'
+   CALL check_isotopes_seq(q,ip1jmp1,'advtrac 162')
 
    !-------------------------------------------------------------------------
@@ -346,8 +344,6 @@
    END DO
 
-   IF(ok_iso_verif) then
-      WRITE(*,*) 'advtrac 402'
-      CALL check_isotopes_seq(q,ip1jmp1,'advtrac 397')
-   END IF
+   IF(isoCheck) WRITE(*,*) 'advtrac 402'
+   CALL check_isotopes_seq(q,ip1jmp1,'advtrac 397')
 
    !-------------------------------------------------------------------------
Index: LMDZ6/branches/Portage_acc/libf/dyn3d/check_isotopes.F
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d/check_isotopes.F	(revision 4445)
+++ 	(revision )
@@ -1,203 +1,0 @@
-        subroutine check_isotopes_seq(q,ip1jmp1,err_msg)
-        USE infotrac, ONLY: nqtot, nqo, niso, ntraciso, nzone,
-     &                     use_iso, 
-     &                     iqiso, index_trac,indnum_fn_num, tnat
-        implicit none
-
-#include "dimensions.h"
-
-        ! inputs
-        integer ip1jmp1
-        real q(ip1jmp1,llm,nqtot)
-        character*(*) err_msg ! message d''erreur à afficher
-
-        ! locals
-        integer ixt,phase,k,i,iq,iiso,izone,ieau,iqeau
-        real xtractot,xiiso
-        real borne
-        real qmin
-        real errmax ! erreur maximale en absolu.
-        real errmaxrel ! erreur maximale en relatif autorisée
-        real deltaDmax,deltaDmin
-        real ridicule
-        parameter (borne=1e19)
-        parameter (errmax=1e-8)
-        parameter (errmaxrel=1e-3)
-        parameter (qmin=1e-11)
-        parameter (deltaDmax=1000.0,deltaDmin=-999.0)
-        parameter (ridicule=1e-12)
-        real deltaD
-
-        if (niso > 0) then
-
-        write(*,*) 'check_isotopes 31: err_msg=',err_msg
-        ! verifier que rien n'est NaN
-        do ixt=1,ntraciso
-          do phase=1,nqo
-            iq=iqiso(ixt,phase)
-            do k=1,llm
-              DO i = 1,ip1jmp1
-                if ((q(i,k,iq).gt.-borne).and.
-     :            (q(i,k,iq).lt.borne)) then
-                else !if ((x(ixt,i,j).gt.-borne).and.
-                  write(*,*) 'erreur detectee par iso_verif_noNaN:'
-                  write(*,*) err_msg
-                  write(*,*) 'q,i,k,iq=',q(i,k,iq),i,k,iq
-                  write(*,*) 'borne=',borne
-                  call abort_gcm('check_isotopes_loc','plantage iso',0)
-                endif  !if ((x(ixt,i,j).gt.-borne).and.
-              enddo !DO i = 1,ip1jmp1
-            enddo !do k=1,llm
-          enddo !do phase=1,nqo
-        enddo !do ixt=1,ntraciso
-
-        !write(*,*) 'check_isotopes 52'
-        ! verifier que l'eau normale est OK
-        if (use_iso(1)) then
-          ixt=indnum_fn_num(1)
-          do phase=1,nqo
-            iq=iqiso(ixt,phase)
-            do k=1,llm
-            DO i = 1,ip1jmp1  
-              if ((abs(q(i,k,phase)-q(i,k,iq)).gt.errmax).and.
-     :          (abs((q(i,k,phase)-q(i,k,iq))/
-     :           max(max(abs(q(i,k,phase)),abs(q(i,k,iq))),1e-18))
-     :           .gt.errmaxrel)) then
-                  write(*,*) 'erreur detectee par iso_verif_egalite:'
-                  write(*,*) err_msg
-                  write(*,*) 'ixt,phase=',ixt,phase
-                  write(*,*) 'q,iq,i,k=',q(i,k,iq),iq,i,k
-                  write(*,*) 'q(i,k,phase)=',q(i,k,phase)
-                  call abort_gcm('check_isotopes_loc','plantage iso',0)
-              endif !if ((abs(q(i,k,phase)-q(i,k,iq)).gt.errmax).and.
-              ! bidouille pour éviter divergence:
-              q(i,k,iq)= q(i,k,phase) 
-            enddo ! DO i = 1,ip1jmp1
-            enddo !do k=1,llm
-          enddo ! do phase=1,nqo 
-        endif !if (use_iso(1)) then
-        
-        !write(*,*) 'check_isotopes 78'
-        ! verifier que HDO est raisonable
-        if (use_iso(2)) then
-          ixt=indnum_fn_num(2)
-          do phase=1,nqo
-            iq=iqiso(ixt,phase)
-            do k=1,llm
-            DO i = 1,ip1jmp1
-            if (q(i,k,iq).gt.qmin) then
-             deltaD=(q(i,k,iq)/q(i,k,phase)/tnat(2)-1)*1000
-             if ((deltaD.gt.deltaDmax).or.(deltaD.lt.deltaDmin)) then
-                  write(*,*) 'erreur detectee par iso_verif_aberrant:'
-                  write(*,*) err_msg
-                  write(*,*) 'ixt,phase=',ixt,phase
-                  write(*,*) 'q,iq,i,k,=',q(i,k,iq),iq,i,k
-                  write(*,*) 'q=',q(i,k,:)
-                  write(*,*) 'deltaD=',deltaD
-                  call abort_gcm('check_isotopes_loc','plantage iso',0)
-             endif !if ((deltaD.gt.deltaDmax).or.(deltaD.lt.deltaDmin)) then
-            endif !if (q(i,k,iq).gt.qmin) then
-            enddo !DO i = 1,ip1jmp1
-            enddo !do k=1,llm
-          enddo ! do phase=1,nqo 
-        endif !if (use_iso(2)) then
-
-        !write(*,*) 'check_isotopes 103'
-        ! verifier que O18 est raisonable
-        if (use_iso(3)) then
-          ixt=indnum_fn_num(3)
-          do phase=1,nqo
-            iq=iqiso(ixt,phase)
-            do k=1,llm
-            DO i = 1,ip1jmp1
-            if (q(i,k,iq).gt.qmin) then
-             deltaD=(q(i,k,iq)/q(i,k,phase)/tnat(3)-1)*1000
-             if ((deltaD.gt.deltaDmax).or.(deltaD.lt.deltaDmin)) then
-                  write(*,*) 'erreur detectee iso_verif_aberrant O18:'
-                  write(*,*) err_msg
-                  write(*,*) 'ixt,phase=',ixt,phase
-                  write(*,*) 'q,iq,i,k,=',q(i,k,phase),iq,i,k
-                  write(*,*) 'xt=',q(i,k,:)
-                  write(*,*) 'deltaO18=',deltaD
-                  call abort_gcm('check_isotopes_loc','plantage iso',0)
-             endif !if ((deltaD.gt.deltaDmax).or.(deltaD.lt.deltaDmin)) then
-            endif !if (q(i,k,iq).gt.qmin) then
-            enddo !DO i = 1,ip1jmp1
-            enddo !do k=1,llm
-          enddo ! do phase=1,nqo 
-        endif !if (use_iso(2)) then
-
-
-        !write(*,*) 'check_isotopes 129'
-        if (nzone > 0) then
-
-          if (use_iso(2).and.use_iso(1)) then
-            do izone=1,nzone
-             ixt=index_trac(izone,indnum_fn_num(2))
-             ieau=index_trac(izone,indnum_fn_num(1))
-             do phase=1,nqo
-               iq=iqiso(ixt,phase)
-               iqeau=iqiso(ieau,phase)
-               do k=1,llm
-                DO i = 1,ip1jmp1
-                if (q(i,k,iq).gt.qmin) then
-                 deltaD=(q(i,k,iq)/q(i,k,iqeau)/tnat(2)-1)*1000
-                 if ((deltaD.gt.deltaDmax).or.
-     &                   (deltaD.lt.deltaDmin)) then
-                  write(*,*) 'erreur dans iso_verif_aberrant trac:'
-                  write(*,*) err_msg
-                  write(*,*) 'izone,phase=',izone,phase
-                  write(*,*) 'ixt,ieau=',ixt,ieau
-                  write(*,*) 'q,iq,i,k,=',q(i,k,iq),iq,i,k
-                  write(*,*) 'deltaD=',deltaD
-                  call abort_gcm('check_isotopes_loc','plantage iso',0)
-                 endif !if ((deltaD.gt.deltaDmax).or.
-                endif !if (q(i,k,iq).gt.qmin) then
-                enddo !DO i = 1,ip1jmp1
-                enddo  ! do k=1,llm
-              enddo ! do phase=1,nqo    
-            enddo !do izone=1,nzone
-          endif !if (use_iso(2).and.use_iso(1)) then
-
-          do iiso=1,niso
-           do phase=1,nqo
-              iq=iqiso(iiso,phase)
-              do k=1,llm
-                DO i = 1,ip1jmp1
-                   xtractot=0.0
-                   xiiso=q(i,k,iq)
-                   do izone=1,nzone
-                      iq=iqiso(index_trac(izone,iiso),phase)
-                      xtractot=xtractot+ q(i,k,iq)
-                   enddo !do izone=1,ntraceurs_zone
-                   if ((abs(xtractot-xiiso).gt.errmax).and.
-     :                  (abs(xtractot-xiiso)/
-     :                  max(max(abs(xtractot),abs(xiiso)),1e-18)
-     :                  .gt.errmaxrel)) then
-                  write(*,*) 'erreur detectee par iso_verif_traceurs:'
-                  write(*,*) err_msg
-                  write(*,*) 'iiso,phase=',iiso,phase
-                  write(*,*) 'i,k,=',i,k
-                  write(*,*) 'q(i,k,:)=',q(i,k,:)
-                  call abort_gcm('check_isotopes_loc','plantage iso',0)
-                 endif !if ((abs(q(i,k,phase)-q(i,k,iq)).gt.errmax).and.
-                  
-                 ! bidouille pour éviter divergence:
-                 if (abs(xtractot).gt.ridicule) then
-                   do izone=1,nzone
-                     ixt=index_trac(izone,iiso) 
-                     q(i,k,iq)=q(i,k,iq)/xtractot*xiiso
-                   enddo !do izone=1,nzone                
-                  endif !if ((abs(xtractot).gt.ridicule) then
-                enddo !DO i = 1,ip1jmp1
-              enddo !do k=1,llm
-           enddo !do phase=1,nqo
-          enddo !do iiso=1,niso
-
-        endif !if (nzone > 0)
-
-        endif ! if (niso > 0)
-        !write(*,*) 'check_isotopes 198'
-        
-        end
-
Index: LMDZ6/branches/Portage_acc/libf/dyn3d/check_isotopes.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d/check_isotopes.F90	(revision 4446)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d/check_isotopes.F90	(revision 4446)
@@ -0,0 +1,174 @@
+SUBROUTINE check_isotopes_seq(q, ip1jmp1, err_msg)
+   USE strings_mod, ONLY: maxlen, msg, strIdx, strStack, int2str, real2str
+   USE infotrac,    ONLY: nqtot, niso, nphas, isotope, isoCheck, iqIsoPha, isoSelect, &
+                          ntiso, iH2O, nzone, tracers, isoName,  itZonIso, getKey
+   IMPLICIT NONE
+   include "dimensions.h"
+   REAL,             INTENT(INOUT) :: q(ip1jmp1,llm,nqtot)
+   INTEGER,          INTENT(IN)    :: ip1jmp1
+   CHARACTER(LEN=*), INTENT(IN)    :: err_msg    !--- Error message to display
+   CHARACTER(LEN=maxlen) :: modname, msg1, nm(2)
+   INTEGER :: ixt, ipha, k, i, iq, iiso, izon, ieau, iqeau, iqpar
+   INTEGER, ALLOCATABLE ::   ix(:)
+   REAL,    ALLOCATABLE, SAVE :: tnat(:)
+   REAL    :: xtractot, xiiso, deltaD, q1, q2
+   REAL, PARAMETER :: borne     = 1e19,  &
+                      errmax    = 1e-8,  &       !--- Max. absolute error
+                      errmaxrel = 1e-3,  &       !--- Max. relative error
+                      qmin      = 1e-11, &
+                      deltaDmax =1000.0, &
+                      deltaDmin =-999.0, &
+                      ridicule  = 1e-12
+   INTEGER, SAVE :: iso_eau, iso_HDO, iso_O18, &
+                             iso_O17, iso_HTO
+   LOGICAL, SAVE :: first=.TRUE.
+
+   modname='check_isotopes'
+   IF(.NOT.isoCheck)    RETURN                   !--- No need to check => finished
+   IF(isoSelect('H2O')) RETURN                   !--- No H2O isotopes group found
+   IF(niso == 0)        RETURN                   !--- No isotopes => finished
+   IF(first) THEN
+      iso_eau = strIdx(isoName,'H216O')
+      iso_HDO = strIdx(isoName,'HDO')
+      iso_O18 = strIdx(isoName,'H218O')
+      iso_O17 = strIdx(isoName,'H217O')
+      iso_HTO = strIdx(isoName,'HTO')
+      IF(getKey('tnat', tnat)) CALL abort_gcm(modname, 'missing isotopic parameter', 1)
+      first = .FALSE.
+   END IF
+   CALL msg('31: err_msg='//TRIM(err_msg), modname)
+
+   !--- CHECK FOR NaNs (FOR ALL THE ISOTOPES, INCLUDING GEOGRAPHIC TAGGING TRACERS)
+   modname = 'check_isotopes:iso_verif_noNaN'
+   DO ixt = 1, ntiso
+      DO ipha = 1, nphas
+         iq = iqIsoPha(ixt,ipha)
+         DO k = 1, llm
+            DO i = 1, ip1jmp1
+               IF(ABS(q(i,k,iq)) < borne) CYCLE
+               WRITE(msg1,'(s,"(",i0,",",i0,",",i0,") = ",ES12.4)')TRIM(isoName(ixt)),i,k,iq,q(i,k,iq)
+               CALL msg(msg1, modname)
+               CALL abort_gcm(modname, 'Error with isotopes: '//TRIM(err_msg), 1)
+            END DO
+         END DO
+      END DO
+   END DO
+
+   !--- CHECK CONSERVATION (MAIN ISOTOPE AND PARENT CONCENTRATIONS MUST BE EQUAL)
+   modname = 'check_isotopes:iso_verif_egalite'
+   ixt = iso_eau
+   IF(ixt /= 0) THEN
+      DO ipha = 1, nphas
+         iq = iqIsoPha(ixt,ipha)
+         iqpar = tracers(iq)%iqParent
+         DO k = 1, llm
+            DO i = 1, ip1jmp1
+               q1 = q(i,k,iqpar)
+               q2 = q(i,k,iq)
+!--- IMPROVEMENT in case at least one isotope is not negligible compared to the main isotopic form.
+!    This would be probably required to sum from smallest to highest concentrations ; the corresponding
+!    indices vector can be computed once only (in the initializations stage), using mean concentrations.
+!              q2 = SUM(q(i,k,tracers(iqPar)%iqDesc), DIM=3)
+               IF(ABS(q1-q2) <= errmax .OR. ABS(q1-q2)/MAX(MAX(ABS(q1),ABS(q2)),1e-18) <= errmaxrel) THEN
+                  q(i,k,iq) = q1                 !--- Bidouille pour convergence
+!                 q(i,k,tracers(iqPar)%iqDesc) = q(i,k,tracers(iqPar)%iqDesc) * q1 / q2
+                  CYCLE
+               END IF
+               CALL msg('ixt, iq = '//TRIM(strStack(int2str([ixt,iq]))), modname)
+               msg1 = '('//TRIM(strStack(int2str([i,k])))//')'
+               CALL msg(TRIM(tracers(iqpar)%name)//TRIM(msg1)//' = '//TRIM(real2str(q1)), modname)
+               CALL msg(TRIM(tracers(iq   )%name)//TRIM(msg1)//' = '//TRIM(real2str(q2)), modname)
+               CALL abort_gcm(modname, 'Error with isotopes: '//TRIM(err_msg), 1)
+            END DO
+         END DO
+      END DO
+   END IF
+
+   !--- CHECK DELTA ANOMALIES
+   modname = 'check_isotopes:iso_verif_aberrant'
+   ix = [ iso_HDO  ,   iso_O18 ]
+   nm = ['deltaD  ', 'deltaO18']
+   DO iiso = 1, SIZE(ix)
+      ixt = ix(iiso)
+      IF(ixt  == 0) CYCLE
+      DO ipha = 1, nphas
+         iq = iqIsoPha(ixt,ipha)
+         iqpar = tracers(iq)%iqParent
+         DO k = 1, llm
+            DO i = 1, ip1jmp1
+               q1 = q(i,k,iqpar)
+               q2 = q(i,k,iq)
+!--- IMPROVEMENT in case at least one isotope is not negligible compared to the main isotopic form.
+!    This would be probably required to sum from smallest to highest concentrations ; the corresponding
+!    indices vector can be computed once only (in the initializations stage), using mean concentrations.
+!              q2 = SUM(q(i,k,tracers(iqPar)%iqDesc), DIM=3)
+               IF(q2 <= qmin) CYCLE
+               deltaD = (q2/q1/tnat(ixt)-1.)*1000.
+               IF(deltaD <= deltaDmax .AND. deltaD >= deltaDmin) CYCLE
+               CALL msg('ixt, iq = '//TRIM(strStack(int2str([ixt,iq]))), modname)
+               msg1 = '('//TRIM(strStack(int2str([i,k])))//')'
+               CALL msg(TRIM(tracers(iqpar)%name)//TRIM(msg1)//' = '//TRIM(real2str(q1)), modname)
+               CALL msg(TRIM(tracers(iq   )%name)//TRIM(msg1)//' = '//TRIM(real2str(q2)), modname)
+               CALL msg(TRIM(nm(iiso))//TRIM(real2str(deltaD)), modname)
+               CALL abort_gcm(modname, 'Error with isotopes: '//TRIM(err_msg), 1)
+            END DO
+         END DO
+      END DO
+   END DO
+
+   IF(nzone == 0) RETURN
+
+   !--- CHECK FOR TAGGING TRACERS DELTAD ANOMALIES
+   modname = 'check_isotopes:iso_verif_aberrant'
+   IF(iso_eau /= 0 .AND. iso_HDO /= 0) THEN
+      DO izon = 1, nzone
+         ixt  = itZonIso(izon, iso_HDO)
+         ieau = itZonIso(izon, iso_eau)
+         DO ipha = 1, nphas
+            iq    = iqIsoPha(ixt,  ipha)
+            iqeau = iqIsoPha(ieau, ipha)
+            DO k = 1, llm
+               DO i = 1, ip1jmp1
+                  q1 = q(i,k,iqeau)
+                  q2 = q(i,k,iq)
+                  IF(q2<=qmin) CYCLE
+                  deltaD = (q2/q1/tnat(iso_HDO)-1.)*1000.
+                  IF(deltaD <= deltaDmax .AND. deltaD >= deltaDmin) CYCLE
+                  CALL msg('izon, ipha = '//TRIM(strStack(int2str([izon, ipha]))), modname)
+                  CALL msg( 'ixt, ieau = '//TRIM(strStack(int2str([ ixt, ieau]))), modname)
+                  msg1 = '('//TRIM(strStack(int2str([i,k])))//')'
+                  CALL msg(TRIM(tracers(iqeau)%name)//TRIM(msg1)//' = '//TRIM(real2str(q1)), modname)
+                  CALL msg(TRIM(tracers(iq   )%name)//TRIM(msg1)//' = '//TRIM(real2str(q2)), modname)
+                  CALL msg('deltaD = '//TRIM(real2str(deltaD)), modname)
+                  CALL abort_gcm(modname, 'Error with isotopes: '//TRIM(err_msg), 1)
+               END DO
+            END DO
+         END DO
+      END DO
+   END IF
+
+   !--- CHECK FOR TAGGING TRACERS CONSERVATION (PARENT AND TAGGING TRACERS SUM OVER ALL REGIONS MUST BE EQUAL)
+   DO iiso = 1, niso
+      DO ipha = 1, nphas
+         iq = iqIsoPha(iiso, ipha)
+         DO k = 1, llm
+            DO i = 1, ip1jmp1
+               xiiso = q(i,k,iq)
+               xtractot = SUM(q(i, k, iqIsoPha(itZonIso(1:nzone,iiso), ipha)))
+               IF(ABS(xtractot-xiiso) > errmax .AND. ABS(xtractot-xiiso)/MAX(MAX(ABS(xtractot),ABS(xiiso)),1e-18) > errmaxrel) THEN
+                  CALL msg('Error in iso_verif_aberrant trac: '//TRIM(err_msg))
+                  CALL msg('iiso, ipha = '//TRIM(strStack(int2str([iiso, ipha]))), modname)
+                  CALL msg('q('//TRIM(strStack(int2str([i,k])))//',:) = '//TRIM(strStack(real2str(q(i,k,:)))), modname)
+                  CALL abort_gcm(modname, 'Error with isotopes: '//TRIM(err_msg), 1)
+               END IF
+               IF(ABS(xtractot) <= ridicule) CYCLE
+               DO izon = 1, nzone
+                  q(i,k,iq) = q(i,k,iq) / xtractot * xiiso !--- Bidouille pour convergence
+               END DO
+            END DO
+         END DO
+      END DO
+   END DO
+
+END SUBROUTINE check_isotopes_seq
+
Index: LMDZ6/branches/Portage_acc/libf/dyn3d/conf_gcm.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d/conf_gcm.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d/conf_gcm.F90	(revision 4446)
@@ -599,14 +599,4 @@
      type_trac = 'lmdz'
      CALL getin('type_trac',type_trac)
-
-     !Config  Key  = config_inca
-     !Config  Desc = Choix de configuration de INCA
-     !Config  Def  = none
-     !Config  Help = Choix de configuration de INCA :
-     !Config         'none' = sans INCA
-     !Config         'chem' = INCA avec calcul de chemie
-     !Config         'aero' = INCA avec calcul des aerosols 
-     config_inca = 'none'
-     CALL getin('config_inca',config_inca)
 
      !Config  Key  = ok_dynzon 
@@ -672,5 +662,4 @@
      write(lunout,*)' offline = ', offline
      write(lunout,*)' type_trac = ', type_trac
-     write(lunout,*)' config_inca = ', config_inca
      write(lunout,*)' ok_dynzon = ', ok_dynzon 
      write(lunout,*)' ok_dyn_ins = ', ok_dyn_ins 
@@ -795,14 +784,4 @@
      type_trac = 'lmdz'
      CALL getin('type_trac',type_trac)
-
-     !Config  Key  = config_inca
-     !Config  Desc = Choix de configuration de INCA
-     !Config  Def  = none
-     !Config  Help = Choix de configuration de INCA :
-     !Config         'none' = sans INCA
-     !Config         'chem' = INCA avec calcul de chemie
-     !Config         'aero' = INCA avec calcul des aerosols 
-     config_inca = 'none'
-     CALL getin('config_inca',config_inca)
 
      !Config  Key  = ok_dynzon 
@@ -912,5 +891,4 @@
      write(lunout,*)' offline = ', offline
      write(lunout,*)' type_trac = ', type_trac
-     write(lunout,*)' config_inca = ', config_inca
      write(lunout,*)' ok_dynzon = ', ok_dynzon
      write(lunout,*)' ok_dyn_ins = ', ok_dyn_ins 
Index: LMDZ6/branches/Portage_acc/libf/dyn3d/dynetat0.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d/dynetat0.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d/dynetat0.F90	(revision 4446)
@@ -6,9 +6,9 @@
 ! Purpose: Initial state reading.
 !-------------------------------------------------------------------------------
-  USE infotrac,    ONLY: nqtot, tracers, niso, iqiso, iso_indnum, iso_num, tnat, alpha_ideal, iH2O
-  USE strings_mod, ONLY: maxlen, msg, strStack, real2str
+  USE infotrac,    ONLY: nqtot, tracers, niso, iqIsoPha, iH2O, isoName
+  USE strings_mod, ONLY: maxlen, msg, strStack, real2str, int2str
   USE netcdf,      ONLY: NF90_OPEN,  NF90_NOWRITE, NF90_INQ_VARID, &
                          NF90_CLOSE, NF90_GET_VAR, NF90_NoErr
-  USE readTracFiles_mod, ONLY: new2oldName
+  USE readTracFiles_mod, ONLY: new2oldH2O, newHNO3, oldHNO3, getKey
   USE control_mod, ONLY: planet_type
   USE assert_eq_m, ONLY: assert_eq
@@ -41,5 +41,6 @@
   INTEGER, PARAMETER :: length=100
   INTEGER :: iq, fID, vID, idecal, iqParent, iName, iZone, iPhase
-  REAL    :: time, tab_cntrl(length)               !--- RUN PARAMS TABLE
+  REAL    :: time, tnat, alpha_ideal, tab_cntrl(length)    !--- RUN PARAMS TABLE
+  LOGICAL :: lSkip, ll
 !-------------------------------------------------------------------------------
   modname="dynetat0"
@@ -127,32 +128,38 @@
 
 !--- Tracers
+  ll=.FALSE.
+#ifdef REPROBUS
+  ll = NF90_INQ_VARID(fID, 'HNO3tot', vID) /= NF90_NoErr                                 !--- DETECT OLD REPRO start.nc FILE
+#endif
   DO iq=1,nqtot
     var = tracers(iq)%name
-    oldVar = new2oldName(var)
-    !--------------------------------------------------------------------------------------------------------------------------
-    IF(NF90_INQ_VARID(fID, var, vID) == NF90_NoErr) THEN                                 !=== REGULAR CASE
+    oldVar = new2oldH2O(var)
+    lSkip = ll .AND. var == 'HNO3'                                                       !--- FORCE "HNO3_g" READING FOR "HNO3"
+#ifdef REPROBUS
+    ix = strIdx(newHNO3, var); IF(ix /= 0) oldVar = oldHNO3(ix)                          !--- REPROBUS HNO3 exceptions
+#endif
+#ifdef INCA
+    IF(var == 'O3') oldVar = 'OX'                                                        !--- DEAL WITH INCA OZONE EXCEPTION
+#endif
+    !--------------------------------------------------------------------------------------------------------------------------
+    IF(NF90_INQ_VARID(fID, var, vID) == NF90_NoErr .AND. .NOT.lSkip) THEN                !=== REGULAR CASE: AVAILABLE VARIABLE
       CALL err(NF90_GET_VAR(fID,vID,q(:,:,:,iq)),"get",var)
     !--------------------------------------------------------------------------------------------------------------------------
-    ELSE IF(NF90_INQ_VARID(fID, oldVar, vID) == NF90_NoErr) THEN                         !=== OLD NAME
+    ELSE IF(NF90_INQ_VARID(fID, oldVar, vID) == NF90_NoErr) THEN                         !=== TRY WITH ALTERNATE NAME
       CALL msg('Tracer <'//TRIM(var)//'> is missing => initialized to <'//TRIM(oldVar)//'>', modname)
       CALL err(NF90_GET_VAR(fID,vID,q(:,:,:,iq)),"get",oldVar)
     !--------------------------------------------------------------------------------------------------------------------------
-#ifdef INCA
-    ELSE IF(NF90_INQ_VARID(fID, 'OX',   vID) == NF90_NoErr .AND. var == 'O3') THEN       !=== INCA: OX INSTEAD OF O3
-      CALL msg('Tracer <O3> is missing => initialized to <OX>', modname)
-      CALL err(NF90_GET_VAR(fID,vID,q(:,:,:,iq)),"get",'OX')
-    !--------------------------------------------------------------------------------------------------------------------------
-#endif
     ELSE IF(tracers(iq)%iso_iGroup == iH2O .AND. niso > 0) THEN                          !=== WATER ISOTOPES
-!     iName    = tracers(iq)%iso_iName  ! (next commit)
-      iName    = iso_num(iq)
+      iName    = tracers(iq)%iso_iName
       iPhase   = tracers(iq)%iso_iPhase
       iqParent = tracers(iq)%iqParent
       IF(tracers(iq)%iso_iZone == 0) THEN
+         IF(getKey('tnat', tnat, isoName(iName)) .OR. getKey('alpha', alpha_ideal, isoName(iName))) &
+            CALL abort_gcm(TRIM(modname), 'missing isotopic parameters', 1)
          CALL msg('Tracer <'//TRIM(var)//'> is missing => initialized with a simplified Rayleigh distillation law.', modname)
-         q(:,:,:,iq) = q(:,:,:,iqParent)*tnat(iName)*(q(:,:,:,iqParent)/30.e-3)**(alpha_ideal(iName)-1.)
+         q(:,:,:,iq) = q(:,:,:,iqParent)*tnat*(q(:,:,:,iqParent)/30.e-3)**(alpha_ideal-1.)
       ELSE
          CALL msg('Tracer <'//TRIM(var)//'> is missing => initialized to its parent isotope concentration.', modname)
-         q(:,:,:,iq) = q(:,:,:,iqiso(iso_indnum(iq),iPhase))
+         q(:,:,:,iq) = q(:,:,:,iqIsoPha(iName,iPhase))
       END IF
     !--------------------------------------------------------------------------------------------------------------------------
@@ -176,10 +183,6 @@
   CHARACTER(LEN=*), INTENT(IN) :: str1, str2
   CHARACTER(LEN=maxlen) :: s1, s2
-  IF(n1/=n2) THEN
-    s1='value of '//TRIM(str1)//' ='
-    s2=' read in starting file differs from parametrized '//TRIM(str2)//' ='
-    WRITE(mesg,'(10x,a,i4,2x,a,i4)')TRIM(ADJUSTL(s1)),n1,TRIM(ADJUSTL(s2)),n2
-    CALL ABORT_gcm(TRIM(modname),TRIM(mesg),1)
-  END IF
+  IF(n1/=n2) CALL abort_gcm(TRIM(modname), 'value of "'//TRIM(str1)//'" = '//TRIM(int2str(n1))// &
+   ' read in starting file differs from gcm value of "'//TRIM(str2)//'" = '//TRIM(int2str(n2)), 1)
 END SUBROUTINE check_dim
 
Index: LMDZ6/branches/Portage_acc/libf/dyn3d/dynredem.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d/dynredem.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d/dynredem.F90	(revision 4446)
@@ -228,5 +228,5 @@
 !--- Tracers in file "start_trac.nc" (added by Anne)
   lread_inca=.FALSE.; fil="start_trac.nc"
-  IF(type_trac=='inca' .OR. type_trac=='inco') INQUIRE(FILE=fil,EXIST=lread_inca)
+  IF(ANY(type_trac == ['inca','inco'])) INQUIRE(FILE=fil,EXIST=lread_inca)
   IF(lread_inca) CALL err(NF90_OPEN(fil,NF90_NOWRITE,nid_trac),"open")
 
Index: LMDZ6/branches/Portage_acc/libf/dyn3d/gcm.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d/gcm.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d/gcm.F90	(revision 4446)
@@ -20,5 +20,5 @@
 
   USE filtreg_mod
-  USE infotrac
+  USE infotrac, ONLY: nqtot, init_infotrac
   USE control_mod
   USE mod_const_mpi, ONLY: COMM_LMDZ
@@ -178,5 +178,5 @@
 #ifdef CPP_IOIPSL
   if (calend == 'earth_360d') then
-     call ioconf_calendar('360d')
+     call ioconf_calendar('360_day')
      write(lunout,*)'CALENDRIER CHOISI: Terrestre a 360 jours/an'
   else if (calend == 'earth_365d') then
@@ -205,5 +205,5 @@
   !  Choix du nombre de traceurs et du schema pour l'advection
   !  dans fichier traceur.def, par default ou via INCA
-  call infotrac_init
+  call init_infotrac
 
   ! Allocation de la tableau q : champs advectes   
Index: LMDZ6/branches/Portage_acc/libf/dyn3d/guide_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d/guide_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d/guide_mod.F90	(revision 4446)
@@ -39,4 +39,6 @@
   REAL, PRIVATE, SAVE     :: lon_min_g,lon_max_g
   REAL, PRIVATE, SAVE     :: tau_lon,tau_lat
+
+  REAL, PRIVATE, SAVE     :: plim_guide_BL
 
   REAL, ALLOCATABLE, DIMENSION(:), PRIVATE, SAVE     :: alpha_u,alpha_v 
@@ -67,4 +69,5 @@
   SUBROUTINE guide_init
 
+    use netcdf, only: nf90_noerr
     USE control_mod, ONLY: day_step
     USE serre_mod, ONLY: grossismx
@@ -113,4 +116,6 @@
     CALL getpar('gamma4',.false.,gamma4,'Zone sans rappel elargie')
     CALL getpar('guide_BL',.true.,guide_BL,'guidage dans C.Lim')
+    CALL getpar('plim_guide_BL',85000.,plim_guide_BL,'BL top presnivs value')
+
 
 ! Sauvegarde du for�age
@@ -169,5 +174,5 @@
        if (ncidpl.eq.-99) then
           rcod=nf90_open('apbp.nc',Nf90_NOWRITe, ncidpl)
-          if (rcod.NE.NF_NOERR) THEN
+          if (rcod.NE.NF90_NOERR) THEN
              abort_message=' Nudging error -> no file apbp.nc'
              CALL abort_gcm(modname,abort_message,1)
@@ -177,5 +182,5 @@
        if (ncidpl.EQ.-99) then
           rcod=nf90_open('P.nc',Nf90_NOWRITe,ncidpl)
-          if (rcod.NE.NF_NOERR) THEN
+          if (rcod.NE.NF90_NOERR) THEN
              abort_message=' Nudging error -> no file P.nc'
              CALL abort_gcm(modname,abort_message,1)
@@ -186,5 +191,5 @@
            if (ncidpl.eq.-99) then
                rcod=nf90_open('u.nc',Nf90_NOWRITe,ncidpl)
-               if (rcod.NE.NF_NOERR) THEN
+               if (rcod.NE.NF90_NOERR) THEN
                   CALL abort_gcm(modname, &
                        ' Nudging error -> no file u.nc',1)
@@ -195,5 +200,5 @@
            if (ncidpl.eq.-99) then
                rcod=nf90_open('v.nc',nf90_nowrite,ncidpl)
-               if (rcod.NE.NF_NOERR) THEN
+               if (rcod.NE.NF90_NOERR) THEN
                   CALL abort_gcm(modname, &
                        ' Nudging error -> no file v.nc',1)
@@ -203,5 +208,5 @@
            if (ncidpl.eq.-99) then
                rcod=nf90_open('T.nc',nf90_nowrite,ncidpl)
-               if (rcod.NE.NF_NOERR) THEN
+               if (rcod.NE.NF90_NOERR) THEN
                   CALL abort_gcm(modname, &
                        ' Nudging error -> no file T.nc',1)
@@ -211,5 +216,5 @@
            if (ncidpl.eq.-99) then
                rcod=nf90_open('hur.nc',nf90_nowrite, ncidpl)
-               if (rcod.NE.NF_NOERR) THEN
+               if (rcod.NE.NF90_NOERR) THEN
                   CALL abort_gcm(modname, &
                        ' Nudging error -> no file hur.nc',1)
@@ -220,6 +225,6 @@
     endif 
     error=NF_INQ_DIMID(ncidpl,'LEVEL',rid)
-    IF (error.NE.NF_NOERR) error=NF_INQ_DIMID(ncidpl,'PRESSURE',rid)
-    IF (error.NE.NF_NOERR) THEN
+    IF (error.NE.NF90_NOERR) error=NF_INQ_DIMID(ncidpl,'PRESSURE',rid)
+    IF (error.NE.NF90_NOERR) THEN
         CALL abort_gcm(modname,'Nudging: error reading pressure levels',1)
     ENDIF
@@ -399,5 +404,5 @@
         else
             do l=1,llm
-                alpha_pcor(l)=(1.+tanh((0.85-presnivs(l)/preff)/0.05))/2.
+               alpha_pcor(l)=(1.+tanh(((plim_guide_BL-presnivs(l))/preff)/0.05))/2.
             enddo
         endif
@@ -1078,7 +1083,8 @@
   SUBROUTINE guide_read(timestep)
 
+    use netcdf, only: NF90_GET_VAR, nf90_noerr
+
     IMPLICIT NONE
 
-    include "netcdf.inc"
     include "dimensions.h"
     include "paramet.h"
@@ -1103,24 +1109,24 @@
     if (first) then
          ncidpl=-99
-         write(*,*),trim(modname)//': opening nudging files '
+         write(*,*) trim(modname)//': opening nudging files '
 ! Niveaux de pression si non constants
          if (guide_plevs.EQ.1) then
-             write(*,*),trim(modname)//' Reading nudging on model levels'
+             write(*,*) trim(modname)//' Reading nudging on model levels'
              rcode = nf90_open('apbp.nc', nf90_nowrite, ncidpl)
-             IF (rcode.NE.NF_NOERR) THEN
+             IF (rcode.NE.NF90_NOERR) THEN
               abort_message='Nudging: error -> no file apbp.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
              rcode = nf90_inq_varid(ncidpl, 'AP', varidap)
-             IF (rcode.NE.NF_NOERR) THEN
+             IF (rcode.NE.NF90_NOERR) THEN
               abort_message='Nudging: error -> no AP variable in file apbp.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
              rcode = nf90_inq_varid(ncidpl, 'BP', varidbp)
-             IF (rcode.NE.NF_NOERR) THEN
+             IF (rcode.NE.NF90_NOERR) THEN
               abort_message='Nudging: error -> no BP variable in file apbp.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
-             write(*,*),trim(modname)//' ncidpl,varidap',ncidpl,varidap
+             write(*,*) trim(modname)//' ncidpl,varidap',ncidpl,varidap
          endif
 
@@ -1128,14 +1134,14 @@
          if (guide_plevs.EQ.2) then
              rcode = nf90_open('P.nc', nf90_nowrite, ncidp)
-             IF (rcode.NE.NF_NOERR) THEN
+             IF (rcode.NE.NF90_NOERR) THEN
               abort_message='Nudging: error -> no file P.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
              rcode = nf90_inq_varid(ncidp, 'PRES', varidp)
-             IF (rcode.NE.NF_NOERR) THEN 
+             IF (rcode.NE.NF90_NOERR) THEN 
               abort_message='Nudging: error -> no PRES variable in file P.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
-             write(*,*),trim(modname)//' ncidp,varidp',ncidp,varidp
+             write(*,*) trim(modname)//' ncidp,varidp',ncidp,varidp
              if (ncidpl.eq.-99) ncidpl=ncidp
          endif
@@ -1144,14 +1150,14 @@
          if (guide_u) then
              rcode = nf90_open('u.nc', nf90_nowrite, ncidu)
-             IF (rcode.NE.NF_NOERR) THEN
+             IF (rcode.NE.NF90_NOERR) THEN
               abort_message='Nudging: error -> no file u.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
              rcode = nf90_inq_varid(ncidu, 'UWND', varidu)
-             IF (rcode.NE.NF_NOERR) THEN
+             IF (rcode.NE.NF90_NOERR) THEN
               abort_message='Nudging: error -> no UWND variable in file u.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
-             write(*,*),trim(modname)//' ncidu,varidu',ncidu,varidu
+             write(*,*) trim(modname)//' ncidu,varidu',ncidu,varidu
              if (ncidpl.eq.-99) ncidpl=ncidu
 
@@ -1175,14 +1181,14 @@
          if (guide_v) then
              rcode = nf90_open('v.nc', nf90_nowrite, ncidv)
-             IF (rcode.NE.NF_NOERR) THEN
+             IF (rcode.NE.NF90_NOERR) THEN
               abort_message='Nudging: error -> no file v.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
              rcode = nf90_inq_varid(ncidv, 'VWND', varidv)
-             IF (rcode.NE.NF_NOERR) THEN
+             IF (rcode.NE.NF90_NOERR) THEN
               abort_message='Nudging: error -> no VWND variable in file v.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
-             write(*,*),trim(modname)//' ncidv,varidv',ncidv,varidv
+             write(*,*) trim(modname)//' ncidv,varidv',ncidv,varidv
              if (ncidpl.eq.-99) ncidpl=ncidv
              
@@ -1208,14 +1214,14 @@
          if (guide_T) then
              rcode = nf90_open('T.nc', nf90_nowrite, ncidt)
-             IF (rcode.NE.NF_NOERR) THEN
+             IF (rcode.NE.NF90_NOERR) THEN
               abort_message='Nudging: error -> no file T.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
              rcode = nf90_inq_varid(ncidt, 'AIR', varidt)
-             IF (rcode.NE.NF_NOERR) THEN
+             IF (rcode.NE.NF90_NOERR) THEN
               abort_message='Nudging: error -> no AIR variable in file T.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
-             write(*,*),trim(modname)//' ncidT,varidT',ncidt,varidt
+             write(*,*) trim(modname)//' ncidT,varidT',ncidt,varidt
              if (ncidpl.eq.-99) ncidpl=ncidt
 
@@ -1239,14 +1245,14 @@
          if (guide_Q) then
              rcode = nf90_open('hur.nc', nf90_nowrite, ncidQ)
-             IF (rcode.NE.NF_NOERR) THEN
+             IF (rcode.NE.NF90_NOERR) THEN
               abort_message='Nudging: error -> no file hur.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
              rcode = nf90_inq_varid(ncidQ, 'RH', varidQ)
-             IF (rcode.NE.NF_NOERR) THEN
+             IF (rcode.NE.NF90_NOERR) THEN
               abort_message='Nudging: error -> no RH variable in file hur.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
-             write(*,*),trim(modname)//' ncidQ,varidQ',ncidQ,varidQ
+             write(*,*) trim(modname)//' ncidQ,varidQ',ncidQ,varidQ
              if (ncidpl.eq.-99) ncidpl=ncidQ
 
@@ -1270,14 +1276,14 @@
          if ((guide_P).OR.(guide_modele)) then
              rcode = nf90_open('ps.nc', nf90_nowrite, ncidps)
-             IF (rcode.NE.NF_NOERR) THEN
+             IF (rcode.NE.NF90_NOERR) THEN
               abort_message='Nudging: error -> no file ps.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
              rcode = nf90_inq_varid(ncidps, 'SP', varidps)
-             IF (rcode.NE.NF_NOERR) THEN
+             IF (rcode.NE.NF90_NOERR) THEN
               abort_message='Nudging: error -> no SP variable in file ps.nc'
               CALL abort_gcm(modname,abort_message,1)
              ENDIF
-             write(*,*),trim(modname)//' ncidps,varidps',ncidps,varidps
+             write(*,*) trim(modname)//' ncidps,varidps',ncidps,varidps
          endif
 ! Coordonnee verticale
@@ -1285,21 +1291,12 @@
               rcode = nf90_inq_varid(ncidpl, 'LEVEL', varidpl)
               IF (rcode.NE.0) rcode = nf90_inq_varid(ncidpl, 'PRESSURE', varidpl)
-              write(*,*),trim(modname)//' ncidpl,varidpl',ncidpl,varidpl
+              write(*,*) trim(modname)//' ncidpl,varidpl',ncidpl,varidpl
          endif
 ! Coefs ap, bp pour calcul de la pression aux differents niveaux
          if (guide_plevs.EQ.1) then
-#ifdef NC_DOUBLE
-             status=NF_GET_VARA_DOUBLE(ncidpl,varidap,1,nlevnc,apnc)
-             status=NF_GET_VARA_DOUBLE(ncidpl,varidbp,1,nlevnc,bpnc)
-#else
-             status=NF_GET_VARA_REAL(ncidpl,varidap,1,nlevnc,apnc)
-             status=NF_GET_VARA_REAL(ncidpl,varidbp,1,nlevnc,bpnc)
-#endif
+             status=NF90_GET_VAR(ncidpl,varidap,apnc,[1],[nlevnc])
+             status=NF90_GET_VAR(ncidpl,varidbp,bpnc,[1],[nlevnc])
          ELSEIF (guide_plevs.EQ.0) THEN
-#ifdef NC_DOUBLE
-             status=NF_GET_VARA_DOUBLE(ncidpl,varidpl,1,nlevnc,apnc)
-#else
-             status=NF_GET_VARA_REAL(ncidpl,varidpl,1,nlevnc,apnc)
-#endif
+             status=NF90_GET_VAR(ncidpl,varidpl,apnc,[1],[nlevnc])
 !FC Pour les corrections la pression est deja en Pascals on commente la ligne ci-dessous
              IF(convert_Pa) apnc=apnc*100.! conversion en Pascals
@@ -1326,9 +1323,5 @@
 ! Pression 
      if (guide_plevs.EQ.2) then
-#ifdef NC_DOUBLE
-         status=NF_GET_VARA_DOUBLE(ncidp,varidp,start,count,pnat2)
-#else
-         status=NF_GET_VARA_REAL(ncidp,varidp,start,count,pnat2)
-#endif
+         status=NF90_GET_VAR(ncidp,varidp,pnat2,start,count)
          IF (invert_y) THEN
 !           PRINT*,"Invertion impossible actuellement"
@@ -1340,9 +1333,5 @@
 !  Vent zonal
      if (guide_u) then
-#ifdef NC_DOUBLE
-         status=NF_GET_VARA_DOUBLE(ncidu,varidu,start,count,unat2)
-#else
-         status=NF_GET_VARA_REAL(ncidu,varidu,start,count,unat2)
-#endif
+         status=NF90_GET_VAR(ncidu,varidu,unat2,start,count)
          IF (invert_y) THEN
            CALL invert_lat(iip1,jjp1,nlevnc,unat2)
@@ -1352,9 +1341,5 @@
 !  Temperature
      if (guide_T) then
-#ifdef NC_DOUBLE
-         status=NF_GET_VARA_DOUBLE(ncidt,varidt,start,count,tnat2)
-#else
-         status=NF_GET_VARA_REAL(ncidt,varidt,start,count,tnat2)
-#endif
+         status=NF90_GET_VAR(ncidt,varidt,tnat2,start,count)
          IF (invert_y) THEN
            CALL invert_lat(iip1,jjp1,nlevnc,tnat2)
@@ -1364,9 +1349,5 @@
 !  Humidite
      if (guide_Q) then
-#ifdef NC_DOUBLE
-         status=NF_GET_VARA_DOUBLE(ncidQ,varidQ,start,count,qnat2)
-#else
-         status=NF_GET_VARA_REAL(ncidQ,varidQ,start,count,qnat2)
-#endif
+         status=NF90_GET_VAR(ncidQ,varidQ,qnat2,start,count)
          IF (invert_y) THEN
            CALL invert_lat(iip1,jjp1,nlevnc,qnat2)
@@ -1378,9 +1359,5 @@
      if (guide_v) then
          count(2)=jjm
-#ifdef NC_DOUBLE
-         status=NF_GET_VARA_DOUBLE(ncidv,varidv,start,count,vnat2)
-#else
-         status=NF_GET_VARA_REAL(ncidv,varidv,start,count,vnat2)
-#endif
+         status=NF90_GET_VAR(ncidv,varidv,vnat2,start,count)
          IF (invert_y) THEN
            CALL invert_lat(iip1,jjm,nlevnc,vnat2)
@@ -1395,9 +1372,5 @@
          count(3)=1
          count(4)=0
-#ifdef NC_DOUBLE
-         status=NF_GET_VARA_DOUBLE(ncidps,varidps,start,count,psnat2)
-#else
-         status=NF_GET_VARA_REAL(ncidps,varidps,start,count,psnat2)
-#endif
+         status=NF90_GET_VAR(ncidps,varidps,psnat2,start,count)
          IF (invert_y) THEN
            CALL invert_lat(iip1,jjp1,1,psnat2)
@@ -1410,7 +1383,8 @@
   SUBROUTINE guide_read2D(timestep)
 
+    use netcdf, only: nf90_get_var, nf90_noerr
+
     IMPLICIT NONE
 
-    include "netcdf.inc"
     include "dimensions.h"
     include "paramet.h"
@@ -1443,15 +1417,15 @@
            write(*,*)trim(modname)//' Reading nudging on model levels'
            rcode = nf90_open('apbp.nc', nf90_nowrite, ncidpl)
-           IF (rcode.NE.NF_NOERR) THEN
+           IF (rcode.NE.NF90_NOERR) THEN
              abort_message='Nudging: error -> no file apbp.nc'
            CALL abort_gcm(modname,abort_message,1)
            ENDIF
            rcode = nf90_inq_varid(ncidpl, 'AP', varidap)
-           IF (rcode.NE.NF_NOERR) THEN
+           IF (rcode.NE.NF90_NOERR) THEN
              abort_message='Nudging: error -> no AP variable in file apbp.nc'
            CALL abort_gcm(modname,abort_message,1)
            ENDIF
            rcode = nf90_inq_varid(ncidpl, 'BP', varidbp)
-           IF (rcode.NE.NF_NOERR) THEN
+           IF (rcode.NE.NF90_NOERR) THEN
              abort_message='Nudging: error -> no BP variable in file apbp.nc'
              CALL abort_gcm(modname,abort_message,1)
@@ -1462,10 +1436,10 @@
          if (guide_plevs.EQ.2) then
            rcode = nf90_open('P.nc', nf90_nowrite, ncidp)
-           IF (rcode.NE.NF_NOERR) THEN
+           IF (rcode.NE.NF90_NOERR) THEN
              abort_message='Nudging: error -> no file P.nc'
              CALL abort_gcm(modname,abort_message,1)
            ENDIF
            rcode = nf90_inq_varid(ncidp, 'PRES', varidp)
-           IF (rcode.NE.NF_NOERR) THEN
+           IF (rcode.NE.NF90_NOERR) THEN
              abort_message='Nudging: error -> no PRES variable in file P.nc'
              CALL abort_gcm(modname,abort_message,1)
@@ -1477,10 +1451,10 @@
          if (guide_u) then
            rcode = nf90_open('u.nc', nf90_nowrite, ncidu)
-           IF (rcode.NE.NF_NOERR) THEN
+           IF (rcode.NE.NF90_NOERR) THEN
              abort_message='Nudging: error -> no file u.nc'
              CALL abort_gcm(modname,abort_message,1)
            ENDIF
            rcode = nf90_inq_varid(ncidu, 'UWND', varidu)
-           IF (rcode.NE.NF_NOERR) THEN
+           IF (rcode.NE.NF90_NOERR) THEN
              abort_message='Nudging: error -> no UWND variable in file u.nc'
              CALL abort_gcm(modname,abort_message,1)
@@ -1492,10 +1466,10 @@
          if (guide_v) then
            rcode = nf90_open('v.nc', nf90_nowrite, ncidv)
-           IF (rcode.NE.NF_NOERR) THEN
+           IF (rcode.NE.NF90_NOERR) THEN
              abort_message='Nudging: error -> no file v.nc'
              CALL abort_gcm(modname,abort_message,1)
            ENDIF
            rcode = nf90_inq_varid(ncidv, 'VWND', varidv)
-           IF (rcode.NE.NF_NOERR) THEN
+           IF (rcode.NE.NF90_NOERR) THEN
              abort_message='Nudging: error -> no VWND variable in file v.nc'
              CALL abort_gcm(modname,abort_message,1)
@@ -1507,10 +1481,10 @@
          if (guide_T) then
            rcode = nf90_open('T.nc', nf90_nowrite, ncidt)
-           IF (rcode.NE.NF_NOERR) THEN
+           IF (rcode.NE.NF90_NOERR) THEN
              abort_message='Nudging: error -> no file T.nc'
              CALL abort_gcm(modname,abort_message,1)
            ENDIF
            rcode = nf90_inq_varid(ncidt, 'AIR', varidt)
-           IF (rcode.NE.NF_NOERR) THEN
+           IF (rcode.NE.NF90_NOERR) THEN
              abort_message='Nudging: error -> no AIR variable in file T.nc'
              CALL abort_gcm(modname,abort_message,1)
@@ -1522,10 +1496,10 @@
          if (guide_Q) then
            rcode = nf90_open('hur.nc', nf90_nowrite, ncidQ)
-           IF (rcode.NE.NF_NOERR) THEN
+           IF (rcode.NE.NF90_NOERR) THEN
              abort_message='Nudging: error -> no file hur.nc'
              CALL abort_gcm(modname,abort_message,1)
            ENDIF
            rcode = nf90_inq_varid(ncidQ, 'RH', varidQ)
-           IF (rcode.NE.NF_NOERR) THEN
+           IF (rcode.NE.NF90_NOERR) THEN
              abort_message='Nudging: error -> no RH,variable in file hur.nc'
              CALL abort_gcm(modname,abort_message,1)
@@ -1537,10 +1511,10 @@
          if ((guide_P).OR.(guide_modele)) then
            rcode = nf90_open('ps.nc', nf90_nowrite, ncidps)
-           IF (rcode.NE.NF_NOERR) THEN
+           IF (rcode.NE.NF90_NOERR) THEN
              abort_message='Nudging: error -> no file ps.nc'
              CALL abort_gcm(modname,abort_message,1)
            ENDIF
            rcode = nf90_inq_varid(ncidps, 'SP', varidps)
-           IF (rcode.NE.NF_NOERR) THEN
+           IF (rcode.NE.NF90_NOERR) THEN
              abort_message='Nudging: error -> no SP variable in file ps.nc'
              CALL abort_gcm(modname,abort_message,1)
@@ -1556,17 +1530,8 @@
 ! Coefs ap, bp pour calcul de la pression aux differents niveaux
          if (guide_plevs.EQ.1) then
-#ifdef NC_DOUBLE
-             status=NF_GET_VARA_DOUBLE(ncidpl,varidap,1,nlevnc,apnc)
-             status=NF_GET_VARA_DOUBLE(ncidpl,varidbp,1,nlevnc,bpnc)
-#else
-             status=NF_GET_VARA_REAL(ncidpl,varidap,1,nlevnc,apnc)
-             status=NF_GET_VARA_REAL(ncidpl,varidbp,1,nlevnc,bpnc)
-#endif
+             status=NF90_GET_VAR(ncidpl,varidap,apnc,[1],[nlevnc])
+             status=NF90_GET_VAR(ncidpl,varidbp,bpnc,[1],[nlevnc])
          elseif (guide_plevs.EQ.0) THEN
-#ifdef NC_DOUBLE
-             status=NF_GET_VARA_DOUBLE(ncidpl,varidpl,1,nlevnc,apnc)
-#else
-             status=NF_GET_VARA_REAL(ncidpl,varidpl,1,nlevnc,apnc)
-#endif
+             status=NF90_GET_VAR(ncidpl,varidpl,apnc,[1],[nlevnc])
              apnc=apnc*100.! conversion en Pascals
              bpnc(:)=0.
@@ -1592,9 +1557,5 @@
 !  Pression
      if (guide_plevs.EQ.2) then
-#ifdef NC_DOUBLE
-         status=NF_GET_VARA_DOUBLE(ncidp,varidp,start,count,zu)
-#else
-         status=NF_GET_VARA_REAL(ncidp,varidp,start,count,zu)
-#endif
+         status=NF90_GET_VAR(ncidp,varidp,zu,start,count)
          DO i=1,iip1
              pnat2(i,:,:)=zu(:,:)
@@ -1609,9 +1570,5 @@
 !  Vent zonal
      if (guide_u) then
-#ifdef NC_DOUBLE
-         status=NF_GET_VARA_DOUBLE(ncidu,varidu,start,count,zu)
-#else
-         status=NF_GET_VARA_REAL(ncidu,varidu,start,count,zu)
-#endif
+         status=NF90_GET_VAR(ncidu,varidu,zu,start,count)
          DO i=1,iip1
              unat2(i,:,:)=zu(:,:)
@@ -1626,9 +1583,5 @@
 !  Temperature
      if (guide_T) then
-#ifdef NC_DOUBLE
-         status=NF_GET_VARA_DOUBLE(ncidt,varidt,start,count,zu)
-#else
-         status=NF_GET_VARA_REAL(ncidt,varidt,start,count,zu)
-#endif
+         status=NF90_GET_VAR(ncidt,varidt,zu,start,count)
          DO i=1,iip1
              tnat2(i,:,:)=zu(:,:)
@@ -1643,9 +1596,5 @@
 !  Humidite
      if (guide_Q) then
-#ifdef NC_DOUBLE
-         status=NF_GET_VARA_DOUBLE(ncidQ,varidQ,start,count,zu)
-#else
-         status=NF_GET_VARA_REAL(ncidQ,varidQ,start,count,zu)
-#endif
+         status=NF90_GET_VAR(ncidQ,varidQ,zu,start,count)
          DO i=1,iip1
              qnat2(i,:,:)=zu(:,:)
@@ -1661,9 +1610,5 @@
      if (guide_v) then
          count(2)=jjm
-#ifdef NC_DOUBLE
-         status=NF_GET_VARA_DOUBLE(ncidv,varidv,start,count,zv)
-#else
-         status=NF_GET_VARA_REAL(ncidv,varidv,start,count,zv)
-#endif
+         status=NF90_GET_VAR(ncidv,varidv,zv,start,count)
          DO i=1,iip1
              vnat2(i,:,:)=zv(:,:)
@@ -1683,9 +1628,5 @@
          count(3)=1
          count(4)=0
-#ifdef NC_DOUBLE
-         status=NF_GET_VARA_DOUBLE(ncidps,varidps,start,count,zu(:,1))
-#else
-         status=NF_GET_VARA_REAL(ncidps,varidps,start,count,zu(:,1))
-#endif
+         status=NF90_GET_VAR(ncidps,varidps,zu(:,1),start,count)
          DO i=1,iip1
              psnat2(i,:)=zu(:,1)
@@ -1706,5 +1647,5 @@
     USE comvert_mod, ONLY: presnivs
     use netcdf95, only: nf95_def_var, nf95_put_var
-    use netcdf, only: nf90_float
+    use netcdf, only: nf90_float, nf90_def_var
     
     IMPLICIT NONE
@@ -1748,13 +1689,13 @@
 
 ! Creation des variables dimensions
-        ierr=NF_DEF_VAR(nid,"LONU",NF_FLOAT,1,id_lonu,vid_lonu)
-        ierr=NF_DEF_VAR(nid,"LONV",NF_FLOAT,1,id_lonv,vid_lonv)
-        ierr=NF_DEF_VAR(nid,"LATU",NF_FLOAT,1,id_latu,vid_latu)
-        ierr=NF_DEF_VAR(nid,"LATV",NF_FLOAT,1,id_latv,vid_latv)
-        ierr=NF_DEF_VAR(nid,"LEVEL",NF_FLOAT,1,id_lev,vid_lev)
-        ierr=NF_DEF_VAR(nid,"cu",NF_FLOAT,2,(/id_lonu,id_latu/),vid_cu)
-        ierr=NF_DEF_VAR(nid,"cv",NF_FLOAT,2,(/id_lonv,id_latv/),vid_cv)
-        ierr=NF_DEF_VAR(nid,"au",NF_FLOAT,2,(/id_lonu,id_latu/),vid_au)
-        ierr=NF_DEF_VAR(nid,"av",NF_FLOAT,2,(/id_lonv,id_latv/),vid_av)
+        ierr=NF90_DEF_VAR(nid,"LONU",NF90_FLOAT,id_lonu,vid_lonu)
+        ierr=NF90_DEF_VAR(nid,"LONV",NF90_FLOAT,id_lonv,vid_lonv)
+        ierr=NF90_DEF_VAR(nid,"LATU",NF90_FLOAT,id_latu,vid_latu)
+        ierr=NF90_DEF_VAR(nid,"LATV",NF90_FLOAT,id_latv,vid_latv)
+        ierr=NF90_DEF_VAR(nid,"LEVEL",NF90_FLOAT,id_lev,vid_lev)
+        ierr=NF90_DEF_VAR(nid,"cu",NF90_FLOAT,(/id_lonu,id_latu/),vid_cu)
+        ierr=NF90_DEF_VAR(nid,"cv",NF90_FLOAT,(/id_lonv,id_latv/),vid_cv)
+        ierr=NF90_DEF_VAR(nid,"au",NF90_FLOAT,(/id_lonu,id_latu/),vid_au)
+        ierr=NF90_DEF_VAR(nid,"av",NF90_FLOAT,(/id_lonv,id_latv/),vid_av)
         call nf95_def_var(nid, "alpha_T", nf90_float, (/id_lonv, id_latu/), &
              varid_alpha_t)
@@ -1794,33 +1735,33 @@
 ! Pressure (GCM)
         dim4=(/id_lonv,id_latu,id_lev,id_tim/)
-        ierr = NF_DEF_VAR(nid,"SP",NF_FLOAT,4,dim4,varid)
+        ierr = NF90_DEF_VAR(nid,"SP",NF90_FLOAT,dim4,varid)
 ! Surface pressure (guidage)
         IF (guide_P) THEN
             dim3=(/id_lonv,id_latu,id_tim/)
-            ierr = NF_DEF_VAR(nid,"ps",NF_FLOAT,3,dim3,varid)
+            ierr = NF90_DEF_VAR(nid,"ps",NF90_FLOAT,dim3,varid)
         ENDIF
 ! Zonal wind
         IF (guide_u) THEN
             dim4=(/id_lonu,id_latu,id_lev,id_tim/)
-            ierr = NF_DEF_VAR(nid,"u",NF_FLOAT,4,dim4,varid)
-            ierr = NF_DEF_VAR(nid,"ua",NF_FLOAT,4,dim4,varid)
-            ierr = NF_DEF_VAR(nid,"ucov",NF_FLOAT,4,dim4,varid)
+            ierr = NF90_DEF_VAR(nid,"u",NF90_FLOAT,dim4,varid)
+            ierr = NF90_DEF_VAR(nid,"ua",NF90_FLOAT,dim4,varid)
+            ierr = NF90_DEF_VAR(nid,"ucov",NF90_FLOAT,dim4,varid)
         ENDIF
 ! Merid. wind
         IF (guide_v) THEN
             dim4=(/id_lonv,id_latv,id_lev,id_tim/)
-            ierr = NF_DEF_VAR(nid,"v",NF_FLOAT,4,dim4,varid)
-            ierr = NF_DEF_VAR(nid,"va",NF_FLOAT,4,dim4,varid)
-            ierr = NF_DEF_VAR(nid,"vcov",NF_FLOAT,4,dim4,varid)
+            ierr = NF90_DEF_VAR(nid,"v",NF90_FLOAT,dim4,varid)
+            ierr = NF90_DEF_VAR(nid,"va",NF90_FLOAT,dim4,varid)
+            ierr = NF90_DEF_VAR(nid,"vcov",NF90_FLOAT,dim4,varid)
         ENDIF
 ! Pot. Temperature
         IF (guide_T) THEN
             dim4=(/id_lonv,id_latu,id_lev,id_tim/)
-            ierr = NF_DEF_VAR(nid,"teta",NF_FLOAT,4,dim4,varid)
+            ierr = NF90_DEF_VAR(nid,"teta",NF90_FLOAT,dim4,varid)
         ENDIF
 ! Specific Humidity
         IF (guide_Q) THEN
             dim4=(/id_lonv,id_latu,id_lev,id_tim/)
-            ierr = NF_DEF_VAR(nid,"q",NF_FLOAT,4,dim4,varid)
+            ierr = NF90_DEF_VAR(nid,"q",NF90_FLOAT,dim4,varid)
         ENDIF
         
Index: LMDZ6/branches/Portage_acc/libf/dyn3d/iniacademic.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d/iniacademic.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d/iniacademic.F90	(revision 4446)
@@ -5,6 +5,5 @@
 
   USE filtreg_mod, ONLY: inifilr
-  USE infotrac,    ONLY: nqtot, niso, niso_possibles, ok_iso_verif, tnat, alpha_ideal, &
-                         iqiso, tracers, iso_indnum, iso_num
+  USE infotrac,    ONLY: nqtot, niso, iqIsoPha, tracers, getKey, isoName
   USE control_mod, ONLY: day_step,planet_type
   use exner_hyb_m, only: exner_hyb
@@ -19,8 +18,11 @@
   USE comconst_mod, ONLY: cpp, kappa, g, daysec, dtvr, pi, im, jm
   USE logic_mod, ONLY: iflag_phys, read_start
-  USE comvert_mod, ONLY: ap, bp, preff, presnivs, pressure_exner
+  USE comvert_mod, ONLY: ap, bp, preff, pa, presnivs, pressure_exner
   USE temps_mod, ONLY: annee_ref, day_ini, day_ref
   USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
   USE readTracFiles_mod, ONLY: addPhase
+  use netcdf, only : NF90_NOWRITE,NF90_OPEN,NF90_NOERR,NF90_INQ_VARID
+  use netcdf, only : NF90_CLOSE, NF90_GET_VAR
+
 
   !   Author:    Frederic Hourdin      original: 15/01/93
@@ -65,4 +67,7 @@
   INTEGER i,j,l,lsup,ij, iq, iName, iPhase, iqParent
 
+  integer :: nid_relief,varid,ierr
+  real, dimension(iip1,jjp1) :: relief
+
   REAL teta0,ttp,delt_y,delt_z,eps ! Constantes pour profil de T
   REAL k_f,k_c_a,k_c_s         ! Constantes de rappel
@@ -74,5 +79,5 @@
   integer idum
 
-  REAL zdtvr
+  REAL zdtvr, tnat, alpha_ideal
   
   character(len=*),parameter :: modname="iniacademic"
@@ -119,19 +124,48 @@
   CALL inifilr
 
+
+  !------------------------------------------------------------------
   ! Initialize pressure and mass field if read_start=.false.
+  !------------------------------------------------------------------
+
   IF (.NOT. read_start) THEN
-     ! surface pressure
-     if (iflag_phys>2) then
-        ! specific value for CMIP5 aqua/terra planets
-        ! "Specify the initial dry mass to be equivalent to
-        !  a global mean surface pressure (101325 minus 245) Pa."
-        ps(:)=101080.  
-     else
-        ! use reference surface pressure
-        ps(:)=preff
+
+     !------------------------------------------------------------------
+     ! Lecture eventuelle d'un fichier de relief interpollee sur la grille
+     ! du modele.
+     ! On suppose que le fichier relief_in.nc est stoké sur une grille
+     ! iim*jjp1
+     ! Facile a créer à partir de la commande
+     ! cdo remapcon,fichier_output_phys.nc Relief.nc relief_in.nc
+     !------------------------------------------------------------------
+
+     relief=0.
+     ierr = NF90_OPEN ('relief_in.nc', NF90_NOWRITE,nid_relief)
+     if (ierr.EQ.NF90_NOERR) THEN
+         ierr=NF90_INQ_VARID(nid_relief,'RELIEF',varid)
+         if (ierr==NF90_NOERR) THEN
+              ierr=NF90_GET_VAR(nid_relief,varid,relief(1:iim,1:jjp1))
+              relief(iip1,:)=relief(1,:)
+         else
+              CALL abort_gcm ('iniacademic','variable RELIEF pas la',1)
+         endif
      endif
+     ierr = NF90_CLOSE (nid_relief)
+
+     !------------------------------------------------------------------
+     ! Initialisation du geopotentiel au sol et de la pression
+     !------------------------------------------------------------------
+
+     print*,'relief=',minval(relief),maxval(relief),'g=',g
+     do j=1,jjp1
+        do i=1,iip1
+           phis((j-1)*iip1+i)=g*relief(i,j)
+        enddo
+     enddo
+     print*,'phis=',minval(phis),maxval(phis),'g=',g
 
      ! ground geopotential
-     phis(:)=0.
+     !phis(:)=0.
+     ps(:)=preff
      CALL pression ( ip1jmp1, ap, bp, ps, p       )
 
@@ -282,13 +316,14 @@
               ! CRisi: init des isotopes
               ! distill de Rayleigh très simplifiée
-!             iName    = tracers(iq)%iso_iName  ! (next commit)
-              iName    = iso_num(iq)
+              iName    = tracers(iq)%iso_iName
               if (niso <= 0 .OR. iName <= 0) CYCLE
               iPhase   = tracers(iq)%iso_iPhase
               iqParent = tracers(iq)%iqParent
               IF(tracers(iq)%iso_iZone == 0) THEN
-                 q(:,:,iq) = q(:,:,iqParent)*tnat(iName)*(q(:,:,iqParent)/30.e-3)**(alpha_ideal(iName)-1.)
+                 IF(getKey('tnat', tnat, isoName(iName)) .OR. getKey('alpha', alpha_ideal, isoName(iName))) &
+                    CALL abort_gcm(TRIM(modname), 'missing isotopic parameters', 1)
+                 q(:,:,iq) = q(:,:,iqParent)*tnat*(q(:,:,iqParent)/30.e-3)**(alpha_ideal-1.)
               ELSE
-                 q(:,:,iq) = q(:,:,iqiso(iso_indnum(iq),iPhase))
+                 q(:,:,iq) = q(:,:,iqIsoPha(iName,iPhase))
               END IF
            enddo
@@ -297,5 +332,5 @@
         endif ! of if (planet_type=="earth")
 
-        if (ok_iso_verif) call check_isotopes_seq(q,1,ip1jmp1,'iniacademic_loc')
+        call check_isotopes_seq(q,1,ip1jmp1,'iniacademic_loc')
 
         ! add random perturbation to temperature
Index: LMDZ6/branches/Portage_acc/libf/dyn3d/leapfrog.F
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d/leapfrog.F	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d/leapfrog.F	(revision 4446)
@@ -11,5 +11,5 @@
       use IOIPSL
 #endif
-      USE infotrac, ONLY: nqtot,ok_iso_verif
+      USE infotrac, ONLY: nqtot, isoCheck
       USE guide_mod, ONLY : guide_main
       USE write_field, ONLY: writefield
@@ -26,4 +26,5 @@
       USE temps_mod, ONLY: jD_ref,jH_ref,itaufin,day_ini,day_ref,
      &                        start_time,dt
+      USE strings_mod, ONLY: msg
 
       IMPLICIT NONE
@@ -237,7 +238,5 @@
       jH_cur = jH_cur - int(jH_cur)
 
-        if (ok_iso_verif) then
-           call check_isotopes_seq(q,ip1jmp1,'leapfrog 321')
-        endif !if (ok_iso_verif) then
+      call check_isotopes_seq(q,ip1jmp1,'leapfrog 321')
 
 #ifdef CPP_IOIPSL
@@ -271,7 +270,5 @@
 !      CALL filtreg ( finvmaold ,jjp1, llm, -2,2, .TRUE., 1 )
 
-        if (ok_iso_verif) then
-           call check_isotopes_seq(q,ip1jmp1,'leapfrog 400')
-        endif !if (ok_iso_verif) then
+      call check_isotopes_seq(q,ip1jmp1,'leapfrog 400')
 
    2  CONTINUE ! Matsuno backward or leapfrog step begins here
@@ -324,7 +321,5 @@
 
 
-        if (ok_iso_verif) then
-           call check_isotopes_seq(q,ip1jmp1,'leapfrog 589')
-        endif !if (ok_iso_verif) then
+      call check_isotopes_seq(q,ip1jmp1,'leapfrog 589')
 
 c-----------------------------------------------------------------------
@@ -345,8 +340,6 @@
 c   -------------------------------------------------------------
 
-        if (ok_iso_verif) then
-           call check_isotopes_seq(q,ip1jmp1,
+      call check_isotopes_seq(q,ip1jmp1,
      &           'leapfrog 686: avant caladvtrac')
-        endif !if (ok_iso_verif) then
 
       IF( forward. OR . leapf )  THEN
@@ -376,8 +369,6 @@
 c   ----------------------------------
 
-        if (ok_iso_verif) then
-           write(*,*) 'leapfrog 720' 
-           call check_isotopes_seq(q,ip1jmp1,'leapfrog 756')
-        endif !if (ok_iso_verif) then
+       CALL msg('720', modname, isoCheck)
+       call check_isotopes_seq(q,ip1jmp1,'leapfrog 756')
         
        CALL integrd ( nqtot,vcovm1,ucovm1,tetam1,psm1,massem1 ,
@@ -385,8 +376,6 @@
 !     $              finvmaold                                    )
 
-       if (ok_iso_verif) then
-          write(*,*) 'leapfrog 724'
-           call check_isotopes_seq(q,ip1jmp1,'leapfrog 762')
-        endif !if (ok_iso_verif) then
+       CALL msg('724', modname, isoCheck)
+       call check_isotopes_seq(q,ip1jmp1,'leapfrog 762')
 
 c .P.Le Van (26/04/94  ajout de  finvpold dans l'appel d'integrd)
@@ -552,7 +541,5 @@
         CALL massdair(p,masse)
 
-        if (ok_iso_verif) then
-           call check_isotopes_seq(q,ip1jmp1,'leapfrog 1196')
-        endif !if (ok_iso_verif) then
+        call check_isotopes_seq(q,ip1jmp1,'leapfrog 1196')
 
 c-----------------------------------------------------------------------
@@ -639,7 +626,5 @@
 c   preparation du pas d'integration suivant  ......
 
-        if (ok_iso_verif) then
-           call check_isotopes_seq(q,ip1jmp1,'leapfrog 1509')
-        endif !if (ok_iso_verif) then
+      call check_isotopes_seq(q,ip1jmp1,'leapfrog 1509')
 
       IF ( .NOT.purmats ) THEN
@@ -703,7 +688,5 @@
             ENDIF ! of IF((MOD(itau,iperiod).EQ.0).OR.(itau.EQ.itaufin))
 
-        if (ok_iso_verif) then
-           call check_isotopes_seq(q,ip1jmp1,'leapfrog 1584')
-        endif !if (ok_iso_verif) then
+            call check_isotopes_seq(q,ip1jmp1,'leapfrog 1584')
 
 c-----------------------------------------------------------------------
@@ -790,7 +773,5 @@
       ELSE ! of IF (.not.purmats)
 
-        if (ok_iso_verif) then
-           call check_isotopes_seq(q,ip1jmp1,'leapfrog 1664')
-        endif !if (ok_iso_verif) then
+            call check_isotopes_seq(q,ip1jmp1,'leapfrog 1664')
 
 c       ........................................................
@@ -817,7 +798,5 @@
             ELSE ! of IF(forward) i.e. backward step
  
-        if (ok_iso_verif) then
-           call check_isotopes_seq(q,ip1jmp1,'leapfrog 1698')
-        endif !if (ok_iso_verif) then  
+              call check_isotopes_seq(q,ip1jmp1,'leapfrog 1698')
 
               IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin) THEN
Index: LMDZ6/branches/Portage_acc/libf/dyn3d/qminimum.F
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d/qminimum.F	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d/qminimum.F	(revision 4446)
@@ -4,5 +4,7 @@
       SUBROUTINE qminimum( q,nqtot,deltap )
 
-      USE infotrac, ONLY: niso, ntraciso,iqiso,ok_iso_verif
+      USE infotrac, ONLY: niso, ntiso,iqIsoPha, tracers
+      USE strings_mod, ONLY: strIdx
+      USE readTracFiles_mod, ONLY: addPhase
       IMPLICIT none
 c
@@ -16,10 +18,8 @@
       REAL q(ip1jmp1,llm,nqtot), deltap(ip1jmp1,llm)
 c
-      INTEGER iq_vap, iq_liq
-      PARAMETER ( iq_vap = 1 ) ! indice pour l'eau vapeur
-      PARAMETER ( iq_liq = 2 ) ! indice pour l'eau liquide
-      REAL seuil_vap, seuil_liq
-      PARAMETER ( seuil_vap = 1.0e-10 ) ! seuil pour l'eau vapeur
-      PARAMETER ( seuil_liq = 1.0e-11 ) ! seuil pour l'eau liquide
+      LOGICAL, SAVE :: first=.TRUE.
+      INTEGER, SAVE :: iq_vap, iq_liq        ! indices pour l'eau vapeur/liquide
+      REAL, PARAMETER :: seuil_vap = 1.0e-10 ! seuil pour l'eau vapeur
+      REAL, PARAMETER :: seuil_liq = 1.0e-11 ! seuil pour l'eau liquide
 c
 c  NB. ....( Il est souhaitable mais non obligatoire que les valeurs des
@@ -43,4 +43,10 @@
       !INTEGER nb_pump
       INTEGER ixt
+
+      IF(first) THEN
+         iq_vap = strIdx(tracers(:)%name, addPhase('H2O', 'g'))
+         iq_liq = strIdx(tracers(:)%name, addPhase('H2O', 'l'))
+         first = .FALSE.
+      END IF
 c
 c Quand l'eau liquide est trop petite (ou negative), on prend
@@ -49,7 +55,5 @@
 c
 
-        if (ok_iso_verif) then
-           call check_isotopes_seq(q,ip1jmp1,'qminimum 52')   
-        endif !if (ok_iso_verif) then     
+      call check_isotopes_seq(q,ip1jmp1,'qminimum 52')   
 
       zx_defau_diag(:,:,:)=0.0
@@ -127,14 +131,16 @@
           if (zx_defau_diag(i,k,iq_vap).gt.0.0) then             
               ! on ajoute la vapeur en k              
-              do ixt=1,ntraciso
-               q(i,k,iqiso(ixt,iq_vap))=q(i,k,iqiso(ixt,iq_vap))
-     :              +zx_defau_diag(i,k,iq_vap)
-     :              *q(i,k-1,iqiso(ixt,iq_vap))/q_follow(i,k-1,iq_vap)
+              do ixt=1,ntiso
+               q(i,k,iqIsoPha(ixt,iq_vap))=q(i,k,iqIsoPha(ixt,iq_vap))
+     :           +zx_defau_diag(i,k,iq_vap)
+     :           *q(i,k-1,iqIsoPha(ixt,iq_vap))/q_follow(i,k-1,iq_vap)
                 
               ! et on la retranche en k-1
-               q(i,k-1,iqiso(ixt,iq_vap))=q(i,k-1,iqiso(ixt,iq_vap))
+               q(i,k-1,iqIsoPha(ixt,iq_vap))=
+     :            q(i,k-1,iqIsoPha(ixt,iq_vap))
      :              -zx_defau_diag(i,k,iq_vap)
      :              *deltap(i,k)/deltap(i,k-1)
-     :              *q(i,k-1,iqiso(ixt,iq_vap))/q_follow(i,k-1,iq_vap)
+     :              *q(i,k-1,iqIsoPha(ixt,iq_vap))
+     :              /q_follow(i,k-1,iq_vap)
 
               enddo !do ixt=1,niso
@@ -148,7 +154,5 @@
        enddo !do k=2,llm
 
-        if (ok_iso_verif) then     
-           call check_isotopes_seq(q,ip1jmp1,'qminimum 168')
-        endif !if (ok_iso_verif) then
+       call check_isotopes_seq(q,ip1jmp1,'qminimum 168')
         
       
@@ -160,12 +164,12 @@
 
               ! on ajoute eau liquide en k en k              
-              do ixt=1,ntraciso
-               q(i,k,iqiso(ixt,iq_liq))=q(i,k,iqiso(ixt,iq_liq))
+              do ixt=1,ntiso
+               q(i,k,iqIsoPha(ixt,iq_liq))=q(i,k,iqIsoPha(ixt,iq_liq))
      :              +zx_defau_diag(i,k,iq_liq)
-     :              *q(i,k,iqiso(ixt,iq_vap))/q_follow(i,k,iq_vap)
+     :              *q(i,k,iqIsoPha(ixt,iq_vap))/q_follow(i,k,iq_vap)
               ! et on la retranche à la vapeur en k
-               q(i,k,iqiso(ixt,iq_vap))=q(i,k,iqiso(ixt,iq_vap))
+               q(i,k,iqIsoPha(ixt,iq_vap))=q(i,k,iqIsoPha(ixt,iq_vap))
      :              -zx_defau_diag(i,k,iq_liq)
-     :              *q(i,k,iqiso(ixt,iq_vap))/q_follow(i,k,iq_vap)   
+     :              *q(i,k,iqIsoPha(ixt,iq_vap))/q_follow(i,k,iq_vap)   
               enddo !do ixt=1,niso
               q_follow(i,k,iq_liq)=   q_follow(i,k,iq_liq)
@@ -177,7 +181,5 @@
        enddo !do k=2,llm  
 
-        if (ok_iso_verif) then
-           call check_isotopes_seq(q,ip1jmp1,'qminimum 197')
-        endif !if (ok_iso_verif) then
+       call check_isotopes_seq(q,ip1jmp1,'qminimum 197')
 
       endif !if (niso > 0) then
Index: LMDZ6/branches/Portage_acc/libf/dyn3d/replay3d.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d/replay3d.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d/replay3d.F90	(revision 4446)
@@ -203,9 +203,8 @@
 ! Boucle en temps sur l'appel à la parametrisation
 !---------------------------------------------------------------------
-!      ntime = 97
       write(6,*)'number of loops to do = '
       read(5,*) ntime
       DO it=1,ntime
-!         print*,'Pas de temps ',it,klon,klev
+         print*,'Pas de temps ',it,klon,klev
          call call_param_replay(klon,klev,elapsed_time)
          mean_elapsed=mean_elapsed+elapsed_time/real(ntime)
Index: LMDZ6/branches/Portage_acc/libf/dyn3d/vlsplt.F
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d/vlsplt.F	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d/vlsplt.F	(revision 4446)
@@ -125,5 +125,5 @@
       RECURSIVE SUBROUTINE vlx(q,pente_max,masse,u_m,iq)
       USE infotrac, ONLY : nqtot,tracers, ! CRisi
-     &                     qperemin,masseqmin,ratiomin ! MVals et CRisi
+     &                     min_qParent,min_qMass,min_ratio ! MVals et CRisi
 
 c     Auteurs:   P.Le Van, F.Hourdin, F.Forget 
@@ -428,14 +428,14 @@
             !Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
             !Mvals: veiller a ce qu'on n'ait pas de denominateur nul
-            masseq(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),masseqmin)
-            if (q(ij,l,iq).gt.qperemin) then
+            masseq(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),min_qMass)
+            if (q(ij,l,iq).gt.min_qParent) then
               Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
             else
-              Ratio(ij,l,iq2)=ratiomin
+              Ratio(ij,l,iq2)=min_ratio
             endif
           enddo   
         enddo
       enddo
-      do ifils=1,tracers(iq)%nqChilds
+      do ifils=1,tracers(iq)%nqChildren
         iq2=tracers(iq)%iqDescen(ifils)
         call vlx(Ratio,pente_max,masseq,u_mq,iq2)
@@ -449,5 +449,5 @@
          DO ij=iip2+1,ip1jm
             !MVals: veiller a ce qu'on 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),min_qMass)
             q(ij,l,iq)=(q(ij,l,iq)*masse(ij,l,iq)+
      &      u_mq(ij-1,l)-u_mq(ij,l))
@@ -485,5 +485,5 @@
       RECURSIVE SUBROUTINE vly(q,pente_max,masse,masse_adv_v,iq)
       USE infotrac, ONLY : nqtot,tracers, ! CRisi
-     &                     qperemin,masseqmin,ratiomin ! MVals et CRisi
+     &                     min_qParent,min_qMass,min_ratio ! MVals et CRisi
 c
 c     Auteurs:   P.Le Van, F.Hourdin, F.Forget 
@@ -752,9 +752,9 @@
             !Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)     
             !MVals: veiller a ce qu'on n'ait pas de denominateur nul
-            masseq(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),masseqmin)
-            if (q(ij,l,iq).gt.qperemin) then
+            masseq(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),min_qMass)
+            if (q(ij,l,iq).gt.min_qParent) then
               Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
             else
-              Ratio(ij,l,iq2)=ratiomin
+              Ratio(ij,l,iq2)=min_ratio
             endif 
           enddo   
@@ -848,5 +848,5 @@
       RECURSIVE SUBROUTINE vlz(q,pente_max,masse,w,iq)
       USE infotrac, ONLY : nqtot,tracers, ! CRisi 
-     &                     qperemin,masseqmin,ratiomin ! MVals et CRisi
+     &                     min_qParent,min_qMass,min_ratio ! MVals et CRisi
 c
 c     Auteurs:   P.Le Van, F.Hourdin, F.Forget 
@@ -969,5 +969,5 @@
 ! CRisi: appel récursif de l'advection sur les fils.
 ! Il faut faire ça avant d'avoir mis à jour q et masse
-      !write(*,*) 'vlsplt 942: iq,nqChilds(iq)=',iq,nqChilds(iq)
+      !write(*,*) 'vlsplt 942: iq,nqChildren(iq)=',iq,nqChildren(iq)
       do ifils=1,tracers(iq)%nqDescen
         iq2=tracers(iq)%iqDescen(ifils)
@@ -977,9 +977,9 @@
             !Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)        
             !MVals: veiller a ce qu'on n'ait pas de denominateur nul
-            masseq(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),masseqmin)
-            if (q(ij,l,iq).gt.qperemin) then
+            masseq(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),min_qMass)
+            if (q(ij,l,iq).gt.min_qParent) then
               Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
             else
-              Ratio(ij,l,iq2)=ratiomin
+              Ratio(ij,l,iq2)=min_ratio
             endif      
           enddo   
@@ -987,5 +987,5 @@
       enddo
         
-      do ifils=1,tracers(iq)%nqChilds
+      do ifils=1,tracers(iq)%nqChildren
         iq2=tracers(iq)%iqDescen(ifils)
         call vlz(Ratio,pente_max,masseq,wq,iq2)
Index: LMDZ6/branches/Portage_acc/libf/dyn3d/vlspltqs.F
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d/vlspltqs.F	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d/vlspltqs.F	(revision 4446)
@@ -479,5 +479,6 @@
 ! CRisi: appel récursif de l'advection sur les fils.
 ! Il faut faire ça avant d'avoir mis à jour q et masse
-      !write(*,*) 'vlspltqs 326: iq,nqChilds(iq)=',iq,tracers(iq)%nqChilds
+      !write(*,*) 'vlspltqs 326: iq,nqChildren(iq)=',iq,
+!     &                 tracers(iq)%nqChildren
       
       do ifils=1,tracers(iq)%nqDescen
@@ -491,5 +492,5 @@
         enddo
       enddo
-      do ifils=1,tracers(iq)%nqChilds
+      do ifils=1,tracers(iq)%nqChildren
         iq2=tracers(iq)%iqDescen(ifils)
         call vlx(Ratio,pente_max,masseq,u_mq,iq2)
@@ -786,5 +787,6 @@
 ! CRisi: appel récursif de l'advection sur les fils.
 ! Il faut faire ça avant d'avoir mis à jour q et masse
-      !write(*,*) 'vlyqs 689: iq,nqChilds(iq)=',iq,tracers(iq)%nqChilds
+      !write(*,*) 'vlyqs 689: iq,nqChildren(iq)=',iq,
+!     &              tracers(iq)%nqChildren
    
       do ifils=1,tracers(iq)%nqDescen
@@ -797,5 +799,5 @@
         enddo
       enddo
-      do ifils=1,tracers(iq)%nqChilds
+      do ifils=1,tracers(iq)%nqChildren
         iq2=tracers(iq)%iqDescen(ifils)
         !write(*,*) 'vlyqs 783: appel rec de vly, iq2=',iq2
Index: LMDZ6/branches/Portage_acc/libf/dyn3d_common/comvert_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d_common/comvert_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d_common/comvert_mod.F90	(revision 4446)
@@ -10,9 +10,11 @@
 
 PUBLIC :: ap,bp,presnivs,dpres,sig,ds,pa,preff,nivsigs,nivsig, &
-          aps,bps,scaleheight,pseudoalt,disvert_type, pressure_exner
+          aps,bps,scaleheight,pseudoalt,disvert_type, pressure_exner, &
+          presinter
 
 REAL ap(llm+1) ! hybrid pressure contribution at interlayers
 REAL bp (llm+1) ! hybrid sigma contribution at interlayer
 REAL presnivs(llm) ! (reference) pressure at mid-layers
+REAL presinter(llm+1) ! (reference) pressure at interlayers
 REAL dpres(llm)
 REAL sig(llm+1)
Index: LMDZ6/branches/Portage_acc/libf/dyn3d_common/conf_planete.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d_common/conf_planete.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d_common/conf_planete.F90	(revision 4446)
@@ -30,36 +30,51 @@
 
 !Reference surface pressure (Pa)
-preff=101325.
+! 101080 : specific value for CMIP5 aqua/terra planets
+! "Specify the initial dry mass to be equivalent to
+!  a global mean surface pressure (101325 minus 245) Pa."
+preff=101080.
 CALL getin('preff', preff)
+
 ! Reference pressure at which hybrid coord. become purely pressure
 ! pa=50000.
 pa=preff/2.
 CALL getin('pa', pa)
+
 ! Gravity
 g=9.80665
+
 CALL getin('g',g)
 ! Molar mass of the atmosphere
+
 molmass = 28.9644
 CALL getin('molmass',molmass)
 ! kappa=R/Cp et Cp      
+
 kappa = 2./7.
 CALL getin('kappa',kappa)
+
 cpp=8.3145/molmass/kappa*1000.
 CALL getin('cpp',cpp)
 ! Radius of the planet
+
 rad = 6371229. 
 CALL getin('radius',rad)
+
 ! Length of a standard day (s)
 daysec=86400.
 CALL getin('daysec',daysec)
+
 ! Rotation rate of the planet:
 ! Length of a solar day, in standard days
 daylen = 1.
+
 CALL getin('daylen',daylen)
 ! Number of days (standard) per year:
+
 year_day = 365.25
 CALL getin('year_day',year_day)
 ! Omega
 ! omeg=2.*pi/86400.
+
 omeg=2.*pi/daysec*(1./daylen+1./year_day)
 CALL getin('omeg',omeg)
Index: LMDZ6/branches/Portage_acc/libf/dyn3d_common/control_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d_common/control_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d_common/control_mod.F90	(revision 4446)
@@ -29,5 +29,4 @@
   INTEGER,SAVE :: ip_ebil_dyn
   LOGICAL,SAVE :: offline
-  CHARACTER(len=4),SAVE :: config_inca
   CHARACTER(len=10),SAVE :: planet_type ! planet type ('earth','mars',...)
   LOGICAL,SAVE :: output_grads_dyn ! output dynamics diagnostics in
@@ -38,4 +37,5 @@
   LOGICAL,SAVE :: ok_dyn_ave ! output averaged values of fields in the dynamics
                              ! in NetCDF files dyn_hist*ave.nc
+  LOGICAL,SAVE :: ok_dyn_xios ! xios outputs in dynamics
   LOGICAL,SAVE :: resetvarc  ! allows to reset the variables in sortvarc
 
Index: LMDZ6/branches/Portage_acc/libf/dyn3d_common/disvert.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d_common/disvert.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d_common/disvert.F90	(revision 4446)
@@ -11,5 +11,5 @@
   use assert_m, only: assert
   USE comvert_mod, ONLY: ap, bp, aps, bps, nivsigs, nivsig, dpres, presnivs, &
-                         pseudoalt, pa, preff, scaleheight
+                         pseudoalt, pa, preff, scaleheight, presinter
   USE logic_mod, ONLY: ok_strato
 
@@ -35,4 +35,5 @@
 ! dpres(llm)                 !--- PRESSURE DIFFERENCE FOR EACH LAYER
 ! presnivs(llm)              !--- PRESSURE AT EACH MID-LAYER
+! presinter(llm+1)           !--- PRESSURE AT EACH INTERFACE
 ! scaleheight                !--- VERTICAL SCALE HEIGHT            (Earth: 8kms)
 ! nivsig(llm+1)              !--- SIGMA INDEX OF EACH LAYER INTERFACE
@@ -355,4 +356,8 @@
           max(ap(l+1)+bp(l+1)*preff, 1.e-10))
   ENDDO
+  DO l=1, llmp1
+     presinter(l)= ( ap(l)+bp(l)*preff)
+     write(lunout, *)'PRESINTER(', l, ')=', presinter(l)
+  ENDDO
 
   write(lunout, *) trim(modname),': PRESNIVS '
@@ -395,5 +400,5 @@
       ELSE IF(SIGN(f1,f4)/=f1) THEN; x2=xx; f2=f4
       ELSE IF(SIGN(f2,f4)/=f2) THEN; x1=xx; f1=f4
-      ELSE; CALL abort_gcm("ridders",'Algorithm failed (which is odd...')
+      ELSE; CALL abort_gcm("ridders",'Algorithm failed (which is odd...', 1)
       END IF
       IF(ABS(10.*LOG(ABS(x2-x1)))<=1E-5) EXIT       !--- ERROR ON SIG <= 0.01m            
Index: LMDZ6/branches/Portage_acc/libf/dyn3d_common/grilles_gcm_netcdf_sub.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d_common/grilles_gcm_netcdf_sub.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d_common/grilles_gcm_netcdf_sub.F90	(revision 4446)
@@ -2,13 +2,17 @@
 ! $Id: $
 !
-! This subroutine creates the file grilles_gcm.nc containg longitudes and
-! latitudes in degrees for grid u and v. This subroutine is called from
-! ce0l. This subroutine corresponds to the first 
-! part in the program create_fausse_var.
+! This subroutine creates the grilles_gcm.nc file, containing:
+! -> longitudes and latitudes in degrees for dynamical grids u, v and scalaire,
+! and the following variables added for INCA (informative anyway)
+! -> vertical levels "presnivs"
+! -> mask (land/sea), area (grid), phis=surface geopotential height = phis/g
 !
+! The subroutine is called in dynphy_lonlat/phylmd/ce0l.F90.
+
 SUBROUTINE grilles_gcm_netcdf_sub(masque,phis)
 
   USE comconst_mod, ONLY: cpp, kappa, g, omeg, daysec, rad, pi
   USE comvert_mod, ONLY: presnivs, preff, pa
+  use netcdf, only: nf90_def_var, nf90_int, nf90_float, nf90_put_var
   
   IMPLICIT NONE
@@ -19,32 +23,35 @@
   INCLUDE "netcdf.inc"
 
-
+!======================== 
   REAL,DIMENSION(iip1,jjp1),INTENT(IN)  :: masque ! masque terre/mer
   REAL,DIMENSION(iip1,jjp1),INTENT(IN)  :: phis   ! geopotentiel au sol
 
-  REAL temp(iim+1,jjm+1)
-  ! Attributs netcdf sortie
+  INTEGER status,i,j
+  
+  ! Attributs netcdf output
   INTEGER ncid_out,rcode_out
-  INTEGER out_lonuid,out_lonvid,out_latuid,out_latvid,out_levid
-  INTEGER out_varid
+  
+  INTEGER out_lonuid,out_lonvid,out_latuid,out_latvid
+  INTEGER out_uid,out_vid,out_tempid
   INTEGER out_lonudim,out_lonvdim
-  INTEGER out_latudim,out_latvdim,out_dim(3)
+  INTEGER out_latudim,out_latvdim,out_dim(2)
   INTEGER out_levdim
-
-  INTEGER start(4),COUNT(4)
-
-  INTEGER status,i,j
-  REAL rlatudeg(jjp1),rlatvdeg(jjm),rlevdeg(llm)
+  !
+  INTEGER :: presnivs_id
+  INTEGER :: mask_id,area_id,phis_id
+  !
+  INTEGER start(2),COUNT(2)
+
+  ! Variables
+  REAL rlatudeg(jjp1),rlatvdeg(jjm),rlev(llm)
   REAL rlonudeg(iip1),rlonvdeg(iip1)
-
-  REAL dlon1(iip1),dlon2(iip1),dlat1(jjp1),dlat2(jjp1)
-  REAL acoslat,dxkm,dykm,resol(iip1,jjp1)
-  REAL,DIMENSION(iip1,jjp1)  :: phis_loc
+  REAL uwnd(iip1,jjp1),vwnd(iip1,jjm),temp(iip1,jjp1) 
+  !
   INTEGER masque_int(iip1,jjp1)
-  INTEGER :: phis_id
-  INTEGER :: area_id
-  INTEGER :: mask_id
-  INTEGER :: presnivs_id
-  
+  REAL :: phis_loc(iip1,jjp1)
+  
+  !======================== 
+  ! CALCULATION of latu, latv, lonu, lonv in deg.
+  ! ---------------------------------------------------
   rad = 6400000
   omeg = 7.272205e-05
@@ -64,4 +71,5 @@
      rlatudeg(j)=rlatu(j)*180./pi
   ENDDO
+  
   DO j=1,jjm
      rlatvdeg(j)=rlatv(j)*180./pi
@@ -72,12 +80,31 @@
      rlonvdeg(i)=rlonv(i)*180./pi + 360.
   ENDDO
-
-
-  !  2 ----- OUVERTURE DE LA SORTIE NETCDF
-  ! ---------------------------------------------------
-  ! CREATION OUTPUT
-  ! ouverture fichier netcdf de sortie out
+ 
+  ! CALCULATION of "false" variables on u, v, s grids
+  ! --------------------------------------------------- 
+   DO i=1,iip1
+     DO j=1,jjp1
+        uwnd(i,j)=MOD(i,2)+MOD(j,2)
+        temp(i,j)=MOD(i,2)+MOD(j,2)
+     ENDDO
+     DO j=1,jjm
+        vwnd(i,j)=MOD(i,2)+MOD(j,2)
+     END DO
+  ENDDO  
+
+  ! CALCULATION of local vars for presnivs, mask, sfc. geopot. height
+  ! --------------------------------------------------- 
+  rlev(:) = presnivs(:)
+  phis_loc(:,:) = phis(:,:)/g
+  masque_int(:,:) = nINT(masque(:,:))
+
+
+  ! OPEN output netcdf file
+  !-------------------------
   status=NF_CREATE('grilles_gcm.nc',IOR(NF_CLOBBER,NF_64BIT_OFFSET),ncid_out)
   CALL handle_err(status)
+  
+  ! DEFINE output dimensions
+  !-------------------------
   status=NF_DEF_DIM(ncid_out,'lonu',iim+1,out_lonudim)
   CALL handle_err(status)
@@ -88,166 +115,118 @@
   status=NF_DEF_DIM(ncid_out,'latv',jjm,out_latvdim)
   CALL handle_err(status)
-
-
-  !   Longitudes en u
-  status=NF_DEF_VAR(ncid_out,'lonu',NF_FLOAT,1,out_lonudim, out_lonuid)
+  !
+  status=NF_DEF_DIM(ncid_out,'lev',llm,out_levdim)
+  CALL handle_err(status)
+  
+  ! DEFINE output variables
+  !-------------------------
+  !   Longitudes on "u" dynamical grid
+  status=NF90_DEF_VAR(ncid_out,'lonu',NF90_FLOAT,out_lonudim, out_lonuid)
   CALL handle_err(status)
   status=NF_PUT_ATT_TEXT(ncid_out,out_lonuid,'units', 12,'degrees_east')
-  status=NF_PUT_ATT_TEXT(ncid_out,out_lonuid,'long_name',9,'Longitude en u')
-
-  !   Longitudes en v
-  status=NF_DEF_VAR(ncid_out,'lonv',NF_FLOAT,1,out_lonvdim, out_lonvid)
+  status=NF_PUT_ATT_TEXT(ncid_out,out_lonuid,'long_name',19,'Longitude on u grid')
+  !   Longitudes on "v" dynamical grid
+  status=NF90_DEF_VAR(ncid_out,'lonv',NF90_FLOAT,out_lonvdim, out_lonvid)
   CALL handle_err(status)
   status=NF_PUT_ATT_TEXT(ncid_out,out_lonvid,'units', 12,'degrees_east')
-  status=NF_PUT_ATT_TEXT(ncid_out,out_lonvid,'long_name', 9,'Longitude en v')
-
-  !   Latitude en u
-  status=NF_DEF_VAR(ncid_out,'latu',NF_FLOAT,1,out_latudim, out_latuid)
+  status=NF_PUT_ATT_TEXT(ncid_out,out_lonvid,'long_name', 19,'Longitude on v grid')
+  !   Latitudes on "u" dynamical grid
+  status=NF90_DEF_VAR(ncid_out,'latu',NF90_FLOAT,out_latudim, out_latuid)
   CALL handle_err(status)
   status=NF_PUT_ATT_TEXT(ncid_out,out_latuid,'units', 13,'degrees_north')
-  status=NF_PUT_ATT_TEXT(ncid_out,out_latuid,'long_name', 8,'Latitude en u')
-
-  !  Latitude en v
-  status=NF_DEF_VAR(ncid_out,'latv',NF_FLOAT,1,out_latvdim, out_latvid)
+  status=NF_PUT_ATT_TEXT(ncid_out,out_latuid,'long_name', 18,'Latitude on u grid')
+  !  Latitudes on "v" dynamical grid
+  status=NF90_DEF_VAR(ncid_out,'latv',NF90_FLOAT,out_latvdim, out_latvid)
   CALL handle_err(status)
   status=NF_PUT_ATT_TEXT(ncid_out,out_latvid,'units', 13,'degrees_north')
-  status=NF_PUT_ATT_TEXT(ncid_out,out_latvid,'long_name', 8,'Latitude en v')
-
-  !   ecriture de la grille u
+  status=NF_PUT_ATT_TEXT(ncid_out,out_latvid,'long_name', 18,'Latitude on v grid')
+  !  "u" lat/lon dynamical grid
   out_dim(1)=out_lonudim
   out_dim(2)=out_latudim
-  status=NF_DEF_VAR(ncid_out,'grille_u',NF_FLOAT,2,out_dim, out_varid)
-  CALL handle_err(status)
-  status=NF_PUT_ATT_TEXT(ncid_out,out_varid,'units', 6,'Kelvin')
-  status=NF_PUT_ATT_TEXT(ncid_out,out_varid,'long_name', 16,'Grille aux point u')
-
-  !   ecriture de la grille v
+  status=NF90_DEF_VAR(ncid_out,'grille_u',NF90_FLOAT,out_dim, out_uid)
+  CALL handle_err(status)
+  status=NF_PUT_ATT_TEXT(ncid_out,out_uid,'units', 3,'m/s')
+  status=NF_PUT_ATT_TEXT(ncid_out,out_uid,'long_name', 21,'u-wind dynamical grid')
+  !  "v" lat/lon dynamical grid
   out_dim(1)=out_lonvdim
   out_dim(2)=out_latvdim
-  status=NF_DEF_VAR(ncid_out,'grille_v',NF_FLOAT,2,out_dim, out_varid)
-  CALL handle_err(status)
-  status=NF_PUT_ATT_TEXT(ncid_out,out_varid,'units', 6,'Kelvin')
-  status=NF_PUT_ATT_TEXT(ncid_out,out_varid,'long_name', 16,'Grille aux point v')
-
-  !   ecriture de la grille u
+  status=NF90_DEF_VAR(ncid_out,'grille_v',NF90_FLOAT,out_dim, out_vid)
+  CALL handle_err(status)
+  status=NF_PUT_ATT_TEXT(ncid_out,out_vid,'units', 3,'m/s')
+  status=NF_PUT_ATT_TEXT(ncid_out,out_vid,'long_name', 21,'v-wind dynamical grid')
+  !  "s" (scalar) lat/lon dynamical grid
   out_dim(1)=out_lonvdim
   out_dim(2)=out_latudim
-  status=NF_DEF_VAR(ncid_out,'grille_s',NF_FLOAT,2,out_dim, out_varid)
-  CALL handle_err(status)
-  status=NF_PUT_ATT_TEXT(ncid_out,out_varid,'units', 6,'Kelvin')
-  status=NF_PUT_ATT_TEXT(ncid_out,out_varid,'long_name',16,'Grille aux point u')
-
-  status=NF_ENDDEF(ncid_out)
-  write(*,*) "COUCOU 6"
-  CALL handle_err(status)
-  ! 5) ----- FERMETURE DES FICHIERS NETCDF------------------
-  ! --------------------------------------------------------
-  ! 3-b- Ecriture de la grille pour la sortie
-  ! rajoute l'ecriture de la grille
-
-#ifdef NC_DOUBLE
-  status=NF_PUT_VARA_DOUBLE(ncid_out,out_lonuid,1,iim+1,rlonudeg)
-  CALL handle_err(status)
-  status=NF_PUT_VARA_DOUBLE(ncid_out,out_lonvid,1,iim+1,rlonvdeg)
-  CALL handle_err(status)
-  status=NF_PUT_VARA_DOUBLE(ncid_out,out_latuid,1,jjm+1,rlatudeg)
-  CALL handle_err(status)
-  status=NF_PUT_VARA_DOUBLE(ncid_out,out_latvid,1,jjm,rlatvdeg)
-  CALL handle_err(status)
-#else
-  status=NF_PUT_VARA_REAL(ncid_out,out_lonuid,1,iim+1,rlonudeg)
-  CALL handle_err(status)
-  status=NF_PUT_VARA_REAL(ncid_out,out_lonvid,1,iim+1,rlonvdeg)
-  CALL handle_err(status)
-  status=NF_PUT_VARA_REAL(ncid_out,out_latuid,1,jjm+1,rlatudeg)
-  CALL handle_err(status)
-  status=NF_PUT_VARA_REAL(ncid_out,out_latvid,1,jjm,rlatvdeg)
-  CALL handle_err(status)
-#endif
-
-  start(1)=1
-  start(2)=1
-  start(3)=1
-  start(4)=1
-
-  COUNT(1)=iim+1
-  COUNT(2)=jjm+1
-  COUNT(3)=1
-  COUNT(4)=1
-
-  DO j=1,jjm+1
-     DO i=1,iim+1
-        temp(i,j)=MOD(i,2)+MOD(j,2)
-     ENDDO
-  ENDDO
-
-#ifdef NC_DOUBLE
-  status=NF_PUT_VARA_DOUBLE(ncid_out,out_varid,start, count,temp)
-  CALL handle_err(status)
-#else
-  status=NF_PUT_VARA_REAL(ncid_out,out_varid,start, count,temp)
-  CALL handle_err(status)
-#endif
-
-  ! On re-ouvre le fichier pour rajouter 4 nouvelles variables necessaire pour INCA
-! lev - phis - aire - mask
-! rlevdeg(:) = presnivs
-  rlevdeg(:) = presnivs(:)
-  phis_loc(:,:) = phis(:,:)/g
-
-! niveaux de pression verticaux
-  status = NF_REDEF (ncid_out)
-  CALL handle_err(status)
-  status=NF_DEF_DIM(ncid_out,'lev',llm,out_levdim)
-  CALL handle_err(status)
-  status=NF_DEF_VAR(ncid_out,'presnivs',NF_FLOAT,1,out_levdim,&
-                    presnivs_id)
-  CALL handle_err(status)
-  
-! fields
+  status=NF90_DEF_VAR(ncid_out,'grille_s',NF90_FLOAT,out_dim, out_tempid)
+  CALL handle_err(status)
+  status=NF_PUT_ATT_TEXT(ncid_out,out_tempid,'units', 6,'Kelvin')
+  status=NF_PUT_ATT_TEXT(ncid_out,out_tempid,'long_name',21,'scalar dynamical grid')
+  !
+  ! for INCA :
+  ! vertical levels "presnivs"
+  status=NF90_DEF_VAR(ncid_out,'presnivs',NF90_FLOAT,out_levdim, presnivs_id)
+  CALL handle_err(status)
+  status=NF_PUT_ATT_TEXT(ncid_out,presnivs_id,'units', 2,'Pa')
+  status=NF_PUT_ATT_TEXT(ncid_out,presnivs_id,'long_name',15,'Vertical levels')
+  ! surface geopotential height: named "phis" as the sfc geopotential, is actually phis/g
   out_dim(1)=out_lonvdim
   out_dim(2)=out_latudim
-
-  status = nf_def_var(ncid_out,'phis',NF_FLOAT,2,out_dim,phis_id)
-  CALL handle_err(status)
-  status = nf_def_var(ncid_out,'aire',NF_FLOAT,2,out_dim,area_id)
-  CALL handle_err(status)
-  status = nf_def_var(ncid_out,'mask',NF_INT  ,2,out_dim,mask_id)
-  CALL handle_err(status)
-
-  status=NF_ENDDEF(ncid_out)
-  CALL handle_err(status)
-
-  ! ecriture des variables
-#ifdef NC_DOUBLE
-  status=NF_PUT_VARA_DOUBLE(ncid_out,presnivs_id,1,llm,rlevdeg)
-  CALL handle_err(status)
-#else
-  status=NF_PUT_VARA_REAL(ncid_out,out_levid,1,llm,rlevdeg)
-  CALL handle_err(status)
-#endif
-
-  start(1)=1
-  start(2)=1
-  start(3)=1
-  start(4)=0
+  status = nf90_def_var(ncid_out,'phis',NF90_FLOAT,out_dim,phis_id)
+  CALL handle_err(status)
+  status=NF_PUT_ATT_TEXT(ncid_out,phis_id,'units', 1,'m')
+  status=NF_PUT_ATT_TEXT(ncid_out,phis_id,'long_name',27,'surface geopotential height')
+  ! gridcell area
+  status = nf90_def_var(ncid_out,'aire',NF90_FLOAT,out_dim,area_id)
+  CALL handle_err(status)
+  status=NF_PUT_ATT_TEXT(ncid_out,area_id,'units', 2,'m2')
+  status=NF_PUT_ATT_TEXT(ncid_out,area_id,'long_name',13,'gridcell area')
+  ! land-sea mask (nearest integer approx)
+  status = nf90_def_var(ncid_out,'mask',NF90_INT,out_dim,mask_id)
+  CALL handle_err(status)
+  status=NF_PUT_ATT_TEXT(ncid_out,mask_id,'long_name',27,'land-sea mask (nINT approx)')
+  
+  ! END the 'define' mode in netCDF file
+  status=NF_ENDDEF(ncid_out)  
+  CALL handle_err(status)
+  
+  ! WRITE the variables
+  !-------------------------
+  ! 1D : lonu, lonv,latu,latv ; INCA : presnivs
+  status=NF90_PUT_VAR(ncid_out,out_lonuid,rlonudeg,[1],[iip1])
+  CALL handle_err(status)
+  status=NF90_PUT_VAR(ncid_out,out_lonvid,rlonvdeg,[1],[iip1])
+  CALL handle_err(status)
+  status=NF90_PUT_VAR(ncid_out,out_latuid,rlatudeg,[1],[jjp1])
+  CALL handle_err(status)
+  status=NF90_PUT_VAR(ncid_out,out_latvid,rlatvdeg,[1],[jjm])
+  CALL handle_err(status)
+  status=NF90_PUT_VAR(ncid_out,presnivs_id,rlev,[1],[llm])
+  CALL handle_err(status)
+
+  ! 2D : grille_u,grille_v,grille_s ; INCA: phis,aire,mask
+  start(:)=1 
   COUNT(1)=iip1
-  COUNT(2)=jjp1
-  COUNT(3)=1
-  COUNT(4)=0
-
-  status = nf_put_vara_double(ncid_out, phis_id,start,count, phis_loc)
-  CALL handle_err(status)
-  status = nf_put_vara_double(ncid_out, area_id,start,count, aire)
-  CALL handle_err(status)
-  masque_int(:,:) = nINT(masque(:,:))
-  status = nf_put_vara_int(ncid_out, mask_id,start,count,masque_int)
-  CALL handle_err(status)
-  
-  ! fermeture du fichier netcdf
+  
+  COUNT(2)=jjp1  ! for "u" and "s" grids
+  status=NF90_PUT_VAR(ncid_out,out_uid,uwnd,start, count)
+  CALL handle_err(status)
+  COUNT(2)=jjm  ! for "v" grid
+  status=NF90_PUT_VAR(ncid_out,out_vid,vwnd,start, count)
+  CALL handle_err(status) 
+  COUNT(2)=jjp1  ! as "s" grid, for all the following vars
+  status=NF90_PUT_VAR(ncid_out,out_tempid,temp,start, count)
+  CALL handle_err(status)
+  status = nf90_put_var(ncid_out, phis_id, phis_loc,start,count)
+  CALL handle_err(status) 
+  status = nf90_put_var(ncid_out, area_id, aire,start,count)
+  CALL handle_err(status) 
+  status = nf90_put_var(ncid_out, mask_id,masque_int,start,count)
+  CALL handle_err(status)
+  
+  ! CLOSE netcdf file
   CALL ncclos(ncid_out,rcode_out)
+  write(*,*) "END grilles_gcm_netcdf_sub OK"
 
 END SUBROUTINE grilles_gcm_netcdf_sub
-
 
 
Index: LMDZ6/branches/Portage_acc/libf/dyn3d_common/infotrac.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d_common/infotrac.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d_common/infotrac.F90	(revision 4446)
@@ -3,9 +3,9 @@
 MODULE infotrac
 
-   USE       strings_mod, ONLY: msg, find, strIdx,  strFind, strParse, dispTable, int2str,  reduceExpr, &
-                          cat, fmsg, test, strTail, strHead, strStack, strReduce, bool2str, maxlen, testFile
-   USE readTracFiles_mod, ONLY: trac_type, readTracersFiles, addPhase, indexUpdate,  nphases, ancestor,  &
-                                isot_type, old2newName,      delPhase,               getKey_init, tran0, &
-                                keys_type, initIsotopes,     getPhase, known_phases, getKey, setGeneration
+   USE       strings_mod, ONLY: msg, fmsg, maxlen, cat, dispTable, int2str, bool2str, strStack, strParse
+   USE readTracFiles_mod, ONLY: trac_type, readTracersFiles, tracers, setGeneration, itZonIso, nzone, tran0, isoZone, &
+        delPhase, niso, getKey, isot_type, readIsotopesFile, isotope, maxTableWidth, iqIsoPha, nphas, ixIso, isoPhas, &
+        addPhase, iH2O, nbIso,  isoSelect, testTracersFiles, isoKeys, indexUpdate,   isoCheck, nzone, ntiso, isoName, &
+        addKey
    IMPLICIT NONE
 
@@ -13,5 +13,5 @@
 
    !=== FOR TRACERS:
-   PUBLIC :: infotrac_init                                 !--- Initialization of the tracers
+   PUBLIC :: init_infotrac                                 !--- Initialization of the tracers
    PUBLIC :: tracers, type_trac                            !--- Full tracers database, tracers type keyword
    PUBLIC :: nqtot,   nbtr,   nqo,   nqCO2,   nqtottr      !--- Main dimensions
@@ -19,8 +19,8 @@
 
    !=== FOR ISOTOPES: General
-   PUBLIC :: isotopes,  nbIso                              !--- Derived type, full isotopes families database + nb of families
+   PUBLIC :: isot_type, 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, tnat, alpha_ideal                       !--- H2O isotopes index, natural abundance, fractionning coeff.
+   PUBLIC :: iH2O                                          !--- H2O isotopes class index
    PUBLIC :: min_qParent, min_qMass, min_ratio             !--- Min. values for various isotopic quantities
    !=== FOR ISOTOPES: Depending on the selected isotopes family
@@ -28,17 +28,9 @@
    PUBLIC :: isoName, isoZone, isoPhas                     !--- Isotopes and tagging zones names, phases
    PUBLIC :: niso,    nzone,   nphas,   ntiso              !---  " " numbers + isotopes & tagging tracers number
-   PUBLIC :: itZonIso, index_trac                          !--- idx "it" (in "isoName(1:niso)") = function(tagging idx, isotope idx)
-   PUBLIC :: iqTraPha, iqiso                               !--- idx "iq" (in "qx") = function(isotope idx, phase idx) + aliases
+   PUBLIC :: itZonIso                                      !--- idx "it" (in "isoName(1:niso)") = function(tagging idx, isotope idx)
+   PUBLIC :: iqIsoPha                                      !--- idx "iq" (in "qx") = function(isotope idx, phase idx) + aliases
    PUBLIC :: isoCheck                                      !--- Run isotopes checking routines
    !=== FOR BOTH TRACERS AND ISOTOPES
    PUBLIC :: getKey                                        !--- Get a key from "tracers" or "isotope"
-
-   !=== OLD QUANTITIES OR ALIASES FOR OLDER NAMES (TO BE REMOVED SOON)
-   PUBLIC :: ntraciso, ntraceurs_zone
-   PUBLIC :: ok_iso_verif, use_iso
-   PUBLIC :: iso_num, iso_indnum, indnum_fn_num, niso_possibles
-   PUBLIC :: qperemin, masseqmin, ratiomin
-
-   INTERFACE isoSelect; MODULE PROCEDURE isoSelectByIndex, isoSelectByName; END INTERFACE isoSelect
 
 !=== CONVENTIONS FOR TRACERS NUMBERS:
@@ -76,17 +68,17 @@
 !  | 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                |
+!  | nqChildren  | Number of childs            (1st generation only)    | nqfils      | 1:nqtot                |
+!  | keys        | key/val pairs accessible with "getKey" routine       | /           |                        |
+!  | iadv        | Advection scheme number                              | iadv        | 1,2,10-20(exc.15,19),30|
+!  | isAdvected  | advected tracers flag (.TRUE. if iadv >= 0)          | /           | nqtrue  .TRUE. values  |
+!  | isInPhysics | tracers not extracted from the main table in physics | /           | nqtottr .TRUE. values  |
 !  | 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       | /           |                        |
 !  +-------------+------------------------------------------------------+-------------+------------------------+
 !
@@ -101,5 +93,5 @@
 !  | zone   | nzone  | Geographic tagging zones   list + number         | / | ntraceurs_zone |                 |
 !  | phase  | nphas  | Phases                     list + number         |                    | [g][l][s], 1:3  |
-!  | iqTraPha        | Index in "qx"           = f(name(1:ntiso)),phas) | iqiso              | 1:nqtot         |
+!  | 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         |
 !  +-----------------+--------------------------------------------------+--------------------+-----------------+
@@ -108,52 +100,19 @@
 
    !=== 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
-
-   !=== 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
-
-   !=== 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, POINTER :: 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, POINTER ::  niso, nzone, &    !--- NUMBER OF ISOTOPES, TAGGING ZONES AND PHASES
-                                             nphas, ntiso, &    !--- NUMBER OF PHASES AND ISOTOPES + ISOTOPIC TAGGING TRACERS
-                                            itZonIso(:,:), &    !--- INDEX IN "isoTrac" AS f(tagging zone idx,  isotope idx)
-                                            iqTraPha(:,:)       !--- INDEX IN "qx"      AS f(isotopic tracer idx, phase idx)
-
-   !--- Aliases for older names + quantities to be removed soon
-   INTEGER,                 SAVE, POINTER ::  index_trac(:,:)   ! numero ixt en fn izone, indnum entre 1 et niso
-   INTEGER,                 SAVE, POINTER ::  iqiso(:,:)        ! donne indice iq en fn de (ixt,phase) 
-   INTEGER,                 SAVE, POINTER :: ntraciso, ntraceurs_zone
-   REAL,    SAVE :: qperemin, masseqmin, ratiomin
-   INTEGER, SAVE :: niso_possibles
-   LOGICAL, SAVE :: ok_iso_verif
-   LOGICAL, SAVE, ALLOCATABLE ::       use_iso(:)
-   INTEGER, SAVE, ALLOCATABLE ::       iso_num(:)               !--- idx in [1,niso_possibles] = f(1<=iq <=nqtot)
-   INTEGER, SAVE, ALLOCATABLE ::    iso_indnum(:)               !--- idx in [1,niso]           = f(1<=iq <=nqtot)
-   INTEGER, SAVE, ALLOCATABLE :: indnum_fn_num(:)               !--- idx in [1,niso]           = f(1<=idx<=niso_possibles)
-
-   !=== VARIABLES FOR ISOTOPES INITIALIZATION AND FOR INCA
-   REAL,                SAVE, ALLOCATABLE ::     tnat(:), &     !--- Natural relative abundance of water isotope        (niso)
-                                          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)
-   LOGICAL, PARAMETER :: lOldCode = .TRUE.
+   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
+                                  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
+
+   !=== VARIABLES FOR INCA
+   INTEGER,               SAVE, ALLOCATABLE :: conv_flg(:), &   !--- Convection     activation ; needed for INCA        (nbtr)
+                                                pbl_flg(:)      !--- Boundary layer activation ; needed for INCA        (nbtr)
 
 CONTAINS
 
-SUBROUTINE infotrac_init
-   USE control_mod, ONLY: planet_type, config_inca
+SUBROUTINE init_infotrac
+   USE control_mod, ONLY: planet_type
 #ifdef REPROBUS
    USE CHEM_REP,    ONLY: Init_chem_rep_trac
@@ -193,22 +152,17 @@
    CHARACTER(LEN=2)      ::   suff(9)                                !--- Suffixes for schemes of order 3 or 4 (Prather)
    CHARACTER(LEN=3)      :: descrq(30)                               !--- Advection scheme description tags
-   CHARACTER(LEN=maxlen) :: msg1                                     !--- String for messages
-   CHARACTER(LEN=maxlen), ALLOCATABLE :: str(:)                      !--- Temporary storage
+   CHARACTER(LEN=maxlen) :: msg1, texp, ttp                          !--- Strings for messages and expanded tracers type
    INTEGER :: fType                                                  !--- Tracers description file type ; 0: none
                                                                      !--- 1/2/3: "traceur.def"/"tracer.def"/"tracer_*.def"
    INTEGER :: nqtrue                                                 !--- Tracers nb from tracer.def (no higher order moments)
    INTEGER :: iad                                                    !--- Advection scheme number
-   INTEGER :: ic, ip, np, iq, jq, it, nt, im, nm, ix, iz, nz, k      !--- Indexes and temporary variables
+   INTEGER :: ic, iq, jq, it, nt, im, nm, iz, k                      !--- Indexes and temporary variables
    LOGICAL :: lerr, ll
    CHARACTER(LEN=1) :: p
    TYPE(trac_type), ALLOCATABLE, TARGET :: ttr(:)
    TYPE(trac_type), POINTER             :: t1, t(:)
-   TYPE(isot_type), POINTER             :: iso
-
-   CHARACTER(LEN=maxlen), ALLOCATABLE :: tnom_0(:), tnom_transp(:)   !--- Tracer short name + transporting fluid name
-   CHARACTER(LEN=maxlen)              :: tchaine
    INTEGER :: ierr
 
-   CHARACTER(LEN=*), PARAMETER :: modname="infotrac_init"
+   CHARACTER(LEN=*), PARAMETER :: modname="init_infotrac"
 !------------------------------------------------------------------------------------------------------------------------------
 ! Initialization :
@@ -220,183 +174,86 @@
     
    CALL msg('type_trac = "'//TRIM(type_trac)//'"', modname)
-   IF(lOldCode) THEN
-      str = [type_trac]; nt = 1
-   ELSE
-      IF(strParse(type_trac, ',', str, n=nt)) CALL abort_gcm(modname,'can''t parse "type_trac = '//TRIM(type_trac)//'"',1)
-   END IF
-
-   !---------------------------------------------------------------------------------------------------------------------------
-   DO it = 1, nt                                                          !--- nt>1=> "type_trac": coma-separated keywords list
-   !---------------------------------------------------------------------------------------------------------------------------
-      !--- MESSAGE ABOUT THE CHOSEN CONFIGURATION
-      msg1 = 'For type_trac = "'//TRIM(str(it))//'":'
-      SELECT CASE(str(it))
-         CASE('inca'); CALL msg(TRIM(msg1)//' coupling with INCA chemistry model, config_inca='//config_inca, modname)
-         CASE('inco'); CALL msg(TRIM(msg1)//' coupling jointly with INCA and CO2 cycle',  modname)
-         CASE('repr'); CALL msg(TRIM(msg1)//' coupling with REPROBUS chemistry model',    modname)
-         CASE('co2i'); CALL msg(TRIM(msg1)//' you have chosen to run with CO2 cycle',     modname)
-         CASE('coag'); CALL msg(TRIM(msg1)//' tracers are treated for COAGULATION tests', modname)
-         CASE('lmdz'); CALL msg(TRIM(msg1)//' tracers are treated in LMDZ only',          modname)
-         CASE DEFAULT; CALL abort_gcm(modname,'type_trac='//TRIM(str(it))//' not possible yet.',1)
-      END SELECT
-
-      !--- COHERENCE TEST BETWEEN "type_trac" AND "config_inca"
-      IF(ANY(['inca', 'inco'] == str(it)) .AND. ALL(['aero', 'aeNP', 'chem'] /= config_inca)) &
-         CALL abort_gcm(modname, 'Incoherence between type_trac and config_inca. Please modify "run.def"',1)
-
-      !--- COHERENCE TEST BETWEEN "type_trac" AND PREPROCESSING KEYS
-      SELECT CASE(str(it))
-         CASE('inca', 'inco')
+
+   !--- MESSAGE ABOUT THE CHOSEN CONFIGURATION
+   msg1 = 'For type_trac = "'//TRIM(type_trac)//'":'
+   SELECT CASE(type_trac)
+      CASE('inca'); CALL msg(TRIM(msg1)//' coupling with INCA chemistry model',        modname)
+      CASE('inco'); CALL msg(TRIM(msg1)//' coupling jointly with INCA and CO2 cycle',  modname)
+      CASE('repr'); CALL msg(TRIM(msg1)//' coupling with REPROBUS chemistry model',    modname)
+      CASE('co2i'); CALL msg(TRIM(msg1)//' you have chosen to run with CO2 cycle',     modname)
+      CASE('coag'); CALL msg(TRIM(msg1)//' tracers are treated for COAGULATION tests', modname)
+      CASE('lmdz'); CALL msg(TRIM(msg1)//' tracers are treated in LMDZ only',          modname)
+      CASE DEFAULT; CALL abort_gcm(modname,'type_trac='//TRIM(type_trac)//' not possible yet.',1)
+   END SELECT
+
+   !--- COHERENCE TEST BETWEEN "type_trac" AND PREPROCESSING KEYS
+   SELECT CASE(type_trac)
+      CASE('inca', 'inco')
 #ifndef INCA
-            CALL abort_gcm(modname, 'You must add cpp key INCA and compile with INCA code', 1)
-#endif
-         CASE('repr')
+         CALL abort_gcm(modname, 'You must add cpp key INCA and compile with INCA code', 1)
+#endif
+      CASE('repr')
 #ifndef REPROBUS
-            CALL abort_gcm(modname, 'You must add cpp key REPROBUS and compile with REPROBUS code', 1)
-#endif
-         CASE('coag')
+         CALL abort_gcm(modname, 'You must add cpp key REPROBUS and compile with REPROBUS code', 1)
+#endif
+      CASE('coag')
 #ifndef CPP_StratAer
-            CALL abort_gcm(modname, 'You must add cpp key StratAer and compile with StratAer code', 1)
-#endif
-      END SELECT
-
-      !--- DISABLE "config_inca" OPTION FOR A RUN WITHOUT "INCA" IF IT DIFFERS FROM "none"
-      IF(fmsg('Setting config_inca="none" as you do not couple with INCA model', &
-              modname, ALL(['inca', 'inco'] /= str(it)) .AND. config_inca /= 'none')) config_inca = 'none'
-
-   !---------------------------------------------------------------------------------------------------------------------------
-   END DO
-   !---------------------------------------------------------------------------------------------------------------------------
-
-   nqCO2 = 0; IF(ANY(str == 'inco')) nqCO2 = 1
+         CALL abort_gcm(modname, 'You must add cpp key StratAer and compile with StratAer code', 1)
+#endif
+   END SELECT
+
+   nqCO2 = COUNT( [type_trac == 'inco', type_trac == 'co2i'] )
 
 !==============================================================================================================================
 ! 1) Get the numbers of: true (first order only) tracers "nqtrue", water tracers "nqo" (vapor/liquid/solid)
 !==============================================================================================================================
-
-!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-   IF(lOldCode) THEN         !--- "type_trac" is a single keyword => no need to loop on its parsed version "str(:)"
-!------------------------------------------------------------------------------------------------------------------------------
-   !--- Determine nqtrue and (INCA only) nqo, nbtr
-   OPEN(90, FILE='traceur.def', FORM='formatted', STATUS='old', IOSTAT=ierr)
-   IF(ierr /= 0) CALL abort_gcm(modname, 'file "traceur.def" not found !', 1)
-   CALL msg('File "traceur.def" successfully opened.', modname)
-
-   IF(ANY(['inca','inco'] == type_trac)) THEN
+   texp = type_trac                                                  !=== EXPANDED VERSION OF "type_trac", WITH "|" SEPARATOR
+   IF(texp == 'inco') texp = 'co2i|inca'
+   IF(texp /= 'lmdz') texp = 'lmdz|'//TRIM(texp)
+
+   !=== DETERMINE THE TYPE OF THE INPUT TRACERS DESCRIPTION FILE
+   IF(testTracersFiles(modname, texp, fType, .TRUE.)) CALL abort_gcm(modname, 'problem with tracers file(s)',1)
+   ttp = type_trac; IF(fType /= 1) ttp = texp
+
+   IF(readTracersFiles(ttp, type_trac == 'repr'))     CALL abort_gcm(modname, 'problem with tracers file(s)',1)
+   !---------------------------------------------------------------------------------------------------------------------------
+   IF(fType == 0) CALL abort_gcm(modname, 'Missing tracers file: "traceur.def", "tracer.def" or "tracer_<keyword>.def file.',1)
+   !---------------------------------------------------------------------------------------------------------------------------
+   IF(fType == 1 .AND. ANY(['inca','inco']==type_trac)) THEN         !=== FOUND OLD STYLE INCA "traceur.def"
+   !---------------------------------------------------------------------------------------------------------------------------
 #ifdef INCA
-      READ(90,*) nqo
-      IF(nqCO2==1 .AND. nqo==4) nqo = 3
-      CALL Init_chem_inca_trac(nqINCA)
-      nbtr = nqINCA + nqCO2
-      nqtrue = nbtr + nqo
-      IF(ALL([2,3] /= nqo)) CALL abort_gcm(modname, 'Only 2 or 3 water phases allowed ; found nqo='//TRIM(int2str(nqo)), 1)
-      ALLOCATE(hadv_inca(nqINCA), conv_flg_inca(nqINCA), solsym_inca(nqINCA))
-      ALLOCATE(vadv_inca(nqINCA),  pbl_flg_inca(nqINCA))
-      CALL init_transport(solsym_inca, conv_flg_inca, pbl_flg_inca, hadv_inca, vadv_inca)
-#endif
-   ELSE
-      READ(90,*) nqtrue
-   END IF
-
-   IF (planet_type=="earth" .AND. nqtrue < 2) &
-      CALL abort_gcm('infotrac_init', 'Not enough tracers: nqtrue='//TRIM(int2str(nqtrue))//', 2 tracers is the minimum', 1)
-
-   !--- Allocate variables depending on nqtrue
-   ALLOCATE(hadv(nqtrue), vadv(nqtrue), tnom_0(nqtrue), tnom_transp(nqtrue), tracers(nqtrue))
-
-   !--- Continue to read tracer.def
-   it = 0
-   DO iq = 1, nqtrue
-#ifdef INCA
-      IF(iq > nqo+nqCO2) THEN
-         it = it+1
-         hadv  (iq) = hadv_inca  (it)
-         vadv  (iq) = vadv_inca  (it) 
-         tnom_0(iq) = solsym_inca(it)
-         tnom_transp(iq) = 'air'
-         CYCLE
-      END IF
-#endif
-      READ(90,'(I2,X,I2,X,A)',IOSTAT=ierr) hadv(iq),vadv(iq),tchaine
-      IF(ierr/=0) CALL abort_gcm('infotrac_init', 'Pb dans la lecture de traceur.def', 1)
-      jq = INDEX(tchaine(1:LEN_TRIM(tchaine)),' ')
-      CALL msg("Ancienne version de traceur.def: traceurs d'air uniquement", modname, iq==1 .AND. jq==0)
-      CALL msg("Nouvelle version de traceur.def",                            modname, iq==1 .AND. jq/=0)
-      CALL msg('iq, hadv, vadv, tchaine ='//TRIM(strStack(int2str([iq, hadv(iq), vadv(iq)])))//', '//TRIM(tchaine), modname)
-      IF(jq /= 0) THEN                                               !--- Space in the string chain => new format
-         tnom_0     (iq) = tchaine(1:jq-1)
-         tnom_transp(iq) = tchaine(jq+1:)
-      ELSE
-         tnom_0     (iq) = tchaine
-         tnom_transp(iq) = 'air'
-      END IF
-   END DO
-   CLOSE(90)
-
-#ifndef INCA
-   IF(planet_type /= 'earth') nqo = 0                                !--- Same number of tracers in dynamics and physics
-   IF(planet_type == 'earth') nqo = COUNT(delPhase(tnom_0) == 'H2O') !--- for all planets except for Earth
-   nbtr = nqtrue - nqo
-#endif
-
-   CALL msg('RAW CONTENT OF "traceur.def" FILE:', modname)
-   IF(dispTable('iiss', ['hadv  ', 'vadv  ', 'name  ', 'parent'], cat(tnom_0, tnom_transp), cat(hadv, vadv))) &
-      CALL abort_gcm(modname, "problem with the tracers table content", 1)
-
-   !--- SET FIELDS %name, %parent, %phase, %component
-   tracers(:)%name      = old2newName(tnom_0)
-   tracers(:)%parent    = old2newName(tnom_transp)
-   tracers(:)%phase     = [( getPhase(tracers(iq)%name), iq=1, nqtrue )]
-   tracers(:)%component = type_trac
-   DO iq = 1, nqtrue
-      IF(addPhase('H2O',tracers(iq)%phase) == tracers(iq)%name) tracers(iq)%component = 'lmdz'
-   END DO
-   IF(ANY(['inca','inco'] == type_trac)) tracers(1+nqo:nqCO2+nqo)%component = 'co2i'
-   CALL setGeneration(tracers)                                       !--- SET FIELDS %iGeneration, %gen0Name
-   WHERE(tracers(:)%iGeneration == 2) tracers(:)%type = 'tag'        !--- DEFAULT VALUE: "tracer"
-
-   !--- FINALIZE
-   DEALLOCATE(tnom_0, tnom_transp)
-#ifdef INCA
-   DEALLOCATE(hadv_inca, vadv_inca, conv_flag_inca, pbl_flag_inca, solsym_inca)
-#endif
-
-!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-ELSE
-!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-   IF(readTracersFiles(type_trac, fType, tracers)) CALL abort_gcm(modname, 'problem with tracers file(s)',1)
-   IF(fType == 0) CALL abort_gcm(modname, 'Missing tracers file: "traceur.def", "tracer.def" or "tracer_<keyword>.def file.',1)
-   !---------------------------------------------------------------------------------------------------------------------------
-   IF(fType == 1 .AND. ANY(['inca','inco'] == type_trac)) THEN       !=== FOUND OLD STYLE INCA "traceur.def" (single type_trac)
-   !---------------------------------------------------------------------------------------------------------------------------
-#ifdef INCA
-      nqo = SIZE(tracers)
-      IF(nqCO2==1 .AND. nqo==4) nqo = 3                              !--- Force nqo to 3 (ThL)
+      nqo = SIZE(tracers) - nqCO2
       CALL Init_chem_inca_trac(nqINCA)                               !--- Get nqINCA from INCA
       nbtr = nqINCA + nqCO2                                          !--- Number of tracers passed to phytrac
       nqtrue = nbtr + nqo                                            !--- Total number of "true" tracers
       IF(ALL([2,3] /= nqo)) CALL abort_gcm(modname, 'Only 2 or 3 water phases allowed ; found nqo='//TRIM(int2str(nqo)), 1)
-      ALLOCATE(hadv(nqtrue), conv_flg(nbtr), hadv_inca(nqINCA), conv_flg_inca(nqINCA), solsym_inca(nqINCA))
-      ALLOCATE(vadv(nqtrue),  pbl_flg(nbtr), vadv_inca(nqINCA),  pbl_flg_inca(nqINCA))
+      ALLOCATE(hadv(nqtrue), hadv_inca(nqINCA), conv_flg_inca(nqINCA), solsym_inca(nqINCA))
+      ALLOCATE(vadv(nqtrue), vadv_inca(nqINCA),  pbl_flg_inca(nqINCA))
       CALL init_transport(solsym_inca, conv_flg_inca, pbl_flg_inca, hadv_inca, vadv_inca)
-      !--- Passive CO2 tracer is at position 1 because: H2O has been removed ; nqCO2/=0 in "inco" case only
-      conv_flg(1:nbtr) = [(1,          k=1, nqCO2), conv_flg_inca]
-       pbl_flg(1:nbtr) = [(1,          k=1, nqCO2),  pbl_flg_inca]
       ALLOCATE(ttr(nqtrue))
-      ttr(1:nqo+nqCO2)                    = tracers
-      ttr(1    :      nqo   )%component   = 'lmdz'
-      ttr(1+nqo:nqCO2+nqo   )%component   = 'co2i'
-      ttr(1+nqo+nqCO2:nqtrue)%component   = 'inca'
-      ttr(1+nqo      :nqtrue)%name        = [('CO2     ', k=1, nqCO2), solsym_inca]
-      ttr(1+nqo+nqCO2:nqtrue)%parent      = tran0
-      ttr(1+nqo+nqCO2:nqtrue)%phase       = 'g'
-      lerr = getKey('hadv', had, ky=ttr(:)%keys); hadv(:) = [had, hadv_inca]
-      lerr = getKey('vadv', vad, ky=ttr(:)%keys); vadv(:) = [vad, vadv_inca]
+      ttr(1:nqo+nqCO2)                  = tracers
+      ttr(1    :      nqo   )%component = 'lmdz'
+      ttr(1+nqo:nqCO2+nqo   )%component = 'co2i'
+      ttr(1+nqo+nqCO2:nqtrue)%component = 'inca'
+      ttr(1+nqo      :nqtrue)%name      = [('CO2     ', k=1, nqCO2), solsym_inca]
+      ttr(1+nqo+nqCO2:nqtrue)%parent    = tran0
+      ttr(1+nqo+nqCO2:nqtrue)%phase     = 'g'
+      lerr = getKey('hadv', had, ky=tracers(:)%keys)
+      lerr = getKey('vadv', vad, ky=tracers(:)%keys)
+      hadv(1:nqo+nqCO2) = had(:); hadv(1+nqo+nqCO2:nqtrue) = hadv_inca
+      vadv(1:nqo+nqCO2) = vad(:); vadv(1+nqo+nqCO2:nqtrue) = vadv_inca
       CALL MOVE_ALLOC(FROM=ttr, TO=tracers)
-      CALL setGeneration(tracers)                                    !--- SET FIELDS %iGeneration, %gen0Name
+      DO iq = 1, nqtrue
+         t1 => tracers(iq)
+         CALL addKey('name',      t1%name,      t1%keys)
+         CALL addKey('component', t1%component, t1%keys)
+         CALL addKey('parent',    t1%parent,    t1%keys)
+         CALL addKey('phase',     t1%phase,     t1%keys)
+      END DO
+      IF(setGeneration(tracers)) CALL abort_gcm(modname,'See above',1) !- SET FIELDS %iGeneration, %gen0Name
       DEALLOCATE(had, hadv_inca, vad, vadv_inca, conv_flg_inca, pbl_flg_inca, solsym_inca)
 #endif
    !---------------------------------------------------------------------------------------------------------------------------
-   ELSE                                                              !=== FOUND NEW STYLE TRACERS CONFIGURATION FILE(S)
+   ELSE                                                              !=== OTHER CASES (OLD OR NEW FORMAT, NO INCA MODULE)
    !---------------------------------------------------------------------------------------------------------------------------
       nqo    =        COUNT(delPhase(tracers(:)%name)     == 'H2O' &
@@ -405,22 +262,18 @@
       nbtr   = nqtrue-COUNT(delPhase(tracers(:)%gen0Name) == 'H2O' &
                                .AND. tracers(:)%component == 'lmdz') !--- Number of tracers passed to phytrac
+#ifdef INCA
+      nqINCA = COUNT(tracers(:)%component == 'inca')
+#endif
       lerr = getKey('hadv', hadv, ky=tracers(:)%keys)
       lerr = getKey('vadv', vadv, ky=tracers(:)%keys)
-      ALLOCATE(conv_flg(nbtr), pbl_flg(nbtr))
-      conv_flg(1:nbtr) = [(1, it=1, nbtr)]                           !--- Convection activated for all tracers
-       pbl_flg(1:nbtr) = [(1, it=1, nbtr)]                           !--- Boundary layer activated for all tracers
    !---------------------------------------------------------------------------------------------------------------------------
    END IF
    !---------------------------------------------------------------------------------------------------------------------------
-END IF
-!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-   CALL getKey_init(tracers)
-
+
+#ifdef REPROBUS
    !--- Transfert the number of tracers to Reprobus
-#ifdef REPROBUS
    CALL Init_chem_rep_trac(nbtr, nqo, tracers(:)%name)
-#endif
-
+
+#endif
 !==============================================================================================================================
 ! 2) Calculate nqtot, number of tracers needed (greater if advection schemes 20 or 30 have been chosen).
@@ -496,5 +349,5 @@
    CALL MOVE_ALLOC(FROM=ttr, TO=tracers)
 
-   !--- SET FIELDS %iqParent, %nqChilds, %iGeneration, %iqDescen, %nqDescen
+   !--- SET FIELDS %iqParent, %nqChildren, %iGeneration, %iqDescen, %nqDescen
    CALL indexUpdate(tracers)
 
@@ -520,74 +373,16 @@
    END DO
 
-IF(lOldCode) THEN
-
-   CALL infotrac_setHeredity                !--- SET FIELDS %iqParent, %nqChilds, %iGeneration, %gen0Name, %iqDescen, %nqDescen
-   CALL infotrac_isoinit                    !--- SET FIELDS %type, %iso_iName, %iso_iZone, %iso_iPhase
-   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
-
-   !--- Remove the isotopic tracers from the tracers list passed to phytrac
-   nbtr    = nbtr -nqo*   ntiso             !--- ISOTOPIC TAGGING TRACERS ARE NOT PASSED TO THE PHYSICS
-   nqtottr = nqtot-nqo*(1+ntiso)            !--- NO H2O-FAMILY    TRACER  IS      PASSED TO THE PHYSICS
-
-   ALLOCATE(conv_flg(nbtr), pbl_flg(nbtr))
-#ifndef INCA
-   conv_flg(1:nbtr) = 1                                              !--- Convection activated for all tracers
-    pbl_flg(1:nbtr) = 1                                              !--- Boundary layer activated for all tracers
-#else
-   !--- Passive CO2 tracer is at position 1 because: H2O has been removed ; nqCO2/=0 in "inco" case only
-   conv_flg(1:nbtr) = [(1, ic=1, nqCO2),conv_flg_inca]
-    pbl_flg(1:nbtr) = [(1, ic=1, nqCO2), pbl_flg_inca]
-#endif
-
-ELSE
-
-   CALL initIsotopes(tracers, isotopes)
-   nbIso = SIZE(isotopes)
-   nqtottr = nqtot - COUNT(tracers%gen0Name == 'H2O' .AND. tracers%component == 'lmdz')
-   IF(nbIso/=0) THEN                        !--- ISOTOPES FOUND
-
-      !=== 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, alpha_ideal)
-      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
-      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)
-
-      !=== MAKE SURE THE MEMBERS OF AN ISOTOPES FAMILY ARE PRESENT IN THE SAME PHASES
-      DO ix = 1, nbIso
-         iso => isotopes(ix)
-         !--- Check whether each isotope and tagging isotopic tracer is present in the same number of phases
-         DO it = 1, iso%ntiso
-            np = SUM([(COUNT(tracers(:)%name == addPhase(iso%trac(it), iso%phase(ip:ip))), ip=1, iso%nphas)])
-            IF(np == iso%nphas) CYCLE
-            WRITE(msg1,'("Found ",i0," phases for ",a," instead of ",i0)')np, TRIM(iso%trac(it)), iso%nphas
-            CALL abort_gcm(modname, msg1, 1)
-         END DO
-         DO it = 1, iso%niso
-            nz = SUM([(COUNT(iso%trac == TRIM(iso%trac(it))//'_'//iso%zone(iz)), iz=1, iso%nzone)])
-            IF(nz == iso%nzone) CYCLE
-            WRITE(msg1,'("Found ",i0," tagging zones for ",a," instead of ",i0)')nz, TRIM(iso%trac(it)), iso%nzone
-            CALL abort_gcm(modname, msg1, 1)
-         END DO
-      END DO
-   END IF
-
-END IF
+   !=== READ PHYSICAL PARAMETERS FOR ISOTOPES ; DONE HERE BECAUSE dynetat0 AND iniacademic NEED "tnat" AND "alpha_ideal"
+   niso = 0; nzone = 0; nphas = nqo; ntiso = 0; isoCheck = .FALSE.
+   IF(readIsotopesFile()) CALL abort_gcm(modname, 'Problem when reading isotopes parameters', 1)
+
+   !--- Convection / boundary layer activation for all tracers
+   ALLOCATE(conv_flg(nbtr)); conv_flg(1:nbtr) = 1
+   ALLOCATE( pbl_flg(nbtr));  pbl_flg(1:nbtr) = 1
 
    !--- Note: nqtottr can differ from nbtr when nmom/=0
-!   IF(COUNT(tracers%iso_iName == 0) - COUNT(delPhase(tracers%name) == 'H2O' .AND. tracers%component == 'lmdz') /= nqtottr) &
-!      CALL abort_gcm('infotrac_init', 'pb dans le calcul de nqtottr', 1)
-
-   !--- Some aliases to be removed later
-   ntraciso       => ntiso
-   ntraceurs_zone => nzone
-   qperemin       =  min_qParent
-   masseqmin      =  min_qMass
-   ratiomin       =  min_ratio
-   iqiso          => iqTraPha
-   index_trac     => itZonIso
+   nqtottr = nqtot - COUNT(delPhase(tracers%gen0Name) == 'H2O' .AND. tracers%component == 'lmdz')
+   IF(COUNT(tracers%iso_iName == 0) - COUNT(delPhase(tracers%name) == 'H2O' .AND. tracers%component == 'lmdz') /= nqtottr) &
+      CALL abort_gcm(modname, 'pb dans le calcul de nqtottr', 1)
 
    !=== DISPLAY THE RESULTS
@@ -605,14 +400,14 @@
    CALL msg('Information stored in infotrac :', modname)
    IF(dispTable('isssssssssiiiiiiiii', &
-      ['iq    ', 'name  ', 'lName ', 'gen0N ', 'parent', 'type  ', 'phase ', 'compon', 'isAdv ', 'isPhy ', &
+      ['iq    ', 'name  ', 'lName ', 'gen0N ', 'parent', 'type  ', 'phase ', 'compon', 'isPhy ', 'isAdv ', &
        'iadv  ', 'iGen  ', 'iqPar ', 'nqDes ', 'nqChld', 'iGroup', 'iName ', 'iZone ', 'iPhase'],          &
-      cat(t%name, t%longName, t%gen0Name, t%parent, t%type, t%phase, t%component, bool2str(t%isAdvected),  &
-                                                                                  bool2str(t%isInPhysics)),&
-      cat([(iq, iq=1, nqtot)], t%iadv, t%iGeneration, t%iqParent, t%nqDescen, t%nqChilds, t%iso_iGroup,    &
-                                                    t%iso_iName, t%iso_iZone, t%iso_iPhase), sub=modname)) &
+      cat(t%name, t%longName, t%gen0Name, t%parent, t%type, t%phase, t%component, bool2str(t%isInPhysics), &
+                                                                                  bool2str(t%isAdvected)), &
+      cat([(iq, iq=1, nqtot)], t%iadv, t%iGeneration, t%iqParent, t%nqDescen, t%nqChildren, t%iso_iGroup,  &
+                  t%iso_iName, t%iso_iZone, t%iso_iPhase), nColMax=maxTableWidth, nHead=2, sub=modname))   &
       CALL abort_gcm(modname, "problem with the tracers table content", 1)
    IF(niso > 0) THEN
       CALL msg('Where, for isotopes family "'//TRIM(isotope%parent)//'":', modname)
-      CALL msg('  isoKeys = '//strStack(isoKeys%name), modname)
+      CALL msg('  isoKeys%name = '//strStack(isoKeys%name), modname)
       CALL msg('  isoName = '//strStack(isoName),      modname)
       CALL msg('  isoZone = '//strStack(isoZone),      modname)
@@ -623,229 +418,5 @@
    CALL msg('end', modname)
 
-END SUBROUTINE infotrac_init
-
-
-
-SUBROUTINE infotrac_setHeredity
-   !--- Purpose: Set fields %iqParent, %nqChilds, %iGeneration, %iqDescen, %nqDescen (old method)
-   USE strings_mod, ONLY: strIdx
-   INTEGER               :: iq, jq, ipere, ifils
-   INTEGER, ALLOCATABLE  :: iqfils(:,:)
-   CHARACTER(LEN=maxlen) :: msg1, modname='infotrac_init'
-   INCLUDE "iniprint.h"
-
-   !=== SET FIELDS %iqParent, %nqChilds
-   ALLOCATE(iqfils(nqtot,nqtot)); iqfils(:,:) = 0
-   tracers(:)%nqChilds = 0
-   tracers(:)%iqParent = 0
-
-   DO iq = 1, nqtot
-      msg1 = 'Tracer nr. '//TRIM(int2str(iq))//', called "'//TRIM(tracers(iq)%name)//'" is '
-
-      !--- IS IT A GENERATION 0 TRACER ? IF SO, tracers(iq)%iqParent KEEPS ITS DEFAULT VALUE (0)
-      IF(fmsg(TRIM(msg1)//' a parent', modname, tracers(iq)%parent == tran0)) CYCLE
-
-      !--- TRACERS OF GENERATION > 0 ; FIND ITS PARENT INDEX
-      ipere = strIdx(tracers(:)%name, tracers(iq)%parent)
-      IF(ipere == 0)  CALL abort_gcm('infotrac_init', TRIM(msg1)//' an orphan', 1)
-      IF(iq == ipere) CALL abort_gcm('infotrac_init', TRIM(msg1)//' its own parent',1)
-
-      CALL msg(TRIM(msg1)//' the child of '//TRIM(tracers(ipere)%name), modname)
-      tracers(iq)%iqParent    = ipere
-      tracers(ipere)%nqChilds = tracers(ipere)%nqChilds+1
-      iqfils(tracers(ipere)%nqChilds,ipere) = iq
-   END DO
-
-   CALL msg('nqGen0   = '//int2str(COUNT(tracers(:)%parent == 'air')), modname)
-   CALL msg('nqChilds = '//strStack(int2str(tracers(:)%nqChilds)),     modname)
-   CALL msg('iqParent = '//strStack(int2str(tracers(:)%iqParent)),     modname)
-   CALL msg('iqChilds = '//strStack(int2str(PACK(iqfils,MASK=.TRUE.))),modname)
-
-   !=== SET FIELDS %iGeneration, %iqDescen, %nqDescen
-   tracers(:)%iGeneration = 0
-   tracers(:)%nqDescen = 0
-   DO iq = 1, nqtot
-      ifils = iq
-      DO WHILE(tracers(ifils)%iqParent > 0)
-         ipere = tracers(ifils)%iqParent
-         tracers(ipere)%nqDescen = tracers(ipere)%nqDescen+1   
-         tracers(iq)%iGeneration = tracers(iq)%iGeneration+1
-         iqfils(tracers(ipere)%nqDescen,ipere) = iq
-         ifils = ipere
-      END DO
-      msg1 = 'Tracer nr. '//TRIM(int2str(iq))//', called "'//TRIM(tracers(iq)%name)//'" is '
-      CALL msg(TRIM(msg1)//' of generation '//TRIM(int2str(tracers(iq)%iGeneration)), modname)
-   END DO
-   DO iq=1,nqtot
-      tracers(iq)%iqDescen = iqfils(1:tracers(iq)%nqDescen,iq)
-   END DO
-
-   !=== SET FIELD %gen0Name
-   DO iq = 1, nqtot
-      jq=iq; DO WHILE(tracers(jq)%iGeneration > 0); jq=tracers(jq)%iqParent; END DO
-      tracers(iq)%gen0Name = tracers(jq)%name
-   END DO
-
-   CALL msg('nqDescen = '//TRIM(strStack(int2str(tracers(:)%nqDescen))), modname)
-   CALL msg('nqDescen_tot = ' //TRIM(int2str(SUM(tracers(:)%nqDescen))), modname)
-   CALL msg('iqDescen = '//strStack(int2str(PACK(iqfils, MASK=.TRUE.))), modname)
-
-END SUBROUTINE infotrac_setHeredity
-
-
-
-SUBROUTINE infotrac_isoinit
-
-#ifdef CPP_IOIPSL
-   USE IOIPSL
-#else
-   USE ioipsl_getincom
-#endif
-   USE readTracFiles_mod, ONLY: tnom_iso => newH2OIso
-   IMPLICIT NONE
-   INTEGER, ALLOCATABLE  :: nb_iso(:), nb_tiso(:), nb_zone(:), ix(:)
-   INTEGER               :: ii, ip, iq, it, iz, ixt
-   TYPE(isot_type), POINTER :: i
-   TYPE(trac_type), POINTER :: t(:), t1
-   CHARACTER(LEN=maxlen)    :: tnom_trac, modname, t0
-   CHARACTER(LEN=maxlen), ALLOCATABLE :: str(:)
-   LOGICAL, DIMENSION(:), ALLOCATABLE :: mask
-   REAL, ALLOCATABLE :: tnat0(:), alpha_ideal0(:)
-   INCLUDE "iniprint.h"
-
-   modname = 'infotrac_isoinit'
-   tnat0       = [ 1.0 ,  155.76e-6, 2005.2e-6, 0.004/100., 0.0 ]    !--- Same length as tnom_iso
-   alpha_ideal0= [ 1.0 ,  1.01,      1.006,     1.003,      1.0 ]    !--- Same length as tnom_iso
-   ALLOCATE(isotopes(1))                                             !--- Only water
-   nbIso = SIZE(isotopes)
-   t => tracers
-   i => isotopes(1)
-   i%parent = 'H2O'
-
-   !--- Effective isotopes names list (embedded in the "keys" field)
-   mask = t%type=='tracer' .AND. t%gen0Name==addPhase('H2O', 'g') .AND. t%iGeneration==1
-   str = PACK(delPhase(t%name), MASK=mask)
-   CALL strReduce(str)
-   i%niso = SIZE(str)
-   ALLOCATE(i%keys(i%niso))
-   i%keys(:)%name = str
-
-   !--- Check whether found isotopes are known
-   mask = [(ALL(tnom_iso /= str(ii)), ii=1, i%niso)]
-   IF(ANY(mask)) CALL abort_gcm(modname, 'The following isotopes are unknown: '//strStack(PACK(str, MASK=mask)), 1)
-
-   !--- Full isotopes list, with isotopes tagging tracers (if any) following the previous list
-   mask = t%type=='tag'    .AND. t%gen0Name==addPhase('H2O', 'g') .AND. t%iGeneration==2
-   str = PACK(delPhase(t%name), MASK=mask)
-   i%ntiso = i%niso + SIZE(str)
-   ALLOCATE(i%trac(i%ntiso))
-   i%trac(:) = [i%keys(:)%name, str]
-
-   !--- Effective tagging zones names list
-   i%zone = strTail(str, '_', .TRUE.)
-   CALL strReduce(i%zone)
-   i%nzone = SIZE(i%zone)
-   IF(i%ntiso /= i%niso*(i%nzone+1)) CALL abort_gcm(modname, 'Error in "ntiso" calculation', 1)
-
-   !--- Effective phases list
-   i%phase = ''
-   DO ip=1,nphases; IF(strIdx(t%name, addPhase('H2O', ip))/=0) i%phase=TRIM(i%phase)//known_phases(ip:ip); END DO
-   i%nphas = LEN_TRIM(i%phase)
-
-   !--- Indexes related to isotopes
-   DO iq = 1, nqtot
-      t1 => tracers(iq)
-      t0 = t1%gen0Name
-      IF(t1%iGeneration==0 .OR. .NOT.t1%isAdvected .OR. delPhase(t0)/='H2O') CYCLE
-      t1%iso_iGroup = 1
-      t1%iso_iPhase = INDEX(i%phase, getPhase(t0))
-      t1%iso_iZone = strIdx(i%zone,  strTail(t1%name, '_'))
-      IF(t1%iso_iZone /= 0) t1%iso_iName = strIdx(i%keys(:)%name, delPhase(t1%parent))
-      IF(t1%iso_iZone == 0) t1%iso_iName = strIdx(i%keys(:)%name, delPhase(t1%name  ))
-   END DO
-
-   niso_possibles = SIZE(tnom_iso)
-!   ix = strIdx(tnom_iso, i%trac)
-!   tnat        = tnat0       (PACK(ix, MASK=ix/=0))
-!   alpha_ideal = alpha_ideal0(PACK(ix, MASK=ix/=0))
-   tnat        = tnat0
-   alpha_ideal = alpha_ideal0
-
-   !--- Tests
-   nb_iso  = [(COUNT(t%iso_iPhase == ip .AND. t%iGeneration == 1), ip=1, i%nphas)]
-   nb_tiso = [(COUNT(t%iso_iPhase == ip .AND. t%iGeneration == 2), ip=1, i%nphas)]
-   nb_zone = [(COUNT(t%iso_iZone  == iz), iz=1, i%nzone)]
-   IF(ANY(nb_iso (:) /= nb_iso (1))) CALL abort_gcm(modname, 'Phases must have same number of isotopes', 1)
-   IF(ANY(nb_tiso(:) /= nb_tiso(1))) CALL abort_gcm(modname, 'Phases must have same number of tagging tracers', 1)
-   IF(i%nzone >= 1) THEN
-      IF(ANY(nb_zone(:) /= nb_zone(1))) CALL abort_gcm(modname, 'Isotopes must have the same number of tagging tracers', 1)
-   END IF
-
-   !--- Isotopic checking routines activation flag
-   i%check = .FALSE.; IF(i%niso > 0) CALL getin('ok_iso_verif', i%check)
-
-   !--- Table: index in "qx(:)" of an isotope, knowing its indices "it","ip" in "isotope%iName,%iPhase"
-   i%iqTraPha = RESHAPE([((strIdx(t%name, TRIM(addPhase(i%trac(it),ip,i%phase))),it=1,i%ntiso),ip=1,i%nphas)],[i%ntiso,i%nphas])
-
-   !--- Table: index in "isotope%tracs(:)%name" of an isotopic tagging tracer, knowing its indices "iz","ip" in "isotope%iZone,%iName"
-   i%itZonIso = RESHAPE([((strIdx(i%trac,TRIM(i%trac(it))//'_'//TRIM(i%zone(iz))),iz=1,i%nzone),it=1,i%niso )],[i%nzone,i%niso])
-
-   DO it=1,i%ntiso; CALL msg('iqTraPha('//TRIM(int2str(it))//',:) = '//strStack(int2str(i%iqTraPha(it,:))), modname); END DO
-   DO iz=1,i%nzone; CALL msg('itZonIso('//TRIM(int2str(iz))//',:) = '//strStack(int2str(i%itZonIso(iz,:))), modname); END DO
-
-   !--- Isotopic quantities (to be removed soon)
-   ok_iso_verif  = i%check
-   niso_possibles = SIZE(tnom_iso)
-   iso_num       = [(strIdx(tnom_iso(:),    strHead(delPhase(tracers(iq)%name), '_')), iq=1, nqtot)]
-   iso_indnum    = [(strIdx(i%keys(:)%name, strHead(delPhase(tracers(iq)%name), '_')), iq=1, nqtot)]
-   indnum_fn_num = [(strIdx(i%keys(:)%name, tnom_iso(ixt)), ixt=1, niso_possibles)]
-   use_iso       = indnum_fn_num /= 0            !--- .TRUE. for the effectively used isotopes of the possible isotopes list
-
-   !--- Finalize :
-   DEALLOCATE(nb_iso)
-
-END SUBROUTINE infotrac_isoinit
-
-
-!==============================================================================================================================
-!=== 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
-   CALL msg('no isotope family named "'//TRIM(iName)//'"', ll=lerr .AND. lV)
-   IF(lerr) RETURN
-   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
-   iqTraPha => isotope%iqTraPha
-END FUNCTION isoSelectByIndex
-!==============================================================================================================================
+END SUBROUTINE init_infotrac
 
 END MODULE infotrac
Index: LMDZ6/branches/Portage_acc/libf/dyn3d_common/iso_verif_dyn.F
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3d_common/iso_verif_dyn.F	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3d_common/iso_verif_dyn.F	(revision 4446)
@@ -64,5 +64,5 @@
         function iso_verif_aberrant_nostop
      :           (x,iso,q,err_msg)
-        USE infotrac, ONLY: tnat
+        USE infotrac, ONLY: isoName, getKey
         implicit none
         
@@ -74,5 +74,5 @@
         ! locals
         real qmin,deltaD
-        real deltaDmax,deltaDmin
+        real deltaDmax,deltaDmin,tnat
         parameter (qmin=1e-11)
         parameter (deltaDmax=200.0,deltaDmin=-999.9)
@@ -85,5 +85,10 @@
         ! verifier que HDO est raisonable
          if (q.gt.qmin) then
-             deltaD=(x/q/tnat(iso)-1)*1000
+             IF(getKey('tnat', tnat, isoName(iso))) THEN
+                  err_msg = 'Missing isotopic parameter "tnat"'
+                  iso_verif_aberrant_nostop=1
+                  RETURN
+             END IF
+             deltaD=(x/q/tnat-1)*1000
              if ((deltaD.gt.deltaDmax).or.(deltaD.lt.deltaDmin)) then
                   write(*,*) 'erreur detectee par iso_verif_aberrant:'
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/advtrac_loc.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/advtrac_loc.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/advtrac_loc.F90	(revision 4446)
@@ -10,5 +10,5 @@
    !            M.A Filiberti (04/2002)
    !
-   USE infotrac,     ONLY: nqtot, tracers, ok_iso_verif
+   USE infotrac,     ONLY: nqtot, tracers
    USE control_mod,  ONLY: iapp_tracvl, day_step, planet_type
    USE comconst_mod, ONLY: dtvr
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/caladvtrac_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/caladvtrac_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/caladvtrac_mod.F90	(revision 4446)
@@ -16,5 +16,13 @@
 
   REAL,POINTER,SAVE :: massem(:,:)
-  
+  !Offline
+  REAL,POINTER,SAVE :: tetac(:,:)
+  REAL,POINTER,SAVE :: massec(:,:)
+  REAL,POINTER,SAVE :: phic(:,:)
+  REAL,POINTER,SAVE :: pbarucc(:,:)
+  REAL,POINTER,SAVE :: pbarvcc(:,:)
+  REAL,POINTER,SAVE :: pbarugg(:,:)
+  REAL,POINTER,SAVE :: pbarvgg(:,:)
+  REAL,POINTER,SAVE :: wgg(:,:)
 CONTAINS
 
@@ -50,4 +58,13 @@
     CALL allocate_v(pbarvg,llm,d)
     CALL allocate_u(wg,llm,d)
+    ! Offline
+    CALL allocate_u(tetac,llm,d)
+    CALL allocate_u(phic,llm,d)
+    CALL allocate_u(pbarucc,llm,d)
+    CALL allocate_v(pbarvcc,llm,d)
+    CALL allocate_u(massec,llm,d)
+    CALL allocate_u(pbarugg,llm,d)
+    CALL allocate_v(pbarvgg,llm,d)
+    CALL allocate_u(wgg,llm,d)
 
     CALL groupe_allocate
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/check_isotopes_loc.F
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/check_isotopes_loc.F	(revision 4445)
+++ 	(revision )
@@ -1,217 +1,0 @@
-        subroutine check_isotopes(q,ijb,ije,err_msg)
-        USE infotrac, ONLY: nqtot, nqo, niso, ntraciso, nzone,
-     &                use_iso, ntraceurs_zone,
-     &                iqiso, indnum_fn_num, index_trac, tnat
-        USE parallel_lmdz
-        implicit none
-
-#include "dimensions.h"
-
-        ! inputs
-        integer ijb,ije ! peut être local et différent de ijb_u,ije_u, ex: dans qminimum
-        real q(ijb_u:ije_u,llm,nqtot)
-        character*(*) err_msg ! message d''erreur à afficher
-
-        ! locals
-        integer ixt,phase,k,i,iq,iiso,izone,ieau,iqeau
-        real xtractot,xiiso
-        real borne
-        real qmin
-        real errmax ! erreur maximale en absolu.
-        real errmaxrel ! erreur maximale en relatif autorisée
-        real deltaDmax,deltaDmin
-        real ridicule
-        parameter (borne=1e19)
-        parameter (errmax=1e-8)
-        parameter (errmaxrel=1e-3)
-        parameter (qmin=1e-11)
-        parameter (deltaDmax=1000.0,deltaDmin=-999.0)
-        parameter (ridicule=1e-12)
-        real deltaD
-
-        if (niso > 0) then
-
-!        write(*,*) 'check_isotopes 31: err_msg=',err_msg
-        ! verifier que rien n'est NaN
-        do ixt=1,ntraciso
-          do phase=1,nqo
-            iq=iqiso(ixt,phase)
-c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-            do k=1,llm
-              DO i = ijb,ije
-                if ((q(i,k,iq).gt.-borne).and.
-     :            (q(i,k,iq).lt.borne)) then
-                else !if ((x(ixt,i,j).gt.-borne).and.
-                  write(*,*) 'erreur detectee par iso_verif_noNaN:'
-                  write(*,*) err_msg
-                  write(*,*) 'q,i,k,iq=',q(i,k,iq),i,k,iq
-                  write(*,*) 'borne=',borne
-                  call abort_gcm('check_isotopes_loc','plantage iso',0)
-                endif  !if ((x(ixt,i,j).gt.-borne).and.
-              enddo !DO i = ijb,ije
-            enddo !do k=1,llm
-c$OMP END DO NOWAIT
-          enddo !do phase=1,nqo
-        enddo !do ixt=1,ntraciso
-
-!        write(*,*) 'check_isotopes 52'
-        ! verifier que l'eau normale est OK
-        if (use_iso(1)) then
-          ixt=indnum_fn_num(1)
-          do phase=1,nqo
-            iq=iqiso(ixt,phase)
-c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-            do k=1,llm
-            DO i = ijb,ije  
-              if ((abs(q(i,k,phase)-q(i,k,iq)).gt.errmax).and.
-     :          (abs((q(i,k,phase)-q(i,k,iq))/
-     :           max(max(abs(q(i,k,phase)),abs(q(i,k,iq))),1e-18))
-     :           .gt.errmaxrel)) then
-                  write(*,*) 'erreur detectee par iso_verif_egalite:'
-                  write(*,*) err_msg
-                  write(*,*) 'ixt,phase,ijb=',ixt,phase,ijb
-                  write(*,*) 'q,iq,i,k=',q(i,k,iq),iq,i,k
-                  write(*,*) 'q(i,k,phase)=',q(i,k,phase)
-                  call abort_gcm('check_isotopes_loc','plantage iso',0)
-              endif !if ((abs(q(i,k,phase)-q(i,k,iq)).gt.errmax).and.
-              ! bidouille pour éviter divergence:
-              q(i,k,iq)= q(i,k,phase) 
-            enddo ! DO i = ijb,ije
-            enddo !do k=1,llm
-c$OMP END DO NOWAIT
-          enddo ! do phase=1,nqo 
-        endif !if (use_iso(1)) then
-        
-!        write(*,*) 'check_isotopes 78'
-        ! verifier que HDO est raisonable
-        if (use_iso(2)) then
-          ixt=indnum_fn_num(2)
-          do phase=1,nqo
-            iq=iqiso(ixt,phase)
-c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-            do k=1,llm
-            DO i = ijb,ije
-            if (q(i,k,iq).gt.qmin) then
-             deltaD=(q(i,k,iq)/q(i,k,phase)/tnat(2)-1)*1000
-             if ((deltaD.gt.deltaDmax).or.(deltaD.lt.deltaDmin)) then
-                  write(*,*) 'erreur detectee par iso_verif_aberrant:'
-                  write(*,*) err_msg
-                  write(*,*) 'ixt,phase=',ixt,phase
-                  write(*,*) 'q,iq,i,k,=',q(i,k,iq),iq,i,k
-                  write(*,*) 'q=',q(i,k,:)
-                  write(*,*) 'deltaD=',deltaD
-                  call abort_gcm('check_isotopes_loc','plantage iso',0)
-             endif !if ((deltaD.gt.deltaDmax).or.(deltaD.lt.deltaDmin)) then
-            endif !if (q(i,k,iq).gt.qmin) then
-            enddo !DO i = ijb,ije
-            enddo !do k=1,llm
-c$OMP END DO NOWAIT
-          enddo ! do phase=1,nqo 
-        endif !if (use_iso(2)) then
-
-!        write(*,*) 'check_isotopes 103'
-        ! verifier que O18 est raisonable
-        if (use_iso(3)) then
-          ixt=indnum_fn_num(3)
-          do phase=1,nqo
-            iq=iqiso(ixt,phase)
-c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-            do k=1,llm
-            DO i = ijb,ije
-            if (q(i,k,iq).gt.qmin) then
-             deltaD=(q(i,k,iq)/q(i,k,phase)/tnat(3)-1)*1000
-             if ((deltaD.gt.deltaDmax).or.(deltaD.lt.deltaDmin)) then
-                  write(*,*) 'erreur detectee iso_verif_aberrant O18:'
-                  write(*,*) err_msg
-                  write(*,*) 'ixt,phase=',ixt,phase
-                  write(*,*) 'q,iq,i,k,=',q(i,k,phase),iq,i,k
-                  write(*,*) 'xt=',q(i,k,:)
-                  write(*,*) 'deltaO18=',deltaD
-                  call abort_gcm('check_isotopes_loc','plantage iso',0)
-             endif !if ((deltaD.gt.deltaDmax).or.(deltaD.lt.deltaDmin)) then
-            endif !if (q(i,k,iq).gt.qmin) then
-            enddo !DO i = ijb,ije
-            enddo !do k=1,llm
-c$OMP END DO NOWAIT
-          enddo ! do phase=1,nqo 
-        endif !if (use_iso(2)) then
-
-
-!        write(*,*) 'check_isotopes 129'
-        if (nzone > 0) then
-
-          if (use_iso(2).and.use_iso(1)) then
-            do izone=1,ntraceurs_zone
-             ixt=index_trac(izone,indnum_fn_num(2))
-             ieau=index_trac(izone,indnum_fn_num(1))
-             do phase=1,nqo
-               iq=iqiso(ixt,phase)
-               iqeau=iqiso(ieau,phase)
-c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-               do k=1,llm
-                DO i = ijb,ije
-                if (q(i,k,iq).gt.qmin) then
-                 deltaD=(q(i,k,iq)/q(i,k,iqeau)/tnat(2)-1)*1000
-                 if ((deltaD.gt.deltaDmax).or.
-     &                   (deltaD.lt.deltaDmin)) then
-                  write(*,*) 'erreur dans iso_verif_aberrant trac:'
-                  write(*,*) err_msg
-                  write(*,*) 'izone,phase=',izone,phase
-                  write(*,*) 'ixt,ieau=',ixt,ieau
-                  write(*,*) 'q,iq,i,k,=',q(i,k,iq),iq,i,k
-                  write(*,*) 'deltaD=',deltaD                  
-                  call abort_gcm('check_isotopes_loc','plantage iso',0)
-                 endif !if ((deltaD.gt.deltaDmax).or.
-                endif !if (q(i,k,iq).gt.qmin) then
-                enddo !DO i = ijb,ije
-                enddo  ! do k=1,llm
-c$OMP END DO NOWAIT
-              enddo ! do phase=1,nqo    
-            enddo !do izone=1,ntraceurs_zone
-          endif !if (use_iso(2).and.use_iso(1)) then
-
-          do iiso=1,niso
-           do phase=1,nqo
-              iq=iqiso(iiso,phase)
-c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
-              do k=1,llm
-                DO i = ijb,ije
-                   xtractot=0.0
-                   xiiso=q(i,k,iq)
-                   do izone=1,ntraceurs_zone
-                      iq=iqiso(index_trac(izone,iiso),phase)
-                      xtractot=xtractot+ q(i,k,iq)
-                   enddo !do izone=1,ntraceurs_zone
-                   if ((abs(xtractot-xiiso).gt.errmax).and.
-     :                  (abs(xtractot-xiiso)/
-     :                  max(max(abs(xtractot),abs(xiiso)),1e-18)
-     :                  .gt.errmaxrel)) then
-                  write(*,*) 'erreur detectee par iso_verif_traceurs:'
-                  write(*,*) err_msg
-                  write(*,*) 'iiso,phase=',iiso,phase
-                  write(*,*) 'i,k,=',i,k
-                  write(*,*) 'q(i,k,:)=',q(i,k,:)
-                  call abort_gcm('check_isotopes_loc','plantage iso',0)
-                 endif !if ((abs(q(i,k,phase)-q(i,k,iq)).gt.errmax).and.
-                  
-                 ! bidouille pour éviter divergence:
-                 if (abs(xtractot).gt.ridicule) then
-                   do izone=1,ntraceurs_zone
-                     ixt=index_trac(izone,iiso) 
-                     q(i,k,iq)=q(i,k,iq)/xtractot*xiiso
-                   enddo !do izone=1,ntraceurs_zone                
-                  endif !if ((abs(xtractot).gt.ridicule) then
-                enddo !DO i = ijb,ije
-              enddo !do k=1,llm
-c$OMP END DO NOWAIT
-           enddo !do phase=1,nqo
-          enddo !do iiso=1,niso
-
-        endif !if (nzone > 0)
-
-        endif ! if (niso > 0)
-!        write(*,*) 'check_isotopes 198'
-        
-        end
-
-
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/check_isotopes_loc.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/check_isotopes_loc.F90	(revision 4446)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/check_isotopes_loc.F90	(revision 4446)
@@ -0,0 +1,189 @@
+SUBROUTINE check_isotopes(q, ijb, ije, err_msg)
+   USE parallel_lmdz
+   USE strings_mod, ONLY: maxlen, msg, strIdx, strStack, int2str, real2str
+   USE infotrac,    ONLY: nqtot, niso, nphas, isotope, isoCheck, iqIsoPha, isoSelect, &
+                          ntiso, iH2O, nzone, tracers, isoName,  itZonIso, getKey
+   IMPLICIT NONE
+   include "dimensions.h"
+   REAL,             INTENT(INOUT) :: q(ijb_u:ije_u,llm,nqtot)
+   INTEGER,          INTENT(IN)    :: ijb, ije   !--- Can be local and different from ijb_u,ije_u, for example in qminimum
+   CHARACTER(LEN=*), INTENT(IN)    :: err_msg    !--- Error message to display
+   CHARACTER(LEN=maxlen) :: modname, msg1, nm(2)
+   INTEGER :: ixt, ipha, k, i, iq, iiso, izon, ieau, iqeau, iqpar
+   INTEGER, ALLOCATABLE ::   ix(:)
+   REAL,    ALLOCATABLE, SAVE :: tnat(:)         !--- OpenMP shared variable
+   REAL    :: xtractot, xiiso, deltaD, q1, q2
+   REAL, PARAMETER :: borne     = 1e19,  &
+                      errmax    = 1e-8,  &       !--- Max. absolute error
+                      errmaxrel = 1e-3,  &       !--- Max. relative error
+                      qmin      = 1e-11, &
+                      deltaDmax =1000.0, &
+                      deltaDmin =-999.0, &
+                      ridicule  = 1e-12
+   INTEGER, SAVE :: iso_eau, iso_HDO, iso_O18, & !--- OpenMP shared variables
+                             iso_O17, iso_HTO
+   LOGICAL, SAVE :: first=.TRUE.
+!$OMP THREADPRIVATE(first)
+
+   modname='check_isotopes'
+   IF(.NOT.isoCheck)    RETURN                   !--- No need to check => finished
+   IF(isoSelect('H2O')) RETURN                   !--- No H2O isotopes group found
+   IF(niso == 0)        RETURN                   !--- No isotopes => finished
+   IF(first) THEN
+!$OMP MASTER
+      iso_eau = strIdx(isoName,'H216O')
+      iso_HDO = strIdx(isoName,'HDO')
+      iso_O18 = strIdx(isoName,'H218O')
+      iso_O17 = strIdx(isoName,'H217O')
+      iso_HTO = strIdx(isoName,'HTO')
+      IF(getKey('tnat', tnat)) CALL abort_gcm(modname, 'missing isotopic parameter', 1)
+!$OMP END MASTER
+!$OMP BARRIER
+      first = .FALSE.
+   END IF
+   CALL msg('31: err_msg='//TRIM(err_msg), modname)
+
+   !--- CHECK FOR NaNs (FOR ALL THE ISOTOPES, INCLUDING GEOGRAPHIC TAGGING TRACERS)
+   modname = 'check_isotopes:iso_verif_noNaN'
+   DO ixt = 1, ntiso
+      DO ipha = 1, nphas
+         iq = iqIsoPha(ixt,ipha)
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+         DO k = 1, llm
+            DO i = ijb, ije
+               IF(ABS(q(i,k,iq))<=borne) CYCLE
+               WRITE(msg1,'(s,"(",i0,",",i0,",",i0,") = ",ES12.4)')TRIM(isoName(ixt)),i,k,iq,q(i,k,iq)
+               CALL msg(msg1, modname)
+               CALL abort_gcm(modname, 'Error with isotopes: '//TRIM(err_msg), 1)
+            END DO
+         END DO
+!$OMP END DO NOWAIT
+      END DO
+   END DO
+
+   !--- CHECK CONSERVATION (MAIN ISOTOPE AND PARENT CONCENTRATIONS MUST BE EQUAL)
+   modname = 'check_isotopes:iso_verif_egalite'
+   ixt = iso_eau
+   IF(ixt /= 0) THEN
+      DO ipha = 1, nphas
+         iq = iqIsoPha(ixt,ipha)
+         iqpar = tracers(iq)%iqParent
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+         DO k = 1, llm
+            DO i = ijb, ije
+               q1 = q(i,k,iqpar)
+               q2 = q(i,k,iq)
+!--- IMPROVEMENT in case at least one isotope is not negligible compared to the main isotopic form.
+!    This would be probably required to sum from smallest to highest concentrations ; the corresponding
+!    indices vector can be computed once only (in the initializations stage), using mean concentrations.
+!              q2 = SUM(q(i,k,tracers(iqPar)%iqDesc), DIM=3)
+               IF(ABS(q1-q2) <= errmax .OR. ABS(q1-q2)/MAX(MAX(ABS(q1),ABS(q2)),1e-18) <= errmaxrel) THEN
+                  q(i,k,iq) = q1                 !--- Bidouille pour convergence
+!                 q(i,k,tracers(iqPar)%iqDesc) = q(i,k,tracers(iqPar)%iqDesc) * q1 / q2
+                  CYCLE
+               END IF
+               CALL msg('ixt, iq = '//TRIM(strStack(int2str([ixt,iq]))), modname)
+               msg1 = '('//TRIM(strStack(int2str([i,k])))//')'
+               CALL msg(TRIM(tracers(iqpar)%name)//TRIM(msg1)//' = '//TRIM(real2str(q1)), modname)
+               CALL msg(TRIM(tracers(iq   )%name)//TRIM(msg1)//' = '//TRIM(real2str(q2)), modname)
+               CALL abort_gcm(modname, 'Error with isotopes: '//TRIM(err_msg), 1)
+            END DO
+         END DO
+!$OMP END DO NOWAIT
+      END DO
+   END IF
+
+   !--- CHECK DELTA ANOMALIES
+   modname = 'check_isotopes:iso_verif_aberrant'
+   ix = [ iso_HDO  ,   iso_O18 ]
+   nm = ['deltaD  ', 'deltaO18']
+   DO iiso = 1, SIZE(ix)
+      ixt = ix(iiso)
+      IF(ixt  == 0) CYCLE
+      DO ipha = 1, nphas
+         iq = iqIsoPha(ixt,ipha)
+         iqpar = tracers(iq)%iqParent
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+         DO k = 1, llm
+            DO i = ijb, ije
+               q1 = q(i,k,iqpar)
+               q2 = q(i,k,iq)
+!--- IMPROVEMENT in case at least one isotope is not negligible compared to the main isotopic form.
+!    This would be probably required to sum from smallest to highest concentrations ; the corresponding
+!    indices vector can be computed once only (in the initializations stage), using mean concentrations.
+!              q2 = SUM(q(i,k,tracers(iqPar)%iqDesc), DIM=3)
+               IF(q2 <= qmin) CYCLE
+               deltaD = (q2/q1/tnat(ixt)-1.)*1000.
+               IF(deltaD <= deltaDmax .AND. deltaD >= deltaDmin) CYCLE
+               CALL msg('ixt, iq = '//TRIM(strStack(int2str([ixt,iq]))), modname)
+               msg1 = '('//TRIM(strStack(int2str([i,k])))//')'
+               CALL msg(TRIM(tracers(iqpar)%name)//TRIM(msg1)//' = '//TRIM(real2str(q1)), modname)
+               CALL msg(TRIM(tracers(iq   )%name)//TRIM(msg1)//' = '//TRIM(real2str(q2)), modname)
+               CALL msg(TRIM(nm(iiso))//TRIM(real2str(deltaD)), modname)
+               CALL abort_gcm(modname, 'Error with isotopes: '//TRIM(err_msg), 1)
+            END DO
+         END DO
+!$OMP END DO NOWAIT
+      END DO
+   END DO
+
+   IF(nzone == 0) RETURN
+
+   !--- CHECK FOR TAGGING TRACERS DELTAD ANOMALIES
+   modname = 'check_isotopes:iso_verif_aberrant'
+   IF(iso_eau /= 0 .AND. iso_HDO /= 0) THEN
+      DO izon = 1, nzone
+         ixt  = itZonIso(izon, iso_HDO)
+         ieau = itZonIso(izon, iso_eau)
+         DO ipha = 1, nphas
+            iq    = iqIsoPha(ixt,  ipha)
+            iqeau = iqIsoPha(ieau, ipha)
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+            DO k = 1, llm
+               DO i = ijb, ije
+                  q1 = q(i,k,iqeau)
+                  q2 = q(i,k,iq)
+                  IF(q2<=qmin) CYCLE
+                  deltaD = (q2/q1/tnat(iso_HDO)-1.)*1000.
+                  IF(deltaD <= deltaDmax .AND. deltaD >= deltaDmin) CYCLE
+                  CALL msg('izon, ipha = '//TRIM(strStack(int2str([izon, ipha]))), modname)
+                  CALL msg( 'ixt, ieau = '//TRIM(strStack(int2str([ ixt, ieau]))), modname)
+                  msg1 = '('//TRIM(strStack(int2str([i,k])))//')'
+                  CALL msg(TRIM(tracers(iqeau)%name)//TRIM(msg1)//' = '//TRIM(real2str(q1)), modname)
+                  CALL msg(TRIM(tracers(iq   )%name)//TRIM(msg1)//' = '//TRIM(real2str(q2)), modname)
+                  CALL msg('deltaD = '//TRIM(real2str(deltaD)), modname)
+                  CALL abort_gcm(modname, 'Error with isotopes: '//TRIM(err_msg), 1)
+               END DO
+            END DO
+!$OMP END DO NOWAIT
+         END DO
+      END DO
+   END IF
+
+   !--- CHECK FOR TAGGING TRACERS CONSERVATION (PARENT AND TAGGING TRACERS SUM OVER ALL REGIONS MUST BE EQUAL)
+   DO iiso = 1, niso
+      DO ipha = 1, nphas
+         iq = iqIsoPha(iiso, ipha)
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+         DO k = 1, llm
+            DO i = ijb, ije
+               xiiso = q(i,k,iq)
+               xtractot = SUM(q(i, k, iqIsoPha(itZonIso(1:nzone,iiso), ipha)))
+               IF(ABS(xtractot-xiiso) > errmax .AND. ABS(xtractot-xiiso)/MAX(MAX(ABS(xtractot),ABS(xiiso)),1e-18) > errmaxrel) THEN
+                  CALL msg('Error in iso_verif_aberrant trac: '//TRIM(err_msg))
+                  CALL msg('iiso, ipha = '//TRIM(strStack(int2str([iiso, ipha]))), modname)
+                  CALL msg('q('//TRIM(strStack(int2str([i,k])))//',:) = '//TRIM(strStack(real2str(q(i,k,:)))), modname)
+                  CALL abort_gcm(modname, 'Error with isotopes: '//TRIM(err_msg), 1)
+               END IF
+               IF(ABS(xtractot) <= ridicule) CYCLE
+               DO izon = 1, nzone
+                  q(i,k,iq) = q(i,k,iq) / xtractot * xiiso !--- Bidouille pour convergence
+               END DO
+            END DO
+         END DO
+!$OMP END DO NOWAIT
+      END DO
+   END DO
+
+END SUBROUTINE check_isotopes
+
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/conf_gcm.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/conf_gcm.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/conf_gcm.F90	(revision 4446)
@@ -645,14 +645,4 @@
      CALL getin('type_trac',type_trac)
 
-     !Config  Key  = config_inca
-     !Config  Desc = Choix de configuration de INCA
-     !Config  Def  = none
-     !Config  Help = Choix de configuration de INCA :
-     !Config         'none' = sans INCA
-     !Config         'chem' = INCA avec calcul de chemie
-     !Config         'aero' = INCA avec calcul des aerosols 
-     config_inca = 'none'
-     CALL getin('config_inca',config_inca)
-
      !Config  Key  = ok_dynzon 
      !Config  Desc = calcul et sortie des transports 
@@ -678,4 +668,12 @@
      ok_dyn_ave = .FALSE. 
      CALL getin('ok_dyn_ave',ok_dyn_ave) 
+
+     !Config  Key  = ok_dyn_xios
+     !Config  Desc = sorties moyennes dans la dynamique
+     !Config  Def  = n 
+     !Config  Help = 
+     !Config          
+     ok_dyn_xios = .FALSE. 
+     CALL getin('ok_dyn_xios',ok_dyn_xios) 
 
      write(lunout,*)' #########################################'
@@ -717,8 +715,8 @@
      write(lunout,*)' offline = ', offline
      write(lunout,*)' type_trac = ', type_trac
-     write(lunout,*)' config_inca = ', config_inca
      write(lunout,*)' ok_dynzon = ', ok_dynzon 
      write(lunout,*)' ok_dyn_ins = ', ok_dyn_ins 
      write(lunout,*)' ok_dyn_ave = ', ok_dyn_ave 
+     write(lunout,*)' ok_dyn_xios = ', ok_dyn_xios 
   else
      !Config  Key  = clon
@@ -847,14 +845,4 @@
      CALL getin('type_trac',type_trac)
 
-     !Config  Key  = config_inca
-     !Config  Desc = Choix de configuration de INCA
-     !Config  Def  = none
-     !Config  Help = Choix de configuration de INCA :
-     !Config         'none' = sans INCA
-     !Config         'chem' = INCA avec calcul de chemie
-     !Config         'aero' = INCA avec calcul des aerosols 
-     config_inca = 'none'
-     CALL getin('config_inca',config_inca)
-
      !Config  Key  = ok_dynzon 
      !Config  Desc = sortie des transports zonaux dans la dynamique
@@ -880,4 +868,12 @@
      ok_dyn_ave = .FALSE. 
      CALL getin('ok_dyn_ave',ok_dyn_ave) 
+
+     !Config  Key  = ok_dyn_xios
+     !Config  Desc = sorties moyennes dans la dynamique
+     !Config  Def  = n 
+     !Config  Help = 
+     !Config          
+     ok_dyn_xios = .FALSE. 
+     CALL getin('ok_dyn_xios',ok_dyn_xios) 
 
      !Config  Key  = use_filtre_fft
@@ -989,8 +985,8 @@
      write(lunout,*)' offline = ', offline
      write(lunout,*)' type_trac = ', type_trac
-     write(lunout,*)' config_inca = ', config_inca
      write(lunout,*)' ok_dynzon = ', ok_dynzon
      write(lunout,*)' ok_dyn_ins = ', ok_dyn_ins 
      write(lunout,*)' ok_dyn_ave = ', ok_dyn_ave 
+     write(lunout,*)' ok_dyn_xios = ', ok_dyn_xios 
      write(lunout,*)' use_filtre_fft = ', use_filtre_fft
      write(lunout,*)' use_mpi_alloc = ', use_mpi_alloc
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/dynetat0_loc.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/dynetat0_loc.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/dynetat0_loc.F90	(revision 4446)
@@ -7,9 +7,9 @@
 !-------------------------------------------------------------------------------
   USE parallel_lmdz
-  USE infotrac,    ONLY: nqtot, tracers, niso, iqiso, iso_indnum, iso_num, tnat, alpha_ideal, iH2O
-  USE strings_mod, ONLY: maxlen, msg, strStack, real2str
+  USE infotrac,    ONLY: nqtot, tracers, niso, iqIsoPha, iH2O, isoName
+  USE strings_mod, ONLY: maxlen, msg, strStack, real2str, int2str, strIdx
   USE netcdf,      ONLY: NF90_OPEN,  NF90_NOWRITE, NF90_INQUIRE_DIMENSION, NF90_INQ_VARID, &
                          NF90_CLOSE, NF90_GET_VAR, NF90_INQUIRE_VARIABLE,  NF90_NoErr
-  USE readTracFiles_mod, ONLY: new2oldName
+  USE readTracFiles_mod, ONLY: new2oldH2O, newHNO3, oldHNO3, getKey
   USE control_mod, ONLY: planet_type
   USE assert_eq_m, ONLY: assert_eq
@@ -41,9 +41,10 @@
   CHARACTER(LEN=maxlen) :: mesg, var, modname, oldVar
   INTEGER, PARAMETER :: length=100
-  INTEGER :: iq, fID, vID, idecal, ierr, iqParent, iName, iZone, iPhase
-  REAL    :: time, tab_cntrl(length)               !--- RUN PARAMS TABLE
+  INTEGER :: iq, fID, vID, idecal, ierr, iqParent, iName, iZone, iPhase, ix
+  REAL    :: time, tnat, alpha_ideal, tab_cntrl(length)    !--- RUN PARAMS TABLE
   REAL,             ALLOCATABLE :: vcov_glo(:,:),masse_glo(:,:),   ps_glo(:)
   REAL,             ALLOCATABLE :: ucov_glo(:,:),    q_glo(:,:), phis_glo(:)
   REAL,             ALLOCATABLE :: teta_glo(:,:)
+  LOGICAL :: lSkip, ll
 !-------------------------------------------------------------------------------
   modname="dynetat0_loc"
@@ -151,32 +152,38 @@
 !--- Tracers
   ALLOCATE(q_glo(ip1jmp1,llm))
+  ll = .FALSE.
+#ifdef REPROBUS
+  ll = NF90_INQ_VARID(fID, 'HNO3tot', vID) /= NF90_NoErr                                 !--- DETECT OLD REPRO start.nc FILE
+#endif
   DO iq=1,nqtot
     var = tracers(iq)%name
-    oldVar = new2oldName(var)
-    !--------------------------------------------------------------------------------------------------------------------------
-    IF(NF90_INQ_VARID(fID, var, vID) == NF90_NoErr) THEN                                 !=== REGULAR CASE
+    oldVar = new2oldH2O(var)
+    lSkip = ll .AND. var == 'HNO3'                                                       !--- FORCE "HNO3_g" READING FOR "HNO3"
+#ifdef REPROBUS
+    ix = strIdx(newHNO3, var); IF(ix /= 0) oldVar = oldHNO3(ix)                          !--- REPROBUS HNO3 exceptions
+#endif
+#ifdef INCA
+    IF(var == 'O3') oldVar = 'OX'                                                        !--- DEAL WITH INCA OZONE EXCEPTION
+#endif
+    !--------------------------------------------------------------------------------------------------------------------------
+    IF(NF90_INQ_VARID(fID, var, vID) == NF90_NoErr .AND. .NOT.lSkip) THEN                !=== REGULAR CASE: AVAILABLE VARIABLE
       CALL get_var2(var,q_glo); q(ijb_u:ije_u,:,iq)=q_glo(ijb_u:ije_u,:)
     !--------------------------------------------------------------------------------------------------------------------------
-    ELSE IF(NF90_INQ_VARID(fID, oldVar, vID) == NF90_NoErr) THEN                         !=== OLD NAME
+    ELSE IF(NF90_INQ_VARID(fID, oldVar, vID) == NF90_NoErr) THEN                         !=== TRY WITH ALTERNATE NAME
       CALL msg('Tracer <'//TRIM(var)//'> is missing => initialized to <'//TRIM(oldVar)//'>', modname)
       CALL get_var2(oldVar, q_glo); q(ijb_u:ije_u,:,iq)=q_glo(ijb_u:ije_u,:)
     !--------------------------------------------------------------------------------------------------------------------------
-#ifdef INCA
-    ELSE IF(NF90_INQ_VARID(fID, 'OX',   vID) == NF90_NoErr .AND. var == 'O3') THEN       !=== INCA: OX INSTEAD OF O3
-      CALL msg('Tracer <O3> is missing => initialized to <OX>', modname)
-      CALL get_var2( 'OX' , q_glo); q(ijb_u:ije_u,:,iq)=q_glo(ijb_u:ije_u,:)
-    !--------------------------------------------------------------------------------------------------------------------------
-#endif
     ELSE IF(tracers(iq)%iso_iGroup == iH2O .AND. niso > 0) THEN                          !=== WATER ISOTOPES
-!     iName    = tracers(iq)%iso_iName  ! (next commit)
-      iName    = iso_num(iq)
+      iName    = tracers(iq)%iso_iName
       iPhase   = tracers(iq)%iso_iPhase
       iqParent = tracers(iq)%iqParent
       IF(tracers(iq)%iso_iZone == 0) THEN
+         IF(getKey('tnat', tnat, isoName(iName)) .OR. getKey('alpha', alpha_ideal, isoName(iName))) &
+            CALL abort_gcm(TRIM(modname), 'missing isotopic parameters', 1)
          CALL msg('Tracer <'//TRIM(var)//'> is missing => initialized with a simplified Rayleigh distillation law.', modname)
-         q(ijb_u:ije_u,:,iq)= q(ijb_u:ije_u,:,iqParent)*tnat(iName)*(q(ijb_u:ije_u,:,iqParent)/30.e-3)**(alpha_ideal(iName)-1.)
+         q(ijb_u:ije_u,:,iq) = q(ijb_u:ije_u,:,iqParent)*tnat*(q(ijb_u:ije_u,:,iqParent)/30.e-3)**(alpha_ideal-1.)
       ELSE
          CALL msg('Tracer <'//TRIM(var)//'> is missing => initialized to its parent isotope concentration.', modname)
-         q(ijb_u:ije_u,:,iq) = q(ijb_u:ije_u,:,iqiso(iso_indnum(iq),iPhase))
+         q(ijb_u:ije_u,:,iq) = q(ijb_u:ije_u,:,iqIsoPha(iName,iPhase))
       END IF
     !--------------------------------------------------------------------------------------------------------------------------
@@ -200,10 +207,6 @@
   CHARACTER(LEN=*), INTENT(IN) :: str1, str2
   CHARACTER(LEN=maxlen) :: s1, s2
-  IF(n1/=n2) THEN
-    s1='value of '//TRIM(str1)//' ='
-    s2=' read in starting file differs from parametrized '//TRIM(str2)//' ='
-    WRITE(mesg,'(10x,a,i4,2x,a,i4)')TRIM(ADJUSTL(s1)),n1,TRIM(ADJUSTL(s2)),n2
-    CALL ABORT_gcm(TRIM(modname),TRIM(mesg),1)
-  END IF
+  IF(n1/=n2) CALL abort_gcm(TRIM(modname), 'value of "'//TRIM(str1)//'" = '//TRIM(int2str(n1))// &
+   ' read in starting file differs from gcm value of "'//TRIM(str2)//'" = '//TRIM(int2str(n2)), 1)
 END SUBROUTINE check_dim
 
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/dynredem_loc.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/dynredem_loc.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/dynredem_loc.F90	(revision 4446)
@@ -15,6 +15,6 @@
                     NF90_64BIT_OFFSET
   USE dynredem_mod, ONLY: cre_var, put_var, err, modname, fil
-  USE comvert_mod, ONLY: ap,bp,aps,bps,presnivs,pseudoalt,pa,preff, &
-                         nivsig,nivsigs
+  USE comvert_mod,  ONLY: ap, bp, presnivs, pa, preff, nivsig, nivsigs,&
+                          aps,bps,pseudoalt
   USE comconst_mod, ONLY: cpp, daysec, dtvr, g, kappa, omeg, rad
   USE logic_mod, ONLY: fxyhypb, ysinus
@@ -37,5 +37,5 @@
 !===============================================================================
 ! Local variables:
-  INTEGER :: iq, l
+  INTEGER :: iq
   INTEGER, PARAMETER :: length=100
   REAL    :: tab_cntrl(length)                     !--- RUN PARAMETERS TABLE
@@ -45,7 +45,7 @@
   INTEGER :: indexID
   INTEGER :: rlonuID, rlonvID, rlatuID, rlatvID
-  INTEGER :: sID, sigID, nID, vID, timID
+  INTEGER :: sID, sigID, nID, timID
   INTEGER :: yyears0, jjour0, mmois0
-  REAL    :: zan0, zjulian, hours
+  REAL    :: zjulian, hours
 !===============================================================================
   modname='dynredem0'; fil=fichnom
@@ -145,5 +145,5 @@
 
 !--- Define fields saved later
-  WRITE(unites,"('days since ',i4,'-',i2.2,'-',i2.2,' 00:00:00')"),&
+  WRITE(unites,"('days since ',i4,'-',i2.2,'-',i2.2,' 00:00:00')") &
                yyears0,mmois0,jjour0
   CALL cre_var(nid,"temps","Temps de simulation",[timID],unites)
@@ -202,5 +202,5 @@
 !===============================================================================
 ! Local variables:
-  INTEGER :: l, iq, nid, vID, ierr, nid_trac, vID_trac
+  INTEGER :: iq, nid, vID, ierr, nid_trac, vID_trac
   INTEGER, SAVE :: nb=0
   INTEGER, PARAMETER :: length=100
@@ -213,5 +213,4 @@
   IF(mpi_rank==0) THEN !++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   modname='dynredem1_loc'; fil=fichnom
-  fil=fichnom
   CALL err(NF90_OPEN(fil,NF90_WRITE,nid),"open",fil)
 
@@ -244,5 +243,5 @@
 !$OMP MASTER
   fil="start_trac.nc"
-  IF(type_trac=='inca' .OR. type_trac=='inco') INQUIRE(FILE=fil,EXIST=lread_inca)
+  IF(ANY(type_trac == ['inca','inco'])) INQUIRE(FILE=fil,EXIST=lread_inca)
   IF(lread_inca) CALL err(NF90_OPEN(fil,NF90_NOWRITE,nid_trac),"open")
 !$OMP END MASTER
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/fluxstokenc_p.F
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/fluxstokenc_p.F	(revision 4446)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/fluxstokenc_p.F	(revision 4446)
@@ -0,0 +1,175 @@
+!
+! $Id: caladvtrac_p.F 1299 2010-01-20 14:27:21Z fairhead $
+!
+c
+c
+            SUBROUTINE fluxstokenc_p(pbaru,pbarv ,
+     *                   masse,  teta, phi)
+      USE parallel_lmdz 
+      USE control_mod, ONLY : iapp_tracvl,planet_type,iphysiq
+      USE caladvtrac_mod
+      USE mod_hallo
+      USE bands
+      USE times
+      USE Vampir
+      USE write_field_loc
+
+c
+      IMPLICIT NONE
+c
+c     Auteurs:   F.Hourdin , P.Le Van, F.Forget, F.Codron  
+c
+c=======================================================================
+c
+c       Shema de  Van Leer
+c
+c=======================================================================
+
+
+      include "dimensions.h"
+      include "paramet.h"
+      include "tracstoke.h"
+
+c   Arguments:
+c   ----------
+      REAL :: pbaru( ijb_u:ije_u,llm ),pbarv( ijb_v:ije_v,llm)
+      REAL :: masse(ijb_u:ije_u,llm)
+      REAL :: teta( ijb_u:ije_u,llm)
+      REAL :: phi(ijb_u:ije_u,llm)
+      
+      INTEGER,SAVE :: pasflx=0
+!$OMP THREADPRIVATE(pasflx)
+      INTEGER ::  ijb,ije,ijbu,ijbv,ijeu,ijev,j
+      INTEGER :: ij,l
+      TYPE(Request),SAVE :: Request_vanleer
+!$OMP THREADPRIVATE(Request_vanleer)
+
+
+
+      !write(*,*) 'caladvtrac 58: entree'     
+      ijbu=ij_begin
+      ijeu=ij_end
+      
+      ijbv=ij_begin-iip1
+      ijev=ij_end
+      if (pole_nord) ijbv=ij_begin
+      if (pole_sud)  ijev=ij_end-iip1
+
+      IF(pasflx.EQ.0) THEN
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)        
+      DO l=1,llm   
+          tetac(ijbu:ijeu,l)=0.
+          phic(ijbu:ijeu,l)=0.
+          pbarucc(ijbu:ijeu,l)=0.
+          pbarvcc(ijbv:ijev,l)=0.
+        ENDDO
+c$OMP END DO NOWAIT  
+      ENDIF
+
+c   accumulation des flux de masse horizontaux
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+      DO l=1,llm
+         DO ij = ijbu,ijeu
+            pbarucc(ij,l) = pbarucc(ij,l) + pbaru(ij,l)
+            tetac(ij,l) = tetac(ij,l) + teta(ij,l) 
+            phic(ij,l) = phic(ij,l) + phi(ij,l)
+
+         ENDDO
+         DO ij = ijbv,ijev
+            pbarvcc(ij,l) = pbarvcc(ij,l) + pbarv(ij,l)
+         ENDDO
+      ENDDO
+c$OMP END DO NOWAIT
+
+c   selection de la masse instantannee des mailles avant le transport.
+      IF(pasflx.EQ.0) THEN
+
+          ijb=ij_begin
+          ije=ij_end
+
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+      DO l=1,llm
+          massec(ijb:ije,l)=masse(ijb:ije,l)
+       ENDDO
+c$OMP END DO NOWAIT
+
+      ENDIF
+
+      pasflx   = pasflx+1
+
+
+c   Test pour savoir si on advecte a ce pas de temps
+
+      IF ( pasflx.EQ.(iphysiq*istphy) ) THEN
+      !write(*,*) 'caladvtrac 133'
+c$OMP MASTER
+      call suspend_timer(timer_caldyn)
+c$OMP END MASTER
+      
+      ijb=ij_begin
+      ije=ij_end
+
+
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+      DO l=1,llm
+            pbarucc(ijb:ije,l) = pbarucc(ijb:ije,l)/REAL(iphysiq*istphy)
+            tetac(ijb:ije,l) = tetac(ijb:ije,l)/REAL(iphysiq*istphy)
+            phic(ijb:ije,l) = phic(ijb:ije,l)/REAL(iphysiq*istphy)
+      ENDDO
+c$OMP ENDDO NOWAIT
+
+      if (pole_sud) ije=ij_end-iip1
+
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+      DO l=1,llm
+            pbarvcc(ijb:ije,l) = pbarvcc(ijb:ije,l)/REAL(iphysiq*istphy)
+      ENDDO
+c$OMP ENDDO NOWAIT
+
+
+c$OMP BARRIER
+        call Register_Hallo_u(pbarucc,llm,1,1,1,1,Request_vanleer)
+        call Register_Hallo_v(pbarvcc,llm,1,1,1,1,Request_vanleer)
+        call SendRequest(Request_vanleer)
+c$OMP BARRIER
+        call WaitRequest(Request_vanleer)
+c$OMP BARRIER
+
+
+
+      
+cc   ..  Modif P.Le Van  ( 20/12/97 )  ....
+cc
+
+c   traitement des flux de masse avant advection.
+c     1. calcul de w
+c     2. groupement des mailles pres du pole.
+
+        CALL groupe_loc( massec, pbarucc,pbarvcc, pbarugg,pbarvgg,wgg )
+
+
+
+         ijb=ij_begin
+         ije=ij_end
+
+c$OMP BARRIER
+         CALL WriteField_u('pbarug',pbarugg)
+         CALL WriteField_v('pbarvg',pbarvgg)
+         CALL WriteField_u('wg',wgg)
+         CALL WriteField_u('tetag',tetac)
+         CALL WriteField_u('phig',phic)
+         CALL WriteField_u('masseg',massec)
+
+
+c$OMP MASTER
+        call Set_Distrib(distrib_caldyn)
+        call VTe(VThallo)
+        call resume_timer(timer_caldyn)
+c$OMP END MASTER
+
+
+c$OMP BARRIER
+          pasflx=0
+       ENDIF ! if iadvtr.EQ.iapp_tracvl
+
+      END
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/gcm.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/gcm.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/gcm.F90	(revision 4446)
@@ -1,3 +1,5 @@
-! $Id: $
+!
+! $Id$
+!
 
 PROGRAM gcm
@@ -9,5 +11,5 @@
   USE mod_const_mpi, ONLY: init_const_mpi
   USE parallel_lmdz
-  USE infotrac, ONLY: nqtot, infotrac_init
+  USE infotrac, ONLY: nqtot, init_infotrac
 !#ifdef CPP_PHYS
 !  USE mod_interface_dyn_phys, ONLY: init_interface_dyn_phys
@@ -26,4 +28,7 @@
                        itau_dyn,itau_phy,day_ini,jD_ref,jH_ref,day_end, &
                        dt,hour_ini,itaufin
+#ifdef CPP_XIOS
+  USE mod_xios_dyn3dmem, ONLY: xios_dyn3dmem_init
+#endif
 
   IMPLICIT NONE
@@ -109,4 +114,9 @@
   INTEGER :: an, mois, jour
   REAL :: heure
+  ! needed for xios interface
+  character (len=10) :: xios_cal_type
+  INTEGER :: anref, moisref, jourref
+  REAL :: heureref
+  
 
 
@@ -172,12 +182,15 @@
 #ifdef CPP_IOIPSL
   if (calend == 'earth_360d') then
-     call ioconf_calendar('360d')
+     call ioconf_calendar('360_day')
      write(lunout,*)'CALENDRIER CHOISI: Terrestre a 360 jours/an'
+     xios_cal_type='d360'
   else if (calend == 'earth_365d') then
      call ioconf_calendar('noleap')
      write(lunout,*)'CALENDRIER CHOISI: Terrestre a 365 jours/an'
+     xios_cal_type='noleap'
   else if (calend == 'gregorian') then
      call ioconf_calendar('gregorian')
      write(lunout,*)'CALENDRIER CHOISI: Terrestre bissextile'
+     xios_cal_type='gregorian'
   else
      abort_message = 'Mauvais choix de calendrier'
@@ -192,5 +205,5 @@
   !  Choix du nombre de traceurs et du schema pour l'advection
   !  dans fichier traceur.def, par default ou via INCA
-  call infotrac_init
+  call init_infotrac
 
   ! Allocation de la tableau q : champs advectes   
@@ -331,7 +344,7 @@
   write(lunout,*)'annee_ref, mois, day_ref, heure, jD_ref'
   write(lunout,*)annee_ref, mois, day_ref, heure, jD_ref
-  call ju2ymds(jD_ref+jH_ref,an, mois, jour, heure)
+  call ju2ymds(jD_ref+jH_ref,anref, moisref, jourref, heureref)
   write(lunout,*)'jD_ref+jH_ref,an, mois, jour, heure'
-  write(lunout,*)jD_ref+jH_ref,an, mois, jour, heure
+  write(lunout,*)jD_ref+jH_ref,anref, moisref, jourref, heureref
 #else
   ! Ehouarn: we still need to define JD_ref and JH_ref
@@ -395,4 +408,11 @@
   !   Initialisation de la physique :
   !   -------------------------------
+
+  !  Choix des frequences de stokage pour le offline
+  !      istdyn=day_step/4     ! stockage toutes les 6h=1jour/4
+  !      istdyn=day_step/12     ! stockage toutes les 2h=1jour/12
+  istdyn=day_step/8     ! stockage toutes les 6h=1jour/12
+  istphy=istdyn/iphysiq
+
   IF ((iflag_phys==1).or.(iflag_phys>=100)) THEN
      ! Physics:
@@ -414,4 +434,5 @@
   ecripar = .TRUE.
 
+#define CPP_IOIPSL
 #ifdef CPP_IOIPSL
   time_step = zdtvr
@@ -433,13 +454,15 @@
   dtav = iperiod*dtvr/daysec
 #endif
+#undef CPP_IOIPSL
+
+! setting up DYN3D/XIOS inerface
+#ifdef CPP_XIOS
+   if (ok_dyn_xios) then
+     CALL xios_dyn3dmem_init(xios_cal_type, anref, moisref, jourref,heureref, an,   &
+          mois, jour, heure, zdtvr)
+  endif
+#endif
+
   ! #endif of #ifdef CPP_IOIPSL
-
-  !  Choix des frequences de stokage pour le offline
-  !      istdyn=day_step/4     ! stockage toutes les 6h=1jour/4
-  !      istdyn=day_step/12     ! stockage toutes les 2h=1jour/12
-  istdyn=day_step/4     ! stockage toutes les 6h=1jour/12
-  istphy=istdyn/iphysiq     
-
-
   !
   !-----------------------------------------------------------------------
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/guide_loc_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/guide_loc_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/guide_loc_mod.F90	(revision 4446)
@@ -40,4 +40,6 @@
   REAL, PRIVATE, SAVE     :: lon_min_g,lon_max_g
   REAL, PRIVATE, SAVE     :: tau_lon,tau_lat
+
+  REAL, PRIVATE, SAVE     :: plim_guide_BL
 
   REAL, ALLOCATABLE, DIMENSION(:), PRIVATE, SAVE     :: alpha_u,alpha_v 
@@ -118,5 +120,6 @@
     CALL getpar('gamma4',.false.,gamma4,'Zone sans rappel elargie')
     CALL getpar('guide_BL',.true.,guide_BL,'guidage dans C.Lim')
-    
+    CALL getpar('plim_guide_BL',85000.,plim_guide_BL,'BL top presnivs value')
+
 ! Sauvegarde du for�age
     CALL getpar('guide_sav',.false.,guide_sav,'sauvegarde guidage')
@@ -453,5 +456,5 @@
         else
             do l=1,llm
-                alpha_pcor(l)=(1.+tanh((0.85-presnivs(l)/preff)/0.05))/2.
+                alpha_pcor(l)=(1.+tanh(((plim_guide_BL-presnivs(l))/preff)/0.05))/2.
             enddo
         endif
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/iniacademic_loc.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/iniacademic_loc.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/iniacademic_loc.F90	(revision 4446)
@@ -5,6 +5,5 @@
 
   USE filtreg_mod, ONLY: inifilr
-  USE infotrac,    ONLY: nqtot, niso, niso_possibles, ok_iso_verif, tnat, alpha_ideal, &
-                         iqiso, tracers, iso_indnum, iso_num
+  USE infotrac,    ONLY: nqtot, niso, iqIsoPha, tracers, getKey, isoName
   USE control_mod, ONLY: day_step,planet_type
   use exner_hyb_m, only: exner_hyb
@@ -20,8 +19,11 @@
   USE comconst_mod, ONLY: cpp, kappa, g, daysec, dtvr, pi, im, jm
   USE logic_mod, ONLY: iflag_phys, read_start
-  USE comvert_mod, ONLY: ap, bp, preff, presnivs, pressure_exner
+  USE comvert_mod, ONLY: ap, bp, preff, pa, presnivs, pressure_exner
   USE temps_mod, ONLY: annee_ref, day_ini, day_ref
   USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
   USE readTracFiles_mod, ONLY: addPhase
+  use netcdf, only : NF90_NOWRITE,NF90_OPEN,NF90_NOERR,NF90_INQ_VARID
+  use netcdf, only : NF90_CLOSE, NF90_GET_VAR
+
 
   !   Author:    Frederic Hourdin      original: 15/01/93
@@ -69,4 +71,8 @@
   INTEGER i,j,l,lsup,ij, iq, iName, iPhase, iqParent
 
+  integer :: nid_relief,varid,ierr
+  real, dimension(iip1,jjp1) :: relief
+
+
   REAL teta0,ttp,delt_y,delt_z,eps ! Constantes pour profil de T
   REAL k_f,k_c_a,k_c_s         ! Constantes de rappel
@@ -78,5 +84,5 @@
   integer idum
 
-  REAL zdtvr
+  REAL zdtvr, tnat, alpha_ideal
   
   character(len=*),parameter :: modname="iniacademic"
@@ -127,4 +133,5 @@
     ! allocate global fields:
 !    allocate(vcov_glo(ip1jm,llm))
+
     allocate(ucov_glo(ip1jmp1,llm))
     allocate(teta_glo(ip1jmp1,llm))
@@ -134,16 +141,41 @@
 
      ! surface pressure
-     if (iflag_phys>2) then
-        ! specific value for CMIP5 aqua/terra planets
-        ! "Specify the initial dry mass to be equivalent to
-        !  a global mean surface pressure (101325 minus 245) Pa."
-        ps_glo(:)=101080.  
-     else
-        ! use reference surface pressure
-        ps_glo(:)=preff
+     ps_glo(:)=preff
+
+     !------------------------------------------------------------------
+     ! Lecture eventuelle d'un fichier de relief interpollee sur la grille
+     ! du modele.
+     ! On suppose que le fichier relief_in.nc est stoké sur une grille
+     ! iim*jjp1
+     ! Facile a créer à partir de la commande
+     ! cdo remapcon,fichier_output_phys.nc Relief.nc relief_in.nc
+     !------------------------------------------------------------------
+
+     relief=0.
+     ierr = NF90_OPEN ('relief_in.nc', NF90_NOWRITE,nid_relief)
+     if (ierr.EQ.NF90_NOERR) THEN
+         ierr=NF90_INQ_VARID(nid_relief,'RELIEF',varid)
+         if (ierr==NF90_NOERR) THEN
+              ierr=NF90_GET_VAR(nid_relief,varid,relief(1:iim,1:jjp1))
+              relief(iip1,:)=relief(1,:)
+         else
+              CALL abort_gcm ('iniacademic','variable RELIEF pas la',1)
+         endif
      endif
-
-     ! ground geopotential
-     phis_glo(:)=0.
+     ierr = NF90_CLOSE (nid_relief)
+
+
+     !------------------------------------------------------------------
+     ! Initialisation du geopotentiel au sol et de la pression
+     !------------------------------------------------------------------
+
+     print*,'relief=',minval(relief),maxval(relief),'g=',g
+     do j=1,jjp1
+        do i=1,iip1
+           phis_glo((j-1)*iip1+i)=g*relief(i,j)
+        enddo
+     enddo
+     print*,'phis=',minval(phis),maxval(phis),'g=',g
+
      CALL pression ( ip1jmp1, ap, bp, ps_glo, p       )
      if (pressure_exner) then
@@ -286,14 +318,14 @@
               ! CRisi: init des isotopes
               ! distill de Rayleigh très simplifiée
-!             iName    = tracers(iq)%iso_iName  ! (next commit)
-              iName    = iso_num(iq)
+              iName    = tracers(iq)%iso_iName
               if (niso <= 0 .OR. iName <= 0) CYCLE
               iPhase   = tracers(iq)%iso_iPhase
               iqParent = tracers(iq)%iqParent
               IF(tracers(iq)%iso_iZone == 0) THEN
-                 q(ijb_u:ije_u,:,iq) = q(ijb_u:ije_u,:,iqParent)*tnat(iName) &
-                                     *(q(ijb_u:ije_u,:,iqParent)/30.e-3)**(alpha_ideal(iName)-1.)
+                 IF(getKey('tnat', tnat, isoName(iName)) .OR. getKey('alpha', alpha_ideal, isoName(iName))) &
+                    CALL abort_gcm(TRIM(modname), 'missing isotopic parameters', 1)
+                 q(ijb_u:ije_u,:,iq) = q(ijb_u:ije_u,:,iqParent)*tnat*(q(ijb_u:ije_u,:,iqParent)/30.e-3)**(alpha_ideal-1.)
               ELSE
-                 q(ijb_u:ije_u,:,iq) = q(ijb_u:ije_u,:,iqiso(iso_indnum(iq),iPhase))
+                 q(ijb_u:ije_u,:,iq) = q(ijb_u:ije_u,:,iqIsoPha(iName,iPhase))
               END IF
            enddo
@@ -302,5 +334,5 @@
         endif ! of if (planet_type=="earth")
 
-        if (ok_iso_verif) call check_isotopes(q,ijb_u,ije_u,'iniacademic_loc')
+        call check_isotopes(q,ijb_u,ije_u,'iniacademic_loc')
 
         ! add random perturbation to temperature
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/integrd_loc.F
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/integrd_loc.F	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/integrd_loc.F	(revision 4446)
@@ -11,5 +11,4 @@
       USE write_field
       USE integrd_mod
-      USE infotrac, ONLY: ok_iso_verif ! ajout CRisi
       USE comconst_mod, ONLY: pi
       USE logic_mod, ONLY: leapf
@@ -347,7 +346,5 @@
 c$OMP BARRIER
 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb,ije,'integrd 342')
-        endif !if (ok_iso_verif) then
+        call check_isotopes(q,ijb,ije,'integrd 342')
 
         !write(*,*) 'integrd 341'
@@ -355,7 +352,5 @@
         !write(*,*) 'integrd 343'
 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb,ije,'integrd 346')
-        endif !if (ok_iso_verif) then
+        call check_isotopes(q,ijb,ije,'integrd 346')
 c
 c    .....  Calcul de la valeur moyenne, unique  aux poles pour  q .....
@@ -408,7 +403,5 @@
       ENDIF
 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb,ije,'integrd 409')
-        endif !if (ok_iso_verif) then
+      call check_isotopes(q,ijb,ije,'integrd 409')
       
 ! Ehouarn: forget about finvmaold
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/leapfrog_loc.F
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/leapfrog_loc.F	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/leapfrog_loc.F	(revision 4446)
@@ -42,4 +42,7 @@
        USE temps_mod, ONLY: itaufin,jD_ref,jH_ref,day_ini,
      &                        day_ref,start_time,dt
+#ifdef CPP_XIOS
+       USE xios, ONLY: xios_update_calendar 
+#endif
        
       IMPLICIT NONE
@@ -204,7 +207,5 @@
       TYPE(distrib),SAVE :: new_dist
 
-      if (ok_iso_verif) then
-         call check_isotopes(q0,ijb_u,ije_u,'leapfrog204: debut')
-      endif !if (ok_iso_verif) then
+      call check_isotopes(q0,ijb_u,ije_u,'leapfrog204: debut')
       
 c$OMP MASTER
@@ -226,7 +227,5 @@
       itaufinp1 = itaufin +1
 
-      if (ok_iso_verif) then
-        call check_isotopes(q0,ijb_u,ije_u,'leapfrog 226')
-      endif !if (ok_iso_verif) then
+      call check_isotopes(q0,ijb_u,ije_u,'leapfrog 226')
 
       itau = 0
@@ -243,7 +242,5 @@
       q=q0
 
-      if (ok_iso_verif) then
-        call check_isotopes(q,ijb_u,ije_u,'leapfrog 239')
-      endif !if (ok_iso_verif) then
+      call check_isotopes(q,ijb_u,ije_u,'leapfrog 239')
       
 !      iday = day_ini+itau/day_step
@@ -324,7 +321,5 @@
       endif
 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'leapfrog 321')
-        endif !if (ok_iso_verif) then
+      call check_isotopes(q,ijb_u,ije_u,'leapfrog 321')
 
 #ifdef CPP_IOIPSL
@@ -406,14 +401,10 @@
 
 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'leapfrog 400')
-        endif !if (ok_iso_verif) then
+         call check_isotopes(q,ijb_u,ije_u,'leapfrog 400')
 
    2  CONTINUE ! Matsuno backward or leapfrog step begins here
 
 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'leapfrog 402')
-        endif !if (ok_iso_verif) then
+      call check_isotopes(q,ijb_u,ije_u,'leapfrog 402')
 
 c$OMP MASTER
@@ -497,7 +488,5 @@
 
 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'leapfrog 471')
-        endif !if (ok_iso_verif) then
+      call check_isotopes(q,ijb_u,ije_u,'leapfrog 471')
 
 !ym  PAS D'AJUSTEMENT POUR LE MOMENT     
@@ -619,7 +608,5 @@
      
       
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'leapfrog 589')
-        endif !if (ok_iso_verif) then
+      call check_isotopes(q,ijb_u,ije_u,'leapfrog 589')
       
 c-----------------------------------------------------------------------
@@ -684,7 +671,5 @@
       CALL geopot_loc  ( ip1jmp1, teta  , pk , pks,  phis  , phi   )
         
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'leapfrog 651')
-        endif !if (ok_iso_verif) then
+      call check_isotopes(q,ijb_u,ije_u,'leapfrog 651')
       
       call VTb(VTcaldyn)
@@ -725,8 +710,6 @@
 c   -------------------------------------------------------------
 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,
+      call check_isotopes(q,ijb_u,ije_u,
      &           'leapfrog 686: avant caladvtrac')
-        endif !if (ok_iso_verif) then
       
       IF( forward. OR . leapf )  THEN
@@ -737,9 +720,12 @@
      .        flxw,pk, iapptrac)
 
+! call creation of mass flux 
+         IF (offline .AND. .NOT. adjust) THEN
+            CALL fluxstokenc_p(pbaru,pbarv,masse,teta,phi)
+         ENDIF
+
          !write(*,*) 'leapfrog 719'
-         if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,
+         call check_isotopes(q,ijb_u,ije_u,
      &           'leapfrog 698: apres caladvtrac')
-         endif !if (ok_iso_verif) then
 
 !      do j=1,nqtot
@@ -775,7 +761,5 @@
 
        !write(*,*) 'leapfrog 720' 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'leapfrog 756')
-        endif !if (ok_iso_verif) then
+       call check_isotopes(q,ijb_u,ije_u,'leapfrog 756')
 
        ! CRisi: pourquoi aller jusqu'à 2 et non pas jusqu'à nqtot?? 
@@ -785,7 +769,5 @@
 
        !write(*,*) 'leapfrog 724'       
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'leapfrog 762')
-        endif !if (ok_iso_verif) then 
+       call check_isotopes(q,ijb_u,ije_u,'leapfrog 762')
  
 !       CALL FTRACE_REGION_END("integrd")
@@ -802,7 +784,5 @@
 #endif    
 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'leapfrog 775')
-        endif !if (ok_iso_verif) then
+      call check_isotopes(q,ijb_u,ije_u,'leapfrog 775')
 
 c      do j=1,nqtot
@@ -1164,7 +1144,5 @@
        ENDIF ! of IF( apphys )
 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'leapfrog 1132')
-        endif !if (ok_iso_verif) then
+       call check_isotopes(q,ijb_u,ije_u,'leapfrog 1132')
         !write(*,*) 'leapfrog 1134: iflag_phys=',iflag_phys
 
@@ -1233,7 +1211,5 @@
 
 cc$OMP END PARALLEL
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'leapfrog 1196')
-        endif !if (ok_iso_verif) then
+        call check_isotopes(q,ijb_u,ije_u,'leapfrog 1196')
 
 c-----------------------------------------------------------------------
@@ -1470,7 +1446,5 @@
 c              ENDIF
 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'leapfrog 1430')
-        endif !if (ok_iso_verif) then     
+       call check_isotopes(q,ijb_u,ije_u,'leapfrog 1430')
  
 c   ********************************************************************
@@ -1545,12 +1519,8 @@
 
 #ifdef INCA
-         if (type_trac == 'inca' .OR. type_trac == 'inco') then 
-            call finalize_inca
-         endif
+         if (ANY(type_trac == ['inca','inco'])) CALL finalize_inca
 #endif
 #ifdef REPROBUS
-         if (type_trac == 'repr') then
-         call finalize_reprobus
-         endif
+         if (type_trac == 'repr') CALL finalize_reprobus
 #endif
 
@@ -1562,7 +1532,5 @@
       ENDIF
       
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'leapfrog 1509')
-        endif !if (ok_iso_verif) then
+      call check_isotopes(q,ijb_u,ije_u,'leapfrog 1509')
 
       IF ( .NOT.purmats ) THEN
@@ -1600,12 +1568,8 @@
 
 #ifdef INCA
-              if (type_trac == 'inca' .OR. type_trac == 'inco') then 
-                 call finalize_inca
-              endif
+              if (ANY(type_trac == ['inca','inco'])) CALL finalize_inca
 #endif
 #ifdef REPROBUS
-              if (type_trac == 'repr') then
-         call finalize_reprobus
-              endif
+              if (type_trac == 'repr') CALL finalize_reprobus
 #endif
 
@@ -1649,9 +1613,9 @@
               ENDIF
 #endif
+
+
             ENDIF
 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'leapfrog 1584')
-        endif !if (ok_iso_verif) then
+            call check_isotopes(q,ijb_u,ije_u,'leapfrog 1584')
 
 c-----------------------------------------------------------------------
@@ -1675,5 +1639,19 @@
              endif
 #endif
-            endif ! of if (leapf.or.(.not.leapf.and.(.not.forward)))
+             
+#ifdef CPP_XIOS
+              IF (ok_dyn_xios) THEN
+c$OMP MASTER
+                 CALL xios_update_calendar(itau)
+c$OMP END MASTER
+c$OMP BARRIER
+                 CALL writedyn_xios(vcov,
+     &                 ucov,teta,pk,phi,q,masse,ps,phis)
+              ENDIF
+#endif
+              
+          endif                 ! of if (leapf.or.(.not.leapf.and.(.not.forward)))
+
+
            ENDIF ! of IF(MOD(itau,iecri).EQ.0)
 
@@ -1696,7 +1674,5 @@
             ENDIF ! of IF (itau.EQ.itaufin)
 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'leapfrog 1624')
-        endif !if (ok_iso_verif) then
+            call check_isotopes(q,ijb_u,ije_u,'leapfrog 1624')
 
 c-----------------------------------------------------------------------
@@ -1736,7 +1712,5 @@
 
 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'leapfrog 1664')
-        endif !if (ok_iso_verif) then
+        call check_isotopes(q,ijb_u,ije_u,'leapfrog 1664')
 
 c       ........................................................
@@ -1761,12 +1735,8 @@
 
 #ifdef INCA
-                 if (type_trac == 'inca' .OR. type_trac == 'inco') then 
-                    call finalize_inca
-                 endif
+              if (ANY(type_trac == ['inca','inco'])) CALL finalize_inca
 #endif
 #ifdef REPROBUS
-                 if (type_trac == 'repr') then
-         call finalize_reprobus
-                 endif
+                 if (type_trac == 'repr') CALL finalize_reprobus
 #endif
 
@@ -1783,7 +1753,5 @@
 
               
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'leapfrog 1698')
-        endif !if (ok_iso_verif) then  
+              call check_isotopes(q,ijb_u,ije_u,'leapfrog 1698')
 
               IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin) THEN
@@ -1812,4 +1780,6 @@
                ENDIF
 #endif
+               
+
               ENDIF ! of IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin)
 
@@ -1830,5 +1800,17 @@
               endif ! of if (ok_dyn_ins)
 #endif
-              ENDIF ! of IF(MOD(itau,iecri).EQ.0)
+
+#ifdef CPP_XIOS
+              IF (ok_dyn_xios) THEN
+c$OMP MASTER
+                 CALL xios_update_calendar(itau)
+c$OMP END MASTER
+c$OMP BARRIER
+                 CALL writedyn_xios(vcov,
+     &                 ucov,teta,pk,phi,q,masse,ps,phis)
+              ENDIF
+#endif
+              
+           ENDIF                ! of IF(MOD(itau,iecri).EQ.0)
               
 
@@ -1852,7 +1834,5 @@
 
 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'leapfrog 1750')
-        endif !if (ok_iso_verif) then
+            call check_isotopes(q,ijb_u,ije_u,'leapfrog 1750')
 
       END IF ! of IF(.not.purmats)
@@ -1862,12 +1842,8 @@
 
 #ifdef INCA
-      if (type_trac == 'inca' .OR. type_trac == 'inco') then 
-         call finalize_inca
-      endif
+      if (ANY(type_trac == ['inca','inco'])) CALL finalize_inca
 #endif
 #ifdef REPROBUS
-      if (type_trac == 'repr') then
-         call finalize_reprobus
-      endif
+      if (type_trac == 'repr') CALL finalize_reprobus
 #endif
 
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/mod_const_mpi.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/mod_const_mpi.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/mod_const_mpi.F90	(revision 4446)
@@ -88,4 +88,5 @@
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 #ifdef CPP_XIOS
+      WRITE(*,*)'IN Init_mpi call wxios_init'
       CALL wxios_init("LMDZ", outcom=COMM_LMDZ)
 #endif
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/mod_xios_dyn3dmem.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/mod_xios_dyn3dmem.F90	(revision 4446)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/mod_xios_dyn3dmem.F90	(revision 4446)
@@ -0,0 +1,262 @@
+!
+! $Id$
+!
+! This module contains the interface between the LMDZ dynamics dyn3dmem module and XIOS.
+! 
+! Lists of subroutines
+!      xios_dyn3dmem_init : context / calendar / domain / axis initialisations
+!
+! Initialisation of communicator between LMDZ and XIOS is done elsewhere: wxios_init called by init_const_mpi 
+!                                                                         (one of the first calls in gcm.F90)
+! L. Fairhead 11/2017
+!
+!
+#ifdef CPP_XIOS
+
+MODULE mod_xios_dyn3dmem
+
+     USE xios
+     USE wxios, ONLY : g_comm
+     CHARACTER(len=100), SAVE :: dyn3d_ctx_name = "LMDZDYN"
+     TYPE(xios_context), SAVE :: dyn3d_ctx_handle
+!$OMP THREADPRIVATE(dyn3d_ctx_name, dyn3d_ctx_handle)
+ 
+  INTERFACE writefield_dyn_u
+     MODULE PROCEDURE writefield_dyn1d_u, writefield_dyn2d_u
+  END INTERFACE writefield_dyn_u
+
+  INTERFACE writefield_dyn_v
+     MODULE PROCEDURE writefield_dyn1d_v, writefield_dyn2d_v
+  END INTERFACE writefield_dyn_v
+
+     REAL, ALLOCATABLE, SAVE :: NewField_U(:,:,:), NewField_V(:,:,:)
+  
+
+   CONTAINS
+
+   SUBROUTINE xios_dyn3dmem_init(xios_cal_type, anref, moisref, jourref,heureref, an, mois, jour, heure, zdtvr)
+
+
+     USE comvert_mod, ONLY: presnivs
+     USE parallel_lmdz
+
+     IMPLICIT NONE
+
+     INCLUDE 'dimensions.h'
+     INCLUDE "paramet.h"
+     INCLUDE 'comgeom.h'
+
+     TYPE(xios_duration) :: tstep_xios
+     TYPE(xios_date)                :: start_date
+     TYPE(xios_date)                :: time_origin
+     INTEGER :: an, mois, jour
+     REAL :: heure
+     CHARACTER (len=10) :: xios_cal_type
+     INTEGER :: anref, moisref, jourref
+     REAL :: heureref
+     REAL :: zdtvr
+     TYPE(xios_domain) :: dom_grid_U, dom_grid_V, dom_grid_T
+     REAL :: rlong(iip1), rlat(jjp1)
+     REAL :: pi
+     INTEGER :: ii, jj, jjb, jje, jjn
+
+!      WRITE(*,*)'Entree mod_xios_dyn3dmem'
+
+! 0 Initialisations
+     pi = 4. * ATAN (1.)
+! allocation of fields passed to xios
+!$OMP BARRIER
+!$OMP MASTER
+     allocate(NewField_U(iip1, jj_begin:jj_end, llm))
+     allocate(NewField_V(iip1, jj_begin:jj_end, llm))     
+!$OMP END MASTER
+!$OMP BARRIER
+
+! 1 Context initialisation
+!$OMP MASTER
+     CALL xios_context_initialize(dyn3d_ctx_name, g_comm)
+     CALL xios_get_handle(dyn3d_ctx_name, dyn3d_ctx_handle)
+     CALL xios_set_current_context(dyn3d_ctx_handle)  
+
+!     WRITE(*,*)'apres context initialisation mod_xios_dyn3dmem'
+
+! 2 calendar stuff
+
+     tstep_xios%second=zdtvr
+     CALL xios_define_calendar(type=xios_cal_type, start_date=xios_date(an, mois, jour,INT(heure),0,0), &
+            time_origin=xios_date(anref,moisref,jourref,INT(heureref),0,0), timestep=tstep_xios)
+
+!     WRITE(*,*)'apres  calendrier mod_xios_dyn3dmem'
+
+! 3 domain / grids / axis
+! Domains:
+      rlong(:) = rlonu(:) * 180. / pi
+      rlat(:) = rlatu(:) * 180. / pi
+
+      CALL xios_set_domain_attr("domain_U", ni_glo=iip1, nj_glo=jjp1,          &
+          type="rectilinear",ibegin=0, ni=iip1, jbegin=jj_begin-1, nj=jj_nb,   &
+          data_dim = 2, lonvalue_1d=rlong(1:iip1), latvalue_1d=rlat(jj_begin:jj_end))
+
+      jjb=jj_begin
+      jje=jj_end
+      jjn=jj_nb
+      IF (pole_sud) jjn=jjn-1
+      IF (pole_sud) jje=jje-1
+
+
+      rlong(:) = rlonv(:) * 180. / pi
+      do jj = jjb, jje
+        rlat(jj) = rlatv(jj) * 180. / pi
+      enddo
+      
+      CALL xios_set_domain_attr("domain_V", ni_glo=iip1, nj_glo=jjm,            &
+          type="rectilinear",ibegin=0, ni=iip1, jbegin=jj_begin-1, nj=jjn,   &
+          data_dim = 2, lonvalue_1d=rlong(1:iip1), latvalue_1d=rlat(jjb:jje))
+
+
+      rlong(:) = rlonv(:) * 180. / pi
+      rlat(:) = rlatu(:) * 180. / pi 
+      CALL xios_set_domain_attr("domain_T", ni_glo=iip1, nj_glo=jjp1,          &
+          type="rectilinear",ibegin=0, ni=iip1, jbegin=jj_begin-1, nj=jj_nb,   &
+          data_dim = 2, lonvalue_1d=rlong(1:iip1), latvalue_1d=rlat(jj_begin:jj_end))
+      
+!     WRITE(*,*)'apres  domaine mod_xios_dyn3dmem'
+! Vertical axis
+       CALL xios_set_axis_attr("presnivs",n_glo=llm,value=presnivs)
+!     WRITE(*,*)'apres  vertical axis mod_xios_dyn3dmem'
+! 4 end of context definition
+       CALL xios_close_context_definition()
+!     WRITE(*,*)'apres close context init. axis mod_xios_dyn3dmem'
+!$OMP END MASTER
+   END SUBROUTINE xios_dyn3dmem_init
+
+   SUBROUTINE  writefield_dyn1d_u(name,Field)
+
+     USE parallel_lmdz
+     IMPLICIT NONE
+     include 'dimensions.h'
+     include 'paramet.h'
+     CHARACTER(LEN=*)   :: name
+     REAL, DIMENSION(ij_begin:ij_end) :: Field
+     REAL, DIMENSION(iip1,  jj_begin:jj_end) :: NewField
+      LOGICAL,SAVE :: debuglf=.true.
+!$OMP THREADPRIVATE(debuglf)
+     
+     NewField(:,jj_begin:jj_end)=reshape(Field(ij_begin:ij_end),(/iip1,jj_nb/))
+
+!$OMP BARRIER       
+!$OMP MASTER
+     CALL xios_send_field(name, NewField)
+!$OMP END MASTER   
+  
+   END SUBROUTINE  writefield_dyn1d_u
+
+   SUBROUTINE  writefield_dyn2d_u(name,Field)
+
+     USE parallel_lmdz
+     IMPLICIT NONE
+     include 'dimensions.h'
+     include 'paramet.h'
+     CHARACTER(LEN=*)   :: name
+     REAL, DIMENSION(ij_begin:ij_end,llm) :: Field
+!     REAL, ALLOCATABLE, SAVE :: NewField(:,:,:)
+     INTEGER :: i,j,l, count
+
+!!!!!$OMP BARRIER
+!!!!!$OMP MASTER
+!!!!     allocate(NewField(iip1, jj_begin:jj_end, llm))
+!!!!!$OMP END MASTER
+!!!!!$OMP BARRIER
+
+
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK) 
+     DO l = 1, llm
+       NewField_U(:,jj_begin:jj_end,l)=reshape(Field(ij_begin:ij_end,l),(/iip1,jj_nb/))
+     ENDDO
+!$OMP ENDDO
+!$OMP BARRIER 
+
+!$OMP MASTER
+     CALL xios_send_field(name, NewField_U)
+!!!!     DEALLOCATE(NewField)
+!$OMP END MASTER   
+!$OMP BARRIER
+  
+   END SUBROUTINE  writefield_dyn2d_u
+
+   SUBROUTINE  writefield_dyn1d_v(name,Field)
+
+     USE parallel_lmdz
+     IMPLICIT NONE
+     include 'dimensions.h'
+     include 'paramet.h'
+     CHARACTER(LEN=*)   :: name
+     REAL, DIMENSION(ij_begin:ij_end) :: Field
+     REAL, DIMENSION(iip1,  jj_begin:jj_end) :: NewField
+     INTEGER ::  jje, ije, jjn
+
+     IF (pole_sud) THEN
+       jje=jj_end-1
+       ije=ij_end-iip1
+       jjn=jj_nb-1
+     ELSE
+       jje=jj_end
+       ije=ij_end
+       jjn=jj_nb
+     ENDIF
+
+     NewField(:,jj_begin:jje)=reshape(Field(ij_begin:ije),(/iip1,jjn/))
+
+!$OMP BARRIER       
+!$OMP MASTER
+     CALL xios_send_field(name, NewField(:,jj_begin:jje))
+!$OMP END MASTER   
+  
+   END SUBROUTINE  writefield_dyn1d_v
+
+   SUBROUTINE  writefield_dyn2d_v(name,Field)
+
+     USE parallel_lmdz
+     IMPLICIT NONE
+     include 'dimensions.h'
+     include 'paramet.h'
+     CHARACTER(LEN=*)   :: name
+     REAL, DIMENSION(ij_begin:ij_end,llm) :: Field
+!!!!     REAL, ALLOCATABLE, SAVE :: NewField(:,:,:)
+     INTEGER :: l, jje, ije, jjn
+
+!!!!!$OMP BARRIER
+!!!!!$OMP MASTER
+!!!!     allocate(NewField(iip1,  jj_begin:jj_end,llm))
+!!!!!$OMP END MASTER
+!!!!!$OMP BARRIER
+
+     IF (pole_sud) THEN
+       jje=jj_end-1
+       ije=ij_end-iip1
+       jjn=jj_nb-1
+     ELSE
+       jje=jj_end
+       ije=ij_end
+       jjn=jj_nb
+     ENDIF
+
+
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+     DO l = 1, llm
+        NewField_V(:,jj_begin:jje,l)=reshape(Field(ij_begin:ije,l),(/iip1,jjn/))
+     ENDDO
+!$OMP ENDDO
+!$OMP BARRIER       
+
+!$OMP MASTER
+     CALL xios_send_field(name, NewField_V(:,jj_begin:jje,:))
+!!!!     DEALLOCATE(NewField)
+!$OMP END MASTER   
+!$OMP BARRIER 
+  
+   END SUBROUTINE  writefield_dyn2d_v
+   
+END MODULE mod_xios_dyn3dmem 
+#endif
+
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/qminimum_loc.F
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/qminimum_loc.F	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/qminimum_loc.F	(revision 4446)
@@ -4,6 +4,8 @@
       SUBROUTINE qminimum_loc( q,nqtot,deltap )
       USE parallel_lmdz
-      USE infotrac, ONLY: niso,ntraciso,iqiso,ok_iso_verif,             &
-     &   ratiomin,qperemin ! CRisi 23nov2020
+      USE infotrac, ONLY: niso, ntiso, iqIsoPha, tracers, 
+     &                    isoCheck, min_qParent
+      USE strings_mod, ONLY: strIdx
+      USE readTracFiles_mod, ONLY: addPhase
       IMPLICIT none
 c
@@ -18,10 +20,9 @@
       REAL q(ijb_u:ije_u,llm,nqtot), deltap(ijb_u:ije_u,llm)
 c
-      INTEGER iq_vap, iq_liq
-      PARAMETER ( iq_vap = 1 ) ! indice pour l'eau vapeur
-      PARAMETER ( iq_liq = 2 ) ! indice pour l'eau liquide
-      REAL seuil_vap, seuil_liq
-      PARAMETER ( seuil_vap = 1.0e-10 ) ! seuil pour l'eau vapeur
-      PARAMETER ( seuil_liq = 1.0e-11 ) ! seuil pour l'eau liquide
+      LOGICAL, SAVE :: first=.TRUE.
+      INTEGER, SAVE :: iq_vap, iq_liq        ! indices pour l'eau vapeur/liquide
+c$OMP THREADPRIVATE(iq_vap, iq_liq, first)
+      REAL, PARAMETER :: seuil_vap = 1.0e-10 ! seuil pour l'eau vapeur
+      REAL, PARAMETER :: seuil_liq = 1.0e-11 ! seuil pour l'eau liquide
 c
 c  NB. ....( Il est souhaitable mais non obligatoire que les valeurs des
@@ -54,18 +55,31 @@
 c
 
-        !write(lunout,*) 'qminimum 52: entree'
-        if (ok_iso_verif) then
-           call check_isotopes(q,ij_begin,ij_end,'qminimum 52')   
-        endif !if (ok_iso_verif) then     
+c$OMP BARRIER
+
+      !write(lunout,*) 'qminimum 52: entree'
+      IF(first) THEN
+         iq_vap = strIdx(tracers(:)%name, addPhase('H2O', 'g'))
+         iq_liq = strIdx(tracers(:)%name, addPhase('H2O', 'l'))
+         first = .FALSE.
+      END IF
+      call check_isotopes(q,ij_begin,ij_end,'qminimum 52')   
 
       ijb=ij_begin
       ije=ij_end
 
-      zx_defau_diag(ijb:ije,:,:)=0.0
-      q_follow(ijb:ije,:,1:2)=q(ijb:ije,:,1:2)  
+      DO k = 1, llm
+c$OMP DO SCHEDULE(STATIC)
+        DO i = ijb, ije
+          zx_defau_diag(i,k,1)=0.0
+          zx_defau_diag(i,k,2)=0.0
+          q_follow(i,k,1)=q(i,k,1)
+          q_follow(i,k,2)=q(i,k,2)
+        ENDDO
+c$OMP END DO NOWAIT
+      ENDDO
 
       !write(lunout,*) 'qminimum 57'
-c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
       DO 1000 k = 1, llm
+c$OMP DO SCHEDULE(STATIC)       
       DO 1040 i = ijb, ije
             if (seuil_liq - q(i,k,iq_liq) .gt. 0.d0 ) then
@@ -78,9 +92,6 @@
             endif
  1040 CONTINUE
+c$OMP END DO NOWAIT
  1000 CONTINUE
-c$OMP END DO NOWAIT
-c$OMP BARRIER
-c --->  SYNCHRO OPENMP ICI
-
 
 c
@@ -109,5 +120,4 @@
 c$OMP END DO NOWAIT
       ENDDO
-c$OMP BARRIER
 
 c
@@ -126,5 +136,5 @@
          ENDIF
       ENDDO
-c$OMP END DO  
+c$OMP END DO NOWAIT 
 !      pompe = SSUM(ije-ijb+1,zx_pump(ijb),1)
 
@@ -158,5 +168,5 @@
         endif !if (zx_pump(i).gt.0.0) then
       enddo !DO i = ijb, ije  
-c$OMP END DO
+c$OMP END DO NOWAIT
 
       ! 2) transfert de vap vers les couches plus hautes
@@ -169,5 +179,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.min_qParent) then
                 write(lunout,*) 'tmp qmin: on stoppe'
                 write(lunout,*) 'zx_pump(i)=',zx_pump(i)
@@ -177,29 +187,29 @@
                 call abort_gcm("qminimum","not enough vapor",1)
               endif  
-            do ixt=1,ntraciso
+            do ixt=1,ntiso
 !                write(lunout,*) 'qmin 168: ixt=',ixt
-!                write(lunout,*) 'q(i,k,iqiso(ixt,iq_vap)=',
-!     :             q(i,k,iqiso(ixt,iq_vap))
+!                write(lunout,*) 'q(i,k,iqIsoPha(ixt,iq_vap)=',
+!     :             q(i,k,iqIsoPha(ixt,iq_vap))
 !                write(lunout,*) 'zx_defau_diag(i,k,iq_vap)=',
 !     :                  zx_defau_diag(i,k,iq_vap)
-!                write(lunout,*) 'q(i,k-1,iqiso(ixt,iq_vap)=',
-!     :                   q(i,k-1,iqiso(ixt,iq_vap))     
-
-               q(i,k,iqiso(ixt,iq_vap))=q(i,k,iqiso(ixt,iq_vap))
-     :              +zx_defau_diag(i,k,iq_vap)
-     :              *q(i,k-1,iqiso(ixt,iq_vap))/q_follow(i,k-1,iq_vap)
+!                write(lunout,*) 'q(i,k-1,iqIsoPha(ixt,iq_vap)=',
+!     :                   q(i,k-1,iqIsoPha(ixt,iq_vap))     
+
+               q(i,k,iqIsoPha(ixt,iq_vap))=q(i,k,iqIsoPha(ixt,iq_vap))
+     :           +zx_defau_diag(i,k,iq_vap)
+     :           *q(i,k-1,iqIsoPha(ixt,iq_vap))/q_follow(i,k-1,iq_vap)
                 
-              if (ok_iso_verif) then
-                if (iso_verif_noNaN_nostop(q(i,k,iqiso(ixt,iq_vap)),
+              if (isoCheck) then
+                if(iso_verif_noNaN_nostop(q(i,k,iqIsoPha(ixt,iq_vap)),
      :                   'qminimum 155').eq.1) then
                    write(*,*) 'i,k,ixt=',i,k,ixt
                    write(*,*) 'q_follow(i,k-1,iq_vap)=',
      :                   q_follow(i,k-1,iq_vap)
-                   write(*,*) 'q(i,k,iqiso(ixt,iq_vap))=',
-     :                   q(i,k,iqiso(ixt,iq_vap))
+                   write(*,*) 'q(i,k,iqIsoPha(ixt,iq_vap))=',
+     :                   q(i,k,iqIsoPha(ixt,iq_vap))
                    write(*,*) 'zx_defau_diag(i,k,iq_vap)=',
      :                   zx_defau_diag(i,k,iq_vap)
-                   write(*,*) 'q(i,k-1,iqiso(ixt,iq_vap))=',
-     :                   q(i,k-1,iqiso(ixt,iq_vap))
+                   write(*,*) 'q(i,k-1,iqIsoPha(ixt,iq_vap))=',
+     :                   q(i,k-1,iqIsoPha(ixt,iq_vap))
                    stop
                 endif
@@ -207,21 +217,24 @@
 
               ! et on la retranche en k-1
-               q(i,k-1,iqiso(ixt,iq_vap))=q(i,k-1,iqiso(ixt,iq_vap))
+               q(i,k-1,iqIsoPha(ixt,iq_vap)) =
+     :            q(i,k-1,iqIsoPha(ixt,iq_vap))
      :              -zx_defau_diag(i,k,iq_vap)
      :              *deltap(i,k)/deltap(i,k-1)
-     :              *q(i,k-1,iqiso(ixt,iq_vap))/q_follow(i,k-1,iq_vap)
-
-               if (ok_iso_verif) then
-                if (iso_verif_noNaN_nostop(q(i,k-1,iqiso(ixt,iq_vap)),
+     :              *q(i,k-1,iqIsoPha(ixt,iq_vap))
+     :              /q_follow(i,k-1,iq_vap)
+
+               if (isoCheck) then
+                if (iso_verif_noNaN_nostop(
+     :              q(i,k-1,iqIsoPha(ixt,iq_vap)),
      :                   'qminimum 175').eq.1) then
                    write(*,*) 'k,i,ixt=',k,i,ixt
                    write(*,*) 'q_follow(i,k-1,iq_vap)=',
      :                   q_follow(i,k-1,iq_vap)
-                   write(*,*) 'q(i,k,iqiso(ixt,iq_vap))=',
-     :                   q(i,k,iqiso(ixt,iq_vap))
+                   write(*,*) 'q(i,k,iqIsoPha(ixt,iq_vap))=',
+     :                   q(i,k,iqIsoPha(ixt,iq_vap))
                    write(*,*) 'zx_defau_diag(i,k,iq_vap)=',
      :                   zx_defau_diag(i,k,iq_vap)
-                   write(*,*) 'q(i,k-1,iqiso(ixt,iq_vap))=',
-     :                   q(i,k-1,iqiso(ixt,iq_vap))
+                   write(*,*) 'q(i,k-1,iqIsoPha(ixt,iq_vap))=',
+     :                   q(i,k-1,iqIsoPha(ixt,iq_vap))
                    stop
                 endif
@@ -236,10 +249,8 @@
           endif !if (zx_defau_diag(i,k,iq_vap).gt.0.0) then
         enddo !DO i = 1, ip1jmp1        
-c$OMP END DO
+c$OMP END DO NOWAIT
         enddo !do k=2,llm
 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb,ije,'qminimum 168')
-        endif !if (ok_iso_verif) then
+        call check_isotopes(q,ijb,ije,'qminimum 168')
         
       
@@ -252,12 +263,12 @@
 
               ! on ajoute eau liquide en k en k              
-              do ixt=1,ntraciso
-               q(i,k,iqiso(ixt,iq_liq))=q(i,k,iqiso(ixt,iq_liq))
+              do ixt=1,ntiso
+               q(i,k,iqIsoPha(ixt,iq_liq))=q(i,k,iqIsoPha(ixt,iq_liq))
      :              +zx_defau_diag(i,k,iq_liq)
-     :              *q(i,k,iqiso(ixt,iq_vap))/q_follow(i,k,iq_vap)
+     :              *q(i,k,iqIsoPha(ixt,iq_vap))/q_follow(i,k,iq_vap)
               ! et on la retranche à la vapeur en k
-               q(i,k,iqiso(ixt,iq_vap))=q(i,k,iqiso(ixt,iq_vap))
+               q(i,k,iqIsoPha(ixt,iq_vap))=q(i,k,iqIsoPha(ixt,iq_vap))
      :              -zx_defau_diag(i,k,iq_liq)
-     :              *q(i,k,iqiso(ixt,iq_vap))/q_follow(i,k,iq_vap)   
+     :              *q(i,k,iqIsoPha(ixt,iq_vap))/q_follow(i,k,iq_vap)   
               enddo !do ixt=1,niso
               q_follow(i,k,iq_liq)=   q_follow(i,k,iq_liq)
@@ -267,13 +278,13 @@
           endif !if (zx_defau_diag(i,k,iq_vap).gt.0.0) then
         enddo !DO i = ijb, ije
-c$OMP END DO        
+c$OMP END DO NOWAIT       
        enddo !do k=2,llm  
 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb,ije,'qminimum 197')
-        endif !if (ok_iso_verif) then
+       call check_isotopes(q,ijb,ije,'qminimum 197')
 
       endif !if (niso > 0) then
       !write(*,*) 'qminimum 188'
+c$OMP BARRIER
+
 c
       RETURN
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/vlsplt_loc.F
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/vlsplt_loc.F	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/vlsplt_loc.F	(revision 4446)
@@ -15,5 +15,5 @@
       USE parallel_lmdz
       USE infotrac, ONLY : nqtot,tracers, ! CRisi                 &
-     &                     qperemin,masseqmin,ratiomin ! MVals et CRisi
+     &                     min_qParent,min_qMass,min_ratio ! MVals et CRisi
       IMPLICIT NONE
 c
@@ -341,9 +341,9 @@
             ! 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),min_qMass)
+            if (q(ij,l,iq).gt.min_qParent) then ! modif 13 nov 2020
               Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
             else
-              Ratio(ij,l,iq2)=ratiomin
+              Ratio(ij,l,iq2)=min_ratio
             endif
           enddo   
@@ -351,5 +351,5 @@
 c$OMP END DO NOWAIT
       enddo !do ifils=1,tracers(iq)%nqDescen
-      do ifils=1,tracers(iq)%nqChilds
+      do ifils=1,tracers(iq)%nqChildren
         iq2=tracers(iq)%iqDescen(ifils)
         call vlx_loc(Ratio,pente_max,masse,u_mq,ijb_x,ije_x,iq2)
@@ -363,5 +363,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),min_qMass)
             q(ij,l,iq)=(q(ij,l,iq)*masse(ij,l,iq)+
      &        u_mq(ij-1,l)-u_mq(ij,l))
@@ -417,5 +417,5 @@
       USE parallel_lmdz
       USE infotrac, ONLY : nqtot,tracers, ! CRisi                 &
-     &                     qperemin,masseqmin,ratiomin ! MVals et CRisi    
+     &                     min_qParent,min_qMass,min_ratio ! MVals et CRisi    
       USE comconst_mod, ONLY: pi
       IMPLICIT NONE
@@ -726,5 +726,5 @@
 ! CRisi: appel récursif de l'advection sur les fils.
 ! Il faut faire ça avant d'avoir mis à jour q et masse
-      !write(*,*) 'vly 689: iq,nqChilds(iq)=',iq,tracers(iq)%nqChilds
+!     write(*,*)'vly 689: iq,nqChildren(iq)=',iq,tracers(iq)%nqChildren
 
       ijb=ij_begin-2*iip1
@@ -745,5 +745,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),min_qMass)
           enddo
 
@@ -751,8 +751,8 @@
           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.min_qParent) then ! modif 13 nov 2020
               Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
             else
-              Ratio(ij,l,iq2)=ratiomin  
+              Ratio(ij,l,iq2)=min_ratio  
             endif     
           enddo !DO ij=ijbm,ijem  
@@ -761,5 +761,5 @@
       enddo
 
-      do ifils=1,tracers(iq)%nqChilds
+      do ifils=1,tracers(iq)%nqChildren
         iq2=tracers(iq)%iqDescen(ifils)
         call vly_loc(Ratio,pente_max,masse,qbyv,iq2)
@@ -885,5 +885,5 @@
       USE vlz_mod
       USE infotrac, ONLY : nqtot,tracers, ! CRisi                 &
-     &                     qperemin,masseqmin,ratiomin ! MVals et CRisi
+     &                     min_qParent,min_qMass,min_ratio ! MVals et CRisi
       
       IMPLICIT NONE
@@ -1148,5 +1148,5 @@
 ! CRisi: appel récursif de l'advection sur les fils.
 ! Il faut faire ça avant d'avoir mis à jour q et masse
-      !write(*,*) 'vlsplt 942: iq,nqChilds(iq)=',iq,tracers(iq)%nqChilds
+!     write(*,*)'vlsplt 942: iq,nqChildren(iq)=',iq,tracers(iq)%nqChildren
       do ifils=1,tracers(iq)%nqDescen
         iq2=tracers(iq)%iqDescen(ifils)
@@ -1155,9 +1155,9 @@
           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),min_qMass)
+            if (q(ij,l,iq).gt.min_qParent) then
               Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
             else
-              Ratio(ij,l,iq2)=ratiomin
+              Ratio(ij,l,iq2)=min_ratio
             endif
             !wq(ij,l,iq2)=wq(ij,l,iq) ! correction bug le 15mai2015
@@ -1169,5 +1169,5 @@
 c$OMP BARRIER
 
-      do ifils=1,tracers(iq)%nqChilds
+      do ifils=1,tracers(iq)%nqChildren
         iq2=tracers(iq)%iqDescen(ifils)
         call vlz_loc(Ratio,pente_max,masse,w,ijb_x,ije_x,iq2)
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/vlspltgen_loc.F
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/vlspltgen_loc.F	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/vlspltgen_loc.F	(revision 4446)
@@ -28,5 +28,5 @@
       USE VAMPIR
       ! CRisi: on rajoute variables utiles d'infotrac  
-      USE infotrac, ONLY : nqtot, tracers,ok_iso_verif
+      USE infotrac, ONLY : nqtot, tracers, isoCheck
       USE vlspltgen_mod
       USE comconst_mod, ONLY: cpp
@@ -191,7 +191,5 @@
       ijb=ij_begin
       ije=ij_end  
-      if (ok_iso_verif) then
-        call check_isotopes(zq,ijb,ije,'vlspltgen_loc 191')
-      endif !if (ok_iso_verif) then   
+      call check_isotopes(zq,ijb,ije,'vlspltgen_loc 191')
 
 c$OMP BARRIER           
@@ -285,7 +283,5 @@
       if (pole_nord) ijb=ij_begin
       if (pole_sud)  ije=ij_end  
-      if (ok_iso_verif) then
-           call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 280')
-      endif !if (ok_iso_verif) then
+      call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 280')
 
       do iq=1,nqtot
@@ -328,5 +324,5 @@
 
       
-      if (ok_iso_verif) then
+      IF(isoCheck) THEN
            call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 326')
            ijb=ij_begin-2*iip1
@@ -335,5 +331,5 @@
            if (pole_sud)  ije=ij_end
            call check_isotopes(zq,ijb,ije,'vlspltgen_loc 336')
-      endif !if (ok_iso_verif) then  
+      END IF
 
       do iq = 1, nqtot
@@ -355,7 +351,5 @@
        enddo
 
-      if (ok_iso_verif) then
-           call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 357')
-      endif !if (ok_iso_verif) then
+      call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 357')
 
       do iq = 1, nqtot
@@ -416,7 +410,5 @@
 
 
-      if (ok_iso_verif) then
-           call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 429')
-      endif !if (ok_iso_verif) then 
+      call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 429')
 
 c$OMP BARRIER
@@ -461,7 +453,5 @@
 
       !write(*,*) 'vlspltgen_loc 494'
-      if (ok_iso_verif) then
-           call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 461')
-      endif !if (ok_iso_verif) then
+      call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 461')
 
       do iq=1,nqtot
@@ -481,7 +471,5 @@
        enddo !do iq=1,nqtot
 
-      if (ok_iso_verif) then
-           call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 493')
-      endif !if (ok_iso_verif) then
+      call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 493')
 
       do iq=1,nqtot
@@ -504,7 +492,5 @@
 
       !write(*,*) 'vlspltgen 550: apres derniere serie de call vlx'
-      if (ok_iso_verif) then
-           call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 521')
-      endif !if (ok_iso_verif) then
+      call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 521')
      
       ijb=ij_begin
@@ -541,7 +527,5 @@
       ENDDO !DO iq=1,nqtot
         
-      if (ok_iso_verif) then
-           call check_isotopes(q,ij_begin,ij_end,'vlspltgen_loc 557')
-      endif !if (ok_iso_verif) then
+      call check_isotopes(q,ij_begin,ij_end,'vlspltgen_loc 557')
 
 c$OMP BARRIER
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/vlspltqs_loc.F
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/vlspltqs_loc.F	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/vlspltqs_loc.F	(revision 4446)
@@ -13,5 +13,5 @@
       USE parallel_lmdz
       USE infotrac, ONLY : nqtot,tracers, ! CRisi                 &
-     &                     qperemin,masseqmin,ratiomin ! MVals et CRisi
+     &                     min_qParent,min_qMass,min_ratio ! MVals et CRisi
       IMPLICIT NONE
 c
@@ -337,6 +337,6 @@
 ! CRisi: appel recursif de l'advection sur les fils.
 ! Il faut faire ca avant d'avoir mis a jour q et masse
-      !write(*,*) 'vlspltqs 336: iq,ijb_x,nqChilds(iq)=',
-!     &     iq,ijb_x,tracers(iq)%nqChilds
+      !write(*,*) 'vlspltqs 336: iq,ijb_x,nqChildren(iq)=',
+!     &     iq,ijb_x,tracers(iq)%nqChildren
 
       do ifils=1,tracers(iq)%nqDescen
@@ -346,9 +346,9 @@
           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),min_qMass)
+            if (q(ij,l,iq).gt.min_qParent) then ! modif 13 nov 2020
               Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
             else
-              Ratio(ij,l,iq2)=ratiomin
+              Ratio(ij,l,iq2)=min_ratio
             endif 
           enddo   
@@ -356,5 +356,5 @@
 c$OMP END DO NOWAIT
       enddo
-      do ifils=1,tracers(iq)%nqChilds
+      do ifils=1,tracers(iq)%nqChildren
         iq2=tracers(iq)%iqDescen(ifils)
         !write(*,*) 'vlxqs 349: on appelle vlx pour iq2=',iq2
@@ -370,5 +370,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),min_qMass)
             q(ij,l,iq)=(q(ij,l,iq)*masse(ij,l,iq)+
      &      u_mq(ij-1,l)-u_mq(ij,l))
@@ -423,5 +423,5 @@
       USE parallel_lmdz
       USE infotrac, ONLY : nqtot,tracers, ! CRisi                 &
-     &                     qperemin,masseqmin,ratiomin ! MVals et CRisi
+     &                     min_qParent,min_qMass,min_ratio ! MVals et CRisi
       USE comconst_mod, ONLY: pi
       IMPLICIT NONE
@@ -729,5 +729,6 @@
 ! CRisi: appel recursif de l'advection sur les fils.
 ! Il faut faire ca avant d'avoir mis a jour q et masse
-      !write(*,*) 'vlyqs 689: iq,nqChilds(iq)=',iq,tracers(iq)%nqChilds
+!     write(*,*)'vlyqs 689: iq,nqChildren(iq)=',iq,
+!    &             tracers(iq)%nqChildren
       
       ijb=ij_begin-2*iip1
@@ -751,5 +752,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),min_qMass)
           enddo !DO ij=ijbm,ijem 
 
@@ -758,8 +759,8 @@
             !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.min_qParent) then ! modif 13 nov 2020
               Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
             else
-              Ratio(ij,l,iq2)=ratiomin   
+              Ratio(ij,l,iq2)=min_ratio   
             endif
           enddo !DO ij=ijbm,ijem
@@ -767,5 +768,5 @@
 c$OMP END DO NOWAIT
       enddo
-      do ifils=1,tracers(iq)%nqChilds
+      do ifils=1,tracers(iq)%nqChildren
         iq2=tracers(iq)%iqDescen(ifils)
         !write(lunout,*) 'vly: appel recursiv vly iq2=',iq2
Index: LMDZ6/branches/Portage_acc/libf/dyn3dmem/writedyn_xios.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dyn3dmem/writedyn_xios.F90	(revision 4446)
+++ LMDZ6/branches/Portage_acc/libf/dyn3dmem/writedyn_xios.F90	(revision 4446)
@@ -0,0 +1,184 @@
+
+! $Id$
+!
+      SUBROUTINE writedyn_xios( vcov, ucov,teta,ppk,phi,q, &
+     &                           masse,ps,phis)
+
+#ifdef CPP_XIOS
+      USE xios
+      USE parallel_lmdz
+      USE misc_mod
+      USE infotrac, ONLY : nqtot
+      use com_io_dyn_mod, only : histaveid,histvaveid,histuaveid
+      USE comconst_mod, ONLY: cpp
+      USE temps_mod, ONLY: itau_dyn
+      USE mod_xios_dyn3dmem, ONLY : writefield_dyn_u, writefield_dyn_v
+      
+      implicit none
+!
+!   Ecriture du fichier histoire au format xios
+!
+!
+!   Entree:
+!      vcov: vents v covariants
+!      ucov: vents u covariants
+!      teta: temperature potentielle
+!      phi : geopotentiel instantane
+!      q   : traceurs
+!      masse: masse
+!      ps   :pression au sol
+!      phis : geopotentiel au sol
+!      
+!   L. Fairhead, LMD, 03/21
+!
+! =====================================================================
+!
+!   Declarations
+      include "dimensions.h"
+      include "paramet.h"
+      include "comgeom.h"
+      include "description.h"
+      include "iniprint.h"
+
+!
+!   Arguments
+!
+
+      REAL vcov(ijb_v:ije_v,llm),ucov(ijb_u:ije_u,llm) 
+      REAL teta(ijb_u:ije_u,llm),phi(ijb_u:ije_u,llm)
+      REAL ppk(ijb_u:ije_u,llm)                  
+      REAL ps(ijb_u:ije_u),masse(ijb_u:ije_u,llm)                   
+      REAL phis(ijb_u:ije_u)                  
+      REAL q(ijb_u:ije_u,llm,nqtot)
+      integer time
+
+
+!   Variables locales
+!
+      INTEGER,SAVE,ALLOCATABLE :: ndex2d(:),ndexu(:),ndexv(:)
+      INTEGER :: iq, ii, ll
+      REAL,SAVE,ALLOCATABLE :: tm(:,:)
+      REAL,SAVE,ALLOCATABLE :: vnat(:,:),unat(:,:)
+      REAL,SAVE,ALLOCATABLE :: vbuffer(:,:)
+      logical ok_sync
+      integer itau_w
+      integer :: ijb,ije,jjn
+      LOGICAL,SAVE :: first=.TRUE.
+      LOGICAL,SAVE :: debuglf=.true.
+!$OMP THREADPRIVATE(debuglf)
+!$OMP THREADPRIVATE(first)
+
+!
+!  Initialisations
+!
+
+!      WRITE(*,*)'IN WRITEDYN_XIOS'
+      IF (first) THEN
+!$OMP BARRIER
+!$OMP MASTER
+        ALLOCATE(unat(ijb_u:ije_u,llm))
+        ALLOCATE(vnat(ijb_v:ije_v,llm))
+        IF (pole_sud) THEN
+           ALLOCATE(vbuffer(ijb_v:ije_v+iip1,llm))
+        ELSE
+           ALLOCATE(vbuffer(ijb_v:ije_v+iip1,llm))
+        ENDIF
+        ALLOCATE(tm(ijb_u:ije_u,llm))
+        ALLOCATE(ndex2d(ijnb_u*llm))
+        ALLOCATE(ndexu(ijnb_u*llm))
+        ALLOCATE(ndexv(ijnb_v*llm))
+        unat = 0.; vnat = 0.; tm = 0. ;
+        ndex2d = 0
+        ndexu = 0
+        ndexv = 0
+        vbuffer=0.
+!$OMP END MASTER
+!$OMP BARRIER
+        first=.FALSE.
+      ENDIF
+      
+      ok_sync = .TRUE.
+      itau_w = itau_dyn + time
+
+! Passage aux composantes naturelles du vent
+      call covnat_loc(llm, ucov, vcov, unat, vnat)
+
+!
+!  Appels a histwrite pour l'ecriture des variables a sauvegarder
+!
+!  Vents U
+!
+      ijb=ij_begin
+      ije=ij_end
+      jjn=jj_nb
+     
+      CALL writefield_dyn_u('U', unat(ijb:ije,:))
+
+!
+!  Vents V
+!
+      ije=ij_end
+      IF (pole_sud) THEN
+         jjn=jj_nb-1
+         ije=ij_end-iip1
+      ENDIF
+      vbuffer(ijb:ije,:)=vnat(ijb:ije,:)
+
+
+      IF (pole_sud) THEN
+         CALL writefield_dyn_v('V', vbuffer(ijb:ije+iip1,:))
+      ELSE
+         CALL writefield_dyn_v('V', vbuffer(ijb:ije,:))
+      ENDIF
+      
+
+      
+!
+!  Temperature potentielle moyennee
+!
+      ijb=ij_begin
+      ije=ij_end
+      jjn=jj_nb
+     CALL writefield_dyn_u('THETA', teta(ijb:ije,:))
+
+!
+!  Temperature moyennee
+!
+
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)       
+      do ll=1,llm
+        do ii = ijb, ije
+          tm(ii,ll) = teta(ii,ll) * ppk(ii,ll)/cpp
+        enddo
+      enddo
+!$OMP ENDDO
+      CALL writefield_dyn_u('TEMP', tm(ijb:ije,:))
+
+
+!
+!  Geopotentiel
+!
+      CALL writefield_dyn_u('PHI', phi(ijb:ije,:))
+
+
+!
+! Tracers?
+!
+!        DO iq=1,nqtot
+!        ENDDO
+
+
+!
+!  Masse
+!
+      CALL writefield_dyn_u('MASSE', masse(ijb:ije,:))
+
+
+!
+!  Pression au sol
+!
+      CALL writefield_dyn_u('PS', ps(ijb:ije))
+
+#endif
+
+      END
Index: LMDZ6/branches/Portage_acc/libf/dynphy_lonlat/inigeomphy_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dynphy_lonlat/inigeomphy_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dynphy_lonlat/inigeomphy_mod.F90	(revision 4446)
@@ -25,5 +25,5 @@
   USE nrtype, ONLY: pi
   USE comvert_mod, ONLY: preff, ap, bp, aps, bps, presnivs, &
-                         scaleheight, pseudoalt
+                         scaleheight, pseudoalt, presinter
   USE vertical_layers_mod, ONLY: init_vertical_layers
   IMPLICIT NONE
@@ -233,5 +233,5 @@
   ! copy over preff , ap(), bp(), etc 
   CALL init_vertical_layers(nlayer,preff,scaleheight, &
-                            ap,bp,aps,bps,presnivs,pseudoalt)
+                            ap,bp,aps,bps,presnivs,presinter,pseudoalt)
 
 !$OMP END PARALLEL
Index: LMDZ6/branches/Portage_acc/libf/dynphy_lonlat/phylmd/callphysiq_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dynphy_lonlat/phylmd/callphysiq_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dynphy_lonlat/phylmd/callphysiq_mod.F90	(revision 4446)
@@ -20,6 +20,10 @@
 
   USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
-  USE control_mod, ONLY: planet_type
+  USE control_mod, ONLY: planet_type, ok_dyn_xios
   USE physiq_mod, ONLY: physiq
+#ifdef CPP_XIOS
+  USE mod_xios_dyn3dmem, ONLY : dyn3d_ctx_handle
+  USE xios, ONLY : xios_set_current_context
+#endif
   IMPLICIT NONE
 
@@ -90,4 +94,13 @@
               zdpsrf_omp)
 
+! switching back to LMDZDYN context
+#ifdef CPP_XIOS
+!$OMP MASTER
+  if (ok_dyn_xios) then
+     CALL xios_set_current_context(dyn3d_ctx_handle)
+  endif
+!$OMP END MASTER
+#endif  
+
 
 END SUBROUTINE call_physiq
Index: LMDZ6/branches/Portage_acc/libf/dynphy_lonlat/phylmd/ce0l.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dynphy_lonlat/phylmd/ce0l.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dynphy_lonlat/phylmd/ce0l.F90	(revision 4446)
@@ -23,5 +23,5 @@
   USE netcdf,         ONLY: NF90_OPEN, NF90_NOWRITE, NF90_CLOSE, NF90_NOERR,    &
          NF90_INQUIRE_DIMENSION, NF90_INQ_DIMID, NF90_INQ_VARID, NF90_GET_VAR
-  USE infotrac,       ONLY: type_trac, infotrac_init
+  USE infotrac,       ONLY: init_infotrac
   USE dimphy,         ONLY: klon
   USE test_disvert_m, ONLY: test_disvert
@@ -108,5 +108,5 @@
   calnd='gregorian'
   SELECT CASE(calend)
-    CASE('earth_360d');CALL ioconf_calendar('360d');   calnd='with 360 days/year'
+    CASE('earth_360d');CALL ioconf_calendar('360_day');   calnd='with 360 days/year'
     CASE('earth_365d');CALL ioconf_calendar('noleap'); calnd='with no leap year'
     CASE('earth_366d');CALL ioconf_calendar('366d');   calnd='with leap years only'
@@ -132,5 +132,5 @@
 
 !--- Tracers initializations
-  CALL infotrac_init()
+  CALL init_infotrac()
 
   CALL inifilr()
Index: LMDZ6/branches/Portage_acc/libf/dynphy_lonlat/phylmd/iniphysiq_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dynphy_lonlat/phylmd/iniphysiq_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dynphy_lonlat/phylmd/iniphysiq_mod.F90	(revision 4446)
@@ -16,5 +16,5 @@
   USE mod_phys_lmdz_para, ONLY: klon_omp ! number of columns (on local omp grid)
   USE vertical_layers_mod, ONLY : init_vertical_layers
-  USE infotrac, ONLY: nbtr,nqCO2,tracers,isotopes,type_trac,conv_flg,pbl_flg,nqtottr
+  USE infotrac, ONLY: nbtr, type_trac
 #ifdef CPP_StratAer
   USE infotrac_phy, ONLY: nbtr_bin, nbtr_sulgas, id_OCS_strat, &
@@ -30,5 +30,5 @@
   USE mod_phys_lmdz_omp_data, ONLY: klon_omp
 #endif
-  USE control_mod, ONLY: dayref,anneeref,day_step,nday,offline, iphysiq, config_inca
+  USE control_mod, ONLY: dayref,anneeref,day_step,nday,offline, iphysiq
   USE inifis_mod, ONLY: inifis
   USE time_phylmdz_mod, ONLY: init_time
@@ -158,5 +158,5 @@
 
   ! Initialize tracer names, numbers, etc. for physics
-  CALL init_infotrac_phy(type_trac, tracers, isotopes, nqtottr, nqCO2, pbl_flg, conv_flg)
+  CALL init_infotrac_phy
 
   ! Initializations for Reprobus
@@ -187,5 +187,5 @@
   END IF
 
-  IF (type_trac == 'inca' .OR. type_trac == 'inco') THEN
+  IF (ANY(type_trac == ['inca','inco'])) THEN
 #ifdef INCA
      CALL init_inca_dim_reg(nbp_lon, nbp_lat - 1, &
@@ -194,10 +194,4 @@
   END IF
 
-  IF (type_trac == 'repr') THEN
-#ifdef REPROBUS
-     CALL Init_chem_rep_phys(klon_omp,nbp_lev)
-#endif
-  END IF
-
 !$OMP END PARALLEL
 
Index: LMDZ6/branches/Portage_acc/libf/dynphy_lonlat/phylmd/init_ssrf_m.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dynphy_lonlat/phylmd/init_ssrf_m.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dynphy_lonlat/phylmd/init_ssrf_m.F90	(revision 4446)
@@ -3,12 +3,13 @@
 !*******************************************************************************
 
-  USE indice_sol_mod, ONLY: is_ter, is_oce, is_oce, is_lic, epsfra
+  USE indice_sol_mod,     ONLY: is_ter, is_oce, is_oce, is_lic, epsfra
   USE dimphy,             ONLY: klon, zmasq
   USE phys_state_var_mod, ONLY: pctsrf
-  USE geometry_mod, ONLY : longitude_deg, latitude_deg
+  USE geometry_mod,       ONLY : longitude_deg, latitude_deg
   USE grid_atob_m,        ONLY: grille_m
   USE ioipsl,             ONLY: flininfo, flinopen, flinget, flinclo
   USE ioipsl_getin_p_mod, ONLY: getin_p
-  USE comconst_mod, ONLY: im, pi
+  USE comconst_mod,       ONLY: im, pi
+  USE surface_data,       ONLY: landice_opt
 
   CHARACTER(LEN=256), PARAMETER :: icefname="landiceref.nc", icevar="landice"
@@ -58,64 +59,75 @@
 ! Sub-surfaces initialization
 !*******************************************************************************
-!--- Read and interpolate on model T-grid soil fraction and soil ice fraction.
-  CALL flininfo(icefname, iml_lic, jml_lic, llm_tmp, ttm_tmp, fid)
-  ALLOCATE(lat_lic(iml_lic,jml_lic),lon_lic(iml_lic,jml_lic))
-  ALLOCATE(fraclic(iml_lic,jml_lic))
-  CALL flinopen(icefname, .FALSE., iml_lic, jml_lic, llm_tmp,  &
- &               lon_lic, lat_lic, lev, ttm_tmp, itaul, date, dt, fid)
-  CALL flinget(fid, icevar, iml_lic, jml_lic, llm_tmp, ttm_tmp, 1,1, fraclic)
-  CALL flinclo(fid)
-  WRITE(lunout,*)'landice dimensions: iml_lic, jml_lic : ',iml_lic,jml_lic
+  IF (landice_opt .LT. 2) THEN
+     ! Continue with reading landice.nc file
+     WRITE(lunout,*)"Read landice.nc file to attribute is_lic fraction"
 
-  ALLOCATE(dlon_lic(iml_lic),dlat_lic(jml_lic))
-  dlon_lic(:)=lon_lic(:,1); IF(MAXVAL(dlon_lic)>pi) dlon_lic=dlon_lic*pi/180.
-  dlat_lic(:)=lat_lic(1,:); IF(MAXVAL(dlat_lic)>pi) dlat_lic=dlat_lic*pi/180.
-  DEALLOCATE(lon_lic,lat_lic); ALLOCATE(flic_tmp(iip1,jjp1))
-  CALL grille_m(dlon_lic,dlat_lic,fraclic,rlonv(1:iim),rlatu,flic_tmp(1:iim,:))
-  flic_tmp(iip1,:)=flic_tmp(1,:)
-
-!--- To the physical grid
-  pctsrf(:,:) = 0.
-  CALL gr_dyn_fi(1, iip1, jjp1, klon, flic_tmp, pctsrf(:,is_lic))
-  DEALLOCATE(flic_tmp)
-
-!--- Adequation with soil/sea mask
-  WHERE(pctsrf(:,is_lic)<EPSFRA) pctsrf(:,is_lic)=0. 
-  WHERE(zmasq(:)<EPSFRA)         pctsrf(:,is_lic)=0.
-  pctsrf(:,is_ter)=zmasq(:)
-  DO ji=1,klon
-    IF(zmasq(ji)>EPSFRA) THEN 
-      IF(pctsrf(ji,is_lic)>=zmasq(ji)) THEN
-        pctsrf(ji,is_lic)=zmasq(ji)
-        pctsrf(ji,is_ter)=0.
-      ELSE
-        pctsrf(ji,is_ter)=zmasq(ji)-pctsrf(ji,is_lic)
-        IF(pctsrf(ji,is_ter)<EPSFRA) THEN
-          pctsrf(ji,is_ter)=0.
-          pctsrf(ji,is_lic)=zmasq(ji)
-        END IF 
-      END IF 
-    END IF 
-  END DO 
-
-
-  !--- Option no_ter_antartique removes all land fractions souther than 60S.
-  !--- Land ice is set instead of the land fractions on these latitudes.
-  !--- The ocean and sea-ice fractions are not changed.
-  no_ter_antartique=.FALSE.
-  CALL getin_p('no_ter_antartique',no_ter_antartique)
-  WRITE(lunout,*)"no_ter_antartique=",no_ter_antartique
-  IF (no_ter_antartique) THEN
-     ! Remove all land fractions souther than 60S and set land-ice instead
-     WRITE(lunout,*) "Remove land fractions souther than 60deg south by increasing"
-     WRITE(lunout,*) "the continental ice fractions. No land can now be found at Antartic."
-     DO ji=1, klon
-        IF (latitude_deg(ji)<-60.0) THEN
-           pctsrf(ji,is_lic) = pctsrf(ji,is_lic) + pctsrf(ji,is_ter)
-           pctsrf(ji,is_ter) = 0
+     !--- Read and interpolate on model T-grid soil fraction and soil ice fraction.
+     CALL flininfo(icefname, iml_lic, jml_lic, llm_tmp, ttm_tmp, fid)
+     ALLOCATE(lat_lic(iml_lic,jml_lic),lon_lic(iml_lic,jml_lic))
+     ALLOCATE(fraclic(iml_lic,jml_lic))
+     CALL flinopen(icefname, .FALSE., iml_lic, jml_lic, llm_tmp,  &
+          &               lon_lic, lat_lic, lev, ttm_tmp, itaul, date, dt, fid)
+     CALL flinget(fid, icevar, iml_lic, jml_lic, llm_tmp, ttm_tmp, 1,1, fraclic)
+     CALL flinclo(fid)
+     WRITE(lunout,*)'landice dimensions: iml_lic, jml_lic : ',iml_lic,jml_lic
+     
+     ALLOCATE(dlon_lic(iml_lic),dlat_lic(jml_lic))
+     dlon_lic(:)=lon_lic(:,1); IF(MAXVAL(dlon_lic)>pi) dlon_lic=dlon_lic*pi/180.
+     dlat_lic(:)=lat_lic(1,:); IF(MAXVAL(dlat_lic)>pi) dlat_lic=dlat_lic*pi/180.
+     DEALLOCATE(lon_lic,lat_lic); ALLOCATE(flic_tmp(iip1,jjp1))
+     CALL grille_m(dlon_lic,dlat_lic,fraclic,rlonv(1:iim),rlatu,flic_tmp(1:iim,:))
+     flic_tmp(iip1,:)=flic_tmp(1,:)
+     
+     !--- To the physical grid
+     pctsrf(:,:) = 0.
+     CALL gr_dyn_fi(1, iip1, jjp1, klon, flic_tmp, pctsrf(:,is_lic))
+     DEALLOCATE(flic_tmp)
+     
+     !--- Adequation with soil/sea mask
+     WHERE(pctsrf(:,is_lic)<EPSFRA) pctsrf(:,is_lic)=0. 
+     WHERE(zmasq(:)<EPSFRA)         pctsrf(:,is_lic)=0.
+     pctsrf(:,is_ter)=zmasq(:)
+     DO ji=1,klon
+        IF(zmasq(ji)>EPSFRA) THEN 
+           IF(pctsrf(ji,is_lic)>=zmasq(ji)) THEN
+              pctsrf(ji,is_lic)=zmasq(ji)
+              pctsrf(ji,is_ter)=0.
+           ELSE
+              pctsrf(ji,is_ter)=zmasq(ji)-pctsrf(ji,is_lic)
+              IF(pctsrf(ji,is_ter)<EPSFRA) THEN
+                 pctsrf(ji,is_ter)=0.
+                 pctsrf(ji,is_lic)=zmasq(ji)
+              END IF
+           END IF
         END IF
      END DO
+     
+     
+     !--- Option no_ter_antartique removes all land fractions souther than 60S.
+     !--- Land ice is set instead of the land fractions on these latitudes.
+     !--- The ocean and sea-ice fractions are not changed.
+     no_ter_antartique=.FALSE.
+     CALL getin_p('no_ter_antartique',no_ter_antartique)
+     WRITE(lunout,*)"no_ter_antartique=",no_ter_antartique
+     IF (no_ter_antartique) THEN
+        ! Remove all land fractions souther than 60S and set land-ice instead
+        WRITE(lunout,*) "Remove land fractions souther than 60deg south by increasing"
+        WRITE(lunout,*) "the continental ice fractions. No land can now be found at Antartic."
+        DO ji=1, klon
+           IF (latitude_deg(ji)<-60.0) THEN
+              pctsrf(ji,is_lic) = pctsrf(ji,is_lic) + pctsrf(ji,is_ter)
+              pctsrf(ji,is_ter) = 0
+           END IF
+        END DO
+     END IF
+     
+  ELSE
+     ! landice_opt=2 and higher
+     WRITE(lunout,*) 'No landice is attributed is_lic sub-surface because landice_opt=2 or higher.'
+     WRITE(lunout,*) 'This means that the land model will handel land ice as well as all other land areas.'
+     pctsrf(:,is_ter) = zmasq(:)
+     pctsrf(:,is_lic) = 0.0
   END IF
-
 
 !--- Sub-surface ocean and sea ice (sea ice set to zero for start).
Index: LMDZ6/branches/Portage_acc/libf/dynphy_lonlat/phylmd/limit_netcdf.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/dynphy_lonlat/phylmd/limit_netcdf.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/dynphy_lonlat/phylmd/limit_netcdf.F90	(revision 4446)
@@ -424,5 +424,5 @@
   IF(NF90_GET_ATT(ncid, varid, 'calendar', cal_in)/=NF90_NOERR) THEN
     SELECT CASE(mode)
-      CASE('RUG', 'ALB'); cal_in='360d'
+      CASE('RUG', 'ALB'); cal_in='360_day'
       CASE('SIC', 'SST'); cal_in='gregorian'
     END SELECT
@@ -492,5 +492,5 @@
       !--- DROPPED FOR BCS DATA (FRACTIONS CAN BE HIGHER THAN 1)
       IF(ll.AND.ix_sic/=1.AND.mode=='SIC') &
-        CALL abort_physic(mode,'unrealistic '//TRIM(mode)//' found: '//TRIM(str))
+        CALL abort_physic(mode,'unrealistic '//TRIM(mode)//' found: '//TRIM(str), 1)
 
     END IF
@@ -641,5 +641,5 @@
   ALLOCATE(champo(klon, ndays))
   DO k=1, ndays
-    CALL gr_dyn_fi(1, iip1, jjp1, klon, champan(1, 1, k), champo(1, k))
+    CALL gr_dyn_fi(1, iip1, jjp1, klon, champan(1, 1, k), champo(:, k))
   END DO
   DEALLOCATE(champan)
Index: LMDZ6/branches/Portage_acc/libf/filtrez/filtreg.F
===================================================================
--- LMDZ6/branches/Portage_acc/libf/filtrez/filtreg.F	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/filtrez/filtreg.F	(revision 4446)
@@ -71,4 +71,6 @@
 
       INTEGER :: sdd1_type, sdd2_type
+
+      if ( iim == 1 ) return ! no filtre in 2D y-z
 
       IF (first) THEN
Index: LMDZ6/branches/Portage_acc/libf/filtrez/filtreg_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/filtrez/filtreg_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/filtrez/filtreg_mod.F90	(revision 4446)
@@ -66,4 +66,5 @@
     !-----------------------------------------------------------
     !
+    if ( iim == 1 ) return ! No filtre in 2D y-z
 
     pi       = 2. * ASIN( 1. )
@@ -125,4 +126,5 @@
     !
     colat0  =  MIN( 0.5, dymin/dxmin )
+    ! colat0  =  1.
     !
     IF( .NOT.fxyhypb.AND.ysinus )  THEN
Index: LMDZ6/branches/Portage_acc/libf/grid/dimension/makdim
===================================================================
--- LMDZ6/branches/Portage_acc/libf/grid/dimension/makdim	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/grid/dimension/makdim	(revision 4446)
@@ -12,5 +12,5 @@
 fi
 
-if (($1 % 8 != 0)) && (( $# == 3 ))
+if ( ( ($1 % 8 != 0)) && (( $# == 3 ) ) || ( $1 == 1 ) )
 then
     echo "The number of longitudes must be a multiple of 8."
Index: LMDZ6/branches/Portage_acc/libf/misc/readTracFiles_mod.f90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/misc/readTracFiles_mod.f90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/misc/readTracFiles_mod.f90	(revision 4446)
@@ -1,7 +1,6 @@
 MODULE readTracFiles_mod
 
-  USE strings_mod,    ONLY: msg, testFile,  strFind, strStack, strReduce,  strHead, strCount, find, fmsg, reduceExpr, &
-             removeComment, cat, checkList, str2int, strParse, strReplace, strTail, strIdx, maxlen, test, dispTable, get_in
-  USE trac_types_mod, ONLY: trac_type, isot_type, keys_type
+  USE strings_mod,    ONLY: msg, find, get_in, str2int, dispTable, testFile, strReduce,  strFind, strStack, strHead,  &
+       test, removeComment, cat, fmsg, maxlen, int2str, checkList, strParse, strReplace, strTail, strCount, strIdx, reduceExpr
 
   IMPLICIT NONE
@@ -9,33 +8,103 @@
   PRIVATE
 
-  PUBLIC :: initIsotopes, maxlen, trac_type, isot_type, keys_type
-  PUBLIC :: readTracersFiles, indexUpdate, setGeneration             !--- TOOLS ASSOCIATED TO TRACERS  DESCRIPTORS
-  PUBLIC :: readIsotopesFile                                         !--- TOOLS ASSOCIATED TO ISOTOPES DESCRIPTORS
-  PUBLIC :: getKey_init, getKey, fGetKey, setDirectKeys              !--- GET/SET KEYS FROM/TO tracers & isotopes
-
-  PUBLIC :: addPhase, new2oldName,  getPhase, &                      !--- FUNCTIONS RELATED TO THE PHASES
-            delPhase, old2newName, getiPhase, &                      !--- + ASSOCIATED VARIABLES
-            known_phases, old_phases, phases_sep, phases_names, nphases
-
-  PUBLIC :: oldH2OIso, newH2OIso                                     !--- NEEDED FOR BACKWARD COMPATIBILITY (OLD traceur.def)
-
-  PUBLIC :: tran0, idxAncestor, ancestor                             !--- GENERATION 0 TRACER + TOOLS FOR GENERATIONS
-!------------------------------------------------------------------------------------------------------------------------------
-  TYPE :: dataBase_type                                              !=== TYPE FOR TRACERS SECTION
-    CHARACTER(LEN=maxlen)  :: name                                   !--- Section name
-    TYPE(trac_type), ALLOCATABLE :: trac(:)                          !--- Tracers descriptors
+  PUBLIC :: maxlen                                              !--- PARAMETER FOR CASUAL STRING LENGTH
+  PUBLIC :: tracers                                             !--- TRACERS  DESCRIPTION DATABASE
+  PUBLIC :: trac_type, setGeneration, indexUpdate               !--- TRACERS  DESCRIPTION ASSOCIATED TOOLS
+  PUBLIC :: testTracersFiles, readTracersFiles                  !--- TRACERS FILES READING ROUTINES
+  PUBLIC :: getKey, fGetKey, fGetKeys, addKey, setDirectKeys    !--- TOOLS TO GET/SET KEYS FROM/TO  tracers & isotopes
+  PUBLIC :: getKeysDBase,    setKeysDBase                       !--- TOOLS TO GET/SET THE DATABASE (tracers & isotopes)
+
+  PUBLIC :: addPhase, getiPhase,  old_phases, phases_sep, &     !--- FUNCTIONS RELATED TO THE PHASES
+   nphases, delPhase, getPhase, known_phases, phases_names      !--- + ASSOCIATED VARIABLES
+
+  PUBLIC :: oldH2OIso, newH2OIso, old2newH2O, new2oldH2O        !--- H2O ISOTOPES BACKWARD COMPATIBILITY (OLD traceur.def)
+  PUBLIC :: oldHNO3,   newHNO3                                  !--- HNO3 REPRO   BACKWARD COMPATIBILITY (OLD start.nc)
+
+  PUBLIC :: tran0, idxAncestor, ancestor                        !--- GENERATION 0 TRACER + TOOLS FOR GENERATIONS
+
+  !=== FOR ISOTOPES: GENERAL
+  PUBLIC :: isot_type, readIsotopesFile, isoSelect              !--- ISOTOPES DESCRIPTION TYPE + READING ROUTINE
+  PUBLIC :: ixIso, nbIso                                        !--- INDEX OF SELECTED ISOTOPES CLASS + NUMBER OF CLASSES
+
+  !=== FOR ISOTOPES: H2O FAMILY ONLY
+  PUBLIC :: iH2O
+
+  !=== FOR ISOTOPES: DEPENDING ON THE SELECTED ISOTOPES CLASS
+  PUBLIC :: isotope, isoKeys                                    !--- SELECTED ISOTOPES DATABASE + ASSOCIATED KEYS
+  PUBLIC :: isoName, isoZone, isoPhas                           !--- ISOTOPES AND TAGGING ZONES NAMES AND PHASES
+  PUBLIC :: niso,    nzone,   nphas,   ntiso                    !---  " " NUMBERS + ISOTOPES AND TAGGING TRACERS NUMBERS
+  PUBLIC :: itZonIso                                            !--- Idx IN isoName(1:niso) = f(tagging idx, isotope idx)
+  PUBLIC :: iqIsoPha                                            !--- Idx IN qx(1:nqtot)     = f(isotope idx,   phase idx)
+  PUBLIC :: isoCheck                                            !--- FLAG TO RUN ISOTOPES CHECKING ROUTINES
+
+  PUBLIC :: maxTableWidth
+!------------------------------------------------------------------------------------------------------------------------------
+  TYPE :: keys_type                                        !=== TYPE FOR A SET OF KEYS ASSOCIATED TO AN ELEMENT
+    CHARACTER(LEN=maxlen)              :: name             !--- Tracer name
+    CHARACTER(LEN=maxlen), ALLOCATABLE :: key(:)           !--- Keys string list
+    CHARACTER(LEN=maxlen), ALLOCATABLE :: val(:)           !--- Corresponding values string list
+  END TYPE keys_type
+!------------------------------------------------------------------------------------------------------------------------------
+  TYPE :: trac_type                                        !=== TYPE FOR A SINGLE TRACER NAMED "name"
+    CHARACTER(LEN=maxlen) :: name        = ''              !--- Name of the tracer
+    CHARACTER(LEN=maxlen) :: gen0Name    = ''              !--- First generation ancestor name
+    CHARACTER(LEN=maxlen) :: parent      = ''              !--- Parent name
+    CHARACTER(LEN=maxlen) :: longName    = ''              !--- Long name (with advection scheme suffix)
+    CHARACTER(LEN=maxlen) :: type        = 'tracer'        !--- Type  (so far: 'tracer' / 'tag')
+    CHARACTER(LEN=maxlen) :: phase       = 'g'             !--- Phase ('g'as / 'l'iquid / 's'olid)
+    CHARACTER(LEN=maxlen) :: component   = ''              !--- Coma-separated list of components (Ex: lmdz,inca)
+    INTEGER               :: iGeneration = -1              !--- Generation number (>=0)
+    INTEGER               :: iqParent    = 0               !--- Parent index
+    INTEGER,  ALLOCATABLE :: iqDescen(:)                   !--- Descendants index (in growing generation order)
+    INTEGER               :: nqDescen    = 0               !--- Number of descendants (all generations)
+    INTEGER               :: nqChildren  = 0               !--- Number of children  (first generation)
+    TYPE(keys_type)       :: keys                          !--- <key>=<val> pairs vector
+    INTEGER               :: iadv        = 10              !--- Advection scheme used
+    LOGICAL               :: isAdvected  = .FALSE.         !--- "true" tracers: iadv > 0.   COUNT(isAdvected )=nqtrue
+    LOGICAL               :: isInPhysics = .TRUE.          !--- "true" tracers: in tr_seri. COUNT(isInPhysics)=nqtottr
+    INTEGER               :: iso_iGroup  = 0               !--- Isotopes group index in isotopes(:)
+    INTEGER               :: iso_iName   = 0               !--- Isotope  name  index in isotopes(iso_iGroup)%trac(:)
+    INTEGER               :: iso_iZone   = 0               !--- Isotope  zone  index in isotopes(iso_iGroup)%zone(:)
+    INTEGER               :: iso_iPhase  = 0               !--- Isotope  phase index in isotopes(iso_iGroup)%phase
+  END TYPE trac_type
+!------------------------------------------------------------------------------------------------------------------------------
+  TYPE :: isot_type                                        !=== TYPE FOR AN ISOTOPES FAMILY DESCENDING ON TRACER "parent"
+    CHARACTER(LEN=maxlen)              :: parent           !--- Isotopes family name (parent tracer name ; ex: H2O)
+    LOGICAL                            :: check=.FALSE.    !--- Triggering of the checking routines
+    TYPE(keys_type),       ALLOCATABLE :: keys(:)          !--- Isotopes keys/values pairs list     (length: niso)
+    CHARACTER(LEN=maxlen), ALLOCATABLE :: trac(:)          !--- Isotopes + tagging tracers list     (length: ntiso)
+    CHARACTER(LEN=maxlen), ALLOCATABLE :: zone(:)          !--- Geographic tagging zones names list (length: nzone)
+    CHARACTER(LEN=maxlen)              :: phase = 'g'      !--- Phases list: [g][l][s]              (length: nphas)
+    INTEGER                            :: niso  = 0        !--- Number of isotopes, excluding tagging tracers
+    INTEGER                            :: nzone = 0        !--- Number of geographic tagging zones
+    INTEGER                            :: ntiso = 0        !--- Number of isotopes, including tagging tracers
+    INTEGER                            :: nphas = 0        !--- Number phases
+    INTEGER,               ALLOCATABLE :: iqIsoPha(:,:)    !--- Idx in "tracers(1:nqtot)" = f(name(1:ntiso)),phas)
+                                                           !---        "iqIsoPha" former name: "iqiso"
+    INTEGER,               ALLOCATABLE :: itZonIso(:,:)    !--- Idx in "trac(1:ntiso)" = f(zone, name(1:niso))
+                                                           !---        "itZonIso" former name: "index_trac"
+  END TYPE isot_type
+!------------------------------------------------------------------------------------------------------------------------------
+  TYPE :: dataBase_type                                         !=== TYPE FOR TRACERS SECTION
+    CHARACTER(LEN=maxlen)  :: name                              !--- Section name
+    TYPE(trac_type), ALLOCATABLE :: trac(:)                     !--- Tracers descriptors
   END TYPE dataBase_type
 !------------------------------------------------------------------------------------------------------------------------------
   INTERFACE getKey
-    MODULE PROCEDURE getKeyByName_s1, getKeyByName_i1, getKeyByName_r1, getKeyByName_sm, getKeyByName_im, getKeyByName_rm
+    MODULE PROCEDURE getKeyByName_s1, getKeyByName_s1m, getKeyByName_sm, getKey_sm, &
+                     getKeyByName_i1, getKeyByName_i1m, getKeyByName_im, getKey_im, &
+                     getKeyByName_r1, getKeyByName_r1m, getKeyByName_rm, getKey_rm, &
+                     getKeyByName_l1, getKeyByName_l1m, getKeyByName_lm, getKey_lm
   END INTERFACE getKey
 !------------------------------------------------------------------------------------------------------------------------------
-  INTERFACE fGetKey;       MODULE PROCEDURE fgetKeyByIndex_s1, fgetKeyByName_s1; END INTERFACE fGetKey
+  INTERFACE    isoSelect;  MODULE PROCEDURE  isoSelectByIndex,  isoSelectByName; END INTERFACE isoSelect
+  INTERFACE  old2newH2O;   MODULE PROCEDURE  old2newH2O_1,  old2newH2O_m;        END INTERFACE old2newH2O
+  INTERFACE  new2oldH2O;   MODULE PROCEDURE  new2oldH2O_1,  new2oldH2O_m;        END INTERFACE new2oldH2O
+  INTERFACE fGetKey;       MODULE PROCEDURE fgetKeyIdx_s1, fgetKeyNam_s1;        END INTERFACE fGetKey
   INTERFACE tracersSubset; MODULE PROCEDURE trSubset_Indx, trSubset_Name, trSubset_gen0Name; END INTERFACE tracersSubset
-  INTERFACE idxAncestor;   MODULE PROCEDURE idxAncestor_1, idxAncestor_m; END INTERFACE idxAncestor
-  INTERFACE    ancestor;   MODULE PROCEDURE    ancestor_1,    ancestor_m; END INTERFACE    ancestor
+  INTERFACE idxAncestor;   MODULE PROCEDURE idxAncestor_1, idxAncestor_m, idxAncestor_mt;    END INTERFACE idxAncestor
+  INTERFACE    ancestor;   MODULE PROCEDURE    ancestor_1,    ancestor_m,    ancestor_mt;    END INTERFACE    ancestor
+  INTERFACE      addKey;   MODULE PROCEDURE      addKey_1; END INTERFACE addKey!,      addKey_m,     addKey_mm;     END INTERFACE addKey
   INTERFACE    addPhase;   MODULE PROCEDURE   addPhase_s1,   addPhase_sm,   addPhase_i1,   addPhase_im; END INTERFACE addPhase
-  INTERFACE old2newName;   MODULE PROCEDURE old2newName_1, old2newName_m; END INTERFACE old2newName
-  INTERFACE new2oldName;   MODULE PROCEDURE new2oldName_1, new2oldName_m; END INTERFACE new2oldName
 !------------------------------------------------------------------------------------------------------------------------------
 
@@ -44,24 +113,42 @@
 
   !--- SOME PARAMETERS THAT ARE NOT LIKELY TO CHANGE OFTEN
-  CHARACTER(LEN=maxlen), SAVE      :: tran0        = 'air'           !--- Default transporting fluid
-  CHARACTER(LEN=maxlen), PARAMETER :: old_phases   = 'vlir'          !--- Old phases for water (no separator)
-  CHARACTER(LEN=maxlen), PARAMETER :: known_phases = 'glsr'          !--- Known phases initials
-  INTEGER,               PARAMETER :: nphases=LEN_TRIM(known_phases) !--- Number of phases
-  CHARACTER(LEN=maxlen), SAVE      :: phases_names(nphases) &        !--- Known phases names
-                                = ['gaseous', 'liquid ', 'solid  ', 'cloud  ']
-  CHARACTER(LEN=1), SAVE :: phases_sep  =  '_'                       !--- Phase separator
-  LOGICAL,          SAVE :: tracs_merge = .TRUE.                     !--- Merge/stack tracers lists
-  LOGICAL,          SAVE :: lSortByGen  = .TRUE.                     !--- Sort by growing generation
-
-  !--- KEPT JUST TO MANAGE OLD WATER ISOTOPES NAMES
-  !--- Apart from that context, on limitaion on isotopes names (as long as they have a corresponding line in isotopes_params.def)
-  CHARACTER(LEN=maxlen), SAVE :: oldH2OIso(5) = ['eau',     'HDO',     'O18',     'O17',     'HTO'    ]
-  CHARACTER(LEN=maxlen), SAVE :: newH2OIso(5) = ['H2[16]O', 'H[2]HO ', 'H2[18]O', 'H2[17]O', 'H[3]HO ']
-
-
-  !=== LOCAL COPIES OF THE TRACERS AND ISOTOPES DESCRIPTORS, USED BY getKey (INITIALIZED IN getKey_init)
+  CHARACTER(LEN=maxlen), SAVE      :: tran0        = 'air'      !--- Default transporting fluid
+  CHARACTER(LEN=maxlen), PARAMETER :: old_phases   = 'vlir'     !--- Old phases for water (no separator)
+  CHARACTER(LEN=maxlen), PARAMETER :: known_phases = 'glsr'     !--- Known phases initials
+  INTEGER, PARAMETER :: nphases = LEN_TRIM(known_phases)        !--- Number of phases
+  CHARACTER(LEN=maxlen), SAVE      :: phases_names(nphases) &   !--- Known phases names
+                                             = ['gaseous', 'liquid ', 'solid  ', 'cloud  ']
+  CHARACTER(LEN=1), SAVE :: phases_sep  =  '_'                  !--- Phase separator
+  LOGICAL,          SAVE :: tracs_merge = .TRUE.                !--- Merge/stack tracers lists
+  LOGICAL,          SAVE :: lSortByGen  = .TRUE.                !--- Sort by growing generation
+  CHARACTER(LEN=maxlen), SAVE :: isoFile = 'isotopes_params.def'!--- Name of the isotopes parameters file
+
+  !--- CORRESPONDANCE BETWEEN OLD AND NEW WATER NAMES
+  CHARACTER(LEN=maxlen), SAVE :: oldH2OIso(5) = ['eau',   'HDO',   'O18',   'O17',   'HTO'  ]
+  CHARACTER(LEN=maxlen), SAVE :: newH2OIso(5) = ['H216O', 'HDO  ', 'H218O', 'H217O', 'HTO  ']
+
+  !--- CORRESPONDANCE BETWEEN OLD AND NEW HNO3 RELATED SPECIES NAMES
+  CHARACTER(LEN=maxlen), SAVE ::   oldHNO3(2) = ['HNO3_g ', 'HNO3   ']
+  CHARACTER(LEN=maxlen), SAVE ::   newHNO3(2) = ['HNO3   ', 'HNO3tot']
+
+  !=== TRACERS AND ISOTOPES DESCRIPTORS, USED BY getKey
   TYPE(trac_type), ALLOCATABLE, TARGET, SAVE ::  tracers(:)
   TYPE(isot_type), ALLOCATABLE, TARGET, SAVE :: isotopes(:)
 
+  !=== ALIASES OF VARIABLES FROM SELECTED ISOTOPES FAMILY EMBEDDED IN "isotope" (isotopes(ixIso))
+  TYPE(isot_type),         SAVE, POINTER :: isotope             !--- CURRENTLY SELECTED ISOTOPES FAMILY DESCRIPTOR
+  INTEGER,                 SAVE          :: ixIso, iH2O         !--- Index of the selected isotopes family and H2O family
+  INTEGER,                 SAVE          :: nbIso               !--- Number of isotopes classes
+  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)
+
+  INTEGER,    PARAMETER :: maxTableWidth = 192                  !--- Maximum width of a table displayed with "dispTable"
   CHARACTER(LEN=maxlen) :: modname
 
@@ -71,5 +158,5 @@
 !==============================================================================================================================
 !=== READ ONE OR SEVERAL TRACER FILES AND FILL A "tr" TRACERS DESCRIPTOR DERIVED TYPE.
-!=== THE RETURN VALUE fType DEPENDS ON WHAT IS FOUND:
+!=== THE RETURNED VALUE fType DEPENDS ON WHAT IS FOUND:
 !===  0: NO ADEQUATE FILE FOUND ; DEFAULT VALUES MUST BE USED
 !===  1: AN "OLD STYLE" TRACERS FILE "traceur.def":
@@ -92,47 +179,27 @@
 !     * If you need to convert a %key/%val pair into a direct-access key, add the corresponding line in "setDirectKeys".
 !==============================================================================================================================
-LOGICAL FUNCTION readTracersFiles(type_trac, fType, tracs) RESULT(lerr)
-!------------------------------------------------------------------------------------------------------------------------------
-  CHARACTER(LEN=*),             INTENT(IN)  :: type_trac              !--- List of components used
-  INTEGER,                      INTENT(OUT) :: fType                  !--- Type of input file found
-  TYPE(trac_type), ALLOCATABLE, INTENT(OUT) :: tracs(:)
+LOGICAL FUNCTION readTracersFiles(type_trac, lRepr) RESULT(lerr)
+!------------------------------------------------------------------------------------------------------------------------------
+  CHARACTER(LEN=*),  INTENT(IN)  :: type_trac                        !--- List of components used
+  LOGICAL, OPTIONAL, INTENT(IN)  :: lRepr                            !--- Activate the HNNO3 exceptions for REPROBUS
   CHARACTER(LEN=maxlen),  ALLOCATABLE :: s(:), sections(:), trac_files(:)
-  CHARACTER(LEN=maxlen) :: str, fname, mesg
-  INTEGER               :: is, nsec, ierr, it, ntrac, ns, ip, ix
-  LOGICAL, ALLOCATABLE  :: ll(:), lGen3(:)
+  CHARACTER(LEN=maxlen) :: str, fname, tname, pname, cname
+  INTEGER               :: nsec, ierr, it, ntrac, ns, ip, ix, fType
+  LOGICAL :: lRep
+  TYPE(keys_type), POINTER :: k
 !------------------------------------------------------------------------------------------------------------------------------
   lerr = .FALSE.
   modname = 'readTracersFiles'
   IF(.NOT.ALLOCATED(dBase)) ALLOCATE(dBase(0))
-
-  !--- Required sections + corresponding files names (new style single section case)
-  IF(test(strParse(type_trac, ',', sections), lerr)) RETURN          !--- Parse "type_trac" list
-
-  nsec = SIZE(sections, DIM=1)
-  ALLOCATE(trac_files(nsec)); DO is=1, nsec; trac_files(is) = 'tracer_'//TRIM(sections(is))//'.def'; END DO
-
-  !--- LOOK AT AVAILABLE FILES
-  ll = .NOT.testFile(trac_files)
-  fType = 0
-  IF(.NOT.testFile('traceur.def') .AND. nsec==1) fType = 1           !--- OLD STYLE FILE
-  IF(.NOT.testFile('tracer.def'))                fType = 2           !--- NEW STYLE ; SINGLE  FILE, SEVERAL SECTIONS
-  IF(ALL(ll))                                    fType = 3           !--- NEW STYLE ; SEVERAL FILES, SINGLE SECTION USED
-  IF(ANY(ll) .AND. fType/=3) THEN                                    !--- MISSING FILES
-    IF(test(checkList(trac_files, .NOT.ll, 'Failed reading tracers description', 'files', 'missing'), lerr)) RETURN
-  END IF
-
-  !--- CHECK WHETHER type_trac AND FILE TYPE ARE COMPATIBLE
-  IF(test(fmsg('No multiple sections for the old format "traceur.def"', ll = SIZE(sections)>1 .AND. fType==1), lerr)) RETURN
-
-  !--- TELLS WHAT WAS IS ABOUT TO BE USED
-  IF (fmsg('No adequate tracers description file(s) found ; default values will be used',          modname, fType==0)) RETURN
-  CALL msg('Trying to read old-style tracers description file "traceur.def"',                      modname, fType==1)
-  CALL msg('Trying to read the new style multi-sections tracers description file "tracer.def"',    modname, fType==2)
-  CALL msg('Trying to read the new style single section tracers description files "tracer_*.def"', modname, fType==3)
+  lRep=.FALSE.; IF(PRESENT(lRepr)) lRep = lRepr
+
+  !--- Required sections + corresponding files names (new style single section case) for tests
+  IF(test(testTracersFiles(modname, type_trac, fType, .FALSE., trac_files, sections), lerr)) RETURN
+  nsec = SIZE(sections)
 
   !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   SELECT CASE(fType)                         !--- Set %name, %genOName, %parent, %type, %phase, %component, %iGeneration, %keys
   !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-    CASE(1)                                                               !=== OLD FORMAT "traceur.def"
+    CASE(1)                                                          !=== OLD FORMAT "traceur.def"
     !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       !--- OPEN THE "traceur.def" FILE
@@ -144,27 +211,54 @@
 
       !--- READ THE REMAINING LINES: <hadv> <vadv> <tracer> [<transporting fluid>]
-      ALLOCATE(tracs(ntrac))
+      IF(ALLOCATED(tracers)) DEALLOCATE(tracers)
+      ALLOCATE(tracers(ntrac))
       DO it=1,ntrac                                                  !=== READ RAW DATA: loop on the line/tracer number
         READ(90,'(a)',IOSTAT=ierr) str
         IF(test(fmsg('Invalid format for "' //TRIM(fname)//'"', modname, ierr>0), lerr)) RETURN
         IF(test(fmsg('Not enough lines in "'//TRIM(fname)//'"', modname, ierr<0), lerr)) RETURN
-        ll = strParse(str, ' ', s, n=ns)
+        lerr = strParse(str, ' ', s, ns)
         CALL msg('This file is for air tracers only',           modname, ns == 3 .AND. it == 1)
         CALL msg('This files specifies the transporting fluid', modname, ns == 4 .AND. it == 1)
-        tracs(it)%name   = old2newName(s(3), ip)                     !--- Set %name:   name   of the tracer
-        tracs(it)%parent = tran0                                     !--- Default transporting fluid name
-        IF(ns == 4) tracs(it)%parent = old2newName(s(4))             !--- Set %parent: parent of the tracer
-        tracs(it)%phase = known_phases(ip:ip)                        !--- Set %phase:  tracer phase (default: "g"azeous)
-        tracs(it)%component = TRIM(type_trac)                        !--- Set %component: model component name
-        tracs(it)%keys%key = ['hadv', 'vadv']                        !--- Set %keys%key
-        tracs(it)%keys%val = s(1:2)                                  !--- Set %keys%val
+        k => tracers(it)%keys
+
+        !=== NAME OF THE TRACER
+        tname = old2newH2O(s(3), ip)
+        ix = strIdx(oldHNO3, s(3))
+        IF(ix /= 0 .AND. lRep) tname = newHNO3(ix)                   !--- Exception for HNO3 (REPROBUS ONLY)
+        tracers(it)%name = tname                                     !--- Set %name
+        CALL addKey_1('name', tname, k)                              !--- Set the name of the tracer
+        tracers(it)%keys%name = tname                                !--- Copy tracers names in keys components
+
+        !=== NAME OF THE COMPONENT
+        cname = type_trac                                            !--- Name of the model component
+        IF(ANY([(addPhase('H2O', ip), ip = 1, nphases)] == tname)) cname = 'lmdz'
+        tracers(it)%component = cname                                !--- Set %component
+        CALL addKey_1('component', cname, k)                         !--- Set the name of the model component
+
+        !=== NAME OF THE PARENT
+        pname = tran0                                                !--- Default name: default transporting fluid (air)
+        IF(ns == 4) THEN
+          pname = old2newH2O(s(4))
+          ix = strIdx(oldHNO3, s(4))
+          IF(ix /= 0 .AND. lRep) pname = newHNO3(ix)                 !--- Exception for HNO3 (REPROBUS ONLY)
+        END IF
+        tracers(it)%parent = pname                                   !--- Set %parent
+        CALL addKey_1('parent', pname, k)
+
+        !=== PHASE AND ADVECTION SCHEMES NUMBERS
+        tracers(it)%phase = known_phases(ip:ip)                      !--- Set %phase:  tracer phase (default: "g"azeous)
+        CALL addKey_1('phase', known_phases(ip:ip), k)               !--- Set the phase  of the tracer (default: "g"azeous)
+        CALL addKey_1('hadv', s(1),  k)                              !--- Set the horizontal advection schemes number
+        CALL addKey_1('vadv', s(2),  k)                              !--- Set the vertical   advection schemes number
       END DO
       CLOSE(90)
-      CALL setGeneration(tracs)                                      !--- Set %iGeneration and %gen0Name
-      WHERE(tracs%iGeneration == 2) tracs%type = 'tag'               !--- Set %type:        'tracer' or 'tag'
-      IF(test(checkTracers(tracs, fname, fname), lerr)) RETURN       !--- Detect orphans and check phases
-      IF(test(checkUnique (tracs, fname, fname), lerr)) RETURN       !--- Detect repeated tracers
-      CALL sortTracers  (tracs)                                      !--- Sort the tracers
-      tracs(:)%keys%name = tracs(:)%name                             !--- Copy tracers names in keys components
+      IF(test(setGeneration(tracers), lerr)) RETURN                  !--- Set %iGeneration and %gen0Name
+      WHERE(tracers%iGeneration == 2) tracers(:)%type = 'tag'        !--- Set %type:        'tracer' or 'tag'
+      DO it=1,ntrac
+        CALL addKey_1('type', tracers(it)%type, tracers(it)%keys)    !--- Set the type of tracer
+      END DO
+      IF(test(checkTracers(tracers, fname, fname), lerr)) RETURN     !--- Detect orphans and check phases
+      IF(test(checkUnique (tracers, fname, fname), lerr)) RETURN     !--- Detect repeated tracers
+      CALL sortTracers    (tracers)                                  !--- Sort the tracers
     !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     CASE(2); IF(test(feedDBase(["tracer.def"], [type_trac], modname), lerr)) RETURN !=== SINGLE   FILE, MULTIPLE SECTIONS
@@ -174,24 +268,59 @@
   END SELECT
   !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
   IF(ALL([2,3] /= fType)) RETURN
 
   IF(nsec  == 1) THEN; 
-    tracs = dBase(1)%trac
+    tracers = dBase(1)%trac
   ELSE IF(tracs_merge) THEN
     CALL msg('The multiple required sections will be MERGED.',    modname)
-    IF(test(mergeTracers(dBase, tracs), lerr)) RETURN
+    IF(test(mergeTracers(dBase, tracers), lerr)) RETURN
   ELSE
     CALL msg('The multiple required sections will be CUMULATED.', modname)
-    IF(test(cumulTracers(dBase, tracs), lerr)) RETURN
+    IF(test(cumulTracers(dBase, tracers), lerr)) RETURN
   END IF
-  WHERE(tracs%gen0Name(1:3) /= 'H2O') tracs%isInPhysics=.TRUE.       !--- Set %isInPhysics: passed to physics
-  CALL setDirectKeys(tracs)                                          !--- Set %iqParent, %iqDescen, %nqDescen, %nqChilds
+  CALL setDirectKeys(tracers)                                        !--- Set %iqParent, %iqDescen, %nqDescen, %nqChildren
 END FUNCTION readTracersFiles
 !==============================================================================================================================
 
+
+!==============================================================================================================================
+LOGICAL FUNCTION testTracersFiles(modname, type_trac, fType, lDisp, tracf, sects) RESULT(lerr)
+  CHARACTER(LEN=*),                             INTENT(IN)  :: modname, type_trac
+  INTEGER,                                      INTENT(OUT) :: fType
+  LOGICAL,                            OPTIONAL, INTENT(IN)  :: lDisp
+  CHARACTER(LEN=maxlen), ALLOCATABLE, OPTIONAL, INTENT(OUT) :: tracf(:), sects(:)
+  CHARACTER(LEN=maxlen), ALLOCATABLE :: trac_files(:), sections(:)
+  LOGICAL, ALLOCATABLE :: ll(:)
+  LOGICAL :: lD
+  INTEGER :: is, nsec
+  lD = .FALSE.; IF(PRESENT(lDisp)) lD = lDisp
+  lerr = .FALSE.
+
+  !--- PARSE "type_trac" LIST AND DETERMINE THE TRACERS FILES NAMES (FOR CASE 3: MULTIPLE FILES, SINGLE SECTION PER FILE)
+  !--- If type_trac is a scalar (case 1), "sections" and "trac_files" are not usable, but are meaningless for case 1 anyway.
+  IF(test(strParse(type_trac, '|', sections,  n=nsec), lerr)) RETURN !--- Parse "type_trac" list
+  IF(PRESENT(sects)) sects = sections
+  ALLOCATE(trac_files(nsec)); DO is=1, nsec; trac_files(is) = 'tracer_'//TRIM(sections(is))//'.def'; END DO
+  IF(PRESENT(tracf)) tracf = trac_files
+  ll = .NOT.testFile(trac_files)
+  fType = 0
+  IF(.NOT.testFile('traceur.def')) fType = 1                         !--- OLD STYLE FILE
+  IF(.NOT.testFile('tracer.def'))  fType = 2                         !--- NEW STYLE ; SINGLE  FILE, SEVERAL SECTIONS
+  IF(ALL(ll))                      fType = 3                         !--- NEW STYLE ; SEVERAL FILES, SINGLE SECTION USED
+  IF(.NOT.lD) RETURN                                                 !--- NO CHECKING/DISPLAY NEEDED: JUST GET type_trac,fType
+  IF(ANY(ll) .AND. fType/=3) THEN                                    !--- MISSING FILES
+    IF(test(checkList(trac_files, .NOT.ll, 'Failed reading tracers description', 'files', 'missing'), lerr)) RETURN
+  END IF
+
+  !--- TELLS WHAT WAS IS ABOUT TO BE USED
+  CALL msg('Trying to read old-style tracers description file "traceur.def"',                      modname, fType==1)
+  CALL msg('Trying to read the new style multi-sections tracers description file "tracer.def"',    modname, fType==2)
+  CALL msg('Trying to read the new style single section tracers description files "tracer_*.def"', modname, fType==3)
+END FUNCTION testTracersFiles
+!==============================================================================================================================
+
 !==============================================================================================================================
 LOGICAL FUNCTION feedDBase(fnames, snames, modname) RESULT(lerr)
-! Purpose: Read the sections "snames(is)" (coma-separated list) from each "fnames(is)"
+! Purpose: Read the sections "snames(is)" (pipe-separated list) from each "fnames(is)"
 !   file and create the corresponding tracers set descriptors in the database "dBase":
 ! * dBase(id)%name                : section name
@@ -201,9 +330,8 @@
 !------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=*), INTENT(IN)  :: fnames(:)                         !--- Files names
-  CHARACTER(LEN=*), INTENT(IN)  :: snames(:)                         !--- Coma-deparated list of sections (one list each file)
+  CHARACTER(LEN=*), INTENT(IN)  :: snames(:)                         !--- Pipe-deparated list of sections (one list each file)
   CHARACTER(LEN=*), INTENT(IN)  :: modname                           !--- Calling routine name
   INTEGER,  ALLOCATABLE :: ndb(:)                                    !--- Number of sections for each file
   INTEGER,  ALLOCATABLE :: ixf(:)                                    !--- File index for each section of the expanded list
-  LOGICAL,  ALLOCATABLE :: lTg(:)                                    !--- Tagging tracers mask
   CHARACTER(LEN=maxlen) :: fnm, snm
   INTEGER               :: idb, i
@@ -211,5 +339,5 @@
 !------------------------------------------------------------------------------------------------------------------------------
   !=== READ THE REQUIRED SECTIONS
-  ll = strCount(snames, ',', ndb)                                    !--- Number of sections for each file
+  ll = strCount(snames, '|', ndb)                                    !--- Number of sections for each file
   ALLOCATE(ixf(SUM(ndb)))
   DO i=1, SIZE(fnames)                                               !--- Set %name, %keys
@@ -223,5 +351,5 @@
     lerr = ANY([(dispTraSection('RAW CONTENT OF SECTION "'//TRIM(snm)//'"', snm, modname), idb=1, SIZE(dBase))])
     IF(test(expandSection(dBase(idb)%trac, snm, fnm), lerr)) RETURN  !--- EXPAND NAMES ;  set %parent, %type, %component
-    CALL setGeneration   (dBase(idb)%trac)                           !---                 set %iGeneration,   %genOName
+    IF(test(setGeneration(dBase(idb)%trac),           lerr)) RETURN  !---                 set %iGeneration,   %genOName
     IF(test(checkTracers (dBase(idb)%trac, snm, fnm), lerr)) RETURN  !--- CHECK ORPHANS AND PHASES
     IF(test(checkUnique  (dBase(idb)%trac, snm, fnm), lerr)) RETURN  !--- CHECK TRACERS UNIQUENESS
@@ -239,5 +367,5 @@
 !------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=*),           INTENT(IN) :: fnam                     !--- File name
-  CHARACTER(LEN=*),           INTENT(IN) :: snam                     !--- Coma-separated sections list
+  CHARACTER(LEN=*),           INTENT(IN) :: snam                     !--- Pipe-separated sections list
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: defName                  !--- Special section (default values) name
 !------------------------------------------------------------------------------------------------------------------------------
@@ -245,5 +373,5 @@
   CHARACTER(LEN=maxlen), ALLOCATABLE :: sec(:)
   INTEGER,               ALLOCATABLE ::  ix(:)
-  INTEGER :: n0, idb, ndb, i, j
+  INTEGER :: n0, idb, ndb
   LOGICAL :: ll
 !------------------------------------------------------------------------------------------------------------------------------
@@ -254,5 +382,5 @@
     DO idb=n0,ndb; CALL addDefault(dBase(idb)%trac, defName); END DO !--- and remove the virtual tracer "defName"
   END IF
-  ll = strParse(snam, ',', keys = sec)                               !--- Requested sections names
+  ll = strParse(snam, '|', keys = sec)                               !--- Requested sections names
   ix = strIdx(dBase(:)%name, sec(:))                                 !--- Indexes of requested sections in database
   IF(test(checkList(sec, ix == 0, 'In file "'//TRIM(fnam)//'"','section(s)', 'missing'), lerr)) RETURN
@@ -267,5 +395,5 @@
   TYPE(trac_type),       ALLOCATABLE :: tt(:)
   TYPE(trac_type)       :: tmp
-  CHARACTER(LEN=1024)   :: str
+  CHARACTER(LEN=1024)   :: str, str2
   CHARACTER(LEN=maxlen) :: secn
   INTEGER               :: ierr, n
@@ -273,5 +401,13 @@
   IF(.NOT.ALLOCATED(dBase)) ALLOCATE(dBase(0))
   OPEN(90, FILE=fnam, FORM='formatted', STATUS='old')
-  DO; READ(90,'(a)', IOSTAT=ierr)str
+  DO; str=''
+    DO
+      READ(90,'(a)', IOSTAT=ierr)str2                                !--- Read a full line
+      str=TRIM(str)//' '//TRIM(str2)                                 !--- Append "str" with the current line
+      n=LEN_TRIM(str); IF(n == 0) EXIT                               !--- Empty line (probably end of file)
+      IF(IACHAR(str(n:n))  /= 92) EXIT                               !--- No "\" continuing line symbol found => end of line
+      str = str(1:n-1)                                               !--- Remove the "\" continuing line symbol
+    END DO
+    str = ADJUSTL(str)                                               !--- Remove the front space
     IF(ierr    /= 0 ) EXIT                                           !--- Finished: error or end of file
     IF(str(1:1)=='#') CYCLE                                          !--- Skip comments lines
@@ -290,5 +426,5 @@
       CALL MOVE_ALLOC(FROM=tdb, TO=dBase)
     ELSE                                                             !=== TRACER LINE
-      ll = strParse(str,' ', keys = s, vals = v, n = n)              !--- Parse <key>=<val> pairs
+      ll = strParse(str,' ', s, n, v)                                !--- Parse <key>=<val> pairs
       tt = dBase(ndb)%trac(:)
       tmp%name = s(1); tmp%keys = keys_type(s(1), s(2:n), v(2:n))    !--- Set %name and %keys
@@ -321,5 +457,6 @@
   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)
+!   CALL addKey_m(ky%key(k), ky%val(k), t(:)%keys, .FALSE.)           !--- Add key to all the tracers (no overwriting)
+    DO it = 1, SIZE(t); CALL addKey_1(ky%key(k), ky%val(k), t(it)%keys, .FALSE.); END DO
   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"
@@ -371,5 +508,5 @@
   CHARACTER(LEN=maxlen), ALLOCATABLE :: ta(:), pa(:)
   CHARACTER(LEN=maxlen) :: msg1, modname
-  INTEGER :: it, nt, iq, nq, itr, ntr, ipr, npr, i
+  INTEGER :: it, nt, iq, nq, itr, ntr, ipr, npr
   LOGICAL :: ll
   modname = 'expandSection'
@@ -384,4 +521,6 @@
     tr(it)%type      = fgetKey(it, 'type'  , tr(:)%keys, 'tracer')
     tr(it)%component = sname
+!   CALL addKey_m('component', sname, tr(:)%keys)
+    DO iq=1,SIZE(tr); CALL addKey_1('component', sname, tr(iq)%keys); END DO
 
     !--- Determine the number of tracers and parents ; coherence checking
@@ -399,5 +538,4 @@
   END DO
   !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-  CALL delKey(['parent','type  '], tr)
 
   ALLOCATE(ttr(nq))
@@ -406,20 +544,18 @@
   DO it = 1, nt                                                      !=== EXPAND TRACERS AND PARENTS NAMES LISTS
   !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-    ll = strParse(tr(it)%name,   ',', ta, n=ntr)                     !--- Number of tracers
-    ll = strParse(tr(it)%parent, ',', pa, n=npr)                     !--- Number of parents
+    ll = strParse(tr(it)%name,   ',', ta, ntr)                       !--- Number of tracers
+    ll = strParse(tr(it)%parent, ',', pa, npr)                       !--- Number of parents
     DO ipr=1,npr                                                     !--- Loop on parents list elts
       DO itr=1,ntr                                                   !--- Loop on tracers list elts
-        i = iq+itr-1+(ipr-1)*ntr
-        ttr(i)%name   = TRIM(ta(itr))
-        ttr(i)%parent = TRIM(pa(ipr))
-        ttr(i)%keys%name = ta(itr)
-        ttr(i)%keys%key  = tr(it)%keys%key
-        ttr(i)%keys%val  = tr(it)%keys%val
-!        ttr(i)%keys   = keys_type(ta(itr), tr(it)%keys%key, tr(it)%keys%val)
+        ttr(iq)%keys%key  = tr(it)%keys%key
+        ttr(iq)%keys%val  = tr(it)%keys%val
+        ttr(iq)%keys%name = ta(itr)
+        ttr(iq)%name      = TRIM(ta(itr));    CALL addKey_1('name',      ta(itr),          ttr(iq)%keys)
+        ttr(iq)%parent    = TRIM(pa(ipr));    CALL addKey_1('parent',    pa(ipr),          ttr(iq)%keys)
+        ttr(iq)%type      = tr(it)%type;      CALL addKey_1('type',      tr(it)%type,      ttr(iq)%keys)
+        ttr(iq)%component = tr(it)%component; CALL addKey_1('component', tr(it)%component, ttr(iq)%keys)
+        iq = iq+1
       END DO
     END DO
-    ttr(iq:iq+ntr*npr-1)%type      = tr(it)%type                     !--- Duplicating type
-    ttr(iq:iq+ntr*npr-1)%component = tr(it)%component                !--- Duplicating type
-    iq = iq + ntr*npr
   !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   END DO
@@ -431,33 +567,33 @@
 !==============================================================================================================================
 
-!==============================================================================================================================
-SUBROUTINE setGeneration(tr)
+
+!==============================================================================================================================
+LOGICAL FUNCTION setGeneration(tr) RESULT(lerr)
 !------------------------------------------------------------------------------------------------------------------------------
 ! Purpose: Determine, for each tracer of "tr(:)":
 !   * %iGeneration: the generation number 
 !   * %gen0Name:    the generation 0 ancestor name
+!          Check also for orphan tracers (tracers not descending on "tran0").
 !------------------------------------------------------------------------------------------------------------------------------
   TYPE(trac_type),     INTENT(INOUT) :: tr(:)                        !--- Tracer derived type vector
-  INTEGER                            :: iq, nq, ig
-  LOGICAL,               ALLOCATABLE :: lg(:)
-  CHARACTER(LEN=maxlen), ALLOCATABLE :: prn(:)
-!------------------------------------------------------------------------------------------------------------------------------
-  tr(:)%iGeneration = -1                                             !--- error if -1
-  nq = SIZE(tr, DIM=1)                                               !--- Number of tracers lines
-  lg = tr(:)%parent == tran0                                         !--- Flag for generation 0 tracers
-  WHERE(lg) tr(:)%iGeneration = 0                                    !--- Generation 0 tracers
-
-  !=== Determine generation for each tracer
-  ig=-1; prn = [tran0]
-  DO                                                                 !--- Update current generation flag
-    IF(ig/=-1) prn = PACK( tr(:)%name, MASK=tr(:)%iGeneration == ig)
-    lg(:) = [(ANY(prn(:) == tr(iq)%parent), iq=1, nq)]               !--- Current generation tracers flag
-    IF( ALL( .NOT. lg ) ) EXIT                                       !--- Empty current generation
-    ig = ig+1; WHERE(lg) tr(:)%iGeneration = ig
-  END DO
-  tr(:)%gen0Name = ancestor(tr)                                      !--- First generation ancestor name
-
-END SUBROUTINE setGeneration
-!==============================================================================================================================
+  INTEGER                            :: iq, jq, ig
+  CHARACTER(LEN=maxlen), ALLOCATABLE :: parent(:)
+!------------------------------------------------------------------------------------------------------------------------------
+  CHARACTER(LEN=maxlen) :: modname
+  modname = 'setGeneration'
+  IF(test(fmsg('missing "parent" attribute', modname, getKey('parent', parent, ky=tr(:)%keys)), lerr)) RETURN
+  DO iq = 1, SIZE(tr)
+    jq = iq; ig = 0
+    DO WHILE(parent(jq) /= tran0)
+      jq = strIdx(tr(:)%name, parent(jq))
+      IF(test(fmsg('Orphan tracer "'//TRIM(tr(iq)%name)//'"', modname, jq == 0), lerr)) RETURN
+      ig = ig + 1
+    END DO
+    tr(iq)%gen0Name = tr(jq)%name; CALL addKey_1('gen0Name',    tr(iq)%gen0Name,   tr(iq)%keys)
+    tr(iq)%iGeneration = ig;       CALL addKey_1('iGeneration', TRIM(int2str(ig)), tr(iq)%keys)
+  END DO
+END FUNCTION setGeneration
+!==============================================================================================================================
+
 
 !==============================================================================================================================
@@ -493,4 +629,5 @@
 END FUNCTION checkTracers
 !==============================================================================================================================
+
 
 !==============================================================================================================================
@@ -533,4 +670,5 @@
 !==============================================================================================================================
 
+
 !==============================================================================================================================
 SUBROUTINE expandPhases(tr)
@@ -542,8 +680,8 @@
   TYPE(trac_type), ALLOCATABLE :: ttr(:)
   INTEGER,   ALLOCATABLE ::  i0(:)
-  CHARACTER(LEN=maxlen)  :: nam, pha, trn
+  CHARACTER(LEN=maxlen)  :: nam, pha, tname
   CHARACTER(LEN=1) :: p
   INTEGER :: ip, np, iq, jq, nq, it, nt, nc, i, n
-  LOGICAL :: lTg, lEx
+  LOGICAL :: lTag, lExt
 !------------------------------------------------------------------------------------------------------------------------------
   nq = SIZE(tr, DIM=1)
@@ -551,7 +689,7 @@
   DO iq = 1, nq                                                      !--- GET THE NUMBER OF TRACERS
     IF(tr(iq)%iGeneration /= 0) CYCLE                                !--- Only deal with generation 0 tracers
-    nc = COUNT(tr(:)%gen0Name==tr(iq)%name .AND. tr%iGeneration/=0)  !--- Number of childs of tr(iq)
-    tr(iq)%phase = fgetKey(iq, 'phases', tr(:)%keys)                 !--- Phases list      of tr(iq)
-    np = LEN_TRIM(tr(iq)%phase)                                      !--- Number of phases of tr(iq)
+    nc = COUNT(tr(:)%gen0Name==tr(iq)%name .AND. tr%iGeneration/=0)  !--- Number of children of tr(iq)
+    tr(iq)%phase = fgetKey(iq, 'phases', tr(:)%keys)                 !--- Phases list        of tr(iq)
+    np = LEN_TRIM(tr(iq)%phase)                                      !--- Number of phases   of tr(iq)
     nt = nt + (1+nc) * np                                            !--- Number of tracers after expansion
   END DO
@@ -559,9 +697,9 @@
   it = 1                                                             !--- Current "ttr(:)" index
   DO iq = 1, nq                                                      !--- Loop on "tr(:)" indexes
-    lTg = tr(iq)%type=='tag'                                         !--- Current tracer is a tag
+    lTag = tr(iq)%type=='tag'                                        !--- Current tracer is a tag
     i0 = strFind(tr(:)%name, TRIM(tr(iq)%gen0Name), n)               !--- Indexes of first generation ancestor copies
     np = SUM([( LEN_TRIM(tr(i0(i))%phase),i=1,n )], 1)               !--- Number of phases for current tracer tr(iq)
-    lEx = np>1                                                       !--- Phase suffix only required if phases number is > 1
-    IF(lTg) lEx = lEx .AND. tr(iq)%iGeneration>0                     !--- No phase suffix for generation 0 tags
+    lExt = np>1                                                      !--- Phase suffix only required if phases number is > 1
+    IF(lTag) lExt = lExt .AND. tr(iq)%iGeneration>0                  !--- No phase suffix for generation 0 tags
     DO i=1,n                                                         !=== LOOP ON GENERATION 0 ANCESTORS
       jq = i0(i)                                                     !--- tr(jq): ith tracer with same gen 0 ancestor as tr(iq)
@@ -570,15 +708,19 @@
       DO ip = 1, LEN_TRIM(pha)                                       !=== LOOP ON PHASES LISTS
         p = pha(ip:ip)
-        trn = TRIM(tr(iq)%name); nam = trn                           !--- Tracer name (regular case)
-        IF(lTg) nam = TRIM(tr(iq)%parent)                            !--- Parent name (tagging case)
-        IF(lEx) nam = addPhase(nam, p )                              !--- Phase extension needed
-        IF(lTg) nam = TRIM(nam)//'_'//TRIM(trn)                      !--- <parent>_<name> for tags
+        tname = TRIM(tr(iq)%name); nam = tname                       !--- Tracer name (regular case)
+        IF(lTag) nam = TRIM(tr(iq)%parent)                           !--- Parent name (tagging case)
+        IF(lExt) nam = addPhase(nam, p )                             !--- Phase extension needed
+        IF(lTag) nam = TRIM(nam)//'_'//TRIM(tname)                   !--- <parent>_<name> for tags
         ttr(it) = tr(iq)                                             !--- Same <key>=<val> pairs
         ttr(it)%name      = TRIM(nam)                                !--- Name with possibly phase suffix
         ttr(it)%keys%name = TRIM(nam)                                !--- Name inside the keys decriptor
         ttr(it)%phase     = p                                        !--- Single phase entry
-        IF(lEx .AND. tr(iq)%iGeneration>0) THEN
-          ttr(it)%parent   = addPhase(ttr(it)%parent,   p)
-          ttr(it)%gen0Name = addPhase(ttr(it)%gen0Name, p)
+        CALL addKey_1('name', nam, ttr(it)%keys)
+        CALL addKey_1('phase', p,  ttr(it)%keys)
+        IF(lExt .AND. tr(iq)%iGeneration>0) THEN
+          ttr(it)%parent   = addPhase(tr(iq)%parent,   p)
+          ttr(it)%gen0Name = addPhase(tr(iq)%gen0Name, p)
+          CALL addKey_1('parent',   ttr(it)%parent,   ttr(it)%keys)
+          CALL addKey_1('gen0Name', ttr(it)%gen0Name, ttr(it)%keys)
         END IF
         it = it+1
@@ -593,4 +735,5 @@
 !==============================================================================================================================
 
+
 !==============================================================================================================================
 SUBROUTINE sortTracers(tr)
@@ -599,10 +742,13 @@
 !  * Put water at the beginning of the vector, in the "known_phases" order.
 !  * lGrowGen == T: in ascending generations numbers.
-!  * lGrowGen == F: tracer + its childs sorted by growing generation, one after the other.
+!  * lGrowGen == F: tracer + its children sorted by growing generation, one after the other.
 !   TO BE ADDED IF NECESSARY: HIGHER MOMENTS AT THE END
 !------------------------------------------------------------------------------------------------------------------------------
   TYPE(trac_type), ALLOCATABLE, INTENT(INOUT) :: tr(:)         !--- Tracer derived type vector
-  INTEGER,         ALLOCATABLE :: iy(:), iz(:)
-  INTEGER :: ig, ng, iq, jq, ip, nq, n, ix(SIZE(tr)), k
+!------------------------------------------------------------------------------------------------------------------------------
+  TYPE(trac_type), ALLOCATABLE        :: tr2(:)
+  INTEGER,         ALLOCATABLE        :: iy(:), iz(:)
+  INTEGER                             :: ig, ng, iq, jq, ip, nq, n, ix(SIZE(tr)), k
+!  tr2 is introduced in order to cope with a bug in gfortran 4.8.5 compiler
 !------------------------------------------------------------------------------------------------------------------------------
   nq = SIZE(tr)
@@ -610,5 +756,6 @@
     iq = strIdx(tr(:)%name, addPhase('H2O', ip))
     IF(iq == 0) CYCLE
-    tr = [tr(iq), tr(1:iq-1), tr(iq+1:nq)]
+    tr2 = tr(:)
+    tr = [tr2(iq), tr2(1:iq-1), tr2(iq+1:nq)]
   END DO
   IF(lSortByGen) THEN
@@ -627,5 +774,5 @@
       ix(iq) = jq                                                    !--- Generation 0 ancestor index first
       iq = iq + 1                                                    !--- Next "iq" for next generations tracers
-      iy = strFind(tr(:)%gen0Name, TRIM(tr(jq)%name))                !--- Indexes of "tr(jq)" childs in "tr(:)"
+      iy = strFind(tr(:)%gen0Name, TRIM(tr(jq)%name))                !--- Indexes of "tr(jq)" children in "tr(:)"
       ng = MAXVAL(tr(iy)%iGeneration, MASK=.TRUE., DIM=1)            !--- Number of generations of the "tr(jq)" family
       DO ig = 1, ng                                                  !--- Loop   on generations of the "tr(jq)" family
@@ -639,4 +786,5 @@
 END SUBROUTINE sortTracers
 !==============================================================================================================================
+
 
 !==============================================================================================================================
@@ -714,5 +862,5 @@
   TYPE(dataBase_type),  TARGET, INTENT(IN)  :: sections(:)
   TYPE(trac_type), ALLOCATABLE, INTENT(OUT) ::       tr(:)
-  TYPE(trac_type), POINTER     :: t1(:), t2(:)
+  TYPE(trac_type), POINTER     :: t(:)
   INTEGER,   ALLOCATABLE :: nt(:)
   CHARACTER(LEN=maxlen)  :: tnam, tnam_new
@@ -725,10 +873,10 @@
   DO is=1, nsec                                                      !=== LOOP ON SECTIONS
   !----------------------------------------------------------------------------------------------------------------------------
-    t1 => sections(is)%trac(:)
+    t => sections(is)%trac(:)
     !--------------------------------------------------------------------------------------------------------------------------
     DO iq=1, nt(is)                                                  !=== LOOP ON TRACERS
     !--------------------------------------------------------------------------------------------------------------------------
-      tnam = TRIM(t1(iq)%name)                                       !--- Original name
-      IF(COUNT(t1%name == tnam) == 1) CYCLE                          !--- Current tracer is not duplicated: finished
+      tnam = TRIM(t(iq)%name)                                        !--- Original name
+      IF(COUNT(t%name == tnam) == 1) CYCLE                           !--- Current tracer is not duplicated: finished
       tnam_new = TRIM(tnam)//'_'//TRIM(sections(is)%name)            !--- Same with section extension
       nq = SUM(nt(1:is-1))                                           !--- Number of tracers in previous sections
@@ -749,5 +897,5 @@
   TYPE(trac_type), INTENT(INOUT) :: tr(:)
 
-  !--- Update %iqParent, %iqDescen, %nqDescen, %nqChilds
+  !--- Update %iqParent, %iqDescen, %nqDescen, %nqChildren
   CALL indexUpdate(tr)
 
@@ -764,5 +912,5 @@
   INTEGER :: idb, iq, nq
   INTEGER, ALLOCATABLE :: hadv(:), vadv(:)
-  CHARACTER(LEN=maxlen), ALLOCATABLE :: phas(:)
+  CHARACTER(LEN=maxlen), ALLOCATABLE :: phas(:), prnt(:)
   TYPE(trac_type), POINTER :: tm(:)
   lerr = .FALSE.
@@ -772,17 +920,20 @@
   !--- BEWARE ! Can't use the "getKeyByName" functions yet.
   !             Names must first include the phases for tracers defined on multiple lines.
-  hadv = str2int([(fgetKey(iq, 'hadv',  tm(:)%keys, '10'), iq=1, nq)])
-  vadv = str2int([(fgetKey(iq, 'vadv',  tm(:)%keys, '10'), iq=1, nq)])
-  phas =         [(fgetKey(iq, 'phases',tm(:)%keys, 'g' ), iq=1, nq)]
+  hadv = str2int(fgetKeys('hadv',  tm(:)%keys, '10'))
+  vadv = str2int(fgetKeys('vadv',  tm(:)%keys, '10'))
+  prnt =         fgetKeys('parent',tm(:)%keys,  '' )
+  IF(getKey('phases', phas, ky=tm(:)%keys)) phas = fGetKeys('phase', tm(:)%keys, 'g')
   CALL msg(TRIM(message)//':', modname)
-  IF(tm(1)%parent == '') THEN
-    IF(test(dispTable('iiiss',   ['iq    ','hadv  ','vadv  ','name  ','phase '], cat(tm%name, phas), cat([(iq, iq=1, nq)], &
-                                            hadv,    vadv),                 sub=modname), lerr)) RETURN
+  IF(ALL(prnt == 'air')) THEN
+    IF(test(dispTable('iiiss',   ['iq    ','hadv  ','vadv  ','name  ','phase '],                   cat(tm%name,       phas),  &
+                 cat([(iq, iq=1, nq)], hadv, vadv),                 nColMax=maxTableWidth, nHead=2, sub=modname), lerr)) RETURN
+  ELSE IF(ALL(tm%iGeneration == -1)) THEN
+    IF(test(dispTable('iiisss', ['iq    ','hadv  ','vadv  ','name  ','parent','phase '],           cat(tm%name, prnt, phas),  &
+                 cat([(iq, iq=1, nq)], hadv, vadv),                 nColMax=maxTableWidth, nHead=2, sub=modname), lerr)) RETURN
   ELSE
-    IF(test(dispTable('iiissis', ['iq    ','hadv  ','vadv  ','name  ','parent','igen  ','phase '], cat(tm%name, tm%parent, &
-           tm%phase), cat([(iq, iq=1, nq)], hadv,    vadv, tm%iGeneration), sub=modname), lerr)) RETURN
+    IF(test(dispTable('iiissis', ['iq    ','hadv  ','vadv  ','name  ','parent','igen  ','phase '], cat(tm%name, prnt, phas),  &
+                 cat([(iq, iq=1, nq)], hadv, vadv, tm%iGeneration), nColMax=maxTableWidth, nHead=2, sub=modname), lerr)) RETURN
   END IF
 END FUNCTION dispTraSection
-!==============================================================================================================================
 !==============================================================================================================================
 
@@ -799,5 +950,5 @@
   out => NULL(); IF(it /= 0) out => t(it)
 END FUNCTION aliasTracer
-!------------------------------------------------------------------------------------------------------------------------------
+!==============================================================================================================================
 
 
@@ -820,5 +971,5 @@
   CALL indexUpdate(out)
 END FUNCTION trSubset_Name
-!------------------------------------------------------------------------------------------------------------------------------
+!==============================================================================================================================
 
 
@@ -833,5 +984,5 @@
   CALL indexUpdate(out)
 END FUNCTION trSubset_gen0Name
-!------------------------------------------------------------------------------------------------------------------------------
+!==============================================================================================================================
 
 
@@ -841,7 +992,7 @@
 SUBROUTINE indexUpdate(tr)
   TYPE(trac_type), INTENT(INOUT) :: tr(:)
-  INTEGER :: iq, ig, ng, igen, ngen
-  INTEGER, ALLOCATABLE :: ix(:)
+  INTEGER :: iq, ig, igen, ngen, ix(SIZE(tr))
   tr(:)%iqParent = strIdx( tr(:)%name, tr(:)%parent )                !--- Parent index
+  DO iq = 1, SIZE(tr); CALL addKey_1('iqParent', int2str(tr(iq)%iqParent), tr(iq)%keys); END DO
   ngen = MAXVAL(tr(:)%iGeneration, MASK=.TRUE.)
   DO iq = 1, SIZE(tr)
@@ -849,13 +1000,18 @@
     IF(ALLOCATED(tr(iq)%iqDescen)) DEALLOCATE(tr(iq)%iqDescen)
     ALLOCATE(tr(iq)%iqDescen(0))
-    ix = idxAncestor(tr, igen=ig)                                    !--- Ancestor of generation "ng" for each tr
+    CALL idxAncestor(tr, ix, ig)                                     !--- Ancestor of generation "ng" for each tr
     DO igen = ig+1, ngen
       tr(iq)%iqDescen = [tr(iq)%iqDescen, find(ix==iq .AND. tr%iGeneration==igen)]
       tr(iq)%nqDescen = SIZE(tr(iq)%iqDescen)
-      IF(igen == ig+1) tr(iq)%nqChilds=tr(iq)%nqDescen
+      IF(igen == ig+1) THEN
+        tr(iq)%nqChildren = tr(iq)%nqDescen
+        CALL addKey_1('nqChildren', int2str(tr(iq)%nqChildren), tr(iq)%keys)
+      END IF
     END DO
+    CALL addKey_1('iqDescen', strStack(int2str(tr(iq)%iqDescen)), tr(iq)%keys)
+    CALL addKey_1('nqDescen',          int2str(tr(iq)%nqDescen) , tr(iq)%keys)
   END DO
 END SUBROUTINE indexUpdate
-!------------------------------------------------------------------------------------------------------------------------------
+!==============================================================================================================================
   
   
@@ -865,6 +1021,6 @@
 !===  * 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):                             ====
-!===      parent,  nzone, zone(:),  niso, keys(:)%name,  ntiso, trac(:),  nphas, phas,  iqTraPha(:,:),  itZonPhi(:,:)      ====
+!===  * Most of the "isot" components have been defined in the calling routine (readIsotopes):                             ====
+!===      parent,  nzone, zone(:),  niso, keys(:)%name,  ntiso, trac(:),  nphas, phas,  iqIsoPha(:,:),  itZonPhi(:,:)      ====
 !===  * 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             ====
@@ -873,16 +1029,12 @@
 !===  * 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)
+LOGICAL FUNCTION readIsotopesFile_prv(fnam, isot) RESULT(lerr)
   CHARACTER(LEN=*),        INTENT(IN)    :: fnam                     !--- Input file name
-  TYPE(isot_type), TARGET, INTENT(INOUT) :: isot(:)                  !--- Isotopes descriptors (field "prnt" must be defined !)
-  INTEGER :: ik, is, it, idb, nk0, i, iis
-  INTEGER :: nk, ns, nt, ndb, nb0, i0
-  CHARACTER(LEN=maxlen), POINTER     :: k(:), v(:), k0(:), v0(:)
+  TYPE(isot_type), TARGET, INTENT(INOUT) :: isot(:)                  !--- Isotopes descriptors (field %parent must be defined!)
+  INTEGER :: is, iis, it, idb, ndb, nb0
   CHARACTER(LEN=maxlen), ALLOCATABLE :: vals(:)
-  CHARACTER(LEN=maxlen)              :: val, modname
-  TYPE(keys_type),           POINTER ::   ky(:)
+  CHARACTER(LEN=maxlen)              :: modname
   TYPE(trac_type),           POINTER ::   tt(:), t
   TYPE(dataBase_type),   ALLOCATABLE ::  tdb(:)
-  LOGICAL,               ALLOCATABLE :: liso(:)
   modname = 'readIsotopesFile'
 
@@ -892,8 +1044,8 @@
   !--- READ THE FILE SECTIONS, ONE EACH PARENT TRACER
   nb0 = SIZE(dBase, DIM=1)+1                                         !--- Next database element index
-  IF(test(readSections(fnam,strStack(isot(:)%parent,',')),lerr)) RETURN !--- Read sections, one each parent tracer
+  IF(test(readSections(fnam,strStack(isot(:)%parent,'|')),lerr)) RETURN !--- Read sections, one each parent tracer
   ndb = SIZE(dBase, DIM=1)                                           !--- Current database size
   DO idb = nb0, ndb
-   iis = idb-nb0+1
+    iis = idb-nb0+1
 
     !--- GET FEW GLOBAL KEYS FROM "def" FILES AND ADD THEM TO THE 'params' SECTION
@@ -910,14 +1062,12 @@
       is = strIdx(isot(iis)%keys(:)%name, t%name)                    !--- Index in "isot(iis)%keys(:)%name" of isotope "t%name"
       IF(is == 0) CYCLE
-      liso = reduceExpr(t%keys%val, vals)                            !--- Reduce expressions (for substituted variables)
-      IF(test(ANY(liso), lerr)) RETURN                               !--- Some non-numerical elements were found
-      isot(iis)%keys(is)%key = PACK(t%keys%key, MASK=.NOT.liso)
-      isot(iis)%keys(is)%val = PACK(  vals,     MASK=.NOT.liso)
+      IF(test(ANY(reduceExpr(t%keys%val, vals)), lerr)) RETURN       !--- Reduce expressions ; detect non-numerical elements
+      isot(iis)%keys(is)%key = t%keys%key
+      isot(iis)%keys(is)%val = vals
     END DO
 
     !--- CHECK FOR MISSING ISOTOPES (NO KEYS ALLOCATED)
-    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
+    IF(test(checkList(isot(iis)%keys(:)%name, .NOT.[( ALLOCATED(isot(iis)%keys(is)%key), is=1, SIZE(isot(iis)%keys) )], &
+      'Check file "'//TRIM(fnam)//'" in section "'//TRIM(dBase(idb)%name)//'"', 'isotopes', 'missing'), lerr)) RETURN
   END DO
 
@@ -932,8 +1082,36 @@
   CALL get_in('ok_iso_verif', isot(strIdx(isot%parent, 'H2O'))%check, .FALSE.)
 
-  lerr = dispIsotopes(isot, 'Isotopes parameters read from file', modname)
-
-END FUNCTION readIsotopesFile
-!==============================================================================================================================
+  lerr = dispIsotopes()
+
+CONTAINS
+
+!------------------------------------------------------------------------------------------------------------------------------
+LOGICAL FUNCTION dispIsotopes() RESULT(lerr)
+  INTEGER :: ik, nk, ip, it, nt
+  CHARACTER(LEN=maxlen) :: prf
+  CHARACTER(LEN=maxlen), ALLOCATABLE :: ttl(:), val(:,:)
+  CALL msg('Isotopes parameters read from file "'//TRIM(fnam)//'":', modname)
+  DO ip = 1, SIZE(isot)                                              !--- Loop on parents tracers
+    nk = SIZE(isot(ip)%keys(1)%key)                                  !--- Same keys for each isotope
+    nt = SIZE(isot(ip)%keys)                                         !--- Number of isotopes
+    prf = 'i'//REPEAT('s',nk+1)                                      !--- Profile for table printing
+    ALLOCATE(ttl(nk+2), val(nt,nk+1))
+    ttl(1:2) = ['it  ','name']; ttl(3:nk+2) = isot(ip)%keys(1)%key(:)!--- Titles line with keys names
+    val(:,1) = isot(ip)%keys(:)%name                                 !--- Values table 1st column: isotopes names  
+    DO ik = 1, nk
+      DO it = 1, nt
+        val(it,ik+1) = isot(ip)%keys(it)%val(ik)                     !--- Other columns: keys values
+      END DO
+    END DO
+    IF(test(fmsg('Problem with the table content', modname, dispTable(prf, ttl, val, &
+            cat([(it,it=1,nt)]), rFmt='(EN8.4)', nColMax=maxTableWidth, nHead=2, sub=modname)), lerr)) RETURN
+    DEALLOCATE(ttl, val)
+  END DO        
+END FUNCTION dispIsotopes
+!------------------------------------------------------------------------------------------------------------------------------
+
+END FUNCTION readIsotopesFile_prv
+!==============================================================================================================================
+
 
 !==============================================================================================================================
@@ -941,33 +1119,44 @@
 !===    * COMPUTE MOST OF THE RELATED QUANTITIES ("isot" COMPONENTS).                                                       ===
 !===    * COMPUTE FEW ISOTOPES-DEDICATED "trac" COMPONENTS                                                                  ===
-!===    * CALL readIsotopesFile TO GET PHYSICAL QUANTITIES (<key>=<val> PAIRS)                                              ===
+!===    * CALL readIsotopesFile_prv 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(trac_type), ALLOCATABLE, TARGET, INTENT(INOUT) :: trac(:)
-  TYPE(isot_type), ALLOCATABLE, TARGET, INTENT(INOUT) :: isot(:)
+LOGICAL FUNCTION readIsotopesFile(iNames) RESULT(lerr)
+  CHARACTER(LEN=maxlen), TARGET, OPTIONAL, INTENT(IN)  :: iNames(:)
   CHARACTER(LEN=maxlen), ALLOCATABLE :: p(:), str(:)                 !--- Temporary storage
-  CHARACTER(LEN=maxlen) :: iname
+  CHARACTER(LEN=maxlen) :: iName, modname
   CHARACTER(LEN=1)   :: ph                                           !--- Phase
-  INTEGER :: nbIso, ic, ip, iq, it, iz
+  INTEGER :: ic, ip, iq, it, iz
   LOGICAL, ALLOCATABLE :: ll(:)                                      !--- Mask
   TYPE(trac_type), POINTER   ::  t(:), t1
   TYPE(isot_type), POINTER   ::  i
-
-  t => trac
-
-  p = PACK(delPhase(t%parent), MASK = t%type=='tracer' .AND. t%iGeneration==1) !--- Parents of generation 1 isotopes
+  lerr = .FALSE.
+  modname = 'readIsotopesFile'
+
+  t => tracers
+
+  !--- GET FROM "tracers" THE FULL LIST OF AVAILABLE ISOTOPES CLASSES
+  p = PACK(delPhase(t%parent), MASK = t%type=='tracer' .AND. t%iGeneration==1)
   CALL strReduce(p, nbIso)
-  ALLOCATE(isot(nbIso))
+
+  !--- CHECK WHETHER NEEDED ISOTOPES CLASSES "iNames" ARE AVAILABLE OR NOT
+  IF(PRESENT(iNames)) THEN
+    DO it = 1, SIZE(iNames)
+      IF(test(fmsg('No isotopes class "'//TRIM(iNames(it))//'" found among tracers', modname, ALL(p /= iNames(it))), lerr)) RETURN
+    END DO
+    p = iNames; nbIso = SIZE(p)
+  END IF
+  IF(ALLOCATED(isotopes)) DEALLOCATE(isotopes)
+  ALLOCATE(isotopes(nbIso))
 
   IF(nbIso==0) RETURN                                                !=== NO ISOTOPES: FINISHED
 
   !--- ISOTOPES RELATED VARIABLES ; NULL OR EMPTY IF NO ISOTOPES
-  isot(:)%parent = p
+  isotopes(:)%parent = p
   DO ic = 1, SIZE(p)                                                 !--- Loop on isotopes classes
-    i => isot(ic)
+    i => isotopes(ic)
     iname = i%parent                                                 !--- Current isotopes class name (parent tracer name)
 
-    !=== Isotopes childs of tracer "iname": mask, names, number (same for each phase of "iname")
+    !=== Isotopes children of tracer "iname": mask, names, number (same for each phase of "iname")
     ll = t(:)%type=='tracer' .AND. delPhase(t(:)%parent) == iname .AND. t(:)%phase == 'g'
     str = PACK(delPhase(t(:)%name), MASK = ll)                       !--- Effectively found isotopes of "iname"
@@ -978,13 +1167,13 @@
     !=== Geographic tagging tracers descending on tracer "iname": mask, names, number
     ll = t(:)%type=='tag'    .AND. delPhase(t(:)%gen0Name) == iname .AND. t(:)%iGeneration == 2
-    i%zone = PACK(strTail(t(:)%name,'_'), MASK = ll)                 !--- Tagging zones names  for isotopes category "iname"
+    i%zone = PACK(strTail(t(:)%name,'_',.TRUE.), MASK = ll)          !--- Tagging zones names  for isotopes category "iname"
     CALL strReduce(i%zone)
     i%nzone = SIZE(i%zone)                                           !--- Tagging zones number for isotopes category "iname"
 
-    !=== Geographic tracers of the isotopes childs of tracer "iname" (same for each phase of "iname")
+    !=== Geographic tracers of the isotopes children 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)
-    i%ntiso = i%niso + SIZE(str)                                     !--- Number of isotopes + their geographic tracers [ntraciso]
+    i%ntiso = i%niso + SIZE(str)                                     !--- Number of isotopes + their geographic tracers [ntiso]
     ALLOCATE(i%trac(i%ntiso))
     FORALL(it = 1:i%niso) i%trac(it) = i%keys(it)%name
@@ -998,9 +1187,9 @@
     !=== 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)
+      t1 => tracers(iq)
       IF(delPhase(t1%gen0Name)/=iname .OR. t1%iGeneration==0) CYCLE  !--- Only deal with tracers descending on "iname"
       t1%iso_iGroup = ic                                             !--- Isotopes family       idx in list "isotopes(:)%parent"
-      t1%iso_iName  = strIdx(i%trac, delPhase(strHead(t1%name,'_'))) !--- Current isotope       idx in effective isotopes list
-      t1%iso_iZone  = strIdx(i%zone,          strTail(t1%name,'_') ) !--- Current isotope zone  idx in effective zones    list
+      t1%iso_iName  = strIdx(i%trac, strHead(delPhase(t1%name),'_',.TRUE.)) !--- Current isotope       idx in effective isotopes list
+      t1%iso_iZone  = strIdx(i%zone,          strTail(t1%name, '_',.TRUE.)) !--- Current isotope zone  idx in effective zones    list
       t1%iso_iPhase =  INDEX(i%phase,TRIM(t1%phase))                 !--- Current isotope phase idx in effective phases   list
       IF(t1%iGeneration /= 2) t1%iso_iZone = 0                       !--- Skip possible generation 1 tagging tracers
@@ -1009,5 +1198,5 @@
     !=== 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
-    i%iqTraPha = RESHAPE( [( (strIdx(t%name,  addPhase(i%trac(it),i%phase(ip:ip))),    it=1, i%ntiso), ip=1, i%nphas)], &
+    i%iqIsoPha = RESHAPE( [( (strIdx(t%name,  addPhase(i%trac(it),i%phase(ip:ip))),       it=1, i%ntiso), ip=1, i%nphas)], &
                          [i%ntiso, i%nphas] )
     !=== Table used to get ix (index in tagging tracers isotopes list, size ntiso) from the zone and isotope indexes
@@ -1016,59 +1205,108 @@
   END DO
 
-  !=== 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
-!==============================================================================================================================
-
-
-!==============================================================================================================================
-LOGICAL FUNCTION dispIsotopes(ides, message, modname) RESULT(lerr)
-  TYPE(isot_type),  INTENT(IN) :: ides(:)                            !--- Isotopes descriptor vector
-  CHARACTER(LEN=*), INTENT(IN) :: message                            !--- Message to display
-  CHARACTER(LEN=*), INTENT(IN) :: modname                            !--- Calling subroutine name
-  INTEGER :: ik, nk, ip, it, nt
-  CHARACTER(LEN=maxlen) :: prf
-  CHARACTER(LEN=maxlen), ALLOCATABLE :: ttl(:), val(:,:)
-  CALL msg(TRIM(message)//':', modname)
-  DO ip = 1, SIZE(ides)                                              !--- Loop on parents tracers
-    nk = SIZE(ides(ip)%keys(1)%key)                                  !--- Same keys for each isotope
-    nt = SIZE(ides(ip)%keys)                                         !--- Number of isotopes
-    prf = 'i'//REPEAT('s',nk+1)                                      !--- Profile for table printing
-    ALLOCATE(ttl(nk+2), val(nt,nk+1))
-    ttl(1:2) = ['iq  ','name']; ttl(3:nk+2) = ides(ip)%keys(1)%key(:)!--- Titles line with keys names
-    val(:,1) = ides(ip)%keys(:)%name                                 !--- Values table 1st column: isotopes names  
-    DO ik = 1, nk
-      DO it = 1, nt
-        val(it,ik+1) = ides(ip)%keys(it)%val(ik)                     !--- Other columns: keys values
-      END DO
+  !=== READ PHYSICAL PARAMETERS FROM isoFile FILE
+  IF(test(readIsotopesFile_prv(isoFile, isotopes), lerr)) RETURN
+
+  !=== CHECK CONSISTENCY
+  IF(test(testIsotopes(), lerr)) RETURN
+
+  !=== SELECT FIRST ISOTOPES CLASS OR, IF POSSIBLE, WATER CLASS
+  IF(.NOT.test(isoSelect(1, .TRUE.), lerr)) THEN; IF(isotope%parent == 'H2O') iH2O = ixIso; END IF
+
+CONTAINS
+
+!------------------------------------------------------------------------------------------------------------------------------
+LOGICAL FUNCTION testIsotopes() RESULT(lerr)     !--- MAKE SURE MEMBERS OF AN ISOTOPES FAMILY ARE PRESENT IN THE SAME PHASES
+!------------------------------------------------------------------------------------------------------------------------------
+  INTEGER :: ix, it, ip, np, iz, nz
+  TYPE(isot_type), POINTER :: i
+  DO ix = 1, nbIso
+    i => isotopes(ix)
+    !--- Check whether each isotope and tagging isotopic tracer is present in the same number of phases
+    DO it = 1, i%ntiso
+      np = SUM([(COUNT(tracers(:)%name == addPhase(i%trac(it), i%phase(ip:ip))), ip=1, i%nphas)])
+      IF(test(fmsg(TRIM(int2str(np))//' phases instead of '//TRIM(int2str(i%nphas))//' for '//TRIM(i%trac(it)), &
+        modname, np /= i%nphas), lerr)) RETURN
     END DO
-    IF(test(fmsg('Problem with the table content', modname, dispTable(prf, ttl, val, cat([(it,it=1,nt)]), rFmt='(EN8.4)',     &
-       sub=modname)), lerr)) RETURN
-    DEALLOCATE(ttl, val)
-  END DO        
-END FUNCTION dispIsotopes
-!==============================================================================================================================
-
-
+    DO it = 1, i%niso
+      nz = SUM([(COUNT(i%trac == TRIM(i%trac(it))//'_'//i%zone(iz)), iz=1, i%nzone)])
+      IF(test(fmsg(TRIM(int2str(nz))//' tagging zones instead of '//TRIM(int2str(i%nzone))//' for '//TRIM(i%trac(it)), &
+        modname, nz /= i%nzone), lerr)) RETURN
+    END DO
+  END DO
+END FUNCTION testIsotopes
+!------------------------------------------------------------------------------------------------------------------------------
+
+END FUNCTION readIsotopesFile
+!==============================================================================================================================
+
+
+!==============================================================================================================================
+!=== 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)
+   IF(test(iIso == 0, lerr)) THEN
+      niso = 0; ntiso = 0; nzone = 0; nphas = 0; 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>SIZE(isotopes)
+   CALL msg('Inconsistent isotopes family index '//TRIM(int2str(iIso))//': should be > 0 and <= '&
+          //TRIM(int2str(SIZE(isotopes)))//'"', 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
+!==============================================================================================================================
+
+
+!==============================================================================================================================
+!=== ADD THE <key>=<val> PAIR TO THE "ky[(:)]" KEY[S] DESCRIPTOR[S] OR THE <key>=<val(:)> PAIRS TO THE "ky(:)" KEYS DESCRIPTORS
 !==============================================================================================================================
 SUBROUTINE addKey_1(key, val, ky, lOverWrite)
-!------------------------------------------------------------------------------------------------------------------------------
-! Purpose: Add the <key>=<val> pair in the "ky" keys descriptor.
-!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=*),  INTENT(IN)    :: key, val
   TYPE(keys_type),   INTENT(INOUT) :: ky
   LOGICAL, OPTIONAL, INTENT(IN)    :: lOverWrite
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen), ALLOCATABLE :: k(:), v(:)
   INTEGER :: iky, nky
   LOGICAL :: lo
-!------------------------------------------------------------------------------------------------------------------------------
-  lo=.FALSE.; IF(PRESENT(lOverWrite)) lo=lOverWrite
+  lo=.TRUE.; IF(PRESENT(lOverWrite)) lo=lOverWrite
+  IF(.NOT.ALLOCATED(ky%key)) THEN
+    ALLOCATE(ky%key(1)); ky%key(1)=key
+    ALLOCATE(ky%val(1)); ky%val(1)=val
+    RETURN
+  END IF
   iky = strIdx(ky%key,key)
   IF(iky == 0) THEN
     nky = SIZE(ky%key)
-    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
+    ALLOCATE(k(nky+1)); k(1:nky) = ky%key; k(nky+1) = key; ky%key = k
+    ALLOCATE(v(nky+1)); v(1:nky) = ky%val; v(nky+1) = val; ky%val = v
+  ELSE IF(lo) THEN
     ky%key(iky) = key; ky%val(iky) = val
   END IF
@@ -1076,23 +1314,32 @@
 !==============================================================================================================================
 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(keys_type),   INTENT(INOUT) :: ky(:)
   LOGICAL, OPTIONAL, INTENT(IN)    :: lOverWrite
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: itr
-  LOGICAL :: lo
-!------------------------------------------------------------------------------------------------------------------------------
-  lo=.FALSE.; IF(PRESENT(lOverWrite)) lo=lOverWrite
-  DO itr = 1, SIZE(ky); CALL addKey_1(key, val, ky(itr), lo); END DO
+  DO itr = 1, SIZE(ky)
+    CALL addKey_1(key, val, ky(itr), lOverWrite)
+  END DO
 END SUBROUTINE addKey_m
 !==============================================================================================================================
+SUBROUTINE addKey_mm(key, val, ky, lOverWrite)
+  CHARACTER(LEN=*),  INTENT(IN)    :: key, val(:)
+  TYPE(keys_type),   INTENT(INOUT) :: ky(:)
+  LOGICAL, OPTIONAL, INTENT(IN)    :: lOverWrite
+!------------------------------------------------------------------------------------------------------------------------------
+  INTEGER :: itr
+  DO itr = 1, SIZE(ky); CALL addKey_1(key, val(itr), ky(itr), lOverWrite); END DO
+END SUBROUTINE addKey_mm
+!==============================================================================================================================
+
+
+!==============================================================================================================================
+!=== OVERWRITE THE KEYS OF THE TRACER NAMED "tr0" WITH THE VALUES FOUND IN THE *.def FILES, IF ANY. ===========================
+!==============================================================================================================================
 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(trac_type), ALLOCATABLE, INTENT(INOUT) :: t(:)
   CHARACTER(LEN=*),             INTENT(IN)    :: tr0
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen) :: val
   INTEGER               :: ik, jd
@@ -1105,16 +1352,17 @@
 END SUBROUTINE addKeysFromDef
 !==============================================================================================================================
+
+
+!==============================================================================================================================
+!=== REMOVE THE KEYS NAMED "keyn(:)" FROM EITHER THE "itr"th OR ALL THE KEYS DESCRIPTORS OF "ky(:)" ===========================
+!==============================================================================================================================
 SUBROUTINE delKey_1(itr, keyn, ky)
-!------------------------------------------------------------------------------------------------------------------------------
-! Purpose: Internal routine.
-!   Remove <key>=<val> pairs in the "itr"th component of the "ky" keys descriptor.
-!------------------------------------------------------------------------------------------------------------------------------
   INTEGER,          INTENT(IN)    :: itr
   CHARACTER(LEN=*), INTENT(IN)    :: keyn(:)
   TYPE(trac_type),  INTENT(INOUT) :: ky(:)
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen), ALLOCATABLE :: k(:), v(:)
   LOGICAL,               ALLOCATABLE :: ll(:)
   INTEGER :: iky
-!------------------------------------------------------------------------------------------------------------------------------
   IF(itr<=0 .OR. itr>SIZE(ky, DIM=1)) RETURN                          !--- Index is out of range
   ll = [( ALL(keyn/=ky(itr)%keys%key(iky)), iky=1, SIZE(ky(itr)%keys%key) )]
@@ -1124,12 +1372,8 @@
 !==============================================================================================================================
 SUBROUTINE delKey(keyn, ky)
-!------------------------------------------------------------------------------------------------------------------------------
-! Purpose: Internal routine.
-!   Remove <key>=<val> pairs in all the components of the "t" tracers descriptor.
-!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=*), INTENT(IN)    :: keyn(:)
   TYPE(trac_type),  INTENT(INOUT) :: ky(:)
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: iky
-!------------------------------------------------------------------------------------------------------------------------------
   DO iky = 1, SIZE(ky); CALL delKey_1(iky, keyn, ky); END DO
 END SUBROUTINE delKey
@@ -1138,34 +1382,25 @@
 
 !==============================================================================================================================
-!=== PUBLIC ROUTINES: GET A KEY FROM A <key>=<val> LIST ; VECTORS, TRACER AND DATABASE VERSIONS ===============================
-!=== BEWARE !!! IF THE "ky" ARGUMENT IS NOT PRESENT, THEN THE VARIABLES "tracers" AND "isotopes" ARE USED. ====================
-!===     THEY ARE LOCAL TO THIS MODULE, SO MUST MUST BE INITIALIZED FIRST USING the "getKey_init" ROUTINE  ====================
-!==============================================================================================================================
-SUBROUTINE getKey_init(tracers_, isotopes_)
-  TYPE(trac_type), OPTIONAL, INTENT(IN) ::  tracers_(:)
-  TYPE(isot_type), OPTIONAL, INTENT(IN) :: isotopes_(:)
-  IF(PRESENT( tracers_))  tracers =  tracers_
-  IF(PRESENT(isotopes_)) isotopes = isotopes_
-END SUBROUTINE getKey_init
-!==============================================================================================================================
-CHARACTER(LEN=maxlen) FUNCTION fgetKeyByIndex_s1(itr, keyn, ky, def_val) RESULT(val)
-!------------------------------------------------------------------------------------------------------------------------------
-! Purpose: Internal function ; get a string formatted key value (returned argument) from its name and the tracer index.
-!------------------------------------------------------------------------------------------------------------------------------
-  INTEGER,                    INTENT(IN) :: itr
-  CHARACTER(LEN=*),           INTENT(IN) :: keyn
-  TYPE(keys_type),            INTENT(IN) :: ky(:)
-  CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: def_val
+!================ GET THE VALUE OF A KEY FROM A "keys_type" DERIVED TYPE ; THE RESULT IS THE RETURNED VALUE ===================
+!==============================================================================================================================
+CHARACTER(LEN=maxlen) FUNCTION fgetKeyIdx_s1(itr, keyn, ky, def_val, lerr) RESULT(val)
+  INTEGER,                    INTENT(IN)  :: itr
+  CHARACTER(LEN=*),           INTENT(IN)  :: keyn
+  TYPE(keys_type),            INTENT(IN)  :: ky(:)
+  CHARACTER(LEN=*), OPTIONAL, INTENT(IN)  :: def_val
+  LOGICAL,          OPTIONAL, INTENT(OUT) :: lerr
 !------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: iky
-  iky = 0;  IF(itr >  0 .AND. itr <= SIZE(ky)) iky = strIdx(ky(itr)%key(:), keyn)
-  val = ''; IF(iky /= 0) val = ky(itr)%val(iky)                      !--- Key was found
-  IF(PRESENT(def_val) .AND. iky == 0) val = def_val                  !--- Default value from arguments
-END FUNCTION fgetKeyByIndex_s1
-!==============================================================================================================================
-CHARACTER(LEN=maxlen) FUNCTION fgetKeyByName_s1(tname, keyn, ky, def_val, lerr) RESULT(val)
-!------------------------------------------------------------------------------------------------------------------------------
-! Purpose: Internal function ; get a string formatted key value (returned argument) from its name and the tracer name.
-!------------------------------------------------------------------------------------------------------------------------------
+  LOGICAL :: ler
+  iky = 0; val = ''
+  IF(.NOT.test(itr <= 0 .OR. itr > SIZE(ky), ler)) iky = strIdx(ky(itr)%key(:), keyn)    !--- Correct index
+  IF(.NOT.test(iky == 0, ler))                     val = ky(itr)%val(iky)                !--- Found key
+  IF(iky == 0) THEN
+    IF(.NOT.test(.NOT.PRESENT(def_val), ler))      val = def_val                         !--- Default value
+  END IF
+  IF(PRESENT(lerr)) lerr = ler
+END FUNCTION fgetKeyIdx_s1
+!==============================================================================================================================
+CHARACTER(LEN=maxlen) FUNCTION fgetKeyNam_s1(tname, keyn, ky, def_val, lerr) RESULT(val)
   CHARACTER(LEN=*),           INTENT(IN)  :: tname, keyn
   TYPE(keys_type),            INTENT(IN)  :: ky(:)
@@ -1173,61 +1408,116 @@
   LOGICAL,          OPTIONAL, INTENT(OUT) :: lerr
 !------------------------------------------------------------------------------------------------------------------------------
-  INTEGER :: iky, itr
-  val = ''; iky = 0
-  itr = strIdx(ky(:)%name, tname)                                    !--- Get the index of the wanted tracer
-  IF(PRESENT(lerr)) lerr = itr==0; IF(itr == 0) RETURN
-  IF(itr >  0 .AND. itr <= SIZE(ky)) iky = strIdx(ky(itr)%key(:), keyn)
-  IF(iky /= 0) val = ky(itr)%val(iky)                                !--- Key was found
-  IF(PRESENT(def_val) .AND. iky == 0) val = def_val                  !--- Default value from arguments
-END FUNCTION fgetKeyByName_s1
+  val = fgetKeyIdx_s1(strIdx(ky(:)%name, tname), keyn, ky, def_val, lerr)
+END FUNCTION fgetKeyNam_s1
+!==============================================================================================================================
+FUNCTION fgetKeys(keyn, ky, def_val, lerr) RESULT(val)
+CHARACTER(LEN=maxlen),        ALLOCATABLE :: val(:)
+  CHARACTER(LEN=*),           INTENT(IN)  :: keyn
+  TYPE(keys_type),            INTENT(IN)  :: ky(:)
+  CHARACTER(LEN=*), OPTIONAL, INTENT(IN)  :: def_val
+  LOGICAL,          OPTIONAL, INTENT(OUT) :: lerr
+!------------------------------------------------------------------------------------------------------------------------------
+  LOGICAL :: ler(SIZE(ky))
+  INTEGER :: it
+  val = [(fgetKeyIdx_s1(it, keyn, ky, def_val, ler(it)), it = 1, SIZE(ky))]
+  IF(PRESENT(lerr)) lerr = ANY(ler)
+END FUNCTION fgetKeys
+!==============================================================================================================================
+
+
+!==============================================================================================================================
+!========== GET THE VALUE OF A KEY FROM A "keys_type" DERIVED TYPE ; THE RETURNED VALUE IS THE ERROR CODE        ==============
+!==========  The key "keyn" is searched in: 1)           "ky(:)%name" (if given)                                 ==============
+!==========                                 2)      "tracers(:)%name"                                            ==============
+!==========                                 3) "isotope%keys(:)%name"                                            ==============
+!==========  for the tracer[s] "tname[(:)]" (if given) or all the available tracers from the used set otherwise. ==============
+!==========  The type of the returned value(s) can be string, integer or real, scalar or vector                  ==============
 !==============================================================================================================================
 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 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
   CHARACTER(LEN=maxlen),     INTENT(OUT) :: val
   CHARACTER(LEN=*),          INTENT(IN)  :: tname
   TYPE(keys_type), OPTIONAL, INTENT(IN)  :: ky(:)
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen) :: tnam
-  INTEGER, ALLOCATABLE  :: is(:)
-  INTEGER :: i, itr
-  tnam = delPhase(strHead(tname,'_',.FALSE.))                        !--- Remove tag and phase
-  IF(PRESENT(ky)) THEN
-    val = fgetKeyByName_s1(tname, keyn, ky, lerr=lerr)               !--- "ky" and "tname"
-    IF(val /= '' .OR. lerr)      RETURN
-    val = fgetKeyByName_s1(tnam,  keyn, ky, lerr=lerr)               !--- "ky" and "tnam"
+  tnam = strHead(delPhase(tname),'_',.TRUE.)                                             !--- Remove phase and tag
+  IF(PRESENT(ky)) THEN                                                                   !=== KEY FROM "ky"
+               val = fgetKeyNam_s1(tname, keyn, ky,           lerr=lerr)                 !--- "ky" and "tname"
+    IF( lerr ) val = fgetKeyNam_s1(tnam,  keyn, ky,           lerr=lerr)                 !--- "ky" and "tnam"
   ELSE
-    IF(.NOT.ALLOCATED(tracers))  RETURN
-    val = fgetKeyByName_s1(tname, keyn, tracers(:)%keys, lerr=lerr)  !--- "tracers" and "tname"
-    IF(val /= ''.AND..NOT.lerr)  RETURN
-    IF(.NOT.ALLOCATED(isotopes)) RETURN
-    IF(SIZE(isotopes) == 0)      RETURN
-    !--- Search the "is" isotopes class index of the isotope named "tnam"
-    is = find([(ANY(isotopes(i)%keys(:)%name == tnam), i=1, SIZE(isotopes))])
-    IF(test(SIZE(is) == 0,lerr)) RETURN
-    val = fgetKeyByName_s1(tname, keyn, isotopes(is(1))%keys(:),lerr=lerr)!--- "isotopes" and "tnam"
+    IF(         .NOT.test(.NOT.ALLOCATED(tracers ), lerr)) lerr = SIZE(tracers ) == 0    !=== KEY FROM "tracers"
+    IF(.NOT.lerr) THEN
+               val = fgetKeyNam_s1(tname, keyn, tracers%keys, lerr=lerr)                 !--- "ky" and "tname"
+      IF(lerr) val = fgetKeyNam_s1(tnam,  keyn, tracers%keys, lerr=lerr)                 !--- "ky" and "tnam"
+    END IF
+    IF(lerr.AND..NOT.test(.NOT.ALLOCATED(isotopes), lerr)) lerr = SIZE(isotopes) == 0    !=== KEY FROM "isotope"
+    IF(.NOT.lerr) THEN
+               val = fgetKeyNam_s1(tname, keyn, isotope%keys, lerr=lerr)                 !--- "ky" and "tname"
+      IF(lerr) val = fgetKeyNam_s1(tnam,  keyn, isotope%keys, lerr=lerr)                 !--- "ky" and "tnam"
+    END IF
   END IF
 END FUNCTION getKeyByName_s1
 !==============================================================================================================================
-LOGICAL FUNCTION getKeyByName_sm(keyn, val, tname, ky) RESULT(lerr)
+LOGICAL FUNCTION getKeyByName_s1m(keyn, val, tname, ky) RESULT(lerr)
   CHARACTER(LEN=*),                   INTENT(IN)  :: keyn
-  CHARACTER(LEN=maxlen), ALLOCATABLE, INTENT(OUT) ::   val(:)
-  CHARACTER(LEN=*), TARGET, OPTIONAL, INTENT(IN)  :: tname(:)
-  TYPE(keys_type),  TARGET, OPTIONAL, INTENT(IN)  ::    ky(:)
-  TYPE(keys_type),           POINTER :: k(:)
-  CHARACTER(LEN=maxlen), ALLOCATABLE :: n(:)
+  CHARACTER(LEN=maxlen), ALLOCATABLE, INTENT(OUT) :: val(:)
+  CHARACTER(LEN=*),                   INTENT(IN)  :: tname
+  TYPE(keys_type),          OPTIONAL, INTENT(IN)  :: ky(:)
+!------------------------------------------------------------------------------------------------------------------------------
+  CHARACTER(LEN=maxlen) :: sval
+  lerr = getKeyByName_s1(keyn, sval, tname, ky)
+  IF(test(fmsg('missing key "'//TRIM(keyn)//'" for tracer "'//TRIM(tname)//'"', modname, lerr), lerr)) RETURN
+  lerr = strParse(sval, ',', val)
+END FUNCTION getKeyByName_s1m
+!==============================================================================================================================
+LOGICAL FUNCTION getKeyByName_sm(keyn, val, tname, ky, nam) RESULT(lerr)
+  CHARACTER(LEN=*),                             INTENT(IN)  :: keyn
+  CHARACTER(LEN=maxlen),           ALLOCATABLE, INTENT(OUT) :: val(:)
+  CHARACTER(LEN=*),                             INTENT(IN)  :: tname(:)
+  TYPE(keys_type),       OPTIONAL, TARGET,      INTENT(IN)  :: ky(:)
+  CHARACTER(LEN=maxlen), OPTIONAL, ALLOCATABLE, INTENT(OUT) :: nam(:)
+!------------------------------------------------------------------------------------------------------------------------------
+  TYPE(keys_type), POINTER ::  keys(:)
+  LOGICAL :: lk, lt, li
   INTEGER :: iq, nq
-  IF(test(.NOT.(PRESENT(tname).OR.PRESENT(ky)), lerr)) RETURN
-  IF(PRESENT(ky   )) nq = SIZE(ky%name)
-  IF(PRESENT(tname)) nq = SIZE(  tname)
+
+  !--- DETERMINE THE DATABASE TO BE USED (ky, tracers or isotope)
+  lk = PRESENT(ky)
+  lt = .NOT.lk .AND. ALLOCATED(tracers);  IF(lt) lt = SIZE(tracers)  /= 0; IF(lt) lt = ANY(tracers(1)%keys%key(:) == keyn)
+  li = .NOT.lt .AND. ALLOCATED(isotopes); IF(li) li = SIZE(isotopes) /= 0; IF(li) li = ANY(isotope%keys(1)%key(:) == keyn)
+
+  !--- LINK "keys" TO THE RIGHT DATABASE
+  IF(test(.NOT.ANY([lk,lt,li]), lerr)) RETURN
+  IF(lk) keys => ky(:)
+  IF(lt) keys => tracers(:)%keys
+  IF(li) keys => isotope%keys(:)
+
+  !--- GET THE DATA
+  nq = SIZE(tname)
   ALLOCATE(val(nq))
-  IF(PRESENT(tname)) THEN
-    IF(     PRESENT(ky)) lerr = ANY([(getKeyByName_s1(keyn, val(iq), tname(iq),   ky), iq=1, nq)])
-    IF(.NOT.PRESENT(ky)) lerr = ANY([(getKeyByName_s1(keyn, val(iq), tname(iq)      ), iq=1, nq)])
-  ELSE;                  lerr = ANY([(getKeyByName_s1(keyn, val(iq), ky(iq)%name, ky), iq=1, nq)])
+  lerr = ANY([(getKeyByName_s1(keyn, val(iq), tname(iq), keys(:)), iq=1, nq)])
+  IF(PRESENT(nam)) nam = tname(:)
+
+END FUNCTION getKeyByName_sm
+!==============================================================================================================================
+LOGICAL FUNCTION getKey_sm(keyn, val, ky, nam) RESULT(lerr)
+  CHARACTER(LEN=*),                             INTENT(IN)  :: keyn
+  CHARACTER(LEN=maxlen),           ALLOCATABLE, INTENT(OUT) :: val(:)
+  TYPE(keys_type),       OPTIONAL,              INTENT(IN)  :: ky(:)
+  CHARACTER(LEN=maxlen), OPTIONAL, ALLOCATABLE, INTENT(OUT) :: nam(:)
+!------------------------------------------------------------------------------------------------------------------------------
+! Note: if names are repeated, getKeyByName_sm can't be used ; this routine, using indexes, must be used instead.
+  IF(PRESENT(ky)) THEN                                                                   !=== KEY FROM "ky"
+    val = fgetKeys(keyn, ky, lerr=lerr)
+    IF(PRESENT(nam)) nam = ky(:)%name
+  ELSE
+    IF(         .NOT.test(.NOT.ALLOCATED(tracers ), lerr)) lerr = SIZE(tracers ) == 0    !=== KEY FROM "tracers"
+    IF(.NOT.lerr) val = fgetKeys(keyn, tracers%keys, lerr=lerr)
+    IF(.NOT.lerr.AND.PRESENT(nam)) nam = tracers(:)%keys%name
+    IF(lerr.AND..NOT.test(.NOT.ALLOCATED(isotopes), lerr)) lerr = SIZE(isotopes) == 0    !=== KEY FROM "isotope"
+    IF(.NOT.lerr) val = fgetKeys(keyn, isotope%keys, lerr=lerr)
+    IF(.NOT.lerr.AND.PRESENT(nam)) nam = isotope%keys(:)%name
   END IF
-END FUNCTION getKeyByName_sm
+END FUNCTION getKey_sm
 !==============================================================================================================================
 LOGICAL FUNCTION getKeyByName_i1(keyn, val, tname, ky) RESULT(lerr)
@@ -1236,31 +1526,61 @@
   CHARACTER(LEN=*),          INTENT(IN)  :: tname
   TYPE(keys_type), OPTIONAL, INTENT(IN)  :: ky(:)
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen) :: sval
   INTEGER :: ierr
-  IF(     PRESENT(ky)) lerr = getKeyByName_s1(keyn, sval, tname, ky)
-  IF(.NOT.PRESENT(ky)) lerr = getKeyByName_s1(keyn, sval, tname)
-  IF(test(fmsg('key "'//TRIM(keyn)//'" or tracer "'//TRIM(tname)//'" is missing',        modname, lerr), lerr)) RETURN
+  lerr = getKeyByName_s1(keyn, sval, tname, ky)
+  IF(test(fmsg('key "'//TRIM(keyn)//'" or tracer "'//TRIM(tname)//'" is missing', modname, lerr), lerr)) RETURN
   READ(sval, *, IOSTAT=ierr) val
+  IF(test(fmsg('key "'//TRIM(keyn)//'" of tracer "'//TRIM(tname)//'" is not an integer', modname, ierr/=0), lerr)) RETURN
+END FUNCTION getKeyByName_i1
+!==============================================================================================================================
+LOGICAL FUNCTION getKeyByName_i1m(keyn, val, tname, ky) RESULT(lerr)
+  CHARACTER(LEN=*),          INTENT(IN)  :: keyn
+  INTEGER,      ALLOCATABLE, INTENT(OUT) :: val(:)
+  CHARACTER(LEN=*),          INTENT(IN)  :: tname
+  TYPE(keys_type), OPTIONAL, INTENT(IN)  ::  ky(:)
+!------------------------------------------------------------------------------------------------------------------------------
+  CHARACTER(LEN=maxlen), ALLOCATABLE :: sval(:)
+  INTEGER :: ierr, iq, nq
+  IF(test(getKeyByName_s1m(keyn, sval, tname, ky), lerr)) RETURN
+  nq = SIZE(sval); ALLOCATE(val(nq))
+  lerr = .FALSE.; DO iq=1, nq; READ(sval(iq), *, IOSTAT=ierr) val(iq); lerr = lerr .OR. ierr /= 0; END DO
   IF(test(fmsg('key "'//TRIM(keyn)//'" of tracer "'//TRIM(tname)//'" is not an integer', modname, lerr), lerr)) RETURN
-END FUNCTION getKeyByName_i1
-!==============================================================================================================================
-LOGICAL FUNCTION getKeyByName_im(keyn, val, tname, ky) RESULT(lerr)
-  CHARACTER(LEN=*),                   INTENT(IN)  :: keyn
-  INTEGER,               ALLOCATABLE, INTENT(OUT) ::   val(:)
-  CHARACTER(LEN=*), TARGET, OPTIONAL, INTENT(IN)  :: tname(:)
-  TYPE(keys_type),  TARGET, OPTIONAL, INTENT(IN)  ::    ky(:)
-  TYPE(keys_type),           POINTER :: k(:)
-  CHARACTER(LEN=maxlen), ALLOCATABLE :: n(:)
-  INTEGER :: iq, nq
-  IF(test(.NOT.(PRESENT(tname).OR.PRESENT(ky)), lerr)) RETURN
-  IF(PRESENT(ky   )) nq = SIZE(ky%name)
-  IF(PRESENT(tname)) nq = SIZE(  tname)
-  ALLOCATE(val(nq))
-  IF(PRESENT(tname)) THEN
-    IF(     PRESENT(ky)) lerr = ANY([(getKeyByName_i1(keyn, val(iq), tname(iq),   ky), iq=1, nq)])
-    IF(.NOT.PRESENT(ky)) lerr = ANY([(getKeyByName_i1(keyn, val(iq), tname(iq)      ), iq=1, nq)])
-  ELSE;                  lerr = ANY([(getKeyByName_i1(keyn, val(iq), ky(iq)%name, ky), iq=1, nq)])
-  END IF
+END FUNCTION getKeyByName_i1m
+!==============================================================================================================================
+LOGICAL FUNCTION getKeyByName_im(keyn, val, tname, ky, nam) RESULT(lerr)
+  CHARACTER(LEN=*),                             INTENT(IN)  ::  keyn
+  INTEGER,                         ALLOCATABLE, INTENT(OUT) ::   val(:)
+  CHARACTER(LEN=*),                             INTENT(IN)  :: tname(:)
+  TYPE(keys_type),       OPTIONAL,              INTENT(IN)  ::    ky(:)
+  CHARACTER(LEN=maxlen), OPTIONAL, ALLOCATABLE, INTENT(OUT) ::   nam(:)
+!------------------------------------------------------------------------------------------------------------------------------
+  CHARACTER(LEN=maxlen), ALLOCATABLE :: sval(:), names(:)
+  INTEGER :: ierr, iq, nq
+  IF(test(getKeyByName_sm(keyn, sval, tname, ky, names), lerr)) RETURN
+  nq = SIZE(sval); ALLOCATE(val(nq))
+  DO iq = 1, nq                                                      !--- CONVERT THE KEYS TO INTEGERS
+    READ(sval(iq), *, IOSTAT=ierr) val(iq)
+    IF(test(fmsg('key "'//TRIM(keyn)//'" of tracer "'//TRIM(names(iq))//'" is not an integer', modname, ierr/=0), lerr)) RETURN
+  END DO
+  IF(PRESENT(nam)) nam = names(:)
 END FUNCTION getKeyByName_im
+!==============================================================================================================================
+LOGICAL FUNCTION getKey_im(keyn, val, ky, nam) RESULT(lerr)
+  CHARACTER(LEN=*),                             INTENT(IN)  :: keyn
+  INTEGER,                         ALLOCATABLE, INTENT(OUT) ::  val(:)
+  TYPE(keys_type),       OPTIONAL,              INTENT(IN)  ::   ky(:)
+  CHARACTER(LEN=maxlen), OPTIONAL, ALLOCATABLE, INTENT(OUT) ::  nam(:)
+!------------------------------------------------------------------------------------------------------------------------------
+  CHARACTER(LEN=maxlen), ALLOCATABLE :: sval(:), names(:)
+  INTEGER :: ierr, iq, nq
+  IF(test(getKey_sm(keyn, sval, ky, names), lerr)) RETURN
+  nq = SIZE(sval); ALLOCATE(val(nq))
+  DO iq = 1, nq
+    READ(sval(iq), *, IOSTAT=ierr) val(iq)
+    IF(test(fmsg('key "'//TRIM(keyn)//'" of tracer "'//TRIM(names(iq))//'" is not an integer', modname, ierr/=0), lerr)) RETURN
+  END DO
+  IF(PRESENT(nam)) nam = names
+END FUNCTION getKey_im
 !==============================================================================================================================
 LOGICAL FUNCTION getKeyByName_r1(keyn, val, tname, ky) RESULT(lerr)
@@ -1269,31 +1589,153 @@
   CHARACTER(LEN=*),          INTENT(IN)  :: tname
   TYPE(keys_type), OPTIONAL, INTENT(IN)  :: ky(:)
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen) :: sval
   INTEGER :: ierr
-  IF(     PRESENT(ky)) lerr = getKeyByName_s1(keyn, sval, tname, ky)
-  IF(.NOT.PRESENT(ky)) lerr = getKeyByName_s1(keyn, sval, tname)
+  lerr = getKeyByName_s1(keyn, sval, tname, ky)
   IF(test(fmsg('key "'//TRIM(keyn)//'" or tracer "'//TRIM(tname)//'" is missing',    modname, lerr), lerr)) RETURN
   READ(sval, *, IOSTAT=ierr) val
-  IF(test(fmsg('key "'//TRIM(keyn)//'" of tracer "'//TRIM(tname)//'" is not a real', modname, lerr), lerr)) RETURN
+  IF(test(fmsg('key "'//TRIM(keyn)//'" of tracer "'//TRIM(tname)//'" is not a real', modname, ierr/=0), lerr)) RETURN
 END FUNCTION getKeyByName_r1
 !==============================================================================================================================
-LOGICAL FUNCTION getKeyByName_rm(keyn, val, tname, ky) RESULT(lerr)
-  CHARACTER(LEN=*),                   INTENT(IN)  :: keyn
-  REAL,                  ALLOCATABLE, INTENT(OUT) ::   val(:)
-  CHARACTER(LEN=*), TARGET, OPTIONAL, INTENT(IN)  :: tname(:)
-  TYPE(keys_type),  TARGET, OPTIONAL, INTENT(IN)  ::    ky(:)
-  TYPE(keys_type),           POINTER :: k(:)
-  CHARACTER(LEN=maxlen), ALLOCATABLE :: n(:)
+LOGICAL FUNCTION getKeyByName_r1m(keyn, val, tname, ky) RESULT(lerr)
+  CHARACTER(LEN=*),           INTENT(IN)  :: keyn
+  REAL,          ALLOCATABLE, INTENT(OUT) :: val(:)
+  CHARACTER(LEN=*),           INTENT(IN)  :: tname
+  TYPE(keys_type),  OPTIONAL, INTENT(IN)  ::  ky(:)
+!------------------------------------------------------------------------------------------------------------------------------
+  CHARACTER(LEN=maxlen), ALLOCATABLE :: sval(:)
+  INTEGER :: ierr, iq, nq
+  IF(test(getKeyByName_s1m(keyn, sval, tname, ky), lerr)) RETURN
+  nq = SIZE(sval); ALLOCATE(val(nq))
+  lerr = .FALSE.; DO iq=1, nq; READ(sval(iq), *, IOSTAT=ierr) val(iq); lerr = lerr .OR. ierr /= 0; END DO
+  IF(test(fmsg('key "'//TRIM(keyn)//'" of tracer "'//TRIM(tname)//'" is not a vector of reals', modname, lerr), lerr)) RETURN
+END FUNCTION getKeyByName_r1m
+!==============================================================================================================================
+LOGICAL FUNCTION getKeyByName_rm(keyn, val, tname, ky, nam) RESULT(lerr)
+  CHARACTER(LEN=*),                             INTENT(IN)  ::  keyn
+  REAL,                            ALLOCATABLE, INTENT(OUT) ::   val(:)
+  CHARACTER(LEN=*),                             INTENT(IN)  :: tname(:)
+  TYPE(keys_type),       OPTIONAL,              INTENT(IN)  ::    ky(:)
+  CHARACTER(LEN=maxlen), OPTIONAL, ALLOCATABLE, INTENT(OUT) ::   nam(:)
+!------------------------------------------------------------------------------------------------------------------------------
+  CHARACTER(LEN=maxlen), ALLOCATABLE :: sval(:), names(:)
+  INTEGER :: ierr, iq, nq
+  IF(test(getKeyByName_sm(keyn, sval, tname, ky, names), lerr)) RETURN
+  nq = SIZE(sval); ALLOCATE(val(nq))
+  DO iq = 1, nq                                                      !--- CONVERT THE KEYS TO INTEGERS
+    READ(sval(iq), *, IOSTAT=ierr) val(iq)
+    IF(test(fmsg('key "'//TRIM(keyn)//'" of tracer "'//TRIM(names(iq))//'" is not a real', modname, ierr/=0), lerr)) RETURN
+  END DO
+  IF(PRESENT(nam)) nam = names
+END FUNCTION getKeyByName_rm
+!==============================================================================================================================
+LOGICAL FUNCTION getKey_rm(keyn, val, ky, nam) RESULT(lerr)
+  CHARACTER(LEN=*),                             INTENT(IN)  :: keyn
+  REAL,                            ALLOCATABLE, INTENT(OUT) ::  val(:)
+  TYPE(keys_type),       OPTIONAL,              INTENT(IN)  ::   ky(:)
+  CHARACTER(LEN=maxlen), OPTIONAL, ALLOCATABLE, INTENT(OUT) ::  nam(:)
+!------------------------------------------------------------------------------------------------------------------------------
+  CHARACTER(LEN=maxlen), ALLOCATABLE :: sval(:), names(:)
+  INTEGER :: ierr, iq, nq
+  IF(test(getKey_sm(keyn, sval, ky, names), lerr)) RETURN
+  nq = SIZE(sval); ALLOCATE(val(nq))
+  DO iq = 1, nq                                                      !--- CONVERT THE KEYS TO INTEGERS
+    READ(sval(iq), *, IOSTAT=ierr) val(iq)
+    IF(test(fmsg('key "'//TRIM(keyn)//'" of tracer "'//TRIM(names(iq))//'" is not a real', modname, ierr/=0), lerr)) RETURN
+  END DO
+  IF(PRESENT(nam)) nam = names
+END FUNCTION getKey_rm
+!==============================================================================================================================
+LOGICAL FUNCTION getKeyByName_l1(keyn, val, tname, ky) RESULT(lerr)
+  USE strings_mod, ONLY: str2bool
+  CHARACTER(LEN=*),          INTENT(IN)  :: keyn
+  LOGICAL,                   INTENT(OUT) :: val
+  CHARACTER(LEN=*),          INTENT(IN)  :: tname
+  TYPE(keys_type), OPTIONAL, INTENT(IN)  :: ky(:)
+!------------------------------------------------------------------------------------------------------------------------------
+  CHARACTER(LEN=maxlen) :: sval
+  lerr = getKeyByName_s1(keyn, sval, tname, ky)
+  IF(test(fmsg('key "'//TRIM(keyn)//'" or tracer "'//TRIM(tname)//'" is missing', modname, lerr), lerr)) RETURN
+  val = str2bool(sval)
+END FUNCTION getKeyByName_l1
+!==============================================================================================================================
+LOGICAL FUNCTION getKeyByName_l1m(keyn, val, tname, ky) RESULT(lerr)
+  USE strings_mod, ONLY: str2bool
+  CHARACTER(LEN=*),           INTENT(IN)  :: keyn
+  LOGICAL,       ALLOCATABLE, INTENT(OUT) :: val(:)
+  CHARACTER(LEN=*),           INTENT(IN)  :: tname
+  TYPE(keys_type),  OPTIONAL, INTENT(IN)  ::  ky(:)
+!------------------------------------------------------------------------------------------------------------------------------
+  CHARACTER(LEN=maxlen), ALLOCATABLE :: sval(:)
   INTEGER :: iq, nq
-  IF(test(.NOT.(PRESENT(tname).OR.PRESENT(ky)), lerr)) RETURN
-  IF(PRESENT(ky   )) nq = SIZE(ky%name)
-  IF(PRESENT(tname)) nq = SIZE(  tname)
-  ALLOCATE(val(nq))
-  IF(PRESENT(tname)) THEN
-    IF(     PRESENT(ky)) lerr = ANY([(getKeyByName_r1(keyn, val(iq), tname(iq),   ky), iq=1, nq)])
-    IF(.NOT.PRESENT(ky)) lerr = ANY([(getKeyByName_r1(keyn, val(iq), tname(iq)      ), iq=1, nq)])
-  ELSE;                  lerr = ANY([(getKeyByName_r1(keyn, val(iq), ky(iq)%name, ky), iq=1, nq)])
+  IF(test(getKeyByName_s1m(keyn, sval, tname, ky), lerr)) RETURN
+  nq = SIZE(sval); ALLOCATE(val(nq))
+  lerr = .FALSE.; DO iq=1, nq; val(iq)=str2bool(sval(iq)); END DO
+END FUNCTION getKeyByName_l1m
+!==============================================================================================================================
+LOGICAL FUNCTION getKeyByName_lm(keyn, val, tname, ky, nam) RESULT(lerr)
+  USE strings_mod, ONLY: str2bool
+  CHARACTER(LEN=*),                             INTENT(IN)  ::  keyn
+  LOGICAL,                         ALLOCATABLE, INTENT(OUT) ::   val(:)
+  CHARACTER(LEN=*),                             INTENT(IN)  :: tname(:)
+  TYPE(keys_type),       OPTIONAL,              INTENT(IN)  ::    ky(:)
+  CHARACTER(LEN=maxlen), OPTIONAL, ALLOCATABLE, INTENT(OUT) ::   nam(:)
+!------------------------------------------------------------------------------------------------------------------------------
+  CHARACTER(LEN=maxlen), ALLOCATABLE :: sval(:)
+  INTEGER :: iq, nq
+  IF(test(getKeyByName_sm(keyn, sval, tname, ky, nam), lerr)) RETURN
+  nq = SIZE(sval); ALLOCATE(val(nq))
+  lerr = .FALSE.; DO iq=1, nq; val(iq)=str2bool(sval(iq)); END DO
+END FUNCTION getKeyByName_lm
+!==============================================================================================================================
+LOGICAL FUNCTION getKey_lm(keyn, val, ky, nam) RESULT(lerr)
+  USE strings_mod, ONLY: str2bool
+  CHARACTER(LEN=*),                             INTENT(IN)  :: keyn
+  LOGICAL,                         ALLOCATABLE, INTENT(OUT) ::  val(:)
+  TYPE(keys_type),       OPTIONAL,              INTENT(IN)  ::   ky(:)
+  CHARACTER(LEN=maxlen), OPTIONAL, ALLOCATABLE, INTENT(OUT) ::  nam(:)
+!------------------------------------------------------------------------------------------------------------------------------
+  CHARACTER(LEN=maxlen), ALLOCATABLE :: sval(:)
+  INTEGER :: iq, nq
+  IF(test(getKey_sm(keyn, sval, ky, nam), lerr)) RETURN
+  nq = SIZE(sval); ALLOCATE(val(nq))
+  lerr = .FALSE.; DO iq=1, nq; val(iq)=str2bool(sval(iq)); END DO
+END FUNCTION getKey_lm
+!==============================================================================================================================
+
+
+!==============================================================================================================================
+!=== ROUTINES TO GET OR PUT TRACERS AND ISOTOPES DATABASES, SINCE tracers AND isotopes ARE PRIVATE VARIABLES ==================
+!==============================================================================================================================
+SUBROUTINE setKeysDBase(tracers_, isotopes_, isotope_)
+  TYPE(trac_type), OPTIONAL, INTENT(IN) ::  tracers_(:)
+  TYPE(isot_type), OPTIONAL, INTENT(IN) :: isotopes_(:)
+  TYPE(isot_type), OPTIONAL, INTENT(IN) :: isotope_
+!------------------------------------------------------------------------------------------------------------------------------
+  TYPE(isot_type), ALLOCATABLE :: iso(:)
+  INTEGER :: ix, nbIso
+  IF(PRESENT( tracers_)) THEN;  tracers =  tracers_; ELSE; ALLOCATE( tracers(0)); END IF
+  IF(PRESENT(isotopes_)) THEN; isotopes = isotopes_; ELSE; ALLOCATE(isotopes(0)); END IF
+  IF(PRESENT(isotope_ )) THEN
+    ix = strIdx(isotopes(:)%parent, isotope_%parent)
+    IF(ix /= 0) THEN
+      isotopes(ix) = isotope_
+    ELSE
+      nbIso = SIZE(isotopes); ALLOCATE(iso(nbIso+1)); iso(1:nbIso) = isotopes; iso(nbIso+1) = isotope_
+      CALL MOVE_ALLOC(FROM=iso, TO=isotopes)
+    END IF
   END IF
-END FUNCTION getKeyByName_rm
+END SUBROUTINE setKeysDBase
+!==============================================================================================================================
+SUBROUTINE getKeysDBase(tracers_, isotopes_, isotope_)
+  TYPE(trac_type), OPTIONAL, ALLOCATABLE, INTENT(OUT) ::  tracers_(:)
+  TYPE(isot_type), OPTIONAL, ALLOCATABLE, INTENT(OUT) :: isotopes_(:)
+  TYPE(isot_type), OPTIONAL,              INTENT(OUT) :: isotope_
+!------------------------------------------------------------------------------------------------------------------------------
+  INTEGER :: ix
+  IF(PRESENT( tracers_)) THEN;  tracers_ =  tracers; ELSE; ALLOCATE( tracers_(0)); END IF
+  IF(PRESENT(isotopes_)) THEN; isotopes_ = isotopes; ELSE; ALLOCATE(isotopes_(0)); END IF
+  IF(PRESENT(isotope_ )) THEN; ix = strIdx(isotopes(:)%parent, isotope%parent); IF(ix /= 0) isotope_=isotopes(ix); END IF
+END SUBROUTINE getKeysDBase
 !==============================================================================================================================
 
@@ -1304,28 +1746,21 @@
 ELEMENTAL CHARACTER(LEN=maxlen) FUNCTION delPhase(s) RESULT(out)
   CHARACTER(LEN=*), INTENT(IN) :: s
-  INTEGER :: l, i, ix
-  CHARACTER(LEN=maxlen) :: sh, st
-  out = s
-  IF(s == '') RETURN                                                           !--- Empty string: nothing to do
-
-  !--- Special case: old phases for water, no phases separator
-  i = INDEX(s,'_'); sh = s; IF(i/=0) sh=s(1:i-1); st='H2O'; IF(i/=0) st='H2O_'//s(i+1:LEN_TRIM(s))
-  IF(ANY([('H2O'//old_phases(ix:ix), ix=1, nphases)] == sh)) THEN; out=st; RETURN; END IF
-
-  !--- Index of found phase in "known_phases"
-  ix = MAXLOC( [(i, i=1,nphases)], MASK=[( INDEX(s, phases_sep//known_phases(i:i))/=0, i=1, nphases)], DIM=1 )
-  IF(ix == 0) RETURN                                                           !--- No phase pattern found
-  i = INDEX(s, phases_sep//known_phases(ix:ix))                                !--- Index of <sep><pha> pattern in "str"
-  l = LEN_TRIM(s)
-  IF(i == l-1) THEN                                                            !--- <var><sep><pha>       => return <var>
-    out = s(1:l-2)
-  ELSE IF(s(i+2:i+2) == '_') THEN                                              !--- <var><sep><pha>_<tag> => return <var>_<tag>
-    out = s(1:i-1)//s(i+2:l)
+!------------------------------------------------------------------------------------------------------------------------------
+  INTEGER :: ix, ip, ns
+  out = s; ns = LEN_TRIM(s)
+  IF(s == '' .OR. ns<=2) RETURN                                                !--- Empty string or LEN(name)<=2: nothing to do
+  IF(s(1:3)=='H2O' .AND. INDEX(old_phases,s(4:4))/=0 .AND. (ns==4 .OR. s(5:5)=='_')) THEN
+    out='H2O'//s(5:ns)                                                         !--- H2O<phase>[_<iso>][_<tag>]
+  ELSE IF(s(ns-1:ns-1)==phases_sep .AND. INDEX(known_phases,s(ns:ns))/=0) THEN
+    out = s(1:ns-2); RETURN                                                    !--- <var><phase_sep><phase>
+  ELSE; DO ip = 1, nphases; ix = INDEX(s, phases_sep//known_phases(ip:ip)//'_'); IF(ix /= 0) EXIT; END DO
+    IF(ip /= nphases+1) out = s(1:ix-1)//s(ix+2:ns)                            !--- <var><phase_sep><phase>_<tag>
   END IF
 END FUNCTION delPhase
-!------------------------------------------------------------------------------------------------------------------------------
+!==============================================================================================================================
 CHARACTER(LEN=maxlen) FUNCTION addPhase_s1(s,pha) RESULT(out)
   CHARACTER(LEN=*),           INTENT(IN) :: s
   CHARACTER(LEN=1),           INTENT(IN) :: pha
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: l, i
   out = s
@@ -1336,24 +1771,26 @@
   IF(i /= 0) out = s(1:i-1)//phases_sep//pha//'_'//s(i+1:l)                    !--- <var>_<tag> => return <var><sep><pha>_<tag>
 END FUNCTION addPhase_s1
-!------------------------------------------------------------------------------------------------------------------------------
+!==============================================================================================================================
 FUNCTION addPhase_sm(s,pha) RESULT(out)
   CHARACTER(LEN=*),           INTENT(IN) :: s(:)
   CHARACTER(LEN=1),           INTENT(IN) :: pha
   CHARACTER(LEN=maxlen),     ALLOCATABLE :: out(:)
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: k
   out = [( addPhase_s1(s(k), pha), k=1, SIZE(s) )]
 END FUNCTION addPhase_sm
-!------------------------------------------------------------------------------------------------------------------------------
+!==============================================================================================================================
 CHARACTER(LEN=maxlen) FUNCTION addPhase_i1(s,ipha,phases) RESULT(out)
   CHARACTER(LEN=*),           INTENT(IN) :: s
   INTEGER,                    INTENT(IN) :: ipha
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: phases
+!------------------------------------------------------------------------------------------------------------------------------
   out = s
   IF(s == '') RETURN                                                           !--- Empty string: nothing to do
-  IF(ipha==0) RETURN                                                           !--- Null index: no phase to add
+  IF(ipha == 0 .OR. ipha > nphases) RETURN                                     !--- Absurd index: no phase to add
   IF(     PRESENT(phases)) out = addPhase_s1(s,       phases(ipha:ipha))
   IF(.NOT.PRESENT(phases)) out = addPhase_s1(s, known_phases(ipha:ipha))
 END FUNCTION addPhase_i1
-!------------------------------------------------------------------------------------------------------------------------------
+!==============================================================================================================================
 FUNCTION addPhase_im(s,ipha,phases) RESULT(out)
   CHARACTER(LEN=*),           INTENT(IN) :: s(:)
@@ -1361,9 +1798,10 @@
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: phases
   CHARACTER(LEN=maxlen),     ALLOCATABLE :: out(:)
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: k
   IF(     PRESENT(phases)) out = [( addPhase_i1(s(k), ipha,       phases), k=1, SIZE(s) )]
   IF(.NOT.PRESENT(phases)) out = [( addPhase_i1(s(k), ipha, known_phases), k=1, SIZE(s) )]
 END FUNCTION addPhase_im
-!------------------------------------------------------------------------------------------------------------------------------
+!==============================================================================================================================
 
 
@@ -1374,15 +1812,17 @@
   CHARACTER(LEN=*),           INTENT(IN)  :: tname
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN)  :: phases
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen) :: phase
   IF(     PRESENT(phases)) phase = getPhase(tname,       phases, iPhase)
   IF(.NOT.PRESENT(phases)) phase = getPhase(tname, known_phases, iPhase)
 END FUNCTION getiPhase
-!------------------------------------------------------------------------------------------------------------------------------
+!==============================================================================================================================
 CHARACTER(LEN=1) FUNCTION getPhase(tname, phases, iPhase) RESULT(phase)
   CHARACTER(LEN=*),           INTENT(IN)  :: tname
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN)  :: phases
   INTEGER,          OPTIONAL, INTENT(OUT) :: iPhase
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: ip
-  phase = TRIM(strHead(strTail(tname, phases_sep, .TRUE.), '_', .TRUE.))
+  phase = TRIM(strHead(strTail(tname, phases_sep), '_', .TRUE.))     !--- <nam><sep><pha>[_<tag>] -> <pha>[_<tag>] -> <pha>
   IF(     PRESENT(phases)) ip = INDEX(      phases, phase)
   IF(.NOT.PRESENT(phases)) ip = INDEX(known_phases, phase)
@@ -1390,69 +1830,76 @@
   IF(PRESENT(iPhase)) iPhase = ip
 END FUNCTION getPhase
-!------------------------------------------------------------------------------------------------------------------------------
-
-
-!------------------------------------------------------------------------------------------------------------------------------
-CHARACTER(LEN=maxlen) FUNCTION old2newName_1(oldName, iPhase) RESULT(newName)
-  !--- Convert an old style name into a new one.
-  !    Only usable with old style "traceur.def" files, in which only water isotopes are allowed.
-  !    In these files, H2O descendants names are: H2O<phase>[_<isotope>][_<tag>], with:
-  !    phase = v, l or i ; isotope = eau, HDO, O18, O17 or HTO.
+!==============================================================================================================================
+
+
+!==============================================================================================================================
+!============ CONVERT WATER-DERIVED NAMES FROM FORMER TO CURRENT CONVENTION ; OTHER NAMES ARE LEFT UNTOUCHED ==================
+!======= NAMES STRUCTURE: H2O[<phase>][_<isotope>][_<tag>] (<phase> from "old_phases", <isotope> from "oldH2OIso") ============
+!==============================================================================================================================
+CHARACTER(LEN=maxlen) FUNCTION old2newH2O_1(oldName, iPhase) RESULT(newName)
   CHARACTER(LEN=*),  INTENT(IN)  :: oldName
   INTEGER, OPTIONAL, INTENT(OUT) :: iPhase
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen), ALLOCATABLE :: tmp(:)
-  INTEGER :: ix, ip, it, nt
+  INTEGER :: ix, ip, nt
   LOGICAL :: lerr
   newName = oldName
   IF(PRESENT(iPhase)) iPhase = 1                                               !--- Default: gaseous phase
-  IF(oldName(1:MIN(3,LEN_TRIM(oldName))) /= 'H2O') RETURN                      !--- Not a water descendant
-  lerr = strParse(oldName, '_', tmp, n=nt)
-  ip = strIdx([('H2O'//old_phases(ip:ip), ip=1, nphases)], tmp(1))             !--- Phase index (/=0 if any)
-  IF(PRESENT(iPhase)) iPhase = ip
-  newName = addPhase('H2O', ip)                                                !--- Water
-  IF(nt == 1) RETURN                                                           !--- Water: finished
-  ix = strIdx(oldH2OIso, tmp(2))                                               !--- Index in the known isotopes list
-  IF(ix == 0) newName = addPhase(tmp(2),        ip)                            !--- Not an isotope
-  IF(ix /= 0) newName = addPhase(newH2OIso(ix), ip)                            !--- Isotope
-  IF(nt == 3) newName = TRIM(newName)//'_'//TRIM(tmp(3))                       !--- Tagging tracer
-END FUNCTION old2newName_1
-!------------------------------------------------------------------------------------------------------------------------------
-FUNCTION old2newName_m(oldName, iPhase) RESULT(newName)
-  CHARACTER(LEN=*),  INTENT(IN)  :: oldName(:)
+  lerr = strParse(oldName, '_', tmp, nt)                                       !--- Parsing: 1 up to 3 elements.
+  ip = strIdx( [('H2O'//old_phases(ix:ix), ix=1, nphases)], tmp(1) )           !--- Phase index
+  IF(ip /= 0 .AND. PRESENT(iPhase)) iPhase = ip                                !--- Returning phase index
+  IF(ip == 0 .AND. tmp(1) /= 'H2O')   RETURN                                   !--- Not an old-style water-related species
+  IF(nt == 1) THEN
+    newName = addPhase('H2O',ip)                                               !=== WATER WITH OR WITHOUT PHASE
+  ELSE
+    ix = strIdx(oldH2OIso, tmp(2))                                             !--- Index in the known isotopes list
+    IF(ix /= 0) newName = newH2OIso(ix)                                        !--- Move to new isotope name
+    IF(ip /= 0) newName = addPhase(newName, ip)                                !--- Add phase to isotope name
+    IF(nt == 3) newName = TRIM(newName)//'_'//TRIM(tmp(3))                     !=== WATER ISOTOPE OR TAGGING TRACER
+  END IF
+END FUNCTION old2newH2O_1
+!==============================================================================================================================
+FUNCTION old2newH2O_m(oldName) RESULT(newName)
+  CHARACTER(LEN=*), INTENT(IN) :: oldName(:)
+  CHARACTER(LEN=maxlen)        :: newName(SIZE(oldName))
+!------------------------------------------------------------------------------------------------------------------------------
+  INTEGER :: i
+  newName = [(old2newH2O_1(oldName(i)), i=1, SIZE(oldName))]
+END FUNCTION old2newH2O_m
+!==============================================================================================================================
+
+
+!==============================================================================================================================
+!============ CONVERT WATER-DERIVED NAMES FROM CURRENT TO FORMER CONVENTION ; OTHER NAMES ARE LEFT UNTOUCHED ==================
+!==== NAMES STRUCTURE: <var>[<phase_sep><phase>][_<tag>] (<phase> from "known_phases", <var> = 'H2O' or from "newH2OIso") =====
+!==============================================================================================================================
+CHARACTER(LEN=maxlen) FUNCTION new2oldH2O_1(newName, iPhase) RESULT(oldName)
+  CHARACTER(LEN=*),  INTENT(IN)  :: newName
   INTEGER, OPTIONAL, INTENT(OUT) :: iPhase
-  CHARACTER(LEN=maxlen)          :: newName(SIZE(oldName))
+!------------------------------------------------------------------------------------------------------------------------------
+  INTEGER :: ix, ip
+  CHARACTER(LEN=maxlen) :: var
+  oldName = newName
+  ip = getiPhase(newName)                                                      !--- Phase index
+  IF(PRESENT(iPhase)) iPhase = MAX(ip, 1)                                      !--- Return phase index ; default: 1 (gazeous)
+  var = TRIM(strHead(newName, phases_sep, .TRUE.))                             !--- Variable without phase and tag
+  ix = strIdx(newH2OIso, var)                                                  !--- Index in the known H2O isotopes list
+  IF(ix == 0 .AND. var /= 'H2O') RETURN                                        !--- Neither H2O nor an H2O isotope => finished
+  oldName = 'H2O'
+  IF(ip /= 0) oldName = TRIM(oldName)//old_phases(ip:ip)                       !--- Add phase if needed
+  IF(ix /= 0) oldName = TRIM(oldName)//'_'//oldH2OIso(ix)                      !--- H2O isotope name
+  IF(newName /= addPhase(var, ip)) &
+    oldName = TRIM(oldName)//strTail(newName, '_', .TRUE.)                     !--- Add the tag suffix
+  IF(ip == 0 .AND. ix /= 0) oldName = strTail(oldName, '_')                    !--- Isotope with no phase: remove 'H2O_' prefix
+END FUNCTION new2oldH2O_1
+!==============================================================================================================================
+FUNCTION new2oldH2O_m(newName) RESULT(oldName)
+  CHARACTER(LEN=*), INTENT(IN) :: newName(:)
+  CHARACTER(LEN=maxlen)        :: oldName(SIZE(newName))
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: i
-  newName = [(old2newName_1(oldName(i), iPhase), i=1, SIZE(oldName))]
-END FUNCTION old2newName_m
-!------------------------------------------------------------------------------------------------------------------------------
-
-!------------------------------------------------------------------------------------------------------------------------------
-CHARACTER(LEN=maxlen) FUNCTION new2oldName_1(newName, iPhase) RESULT(oldName)
-  !--- Convert a new style name into an old one.
-  !    Only convertable names are water descendants names H2O_<phase>, <isotope>_<phase>, <isotope>_<phase>_<tag>, with:
-  !    phase = g, l or s ; isotope = H2[16]O, H[2]O, H2<[18]O, H2[17]O or H[3]O.
-  CHARACTER(LEN=*),  INTENT(IN)    :: newName
-  INTEGER, OPTIONAL, INTENT(OUT)   :: iPhase
-  INTEGER :: ix, ip, it, nt
-  LOGICAL :: lH2O
-  CHARACTER(LEN=maxlen) :: tag
-  ix = strIdx([(addPhase('H2O',ip), ip=1, nphases)], newName)                  !--- Phase index for H2O_<phase>
-  IF(ix /= 0) THEN; oldName = 'H2O'//old_phases(ix:ix); RETURN; END IF         !--- H2O_<phase> case
-  ix = strIdx(newH2OIso, strHead(newName, phases_sep, .TRUE.))                 !--- Isotope index
-  IF(ix == 0) THEN; oldName = newName;                  RETURN; END IF         !--- Not a water descendant
-  ip = getiPhase(newName)                                                      !--- Phase index
-  oldName = TRIM(oldH2OIso(ix))//old_phases(ip:ip)                             !--- <isotope>_<phase>
-  tag = strTail(delPhase(newName), TRIM(newH2OIso(ix)))                        !--- Get "_<tag>" if any
-  IF(tag /= delPhase(newName) .AND. tag /= '') oldName = TRIM(oldName)//tag    !--- Tagging tracer
-END FUNCTION new2oldName_1
-!------------------------------------------------------------------------------------------------------------------------------
-FUNCTION new2oldName_m(newName, iPhase) RESULT(oldName)
-  CHARACTER(LEN=*),  INTENT(IN)  :: newName(:)
-  INTEGER, OPTIONAL, INTENT(OUT) :: iPhase
-  CHARACTER(LEN=maxlen)          :: oldName(SIZE(newName))
-  INTEGER :: i
-  oldName = [(new2oldName_1(newName(i), iPhase), i=1, SIZE(newName))]
-END FUNCTION new2oldName_m
-!------------------------------------------------------------------------------------------------------------------------------
+  oldName = [(new2oldH2O_1(newName(i)), i=1, SIZE(newName))]
+END FUNCTION new2oldH2O_m
+!==============================================================================================================================
 
 
@@ -1460,56 +1907,70 @@
 !=== GET THE NAME(S) OF THE ANCESTOR(S) OF TRACER(S) "tname" AT GENERATION "igen"  IN THE TRACERS DESCRIPTORS LIST "tr" =======
 !==============================================================================================================================
-CHARACTER(LEN=maxlen) FUNCTION ancestor_1(t, tname, igen) RESULT(out)
-  TYPE(trac_type),   INTENT(IN) :: t(:)
-  CHARACTER(LEN=*),  INTENT(IN) :: tname
-  INTEGER, OPTIONAL, INTENT(IN) :: igen
-  INTEGER :: ig, ix
-  ig = 0; IF(PRESENT(igen)) ig = igen
-  ix = idxAncestor_1(t, tname, ig)
+SUBROUTINE ancestor_1(t, out, tname, igen)
+  TYPE(trac_type),       INTENT(IN)  :: t(:)
+  CHARACTER(LEN=maxlen), INTENT(OUT) :: out
+  CHARACTER(LEN=*),      INTENT(IN)  :: tname
+  INTEGER,     OPTIONAL, INTENT(IN)  :: igen
+!------------------------------------------------------------------------------------------------------------------------------
+  INTEGER :: ix
+  CALL idxAncestor_1(t, ix, tname, igen)
   out = ''; IF(ix /= 0) out = t(ix)%name
-END FUNCTION ancestor_1
-!------------------------------------------------------------------------------------------------------------------------------
-FUNCTION ancestor_m(t, tname, igen) RESULT(out)
-  CHARACTER(LEN=maxlen), ALLOCATABLE     ::   out(:)
-  TYPE(trac_type),            INTENT(IN) ::     t(:)
-  CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: tname(:)
-  INTEGER,          OPTIONAL, INTENT(IN) :: igen
-  INTEGER, ALLOCATABLE :: ix(:)
+END SUBROUTINE ancestor_1
+!==============================================================================================================================
+SUBROUTINE ancestor_mt(t, out, tname, igen)
+  TYPE(trac_type),       INTENT(IN)  :: t(:)
+  CHARACTER(LEN=*),      INTENT(IN)  :: tname(:)
+  CHARACTER(LEN=maxlen), INTENT(OUT) :: out(SIZE(tname))
+  INTEGER,     OPTIONAL, INTENT(IN)  :: igen
+!------------------------------------------------------------------------------------------------------------------------------
+  INTEGER :: ix(SIZE(tname))
+  CALL idxAncestor_mt(t, ix, tname, igen)
+  out(:) = ''; WHERE(ix /= 0) out = t(ix)%name
+END SUBROUTINE ancestor_mt
+!==============================================================================================================================
+SUBROUTINE ancestor_m(t, out, igen)
+  TYPE(trac_type),       INTENT(IN)  :: t(:)
+  CHARACTER(LEN=maxlen), INTENT(OUT) :: out(SIZE(t))
+  INTEGER,     OPTIONAL, INTENT(IN)  :: igen
+!------------------------------------------------------------------------------------------------------------------------------
+  INTEGER :: ix(SIZE(t))
+  CALL idxAncestor_m(t, ix, igen)
+  out(:) = ''; WHERE(ix /= 0) out = t(ix)%name
+END SUBROUTINE ancestor_m
+!==============================================================================================================================
+
+
+!==============================================================================================================================
+!=== GET THE INDEX(ES) OF THE GENERATION "igen" ANCESTOR(S) OF "tname" (t%name IF UNSPECIFIED) IN THE "t" LIST ================
+!==============================================================================================================================
+SUBROUTINE idxAncestor_1(t, idx, tname, igen)
+  TYPE(trac_type),   INTENT(IN)  :: t(:)
+  INTEGER,           INTENT(OUT) :: idx
+  CHARACTER(LEN=*),  INTENT(IN)  :: tname
+  INTEGER, OPTIONAL, INTENT(IN)  :: igen
   INTEGER :: ig
   ig = 0; IF(PRESENT(igen)) ig = igen
-  IF(     PRESENT(tname)) ix = idxAncestor_m(t, tname,     ig)
-  IF(.NOT.PRESENT(tname)) ix = idxAncestor_m(t, t(:)%name, ig)
-  ALLOCATE(out(SIZE(ix))); out(:) = ''
-  WHERE(ix /= 0) out = t(ix)%name
-END FUNCTION ancestor_m
-!==============================================================================================================================
-
-
-!==============================================================================================================================
-!=== GET THE INDEX(ES) OF THE ANCESTOR(S) OF TRACER(S) "tname" AT GENERATION "igen"  IN THE TRACERS DESCRIPTORS LIST "tr" =====
-!==============================================================================================================================
-INTEGER FUNCTION idxAncestor_1(t, tname, igen) RESULT(out)
-! Return the name of the generation "igen" (>=0) ancestor of "tname"
-  TYPE(trac_type),   INTENT(IN) :: t(:)
-  CHARACTER(LEN=*),  INTENT(IN) :: tname
-  INTEGER, OPTIONAL, INTENT(IN) :: igen
-  INTEGER :: ig
-  ig = 0; IF(PRESENT(igen)) ig = igen
-  out = strIdx(t(:)%name, tname)
-  IF(out == 0)                 RETURN            !--- Tracer not found
-  IF(t(out)%iGeneration <= ig) RETURN            !--- Tracer has a lower generation number than asked generation 'igen"
-  DO WHILE(t(out)%iGeneration > ig); out = strIdx(t(:)%name, t(out)%parent); END DO
-END FUNCTION idxAncestor_1
-!------------------------------------------------------------------------------------------------------------------------------
-FUNCTION idxAncestor_m(t, tname, igen) RESULT(out)
-  INTEGER,          ALLOCATABLE          ::   out(:)
-  TYPE(trac_type),            INTENT(IN) ::     t(:)
-  CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: tname(:)
-  INTEGER,          OPTIONAL, INTENT(IN) :: igen
-  INTEGER :: ig, ix
-  ig = 0; IF(PRESENT(igen)) ig = igen
-  IF(     PRESENT(tname)) out = [(idxAncestor_1(t, tname(ix),  ig), ix=1, SIZE(tname))]
-  IF(.NOT.PRESENT(tname)) out = [(idxAncestor_1(t, t(ix)%name, ig), ix=1, SIZE(t))]
-END FUNCTION idxAncestor_m
+  idx = strIdx(t(:)%name, tname)
+  IF(idx == 0)                 RETURN            !--- Tracer not found
+  IF(t(idx)%iGeneration <= ig) RETURN            !--- Tracer has a lower generation number than asked generation 'igen"
+  DO WHILE(t(idx)%iGeneration > ig); idx = strIdx(t(:)%name, t(idx)%parent); END DO
+END SUBROUTINE idxAncestor_1
+!------------------------------------------------------------------------------------------------------------------------------
+SUBROUTINE idxAncestor_mt(t, idx, tname, igen)
+  TYPE(trac_type),   INTENT(IN)  :: t(:)
+  CHARACTER(LEN=*),  INTENT(IN)  :: tname(:)
+  INTEGER,           INTENT(OUT) :: idx(SIZE(tname))
+  INTEGER, OPTIONAL, INTENT(IN)  :: igen
+  INTEGER :: ix
+  DO ix = 1, SIZE(tname); CALL idxAncestor_1(t, idx(ix), tname(ix), igen); END DO
+END SUBROUTINE idxAncestor_mt
+!------------------------------------------------------------------------------------------------------------------------------
+SUBROUTINE idxAncestor_m(t, idx, igen)
+  TYPE(trac_type),   INTENT(IN)  :: t(:)
+  INTEGER,           INTENT(OUT) :: idx(SIZE(t))
+  INTEGER, OPTIONAL, INTENT(IN)  :: igen
+  INTEGER :: ix
+  DO ix = 1, SIZE(t); CALL idxAncestor_1(t, idx(ix), t(ix)%name, igen); END DO
+END SUBROUTINE idxAncestor_m
 !==============================================================================================================================
 
Index: LMDZ6/branches/Portage_acc/libf/misc/strings_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/misc/strings_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/misc/strings_mod.F90	(revision 4446)
@@ -21,5 +21,4 @@
   INTERFACE strIdx;     MODULE PROCEDURE     strIdx_1,                 strIdx_m; END INTERFACE strIdx
   INTERFACE strCount;   MODULE PROCEDURE  strCount_m1, strCount_11, strCount_1m; END INTERFACE strCount
-  INTERFACE strParse;   MODULE PROCEDURE   strParse_1,               strParse_m; END INTERFACE strParse
   INTERFACE strReplace; MODULE PROCEDURE strReplace_1,             strReplace_m; END INTERFACE strReplace
   INTERFACE cat;        MODULE PROCEDURE   horzcat_s1,  horzcat_i1,  horzcat_r1, &
@@ -38,4 +37,5 @@
 CONTAINS
 
+!==============================================================================================================================
 LOGICAL FUNCTION test(lcond, lout) RESULT(lerr)
   LOGICAL, INTENT(IN)  :: lcond
@@ -43,9 +43,12 @@
   lerr = lcond; lout = lcond
 END FUNCTION test
+!==============================================================================================================================
+
 
 !==============================================================================================================================
 SUBROUTINE init_printout(lunout_, prt_level_)
   INTEGER, INTENT(IN) :: lunout_, prt_level_
-  lunout = lunout_
+  lunout    = lunout_
+  prt_level = prt_level_
 END SUBROUTINE init_printout
 !==============================================================================================================================
@@ -105,4 +108,5 @@
   LOGICAL,          OPTIONAL, INTENT(IN) :: ll
   INTEGER,          OPTIONAL, INTENT(IN) :: unit
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen) :: subn
   INTEGER :: unt
@@ -121,4 +125,5 @@
   INTEGER,          OPTIONAL, INTENT(IN) :: unit
   INTEGER,          OPTIONAL, INTENT(IN) :: nmax
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen), ALLOCATABLE :: s(:)
   CHARACTER(LEN=maxlen) :: subn
@@ -138,4 +143,5 @@
   LOGICAL,          OPTIONAL, INTENT(IN) :: ll
   INTEGER,          OPTIONAL, INTENT(IN) :: unit
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen) :: subn
   INTEGER :: unt
@@ -152,4 +158,5 @@
   INTEGER,          OPTIONAL, INTENT(IN) :: unit
   INTEGER,          OPTIONAL, INTENT(IN)  :: nmax
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen) :: subn
   INTEGER :: unt, nmx
@@ -187,69 +194,73 @@
 
 !==============================================================================================================================
-!=== Extract the substring in front of the last (first if lFirst==TRUE) occurrence of separator "sep" in "str" ================
+!=== Extract the substring in front of the first (last if lBackward==TRUE) occurrence of "sep" in "str"        ================
 !=== Examples for str='a_b_c' and sep='_' and the bash command with the same effect:                           ================
 !===    * strHead(..,.FALSE.) = 'a'           ${str%%$sep*}                                                    ================
 !===    * strHead(..,.TRUE.)  = 'a_b'         ${str%$sep*}                                                     ================
 !==============================================================================================================================
-CHARACTER(LEN=maxlen) FUNCTION strHead_1(str,sep,lFirst) RESULT(out)
+CHARACTER(LEN=maxlen) FUNCTION strHead_1(str, sep, lBackward) RESULT(out)
   CHARACTER(LEN=*),           INTENT(IN) :: str
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: sep
-  LOGICAL,          OPTIONAL, INTENT(IN) :: lFirst
-  LOGICAL :: lf
-  lf = .FALSE.; IF(PRESENT(lFirst)) lf=lFirst
+  LOGICAL,          OPTIONAL, INTENT(IN) :: lBackward
+!------------------------------------------------------------------------------------------------------------------------------
   IF(PRESENT(sep)) THEN
-    out = str(1:INDEX(str,sep,.NOT.lf)-1)
+    IF(     PRESENT(lBackWard)) out = str(1:INDEX(str,sep,lBackWard)-1)
+    IF(.NOT.PRESENT(lBackWard)) out = str(1:INDEX(str,sep)-1)
   ELSE
-    out = str(1:INDEX(str,'/',.NOT.lf)-1)
+    IF(     PRESENT(lBackWard)) out = str(1:INDEX(str,'/',lBackWard)-1)
+    IF(.NOT.PRESENT(lBackWard)) out = str(1:INDEX(str,'/')-1)
   END IF
   IF(out == '') out = str
 END FUNCTION strHead_1
 !==============================================================================================================================
-FUNCTION strHead_m(str,sep,lFirst) RESULT(out)
+FUNCTION strHead_m(str, sep, lBackward) RESULT(out)
   CHARACTER(LEN=maxlen),     ALLOCATABLE :: out(:)
   CHARACTER(LEN=*),           INTENT(IN) :: str(:)
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: sep
-  LOGICAL,          OPTIONAL, INTENT(IN) :: lFirst
-  LOGICAL :: lf
+  LOGICAL,          OPTIONAL, INTENT(IN) :: lBackward
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: k
-  lf = .FALSE.; IF(PRESENT(lFirst)) lf=lFirst
   IF(PRESENT(sep)) THEN
-    out = [(strHead_1(str(k), sep,   lf), k=1, SIZE(str))]
+    IF(     PRESENT(lBackWard)) out = [(strHead_1(str(k), sep, lBackWard), k=1, SIZE(str))]
+    IF(.NOT.PRESENT(lBackWard)) out = [(strHead_1(str(k), sep),            k=1, SIZE(str))]
   ELSE
-    out = [(strHead_1(str(k), lFirst=lf), k=1, SIZE(str))]
+    IF(     PRESENT(lBackWard)) out = [(strHead_1(str(k), '/', lBackWard), k=1, SIZE(str))]
+    IF(.NOT.PRESENT(lBackWard)) out = [(strHead_1(str(k), '/'),            k=1, SIZE(str))]
   END IF
 END FUNCTION strHead_m
 !==============================================================================================================================
-!=== Extract the substring following the last (first if lFirst==TRUE) occurrence of separator "sep" in "str"   ================
+!=== Extract the substring following the first (last if lBackward==TRUE) occurrence of "sep" in "str"          ================
 !=== Examples for str='a_b_c' and sep='_' and the bash command with the same effect:                           ================
-!===    * strTail(..,.FALSE.) = 'c'           ${str#*$sep}                                                     ================
-!===    * strTail(..,.TRUE.)  = 'b_c'         ${str##*$sep}                                                    ================
-!==============================================================================================================================
-CHARACTER(LEN=maxlen) FUNCTION strTail_1(str,sep,lFirst) RESULT(out)
+!===    * strTail(str, '_', .FALSE.) = 'b_c'         ${str#*$sep}                                              ================
+!===    * strTail(str, '_', .TRUE.)  = 'c'           ${str##*$sep}                                             ================
+!==============================================================================================================================
+CHARACTER(LEN=maxlen) FUNCTION strTail_1(str, sep, lBackWard) RESULT(out)
   CHARACTER(LEN=*),           INTENT(IN) :: str
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: sep
-  LOGICAL,          OPTIONAL, INTENT(IN) :: lFirst
-  LOGICAL :: lf
-  lf = .FALSE.; IF(PRESENT(lFirst)) lf=lFirst
+  LOGICAL,          OPTIONAL, INTENT(IN) :: lBackWard
+!------------------------------------------------------------------------------------------------------------------------------
   IF(PRESENT(sep)) THEN
-    out = str(INDEX(str,sep,.NOT.lf)+LEN(sep):LEN_TRIM(str))
+    IF(     PRESENT(lBackWard)) out = str(INDEX(str,sep,lBackWard)+LEN(sep):LEN_TRIM(str))
+    IF(.NOT.PRESENT(lBackWard)) out = str(INDEX(str,sep)          +LEN(sep):LEN_TRIM(str))
   ELSE
-    out = str(INDEX(str,'/',.NOT.lf)+1:LEN_TRIM(str))
+    IF(     PRESENT(lBackWard)) out = str(INDEX(str,'/',lBackWard)+1:LEN_TRIM(str))
+    IF(.NOT.PRESENT(lBackWard)) out = str(INDEX(str,'/')          +1:LEN_TRIM(str))
   END IF
   IF(out == '') out = str
 END FUNCTION strTail_1
 !==============================================================================================================================
-FUNCTION strTail_m(str,sep,lFirst) RESULT(out)
+FUNCTION strTail_m(str, sep, lBackWard) RESULT(out)
   CHARACTER(LEN=maxlen),     ALLOCATABLE :: out(:)
   CHARACTER(LEN=*),           INTENT(IN) :: str(:)
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: sep
-  LOGICAL,          OPTIONAL, INTENT(IN) :: lFirst
-  LOGICAL :: lf
+  LOGICAL,          OPTIONAL, INTENT(IN) :: lBackWard
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: k
-  lf = .FALSE.; IF(PRESENT(lFirst)) lf=lFirst
   IF(PRESENT(sep)) THEN
-    out = [(strTail_1(str(k), sep,   lf), k=1, SIZE(str))]
+    IF(     PRESENT(lBackWard)) out = [(strTail_1(str(k), sep, lBackWard), k=1, SIZE(str))]
+    IF(.NOT.PRESENT(lBackWard)) out = [(strTail_1(str(k), sep),            k=1, SIZE(str))]
   ELSE
-    out = [(strTail_1(str(k), lFirst=lf), k=1, SIZE(str))]
+    IF(     PRESENT(lBackWard)) out = [(strTail_1(str(k), '/', lBackWard), k=1, SIZE(str))]
+    IF(.NOT.PRESENT(lBackWard)) out = [(strTail_1(str(k), '/'),            k=1, SIZE(str))]
   END IF
 END FUNCTION strTail_m
@@ -265,4 +276,5 @@
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: sep
   LOGICAL,          OPTIONAL, INTENT(IN) :: mask(:)
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=:), ALLOCATABLE :: s
   INTEGER :: is, i0
@@ -285,4 +297,5 @@
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: sep
   INTEGER,          OPTIONAL, INTENT(IN) :: nmax
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen), ALLOCATABLE :: t(:)
   CHARACTER(LEN=maxlen) :: sp
@@ -339,4 +352,5 @@
   CHARACTER(LEN=*), ALLOCATABLE, INTENT(INOUT) :: str(:)
   INTEGER,          OPTIONAL,    INTENT(OUT)   :: nb
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen), ALLOCATABLE :: s1(:)
   INTEGER :: k, n, n1
@@ -355,4 +369,5 @@
   CHARACTER(LEN=*),   ALLOCATABLE, INTENT(INOUT) :: str1(:)
   CHARACTER(LEN=*),                INTENT(IN)    :: str2(:)
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen), ALLOCATABLE :: s1(:), s2(:)
   INTEGER :: k
@@ -374,5 +389,6 @@
 
 !==============================================================================================================================
-!=== GET THE INDEX OF THE FIRST APPEARANCE IN THE STRING VECTOR "str(:)" OF THE STRING(s) "s" =================================
+!=== GET THE INDEX OF THE FIRST APPEARANCE IN THE STRING VECTOR "str(:)" OF THE STRING(s) "s[(:)]" ============================
+!=== OPTIONALY: GET THE NUMBER OF FOUND ELEMENTS "n". NB: UNFOUND => INDEX=0                       ============================
 !==============================================================================================================================
 INTEGER FUNCTION strIdx_1(str, s) RESULT(out)
@@ -386,4 +402,5 @@
   INTEGER, OPTIONAL, INTENT(OUT) :: n
   INTEGER,           ALLOCATABLE :: out(:)
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: k
   out = [(strIdx_1(str(:), s(k)), k=1, SIZE(s))]
@@ -400,4 +417,5 @@
   INTEGER, OPTIONAL, INTENT(OUT) :: n
   INTEGER,           ALLOCATABLE :: out(:)
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: k
   out = PACK( [(k, k=1, SIZE(str(:), DIM=1))], MASK = str(:) == s )
@@ -409,4 +427,5 @@
   INTEGER, OPTIONAL, INTENT(OUT) :: n
   INTEGER,           ALLOCATABLE :: out(:)
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: k
   out = PACK( [(k, k=1, SIZE(i(:), DIM=1))], MASK = i(:) == j )
@@ -418,15 +437,9 @@
   INTEGER, OPTIONAL, INTENT(OUT) :: n
   INTEGER,           ALLOCATABLE :: out(:)
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: k
   out = PACK( [(k, k=1, SIZE(l(:), DIM=1))], MASK = l(:) )
   IF(PRESENT(n)) n = SIZE(out(:), DIM=1)
 END FUNCTION find_boo
-!==============================================================================================================================
-
-
-
-!==============================================================================================================================
-!=== GET 1ST APPEARANCE INDEX OF EACH ELEMENT OF "t(:)" IN "s(:)" (UNFOUND: INDEX=0) ==========================================
-!=== OPTIONALY: GET THE NUMBER OF FOUND ELEMENTS "n"                                 ==========================================
 !==============================================================================================================================
 
@@ -444,54 +457,41 @@
   INTEGER,           INTENT(OUT) :: idel                             !--- Index of the identified delimiter (0 if idx==0)
   LOGICAL, OPTIONAL, INTENT(IN)  :: lSc                              !--- Care about nbs with front sign or in scient. notation
-
-  INTEGER               :: idx0                                      !--- Used to display an identified non-numeric string
-  INTEGER, ALLOCATABLE  :: ii(:)
-  LOGICAL               :: ll, ls
-  CHARACTER(LEN=maxlen) :: d
-!  modname = 'strIdx'
+!------------------------------------------------------------------------------------------------------------------------------
+  INTEGER :: idx0                                                    !--- Used to display an identified non-numeric string
   lerr = .FALSE.
-  idx = strIdx1(rawList, del, ibeg, idel)                            !--- del(idel) appears in "rawList" at position idx
+  idx = strIdx1(rawList, del, ibeg, idel)                            !--- idx/=0: del(idel) is at position "idx" in "rawList" 
   IF(.NOT.PRESENT(lSc))               RETURN                         !--- No need to check exceptions for numbers => finished
   IF(.NOT.        lSc )               RETURN                         !--- No need to check exceptions for numbers => finished
-  IF(idx == 0) THEN                                                  !--- No element of "del" in "rawList":
-    lerr = .NOT.is_numeric(rawList(ibeg:))                           !--- String must be a number
-    IF(lerr) idx = LEN_TRIM(rawList); RETURN                         !--- Update idx => rawList(ibeg:idx-1) is the whole string
-  END IF
-  idx0 = idx
-  IF(test(idx==1.AND.INDEX('+-',del(idel))/=0, lerr)) RETURN         !--- Front separator different from +/-: error
-  IF(idx/=1.AND.is_numeric(rawList(ibeg:idx-1)))      RETURN         !--- The input string tail is a valid number
-  idx = strIdx1(rawList, del, idx+1, idel)                           !---   => TO THE NEXT DELIMITER
+
+  !=== No delimiter found: the whole string must be a valid number
+  IF(idx == 0) THEN                                                  !--- No element of "del" in "rawList"
+    lerr = .NOT.is_numeric(rawList(ibeg:LEN_TRIM(rawList)))          !--- String must be a number
+    IF(lerr) idx = LEN_TRIM(rawList); RETURN                         !--- Set idx so that rawList(ibeg:idx-1) = whole string
+  END IF
+
+  IF(test(idx == 1 .AND. INDEX('+-',del(idel)) /= 0, lerr)) RETURN   !--- The front delimiter is different from +/-: error
+  IF(     idx /= 1 .AND. is_numeric(rawList(ibeg:idx-1)))   RETURN   !--- The input string head is a valid number
+
+  !=== The string part in front of the 1st delimiter is not a valid number: search for next delimiter index "idx"
+  idx0 = idx ; idx = strIdx1(rawList, del, idx+1, idel)              !--- Keep start index because idx is recycled
   IF(idx == 0) THEN
-    lerr = .NOT.is_numeric(rawList(ibeg:))                           !--- No delimiter detected: string must be a number
+    lerr = .NOT.is_numeric(rawList(ibeg:LEN_TRIM(rawList)))          !--- No other delimiter: whole string must be a valid numb
     IF(lerr) idx = idx0; RETURN
   END IF
-  idx0 = idx
-  IF(is_numeric(rawList(ibeg:idx-1)))                 RETURN         !--- The input string tail is a valid number
-  IF(test(          INDEX('eE',rawList(idx-1:idx-1)) /= 0  &         !--- Sole possible exception: scientific notation: E+/-
-               .OR. INDEX('+-',del(idel)) /=0, lerr)) RETURN
-  idx = strIdx1(rawList, del, idx+1, idel)                           !---   => TO THE NEXT DELIMITER
-  IF(idx == 0) THEN
-    lerr = .NOT.is_numeric(rawList(ibeg:))                           !--- No separator detected: string must be a number
-    IF(lerr) idx = idx0; RETURN
-  END IF
   lerr = .NOT.is_numeric(rawList(ibeg:idx-1))
+
 CONTAINS
 
-INTEGER FUNCTION strIdx1(str, del, ib, id) RESULT(idx)
-  CHARACTER(LEN=*),  INTENT(IN)  :: str
-  CHARACTER(LEN=*),  INTENT(IN)  :: del(:)
+!------------------------------------------------------------------------------------------------------------------------------
+INTEGER FUNCTION strIdx1(str, del, ib, id) RESULT(i)
+!--- Get the index of the first appereance of one of the delimiters "del(:)" in "str" starting from position "ib".
+!--- "id" is the index in "del(:)" of the first delimiter found.
+  IMPLICIT NONE
+  CHARACTER(LEN=*),  INTENT(IN)  :: str, del(:)
   INTEGER,           INTENT(IN)  :: ib
   INTEGER,           INTENT(OUT) :: id
-
-  INTEGER              :: nd, ns, i
-  INTEGER, ALLOCATABLE :: ii(:)
-
-  nd  = SIZE(del)                                                    !--- Number of separators
-  ns  = LEN_TRIM(str)                                                !--- Length of the raw chain
-  ii  = [(INDEX( str(ib:ns), del(i) ), i = 1, nd)]                   !--- Determine the next separator start index
-  id  =  MINLOC( ii, MASK = ii /= 0, DIM = 1 )                       !--- Current delimiter index in the "delimiter(:)" list
-  idx = 0
-  IF(ANY(ii /= 0)) idx = MINVAL( ii, MASK = ii /= 0 ) + ib - 1       !--- Index in "str(1:ns)" of the delimiter first character
-  IF(idx == 0) id = 0
+!------------------------------------------------------------------------------------------------------------------------------
+  DO i = ib, LEN_TRIM(str); id = strIdx(del, str(i:i)); IF(id /= 0) EXIT; END DO
+  IF(i > LEN_TRIM(str)) THEN; i = 0; id = 0; END IF
 END FUNCTION strIdx1
 
@@ -501,42 +501,30 @@
 
 !==============================================================================================================================
-!=== Return the index of first appearance of "del" in "str" starting from index "ib"
-!==============================================================================================================================
-INTEGER FUNCTION strIndex(str, del, ib) RESULT(idx)
-  CHARACTER(LEN=*),  INTENT(IN)  :: str
-  CHARACTER(LEN=*),  INTENT(IN)  :: del
-  INTEGER,           INTENT(IN)  :: ib
-  idx  = INDEX( str(ib:LEN_TRIM(str)), del ) + ib -1
-END FUNCTION strIndex
-!==============================================================================================================================
-
-
-!==============================================================================================================================
 !=== Count the number of elements separated by "delimiter" in list "rawList". =================================================
 !==============================================================================================================================
-LOGICAL FUNCTION strCount_11(rawList, delimiter, nb, lSc) RESULT(out)
+LOGICAL FUNCTION strCount_11(rawList, delimiter, nb, lSc) RESULT(lerr)
   CHARACTER(LEN=*),  INTENT(IN)  :: rawList
   CHARACTER(LEN=*),  INTENT(IN)  :: delimiter
   INTEGER,           INTENT(OUT) :: nb
   LOGICAL, OPTIONAL, INTENT(IN)  :: lSc
+!------------------------------------------------------------------------------------------------------------------------------
   LOGICAL :: ll
   ll = .FALSE.; IF(PRESENT(lSc)) ll = lSc
-  out = strCount_1m(rawList, [delimiter], nb, ll)
+  lerr = strCount_1m(rawList, [delimiter], nb, ll)
 END FUNCTION strCount_11
 !==============================================================================================================================
-LOGICAL FUNCTION strCount_m1(rawList, delimiter, nb, lSc) RESULT(out)
+LOGICAL FUNCTION strCount_m1(rawList, delimiter, nb, lSc) RESULT(lerr)
   CHARACTER(LEN=*),     INTENT(IN)  :: rawList(:)
   CHARACTER(LEN=*),     INTENT(IN)  :: delimiter
   INTEGER, ALLOCATABLE, INTENT(OUT) :: nb(:)
   LOGICAL,    OPTIONAL, INTENT(IN)  :: lSc
-
+!------------------------------------------------------------------------------------------------------------------------------
   LOGICAL :: ll
   INTEGER :: id
-
   ll  = .FALSE.; IF(PRESENT(lSc)) ll = lSc .AND. INDEX('+-', delimiter) /= 0
-  out = .TRUE.
+  lerr = .TRUE.
   ALLOCATE(nb(SIZE(rawList)))
   DO id = 1, SIZE(rawList)
-    out = out .AND. strCount_1m(rawList(id), [delimiter], nb(id), ll)
+    lerr = lerr .AND. strCount_1m(rawList(id), [delimiter], nb(id), ll)
   END DO
 END FUNCTION strCount_m1
@@ -547,8 +535,8 @@
   INTEGER,           INTENT(OUT) :: nb
   LOGICAL, OPTIONAL, INTENT(IN)  :: lSc
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER              :: ib, ie, jd, nr
   LOGICAL              :: ll
   CHARACTER(LEN=1024)  :: r
-!  modname = 'strCount'
   lerr = .FALSE.
   ll   = .FALSE.; IF(PRESENT(lSc)) ll = lSc
@@ -559,5 +547,5 @@
     lerr = strIdx_prv(r, delimiter, ib, ie, jd, ll)
     IF(fmsg('"'//TRIM(r(ib:ie-1))//'" is not numeric', ll=lerr)) RETURN
-    IF(jd == 0) EXIT
+    IF(ie == 0 .OR. jd == 0) EXIT
     ib = ie + LEN(delimiter(jd))
     DO WHILE(r(ib:ib) == ' ' .AND. ib < nr); ib = ib + 1; END DO     !--- Skip spaces before next chain
@@ -572,31 +560,74 @@
 !===          Corresponding "vals" remains empty if the element does not contain "=" sign. ====================================
 !==============================================================================================================================
-LOGICAL FUNCTION strParse_1(rawList, delimiter, keys, lSc, vals, n) RESULT(lerr)
+LOGICAL FUNCTION strParse(rawList, delimiter, keys, n, vals) RESULT(lerr)
   CHARACTER(LEN=*),                             INTENT(IN)  :: rawList, delimiter
   CHARACTER(LEN=maxlen), ALLOCATABLE,           INTENT(OUT) :: keys(:)
-  LOGICAL,                            OPTIONAL, INTENT(IN)  :: lSc      !--- Take care about numbers in scientific notation
+  INTEGER,                            OPTIONAL, INTENT(OUT) :: n
   CHARACTER(LEN=maxlen), ALLOCATABLE, OPTIONAL, INTENT(OUT) :: vals(:)
-  INTEGER,                            OPTIONAL, INTENT(OUT) :: n
-  LOGICAL :: ll
-!  modname = 'strParse'
-  ll = .FALSE.; IF(PRESENT(lSc)) ll = lSc
-  IF(.NOT.PRESENT(vals)) lerr = strParse_m(rawList, [delimiter], keys, ll)
-  IF(     PRESENT(vals)) lerr = strParse_m(rawList, [delimiter], keys, ll, vals)
-  IF(PRESENT(n)) n = SIZE(keys)
-END FUNCTION strParse_1
-!==============================================================================================================================
-LOGICAL FUNCTION strParse_m(rawList, delimiter, keys, lSc, vals, n, id) RESULT(lerr)
+!------------------------------------------------------------------------------------------------------------------------------
+  CHARACTER(LEN=1024) :: r
+  INTEGER :: nr, nk
+  lerr = .FALSE.
+  r  = TRIM(ADJUSTL(rawList))
+  nr = LEN_TRIM(r); IF(nr == 0) THEN; keys = ['']; RETURN; END IF
+  CALL strParse_prv(nk)                                              !--- COUNT THE ELEMENTS
+  ALLOCATE(keys(nk))
+  IF(PRESENT(vals)) THEN
+    ALLOCATE(vals(nk)); CALL strParse_prv(nk, keys, vals)            !--- PARSE THE KEYS
+  ELSE
+    CALL strParse_prv(nk, keys)                                      !--- PARSE THE KEYS
+  END IF
+  IF(PRESENT(n)) n = nk
+
+CONTAINS
+
+!------------------------------------------------------------------------------------------------------------------------------
+SUBROUTINE strParse_prv(nkeys, keys, vals)
+!--- * Get the number of elements after parsing ("nkeys" only is present)
+!--- * Parse the <key>=<val> pairs and store result in "keys" and "vals" (already allocated)
+  IMPLICIT NONE
+  INTEGER,                         INTENT(OUT) :: nkeys
+  CHARACTER(LEN=maxlen), OPTIONAL, INTENT(OUT) :: keys(:)
+  CHARACTER(LEN=maxlen), OPTIONAL, INTENT(OUT) :: vals(:)
+!------------------------------------------------------------------------------------------------------------------------------
+  INTEGER :: ib, ie
+  nkeys = 1; ib = 1
+  DO
+    ie = INDEX(rawList(ib:nr), delimiter)+ib-1                       !--- Determine the next separator start index
+    IF(ie == ib-1) EXIT
+    IF(PRESENT(keys)) keys(nkeys) = r(ib:ie-1)                       !--- Get the ikth key
+    IF(PRESENT(vals)) CALL parseKeys(keys(nkeys), vals(nkeys))       !--- Parse the ikth <key>=<val> pair
+    ib = ie + LEN(delimiter)
+    DO WHILE(r(ib:ib) == ' ' .AND. ib < nr); ib = ib + 1; END DO     !--- Skip spaces before next chain
+    nkeys = nkeys+1
+  END DO
+  IF(PRESENT(keys)) keys(nkeys) = r(ib:nr)                           !--- Get the last key
+  IF(PRESENT(vals)) CALL parseKeys(keys(nkeys), vals(nkeys))         !--- Parse the last <key>=<val> pair
+END SUBROUTINE strParse_prv
+
+!------------------------------------------------------------------------------------------------------------------------------
+SUBROUTINE parseKeys(key, val)
+  CHARACTER(LEN=*), INTENT(INOUT) :: key
+  CHARACTER(LEN=*), INTENT(OUT)   :: val
+!------------------------------------------------------------------------------------------------------------------------------
+  INTEGER :: ix
+  ix = INDEX(key, '='); IF(ix == 0) RETURN                           !--- First "=" index in "key"
+  val = ADJUSTL(key(ix+1:LEN_TRIM(key)))
+  key = ADJUSTL(key(1:ix-1))
+END SUBROUTINE parseKeys
+
+END FUNCTION strParse
+!==============================================================================================================================
+LOGICAL FUNCTION strParse_m(rawList, delimiter, keys, n, vals, lSc, id) RESULT(lerr)
   CHARACTER(LEN=*),                             INTENT(IN)  :: rawList, delimiter(:)
   CHARACTER(LEN=maxlen),           ALLOCATABLE, INTENT(OUT) :: keys(:)  !--- Parsed keys vector
+  INTEGER,               OPTIONAL,              INTENT(OUT) :: n        !--- Length of the parsed vector
+  CHARACTER(LEN=maxlen), OPTIONAL, ALLOCATABLE, INTENT(OUT) :: vals(:)  !--- Values for <name>=<value> keys
   LOGICAL,               OPTIONAL,              INTENT(IN)  :: lSc      !--- Take care about numbers in scientific notation
-  CHARACTER(LEN=maxlen), OPTIONAL, ALLOCATABLE, INTENT(OUT) :: vals(:)  !--- Values for <name>=<value> keys
-  INTEGER,               OPTIONAL,              INTENT(OUT) :: n        !--- Length of the parsed vector
   INTEGER,               OPTIONAL, ALLOCATABLE, INTENT(OUT) :: id(:)    !--- Indexes of the separators in "delimiter(:)" vector
-
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=1024) :: r
   INTEGER :: nr, ik, nk, ib, ie, jd
   LOGICAL :: ll
-
-!  modname = 'strParse'
   ll = .FALSE.; IF(PRESENT(lSc)) ll = lSc
   IF(test(fmsg("Couldn't parse list: non-numerical strings were found", ll=strCount_1m(rawList, delimiter, nk, ll)),lerr)) RETURN
@@ -625,7 +656,9 @@
 CONTAINS
 
+!------------------------------------------------------------------------------------------------------------------------------
 SUBROUTINE parseKeys(key, val)
   CHARACTER(LEN=*), INTENT(INOUT) :: key
   CHARACTER(LEN=*), INTENT(OUT)   :: val
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: ix
   ix = INDEX(key, '='); IF(ix == 0) RETURN                           !--- First "=" index in "key"
@@ -645,9 +678,7 @@
   CHARACTER(LEN=*),  INTENT(IN)    :: key, val   !--- "key" will be replaced by "val"
   LOGICAL, OPTIONAL, INTENT(IN)    :: lsurr      !--- TRUE => key must be surrounded by special characters to be substituted
-
-  CHARACTER(LEN=1024) :: s, t
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: i0, ix, nk, ns
   LOGICAL :: lsur, lb, le
-
   lsur = .FALSE.; IF(PRESENT(lsurr)) lsur = lsurr
   nk = LEN_TRIM(key)
@@ -688,4 +719,5 @@
   CHARACTER(LEN=*), OPTIONAL, TARGET, INTENT(IN) :: s1, s2, s3, s4, s5, s6, s7, s8, s9
   CHARACTER(LEN=maxlen), ALLOCATABLE :: out(:)
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen), POINTER     :: s
   LOGICAL :: lv(10)
@@ -707,4 +739,5 @@
   CHARACTER(LEN=*), OPTIONAL, TARGET, DIMENSION(:), INTENT(IN) :: s1, s2, s3, s4, s5, s6, s7, s8, s9
   CHARACTER(LEN=maxlen), ALLOCATABLE :: out(:,:)
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen), POINTER     :: s(:)
   LOGICAL :: lv(10)
@@ -729,4 +762,5 @@
   INTEGER, OPTIONAL, TARGET, INTENT(IN) :: i1, i2, i3, i4, i5, i6, i7, i8, i9
   INTEGER, ALLOCATABLE :: out(:)
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER, POINTER     :: i
   LOGICAL :: lv(10)
@@ -748,4 +782,5 @@
   INTEGER, OPTIONAL, TARGET, DIMENSION(:), INTENT(IN) :: i1, i2, i3, i4, i5, i6, i7, i8, i9
   INTEGER, ALLOCATABLE :: out(:,:)
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER, POINTER     :: i(:)
   LOGICAL :: lv(10)
@@ -770,4 +805,5 @@
   REAL, OPTIONAL, TARGET, INTENT(IN) :: r1, r2, r3, r4, r5, r6, r7, r8, r9
   REAL, ALLOCATABLE :: out(:)
+!------------------------------------------------------------------------------------------------------------------------------
   REAL, POINTER     :: r
   LOGICAL :: lv(10)
@@ -789,4 +825,5 @@
   REAL, OPTIONAL, TARGET, DIMENSION(:), INTENT(IN) :: r1, r2, r3, r4, r5, r6, r7, r8, r9
   REAL, ALLOCATABLE :: out(:,:)
+!------------------------------------------------------------------------------------------------------------------------------
   REAL, POINTER     :: r(:)
   LOGICAL :: lv(10)
@@ -811,4 +848,5 @@
   DOUBLE PRECISION, OPTIONAL, TARGET, INTENT(IN) :: d1, d2, d3, d4, d5, d6, d7, d8, d9
   DOUBLE PRECISION, ALLOCATABLE :: out(:)
+!------------------------------------------------------------------------------------------------------------------------------
   DOUBLE PRECISION, POINTER     :: d
   LOGICAL :: lv(10)
@@ -830,4 +868,5 @@
   DOUBLE PRECISION, OPTIONAL, TARGET, DIMENSION(:), INTENT(IN) :: d1, d2, d3, d4, d5, d6, d7, d8, d9
   DOUBLE PRECISION, ALLOCATABLE :: out(:,:)
+!------------------------------------------------------------------------------------------------------------------------------
   DOUBLE PRECISION, POINTER     :: d(:)
   LOGICAL :: lv(10)
@@ -853,6 +892,9 @@
 !--- Display a clean table composed of successive vectors of same length.
 !=== The profile "p" describe in which order to pick up the columns from "s", "i" and "r" for display.
-!==============================================================================================================================
-LOGICAL FUNCTION dispTable(p, titles, s, i, r, rFmt, nmax, unit, sub) RESULT(lerr)
+!===  * nRowMax lines are displayed (default: all lines)
+!===  * nColMax characters (default: as long as needed) are displayed at most on a line. If the effective total length is
+!===    higher, several partial tables are displayed ; the nHead (default: 1) first columns are included in each sub-table.
+!==============================================================================================================================
+LOGICAL FUNCTION dispTable(p, titles, s, i, r, rFmt, nRowMax, nColMax, nHead, unit, sub) RESULT(lerr)
   CHARACTER(LEN=*),           INTENT(IN)  :: p             !--- DISPLAY MAP: s/i/r
   CHARACTER(LEN=*),           INTENT(IN)  :: titles(:)     !--- TITLES (ONE EACH COLUMN)
@@ -861,18 +903,19 @@
   REAL,             OPTIONAL, INTENT(IN)  :: r(:,:)        !--- REALS
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN)  :: rFmt          !--- Format for reals
-  INTEGER,          OPTIONAL, INTENT(IN)  :: nmax          !--- Display less than "nrow" rows
+  INTEGER,          OPTIONAL, INTENT(IN)  :: nRowMax       !--- Display at most "nRowMax" rows
+  INTEGER,          OPTIONAL, INTENT(IN)  :: nColMax       !--- Display at most "nColMax" characters each line
+  INTEGER,          OPTIONAL, INTENT(IN)  :: nHead         !--- Head columns repeated for multiple tables display
   INTEGER,          OPTIONAL, INTENT(IN)  :: unit          !--- Output unit (default: screen)
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN)  :: sub           !--- Subroutine name
-
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=2048) :: row
   CHARACTER(LEN=maxlen)  :: rFm, el, subn
   CHARACTER(LEN=maxlen), ALLOCATABLE :: d(:,:)
   CHARACTER(LEN=1) :: s1, sp
-  INTEGER :: is, ii, ir, np, nrow, unt, ic
-  INTEGER :: ns, ni, nr, ncol, nmx
-  INTEGER, ALLOCATABLE :: n(:)
-  INTEGER, PARAMETER   :: nm=2                             !--- Space between values & columns
+  INTEGER :: is, ii, ir, it, k, nmx,  unt, ic, np
+  INTEGER :: ns, ni, nr, nt, l, ncol, nHd, ib, l0
+  INTEGER, ALLOCATABLE :: n(:), ncmx(:)
+  INTEGER, PARAMETER   :: nm=1                             !--- Space between values & columns
   LOGICAL :: ls, li, lr
-
   subn = '';    IF(PRESENT(sub)) subn = sub
   rFm = '*';    IF(PRESENT(rFmt)) rFm = rFmt               !--- Specified format for reals
@@ -884,5 +927,5 @@
 
   !--- CHECK ARGUMENTS COHERENCE
-  lerr = np /= SIZE(titles); IF(fmsg('string "pattern" length and titles list mismatch', subn, lerr)) RETURN
+  lerr = np /= SIZE(titles); IF(fmsg('display map "p" length and titles list mismatch', subn, lerr)) RETURN
   IF(ls) THEN
     ns = SIZE(s, 1); ncol = ncol + SIZE(s, 2); lerr = COUNT([(p(ic:ic)=='s', ic=1, np)]) /= SIZE(s, 2)
@@ -894,14 +937,13 @@
     nr = SIZE(r, 1); ncol = ncol + SIZE(r, 2); lerr = COUNT([(p(ic:ic)=='r', ic=1, np)]) /= SIZE(r, 2)
   END IF
-  IF(fmsg('string "pattern" length and arguments number mismatch', subn, lerr)) RETURN
+  IF(fmsg('display map "p" length and arguments number mismatch', subn, lerr)) RETURN
   lerr = ncol /= SIZE(titles); IF(fmsg('"titles" length and arguments number mismatch', subn, lerr)) RETURN
   lerr = ls.AND.li.AND.ns/=ni; IF(fmsg('string and integer arguments lengths mismatch', subn, lerr)) RETURN
   lerr = ls.AND.lr.AND.ns/=nr; IF(fmsg(   'string and real arguments lengths mismatch', subn, lerr)) RETURN
   lerr = li.AND.lr.AND.ni/=nr; IF(fmsg(  'integer and real arguments lengths mismatch', subn, lerr)) RETURN
-  nrow = MAX(ns,ni,nr)+1
-  nmx = nrow; IF(PRESENT(nmax)) nmx = MIN(nmx,nmax+1)
+  nmx = MAX(ns,ni,nr)+1; IF(PRESENT(nRowMax)) nmx = MIN(nmx,nRowMax+1)
 
   !--- Allocate the assembled quantities array
-  ALLOCATE(d(nrow,ncol), n(ncol))
+  ALLOCATE(d(nmx,ncol), n(ncol))
 
   !--- Assemble the vectors into a strings array in the order indicated by "pattern"
@@ -914,19 +956,46 @@
       CASE('r'); d(2:nmx,ic) = real2str(r(:,ir),rFm); ir = ir + 1
     END SELECT
+  END DO
+  CALL cleanZeros(d)
+  DO ic = 1, ncol
     n(ic)=0; DO ir=1, nmx; n(ic)=MAX(n(ic), LEN_TRIM(d(ir,ic))); END DO
   END DO
   n(:) = n(:) + 2*nm
 
+  !--- Build the vector of max column index in case the rows are too long (table must be displayed in multiple parts)
+  nHd = 1; IF(PRESENT(nHead)) nHd = nHead
+  IF(.NOT.PRESENT(nColMax)) THEN
+    nt = 1; ncmx = [ncol]
+  ELSE
+    nt = 1; l0 = SUM(n(1:nHd)+1)+1
+    IF(PRESENT(sub)) l0=l0+LEN_TRIM(subn)+1
+    !--- Count the number of table parts
+    l = l0; DO ic = nHd+1, ncol; l = l+n(ic)+1; IF(l>=nColMax) THEN; nt = nt+1; l = l0+n(ic)+1; END IF; END DO
+    !--- Get the index of the last column for each table part
+    ALLOCATE(ncmx(nt)); k = 1
+    l = l0; DO ic = nHd+1, ncol; l = l+n(ic)+1; IF(l>=nColMax) THEN; ncmx(k) = ic-1; l = l0+n(ic)+1; k = k+1; END IF; END DO
+    ncmx(nt) = ncol
+  END IF
+      
   !--- Display the strings array as a table
-  DO ir = 1, nmx; row = ''
-    DO ic = 1, ncol; el = d(ir,ic)
-      s1 = sp
-      row = TRIM(row)//REPEAT(' ',nm)//TRIM(el)//REPEAT(' ',n(ic)-LEN_TRIM(el)-nm)//s1
+  DO it = 1, nt
+    DO ir = 1, nmx; row = ''
+      DO ic = 1, nHd; el = d(ir,ic)
+        s1 = sp
+        row = TRIM(row)//REPEAT(' ',nm)//TRIM(el)//REPEAT(' ',n(ic)-LEN_TRIM(el)-nm)//s1
+      END DO
+      ib = nHd+1; IF(it>1) ib = ncmx(it-1)+1
+      DO ic = ib, ncmx(it); el = d(ir,ic)
+        s1 = sp
+        row = TRIM(row)//REPEAT(' ',nm)//TRIM(el)//REPEAT(' ',n(ic)-LEN_TRIM(el)-nm)//s1
+      END DO
+      nr = LEN_TRIM(row)-1                                           !--- Final separator removed
+      CALL msg(row(1:nr), subn, unit=unt)
+      IF(ir /= 1) CYCLE                                              !--- Titles only are underlined
+      row=''; DO ic=1,nHd; row=TRIM(row)//REPEAT('-',n(ic))//'+'; END DO
+      DO ic = ib,ncmx(it); row=TRIM(row)//REPEAT('-',n(ic))//'+'; END DO
+      CALL msg(row(1:LEN_TRIM(row)-1), subn, unit=unt)
     END DO
-    nr = LEN_TRIM(row)-1                                             !--- Final separator removed
-    CALL msg(row(1:nr), subn, unit=unt)
-    IF(ir /= 1) CYCLE                                                !--- Titles are underlined
-    row=''; DO ic=1,ncol; row=TRIM(row)//REPEAT('-',n(ic))//'+'; END DO
-    CALL msg(row(1:LEN_TRIM(row)-1), subn, unit=unt)
+    CALL msg('', subn, unit=unt)
   END DO
 
@@ -944,5 +1013,5 @@
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN)  :: rFmt          !--- Format for reals
   LOGICAL,          OPTIONAL, INTENT(IN)  :: llast         !--- Last variable: no final ','
-
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen)  :: rFm, el
   CHARACTER(LEN=maxlen), ALLOCATABLE :: d(:,:)
@@ -952,6 +1021,4 @@
   INTEGER, ALLOCATABLE :: n(:)
   LOGICAL :: ls, li, lr, la
-
-!  modname = 'dispNamelist'
   rFm = '*';    IF(PRESENT(rFmt)) rFm = rFmt               !--- Specified format for reals
   ls = PRESENT(s); li = PRESENT(i); lr = PRESENT(r)
@@ -970,5 +1037,5 @@
     lerr = COUNT([(p(ic:ic)=='r', ic=1, np)]) /= SIZE(r, DIM=2)
   END IF
-  IF(fmsg('string "pattern" length and arguments number mismatch', ll=lerr)) RETURN
+  IF(fmsg('display map "p" length and arguments number mismatch', ll=lerr)) RETURN
   lerr = ncol /= SIZE(titles); IF(fmsg('"titles" length and arguments number mismatch', ll=lerr)) RETURN
   lerr = ls.AND.li.AND.ns/=ni; IF(fmsg('string and integer arguments lengths mismatch', ll=lerr)) RETURN
@@ -989,4 +1056,7 @@
       CASE('r'); d(2:nrow,ic) = real2str(r(:,ir),rFm); ir = ir + 1
     END SELECT
+  END DO
+  CALL cleanZeros(d)
+  DO ic = 1, ncol
     n(ic) = 0; DO ir=1, nrow; n(ic)=MAX(n(ic), LEN_TRIM(d(ir,ic))); END DO
     IF(needQuotes(d(2,ic)) .AND. ic/=1) n(ic) = n(ic) + 2 !--- For quotes, using second line only
@@ -1016,5 +1086,5 @@
 
 !==============================================================================================================================
-LOGICAL FUNCTION dispOutliers_1(ll, a, n, err_msg, nam, subn, nmax, unit) RESULT(lerr)
+LOGICAL FUNCTION dispOutliers_1(ll, a, n, err_msg, nam, subn, nRowmax, nColMax, nHead, unit) RESULT(lerr)
 ! Display outliers list in tables
 ! If "nam" is supplied, it means the last index is for tracers => one table each tracer for rank > 2.
@@ -1022,11 +1092,14 @@
   REAL,                       INTENT(IN)  ::  a(:)                   !--- Linearized array of values
   INTEGER,                    INTENT(IN)  ::  n(:)                   !--- Profile before linearization
-
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN)  :: err_msg, nam(:), subn   !--- Error message, variables and calling subroutine names
-  INTEGER,          OPTIONAL, INTENT(IN)  :: nmax, unit              !--- Maximum number of lines to display (default: all)
+  INTEGER,          OPTIONAL, INTENT(IN)  :: nRowMax                 !--- Maximum number of lines to display    (default: all)
+  INTEGER,          OPTIONAL, INTENT(IN)  :: nColMax                 !--- Maximum number of characters per line (default: 2048)
+  INTEGER,          OPTIONAL, INTENT(IN)  :: nHead                   !--- Number of front columns to duplicate  (default: 1)
+  INTEGER,          OPTIONAL, INTENT(IN)  :: unit                    !--- Output unit                           (def: lunout)
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen),      ALLOCATABLE :: ttl(:)
   LOGICAL,                    ALLOCATABLE :: m(:)
   INTEGER,                    ALLOCATABLE :: ki(:), kj(:)
-  INTEGER                                 :: i, j, k, rk, rk1, ib, ie, itr, nm, unt, nmx, nv
+  INTEGER                                 :: i, j, k, rk, rk1, ib, ie, itr, nm, unt, nRmx, nCmx, nHd, nv
   CHARACTER(LEN=maxlen)                   :: mes, sub, fm='(f12.9)', v, s
   CHARACTER(LEN=maxlen),      ALLOCATABLE :: vnm(:)
@@ -1037,5 +1110,7 @@
   vnm = ['a'];            IF(PRESENT(nam ))    vnm = nam             !--- Variables names
   sub = 'dispOutliers';   IF(PRESENT(subn))    sub = subn            !--- Calling subroutine name
-  nmx = SIZE(a);          IF(PRESENT(nmax))    nmx = MIN(nmx,nmax)   !--- Maximum number of lines to print
+  nRmx= SIZE(a);          IF(PRESENT(nRowMax)) nRmx=MIN(nRmx,nRowMax)!-- Maximum number of lines to print
+  nCmx= 2048;             IF(PRESENT(nColMax)) nCmx=MIN(nCmx,nColMax)!-- Maximum number of characters each line
+  nHd = 1;                IF(PRESENT(nHead))   nHd = nHead           !--- Number of front columns to duplicate
   unt = lunout;           IF(PRESENT(unit))    unt = unit            !--- Unit to print messages
 
@@ -1061,6 +1136,8 @@
   IF(rk==1) THEN
     ALLOCATE(ttl(2)); ttl(2) = TRIM(vnm(1))//'(i)'; ttl(1) = 'i'
-    IF(nv == 1) lerr = dispTable('sr', ttl,               s=cat(PACK(nam,ll)), r=cat(PACK(a,ll)), rFmt=fm, nmax=nmax)
-    IF(nv /= 1) lerr = dispTable('ir', ['name ','value'], i=cat(PACK(ki,m)),   r=cat(PACK(a,ll)), rFmt=fm, nmax=nmax)
+    IF(nv == 1) lerr = dispTable('sr', ttl,               s=cat(PACK(nam,ll)), r=cat(PACK(a,ll)), &
+                                 rFmt=fm, nRowMax=nRmx, nColMax=nCmx, nHead=nHd, unit=unt, sub=sub)
+    IF(nv /= 1) lerr = dispTable('ir', ['name ','value'], i=cat(PACK(ki,m)),   r=cat(PACK(a,ll)), &
+                                 rFmt=fm, nRowMax=nRmx, nColMax=nCmx, nHead=nHd, unit=unt, sub=sub)
     CALL msg("can't display outliers table", sub, lerr, unt)
     RETURN
@@ -1078,6 +1155,8 @@
     IF(nv == 1) ttl(rk) = TRIM(v)//','//int2str(itr)//')'            !--- "<name>(i,j,itr)" (single name)
     IF(nv /= 1) ttl(rk) = TRIM(v)//')'                               !--- "<nam(itr)>(i,j)" (one name each table/itr index)
-    IF(rk==2) lerr = dispTable('ir',  ttl, i=cat(PACK(ki,m)),            r=cat(PACK(a(ib:ie),m)), rFmt=fm, nmax=nmax)
-    IF(rk==3) lerr = dispTable('iir', ttl, i=cat(PACK(ki,m),PACK(kj,m)), r=cat(PACK(a(ib:ie),m)), rFmt=fm, nmax=nmax)
+    IF(rk==2) lerr = dispTable('ir',  ttl, i=cat(PACK(ki,m)),            r=cat(PACK(a(ib:ie),m)), &
+                                 rFmt=fm, nRowMax=nRmx, nColMax=nCmx, nHead=nHd, unit=unt, sub=sub)
+    IF(rk==3) lerr = dispTable('iir', ttl, i=cat(PACK(ki,m),PACK(kj,m)), r=cat(PACK(a(ib:ie),m)), &
+                                 rFmt=fm, nRowMax=nRmx, nColMax=nCmx, nHead=nHd, unit=unt, sub=sub)
     CALL msg("can't display outliers table", sub, lerr, unt)
     IF(lerr) RETURN
@@ -1085,5 +1164,5 @@
 END FUNCTION dispOutliers_1
 !==============================================================================================================================
-LOGICAL FUNCTION dispOutliers_2(ll, a, n, err_msg, nam, subn, nmax, unit) RESULT(lerr)
+LOGICAL FUNCTION dispOutliers_2(ll, a, n, err_msg, nam, subn, nRowMax, nColMax, nHead, unit) RESULT(lerr)
 ! Display outliers list in tables
 ! If "nam" is supplied and, it means the last index is for tracers => one table each tracer for rank > 2.
@@ -1092,25 +1171,29 @@
   INTEGER,                    INTENT(IN)  ::  n(:)                   !--- Profile before linearization
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN)  :: err_msg, nam(:), subn   !--- Error message, variables and calling subroutine names
-  INTEGER,          OPTIONAL, INTENT(IN)  :: nmax, unit              !--- Maximum number of lines to display (default: all)
-
+  INTEGER,          OPTIONAL, INTENT(IN)  :: nRowMax                 !--- Maximum number of lines to display    (default: all)
+  INTEGER,          OPTIONAL, INTENT(IN)  :: nColMax                 !--- Maximum number of characters per line (default: 2048)
+  INTEGER,          OPTIONAL, INTENT(IN)  :: nHead                   !--- Number of front columns to duplicate  (default: 1)
+  INTEGER,          OPTIONAL, INTENT(IN)  :: unit                    !--- Output unit                           (def: lunout)
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen)                   :: mes, sub, fm='(f12.9)', prf
   CHARACTER(LEN=maxlen),      ALLOCATABLE :: ttl(:), vnm(:)
-  LOGICAL,                    ALLOCATABLE :: m(:)
   INTEGER,                    ALLOCATABLE :: ki(:), kj(:), kl(:)
-  INTEGER                                 :: i, j, k, rk, ib, ie, itr, nm, nv, unt, nmx, rk1
+  INTEGER                                 :: i, j, k, rk, nv, unt, nRmx, nCmx, nHd
   REAL,                       ALLOCATABLE :: val(:,:)
 
-  lerr = ANY(ll); IF(.NOT.lerr) RETURN                                    !--- No outliers -> finished
+  lerr = ANY(ll); IF(.NOT.lerr) RETURN                               !--- No outliers -> finished
   rk = SIZE(n); nv = SIZE(a,2)
-  mes = 'outliers found';         IF(PRESENT(err_msg)) mes = err_msg      !--- Error message
-  vnm = [(ACHAR(k+96),k=1,nv)];   IF(PRESENT(nam ))    vnm = nam          !--- Variables names
-  sub = 'dispOutliers';           IF(PRESENT(subn))    sub = subn         !--- Calling subroutine name
-  nmx = SIZE(a);                  IF(PRESENT(nmax))    nmx = MIN(nmx,nmax)!--- Maximum number of lines to print
-  unt = lunout;                   IF(PRESENT(unit))    unt = unit         !--- Unit to print messages
-  lerr = SIZE(vnm) /= nv;         IF(fmsg('SIZE(nam) /= SIZE(a,2)',                  sub, lerr, unt)) RETURN
-  lerr = SIZE(a,1) /= SIZE(ll);   IF(fmsg('"ll" and "a" sizes mismatch',             sub, lerr, unt)) RETURN
-  lerr = SIZE(a,1) /= PRODUCT(n); IF(fmsg('profile "n" does not match "a" and "ll"', sub, lerr, unt)) RETURN
-
-  SELECT CASE(rk1)                                                   !--- Indices list
+  mes = 'outliers found';        IF(PRESENT(err_msg)) mes = err_msg  !--- Error message
+  vnm = [(ACHAR(k+96),k=1,nv)];  IF(PRESENT(nam ))    vnm = nam      !--- Variables names
+  sub = 'dispOutliers';          IF(PRESENT(subn))    sub = subn     !--- Calling subroutine name
+  nRmx= SIZE(a);          IF(PRESENT(nRowMax)) nRmx=MIN(nRmx,nRowMax)!-- Maximum number of lines to print
+  nCmx= 2048;             IF(PRESENT(nColMax)) nCmx=MIN(nCmx,nColMax)!-- Maximum number of characters each line
+  nHd = 1;                IF(PRESENT(nHead))   nHd = nHead           !--- Number of front columns to duplicate
+  unt = lunout;                  IF(PRESENT(unit))    unt = unit     !--- Unit to print messages
+  lerr= SIZE(vnm) /= nv;         IF(fmsg('SIZE(nam) /= SIZE(a,2)',                  sub, lerr, unt)) RETURN
+  lerr= SIZE(a,1) /= SIZE(ll);   IF(fmsg('"ll" and "a" sizes mismatch',             sub, lerr, unt)) RETURN
+  lerr= SIZE(a,1) /= PRODUCT(n); IF(fmsg('profile "n" does not match "a" and "ll"', sub, lerr, unt)) RETURN
+
+  SELECT CASE(rk)                                                   !--- Indices list
     CASE(0); IF(ll(1)) THEN; WRITE(unt,'(a,", ",a," = ",2f12.9)')TRIM(vnm(1)),TRIM(vnm(2)),a(1,1),a(1,2); RETURN; END IF
     CASE(1); ki = [  (i,i=1,n(1)) ]
@@ -1124,8 +1207,10 @@
   prf = REPEAT('i',rk)//REPEAT('r',nv)                               !--- Profile
   ALLOCATE(val(COUNT(ll),nv)); DO k=1, nv; val(:,k) = PACK(a(:,k),ll); END DO
-  IF(rk == 1) lerr = dispTable(prf, ttl, i = cat(PACK(ki,ll)),             r = val, rFmt=fm, nmax=nmax)
-  IF(rk == 2) lerr = dispTable(prf, ttl, i = cat(PACK(ki,ll),PACK(kj,ll)), r = val, rFmt=fm, nmax=nmax)
-  IF(rk == 3) lerr = dispTable(prf, ttl, i = cat(PACK(ki,ll),PACK(kj,ll),PACK(kl,ll)), &
-                     r = val, rFmt=fm, nmax=nmax)
+  IF(rk == 1) lerr = dispTable(prf, ttl, i = cat(PACK(ki,ll)),                         r = val, &
+                                 rFmt=fm, nRowMax=nRmx, nColMax=nCmx, nHead=nHd, unit=unt, sub=sub)
+  IF(rk == 2) lerr = dispTable(prf, ttl, i = cat(PACK(ki,ll),PACK(kj,ll)),             r = val, &
+                                 rFmt=fm, nRowMax=nRmx, nColMax=nCmx, nHead=nHd, unit=unt, sub=sub)
+  IF(rk == 3) lerr = dispTable(prf, ttl, i = cat(PACK(ki,ll),PACK(kj,ll),PACK(kl,ll)), r = val, &
+                                 rFmt=fm, nRowMax=nRmx, nColMax=nCmx, nHead=nHd, unit=unt, sub=sub)
   CALL msg("can't display outliers table", sub, lerr, unt)
 END FUNCTION dispOutliers_2
@@ -1139,5 +1224,5 @@
   CHARACTER(LEN=*),      INTENT(IN)  :: str
   CHARACTER(LEN=maxlen), INTENT(OUT) :: val
-
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen)              :: v
   CHARACTER(LEN=1024)                :: s, vv
@@ -1146,5 +1231,4 @@
   INTEGER :: nl, nn, i, j, im, ix
   LOGICAL :: ll
-!  modname = 'reduceExpr_1'
   s = str
 
@@ -1193,15 +1277,13 @@
   CHARACTER(LEN=maxlen), ALLOCATABLE :: ky(:)
   CHARACTER(LEN=1),      ALLOCATABLE :: op(:)
-
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=1024) :: s
   DOUBLE PRECISION :: v, vm, vp
   INTEGER      :: i, ni, io
-
-!  modname = 'reduceExpr_basic'
   lerr = .FALSE.
   IF(is_numeric(str)) THEN; val=TRIM(str); RETURN; END IF
   op = ['^','/','*','+','-']                                                   !--- List of recognized operations
   s = str
-  IF(test(strParse_m(s, op, ky, .TRUE., id = id), lerr)) RETURN                !--- Parse the values
+  IF(test(strParse_m(s, op, ky, lSc=.TRUE., id = id), lerr)) RETURN            !--- Parse the values
   vl = str2dble(ky)                                                            !--- Conversion to doubles
   lerr = ANY(vl >= HUGE(1.d0))
@@ -1212,10 +1294,10 @@
       IF(id(i) /= io) CYCLE                                                    !--- Current found operator is not op(io)
       vm = vl(i); vp = vl(i+1)                                                 !--- Couple of values used for current operation
-      SELECT CASE(io)                                                          !--- Perform operation on the two values
-        CASE(1); v = vm**vp  !--- ^
-        CASE(2); v = vm/vp   !--- /
-        CASE(3); v = vm*vp   !--- *
-        CASE(4); v = vm+vp   !--- +
-        CASE(5); v = vm-vp   !--- +
+      SELECT CASE(op(io))                                                          !--- Perform operation on the two values
+        CASE('^'); v = vm**vp
+        CASE('/'); v = vm/vp
+        CASE('*'); v = vm*vp
+        CASE('+'); v = vm+vp
+        CASE('-'); v = vm-vp
       END SELECT
       IF(i == ni) THEN; vl = [vl(1:ni-1), v]; ELSE; vl = [vl(1:i-1), v, vl(i+2:ni+1)]; END IF
@@ -1233,4 +1315,5 @@
   CHARACTER(LEN=*),                   INTENT(IN)  :: str(:)
   CHARACTER(LEN=maxlen), ALLOCATABLE, INTENT(OUT) :: val(:)
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: i
   ALLOCATE(lerr(SIZE(str)),val(SIZE(str)))
@@ -1252,5 +1335,4 @@
   READ(str,fmt,IOSTAT=e) x
   out = e==0 .AND. INDEX('Ee',str(LEN_TRIM(str):LEN_TRIM(str)))==0
-  IF(str == '') out = .FALSE.
 END FUNCTION is_numeric
 !==============================================================================================================================
@@ -1298,4 +1380,5 @@
   INTEGER,           INTENT(IN) :: i
   INTEGER, OPTIONAL, INTENT(IN) :: nDigits
+!------------------------------------------------------------------------------------------------------------------------------
   WRITE(out,*)i
   out = ADJUSTL(out)
@@ -1307,4 +1390,5 @@
   REAL,                       INTENT(IN) :: r
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: fmt
+!------------------------------------------------------------------------------------------------------------------------------
   IF(     PRESENT(fmt)) WRITE(out,fmt)r
   IF(.NOT.PRESENT(fmt)) WRITE(out, * )r
@@ -1315,8 +1399,23 @@
   DOUBLE PRECISION,           INTENT(IN) :: d
   CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: fmt
+!------------------------------------------------------------------------------------------------------------------------------
   IF(     PRESENT(fmt)) WRITE(out,fmt)d
   IF(.NOT.PRESENT(fmt)) WRITE(out, * )d
   out = ADJUSTL(out)
 END FUNCTION dble2str
+!==============================================================================================================================
+ELEMENTAL SUBROUTINE cleanZeros(s)
+  CHARACTER(LEN=*), INTENT(INOUT) :: s
+  INTEGER :: ls, ix, i
+  IF(is_numeric(s)) THEN
+    ls = LEN_TRIM(s)
+    ix = MAX(INDEX(s,'E'),INDEX(s,'e'),INDEX(s,'D'),INDEX(s,'d'))
+    IF(ix == 0) THEN
+      DO ix = ls,1,-1; IF(s(ix:ix) /= '0') EXIT; END DO; s=s(1:ix+1)
+    ELSE IF(INDEX(s,'.')/=0) THEN
+      i = ix-1; DO WHILE(s(i:i) == '0'); i = i-1; END DO; s=s(1:i)//s(ix:ls)
+    END IF
+  END IF
+END SUBROUTINE cleanZeros
 !==============================================================================================================================
 
@@ -1332,4 +1431,5 @@
   CHARACTER(LEN=*), INTENT(IN)  :: s(:)
   CHARACTER(LEN=:), ALLOCATABLE :: out(:)
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: k, n
   n = MAXVAL(LEN_TRIM(s), MASK=.TRUE.)
@@ -1343,4 +1443,5 @@
   CHARACTER(LEN=*), INTENT(IN) :: s
   CHARACTER(LEN=1) :: b, e
+!------------------------------------------------------------------------------------------------------------------------------
   out = .TRUE.; IF(TRIM(s) == '') RETURN
   b = s(1:1); e = s(MAX(1,LEN_TRIM(s)):MAX(1,LEN_TRIM(s)))
@@ -1355,4 +1456,5 @@
 LOGICAL FUNCTION testFile_1(fname) RESULT(out)
   CHARACTER(LEN=*), INTENT(IN) :: fname
+!------------------------------------------------------------------------------------------------------------------------------
   INTEGER :: ierr
   OPEN(90, FILE=fname, FORM='formatted', STATUS='old', IOSTAT=ierr); CLOSE(99)
@@ -1364,4 +1466,5 @@
   CHARACTER(LEN=*), INTENT(IN) :: fname(:)
   INTEGER :: k
+!------------------------------------------------------------------------------------------------------------------------------
   out = [(testFile_1(fname(k)), k=1, SIZE(fname))]
 END FUNCTION testFile_m
@@ -1379,4 +1482,5 @@
   CHARACTER(LEN=*),   INTENT(IN)  :: message, items, reason
   INTEGER,  OPTIONAL, INTENT(IN)  :: nmax
+!------------------------------------------------------------------------------------------------------------------------------
   CHARACTER(LEN=maxlen), ALLOCATABLE :: s(:)
   INTEGER :: i, nmx
@@ -1401,4 +1505,3 @@
 
 
-
 END MODULE strings_mod
Index: LMDZ6/branches/Portage_acc/libf/misc/trac_types_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/misc/trac_types_mod.F90	(revision 4445)
+++ 	(revision )
@@ -1,55 +1,0 @@
-MODULE trac_types_mod
-
-  USE strings_mod, ONLY: maxlen
-  PRIVATE
-
-!=== TRACERS DESCRIPTOR DERIVED TYPE AND ASSOCIATED ROUTINES INTERFACES =======================================================
-  PUBLIC :: trac_type, isot_type, keys_type
-!------------------------------------------------------------------------------------------------------------------------------
-  TYPE :: keys_type                                        !=== TYPE FOR A SET OF KEYS ASSOCIATED TO AN ELEMENT
-    CHARACTER(LEN=maxlen)              :: name             !--- Tracer name
-    CHARACTER(LEN=maxlen), ALLOCATABLE :: key(:)           !--- Keys string list
-    CHARACTER(LEN=maxlen), ALLOCATABLE :: val(:)           !--- Corresponding values string list
-  END TYPE keys_type
-!------------------------------------------------------------------------------------------------------------------------------
-  TYPE :: trac_type                                        !=== TYPE FOR A SINGLE TRACER NAMED "name"
-    CHARACTER(LEN=maxlen) :: name        = ''              !--- Name of the tracer
-    CHARACTER(LEN=maxlen) :: gen0Name    = ''              !--- First generation ancestor name
-    CHARACTER(LEN=maxlen) :: parent      = ''              !--- Parent name
-    CHARACTER(LEN=maxlen) :: longName    = ''              !--- Long name (with advection scheme suffix)
-    CHARACTER(LEN=maxlen) :: type        = 'tracer'        !--- Type  (so far: 'tracer' / 'tag')
-    CHARACTER(LEN=maxlen) :: phase       = 'g'             !--- Phase ('g'as / 'l'iquid / 's'olid)
-    CHARACTER(LEN=maxlen) :: component   = ''              !--- Coma-separated list of components (Ex: lmdz,inca)
-    INTEGER               :: iadv        = 10              !--- Advection scheme used
-    INTEGER               :: iGeneration = -1              !--- Generation number (>=0)
-    LOGICAL               :: isAdvected  = .FALSE.         !--- "true" tracers: iadv > 0.   COUNT(isAdvected )=nqtrue
-    LOGICAL               :: isInPhysics = .TRUE.          !--- "true" tracers: in tr_seri. COUNT(isInPhysics)=nqtottr
-    INTEGER               :: iqParent    = 0               !--- Parent index
-    INTEGER,  ALLOCATABLE :: iqDescen(:)                   !--- Descendants index (in growing generation order)
-    INTEGER               :: nqDescen    = 0               !--- Number of descendants (all generations)
-    INTEGER               :: nqChilds    = 0               !--- Number of childs    (first generation)
-    INTEGER               :: iso_iGroup  = 0               !--- Isotopes group index in isotopes(:)
-    INTEGER               :: iso_iName   = 0               !--- Isotope  name  index in isotopes(iso_iGroup)%trac(:)
-    INTEGER               :: iso_iZone   = 0               !--- Isotope  zone  index in isotopes(iso_iGroup)%zone(:)
-    INTEGER               :: iso_iPhase  = 0               !--- Isotope  phase index in isotopes(iso_iGroup)%phas
-    TYPE(keys_type)       :: keys                          !--- <key>=<val> pairs vector
-  END TYPE trac_type
-!------------------------------------------------------------------------------------------------------------------------------
-  TYPE :: isot_type                                        !=== TYPE FOR AN ISOTOPES FAMILY DESCENDING ON TRACER "parent"
-    CHARACTER(LEN=maxlen)              :: parent           !--- Isotopes family name (parent tracer name ; ex: H2O)
-    LOGICAL                            :: check=.FALSE.    !--- Triggering of the checking routines
-    TYPE(keys_type),       ALLOCATABLE :: keys(:)          !--- Isotopes keys/values pairs list     (length: niso)
-    CHARACTER(LEN=maxlen), ALLOCATABLE :: trac(:)          !--- Isotopes + tagging tracers list     (length: ntiso)
-    CHARACTER(LEN=maxlen), ALLOCATABLE :: zone(:)          !--- Geographic tagging zones names list (length: nzone)
-    CHARACTER(LEN=maxlen)              :: phase = 'g'      !--- Phases list: [g][l][s]              (length: nphas)
-    INTEGER                            :: niso  = 0        !--- Number of isotopes, excluding tagging tracers
-    INTEGER                            :: nzone = 0        !--- Number of geographic tagging zones
-    INTEGER                            :: ntiso = 0        !--- Number of isotopes, including tagging tracers
-    INTEGER                            :: nphas = 0        !--- Number phases
-    INTEGER,               ALLOCATABLE :: iqTraPha(:,:)    !--- Idx in "tracers(1:nqtot)" = f(name(1:ntiso)),phas)
-                                                           !---        "iqTraPha" former name: "iqiso"
-    INTEGER,               ALLOCATABLE :: itZonIso(:,:)    !--- Idx in "trac(1:ntiso)" = f(zone, name(1:niso))
-                                                           !---        "itZonIso" former name: "index_trac"
-  END TYPE isot_type
-
-END MODULE trac_types_mod
Index: LMDZ6/branches/Portage_acc/libf/misc/wxios.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/misc/wxios.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/misc/wxios.F90	(revision 4446)
@@ -140,4 +140,5 @@
 !            CALL wxios_context_init()
 !        ENDIF
+         WRITE(*,*)'END of WXIOS_INIT', g_comm , g_ctx_name 
 
     END SUBROUTINE wxios_init
Index: LMDZ6/branches/Portage_acc/libf/phy_common/physics_distribution_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phy_common/physics_distribution_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phy_common/physics_distribution_mod.F90	(revision 4446)
@@ -37,10 +37,8 @@
 #endif
 
+#ifdef REPROBUS
 ! Initialization of Reprobus
-    IF (type_trac == 'repr') THEN
-#ifdef REPROBUS
-       CALL Init_chem_rep_phys(klon_omp,nbp_lev)
+    IF (type_trac == 'repr') CALL Init_chem_rep_phys(klon_omp,nbp_lev)
 #endif
-    END IF
 
 !$OMP END PARALLEL
@@ -71,10 +69,9 @@
 !    CALL Init_dimphy(klon_omp,nbp_lev)
 !
+!#ifdef REPROBUS
 !! Initialization of Reprobus
-!    IF (type_trac == 'repr') THEN
-!#ifdef REPROBUS
-!       CALL Init_chem_rep_phys(klon_omp,nbp_lev)
+!    IF (type_trac == 'repr') CALL Init_chem_rep_phys(klon_omp,nbp_lev)
+!    END IF
 !#endif
-!    END IF
 !
 !!$OMP END PARALLEL
Index: LMDZ6/branches/Portage_acc/libf/phy_common/vertical_layers_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phy_common/vertical_layers_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phy_common/vertical_layers_mod.F90	(revision 4446)
@@ -15,8 +15,10 @@
    REAL,SAVE,ALLOCATABLE :: presnivs(:) ! reference pressure at mid-layer (Pa),
                                         ! based on preff, ap and bp
+   REAL,SAVE,ALLOCATABLE :: presinter(:) ! reference pressure at interface (Pa),
+                                        ! based on preff, ap and bp
    REAL,SAVE,ALLOCATABLE :: pseudoalt(:) ! pseudo-altitude of model layers (km),
                                          ! based on preff and scaleheight
    
-!$OMP THREADPRIVATE(preff,scaleheight,ap,bp,aps,bps,presnivs,pseudoalt)
+!$OMP THREADPRIVATE(preff,scaleheight,ap,bp,aps,bps,presnivs,presinter,pseudoalt)
 
 
@@ -24,5 +26,5 @@
 
   SUBROUTINE init_vertical_layers(nlayer,preff_,scaleheight_,ap_,bp_,&
-                                 aps_,bps_,presnivs_, pseudoalt_)
+                                 aps_,bps_,presnivs_, presinter_, pseudoalt_)
     IMPLICIT NONE
     INTEGER,INTENT(IN) :: nlayer ! number of atmospheric layers
@@ -34,4 +36,5 @@
     REAL,INTENT(IN)    :: bps_(nlayer) ! hybrid coordinate at mid-layer
     REAL,INTENT(IN)    :: presnivs_(nlayer) ! Appproximative pressure of atm. layers (Pa)
+    REAL,INTENT(IN)    :: presinter_(nlayer+1) ! Appproximative pressure of atm. layers (Pa)
     REAL,INTENT(IN)    :: pseudoalt_(nlayer) ! pseudo-altitude of atm. layers (km)
   
@@ -41,4 +44,5 @@
     ALLOCATE(bps(nlayer))
     ALLOCATE(presnivs(nlayer))
+    ALLOCATE(presinter(nlayer+1))
     ALLOCATE(pseudoalt(nlayer))
   
@@ -50,4 +54,5 @@
     bps(:) = bps_(:)
     presnivs(:) = presnivs_(:)
+    presinter(:) = presinter_(:)
     pseudoalt(:) = pseudoalt_(:)
 
Index: LMDZ6/branches/Portage_acc/libf/phydev/infotrac_phy.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phydev/infotrac_phy.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phydev/infotrac_phy.F90	(revision 4446)
@@ -4,23 +4,20 @@
 MODULE infotrac_phy
 
-! Information on tracers for physics;
-! nqtot : total number of tracers and higher order of moment, water vapor and liquid included
-  INTEGER, SAVE :: nqtot
-!$OMP THREADPRIVATE(nqtot)
-
-  CHARACTER(len=4),SAVE :: type_trac
-!$OMP THREADPRIVATE(type_trac)
+   USE strings_mod, ONLY: maxlen
+   INTEGER,                 SAVE :: nqtot                       !--- Tracers nb in dynamics (incl. higher moments + H2O)
+   CHARACTER(LEN=maxlen),   SAVE :: type_trac                   !--- Keyword for tracers type
+!$OMP THREADPRIVATE(nqtot, type_trac)
 
 CONTAINS
 
-  SUBROUTINE init_infotrac_phy(nqtot_,type_trac_)
-  ! transfer information on tracers from dynamics to physics
-  IMPLICIT NONE
-    INTEGER,INTENT(IN) :: nqtot_
-    CHARACTER(len=4),INTENT(IN) :: type_trac_
+SUBROUTINE init_infotrac_phy(nqtot_, type_trac_)
+   IMPLICIT NONE
+   INTEGER,          INTENT(IN) :: nqtot_
+   CHARACTER(LEN=*), INTENT(IN) :: type_trac_
+   CHARACTER(LEN=maxlen) :: modname='init_infotrac_phy'
 
-    nqtot=nqtot_
-    type_trac=type_trac_
-  
+   nqtot = nqtot_
+   type_trac = type_trac_
+
   END SUBROUTINE init_infotrac_phy
 
Index: LMDZ6/branches/Portage_acc/libf/phylmd/Dust/phys_output_write_spl_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/Dust/phys_output_write_spl_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/Dust/phys_output_write_spl_mod.F90	(revision 4446)
@@ -381,5 +381,5 @@
     USE pbl_surface_mod, ONLY: snow
     USE indice_sol_mod, ONLY: nbsrf
-    USE infotrac, ONLY: nqtot, nbtr, type_trac
+    USE infotrac, ONLY: nqtot, nbtr, tracers
     USE geometry_mod, ONLY: cell_area
     USE surface_data, ONLY: type_ocean, version_ocean, ok_veget, landice_opt
@@ -401,5 +401,5 @@
 !   INCLUDE "temps.h"
     INCLUDE "clesphys.h"
-    INCLUDE "thermcell.h"
+    INCLUDE "alpale.h"
     INCLUDE "compbl.h"
     INCLUDE "YOMCST.h"
Index: LMDZ6/branches/Portage_acc/libf/phylmd/Dust/phytracr_spl_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/Dust/phytracr_spl_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/Dust/phytracr_spl_mod.F90	(revision 4446)
@@ -820,4 +820,6 @@
 ! 1/ le call phytrac se fait avec nqmax-2 donc nous avons bien 
 ! les vrais traceurs (nbtr) dans phytrac (pas la vapeur ni eau liquide)
+!! AS : nqmax-2 devrait etre nqmax-3 apres introducton de H2Oi ; 
+!!   et c'est encore different avec le parser de DC ?
 !======================================================================
 #include "dimensions.h"
@@ -827,5 +829,5 @@
 #include "YOETHF.h"
 #include "paramet.h"
-#include "thermcell.h"
+#include "alpale.h"
 
 !======================================================================
@@ -1264,5 +1266,5 @@
          IF(.NOT.tracers(iq)%isInPhysics) CYCLE
          itr = itr+1
-         write(str2,'(i2.2)') itr
+         write(str2,'(i2.2)') itrr
          call iophys_ecrit('TRA'//str2,klev,'SOURCE','',tr_seri(:,:,itr))
       enddo
@@ -1574,6 +1576,6 @@
       ENDIF
 ! JE   initializon to cero the tracers     
-!         DO it=1, nbtr
-!            tr_seri(:,:,it)=0.0
+!         DO itr=1,nbtr
+!            tr_seri(:,:,itr)=0.0
 !         ENDDO
 ! JE end     
@@ -1581,12 +1583,12 @@
 !        tr_seri(:,:,:)=0.0
 !
-!        DO it=1,nbtr
-!           trm_aux(it)=0.0
-!           src_aux(it)=0.0
-!           diag_trm(it)=0.0
-!           diag_drydep(it)=0.0
-!           diag_wetdep(it)=0.0
-!           diag_cvtdep(it)=0.0
-!           diag_emissn(it)=0.0
+!        DO itr=1,nbtr
+!           trm_aux(itr)=0.0
+!           src_aux(itr)=0.0
+!           diag_trm(itr)=0.0
+!           diag_drydep(itr)=0.0
+!           diag_wetdep(itr)=0.0
+!           diag_cvtdep(itr)=0.0
+!           diag_emissn(itr)=0.0
 !        ENDDO
 !        diag_g2part=0.0
@@ -1764,36 +1766,36 @@
 
 !
-      DO it=1, nbtr
+      DO itr=1,nbtr
        DO k=1,klev
         DO i=1,klon
-         d_tr_cv(i,k,it)=0.
-         d_tr_trsp(i,k,it)=0.
-         d_tr_sscav(i,k,it)=0.
-         d_tr_sat(i,k,it)=0.
-         d_tr_uscav(i,k,it)=0.
-         d_tr(i,k,it)=0.
-         d_tr_insc(i,k,it)=0.
-         d_tr_bcscav(i,k,it)=0.
-         d_tr_evapls(i,k,it)=0.
-         d_tr_ls(i,k,it)=0.
-         d_tr_cl(i,k,it)=0.
-         d_tr_th(i,k,it)=0.
+         d_tr_cv(i,k,itr)=0.
+         d_tr_trsp(i,k,itr)=0.
+         d_tr_sscav(i,k,itr)=0.
+         d_tr_sat(i,k,itr)=0.
+         d_tr_uscav(i,k,itr)=0.
+         d_tr(i,k,itr)=0.
+         d_tr_insc(i,k,itr)=0.
+         d_tr_bcscav(i,k,itr)=0.
+         d_tr_evapls(i,k,itr)=0.
+         d_tr_ls(i,k,itr)=0.
+         d_tr_cl(i,k,itr)=0.
+         d_tr_th(i,k,itr)=0.
   
-         d_tr_cv_o(i,k,it)=0.
-         d_tr_trsp_o(i,k,it)=0.
-         d_tr_sscav_o(i,k,it)=0.
-         d_tr_sat_o(i,k,it)=0.
-         d_tr_uscav_o(i,k,it)=0.
-
-
-         qDi(i,k,it)=0.
-         qPr(i,k,it)=0.
-         qPa(i,k,it)=0.
-         qMel(i,k,it)=0.
-         qTrdi(i,k,it)=0.
-         dtrcvMA(i,k,it)=0.
-         zmfd1a(i,k,it)=0.
-         zmfdam(i,k,it)=0.
-         zmfphi2(i,k,it)=0.
+         d_tr_cv_o(i,k,itr)=0.
+         d_tr_trsp_o(i,k,itr)=0.
+         d_tr_sscav_o(i,k,itr)=0.
+         d_tr_sat_o(i,k,itr)=0.
+         d_tr_uscav_o(i,k,itr)=0.
+
+
+         qDi(i,k,itr)=0.
+         qPr(i,k,itr)=0.
+         qPa(i,k,itr)=0.
+         qMel(i,k,itr)=0.
+         qTrdi(i,k,itr)=0.
+         dtrcvMA(i,k,itr)=0.
+         zmfd1a(i,k,itr)=0.
+         zmfdam(i,k,itr)=0.
+         zmfphi2(i,k,itr)=0.
         END DO
        END DO
@@ -1801,27 +1803,27 @@
 
 
-      DO it=1, nbtr
+      DO itr=1,nbtr
        DO i=1,klon
-          qPrls(i,it)=0.0
-          dtrconv(i,it)=0.0
+          qPrls(i,itr)=0.0
+          dtrconv(i,itr)=0.0
 !JE20140507<<
-          d_tr_dry(i,it)=0.0
-          flux_tr_dry(i,it)=0.0
+          d_tr_dry(i,itr)=0.0
+          flux_tr_dry(i,itr)=0.0
 !JE20140507>>
        ENDDO
       ENDDO
 
-      DO it=1, nbtr
+      DO itr=1,nbtr
       DO i=1, klon 
-        his_dh(i,it)=0.0
-        his_dhlsc(i,it)=0.0
-        his_dhcon(i,it)=0.0
-        his_dhbclsc(i,it)=0.0
-        his_dhbccon(i,it)=0.0
-        trm(i,it)=0.0
-        his_th(i,it)=0.0
-        his_dhkecv(i,it)=0.0
-        his_ds(i,it)=0.0
-        his_dhkelsc(i,it)=0.0
+        his_dh(i,itr)=0.0
+        his_dhlsc(i,itr)=0.0
+        his_dhcon(i,itr)=0.0
+        his_dhbclsc(i,itr)=0.0
+        his_dhbccon(i,itr)=0.0
+        trm(i,itr)=0.0
+        his_th(i,itr)=0.0
+        his_dhkecv(i,itr)=0.0
+        his_ds(i,itr)=0.0
+        his_dhkelsc(i,itr)=0.0
 
       ENDDO
@@ -2065,8 +2067,8 @@
 !=======================================================================
 !
-      DO it=1, nbtr
+      DO itr=1,nbtr
         DO j=1,klev
         DO i=1,klon
-           tmp_var(i,j)=tr_seri(i,j,it)
+           tmp_var(i,j)=tr_seri(i,j,itr)
         ENDDO
         ENDDO
@@ -2074,5 +2076,5 @@
         DO j=1,klev
         DO i=1,klon
-           tr_seri(i,j,it)=tmp_var(i,j)
+           tr_seri(i,j,itr)=tmp_var(i,j)
         ENDDO
         ENDDO
@@ -2091,9 +2093,9 @@
 !
       IF (lminmax) THEN
-        DO it=1,nbtr
-        CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_avt_coarem')
+        DO itr=1,nbtr
+        CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_avt_coarem')
         ENDDO        
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'avt coarem')
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'avt coarem')
         ENDDO
         CALL minmaxsource(source_tr,qmin,qmax,'src: avt coarem')
@@ -2128,12 +2130,12 @@
 !     .                                         MAXVAL(tr_seri(:,:,3))
 #ifdef IOPHYS_DUST
-      do it=1,nbtr
-         write(str2,'(i2.2)') it
-         call iophys_ecrit('sav'//str2,1,'SOURCE','',source_tr(:,it))
-         call iophys_ecrit('fav'//str2,1,'SOURCE','',source_tr(:,it))
+      do itr=1,nbtr
+         write(str2,'(i2.2)') itr
+         call iophys_ecrit('sav'//str2,1,'SOURCE','',source_tr(:,itr))
+         call iophys_ecrit('fav'//str2,1,'SOURCE','',source_tr(:,itr))
       enddo
-      do it=1,nbtr
-         write(str2,'(i2.2)') it
-         call iophys_ecrit('TRB'//str2,klev,'SOURCE','',tr_seri(:,:,it))
+      do itr=1,nbtr
+         write(str2,'(i2.2)') itr
+         call iophys_ecrit('TRB'//str2,klev,'SOURCE','',tr_seri(:,:,itr))
       enddo
 #endif
@@ -2161,17 +2163,17 @@
 
 #ifdef IOPHYS_DUST
-      do it=1,nbtr
-         write(str2,'(i2.2)') it
-         call iophys_ecrit('sap'//str2,1,'SOURCE','',source_tr(:,it))
-         call iophys_ecrit('fap'//str2,1,'SOURCE','',source_tr(:,it))
+      do itr=1,nbtr
+         write(str2,'(i2.2)') itr
+         call iophys_ecrit('sap'//str2,1,'SOURCE','',source_tr(:,itr))
+         call iophys_ecrit('fap'//str2,1,'SOURCE','',source_tr(:,itr))
       enddo
 #endif
 
       IF (lminmax) THEN
-        DO it=1,nbtr
-        CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_after_coarem')
-        ENDDO
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'after coarem')
+        DO itr=1,nbtr
+        CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_after_coarem')
+        ENDDO
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'after coarem')
         ENDDO
         CALL minmaxsource(source_tr,qmin,qmax,'src: after coarem')
@@ -2245,9 +2247,9 @@
 !
       IF (lminmax) THEN
-        DO it=1,nbtr
-        CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_after precur')
-        ENDDO
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'after precur')
+        DO itr=1,nbtr
+        CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_after precur')
+        ENDDO
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'after precur')
         ENDDO
         CALL minmaxsource(source_tr,qmin,qmax,'src: after precur')
@@ -2259,8 +2261,8 @@
 #ifdef IOPHYS_DUST
 !
-      do it=1,nbtr
-         write(str2,'(i2.2)') it
-         call iophys_ecrit('tpr'//str2,1,'SOURCE','',source_tr(:,it))
-         call iophys_ecrit('fpr'//str2,1,'SOURCE','',flux_tr(:,it))
+      do itr=1,nbtr
+         write(str2,'(i2.2)') itr
+         call iophys_ecrit('tpr'//str2,1,'SOURCE','',source_tr(:,itr))
+         call iophys_ecrit('fpr'//str2,1,'SOURCE','',flux_tr(:,itr))
       enddo
 #endif
@@ -2279,13 +2281,13 @@
 !
       IF (lminmax) THEN
-        DO it=1,nbtr
-        CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_after_fineem')
-        ENDDO
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'after fineem')
+        DO itr=1,nbtr
+        CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_after_fineem')
+        ENDDO
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'after fineem')
         ENDDO
       IF (lcheckmass) THEN
-        DO it=1,nbtr
-         CALL checkmass(tr_seri(:,:,it),RNAVO,masse(it),zdz,   &
+        DO itr=1,nbtr
+         CALL checkmass(tr_seri(:,:,itr),RNAVO,masse(itr),zdz,   &
            pplay,t_seri,iscm3,'after fineem')                  
         ENDDO
@@ -2306,8 +2308,8 @@
 
 #ifdef IOPHYS_DUST
-      do it=1,nbtr
-         write(str2,'(i2.2)') it
-         call iophys_ecrit('t'//str2,1,'SOURCE','',source_tr(:,it))
-         call iophys_ecrit('f'//str2,1,'SOURCE','',flux_tr(:,it))
+      do itr=1,nbtr
+         write(str2,'(i2.2)') itr
+         call iophys_ecrit('t'//str2,1,'SOURCE','',source_tr(:,itr))
+         call iophys_ecrit('f'//str2,1,'SOURCE','',flux_tr(:,itr))
       enddo
 #endif
@@ -2322,6 +2324,6 @@
 !=======================================================================
 !
-!        DO it=1,nbtr
-!         CALL checkmass(tr_seri(:,:,it),RNAVO,masse(it),zdz,
+!        DO itr=1,nbtr
+!         CALL checkmass(tr_seri(:,:,itr),RNAVO,masse(itr),zdz,
 !     .      pplay,t_seri,iscm3,'')
 !        ENDDO
@@ -2334,8 +2336,8 @@
       ENDIF
 
-      DO it=1, nbtr
+      DO itr=1,nbtr
          DO j=1,klev
          DO i=1,klon
-           tmp_var(i,j)=tr_seri(i,j,it)
+           tmp_var(i,j)=tr_seri(i,j,itr)
          ENDDO 
          ENDDO
@@ -2343,5 +2345,5 @@
          DO j=1,klev
          DO i=1,klon
-           tr_seri(i,j,it)=tmp_var(i,j)
+           tr_seri(i,j,itr)=tmp_var(i,j)
          ENDDO 
          ENDDO
@@ -2350,13 +2352,13 @@
 !----------------------------
       IF (lminmax) THEN
-        DO it=1,nbtr
-        CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_before_depo')
-        ENDDO
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'before depo')
+        DO itr=1,nbtr
+        CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_before_depo')
+        ENDDO
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'before depo')
         ENDDO
       IF (lcheckmass) THEN
-        DO it=1,nbtr
-         CALL checkmass(tr_seri(:,:,it),RNAVO,masse(it),zdz, &
+        DO itr=1,nbtr
+         CALL checkmass(tr_seri(:,:,itr),RNAVO,masse(itr),zdz, &
            pplay,t_seri,iscm3,'before depo')
         ENDDO
@@ -2366,7 +2368,7 @@
 
 #ifdef IOPHYS_DUST
-      do it=1,nbtr
-         write(str2,'(i2.2)') it
-         call iophys_ecrit('TRC'//str2,klev,'SOURCE','',tr_seri(:,:,it))
+      do itr=1,nbtr
+         write(str2,'(i2.2)') itr
+         call iophys_ecrit('TRC'//str2,klev,'SOURCE','',tr_seri(:,:,itr))
       enddo
 #endif
@@ -2378,13 +2380,13 @@
 !
       IF (lminmax) THEN
-        DO it=1,nbtr
-        CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_after_depo')
-        ENDDO
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'after depo')
+        DO itr=1,nbtr
+        CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_after_depo')
+        ENDDO
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'after depo')
         ENDDO
       IF (lcheckmass) THEN
-        DO it=1,nbtr
-         CALL checkmass(tr_seri(:,:,it),RNAVO,masse(it),zdz,   &
+        DO itr=1,nbtr
+         CALL checkmass(tr_seri(:,:,itr),RNAVO,masse(itr),zdz,   &
            pplay,t_seri,iscm3,'after depo')
         ENDDO
@@ -2408,7 +2410,7 @@
 
 #ifdef IOPHYS_DUST
-      do it=1,nbtr
-         write(str2,'(i2.2)') it
-         call iophys_ecrit('TRD'//str2,klev,'SOURCE','',tr_seri(:,:,it))
+      do itr=1,nbtr
+         write(str2,'(i2.2)') itr
+         call iophys_ecrit('TRD'//str2,klev,'SOURCE','',tr_seri(:,:,itr))
       enddo
 #endif
@@ -2428,9 +2430,9 @@
       END DO
 !
-      DO it=1, nbtr
+      DO itr=1,nbtr
       DO j=1, klev
       DO i=1, klon
-        tmp_var(i,j)=tr_seri(i,j,it)
-        aux_var2(i)=source_tr(i,it)
+        tmp_var(i,j)=tr_seri(i,j,itr)
+        aux_var2(i)=source_tr(i,itr)
       ENDDO
       ENDDO
@@ -2443,22 +2445,22 @@
 !KE
       CALL cltrac(pdtphys, coefh,t_seri,tmp_var,aux_var2,paprs,pplay,  &
-                 delp,aux_var3,d_tr_dry,flux_tr_dry(:,it))
+                 delp,aux_var3,d_tr_dry,flux_tr_dry(:,itr))
       ENDIF
 
       DO i=1, klon
       DO j=1, klev
-        tr_seri(i,j,it)=tmp_var(i,j)
-        d_tr(i,j,it)=aux_var3(i,j)
-        d_tr_cl(i,j,it)=d_tr(i,j,it)
+        tr_seri(i,j,itr)=tmp_var(i,j)
+        d_tr(i,j,itr)=aux_var3(i,j)
+        d_tr_cl(i,j,itr)=d_tr(i,j,itr)
       ENDDO
       ENDDO
       DO k = 1, klev
       DO i = 1, klon
-         tr_seri(i,k,it) = tr_seri(i,k,it) + d_tr(i,k,it)
+         tr_seri(i,k,itr) = tr_seri(i,k,itr) + d_tr(i,k,itr)
       ENDDO
       ENDDO
       print *,' AFTER Cltrac'
       IF (lminmax) THEN
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'after cltrac')
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'after cltrac')
       ENDIF
       ENDDO !--end itr loop
@@ -2484,7 +2486,7 @@
       call iophys_ecrit('yv1',1,'yv1','',yv1)
       call iophys_ecrit('delp',klev,'delp','',delp)
-      do it=1,nbtr
-         write(str2,'(i2.2)') it
-         call iophys_ecrit('TRE'//str2,klev,'SOURCE','',tr_seri(:,:,it))
+      do itr=1,nbtr
+         write(str2,'(i2.2)') itr
+         call iophys_ecrit('TRE'//str2,klev,'SOURCE','',tr_seri(:,:,itr))
       enddo
 #endif
@@ -2503,13 +2505,13 @@
       
        IF (lminmax) THEN
-        DO it=1,nbtr
-       CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_before therm')
-        ENDDO
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'before therm')
+        DO itr=1,nbtr
+       CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_before therm')
+        ENDDO
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'before therm')
         ENDDO
       IF (lcheckmass) THEN
-        DO it=1,nbtr
-         CALL checkmass(tr_seri(:,:,it),RNAVO,masse(it),zdz,  &
+        DO itr=1,nbtr
+         CALL checkmass(tr_seri(:,:,itr),RNAVO,masse(itr),zdz,  &
            pplay,t_seri,iscm3,'before therm')
         ENDDO
@@ -2518,11 +2520,11 @@
       ENDIF
 
-      DO it=1,nbtr
+      DO itr=1,nbtr
          DO k=1,klev
             DO i=1,klon
-               tmp_var3(i,k,it)=tr_seri(i,k,it)
-               d_tr_th(i,k,it)=0.
-               tr_seri(i,k,it)=MAX(tr_seri(i,k,it),0.)
-!JE: precursor >>1e10         tr_seri(i,k,it)=MIN(tr_seri(i,k,it),1.e10)
+               tmp_var3(i,k,itr)=tr_seri(i,k,itr)
+               d_tr_th(i,k,itr)=0.
+               tr_seri(i,k,itr)=MAX(tr_seri(i,k,itr),0.)
+!JE: precursor >>1e10         tr_seri(i,k,itr)=MIN(tr_seri(i,k,itr),1.e10)
             END DO
          END DO
@@ -2530,14 +2532,14 @@
 
 !JE  new implicit scheme 20140323
-      DO it=1,nbtr
+      DO itr=1,nbtr
         CALL thermcell_dq(klon,klev,1,pdtphys,fm_therm,entr_therm,  &
-                         zmasse,tr_seri(1:klon,1:klev,it),         &
-                         d_tr(1:klon,1:klev,it),ztra_th,0 )
+                         zmasse,tr_seri(1:klon,1:klev,itr),         &
+                         d_tr(1:klon,1:klev,itr),ztra_th,0 )
 
         DO k=1,klev
            DO i=1,klon
-              d_tr(i,k,it)=pdtphys*d_tr(i,k,it)
-              d_tr_th(i,k,it)=d_tr_th(i,k,it)+d_tr(i,k,it)
-              tr_seri(i,k,it)=MAX(tr_seri(i,k,it)+d_tr(i,k,it),0.)
+              d_tr(i,k,itr)=pdtphys*d_tr(i,k,itr)
+              d_tr_th(i,k,itr)=d_tr_th(i,k,itr)+d_tr(i,k,itr)
+              tr_seri(i,k,itr)=MAX(tr_seri(i,k,itr)+d_tr(i,k,itr),0.)
               END DO
         END DO
@@ -2547,15 +2549,15 @@
 ! old scheme explicit
 !       nsplit=10
-!       DO it=1,nbtr
+!       DO itr=1,nbtr
 !          DO isplit=1,nsplit
 !              CALL dqthermcell(klon,klev,pdtphys/nsplit, 
 !     .            fm_therm,entr_therm,zmasse, 
-!     .            tr_seri(1:klon,1:klev,it),
-!     .            d_tr(1:klon,1:klev,it),ztra_th)
+!     .            tr_seri(1:klon,1:klev,itr),
+!     .            d_tr(1:klon,1:klev,itr),ztra_th)
 !            DO k=1,klev
 !               DO i=1,klon
-!                  d_tr(i,k,it)=pdtphys*d_tr(i,k,it)/nsplit
-!                  d_tr_th(i,k,it)=d_tr_th(i,k,it)+d_tr(i,k,it)
-!                  tr_seri(i,k,it)=MAX(tr_seri(i,k,it)+d_tr(i,k,it),0.)
+!                  d_tr(i,k,itr)=pdtphys*d_tr(i,k,itr)/nsplit
+!                  d_tr_th(i,k,itr)=d_tr_th(i,k,itr)+d_tr(i,k,itr)
+!                  tr_seri(i,k,itr)=MAX(tr_seri(i,k,itr)+d_tr(i,k,itr),0.)
 !               END DO
 !            END DO
@@ -2564,13 +2566,13 @@
 !JE end modif 20140323
 
-      DO it=1,nbtr
+      DO itr=1,nbtr
          DO k=1,klev
             DO i=1,klon
-          tmp_var(i,k)=tr_seri(i,k,it)-tmp_var3(i,k,it)
+          tmp_var(i,k)=tr_seri(i,k,itr)-tmp_var3(i,k,itr)
             ENDDO
          ENDDO
        IF (lminmax) THEN
       IF (lcheckmass) THEN
-         CALL checkmass(tmp_var(:,:),RNAVO,masse(it),zdz,  &
+         CALL checkmass(tmp_var(:,:),RNAVO,masse(itr),zdz,  &
            pplay,t_seri,iscm3,'dtr therm ')
       ENDIF
@@ -2580,7 +2582,7 @@
          DO k=1,klev
             DO i=1,klon
-               his_th(i,it)=his_th(i,it)+    &
+               his_th(i,itr)=his_th(i,itr)+    &
                            (tmp_var(i,k))/RNAVO*   &
-                     masse(it)*1.e3*1.e6*zdz(i,k)/pdtphys
+                     masse(itr)*1.e3*1.e6*zdz(i,k)/pdtphys
             END DO !klon
          END DO !klev
@@ -2588,13 +2590,13 @@
       END DO !it
        IF (lminmax) THEN
-        DO it=1,nbtr
-       CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_after therm')
-        ENDDO
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'after therm')
+        DO itr=1,nbtr
+       CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_after therm')
+        ENDDO
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'after therm')
         ENDDO
       IF (lcheckmass) THEN
-        DO it=1,nbtr
-         CALL checkmass(tr_seri(:,:,it),RNAVO,masse(it),zdz,   &
+        DO itr=1,nbtr
+         CALL checkmass(tr_seri(:,:,itr),RNAVO,masse(itr),zdz,   &
            pplay,t_seri,iscm3,'after therm')
         ENDDO
@@ -2621,8 +2623,8 @@
 
 
-      DO it=1,nbtr
+      DO itr=1,nbtr
       DO j=1,klev
       DO i=1,klon
-         tmp_var(i,j)=tr_seri(i,j,it)
+         tmp_var(i,j)=tr_seri(i,j,itr)
       ENDDO
       ENDDO
@@ -2630,5 +2632,5 @@
       DO j=1,klev
       DO i=1,klon
-         tr_seri(i,j,it)=tmp_var(i,j)
+         tr_seri(i,j,itr)=tmp_var(i,j)
       ENDDO
       ENDDO
@@ -2639,13 +2641,13 @@
 
       IF (lminmax) THEN
-        DO it=1,nbtr
-        CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_before_sedi')
-        ENDDO
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'before sedi')
+        DO itr=1,nbtr
+        CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_before_sedi')
+        ENDDO
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'before sedi')
         ENDDO
       IF (lcheckmass) THEN
-        DO it=1,nbtr
-         CALL checkmass(tr_seri(:,:,it),RNAVO,masse(it),zdz,   &
+        DO itr=1,nbtr
+         CALL checkmass(tr_seri(:,:,itr),RNAVO,masse(itr),zdz,   &
            pplay,t_seri,iscm3,'before sedi')
         ENDDO
@@ -2665,13 +2667,13 @@
 
       IF (lminmax) THEN
-        DO it=1,nbtr
-        CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_after_sedi')
-        ENDDO
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'after sedi')
+        DO itr=1,nbtr
+        CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_after_sedi')
+        ENDDO
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'after sedi')
         ENDDO
       IF (lcheckmass) THEN
-        DO it=1,nbtr
-         CALL checkmass(tr_seri(:,:,it),RNAVO,masse(it),zdz,  &
+        DO itr=1,nbtr
+         CALL checkmass(tr_seri(:,:,itr),RNAVO,masse(itr),zdz,  &
            pplay,t_seri,iscm3,'after sedi')
         ENDDO
@@ -2683,7 +2685,7 @@
 !=======================================================================
 #ifdef IOPHYS_DUST
-      do it=1,nbtr
-         write(str2,'(i2.2)') it
-         call iophys_ecrit('TRF'//str2,klev,'SOURCE','',tr_seri(:,:,it))
+      do itr=1,nbtr
+         write(str2,'(i2.2)') itr
+         call iophys_ecrit('TRF'//str2,klev,'SOURCE','',tr_seri(:,:,itr))
       enddo
 #endif
@@ -2700,8 +2702,8 @@
       ENDIF
 
-      DO it=1, nbtr
+      DO itr=1,nbtr
          DO j=1,klev
          DO i=1,klon
-           tmp_var(i,j)=tr_seri(i,j,it)
+           tmp_var(i,j)=tr_seri(i,j,itr)
          ENDDO 
          ENDDO
@@ -2709,5 +2711,5 @@
          DO j=1,klev
          DO i=1,klon
-           tr_seri(i,j,it)=tmp_var(i,j)
+           tr_seri(i,j,itr)=tmp_var(i,j)
          ENDDO 
          ENDDO
@@ -2726,13 +2728,13 @@
 
       IF (lminmax) THEN
-        DO it=1,nbtr
-        CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_beforegastopar')
-        ENDDO
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'before gastopar')
+        DO itr=1,nbtr
+        CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_beforegastopar')
+        ENDDO
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'before gastopar')
         ENDDO
       IF (lcheckmass) THEN
-        DO it=1,nbtr
-         CALL checkmass(tr_seri(:,:,it),RNAVO,masse(it),zdz,  &
+        DO itr=1,nbtr
+         CALL checkmass(tr_seri(:,:,itr),RNAVO,masse(itr),zdz,  &
            pplay,t_seri,iscm3,'before gastopar')
         ENDDO
@@ -2746,13 +2748,13 @@
 !
       IF (lminmax) THEN
-        DO it=1,nbtr
-        CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_after_gastopar')
-        ENDDO
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'after gastopar')
+        DO itr=1,nbtr
+        CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_after_gastopar')
+        ENDDO
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'after gastopar')
         ENDDO
       IF (lcheckmass) THEN
-        DO it=1,nbtr
-         CALL checkmass(tr_seri(:,:,it),RNAVO,masse(it),zdz,  &
+        DO itr=1,nbtr
+         CALL checkmass(tr_seri(:,:,itr),RNAVO,masse(itr),zdz,  &
            pplay,t_seri,iscm3,'after gastopar')
         ENDDO
@@ -2777,7 +2779,7 @@
 
 #ifdef IOPHYS_DUST
-      do it=1,nbtr
-         write(str2,'(i2.2)') it
-         call iophys_ecrit('TRG'//str2,klev,'SOURCE','',tr_seri(:,:,it))
+      do itr=1,nbtr
+         write(str2,'(i2.2)') itr
+         call iophys_ecrit('TRG'//str2,klev,'SOURCE','',tr_seri(:,:,itr))
       enddo
 #endif
@@ -2793,8 +2795,8 @@
 
 
-       DO it=1, nbtr
+       DO itr=1,nbtr
         DO j=1,klev
         DO i=1,klon
-           tmp_var(i,j)=tr_seri(i,j,it)
+           tmp_var(i,j)=tr_seri(i,j,itr)
         ENDDO
         ENDDO
@@ -2802,5 +2804,5 @@
         DO j=1,klev
         DO i=1,klon
-           tr_seri(i,j,it)=tmp_var(i,j)
+           tr_seri(i,j,itr)=tmp_var(i,j)
         ENDDO
         ENDDO
@@ -2815,13 +2817,13 @@
 
       IF (lminmax) THEN
-        DO it=1,nbtr
-        CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_before_incloud')
-        ENDDO
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'before incloud')
+        DO itr=1,nbtr
+        CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_before_incloud')
+        ENDDO
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'before incloud')
         ENDDO
       IF (lcheckmass) THEN
-        DO it=1,nbtr
-         CALL checkmass(tr_seri(:,:,it),RNAVO,masse(it),zdz,  &
+        DO itr=1,nbtr
+         CALL checkmass(tr_seri(:,:,itr),RNAVO,masse(itr),zdz,  &
            pplay,t_seri,iscm3,'before incloud')
         ENDDO
@@ -2856,13 +2858,13 @@
       print *,' BEFORE blcloud (after incloud)'
       IF (lminmax) THEN
-        DO it=1,nbtr
-        CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_before_blcloud')
-        ENDDO
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'before blcloud')
+        DO itr=1,nbtr
+        CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_before_blcloud')
+        ENDDO
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'before blcloud')
         ENDDO
       IF (lcheckmass) THEN
-        DO it=1,nbtr
-         CALL checkmass(tr_seri(:,:,it),RNAVO,masse(it),zdz,   &
+        DO itr=1,nbtr
+         CALL checkmass(tr_seri(:,:,itr),RNAVO,masse(itr),zdz,   &
            pplay,t_seri,iscm3,'before blcloud')
         ENDDO
@@ -2899,13 +2901,13 @@
 
       IF (lminmax) THEN
-        DO it=1,nbtr
-        CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_after_blcloud')
+        DO itr=1,nbtr
+        CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_after_blcloud')
         ENDDO                           
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'after blcloud')
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'after blcloud')
         ENDDO                                  
       IF (lcheckmass) THEN
-        DO it=1,nbtr
-         CALL checkmass(tr_seri(:,:,it),RNAVO,masse(it),zdz,  &
+        DO itr=1,nbtr
+         CALL checkmass(tr_seri(:,:,itr),RNAVO,masse(itr),zdz,  &
            pplay,t_seri,iscm3,'after blcloud')
         ENDDO
@@ -2917,8 +2919,8 @@
       ENDIF !--lessivage
 
-      DO it=1, nbtr
+      DO itr=1,nbtr
          DO j=1,klev
          DO i=1,klon
-           tmp_var(i,j)=tr_seri(i,j,it)
+           tmp_var(i,j)=tr_seri(i,j,itr)
          ENDDO 
          ENDDO
@@ -2926,5 +2928,5 @@
          DO j=1,klev
          DO i=1,klon
-           tr_seri(i,j,it)=tmp_var(i,j)
+           tr_seri(i,j,itr)=tmp_var(i,j)
          ENDDO 
          ENDDO
@@ -2952,7 +2954,7 @@
 !
 #ifdef IOPHYS_DUST
-      do it=1,nbtr
-         write(str2,'(i2.2)') it
-         call iophys_ecrit('TRH'//str2,klev,'SOURCE','',tr_seri(:,:,it))
+      do itr=1,nbtr
+         write(str2,'(i2.2)') itr
+         call iophys_ecrit('TRH'//str2,klev,'SOURCE','',tr_seri(:,:,itr))
       enddo
 #endif
@@ -2969,13 +2971,13 @@
 
       IF (lminmax) THEN
-        DO it=1,nbtr
-        CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_before_trconve')
-        ENDDO
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'before trconve')
+        DO itr=1,nbtr
+        CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_before_trconve')
+        ENDDO
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'before trconve')
         ENDDO
       IF (lcheckmass) THEN
-        DO it=1,nbtr
-         CALL checkmass(tr_seri(:,:,it),RNAVO,masse(it),zdz,  &
+        DO itr=1,nbtr
+         CALL checkmass(tr_seri(:,:,itr),RNAVO,masse(itr),zdz,  &
            pplay,t_seri,iscm3,'before trconve')
         ENDDO
@@ -2994,6 +2996,6 @@
                   pen_d,pde_d,paprs,zdz,xconv,qmin,qmax,.false.,masse, &
                                                       dtrconv,tr_seri)
-         DO it=1, nbtr
-           d_tr_cv(:,:,it)=0.
+         DO itr=1,nbtr
+           d_tr_cv(:,:,itr)=0.
          ENDDO
 
@@ -3001,21 +3003,21 @@
 ! KE
          print *,'JE: KE in phytracr_spl'
-         DO it=1, nbtr
+         DO itr=1,nbtr
              DO k = 1, klev
               DO i = 1, klon
-               tmp_var3(i,k,it)=tr_seri(i,k,it)
+               tmp_var3(i,k,itr)=tr_seri(i,k,itr)
               END DO
              END DO
          ENDDO
 
-         DO it=1, nbtr
+         DO itr=1,nbtr
 !          routine for aerosols . otherwise, check cvltrorig
-         print *,'Check sum before cvltr it',it,SUM(tr_seri(:,:,it))
+         print *,'Check sum before cvltr itr)',itr,SUM(tr_seri(:,:,itr))
 !           IF (.FALSE.) THEN 
            CALL cvltr_spl(pdtphys, da, phi,phi2,d1a,dam, mp,ep,    &
             sigd,sij,wght_cvfd,clw,elij,epmlmMm,eplaMm,           &
             pmflxr,pmflxs,evapls,t_seri,wdtrainA,wdtrainM,          &
-!            paprs,it,tr_seri,upwd,dnwd,itop_con,ibas_con,        &
-            paprs,it,tmp_var3,upwd,dnwd,itop_con,ibas_con,        &
+!            paprs,itr,tr_seri,upwd,dnwd,itop_con,ibas_con,        &
+            paprs,itr,tmp_var3,upwd,dnwd,itop_con,ibas_con,        &
             henry,kk,zrho,ccntrAA_spla,ccntrENV_spla,coefcoli_spla, &
             id_prec,id_fine,id_coss, id_codu, id_scdu,              &
@@ -3029,5 +3031,5 @@
 !     .       sigd,sij,wght_cvfd,clw,elij,epmlmMm,eplaMm,
 !     .       pmflxr,pmflxs,evapls,t_seri,wdtrainA,wdtrainM,
-!     .       paprs,it,tmp_var3,upwd,dnwd,itop_con,ibas_con,
+!     .       paprs,itr,tmp_var3,upwd,dnwd,itop_con,ibas_con,
 !     .       d_tr_cv,d_tr_trsp,d_tr_sscav,d_tr_sat,d_tr_uscav,qDi,qPr,
 !     .       qPa,qMel,qTrdi,dtrcvMA,Mint,
@@ -3047,8 +3049,8 @@
 !             CALL checknanqfi(paprs(:,:),1.,-1.,'paprs ')
 !             CALL checknanqfi(pplay(:,:),1.,-1.,'pplay ')
-!             CALL checknanqfi(tmp_var3(:,:,it),1.,-1.,'tmp_var3 ')
+!             CALL checknanqfi(tmp_var3(:,:,itr),1.,-1.,'tmp_var3 ')
 !             CALL checknanqfi(upwd(:,:),1.,-1.,'upwd ')
 !             CALL checknanqfi(dnwd(:,:),1.,-1.,'dnwd ')
-!             CALL checknanqfi(d_tr_cv(:,:,it),1.,-1.,'d_tr_cv ')
+!             CALL checknanqfi(d_tr_cv(:,:,itr),1.,-1.,'d_tr_cv ')
 !             IF (.TRUE.) THEN
 !             CALL cvltr_noscav(it,pdtphys, da, phi,mp,wght_cvfd,paprs,
@@ -3057,7 +3059,7 @@
              DO k = 1, klev
               DO i = 1, klon
-!               tr_seri(i,k,it) = tr_seri(i,k,it) + d_tr_cv(i,k,it)
-               tr_seri(i,k,it)=(tmp_var3(i,k,it)+d_tr_cv(i,k,it))
-               tmp_var(i,k)=d_tr_cv(i,k,it)
+!               tr_seri(i,k,itr) = tr_seri(i,k,itr) + d_tr_cv(i,k,itr)
+               tr_seri(i,k,itr)=(tmp_var3(i,k,itr)+d_tr_cv(i,k,itr))
+               tmp_var(i,k)=d_tr_cv(i,k,itr)
 
               END DO
@@ -3068,7 +3070,7 @@
              DO k = 1, klev
               DO i = 1, klon
-               dtrconv(i,it)=0.0
-               his_dhkecv(i,it)=his_dhkecv(i,it)-tmp_var(i,k)  &
-                     /RNAVO*masse(it)*1.e3*1.e6*zdz(i,k)/pdtphys
+               dtrconv(i,itr)=0.0
+               his_dhkecv(i,itr)=his_dhkecv(i,itr)-tmp_var(i,k)  &
+                     /RNAVO*masse(itr)*1.e3*1.e6*zdz(i,k)/pdtphys
               END DO
              END DO
@@ -3079,7 +3081,7 @@
              DO k = 1, klev
               DO i = 1, klon
-               dtrconv(i,it)=0.0
-               his_ds(i,it)=his_ds(i,it)-tmp_var(i,k)  &
-                     /RNAVO*masse(it)*1.e3*1.e6*zdz(i,k)/pdtphys
+               dtrconv(i,itr)=0.0
+               his_ds(i,itr)=his_ds(i,itr)-tmp_var(i,k)  &
+                     /RNAVO*masse(itr)*1.e3*1.e6*zdz(i,k)/pdtphys
               END DO
              END DO
@@ -3087,12 +3089,12 @@
        IF (lminmax) THEN
 
-         print *,'Check sum after cvltr it',it,SUM(tr_seri(:,:,it))
-        CALL minmaxqfi2(d_tr_cv(:,:,it),qmin,qmax,'d_tr_cv:')
-        CALL minmaxqfi2(d_tr_trsp(:,:,it),qmin,qmax,'d_tr_trsp:')
-        CALL minmaxqfi2(d_tr_sscav(:,:,it),qmin,qmax,'d_tr_sscav:')
-        CALL minmaxqfi2(d_tr_sat(:,:,it),qmin,qmax,'d_tr_sat:')
-        CALL minmaxqfi2(d_tr_uscav(:,:,it),qmin,qmax,'d_tr_uscav:')
+         print *,'Check sum after cvltr itr)',itr,SUM(tr_seri(:,:,itr))
+        CALL minmaxqfi2(d_tr_cv(:,:,itr),qmin,qmax,'d_tr_cv:')
+        CALL minmaxqfi2(d_tr_trsp(:,:,itr),qmin,qmax,'d_tr_trsp:')
+        CALL minmaxqfi2(d_tr_sscav(:,:,itr),qmin,qmax,'d_tr_sscav:')
+        CALL minmaxqfi2(d_tr_sat(:,:,itr),qmin,qmax,'d_tr_sat:')
+        CALL minmaxqfi2(d_tr_uscav(:,:,itr),qmin,qmax,'d_tr_uscav:')
       IF (lcheckmass) THEN
-        CALL checkmass(d_tr_cv(:,:,it),RNAVO,masse(it),zdz,  &
+        CALL checkmass(d_tr_cv(:,:,itr),RNAVO,masse(itr),zdz,  &
            pplay,t_seri,.false.,'d_tr_cv:')
       ENDIF
@@ -3102,13 +3104,13 @@
         ENDIF ! iflag_conv
        IF (lminmax) THEN
-        DO it=1,nbtr
-        CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_after_trcon')
-        ENDDO
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'after trconv')
+        DO itr=1,nbtr
+        CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_after_trcon')
+        ENDDO
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'after trconv')
         ENDDO
       IF (lcheckmass) THEN
-        DO it=1,nbtr
-         CALL checkmass(tr_seri(:,:,it),RNAVO,masse(it),zdz, &
+        DO itr=1,nbtr
+         CALL checkmass(tr_seri(:,:,itr),RNAVO,masse(itr),zdz, &
            pplay,t_seri,iscm3,'after trconv')
         ENDDO
@@ -3155,7 +3157,7 @@
       call iophys_ecrit('wdtrainM',klev,'wdtrainM','',wdtrainM)
 
-      do it=1,nbtr
-         write(str2,'(i2.2)') it
-         call iophys_ecrit('TRI'//str2,klev,'SOURCE','',tr_seri(:,:,it))
+      do itr=1,nbtr
+         write(str2,'(i2.2)') itr
+         call iophys_ecrit('TRI'//str2,klev,'SOURCE','',tr_seri(:,:,itr))
       enddo
 #endif
@@ -3171,13 +3173,13 @@
        print *,' BEFORE lsc_scav '
        IF (lminmax) THEN
-        DO it=1,nbtr
-       CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_before_lsc_scav')
-        ENDDO
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'before lsc_scav')
+        DO itr=1,nbtr
+       CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_before_lsc_scav')
+        ENDDO
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'before lsc_scav')
         ENDDO
       IF (lcheckmass) THEN
-        DO it=1,nbtr
-         CALL checkmass(tr_seri(:,:,it),RNAVO,masse(it),zdz,  &
+        DO itr=1,nbtr
+         CALL checkmass(tr_seri(:,:,itr),RNAVO,masse(itr),zdz,  &
            pplay,t_seri,iscm3,'before lsc_scav')
         ENDDO
@@ -3196,5 +3198,5 @@
       !IF (.false.) THEN  ! test #DFB (Binta) sans lsc_scav_spl
         print *,'JE iflag_lscav',iflag_lscav
-        DO it = 1, nbtr
+        DO itr=1,nbtr
 
 !       incloud scavenging and removal by large scale rain ! orig : ql_incl
@@ -3203,9 +3205,9 @@
 !         Liu (2001) proposed to use 1.5e-3 kg/kg
 
-!       CALL lsc_scav_orig(pdtphys,it,iflag_lscav,ql_incl,prfl,psfl,
+!       CALL lsc_scav_orig(pdtphys,itr,iflag_lscav,ql_incl,prfl,psfl,
 !     .               rneb,beta_fisrt, beta_v1,pplay,paprs,
 !     .               t_seri,tr_seri,d_tr_insc, 
 !     .               d_tr_bcscav,d_tr_evapls,qPrls)
-          CALL lsc_scav_spl(pdtphys,it,iflag_lscav,ql_incl,prfl,psfl,  &
+          CALL lsc_scav_spl(pdtphys,itr,iflag_lscav,ql_incl,prfl,psfl,  &
                     rneb,beta_fisrt, beta_v1,pplay,paprs,      &
                     t_seri,tr_seri,d_tr_insc,                  &
@@ -3217,8 +3219,8 @@
           DO k = 1, klev
            DO i = 1, klon
-                d_tr_ls(i,k,it)=d_tr_insc(i,k,it)+d_tr_bcscav(i,k,it) &
-                        +d_tr_evapls(i,k,it)
-                tr_seri(i,k,it)=tr_seri(i,k,it)+d_tr_ls(i,k,it)
-                         tmp_var(i,k)=d_tr_ls(i,k,it)
+                d_tr_ls(i,k,itr)=d_tr_insc(i,k,itr)+d_tr_bcscav(i,k,itr) &
+                        +d_tr_evapls(i,k,itr)
+                tr_seri(i,k,itr)=tr_seri(i,k,itr)+d_tr_ls(i,k,itr)
+                         tmp_var(i,k)=d_tr_ls(i,k,itr)
            ENDDO
           ENDDO
@@ -3228,6 +3230,6 @@
           DO k=1,klev
            DO i=1,klon
-            his_dhkelsc(i,it)=his_dhkelsc(i,it)-tmp_var(i,k)    &
-                     /RNAVO*masse(it)*1.e3*1.e6*zdz(i,k)/pdtphys
+            his_dhkelsc(i,itr)=his_dhkelsc(i,itr)-tmp_var(i,k)    &
+                     /RNAVO*masse(itr)*1.e3*1.e6*zdz(i,k)/pdtphys
      
            END DO
@@ -3238,7 +3240,7 @@
       ELSE
         print *,'WARNING: NO lsc_scav, Please choose iflag_lscav=3 or 4'
-        DO it = 1, nbtr
+        DO itr=1,nbtr
           DO i=1,klon
-            his_dhkelsc(i,it)=0.0
+            his_dhkelsc(i,itr)=0.0
           END DO  ! klon
          END DO  !it=1,nbtr
@@ -3247,13 +3249,13 @@
        print *,' AFTER lsc_scav '
        IF (lminmax) THEN
-        DO it=1,nbtr
-       CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan_after_lsc_scav')
-        ENDDO
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'after lsc_scav')
+        DO itr=1,nbtr
+       CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan_after_lsc_scav')
+        ENDDO
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'after lsc_scav')
         ENDDO
       IF (lcheckmass) THEN
-        DO it=1,nbtr
-         CALL checkmass(tr_seri(:,:,it),RNAVO,masse(it),zdz, &
+        DO itr=1,nbtr
+         CALL checkmass(tr_seri(:,:,itr),RNAVO,masse(itr),zdz, &
            pplay,t_seri,iscm3,'after lsc_scav')
         ENDDO
@@ -3281,7 +3283,7 @@
 !=======================================================================
 #ifdef IOPHYS_DUST
-      do it=1,nbtr
-         write(str2,'(i2.2)') it
-         call iophys_ecrit('TRJ'//str2,klev,'SOURCE','',tr_seri(:,:,it))
+      do itr=1,nbtr
+         write(str2,'(i2.2)') itr
+         call iophys_ecrit('TRJ'//str2,klev,'SOURCE','',tr_seri(:,:,itr))
       enddo
 #endif
@@ -3293,8 +3295,8 @@
 
   
-      DO it=1, nbtr
+      DO itr=1,nbtr
         DO j=1,klev
         DO i=1,klon
-           tmp_var(i,j)=tr_seri(i,j,it)
+           tmp_var(i,j)=tr_seri(i,j,itr)
         ENDDO
         ENDDO
@@ -3302,5 +3304,5 @@
         DO j=1,klev
         DO i=1,klon
-           tr_seri(i,j,it)=tmp_var(i,j)
+           tr_seri(i,j,itr)=tmp_var(i,j)
         ENDDO
         ENDDO
@@ -3310,9 +3312,9 @@
 !
 ! Computing burden in mg/m2
-      DO it=1, nbtr
+      DO itr=1,nbtr
       DO k=1, klev
       DO i=1, klon
-        trm(i,it)=trm(i,it)+tr_seri(i,k,it)*1.e6*zdz(i,k)*  &
-                 masse(it)*1.e3/RNAVO     !--mg S/m2
+        trm(i,itr)=trm(i,itr)+tr_seri(i,k,itr)*1.e6*zdz(i,k)*  &
+                 masse(itr)*1.e3/RNAVO     !--mg S/m2
       ENDDO
       ENDDO
@@ -3321,8 +3323,8 @@
 ! Computing Surface concentration in ug/m3
 !
-      DO it=1, nbtr
+      DO itr=1,nbtr
       DO i=1, klon
-        sconc_seri(i,it)=tr_seri(i,1,it)*1.e6* &
-                 masse(it)*1.e3/RNAVO     !--mg/m3 (tr_seri ist in g/cm3)
+        sconc_seri(i,itr)=tr_seri(i,1,itr)*1.e6* &
+                 masse(itr)*1.e3/RNAVO     !--mg/m3 (tr_seri ist in g/cm3)
       ENDDO
       ENDDO
@@ -3556,7 +3558,7 @@
 !======================================================================
 #ifdef IOPHYS_DUST
-      do it=1,nbtr
-         write(str2,'(i2.2)') it
-         call iophys_ecrit('TRK'//str2,klev,'SOURCE','',tr_seri(:,:,it))
+      do itr=1,nbtr
+         write(str2,'(i2.2)') itr
+         call iophys_ecrit('TRK'//str2,klev,'SOURCE','',tr_seri(:,:,itr))
       enddo
 #endif
@@ -3568,8 +3570,8 @@
       ENDIF
 
-      DO it=1, nbtr
+      DO itr=1,nbtr
          DO j=1,klev
          DO i=1,klon
-           tmp_var(i,j)=tr_seri(i,j,it)
+           tmp_var(i,j)=tr_seri(i,j,itr)
          ENDDO 
          ENDDO
@@ -3577,5 +3579,5 @@
          DO j=1,klev
          DO i=1,klon
-           tr_seri(i,j,it)=tmp_var(i,j)
+           tr_seri(i,j,itr)=tmp_var(i,j)
          ENDDO 
          ENDDO
@@ -3726,8 +3728,8 @@
 !      prepare outputs cvltr
 
-      DO it=1, nbtr
+      DO itr=1,nbtr
         DO k=1,klev
         DO i=1,klon
-           tmp_var(i,k)=d_tr_cv(i,k,it)
+           tmp_var(i,k)=d_tr_cv(i,k,itr)
         ENDDO
         ENDDO
@@ -3735,13 +3737,13 @@
        DO k=1,klev
         DO i=1,klon
-          d_tr_cv_o(i,k,it)=tmp_var(i,k)  &
-                         /RNAVO*masse(it)*1.e3*1.e6*zdz(i,k)/pdtphys  
+          d_tr_cv_o(i,k,itr)=tmp_var(i,k)  &
+                         /RNAVO*masse(itr)*1.e3*1.e6*zdz(i,k)/pdtphys  
         ENDDO
        ENDDO
       ENDDO
-      DO it=1, nbtr
+      DO itr=1,nbtr
         DO k=1,klev
         DO i=1,klon
-           tmp_var(i,k)=d_tr_trsp(i,k,it)
+           tmp_var(i,k)=d_tr_trsp(i,k,itr)
         ENDDO
         ENDDO
@@ -3749,13 +3751,13 @@
        DO k=1,klev
         DO i=1,klon
-          d_tr_trsp_o(i,k,it)=tmp_var(i,k)  &
-                         /RNAVO*masse(it)*1.e3*1.e6*zdz(i,k)/pdtphys  
+          d_tr_trsp_o(i,k,itr)=tmp_var(i,k)  &
+                         /RNAVO*masse(itr)*1.e3*1.e6*zdz(i,k)/pdtphys  
         ENDDO
        ENDDO
       ENDDO
-      DO it=1, nbtr
+      DO itr=1,nbtr
         DO k=1,klev
         DO i=1,klon
-           tmp_var(i,k)=d_tr_sscav(i,k,it)
+           tmp_var(i,k)=d_tr_sscav(i,k,itr)
         ENDDO
         ENDDO
@@ -3763,13 +3765,13 @@
        DO k=1,klev
         DO i=1,klon
-          d_tr_sscav_o(i,k,it)=tmp_var(i,k)  &
-                         /RNAVO*masse(it)*1.e3*1.e6*zdz(i,k)/pdtphys  
+          d_tr_sscav_o(i,k,itr)=tmp_var(i,k)  &
+                         /RNAVO*masse(itr)*1.e3*1.e6*zdz(i,k)/pdtphys  
         ENDDO
        ENDDO
       ENDDO
-      DO it=1, nbtr
+      DO itr=1,nbtr
         DO k=1,klev
         DO i=1,klon
-           tmp_var(i,k)=d_tr_sat(i,k,it)
+           tmp_var(i,k)=d_tr_sat(i,k,itr)
         ENDDO
         ENDDO
@@ -3777,13 +3779,13 @@
        DO k=1,klev
         DO i=1,klon
-          d_tr_sat_o(i,k,it)=tmp_var(i,k)   &
-                         /RNAVO*masse(it)*1.e3*1.e6*zdz(i,k)/pdtphys  
+          d_tr_sat_o(i,k,itr)=tmp_var(i,k)   &
+                         /RNAVO*masse(itr)*1.e3*1.e6*zdz(i,k)/pdtphys  
         ENDDO
        ENDDO
       ENDDO
-      DO it=1, nbtr
+      DO itr=1,nbtr
         DO k=1,klev
         DO i=1,klon
-           tmp_var(i,k)=d_tr_uscav(i,k,it)
+           tmp_var(i,k)=d_tr_uscav(i,k,itr)
         ENDDO
         ENDDO
@@ -3791,6 +3793,6 @@
        DO k=1,klev
         DO i=1,klon
-          d_tr_uscav_o(i,k,it)=tmp_var(i,k)  &
-                         /RNAVO*masse(it)*1.e3*1.e6*zdz(i,k)/pdtphys  
+          d_tr_uscav_o(i,k,itr)=tmp_var(i,k)  &
+                         /RNAVO*masse(itr)*1.e3*1.e6*zdz(i,k)/pdtphys  
         ENDDO
        ENDDO
@@ -3798,8 +3800,8 @@
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      DO it=1, nbtr
+      DO itr=1,nbtr
         DO k=1,klev
         DO i=1,klon
-           tmp_var(i,k)=d_tr_insc(i,k,it)
+           tmp_var(i,k)=d_tr_insc(i,k,itr)
         ENDDO
         ENDDO
@@ -3807,6 +3809,6 @@
        DO k=1,klev
         DO i=1,klon
-          d_tr_insc_o(i,k,it)=tmp_var(i,k)  &
-                         /RNAVO*masse(it)*1.e3*1.e6*zdz(i,k)/pdtphys  
+          d_tr_insc_o(i,k,itr)=tmp_var(i,k)  &
+                         /RNAVO*masse(itr)*1.e3*1.e6*zdz(i,k)/pdtphys  
         ENDDO
        ENDDO
@@ -3814,8 +3816,8 @@
      
 
-      DO it=1, nbtr
+      DO itr=1,nbtr
         DO k=1,klev
         DO i=1,klon
-           tmp_var(i,k)=d_tr_bcscav(i,k,it)
+           tmp_var(i,k)=d_tr_bcscav(i,k,itr)
         ENDDO
         ENDDO
@@ -3823,6 +3825,6 @@
        DO k=1,klev
         DO i=1,klon
-          d_tr_bcscav_o(i,k,it)=tmp_var(i,k)  &
-                         /RNAVO*masse(it)*1.e3*1.e6*zdz(i,k)/pdtphys  
+          d_tr_bcscav_o(i,k,itr)=tmp_var(i,k)  &
+                         /RNAVO*masse(itr)*1.e3*1.e6*zdz(i,k)/pdtphys  
         ENDDO
        ENDDO
@@ -3830,8 +3832,8 @@
 
 
-      DO it=1, nbtr
+      DO itr=1,nbtr
         DO k=1,klev
         DO i=1,klon
-           tmp_var(i,k)=d_tr_evapls(i,k,it)
+           tmp_var(i,k)=d_tr_evapls(i,k,itr)
         ENDDO
         ENDDO
@@ -3839,6 +3841,6 @@
        DO k=1,klev
         DO i=1,klon
-          d_tr_evapls_o(i,k,it)=tmp_var(i,k)  &
-                         /RNAVO*masse(it)*1.e3*1.e6*zdz(i,k)/pdtphys  
+          d_tr_evapls_o(i,k,itr)=tmp_var(i,k)  &
+                         /RNAVO*masse(itr)*1.e3*1.e6*zdz(i,k)/pdtphys  
         ENDDO
        ENDDO
@@ -3846,8 +3848,8 @@
 
 
-      DO it=1, nbtr
+      DO itr=1,nbtr
         DO k=1,klev
         DO i=1,klon
-           tmp_var(i,k)=d_tr_ls(i,k,it)
+           tmp_var(i,k)=d_tr_ls(i,k,itr)
         ENDDO
         ENDDO
@@ -3855,6 +3857,6 @@
        DO k=1,klev
         DO i=1,klon
-          d_tr_ls_o(i,k,it)=tmp_var(i,k)  &
-                         /RNAVO*masse(it)*1.e3*1.e6*zdz(i,k)/pdtphys  
+          d_tr_ls_o(i,k,itr)=tmp_var(i,k)  &
+                         /RNAVO*masse(itr)*1.e3*1.e6*zdz(i,k)/pdtphys  
         ENDDO
        ENDDO
@@ -3862,8 +3864,8 @@
 
 
-      DO it=1, nbtr
+      DO itr=1,nbtr
         DO k=1,klev
         DO i=1,klon
-           tmp_var(i,k)=d_tr_dyn(i,k,it)
+           tmp_var(i,k)=d_tr_dyn(i,k,itr)
         ENDDO
         ENDDO
@@ -3871,6 +3873,6 @@
        DO k=1,klev
         DO i=1,klon
-          d_tr_dyn_o(i,k,it)=tmp_var(i,k)  &
-                         /RNAVO*masse(it)*1.e3*1.e6*zdz(i,k)/pdtphys  
+          d_tr_dyn_o(i,k,itr)=tmp_var(i,k)  &
+                         /RNAVO*masse(itr)*1.e3*1.e6*zdz(i,k)/pdtphys  
         ENDDO
        ENDDO
@@ -3878,8 +3880,8 @@
 
 
-      DO it=1, nbtr
+      DO itr=1,nbtr
         DO k=1,klev
         DO i=1,klon
-           tmp_var(i,k)=d_tr_cl(i,k,it)
+           tmp_var(i,k)=d_tr_cl(i,k,itr)
         ENDDO
         ENDDO
@@ -3887,6 +3889,6 @@
        DO k=1,klev
         DO i=1,klon
-          d_tr_cl_o(i,k,it)=tmp_var(i,k)  &
-                         /RNAVO*masse(it)*1.e3*1.e6*zdz(i,k)/pdtphys  
+          d_tr_cl_o(i,k,itr)=tmp_var(i,k)  &
+                         /RNAVO*masse(itr)*1.e3*1.e6*zdz(i,k)/pdtphys  
         ENDDO
        ENDDO
@@ -3894,8 +3896,8 @@
 
 
-      DO it=1, nbtr
+      DO itr=1,nbtr
         DO k=1,klev
         DO i=1,klon
-           tmp_var(i,k)=d_tr_th(i,k,it)
+           tmp_var(i,k)=d_tr_th(i,k,itr)
         ENDDO
         ENDDO
@@ -3903,6 +3905,6 @@
        DO k=1,klev
         DO i=1,klon
-          d_tr_th_o(i,k,it)=tmp_var(i,k)  &
-                         /RNAVO*masse(it)*1.e3*1.e6*zdz(i,k)/pdtphys  
+          d_tr_th_o(i,k,itr)=tmp_var(i,k)  &
+                         /RNAVO*masse(itr)*1.e3*1.e6*zdz(i,k)/pdtphys  
         ENDDO
        ENDDO
@@ -3911,9 +3913,9 @@
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-     DO it=1,nbtr
-      WRITE(str2,'(i2.2)') it
+     DO itr=1,nbtr
+      WRITE(str2,'(i2.2)') itr
        DO i=1, klon                                                        
-        his_dh(i,it)= his_dhlsc(i,it)+his_dhcon(i,it)+               &
-                   his_dhbclsc(i,it)+his_dhbccon(i,it)
+        his_dh(i,itr)= his_dhlsc(i,itr)+his_dhcon(i,itr)+               &
+                   his_dhbclsc(i,itr)+his_dhbccon(i,itr)
 
        ENDDO
Index: LMDZ6/branches/Portage_acc/libf/phylmd/Dust/splaeropt_5wv_rrtm.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/Dust/splaeropt_5wv_rrtm.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/Dust/splaeropt_5wv_rrtm.F90	(revision 4446)
@@ -120,6 +120,6 @@
       CASE('FINE'); soluble=.TRUE.;  spsol=1; aerindex=1   !--fine mode accumulation mode
       CASE('COSS'); soluble=.TRUE.;  spsol=2; aerindex=2   !--coarse mode sea salt
-      CASE('CODU'); soluble=.FALSE.; spsol=1; aerindex=3   !--coarse mode dust
-      CASE('SCDU'); soluble=.FALSE.; spsol=2; aerindex=4   !--super coarse mode dust
+      CASE('CODU'); soluble=.FALSE.; spinsol=1; aerindex=3   !--coarse mode dust
+      CASE('SCDU'); soluble=.FALSE.; spinsol=2; aerindex=4   !--super coarse mode dust
       CASE DEFAULT; CALL abort_physic(modname,'I cannot do aerosol optics for '//tracers(iq)%name,1)
     END SELECT
Index: LMDZ6/branches/Portage_acc/libf/phylmd/Dust/splaeropt_6bands_rrtm.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/Dust/splaeropt_6bands_rrtm.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/Dust/splaeropt_6bands_rrtm.F90	(revision 4446)
@@ -173,6 +173,6 @@
       CASE('FINE'); soluble=.TRUE.;  spsol=1; aerindex=1   !--fine mode accumulation mode
       CASE('COSS'); soluble=.TRUE.;  spsol=2; aerindex=2   !--coarse mode sea salt
-      CASE('CODU'); soluble=.FALSE.; spsol=1; aerindex=3   !--coarse mode dust
-      CASE('SCDU'); soluble=.FALSE.; spsol=2; aerindex=4   !--super coarse mode dust
+      CASE('CODU'); soluble=.FALSE.; spinsol=1; aerindex=3   !--coarse mode dust
+      CASE('SCDU'); soluble=.FALSE.; spinsol=2; aerindex=4   !--super coarse mode dust
       CASE DEFAULT; CALL abort_physic(modname,'I cannot do aerosol optics for '//tracers(iq)%name,1)
     END SELECT
Index: LMDZ6/branches/Portage_acc/libf/phylmd/Ocean_skin/config_ocean_skin_m.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/Ocean_skin/config_ocean_skin_m.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/Ocean_skin/config_ocean_skin_m.F90	(revision 4446)
@@ -11,6 +11,7 @@
   ! the depth of a sensor, or the depth at the middle of the first
   ! layer of an ocean model (half the depth of the first layer). In
-  ! m. Setting depth_1 to any value >= depth has the same effect as
-  ! setting depth_1 to depth.
+  ! m. Setting depth_1 to any value >= depth (named constant defined
+  ! in module `near_Surface_m`) has the same effect as setting depth_1
+  ! to depth.
 
   !$omp threadprivate(jcool, jwarm, rain_effect, depth_1)
Index: LMDZ6/branches/Portage_acc/libf/phylmd/Ocean_skin/sens_heat_rain_m.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/Ocean_skin/sens_heat_rain_m.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/Ocean_skin/sens_heat_rain_m.F90	(revision 4446)
@@ -5,12 +5,16 @@
 contains
 
+#ifdef IN_LMDZ
   real function sens_heat_rain(rain, t, q, rhoa, xlv, t_int, p)
+#else
+  elemental real function sens_heat_rain(rain, t, q, rhoa, xlv, t_int, p)
+#endif
 
     ! Computes heat flux due to rainfall, in W m-2, positive
     ! upward.
 
-    ! Do not declare this function as elemental because it may include
-    ! YOMCST.h, which contains an OpenMP directive, and that only
-    ! works in OpenMP 5.0.
+    ! If in LMDZ, do not declare this function as elemental because
+    ! YOMCST.h contains an OpenMP directive, and that only works in
+    ! OpenMP 5.0.
 
     use const, only: cpa, cpw, rgas
Index: LMDZ6/branches/Portage_acc/libf/phylmd/StratAer/calcaerosolstrato_rrtm.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/StratAer/calcaerosolstrato_rrtm.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/StratAer/calcaerosolstrato_rrtm.F90	(revision 4446)
@@ -16,5 +16,4 @@
   INCLUDE "clesphys.h"
   INCLUDE "paramet.h"
-  INCLUDE "thermcell.h"
   INCLUDE "iniprint.h"
 
Index: LMDZ6/branches/Portage_acc/libf/phylmd/StratAer/micphy_tstep.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/StratAer/micphy_tstep.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/StratAer/micphy_tstep.F90	(revision 4446)
@@ -7,5 +7,5 @@
   USE dimphy, ONLY : klon,klev
   USE aerophys
-  USE infotrac_phy
+  USE infotrac_phy, ONLY : nbtr_bin, nbtr_sulgas, nbtr, id_H2SO4_strat
   USE phys_local_var_mod, ONLY: mdw, budg_3D_nucl, budg_3D_cond_evap, budg_h2so4_to_part, R2SO4, DENSO4, f_r_wet
   USE nucleation_tstep_mod
@@ -47,5 +47,5 @@
   REAL ASO4(nbtr_bin)
   REAL DNDR(nbtr_bin)
-  REAL H2SO4_sat(nbtr_bin)
+  REAL H2SO4_sat
 
   DO it=1,nbtr_bin
@@ -107,4 +107,6 @@
              & ACTSO4(ilon,ilev),R2SO4(ilon,ilev),DENSO4(ilon,ilev),f_r_wet(ilon,ilev), &
              & RRSI,Vbin,FL,ASO4,DNDR)
+      ! Compute H2SO4 saturate vapor for big particules
+      H2SO4_sat = DNDR(nbtr_bin)/(pplay(ilon,ilev)/t_seri(ilon,ilev)/RD/1.E6/mH2SO4mol)
       ! consider only condensation (positive FL)
       DO it=1,nbtr_bin
@@ -117,5 +119,5 @@
       ENDDO
       ! determine appropriate time step
-      dt=(H2SO4_init-H2SO4_sat(nbtr_bin))/float(nbtstep)/MAX(1.e-30, nucl_rate+cond_evap_rate) !cond_evap_rate pos. for cond. and neg. for evap.
+      dt=(H2SO4_init-H2SO4_sat)/float(nbtstep)/MAX(1.e-30, nucl_rate+cond_evap_rate) !cond_evap_rate pos. for cond. and neg. for evap.
       IF (dt.LT.0.0) THEN
         dt=PDT
Index: LMDZ6/branches/Portage_acc/libf/phylmd/StratAer/nucleation_tstep_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/StratAer/nucleation_tstep_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/StratAer/nucleation_tstep_mod.F90	(revision 4446)
@@ -604,5 +604,5 @@
      na_n=x_n*ntot_n
      IF (na_n .LT. 1.) THEN
-        print *, 'Warning: number of acid molecules < 1 in nucleation regime, setting na_n=1'
+!        print *, 'Warning: number of acid molecules < 1 in nucleation regime, setting na_n=1'
         na_n=1.0
      ENDIF
Index: LMDZ6/branches/Portage_acc/libf/phylmd/StratAer/strataer_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/StratAer/strataer_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/StratAer/strataer_mod.F90	(revision 4446)
@@ -79,5 +79,6 @@
     !Config Help = Used in physiq.F
     !
-    flag_sulf_emit = 0
+    flag_sulf_emit = 0 ! Background (default)
+    flag_sulf_emit_distrib = 0 ! Gaussian (default)
     nErupt = 0 ! eruption number
     injdur = 0 ! init injection duration
@@ -87,4 +88,31 @@
        CALL getin_p('nErupt',nErupt)
        CALL getin_p('injdur',injdur)
+       CALL getin_p('flag_sulf_emit_distrib',flag_sulf_emit_distrib)
+
+       year_emit_vol=0 ; mth_emit_vol=0 ; day_emit_vol=0
+       m_aer_emiss_vol=0. ; altemiss_vol=0. ; sigma_alt_vol=0.
+       xlon_min_vol=0. ; xlon_max_vol=0.
+       xlat_min_vol=0. ; xlat_max_vol=0.
+
+       IF (nErupt.GT.0) THEN
+          ALLOCATE(year_emit_vol(nErupt),mth_emit_vol(nErupt),day_emit_vol(nErupt))
+          ALLOCATE(m_aer_emiss_vol(nErupt),altemiss_vol(nErupt),sigma_alt_vol(nErupt))
+          ALLOCATE(xlat_min_vol(nErupt),xlon_min_vol(nErupt))
+          ALLOCATE(xlat_max_vol(nErupt),xlon_max_vol(nErupt))
+       ELSE
+          WRITE(lunout,*) 'ERROR : Using flag_sulf_emit=1 (ie Volcanic eruption) but nErupt (',nErupt,') <=0 !'
+          CALL abort_physic('strataer_mod','No eruption define in physiq_def (nErupt=0). Add one or use background condition.',1)
+       ENDIF
+
+       CALL getin_p('year_emit_vol',year_emit_vol)
+       CALL getin_p('mth_emit_vol',mth_emit_vol)
+       CALL getin_p('day_emit_vol',day_emit_vol)
+       CALL getin_p('m_aer_emiss_vol',m_aer_emiss_vol)
+       CALL getin_p('altemiss_vol',altemiss_vol)
+       CALL getin_p('sigma_alt_vol',sigma_alt_vol)
+       CALL getin_p('xlon_min_vol',xlon_min_vol)
+       CALL getin_p('xlon_max_vol',xlon_max_vol)
+       CALL getin_p('xlat_min_vol',xlat_min_vol)
+       CALL getin_p('xlat_max_vol',xlat_max_vol)
     ELSEIF (flag_sulf_emit == 2) THEN ! SAI
        CALL getin_p('m_aer_emiss_sai',m_aer_emiss_sai)
@@ -93,5 +121,4 @@
        CALL getin_p('xlat_sai',xlat_sai)
        CALL getin_p('xlon_sai',xlon_sai)
-       CALL getin_p('flag_sulf_emit_distrib',flag_sulf_emit_distrib)
     ELSEIF (flag_sulf_emit == 3) THEN ! SAI between latitudes
        CALL getin_p('m_aer_emiss_sai',m_aer_emiss_sai)
@@ -101,29 +128,6 @@
        CALL getin_p('xlat_max_sai',xlat_max_sai)
        CALL getin_p('xlat_min_sai',xlat_min_sai)
-       CALL getin_p('flag_sulf_emit_distrib',flag_sulf_emit_distrib)
     ENDIF
 
-    ALLOCATE(year_emit_vol(nErupt),mth_emit_vol(nErupt),day_emit_vol(nErupt))
-    ALLOCATE(m_aer_emiss_vol(nErupt),altemiss_vol(nErupt),sigma_alt_vol(nErupt))
-    ALLOCATE(xlat_min_vol(nErupt),xlon_min_vol(nErupt))
-    ALLOCATE(xlat_max_vol(nErupt),xlon_max_vol(nErupt))
-    
-    IF (nErupt.GT.0) THEN 
-      year_emit_vol=0 ; mth_emit_vol=0 ; day_emit_vol=0
-      m_aer_emiss_vol=0. ; altemiss_vol=0. ; sigma_alt_vol=0.
-      xlon_min_vol=0. ; xlon_max_vol=0.
-      xlat_min_vol=0. ; xlat_max_vol=0.
-    ENDIF
-    
-    CALL getin_p('year_emit_vol',year_emit_vol)
-    CALL getin_p('mth_emit_vol',mth_emit_vol)
-    CALL getin_p('day_emit_vol',day_emit_vol)
-    CALL getin_p('m_aer_emiss_vol',m_aer_emiss_vol)
-    CALL getin_p('altemiss_vol',altemiss_vol)
-    CALL getin_p('sigma_alt_vol',sigma_alt_vol)
-    CALL getin_p('xlon_min_vol',xlon_min_vol)
-    CALL getin_p('xlon_max_vol',xlon_max_vol)
-    CALL getin_p('xlat_min_vol',xlat_min_vol)
-    CALL getin_p('xlat_max_vol',xlat_max_vol)
     !Config Key  = flag_nuc_rate_box
     !Config Desc = define or not a box for nucleation rate
@@ -136,4 +140,7 @@
     !
     flag_nuc_rate_box = .FALSE.
+    nuclat_min=0  ; nuclat_max=0
+    nucpres_min=0 ; nucpres_max=0
+
     CALL getin_p('flag_nuc_rate_box',flag_nuc_rate_box)
     CALL getin_p('nuclat_min',nuclat_min)
@@ -153,5 +160,4 @@
        WRITE(lunout,*) 'IN STRATAER : altemiss_vol',altemiss_vol
        WRITE(lunout,*) 'IN STRATAER : sigma_alt_vol',sigma_alt_vol
-       WRITE(lunout,*) 'IN STRATAER : ponde_lonlat_vol',ponde_lonlat_vol
        WRITE(lunout,*) 'IN STRATAER : xlat_min_vol',xlat_min_vol
        WRITE(lunout,*) 'IN STRATAER : xlat_max_vol',xlat_max_vol
@@ -164,5 +170,4 @@
        WRITE(lunout,*) 'IN STRATAER : xlat_sai',xlat_sai
        WRITE(lunout,*) 'IN STRATAER : xlon_sai',xlon_sai
-       WRITE(lunout,*) 'flag_sulf_emit_distrib = ',flag_sulf_emit_distrib
     ELSEIF (flag_sulf_emit == 3) THEN
        WRITE(lunout,*) 'IN STRATAER : m_aer_emiss_sai',m_aer_emiss_sai
@@ -172,6 +177,6 @@
        WRITE(lunout,*) 'IN STRATAER : xlat_max_sai',xlat_max_sai
        WRITE(lunout,*) 'IN STRATAER : xlon_sai',xlon_sai
-       WRITE(lunout,*) 'flag_sulf_emit_distrib = ',flag_sulf_emit_distrib
     ENDIF
+    WRITE(lunout,*) 'flag_sulf_emit_distrib = ',flag_sulf_emit_distrib
     WRITE(lunout,*) 'IN STRATAER : flag_nuc_rate_box = ',flag_nuc_rate_box
     IF (flag_nuc_rate_box) THEN
@@ -181,6 +186,9 @@
     !ENDIF
 
-    CALL strataer_ponde_init
-    WRITE(lunout,*) 'IN STRATAER INT2 END'
+    IF (flag_sulf_emit == 1) THEN
+       CALL strataer_ponde_init
+       WRITE(lunout,*) 'IN STRATAER INT2 END'
+    END IF
+    WRITE(lunout,*) 'IN STRATAER END'
 
   END SUBROUTINE strataer_init
Index: LMDZ6/branches/Portage_acc/libf/phylmd/StratAer/traccoag_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/StratAer/traccoag_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/StratAer/traccoag_mod.F90	(revision 4446)
@@ -17,5 +17,5 @@
 
     USE dimphy
-    USE infotrac_phy
+    USE infotrac_phy, ONLY : nbtr_bin, nbtr_sulgas, nbtr, id_SO2_strat
     USE aerophys
     USE geometry_mod, ONLY : cell_area, boundslat
@@ -23,5 +23,5 @@
     USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
     USE mod_phys_lmdz_para, only: gather, scatter
-    USE phys_cal_mod
+    USE phys_cal_mod, ONLY : year_len, year_cur,mth_cur, day_cur, hour
     USE sulfate_aer_mod
     USE phys_local_var_mod, ONLY: stratomask
@@ -29,5 +29,4 @@
     USE print_control_mod, ONLY: lunout
     USE strataer_mod
-    USE phys_cal_mod, ONLY : year_len
 
     IMPLICIT NONE
Index: LMDZ6/branches/Portage_acc/libf/phylmd/aero_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/aero_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/aero_mod.F90	(revision 4446)
@@ -53,17 +53,17 @@
 ! Corresponding names for the aerosols
   CHARACTER(len=7),DIMENSION(naero_spc), PARAMETER :: name_aero=(/&
-       "ASBCM  ", &
-       "ASPOMM ", &
-       "SO4    ", &
-       "CSSO4M ", &
-       "SSSSM  ", &
-       "CSSSM  ", &
-       "ASSSM  ", &
-       "CIDUSTM", &
-       "AIBCM  ", &
-       "AIPOMM " ,&
-       "ASNO3M ", & 
-       "CSNO3M ", &
-       "CINO3M " /)
+       "ASBCM  ", & ! Accumulation-mode Soluble Black Carbon Mass 
+       "ASPOMM ", & ! Accumulation-mode Soluble Particle Organic Matter Mass
+       "SO4    ", & ! Accumulation-mode Soluble Sulfate
+       "CSSO4M ", & ! Coarse-mode Soluble Sulfate Mass
+       "SSSSM  ", & ! Super-coarse mode Soluble Sea-Salt Mass
+       "CSSSM  ", & ! Coarse-mode Soluble Sea-Salt Mass
+       "ASSSM  ", & ! Accumulation-mode Soluble Sea-Salt Mass
+       "CIDUSTM", & ! Coarse-mode Insoluble Dust Mass
+       "AIBCM  ", & ! Accumulation-mode Insoluble Black Carbon Mass
+       "AIPOMM " ,& ! Accumulation-mode Insoluble Particle Organic Matter Mass 
+       "ASNO3M ", & ! Accumulation-mode Soluble Nitrate Mass
+       "CSNO3M ", & ! Coarse-mode Soluble Nitrate Mass
+       "CINO3M " /) ! Coarse-mode Insoluble Nitrate Mass
 
 ! 3/ Number of aerosol groups
Index: LMDZ6/branches/Portage_acc/libf/phylmd/calltherm.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/calltherm.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/calltherm.F90	(revision 4446)
@@ -30,5 +30,5 @@
       USE print_control_mod, ONLY: prt_level,lunout
 #ifdef ISO
-      use infotrac_phy, ONLY: ntraciso
+      use infotrac_phy, ONLY: ntiso
 #ifdef ISOVERIF
       USE isotopes_mod, ONLY: iso_eau,iso_HDO
@@ -145,10 +145,10 @@
 
 #ifdef ISO
-      REAL xt_seri(ntraciso,klon,klev),xtmemoire(ntraciso,klon,klev)
-      REAL d_xt_ajs(ntraciso,klon,klev)
-      real d_xt_the(ntraciso,klon,klev)
+      REAL xt_seri(ntiso,klon,klev),xtmemoire(ntiso,klon,klev)
+      REAL d_xt_ajs(ntiso,klon,klev)
+      real d_xt_the(ntiso,klon,klev)
 #ifdef DIAGISO
       real q_the(klon,klev)
-      real xt_the(ntraciso,klon,klev)
+      real xt_the(ntiso,klon,klev)
 #endif
       real qprec(klon,klev)
@@ -205,5 +205,5 @@
                 nbptspb=nbptspb+1
 #ifdef ISO
-                do ixt=1,ntraciso
+                do ixt=1,ntiso
                   xt_seri(ixt,i,k)=1.e-15*(xt_seri(ixt,i,k)/qprec(i,k))
                   ! xt_seri(ixt,i,k)=1.e-15*(Rdefault(index_iso(ixt)))
@@ -228,5 +228,5 @@
        call iso_verif_egalite_vect2D( &
      &           xt_seri,q_seri, &
-     &           'calltherm 174',ntraciso,klon,klev) 
+     &           'calltherm 174',ntiso,klon,klev) 
       endif !if (iso_eau.gt.0) then
 #endif    
@@ -360,5 +360,5 @@
      &       +zdetr_therm(:,k)*fact(:)
 #ifdef ISO
-            do ixt=1,ntraciso
+            do ixt=1,ntiso
               d_xt_the(ixt,:,k)=d_xt_the(ixt,:,k)*dtime*fact(:)
             enddo
@@ -398,5 +398,5 @@
       call iso_verif_aberrant_enc_vect2D( &
      &        xt_seri,q_seri, &
-     &        'calltherm 353, apres ajout d_xt_the',ntraciso,klon,klev)
+     &        'calltherm 353, apres ajout d_xt_the',ntiso,klon,klev)
       endif      
 #endif
@@ -424,5 +424,5 @@
                 nbptspb=nbptspb+1
 #ifdef ISO
-                do ixt=1,ntraciso
+                do ixt=1,ntiso
                   xt_seri(ixt,i,k)=1.e-15*(xtmemoire(ixt,i,k)/qmemoire(i,k))
                 enddo
@@ -440,5 +440,5 @@
       call iso_verif_aberrant_enc_vect2D( &
      &        xt_seri,q_seri, &
-     &        'calltherm 393, apres bidouille q<0',ntraciso,klon,klev)
+     &        'calltherm 393, apres bidouille q<0',ntiso,klon,klev)
       endif      
 #endif
Index: LMDZ6/branches/Portage_acc/libf/phylmd/carbon_cycle_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/carbon_cycle_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/carbon_cycle_mod.F90	(revision 4446)
@@ -237,44 +237,34 @@
        IF (.NOT.ALLOCATED(fco2_land)) ALLOCATE(fco2_land(klon), stat=ierr)
        IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land',1)
-       fco2_land(1:klon) = 0.
 
        IF (.NOT.ALLOCATED(fco2_land_nbp)) ALLOCATE(fco2_land_nbp(klon), stat=ierr)
        IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land_nbp',1)
-       fco2_land_nbp(1:klon) = 0.
 
        IF (.NOT.ALLOCATED(fco2_land_nep)) ALLOCATE(fco2_land_nep(klon), stat=ierr)
        IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land_nep',1)
-       fco2_land_nep(1:klon) = 0.
 
        IF (.NOT.ALLOCATED(fco2_land_fLuc)) ALLOCATE(fco2_land_fLuc(klon), stat=ierr)
        IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land_fLuc',1)
-       fco2_land_fLuc(1:klon) = 0.
 
        IF (.NOT.ALLOCATED(fco2_land_fwoodharvest)) ALLOCATE(fco2_land_fwoodharvest(klon), stat=ierr)
        IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land_fwoodharvest',1)
-       fco2_land_fwoodharvest(1:klon) = 0.
 
        IF (.NOT.ALLOCATED(fco2_land_fHarvest)) ALLOCATE(fco2_land_fHarvest(klon), stat=ierr)
        IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land_fHarvest',1)
-       fco2_land_fHarvest(1:klon) = 0.
 
        IF (.NOT.ALLOCATED(fco2_ff)) ALLOCATE(fco2_ff(klon), stat=ierr)
        IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_ff',1)
-       fco2_ff(1:klon) = 0.
 
        IF (.NOT.ALLOCATED(fco2_bb)) ALLOCATE(fco2_bb(klon), stat=ierr)
        IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_bb',1)
-       fco2_bb(1:klon) = 0.
 
        IF (.NOT.ALLOCATED(fco2_ocean)) ALLOCATE(fco2_ocean(klon), stat=ierr)
        IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_ocean',1)
-       fco2_ocean(1:klon) = 0.
 
        IF (.NOT.ALLOCATED(fco2_ocean_cor)) ALLOCATE(fco2_ocean_cor(klon), stat=ierr)
        IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_ocean_cor',1)
-       fco2_ocean_cor(1:klon) = 0.
+
        IF (.NOT.ALLOCATED(fco2_land_cor)) ALLOCATE(fco2_land_cor(klon), stat=ierr)
        IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land_cor',1)
-       fco2_land_cor(1:klon) = 0.
 
     ENDIF
Index: LMDZ6/branches/Portage_acc/libf/phylmd/clesphys.h
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/clesphys.h	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/clesphys.h	(revision 4446)
@@ -7,5 +7,7 @@
 !
 !..include cles_phys.h
-!
+
+       ! threshold on zrel_mount to activate SSO schemes
+       REAL zrel_mount_t
        INTEGER iflag_cycle_diurne
        LOGICAL soil_model,new_oliq,ok_orodr,ok_orolf 
@@ -54,4 +56,5 @@
        REAL min_wind_speed,f_gust_wk,f_gust_bl,f_qsat_oce,f_z0qh_oce
        REAL z0m_seaice,z0h_seaice
+       REAL z0m_landice, z0h_landice
        INTEGER iflag_gusts,iflag_z0_oce
 
@@ -113,5 +116,5 @@
      &     , f_cdrag_ter,f_cdrag_oce,f_rugoro,z0min,tau_gl              &
      &     , min_wind_speed,f_gust_wk,f_gust_bl,f_qsat_oce,f_z0qh_oce   &
-     &     , z0m_seaice,z0h_seaice                                      &
+     &     , z0m_seaice,z0h_seaice,z0m_landice,z0h_landice              &
      &     , freq_outNMC, freq_calNMC                                   &
      &     , lonmin_ins, lonmax_ins, latmin_ins, latmax_ins             &
@@ -121,5 +124,5 @@
      &     , co2_ppm0                                                   &
 !FC
-     &     , Cd_frein                                                   &
+     &     , Cd_frein, zrel_mount_t                                     &
      &     , ecrit_LES                                                  &
      &     , ecrit_ins, ecrit_hf, ecrit_day                             &
Index: LMDZ6/branches/Portage_acc/libf/phylmd/cloudth_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/cloudth_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/cloudth_mod.F90	(revision 4446)
@@ -1146,5 +1146,7 @@
 
       ELSE IF (iflag_cloudth_vert == 5) THEN
-      sigma1s=(0.71794+0.000498239*dz(ind1,ind2))*(fraca(ind1,ind2)**0.5)/(1-fraca(ind1,ind2))*(((sth-senv)**2)**0.5)+ratqs(ind1,ind2)*po(ind1) !Environment
+         sigma1s=(0.71794+0.000498239*dz(ind1,ind2))*(fraca(ind1,ind2)**0.5) &
+              /(1-fraca(ind1,ind2))*(((sth-senv)**2)**0.5) &
+              +ratqs(ind1,ind2)*po(ind1) !Environment
       sigma2s=(0.03218+0.000092655*dz(ind1,ind2))/((fraca(ind1,ind2)+0.02)**0.5)*(((sth-senv)**2)**0.5)+0.002*zqta(ind1,ind2)                   !Thermals
       !sigma1s=(1.1**0.5)*(fraca(ind1,ind2)**0.6)/(1-fraca(ind1,ind2))*((sth-senv)**2)**0.5+0.002*po(ind1)
@@ -1414,5 +1416,7 @@
         !--------------------------------------------
       sigma_th=(0.03218+0.000092655*dz(ind1,ind2))/((fraca(ind1,ind2)+0.01)**0.5)*(((sth-senv)**2)**0.5)+0.002*zqta(ind1,ind2)
-      sigma_env=(0.71794+0.000498239*dz(ind1,ind2))*(fraca(ind1,ind2)**0.5)/(1-fraca(ind1,ind2))*(((sth-senv)**2)**0.5)+ratqs(ind1,ind2)*po(ind1)
+      sigma_env=(0.71794+0.000498239*dz(ind1,ind2))*(fraca(ind1,ind2)**0.5) &
+           /(1-fraca(ind1,ind2))*(((sth-senv)**2)**0.5) &
+           +ratqs(ind1,ind2)*po(ind1)
       xth=sth/(sqrt2*sigma_th)
       xenv=senv/(sqrt2*sigma_env)
@@ -1534,5 +1538,5 @@
 
 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-SUBROUTINE cloudth_mpc(klon,klev,ind2,mpc_bl_points,                        &
+SUBROUTINE cloudth_mpc(klon,klev,ind2,iflag_mpc_bl,mpc_bl_points,           &
 &           temp,ztv,po,zqta,fraca,zpspsk,paprs,pplay,ztla,zthl,            &
 &           ratqs,zqs,snowflux,qcloud,qincloud,icefrac,ctot,ctot_vol)
@@ -1582,4 +1586,6 @@
       REAL, DIMENSION(klon),      INTENT(IN)      ::  zqs           ! Saturation specific humidity in the mesh [kg/kg]
       REAL, DIMENSION(klon,klev+1), INTENT(IN)    ::  snowflux      ! snow flux at the interface of the layer [kg/m2/s]
+      INTEGER,                      INTENT(IN)    ::  iflag_mpc_bl  ! option flag for mpc boundary layer clouds param.
+
 
       INTEGER, DIMENSION(klon,klev), INTENT(INOUT) :: mpc_bl_points  ! grid points with convective (thermals) mixed phase clouds
@@ -2020,5 +2026,7 @@
                 + (1.-1./(1.+C_mpc*qith(ind1,ind2))) * athl*(qsith(ind1,ind2)-qslth(ind1))  
 
-            sigma2sc=(sigma2s_factor*((MAX((sthlc-senvl),0.)**2)**0.5)/((fraca(ind1,ind2)+0.02)**sigma2s_power))+0.002*zqta(ind1,ind2)
+            sigma2sc=(sigma2s_factor*((MAX((sthlc-senvl),0.)**2)**0.5) &
+                 /((fraca(ind1,ind2)+0.02)**sigma2s_power)) &
+                 +0.002*zqta(ind1,ind2)
             deltasthc=athl*vert_alpha_th*sigma2sc
      
@@ -2166,5 +2174,7 @@
             ctot_vol(ind1,ind2)=fraca(ind1,ind2)*cth_vol(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*cenv_vol(ind1,ind2)
             IF (qcth(ind1,ind2) .GT. 0) THEN
-                icefrac(ind1,ind2)=fraca(ind1,ind2)*qith(ind1,ind2)/(fraca(ind1,ind2)*qcth(ind1,ind2)+(1.-1.*fraca(ind1,ind2))*qcenv(ind1,ind2))
+               icefrac(ind1,ind2)=fraca(ind1,ind2)*qith(ind1,ind2) &
+                    /(fraca(ind1,ind2)*qcth(ind1,ind2) &
+                    +(1.-1.*fraca(ind1,ind2))*qcenv(ind1,ind2))
                 icefrac(ind1,ind2)=MAX(MIN(1.,icefrac(ind1,ind2)),0.)
             ELSE
@@ -2386,5 +2396,7 @@
     AA=RLSTT/Ka/temp(ind2p1)*(RLSTT/RV/temp(ind2p1)-1.)
     BB=1./(rho(ind2p1)*Dv*qsith(ind2p1))
-    unsurtaustardep=C_cap*(Ni**0.66)*(qth(ind2p1)-qsith(ind2p1))/qsith(ind2p1)*4.*RPI/(AA+BB)*(6.*rho(ind2p1)/rhoi/RPI/Gamma(4.))**(0.33)
+    unsurtaustardep=C_cap*(Ni**0.66)*(qth(ind2p1)-qsith(ind2p1)) &
+         /qsith(ind2p1)*4.*RPI/(AA+BB) &
+         *(6.*rho(ind2p1)/rhoi/RPI/Gamma(4.))**(0.33)
     dep_term=rho(ind2p1)*fraca(ind2p1)*(qith(ind2p1)**0.33)*unsurtaustardep
  
Index: LMDZ6/branches/Portage_acc/libf/phylmd/coef_diff_turb_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/coef_diff_turb_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/coef_diff_turb_mod.F90	(revision 4446)
@@ -162,5 +162,5 @@
      
        IF (prt_level > 9) THEN
-          WRITE(lunout,*) 'USTAR = ',yustar
+          WRITE(lunout,*) 'USTAR = ',(yustar(i),i=1,knon)
        ENDIF
          
Index: LMDZ6/branches/Portage_acc/libf/phylmd/conf_phys_m.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/conf_phys_m.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/conf_phys_m.F90	(revision 4446)
@@ -133,9 +133,7 @@
     REAL, SAVE          :: f_rugoro_omp   , z0min_omp
     REAL, SAVE          :: z0m_seaice_omp,z0h_seaice_omp
+    REAL, SAVE          :: z0m_landice_omp,z0h_landice_omp
     REAL, SAVE          :: min_wind_speed_omp,f_gust_wk_omp,f_gust_bl_omp,f_qsat_oce_omp, f_z0qh_oce_omp
     INTEGER, SAVE       :: iflag_gusts_omp,iflag_z0_oce_omp
-
-    ! Local
-    REAL                 :: zzz
 
     REAL :: seuil_inversion
@@ -161,7 +159,8 @@
 
     REAL,SAVE :: R_ecc_omp,R_peri_omp,R_incl_omp,solaire_omp
-    REAL,SAVE      :: solaire_omp_init
+    REAL,SAVE :: solaire_omp_init
     LOGICAL,SAVE :: ok_suntime_rrtm_omp
     REAL,SAVE :: co2_ppm_omp, RCO2_omp, co2_ppm_per_omp, RCO2_per_omp
+    REAL,SAVE :: co2_ppm0_omp
     REAL,SAVE :: CH4_ppb_omp, RCH4_omp, CH4_ppb_per_omp, RCH4_per_omp
     REAL,SAVE :: N2O_ppb_omp, RN2O_omp, N2O_ppb_per_omp, RN2O_per_omp
@@ -186,5 +185,5 @@
     REAL,SAVE :: t_glace_min_omp, t_glace_max_omp
     REAL,SAVE :: exposant_glace_omp
-    INTEGER,SAVE :: iflag_gammasat_omp, iflag_mpc_bl_omp
+    INTEGER,SAVE :: iflag_gammasat_omp
     REAL,SAVE :: rei_min_omp, rei_max_omp
     INTEGER,SAVE :: iflag_sic_omp, iflag_inertie_omp
@@ -227,4 +226,5 @@
     LOGICAL, SAVE :: ok_lic_cond_omp
     !
+    REAL, SAVE    :: zrel_mount_t_omp
     INTEGER, SAVE :: iflag_cycle_diurne_omp
     LOGICAL, SAVE :: soil_model_omp,new_oliq_omp
@@ -255,5 +255,4 @@
     LOGICAL, SAVE :: ok_new_lscp_omp
     LOGICAL, SAVE :: ok_icefra_lscp_omp
-    LOGICAL, SAVE :: ok_radliq_snow_omp
 
 
@@ -745,24 +744,24 @@
     !
     !Config Key  = co2_ppm
-    !Config Desc = concentration du gaz carbonique en ppmv
+    !Config Desc = concentration du CO2 en ppmv
     !Config Def  = 348.
     !Config Help = 
     !               
-    !
     !valeur AMIP II
     co2_ppm_omp = 348.
     CALL getin('co2_ppm', co2_ppm_omp)
     !
-    !Config Key  = RCO2
-    !Config Desc = Concentration du CO2
-    !Config Def  = co2_ppm * 1.0e-06  * 44.011/28.97
-    !Config Def  = 348. * 1.0e-06  * 44.011/28.97
+    !conversion en rapport de mélange massique
+    RCO2_omp = co2_ppm_omp * 1.0e-06 * RMCO2 / RMD
+
+    !
+    !Config Key  = co2_ppm0
+    !Config Desc = concentration initiale du CO2 en ppmv pour la version ESM avec CO2 interactif dans le cas 
+    !              où cette concentration de figure pas dans l'état de redémarrage de la physique
+    !Config Def  = 284.32
     !Config Help = 
     !               
-    ! RCO2 = 5.286789092164308E-04
-    !ancienne valeur
-    RCO2_omp = co2_ppm_omp * 1.0e-06 * RMCO2 / RMD ! pour co2_ppm=348.
-
-    !  CALL getin('RCO2', RCO2)
+    co2_ppm0_omp = 284.32
+    CALL getin('co2_ppm0', co2_ppm0_omp)
     !
     !Config Key  = RCH4
@@ -771,15 +770,7 @@
     !Config Help = 
     !               
-    !
-    !valeur AMIP II
-    !OK  RCH4 = 1.65E-06* 16.043/28.97
-    ! RCH4 = 9.137366240938903E-07
-    !
-    !ancienne valeur
-    ! RCH4 = 1.72E-06* 16.043/28.97
-    !OK CALL getin('RCH4', RCH4)
-    zzz = 1650.
-    CALL getin('CH4_ppb', zzz)
-    CH4_ppb_omp = zzz
+    CH4_ppb_omp = 1650.
+    CALL getin('CH4_ppb', CH4_ppb_omp)
+    !conversion en rapport de mélange massique
     RCH4_omp = CH4_ppb_omp * 1.0E-09 * RMCH4 / RMD
     !
@@ -789,15 +780,7 @@
     !Config Help = 
     !               
-    !
-    !valeur AMIP II
-    !OK  RN2O = 306.E-09* 44.013/28.97
-    ! RN2O = 4.648939592682085E-07
-    !
-    !ancienne valeur
-    ! RN2O = 310.E-09* 44.013/28.97
-    !OK  CALL getin('RN2O', RN2O)
-    zzz=306.
-    CALL getin('N2O_ppb', zzz)
-    N2O_ppb_omp = zzz
+    N2O_ppb_omp = 306.
+    CALL getin('N2O_ppb', N2O_ppb_omp)
+    !conversion en rapport de mélange massique
     RN2O_omp = N2O_ppb_omp * 1.0E-09 * RMN2O / RMD
     !
@@ -807,12 +790,8 @@
     !Config Help = 
     !               
-    !
-    !OK RCFC11 = 280.E-12* 137.3686/28.97
-    zzz = 280.
-    CALL getin('CFC11_ppt',zzz)
-    CFC11_ppt_omp = zzz
+    CFC11_ppt_omp = 280.
+    CALL getin('CFC11_ppt',CFC11_ppt_omp)
+    !conversion en rapport de mélange massique
     RCFC11_omp=CFC11_ppt_omp* 1.0E-12 * RMCFC11 / RMD
-    ! RCFC11 = 1.327690990680013E-09
-    !OK CALL getin('RCFC11', RCFC11)
     !
     !Config Key  = RCFC12
@@ -821,17 +800,12 @@
     !Config Help = 
     !               
-    !
-    !OK RCFC12 = 484.E-12* 120.9140/28.97
-    zzz = 484.
-    CALL getin('CFC12_ppt',zzz)
-    CFC12_ppt_omp = zzz
+    CFC12_ppt_omp = 484.
+    CALL getin('CFC12_ppt',CFC12_ppt_omp)
+    !conversion en rapport de mélange massique
     RCFC12_omp = CFC12_ppt_omp * 1.0E-12 * RMCFC12 / RMD
-    ! RCFC12 = 2.020102726958923E-09
-    !OK CALL getin('RCFC12', RCFC12)
-
-    !ajout CFMIP begin
+
     !
     !Config Key  = co2_ppm_per
-    !Config Desc = concentration du co2_ppm_per
+    !Config Desc = concentration du CO2 perturbé en ppmv (CFMIP)
     !Config Def  = 348.
     !Config Help = 
@@ -839,17 +813,6 @@
     co2_ppm_per_omp = co2_ppm_omp
     CALL getin('co2_ppm_per', co2_ppm_per_omp)
-    !
-    !Config Key  = RCO2_per
-    !Config Desc = Concentration du CO2_per
-    !Config Def  = co2_ppm_per * 1.0e-06  * 44.011/28.97
-    !Config Def  = 348. * 1.0e-06  * 44.011/28.97
-    !Config Help = 
-    !               
+    !conversion en rapport de mélange massique
     RCO2_per_omp = co2_ppm_per_omp * 1.0e-06 * RMCO2 / RMD
-
-    !Config Key  = ok_4xCO2atm
-    !Config Desc = Calcul ou non effet radiatif 4xco2
-    !Config Def  = .FALSE.
-    !Config Help = 
 
     !Config Key  = RCH4_per
@@ -858,7 +821,7 @@
     !Config Help = 
     !               
-    zzz = CH4_ppb_omp
-    CALL getin('CH4_ppb_per', zzz)
-    CH4_ppb_per_omp = zzz
+    CH4_ppb_per_omp = CH4_ppb_omp
+    CALL getin('CH4_ppb_per', CH4_ppb_per_omp)
+    !conversion en rapport de mélange massique
     RCH4_per_omp = CH4_ppb_per_omp * 1.0E-09 * RMCH4 / RMD
     !
@@ -868,7 +831,7 @@
     !Config Help = 
     !               
-    zzz = N2O_ppb_omp
-    CALL getin('N2O_ppb_per', zzz)
-    N2O_ppb_per_omp = zzz
+    N2O_ppb_per_omp = N2O_ppb_omp
+    CALL getin('N2O_ppb_per', N2O_ppb_per_omp)
+    !conversion en rapport de mélange massique
     RN2O_per_omp = N2O_ppb_per_omp * 1.0E-09 * RMN2O / RMD
     !
@@ -878,7 +841,7 @@
     !Config Help = 
     !               
-    zzz = CFC11_ppt_omp
-    CALL getin('CFC11_ppt_per',zzz)
-    CFC11_ppt_per_omp = zzz
+    CFC11_ppt_per_omp = CFC11_ppt_omp
+    CALL getin('CFC11_ppt_per',CFC11_ppt_per_omp)
+    !conversion en rapport de mélange massique
     RCFC11_per_omp=CFC11_ppt_per_omp* 1.0E-12 * RMCFC11 / RMD
     !
@@ -888,9 +851,8 @@
     !Config Help = 
     !               
-    zzz = CFC12_ppt_omp
-    CALL getin('CFC12_ppt_per',zzz)
-    CFC12_ppt_per_omp = zzz
+    CFC12_ppt_per_omp = CFC12_ppt_omp
+    CALL getin('CFC12_ppt_per',CFC12_ppt_per_omp)
+    !conversion en rapport de mélange massique
     RCFC12_per_omp = CFC12_ppt_per_omp * 1.0E-12 * RMCFC12 / RMD
-    !ajout CFMIP end
 
     !
@@ -937,4 +899,13 @@
     ok_orolf_omp = .TRUE.
     CALL getin('ok_orolf', ok_orolf_omp)
+
+
+    !Config  Key  =  zrel_mount_t
+    !Config  Desc = zrel_mount_t
+    !Config  Def  = 0.
+    !Config  Help = Connais pas !
+    zrel_mount_t_omp = 0.
+    CALL getin('zrel_mount_t', zrel_mount_t_omp)
+
 
     !Config  Key  = ok_limitvrai
@@ -1457,15 +1428,4 @@
 
     !
-    !Config Key  = iflag_mpc_bl
-    !Config Desc =
-    !Config Def  = 0
-    !Config Help =
-    !
-    iflag_mpc_bl_omp=0
-    CALL getin('iflag_mpc_bl',iflag_mpc_bl_omp)
-
-
-
-    !
     !Config Key  = iflag_t_glace
     !Config Desc =  
@@ -2123,4 +2083,8 @@
     z0m_seaice_omp = 0.002 ; CALL getin('z0m_seaice',z0m_seaice_omp)
     z0h_seaice_omp = 0.002 ; CALL getin('z0h_seaice',z0h_seaice_omp)
+
+
+    z0m_landice_omp = 0.001 ; CALL getin('z0m_landice',z0m_landice_omp)
+    z0h_landice_omp = 0.001 ; CALL getin('z0h_landice',z0h_landice_omp)
 
     f_rugoro_omp = 0.
@@ -2376,12 +2340,4 @@
     !Config Help = ...
 
-
-    ok_radliq_snow_omp = .FALSE.
-    CALL getin('ok_radliq_snow', ok_radliq_snow_omp)
-    !
-    !Config Key  = ok_radliq_snow_omp
-    !Config Desc = take into account snowfall for radiation
-    !Config Def  = .FALSE.
-    !Config Help = ...
 
     ecrit_LES_omp = 1./8.
@@ -2434,4 +2390,5 @@
     ok_suntime_rrtm = ok_suntime_rrtm_omp
     co2_ppm = co2_ppm_omp
+    co2_ppm0 = co2_ppm0_omp
     RCO2 = RCO2_omp
     CH4_ppb = CH4_ppb_omp
@@ -2459,4 +2416,5 @@
     ok_orodr = ok_orodr_omp
     ok_orolf = ok_orolf_omp
+    zrel_mount_t=zrel_mount_t_omp
     ok_limitvrai = ok_limitvrai_omp
     nbapp_rad = nbapp_rad_omp
@@ -2500,5 +2458,4 @@
     exposant_glace = exposant_glace_omp
     iflag_gammasat=iflag_gammasat_omp
-    iflag_mpc_bl=iflag_mpc_bl_omp
     iflag_t_glace = iflag_t_glace_omp
     iflag_cloudth_vert=iflag_cloudth_vert_omp
@@ -2666,4 +2623,6 @@
     z0m_seaice=z0m_seaice_omp
     z0h_seaice=z0h_seaice_omp
+    z0m_landice=z0m_landice_omp
+    z0h_landice=z0h_landice_omp
 
     f_rugoro=f_rugoro_omp
@@ -2708,5 +2667,4 @@
     ok_new_lscp = ok_new_lscp_omp
     ok_icefra_lscp=ok_icefra_lscp_omp
-    ok_radliq_snow=ok_radliq_snow_omp
     read_fco2_ocean_cor = read_fco2_ocean_cor_omp
     var_fco2_ocean_cor = var_fco2_ocean_cor_omp
@@ -2863,4 +2821,5 @@
     WRITE(lunout,*) ' ok_suntime_rrtm =',ok_suntime_rrtm
     WRITE(lunout,*) ' co2_ppm =',co2_ppm
+    WRITE(lunout,*) ' co2_ppm0 =',co2_ppm0
     WRITE(lunout,*) ' RCO2_act = ',RCO2_act
     WRITE(lunout,*) ' CH4_ppb =',CH4_ppb,' RCH4_act = ',RCH4_act
@@ -2881,4 +2840,5 @@
     WRITE(lunout,*) ' ok_orodr=',ok_orodr
     WRITE(lunout,*) ' ok_orolf=',ok_orolf
+    WRITE(lunout,*) ' zrel_mount_t=',zrel_mount_t
     WRITE(lunout,*) ' ok_limitvrai=',ok_limitvrai
     WRITE(lunout,*) ' nbapp_rad=',nbapp_rad
@@ -2929,5 +2889,4 @@
     WRITE(lunout,*) ' exposant_glace = ',exposant_glace
     WRITE(lunout,*) ' iflag_gammasat = ',iflag_gammasat
-    WRITE(lunout,*) ' iflag_mpc_bl = ',iflag_mpc_bl
     WRITE(lunout,*) ' iflag_t_glace = ',iflag_t_glace
     WRITE(lunout,*) ' iflag_cloudth_vert = ',iflag_cloudth_vert
@@ -3048,5 +3007,4 @@
     WRITE(lunout,*) ' ok_new_lscp = ', ok_new_lscp
     WRITE(lunout,*) ' ok_icefra_lscp = ', ok_icefra_lscp
-    WRITE(lunout,*) ' ok_radliq_snow = ', ok_radliq_snow
     WRITE(lunout,*) ' read_climoz = ', read_climoz
     WRITE(lunout,*) ' carbon_cycle_tr = ', carbon_cycle_tr
Index: LMDZ6/branches/Portage_acc/libf/phylmd/cosp/dsd.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/cosp/dsd.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/cosp/dsd.F90	(revision 4446)
@@ -1,3 +1,6 @@
-  subroutine dsd(Q,Re,Np,D,N,nsizes,dtype,rho_a,tk, &
+!
+! $Id$
+!
+  subroutine dsd(Q,Re_,Np,D,N,nsizes,dtype,rho_a,tk, &
              dmin,dmax,apm,bpm,rho_c,p1,p2,p3)
   use array_lib
Index: LMDZ6/branches/Portage_acc/libf/phylmd/cpl_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/cpl_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/cpl_mod.F90	(revision 4446)
@@ -49,6 +49,8 @@
   !$OMP THREADPRIVATE(cpl_snow,cpl_evap,cpl_tsol)
 
-  REAL, ALLOCATABLE, SAVE:: cpl_delta_sst(:), cpl_delta_sal(:)
-  !$OMP THREADPRIVATE(cpl_delta_sst, cpl_delta_sal)
+  REAL, ALLOCATABLE, SAVE:: cpl_delta_sst(:), cpl_delta_sal(:), cpl_dter(:), &
+       cpl_dser(:), cpl_dt_ds(:)
+  !$OMP THREADPRIVATE(cpl_delta_sst, cpl_delta_sal, cpl_dter, cpl_dser)
+  !$OMP THREADPRIVATE(cpl_dt_ds)
   
   REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: cpl_fder, cpl_albe, cpl_taux, cpl_tauy
@@ -64,4 +66,6 @@
   REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: cpl_rriv2D, cpl_rcoa2D, cpl_rlic2D
   !$OMP THREADPRIVATE(cpl_rriv2D,cpl_rcoa2D,cpl_rlic2D)
+  REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: rlic_in_frac2D  ! fraction for continental ice
+  !$OMP THREADPRIVATE(rlic_in_frac2D)
 
 ! variables read from coupler :
@@ -94,6 +98,8 @@
   !$OMP THREADPRIVATE(cpl_snow2D, cpl_evap2D, cpl_tsol2D)
 
-  REAL, ALLOCATABLE, SAVE:: cpl_delta_sst_2D(:,:), cpl_delta_sal_2D(:,:)
+  REAL, ALLOCATABLE, SAVE:: cpl_delta_sst_2D(:, :), cpl_delta_sal_2D(:, :), &
+       cpl_dter_2D(:, :), cpl_dser_2D(:, :), cpl_dt_ds_2D(:, :)
   !$OMP THREADPRIVATE(cpl_delta_sst_2D, cpl_delta_sal_2D)
+  !$OMP THREADPRIVATE(cpl_dter_2D, cpl_dser_2D, cpl_dt_ds_2D)
 
   REAL, ALLOCATABLE, DIMENSION(:,:,:), SAVE :: cpl_fder2D, cpl_albe2D
@@ -226,4 +232,6 @@
     ALLOCATE(cpl_rlic2D(nbp_lon,jj_nb), stat=error)
     sum_error = sum_error + error
+    ALLOCATE(rlic_in_frac2D(nbp_lon,jj_nb), stat=error)
+    sum_error = sum_error + error
     ALLOCATE(read_sst(nbp_lon, jj_nb), stat = error)
     sum_error = sum_error + error
@@ -238,5 +246,6 @@
     
        if (activate_ocean_skin == 2) then
-          ALLOCATE(cpl_delta_sst(klon), cpl_delta_sal(klon), stat = error)
+          ALLOCATE(cpl_delta_sst(klon), cpl_delta_sal(klon), cpl_dter(klon), &
+               cpl_dser(klon), cpl_dt_ds(klon), stat = error)
           sum_error = sum_error + error
        end if
@@ -650,5 +659,5 @@
        precip_rain, precip_snow, evap, tsurf, fder, albsol, taux, tauy, windsp,&
        sens_prec_liq, sens_prec_sol, lat_prec_liq, lat_prec_sol, delta_sst, &
-       delta_sal)
+       delta_sal, dTer, dSer, dt_ds)
 
     ! This subroutine cumulates some fields for each time-step during
@@ -683,4 +692,16 @@
     real, intent(in):: delta_sal(:) ! (knon)
     ! Ocean-air interface salinity minus bulk salinity, in ppt.
+
+    REAL, intent(in):: dter(:) ! (knon)
+    ! Temperature variation in the diffusive microlayer, that is
+    ! ocean-air interface temperature minus subskin temperature. In
+    ! K.
+
+    REAL, intent(in):: dser(:) ! (knon)
+    ! Salinity variation in the diffusive microlayer, that is
+    ! ocean-air interface salinity minus subskin salinity. In ppt.
+
+    real, intent(in):: dt_ds(:) ! (knon)
+    ! (tks / tkt) * dTer, in K
 
 ! Local variables
@@ -722,4 +743,7 @@
           cpl_delta_sst = 0.
           cpl_delta_sal = 0.
+          cpl_dter = 0.
+          cpl_dser = 0.
+          cpl_dt_ds = 0.
        end if
     ENDIF
@@ -768,4 +792,7 @@
           cpl_delta_sst(ig) = cpl_delta_sst(ig) + delta_sst(ig) / REAL(nexca)
           cpl_delta_sal(ig) = cpl_delta_sal(ig) + delta_sal(ig) / REAL(nexca)
+          cpl_dter(ig) = cpl_dter(ig) + dter(ig) / REAL(nexca)
+          cpl_dser(ig) = cpl_dser(ig) + dser(ig) / REAL(nexca)
+          cpl_dt_ds(ig) = cpl_dt_ds(ig) + dt_ds(ig) / REAL(nexca)
        end if
      ENDDO
@@ -817,5 +844,7 @@
           if (activate_ocean_skin == 2) then
              ALLOCATE(cpl_delta_sst_2D(nbp_lon, jj_nb), &
-                  cpl_delta_sal_2D(nbp_lon, jj_nb), stat = error)
+                  cpl_delta_sal_2D(nbp_lon, jj_nb), &
+                  cpl_dter_2D(nbp_lon, jj_nb), cpl_dser_2D(nbp_lon, jj_nb), &
+                  cpl_dt_ds_2D(nbp_lon, jj_nb), stat = error)
              sum_error = sum_error + error
           end if
@@ -878,4 +907,7 @@
           CALL gath2cpl(cpl_delta_sst, cpl_delta_sst_2D, knon, knindex)
           CALL gath2cpl(cpl_delta_sal, cpl_delta_sal_2D, knon, knindex)
+          CALL gath2cpl(cpl_dter, cpl_dter_2D, knon, knindex)
+          CALL gath2cpl(cpl_dser, cpl_dser_2D, knon, knindex)
+          CALL gath2cpl(cpl_dt_ds, cpl_dt_ds_2D, knon, knindex)
        end if
     ENDIF
@@ -1151,5 +1183,5 @@
 !
 
-  SUBROUTINE cpl_send_landice_fields(itime, knon, knindex, rlic_in)
+  SUBROUTINE cpl_send_landice_fields(itime, knon, knindex, rlic_in, rlic_in_frac)
 ! This subroutine cumulates the field for melting ice for each time-step 
 ! during a coupling period. This routine will not send to coupler. Sending 
@@ -1165,4 +1197,7 @@
     INTEGER, DIMENSION(klon), INTENT(IN)      :: knindex
     REAL, DIMENSION(klon), INTENT(IN)         :: rlic_in
+    REAL, DIMENSION(klon), INTENT(IN)         :: rlic_in_frac  ! Fraction for continental ice, can be equal to 
+                                                               ! pctsrf(:,is_lic) or not, depending on landice_opt
+    
 
 ! Local varibales
@@ -1179,5 +1214,5 @@
 !$OMP END MASTER
     CALL gath2cpl(rlic_in, rlic2D, knon, knindex)
-
+    CALL gath2cpl(rlic_in_frac(:), rlic_in_frac2D(:,:), knon, knindex) 
 !*************************************************************************************
 ! Reset field to zero in the beginning of a new coupling period 
@@ -1276,4 +1311,7 @@
        tab_flds(:, :, ids_delta_sst) = cpl_delta_sst_2D
        tab_flds(:, :, ids_delta_sal) = cpl_delta_sal_2D
+       tab_flds(:, :, ids_dter) = cpl_dter_2D
+       tab_flds(:, :, ids_dser) = cpl_dser_2D
+       tab_flds(:, :, ids_dt_ds) = cpl_dt_ds_2D
     end if
     
@@ -1298,5 +1336,7 @@
     CALL gath2cpl(pctsrf(:,is_oce), pctsrf2D(:,:,is_oce), klon, unity)
     CALL gath2cpl(pctsrf(:,is_sic), pctsrf2D(:,:,is_sic), klon, unity)
-    CALL gath2cpl(pctsrf(:,is_lic), pctsrf2D(:,:,is_lic), klon, unity)
+
+
+
 
 !*************************************************************************************
@@ -1311,5 +1351,5 @@
         DO j = 1, jj_nb
            tmp_calv(:,j) = DOT_PRODUCT (cpl_rlic2D(1:nbp_lon,j), &
-                pctsrf2D(1:nbp_lon,j,is_lic)) / REAL(nbp_lon)
+                rlic_in_frac2D(1:nbp_lon,j)) / REAL(nbp_lon)
         ENDDO
     
@@ -1348,5 +1388,5 @@
             calving(k)=0
             DO j = 1, jj_nb
-               calving(k)= calving(k)+DOT_PRODUCT(cpl_rlic2D(:,j)*area_calving(:,j,k),pctsrf2D(:,j,is_lic))
+               calving(k)= calving(k)+DOT_PRODUCT(cpl_rlic2D(:,j)*area_calving(:,j,k),rlic_in_frac2D(:,j))
             ENDDO
          ENDDO
@@ -1513,5 +1553,6 @@
     ENDIF
 
-    if (activate_ocean_skin == 2) deallocate(cpl_delta_sst_2d, cpl_delta_sal_2d)
+    if (activate_ocean_skin == 2) deallocate(cpl_delta_sst_2d, &
+         cpl_delta_sal_2d, cpl_dter_2d, cpl_dser_2d, cpl_dt_ds_2d)
 
     IF (sum_error /= 0) THEN
Index: LMDZ6/branches/Portage_acc/libf/phylmd/create_etat0_unstruct.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/create_etat0_unstruct.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/create_etat0_unstruct.F90	(revision 4446)
@@ -53,4 +53,5 @@
   USE phys_state_var_mod
   USE indice_sol_mod
+  USE surface_data,      ONLY: landice_opt
   USE mod_phys_lmdz_para
   USE print_control_mod, ONLY: lunout
@@ -83,5 +84,5 @@
       CALL xios_recv_field("qs",qsol_mpi)
       CALL xios_recv_field("mask",zmasq_mpi)
-      CALL xios_recv_field("landice",lic_mpi)
+      IF (landice_opt .LT. 2) CALL xios_recv_field("landice",lic_mpi)
       CALL xios_recv_field("zmea",zmea_mpi)
       CALL xios_recv_field("zstd",zstd_mpi)
@@ -93,5 +94,5 @@
     CALL scatter_omp(qsol_mpi,qsol)
     CALL scatter_omp(zmasq_mpi,zmasq)
-    CALL scatter_omp(lic_mpi,lic)
+    IF (landice_opt .LT. 2) CALL scatter_omp(lic_mpi,lic)
     CALL scatter_omp(zmea_mpi,zmea)
     CALL scatter_omp(zstd_mpi,zstd)
@@ -110,25 +111,35 @@
 
     pctsrf(:,:) = 0
-    pctsrf(:,is_lic)=lic
-    WHERE(pctsrf(:,is_lic)<EPSFRA) pctsrf(:,is_lic)=0. 
-    WHERE(zmasq(:)<EPSFRA)         pctsrf(:,is_lic)=0.
-
-    pctsrf(:,is_ter)=zmasq(:)
-
-!--- Adequation with soil/sea mask
-    DO ji=1,klon
-      IF(zmasq(ji)>EPSFRA) THEN 
-        IF(pctsrf(ji,is_lic)>=zmasq(ji)) THEN
-          pctsrf(ji,is_lic)=zmasq(ji)
-          pctsrf(ji,is_ter)=0.
-        ELSE
-          pctsrf(ji,is_ter)=zmasq(ji)-pctsrf(ji,is_lic)
-          IF(pctsrf(ji,is_ter)<EPSFRA) THEN
-            pctsrf(ji,is_ter)=0.
-            pctsrf(ji,is_lic)=zmasq(ji)
-          END IF 
-        END IF 
-      END IF 
-    END DO 
+    IF (landice_opt .LT. 2) THEN
+       pctsrf(:,is_lic)=lic
+       WHERE(pctsrf(:,is_lic)<EPSFRA) pctsrf(:,is_lic)=0.
+       WHERE(zmasq(:)<EPSFRA)         pctsrf(:,is_lic)=0.
+
+       pctsrf(:,is_ter)=zmasq(:)
+       
+       !--- Adequation with soil/sea mask
+       DO ji=1,klon
+          IF(zmasq(ji)>EPSFRA) THEN 
+             IF(pctsrf(ji,is_lic)>=zmasq(ji)) THEN
+                pctsrf(ji,is_lic)=zmasq(ji)
+                pctsrf(ji,is_ter)=0.
+             ELSE
+                pctsrf(ji,is_ter)=zmasq(ji)-pctsrf(ji,is_lic)
+                IF(pctsrf(ji,is_ter)<EPSFRA) THEN
+                   pctsrf(ji,is_ter)=0.
+                   pctsrf(ji,is_lic)=zmasq(ji)
+                END IF
+             END IF
+          END IF
+       END DO
+   
+    ELSE
+       ! landice_opt=>2 : no land ice
+       pctsrf(:,is_lic)=0.0
+       pctsrf(:,is_ter)=zmasq(:)
+    END IF
+
+
+
 
 
Index: LMDZ6/branches/Portage_acc/libf/phylmd/create_limit_unstruct.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/create_limit_unstruct.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/create_limit_unstruct.F90	(revision 4446)
@@ -111,8 +111,8 @@
       WHERE(NINT(zmasq(:))/=1) rugos(:,l)=0.001
     ENDDO
-    CALL time_interpolation(ndays,rugos,'360d',rugos_year)
+    CALL time_interpolation(ndays,rugos,'360_day',rugos_year)
 
 ! albedo    
-    CALL time_interpolation(ndays,albedo,'360d',albedo_year)
+    CALL time_interpolation(ndays,albedo,'360_day',albedo_year)
 
 
Index: LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/1DUTILS.h
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/1DUTILS.h	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/1DUTILS.h	(revision 4446)
@@ -1708,9 +1708,9 @@
 
 !
-        print *,'dtime, tau ',dtime,tau
-        print *, 'u_targ',u_targ
-        print *, 'v_targ',v_targ
-        print *,'zonal velocity ',u
-        print *,'meridional velocity ',v
+        !print *,'dtime, tau ',dtime,tau
+        !print *, 'u_targ',u_targ
+        !print *, 'v_targ',v_targ
+        !print *,'zonal velocity ',u
+        !print *,'meridional velocity ',v
         DO k = 1,klev
          DO i = 1,klon
@@ -1721,6 +1721,6 @@
             d_v(i,k) = d_v(i,k) + 1./tau*(v_targ(i,k)-v(i,k))
 !
-            print *,' k,u,d_u,v,d_v ',    &
-                      k,u(i,k),d_u(i,k),v(i,k),d_v(i,k)
+!           print *,' k,u,d_u,v,d_v ',    &
+!                     k,u(i,k),d_u(i,k),v(i,k),d_v(i,k)
 !           ENDIF
 !
Index: LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/1D_interp_cases.h
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/1D_interp_cases.h	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/1D_interp_cases.h	(revision 4446)
@@ -10,5 +10,5 @@
 !    &       ,year_ini_cas,day_ju_ini_cas,nt_cas,pdt_cas,nlev_cas                           &
      &       ,nt_cas,nlev_cas                                                               &
-     &       ,ts_cas,ps_cas,plev_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,ql_cas,qi_cas      &
+     &       ,ts_cas,tskin_cas,ps_cas,plev_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,ql_cas,qi_cas      &
      &       ,u_cas,v_cas,ug_cas,vg_cas                                                     &
      &       ,temp_nudg_cas,qv_nudg_cas,u_nudg_cas,v_nudg_cas                               &
@@ -19,5 +19,5 @@
      &       ,uw_cas,vw_cas,q1_cas,q2_cas,tkes_cas                                           &
 !
-     &       ,ts_prof_cas,ps_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas,thv_prof_cas  &
+     &       ,ts_prof_cas,tskin_prof_cas,ps_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas,thv_prof_cas  &
      &       ,thl_prof_cas,qv_prof_cas,ql_prof_cas,qi_prof_cas                              &
      &       ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas                                 &
@@ -31,5 +31,9 @@
      &       ,sens_prof_cas,ustar_prof_cas,uw_prof_cas,vw_prof_cas,q1_prof_cas,q2_prof_cas,tkes_prof_cas)
 ! EV tg instead of ts_cur
-             tg = ts_prof_cas 
+             tg = ts_prof_cas
+             if ((tg .eq. 0.) .and. (tskin_prof_cas .ne. 0.)) then
+                tg=tskin_prof_cas
+              endif
+
 !            psurf=plev_prof_cas(1)
              psurf=ps_prof_cas
Index: LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/1D_nudge_sandu_astex.h
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/1D_nudge_sandu_astex.h	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/1D_nudge_sandu_astex.h	(revision 4446)
@@ -33,10 +33,10 @@
 
 
-	print*,'OLDLMDZ1D IOPH'
-      CALL iophys_ecrit('relax_thl',klev,'relax_thl','m/s',relax_thl)
-      CALL iophys_ecrit('d_t_adv',klev,'d_t_adv','m/s',d_t_adv)
-      CALL iophys_ecrit('temp',klev,'temp','m/s',temp)
-      CALL iophys_ecrit('q',klev,'q','m/s',q(:,1))
-      CALL iophys_ecrit('relax_q',klev,'relax_q','m/s',relax_q(:,1))
-      CALL iophys_ecrit('d_q_adv',klev,'d_q_adv','m/s',d_q_adv(:,1))
+      !	print*,'OLDLMDZ1D IOPH'
+      !      CALL iophys_ecrit('relax_thl',klev,'relax_thl','m/s',relax_thl)
+      !      CALL iophys_ecrit('d_t_adv',klev,'d_t_adv','m/s',d_t_adv)
+      !      CALL iophys_ecrit('temp',klev,'temp','m/s',temp)
+      !      CALL iophys_ecrit('q',klev,'q','m/s',q(:,1))
+      !      CALL iophys_ecrit('relax_q',klev,'relax_q','m/s',relax_q(:,1))
+      !      CALL iophys_ecrit('d_q_adv',klev,'d_q_adv','m/s',d_q_adv(:,1))
 
Index: LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/1D_read_forc_cases.h
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/1D_read_forc_cases.h	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/1D_read_forc_cases.h	(revision 4446)
@@ -24,5 +24,5 @@
 !    &       ,year_ini_cas,day_ju_ini_cas,nt_cas,pdt_cas,nlev_cas                           &
      &       ,nt_cas,nlev_cas                                                               &
-     &       ,ts_cas,ps_cas,plev_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,ql_cas,qi_cas      &
+     &       ,ts_cas,tskin_cas,ps_cas,plev_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,ql_cas,qi_cas      &
      &       ,u_cas,v_cas,ug_cas,vg_cas                                                     &
      &       ,temp_nudg_cas,qv_nudg_cas,u_nudg_cas,v_nudg_cas                               &
@@ -33,5 +33,5 @@
      &       ,uw_cas,vw_cas,q1_cas,q2_cas,tkes_cas                                           &
 !
-     &       ,ts_prof_cas,ps_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas,thv_prof_cas  &
+     &       ,ts_prof_cas,tskin_prof_cas,ps_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas,thv_prof_cas  &
      &       ,thl_prof_cas,qv_prof_cas,ql_prof_cas,qi_prof_cas                              &
      &       ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas                                 &
@@ -73,9 +73,15 @@
 
 ! initial and boundary conditions :
-!     tsurf = ts_prof_cas
       psurf = ps_prof_cas
-      !EV tg instead of ts_cur
-      tg = ts_prof_cas 
-      print*, 'tg=', tg
+      if (tskin_prof_cas .NE. 0.) THEN
+          tsurf=tskin_prof_cas
+      endif
+
+      tg = ts_prof_cas
+      if ((tg .eq. 0.) .and. (tskin_prof_cas .NE. 0.)) THEN
+          tg=tskin_prof_cas
+      endif
+
+
 
       do l = 1, llm
@@ -83,4 +89,5 @@
        q(l,1) = qv_mod_cas(l)
        q(l,2) = ql_mod_cas(l)
+       q(l,3) = qi_mod_cas(l)
        u(l) = u_mod_cas(l)
        ug(l)= ug_mod_cas(l)
Index: LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/mod_1D_cases_read2.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/mod_1D_cases_read2.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/mod_1D_cases_read2.F90	(revision 4446)
@@ -5,724 +5,712 @@
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!Declarations specifiques au cas standard
-        character*80 :: fich_cas
-! Discr?tisation 
-        integer nlev_cas, nt_cas
-
-
-!profils environnementaux
-        real, allocatable::  plev_cas(:,:),plevh_cas(:)
-        real, allocatable::  ap_cas(:),bp_cas(:)
-
-        real, allocatable::  z_cas(:,:),zh_cas(:)
-        real, allocatable::  t_cas(:,:),q_cas(:,:),qv_cas(:,:),ql_cas(:,:),qi_cas(:,:),rh_cas(:,:)
-        real, allocatable::  th_cas(:,:),thv_cas(:,:),thl_cas(:,:),rv_cas(:,:)
-        real, allocatable::  u_cas(:,:),v_cas(:,:),vitw_cas(:,:),omega_cas(:,:)
-
-!forcing
-        real, allocatable::  ht_cas(:,:),vt_cas(:,:),dt_cas(:,:),dtrad_cas(:,:)
-        real, allocatable::  hth_cas(:,:),vth_cas(:,:),dth_cas(:,:)
-        real, allocatable::  hq_cas(:,:),vq_cas(:,:),dq_cas(:,:)
-        real, allocatable::  hr_cas(:,:),vr_cas(:,:),dr_cas(:,:)
-        real, allocatable::  hu_cas(:,:),vu_cas(:,:),du_cas(:,:)
-        real, allocatable::  hv_cas(:,:),vv_cas(:,:),dv_cas(:,:)
-        real, allocatable::  ug_cas(:,:),vg_cas(:,:)
-        real, allocatable::  lat_cas(:),sens_cas(:),ts_cas(:),ps_cas(:),ustar_cas(:)
-        real, allocatable::  uw_cas(:,:),vw_cas(:,:),q1_cas(:,:),q2_cas(:,:),tke_cas(:)
-
-!champs interpoles
-        real, allocatable::  plev_prof_cas(:)
-        real, allocatable::  t_prof_cas(:)
-        real, allocatable::  theta_prof_cas(:)
-        real, allocatable::  thl_prof_cas(:)
-        real, allocatable::  thv_prof_cas(:)
-        real, allocatable::  q_prof_cas(:)
-        real, allocatable::  qv_prof_cas(:)
-        real, allocatable::  ql_prof_cas(:)
-        real, allocatable::  qi_prof_cas(:)
-        real, allocatable::  rh_prof_cas(:)
-        real, allocatable::  rv_prof_cas(:)
-        real, allocatable::  u_prof_cas(:)
-        real, allocatable::  v_prof_cas(:)        
-        real, allocatable::  vitw_prof_cas(:)
-        real, allocatable::  omega_prof_cas(:)
-        real, allocatable::  ug_prof_cas(:)
-        real, allocatable::  vg_prof_cas(:)
-        real, allocatable::  ht_prof_cas(:)
-        real, allocatable::  hth_prof_cas(:)
-        real, allocatable::  hq_prof_cas(:)
-        real, allocatable::  vt_prof_cas(:)
-        real, allocatable::  vth_prof_cas(:)
-        real, allocatable::  vq_prof_cas(:)
-        real, allocatable::  dt_prof_cas(:)
-        real, allocatable::  dth_prof_cas(:)
-        real, allocatable::  dtrad_prof_cas(:)
-        real, allocatable::  dq_prof_cas(:)
-        real, allocatable::  hu_prof_cas(:)
-        real, allocatable::  hv_prof_cas(:)
-        real, allocatable::  vu_prof_cas(:)
-        real, allocatable::  vv_prof_cas(:)
-        real, allocatable::  du_prof_cas(:)
-        real, allocatable::  dv_prof_cas(:)
-        real, allocatable::  uw_prof_cas(:)
-        real, allocatable::  vw_prof_cas(:)
-        real, allocatable::  q1_prof_cas(:)
-        real, allocatable::  q2_prof_cas(:)
-
-
-        real lat_prof_cas,sens_prof_cas,ts_prof_cas,ps_prof_cas,ustar_prof_cas,tke_prof_cas
-        real o3_cas,orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough,rugos_cas,sand_cas,clay_cas
-      
+  !Declarations specifiques au cas standard
+  character*80 :: fich_cas
+  ! Discr?tisation 
+  integer nlev_cas, nt_cas
+
+
+  !profils environnementaux
+  real, allocatable::  plev_cas(:,:),plevh_cas(:)
+  real, allocatable::  ap_cas(:),bp_cas(:)
+
+  real, allocatable::  z_cas(:,:),zh_cas(:)
+  real, allocatable::  t_cas(:,:),q_cas(:,:),qv_cas(:,:),ql_cas(:,:),qi_cas(:,:),rh_cas(:,:)
+  real, allocatable::  th_cas(:,:),thv_cas(:,:),thl_cas(:,:),rv_cas(:,:)
+  real, allocatable::  u_cas(:,:),v_cas(:,:),vitw_cas(:,:),omega_cas(:,:)
+
+  !forcing
+  real, allocatable::  ht_cas(:,:),vt_cas(:,:),dt_cas(:,:),dtrad_cas(:,:)
+  real, allocatable::  hth_cas(:,:),vth_cas(:,:),dth_cas(:,:)
+  real, allocatable::  hq_cas(:,:),vq_cas(:,:),dq_cas(:,:)
+  real, allocatable::  hr_cas(:,:),vr_cas(:,:),dr_cas(:,:)
+  real, allocatable::  hu_cas(:,:),vu_cas(:,:),du_cas(:,:)
+  real, allocatable::  hv_cas(:,:),vv_cas(:,:),dv_cas(:,:)
+  real, allocatable::  ug_cas(:,:),vg_cas(:,:)
+  real, allocatable::  lat_cas(:),sens_cas(:),ts_cas(:),ps_cas(:),ustar_cas(:)
+  real, allocatable::  uw_cas(:,:),vw_cas(:,:),q1_cas(:,:),q2_cas(:,:),tke_cas(:)
+
+  !champs interpoles
+  real, allocatable::  plev_prof_cas(:)
+  real, allocatable::  t_prof_cas(:)
+  real, allocatable::  theta_prof_cas(:)
+  real, allocatable::  thl_prof_cas(:)
+  real, allocatable::  thv_prof_cas(:)
+  real, allocatable::  q_prof_cas(:)
+  real, allocatable::  qv_prof_cas(:)
+  real, allocatable::  ql_prof_cas(:)
+  real, allocatable::  qi_prof_cas(:)
+  real, allocatable::  rh_prof_cas(:)
+  real, allocatable::  rv_prof_cas(:)
+  real, allocatable::  u_prof_cas(:)
+  real, allocatable::  v_prof_cas(:)        
+  real, allocatable::  vitw_prof_cas(:)
+  real, allocatable::  omega_prof_cas(:)
+  real, allocatable::  ug_prof_cas(:)
+  real, allocatable::  vg_prof_cas(:)
+  real, allocatable::  ht_prof_cas(:)
+  real, allocatable::  hth_prof_cas(:)
+  real, allocatable::  hq_prof_cas(:)
+  real, allocatable::  vt_prof_cas(:)
+  real, allocatable::  vth_prof_cas(:)
+  real, allocatable::  vq_prof_cas(:)
+  real, allocatable::  dt_prof_cas(:)
+  real, allocatable::  dth_prof_cas(:)
+  real, allocatable::  dtrad_prof_cas(:)
+  real, allocatable::  dq_prof_cas(:)
+  real, allocatable::  hu_prof_cas(:)
+  real, allocatable::  hv_prof_cas(:)
+  real, allocatable::  vu_prof_cas(:)
+  real, allocatable::  vv_prof_cas(:)
+  real, allocatable::  du_prof_cas(:)
+  real, allocatable::  dv_prof_cas(:)
+  real, allocatable::  uw_prof_cas(:)
+  real, allocatable::  vw_prof_cas(:)
+  real, allocatable::  q1_prof_cas(:)
+  real, allocatable::  q2_prof_cas(:)
+
+
+  real lat_prof_cas,sens_prof_cas,ts_prof_cas,ps_prof_cas,ustar_prof_cas,tke_prof_cas
+  real o3_cas,orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough,rugos_cas,sand_cas,clay_cas
+
 
 
 CONTAINS
 
-SUBROUTINE read_1D_cas
-      implicit none
+  SUBROUTINE read_1D_cas
+    implicit none
 
 #include "netcdf.inc"
 
-      INTEGER nid,rid,ierr
-      INTEGER ii,jj
-
-      fich_cas='setup/cas.nc'
-      print*,'fich_cas ',fich_cas
-      ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
-      print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
-      if (ierr.NE.NF_NOERR) then
-         write(*,*) 'ERROR: GROS Pb opening forcings nc file '
-         write(*,*) NF_STRERROR(ierr)
-         stop ""
-      endif
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lat',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension lat'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,ii)
-      print*,'OK1 nid,rid,lat',nid,rid,ii
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lon',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension lon'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,jj)
-      print*,'OK2 nid,rid,lat',nid,rid,jj
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lev',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension zz'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,nlev_cas)
-      print*,'OK3 nid,rid,nlev_cas',nid,rid,nlev_cas
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'time',rid)
-      print*,'nid,rid',nid,rid
-      nt_cas=0
-      IF (ierr.NE.NF_NOERR) THEN
-        stop 'probleme lecture dimension sens'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,nt_cas)
-      print*,'OK4 nid,rid,nt_cas',nid,rid,nt_cas
+    INTEGER nid,rid,ierr
+    INTEGER ii,jj
+
+    fich_cas='setup/cas.nc'
+    print*,'fich_cas ',fich_cas
+    ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
+    print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
+    if (ierr.NE.NF_NOERR) then
+       write(*,*) 'ERROR: GROS Pb opening forcings nc file '
+       write(*,*) NF_STRERROR(ierr)
+       stop ""
+    endif
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lat',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension lat'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,ii)
+    print*,'OK1 nid,rid,lat',nid,rid,ii
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lon',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension lon'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,jj)
+    print*,'OK2 nid,rid,lat',nid,rid,jj
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lev',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension zz'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,nlev_cas)
+    print*,'OK3 nid,rid,nlev_cas',nid,rid,nlev_cas
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'time',rid)
+    print*,'nid,rid',nid,rid
+    nt_cas=0
+    IF (ierr.NE.NF_NOERR) THEN
+       stop 'probleme lecture dimension sens'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,nt_cas)
+    print*,'OK4 nid,rid,nt_cas',nid,rid,nt_cas
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!profils moyens:
-        allocate(plev_cas(nlev_cas,nt_cas))        
-        allocate(z_cas(nlev_cas,nt_cas))
-        allocate(t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas),rh_cas(nlev_cas,nt_cas))
-        allocate(th_cas(nlev_cas,nt_cas),rv_cas(nlev_cas,nt_cas))
-        allocate(u_cas(nlev_cas,nt_cas))
-        allocate(v_cas(nlev_cas,nt_cas))
-
-!forcing
-        allocate(ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas),dt_cas(nlev_cas,nt_cas),dtrad_cas(nlev_cas,nt_cas))
-        allocate(hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas),dq_cas(nlev_cas,nt_cas))
-        allocate(hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas),dth_cas(nlev_cas,nt_cas))
-        allocate(hr_cas(nlev_cas,nt_cas),vr_cas(nlev_cas,nt_cas),dr_cas(nlev_cas,nt_cas))
-        allocate(hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas),du_cas(nlev_cas,nt_cas))
-        allocate(hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas),dv_cas(nlev_cas,nt_cas))
-        allocate(vitw_cas(nlev_cas,nt_cas))
-        allocate(ug_cas(nlev_cas,nt_cas))
-        allocate(vg_cas(nlev_cas,nt_cas))
-        allocate(lat_cas(nt_cas),sens_cas(nt_cas),ts_cas(nt_cas),ps_cas(nt_cas),ustar_cas(nt_cas))
-        allocate(uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas),q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas))
-
-
-!champs interpoles
-        allocate(plev_prof_cas(nlev_cas))
-        allocate(t_prof_cas(nlev_cas))
-        allocate(q_prof_cas(nlev_cas))
-        allocate(u_prof_cas(nlev_cas))
-        allocate(v_prof_cas(nlev_cas))
-
-        allocate(vitw_prof_cas(nlev_cas))
-        allocate(ug_prof_cas(nlev_cas))
-        allocate(vg_prof_cas(nlev_cas))
-        allocate(ht_prof_cas(nlev_cas))
-        allocate(hq_prof_cas(nlev_cas))
-        allocate(hu_prof_cas(nlev_cas))
-        allocate(hv_prof_cas(nlev_cas))
-        allocate(vt_prof_cas(nlev_cas))
-        allocate(vq_prof_cas(nlev_cas))
-        allocate(vu_prof_cas(nlev_cas))
-        allocate(vv_prof_cas(nlev_cas))
-        allocate(dt_prof_cas(nlev_cas))
-        allocate(dtrad_prof_cas(nlev_cas))
-        allocate(dq_prof_cas(nlev_cas))
-        allocate(du_prof_cas(nlev_cas))
-        allocate(dv_prof_cas(nlev_cas))
-        allocate(uw_prof_cas(nlev_cas))
-        allocate(vw_prof_cas(nlev_cas))
-        allocate(q1_prof_cas(nlev_cas))
-        allocate(q2_prof_cas(nlev_cas))
-
-        print*,'Allocations OK'
-        call read_cas2(nid,nlev_cas,nt_cas                                       &
-     &     ,z_cas,plev_cas,t_cas,q_cas,rh_cas,th_cas,rv_cas,u_cas,v_cas         &
-     &     ,ug_cas,vg_cas,vitw_cas,du_cas,hu_cas,vu_cas,dv_cas,hv_cas,vv_cas    &
-     &     ,dt_cas,dtrad_cas,ht_cas,vt_cas,dq_cas,hq_cas,vq_cas                 &
-     &     ,dth_cas,hth_cas,vth_cas,dr_cas,hr_cas,vr_cas,sens_cas,lat_cas,ts_cas&
-     &     ,ustar_cas,uw_cas,vw_cas,q1_cas,q2_cas)
-        print*,'Read cas OK'
-
-
-END SUBROUTINE read_1D_cas
-!**********************************************************************************************
-SUBROUTINE read2_1D_cas
-      implicit none
+    !profils moyens:
+    allocate(plev_cas(nlev_cas,nt_cas))        
+    allocate(z_cas(nlev_cas,nt_cas))
+    allocate(t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas),rh_cas(nlev_cas,nt_cas))
+    allocate(th_cas(nlev_cas,nt_cas),rv_cas(nlev_cas,nt_cas))
+    allocate(u_cas(nlev_cas,nt_cas))
+    allocate(v_cas(nlev_cas,nt_cas))
+
+    !forcing
+    allocate(ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas),dt_cas(nlev_cas,nt_cas),dtrad_cas(nlev_cas,nt_cas))
+    allocate(hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas),dq_cas(nlev_cas,nt_cas))
+    allocate(hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas),dth_cas(nlev_cas,nt_cas))
+    allocate(hr_cas(nlev_cas,nt_cas),vr_cas(nlev_cas,nt_cas),dr_cas(nlev_cas,nt_cas))
+    allocate(hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas),du_cas(nlev_cas,nt_cas))
+    allocate(hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas),dv_cas(nlev_cas,nt_cas))
+    allocate(vitw_cas(nlev_cas,nt_cas))
+    allocate(ug_cas(nlev_cas,nt_cas))
+    allocate(vg_cas(nlev_cas,nt_cas))
+    allocate(lat_cas(nt_cas),sens_cas(nt_cas),ts_cas(nt_cas),ps_cas(nt_cas),ustar_cas(nt_cas))
+    allocate(uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas),q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas))
+
+
+    !champs interpoles
+    allocate(plev_prof_cas(nlev_cas))
+    allocate(t_prof_cas(nlev_cas))
+    allocate(q_prof_cas(nlev_cas))
+    allocate(u_prof_cas(nlev_cas))
+    allocate(v_prof_cas(nlev_cas))
+
+    allocate(vitw_prof_cas(nlev_cas))
+    allocate(ug_prof_cas(nlev_cas))
+    allocate(vg_prof_cas(nlev_cas))
+    allocate(ht_prof_cas(nlev_cas))
+    allocate(hq_prof_cas(nlev_cas))
+    allocate(hu_prof_cas(nlev_cas))
+    allocate(hv_prof_cas(nlev_cas))
+    allocate(vt_prof_cas(nlev_cas))
+    allocate(vq_prof_cas(nlev_cas))
+    allocate(vu_prof_cas(nlev_cas))
+    allocate(vv_prof_cas(nlev_cas))
+    allocate(dt_prof_cas(nlev_cas))
+    allocate(dtrad_prof_cas(nlev_cas))
+    allocate(dq_prof_cas(nlev_cas))
+    allocate(du_prof_cas(nlev_cas))
+    allocate(dv_prof_cas(nlev_cas))
+    allocate(uw_prof_cas(nlev_cas))
+    allocate(vw_prof_cas(nlev_cas))
+    allocate(q1_prof_cas(nlev_cas))
+    allocate(q2_prof_cas(nlev_cas))
+
+    print*,'Allocations OK'
+    call read_cas2(nid,nlev_cas,nt_cas                                       &
+         ,z_cas,plev_cas,t_cas,q_cas,rh_cas,th_cas,rv_cas,u_cas,v_cas         &
+         ,ug_cas,vg_cas,vitw_cas,du_cas,hu_cas,vu_cas,dv_cas,hv_cas,vv_cas    &
+         ,dt_cas,dtrad_cas,ht_cas,vt_cas,dq_cas,hq_cas,vq_cas                 &
+         ,dth_cas,hth_cas,vth_cas,dr_cas,hr_cas,vr_cas,sens_cas,lat_cas,ts_cas&
+         ,ustar_cas,uw_cas,vw_cas,q1_cas,q2_cas)
+    print*,'Read cas OK'
+
+
+  END SUBROUTINE read_1D_cas
+  !**********************************************************************************************
+  SUBROUTINE read2_1D_cas
+    implicit none
 
 #include "netcdf.inc"
 
-      INTEGER nid,rid,ierr
-      INTEGER ii,jj
-
-      fich_cas='setup/cas.nc'
-      print*,'fich_cas ',fich_cas
-      ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
-      print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
-      if (ierr.NE.NF_NOERR) then
-         write(*,*) 'ERROR: GROS Pb opening forcings nc file '
-         write(*,*) NF_STRERROR(ierr)
-         stop ""
-      endif
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lat',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension lat'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,ii)
-      print*,'OK1 read2: nid,rid,lat',nid,rid,ii
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lon',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension lon'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,jj)
-      print*,'OK2 read2: nid,rid,lat',nid,rid,jj
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'nlev',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension nlev'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,nlev_cas)
-      print*,'OK3 read2: nid,rid,nlev_cas',nid,rid,nlev_cas
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'time',rid)
-      nt_cas=0
-      IF (ierr.NE.NF_NOERR) THEN
-        stop 'Oh probleme lecture dimension time'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,nt_cas)
-      print*,'OK4 read2: nid,rid,nt_cas',nid,rid,nt_cas
+    INTEGER nid,rid,ierr
+    INTEGER ii,jj
+
+    fich_cas='setup/cas.nc'
+    print*,'fich_cas ',fich_cas
+    ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
+    print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
+    if (ierr.NE.NF_NOERR) then
+       write(*,*) 'ERROR: GROS Pb opening forcings nc file '
+       write(*,*) NF_STRERROR(ierr)
+       stop ""
+    endif
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lat',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension lat'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,ii)
+    print*,'OK1 read2: nid,rid,lat',nid,rid,ii
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lon',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension lon'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,jj)
+    print*,'OK2 read2: nid,rid,lat',nid,rid,jj
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'nlev',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension nlev'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,nlev_cas)
+    print*,'OK3 read2: nid,rid,nlev_cas',nid,rid,nlev_cas
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'time',rid)
+    nt_cas=0
+    IF (ierr.NE.NF_NOERR) THEN
+       stop 'Oh probleme lecture dimension time'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,nt_cas)
+    print*,'OK4 read2: nid,rid,nt_cas',nid,rid,nt_cas
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!profils moyens:
-        allocate(plev_cas(nlev_cas,nt_cas),plevh_cas(nlev_cas+1))        
-        allocate(z_cas(nlev_cas,nt_cas),zh_cas(nlev_cas+1))
-        allocate(ap_cas(nlev_cas+1),bp_cas(nt_cas+1))
-        allocate(t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas),qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas), &
-             qi_cas(nlev_cas,nt_cas),rh_cas(nlev_cas,nt_cas))
-        allocate(th_cas(nlev_cas,nt_cas),thl_cas(nlev_cas,nt_cas),thv_cas(nlev_cas,nt_cas),rv_cas(nlev_cas,nt_cas))
-        allocate(u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas),vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas))
-
-!forcing
-        allocate(ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas),dt_cas(nlev_cas,nt_cas),dtrad_cas(nlev_cas,nt_cas))
-        allocate(hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas),dq_cas(nlev_cas,nt_cas))
-        allocate(hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas),dth_cas(nlev_cas,nt_cas))
-        allocate(hr_cas(nlev_cas,nt_cas),vr_cas(nlev_cas,nt_cas),dr_cas(nlev_cas,nt_cas))
-        allocate(hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas),du_cas(nlev_cas,nt_cas))
-        allocate(hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas),dv_cas(nlev_cas,nt_cas))
-        allocate(ug_cas(nlev_cas,nt_cas))
-        allocate(vg_cas(nlev_cas,nt_cas))
-        allocate(lat_cas(nt_cas),sens_cas(nt_cas),ts_cas(nt_cas),ps_cas(nt_cas),ustar_cas(nt_cas),tke_cas(nt_cas))
-        allocate(uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas),q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas))
-
-
-
-!champs interpoles
-        allocate(plev_prof_cas(nlev_cas))
-        allocate(t_prof_cas(nlev_cas))
-        allocate(theta_prof_cas(nlev_cas))
-        allocate(thl_prof_cas(nlev_cas))
-        allocate(thv_prof_cas(nlev_cas))
-        allocate(q_prof_cas(nlev_cas))
-        allocate(qv_prof_cas(nlev_cas))
-        allocate(ql_prof_cas(nlev_cas))
-        allocate(qi_prof_cas(nlev_cas))
-        allocate(rh_prof_cas(nlev_cas))
-        allocate(rv_prof_cas(nlev_cas))
-        allocate(u_prof_cas(nlev_cas))
-        allocate(v_prof_cas(nlev_cas))
-        allocate(vitw_prof_cas(nlev_cas))
-        allocate(omega_prof_cas(nlev_cas))
-        allocate(ug_prof_cas(nlev_cas))
-        allocate(vg_prof_cas(nlev_cas))
-        allocate(ht_prof_cas(nlev_cas))
-        allocate(hth_prof_cas(nlev_cas))
-        allocate(hq_prof_cas(nlev_cas))
-        allocate(hu_prof_cas(nlev_cas))
-        allocate(hv_prof_cas(nlev_cas))
-        allocate(vt_prof_cas(nlev_cas))
-        allocate(vth_prof_cas(nlev_cas))
-        allocate(vq_prof_cas(nlev_cas))
-        allocate(vu_prof_cas(nlev_cas))
-        allocate(vv_prof_cas(nlev_cas))
-        allocate(dt_prof_cas(nlev_cas))
-        allocate(dth_prof_cas(nlev_cas))
-        allocate(dtrad_prof_cas(nlev_cas))
-        allocate(dq_prof_cas(nlev_cas))
-        allocate(du_prof_cas(nlev_cas))
-        allocate(dv_prof_cas(nlev_cas))
-        allocate(uw_prof_cas(nlev_cas))
-        allocate(vw_prof_cas(nlev_cas))
-        allocate(q1_prof_cas(nlev_cas))
-        allocate(q2_prof_cas(nlev_cas))
-
-        print*,'Allocations OK'
-        call read2_cas (nid,nlev_cas,nt_cas,                                                                     &
-     &     ap_cas,bp_cas,z_cas,plev_cas,zh_cas,plevh_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,                    &
-     &     ql_cas,qi_cas,rh_cas,rv_cas,u_cas,v_cas,vitw_cas,omega_cas,ug_cas,vg_cas,du_cas,hu_cas,vu_cas,        &
-     &     dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas,               &
-     &     dr_cas,hr_cas,vr_cas,dtrad_cas,sens_cas,lat_cas,ts_cas,ps_cas,ustar_cas,tke_cas,                      &
-     &     uw_cas,vw_cas,q1_cas,q2_cas,orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough, &
-     &     o3_cas,rugos_cas,clay_cas,sand_cas)
-        print*,'Read2 cas OK'
-        do ii=1,nlev_cas
-        print*,'apres read2_cas, plev_cas=',ii,plev_cas(ii,1)
-        enddo
-
-
-END SUBROUTINE read2_1D_cas
-
-!**********************************************************************************************
-SUBROUTINE old_read_SCM_cas
-      implicit none
+    !profils moyens:
+    allocate(plev_cas(nlev_cas,nt_cas),plevh_cas(nlev_cas+1))        
+    allocate(z_cas(nlev_cas,nt_cas),zh_cas(nlev_cas+1))
+    allocate(ap_cas(nlev_cas+1),bp_cas(nt_cas+1))
+    allocate(t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas),qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas), &
+         qi_cas(nlev_cas,nt_cas),rh_cas(nlev_cas,nt_cas))
+    allocate(th_cas(nlev_cas,nt_cas),thl_cas(nlev_cas,nt_cas),thv_cas(nlev_cas,nt_cas),rv_cas(nlev_cas,nt_cas))
+    allocate(u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas),vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas))
+
+    !forcing
+    allocate(ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas),dt_cas(nlev_cas,nt_cas),dtrad_cas(nlev_cas,nt_cas))
+    allocate(hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas),dq_cas(nlev_cas,nt_cas))
+    allocate(hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas),dth_cas(nlev_cas,nt_cas))
+    allocate(hr_cas(nlev_cas,nt_cas),vr_cas(nlev_cas,nt_cas),dr_cas(nlev_cas,nt_cas))
+    allocate(hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas),du_cas(nlev_cas,nt_cas))
+    allocate(hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas),dv_cas(nlev_cas,nt_cas))
+    allocate(ug_cas(nlev_cas,nt_cas))
+    allocate(vg_cas(nlev_cas,nt_cas))
+    allocate(lat_cas(nt_cas),sens_cas(nt_cas),ts_cas(nt_cas),ps_cas(nt_cas),ustar_cas(nt_cas),tke_cas(nt_cas))
+    allocate(uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas),q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas))
+
+
+
+    !champs interpoles
+    allocate(plev_prof_cas(nlev_cas))
+    allocate(t_prof_cas(nlev_cas))
+    allocate(theta_prof_cas(nlev_cas))
+    allocate(thl_prof_cas(nlev_cas))
+    allocate(thv_prof_cas(nlev_cas))
+    allocate(q_prof_cas(nlev_cas))
+    allocate(qv_prof_cas(nlev_cas))
+    allocate(ql_prof_cas(nlev_cas))
+    allocate(qi_prof_cas(nlev_cas))
+    allocate(rh_prof_cas(nlev_cas))
+    allocate(rv_prof_cas(nlev_cas))
+    allocate(u_prof_cas(nlev_cas))
+    allocate(v_prof_cas(nlev_cas))
+    allocate(vitw_prof_cas(nlev_cas))
+    allocate(omega_prof_cas(nlev_cas))
+    allocate(ug_prof_cas(nlev_cas))
+    allocate(vg_prof_cas(nlev_cas))
+    allocate(ht_prof_cas(nlev_cas))
+    allocate(hth_prof_cas(nlev_cas))
+    allocate(hq_prof_cas(nlev_cas))
+    allocate(hu_prof_cas(nlev_cas))
+    allocate(hv_prof_cas(nlev_cas))
+    allocate(vt_prof_cas(nlev_cas))
+    allocate(vth_prof_cas(nlev_cas))
+    allocate(vq_prof_cas(nlev_cas))
+    allocate(vu_prof_cas(nlev_cas))
+    allocate(vv_prof_cas(nlev_cas))
+    allocate(dt_prof_cas(nlev_cas))
+    allocate(dth_prof_cas(nlev_cas))
+    allocate(dtrad_prof_cas(nlev_cas))
+    allocate(dq_prof_cas(nlev_cas))
+    allocate(du_prof_cas(nlev_cas))
+    allocate(dv_prof_cas(nlev_cas))
+    allocate(uw_prof_cas(nlev_cas))
+    allocate(vw_prof_cas(nlev_cas))
+    allocate(q1_prof_cas(nlev_cas))
+    allocate(q2_prof_cas(nlev_cas))
+
+    print*,'Allocations OK'
+    call read2_cas (nid,nlev_cas,nt_cas,                                                                     &
+         ap_cas,bp_cas,z_cas,plev_cas,zh_cas,plevh_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,                    &
+         ql_cas,qi_cas,rh_cas,rv_cas,u_cas,v_cas,vitw_cas,omega_cas,ug_cas,vg_cas,du_cas,hu_cas,vu_cas,        &
+         dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas,               &
+         dr_cas,hr_cas,vr_cas,dtrad_cas,sens_cas,lat_cas,ts_cas,ps_cas,ustar_cas,tke_cas,                      &
+         uw_cas,vw_cas,q1_cas,q2_cas,orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough, &
+         o3_cas,rugos_cas,clay_cas,sand_cas)
+    print*,'Read2 cas OK'
+    do ii=1,nlev_cas
+       print*,'apres read2_cas, plev_cas=',ii,plev_cas(ii,1)
+    enddo
+
+
+  END SUBROUTINE read2_1D_cas
+
+  !**********************************************************************************************
+  SUBROUTINE old_read_SCM_cas
+    use netcdf, only: nf90_get_var
+    implicit none
 
 #include "netcdf.inc"
 #include "date_cas.h"
 
-      INTEGER nid,rid,ierr
-      INTEGER ii,jj,timeid
-      REAL, ALLOCATABLE :: time_val(:)
-
-      fich_cas='cas.nc'
-      print*,'fich_cas ',fich_cas
-      ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
-      print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
-      if (ierr.NE.NF_NOERR) then
-         write(*,*) 'ERROR: GROS Pb opening forcings nc file '
-         write(*,*) NF_STRERROR(ierr)
-         stop ""
-      endif
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lat',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension lat'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,ii)
-      print*,'OK1 read2: nid,rid,lat',nid,rid,ii
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lon',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension lon'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,jj)
-      print*,'OK2 read2: nid,rid,lat',nid,rid,jj
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lev',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension nlev'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,nlev_cas)
-      print*,'OK3 read2: nid,rid,nlev_cas',nid,rid,nlev_cas
-      IF ( .NOT. ( nlev_cas > 10 .AND. nlev_cas < 1000 )) THEN
-              print*,'Valeur de nlev_cas peu probable'
-              STOP
-      ENDIF
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'time',rid)
-      nt_cas=0
-      IF (ierr.NE.NF_NOERR) THEN
-        stop 'Oh probleme lecture dimension time'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,nt_cas)
-      print*,'OK4 read2: nid,rid,nt_cas',nid,rid,nt_cas
-! Lecture de l'axe des temps
-      print*,'LECTURE DU TEMPS'
-      ierr=NF_INQ_VARID(nid,'time',timeid)
-         if(ierr/=NF_NOERR) then
-           print *,'Variable time manquante dans cas.nc:'
-           ierr=NF_NOERR
-         else
-                 allocate(time_val(nt_cas))
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,timeid,time_val)
-#else
-           ierr = NF_GET_VAR_REAL(nid,timeid,time_val)
-#endif
-           if(ierr/=NF_NOERR) then
-              print *,'Pb a la lecture de time cas.nc: '
-           endif
-   endif
-   IF (nt_cas>1) THEN
-           pdt_cas=time_val(2)-time_val(1)
-   ELSE
-           pdt_cas=0.
-   ENDIF
+    INTEGER nid,rid,ierr
+    INTEGER ii,jj,timeid
+    REAL, ALLOCATABLE :: time_val(:)
+
+    fich_cas='cas.nc'
+    print*,'fich_cas ',fich_cas
+    ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
+    print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
+    if (ierr.NE.NF_NOERR) then
+       write(*,*) 'ERROR: GROS Pb opening forcings nc file '
+       write(*,*) NF_STRERROR(ierr)
+       stop ""
+    endif
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lat',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension lat'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,ii)
+    print*,'OK1 read2: nid,rid,lat',nid,rid,ii
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lon',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension lon'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,jj)
+    print*,'OK2 read2: nid,rid,lat',nid,rid,jj
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lev',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension nlev'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,nlev_cas)
+    print*,'OK3 read2: nid,rid,nlev_cas',nid,rid,nlev_cas
+    IF ( .NOT. ( nlev_cas > 10 .AND. nlev_cas < 1000 )) THEN
+       print*,'Valeur de nlev_cas peu probable'
+       STOP
+    ENDIF
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'time',rid)
+    nt_cas=0
+    IF (ierr.NE.NF_NOERR) THEN
+       stop 'Oh probleme lecture dimension time'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,nt_cas)
+    print*,'OK4 read2: nid,rid,nt_cas',nid,rid,nt_cas
+    ! Lecture de l'axe des temps
+    print*,'LECTURE DU TEMPS'
+    ierr=NF_INQ_VARID(nid,'time',timeid)
+    if(ierr/=NF_NOERR) then
+       print *,'Variable time manquante dans cas.nc:'
+       ierr=NF_NOERR
+    else
+       allocate(time_val(nt_cas))
+       ierr = NF90_GET_VAR(nid,timeid,time_val)
+       if(ierr/=NF_NOERR) then
+          print *,'Pb a la lecture de time cas.nc: '
+       endif
+    endif
+    IF (nt_cas>1) THEN
+       pdt_cas=time_val(2)-time_val(1)
+    ELSE
+       pdt_cas=0.
+    ENDIF
 
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!profils moyens:
-        allocate(plev_cas(nlev_cas,nt_cas),plevh_cas(nlev_cas+1))        
-        allocate(z_cas(nlev_cas,nt_cas),zh_cas(nlev_cas+1))
-        allocate(ap_cas(nlev_cas+1),bp_cas(nt_cas+1))
-        allocate(t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas),qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas), &
-             qi_cas(nlev_cas,nt_cas),rh_cas(nlev_cas,nt_cas))
-        allocate(th_cas(nlev_cas,nt_cas),thl_cas(nlev_cas,nt_cas),thv_cas(nlev_cas,nt_cas),rv_cas(nlev_cas,nt_cas))
-        allocate(u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas),vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas))
-
-!forcing
-        allocate(ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas),dt_cas(nlev_cas,nt_cas),dtrad_cas(nlev_cas,nt_cas))
-        allocate(hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas),dq_cas(nlev_cas,nt_cas))
-        allocate(hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas),dth_cas(nlev_cas,nt_cas))
-        allocate(hr_cas(nlev_cas,nt_cas),vr_cas(nlev_cas,nt_cas),dr_cas(nlev_cas,nt_cas))
-        allocate(hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas),du_cas(nlev_cas,nt_cas))
-        allocate(hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas),dv_cas(nlev_cas,nt_cas))
-        allocate(ug_cas(nlev_cas,nt_cas))
-        allocate(vg_cas(nlev_cas,nt_cas))
-        allocate(lat_cas(nt_cas),sens_cas(nt_cas),ts_cas(nt_cas),ps_cas(nt_cas),ustar_cas(nt_cas),tke_cas(nt_cas))
-        allocate(uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas),q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas))
-
-
-
-!champs interpoles
-        allocate(plev_prof_cas(nlev_cas))
-        allocate(t_prof_cas(nlev_cas))
-        allocate(theta_prof_cas(nlev_cas))
-        allocate(thl_prof_cas(nlev_cas))
-        allocate(thv_prof_cas(nlev_cas))
-        allocate(q_prof_cas(nlev_cas))
-        allocate(qv_prof_cas(nlev_cas))
-        allocate(ql_prof_cas(nlev_cas))
-        allocate(qi_prof_cas(nlev_cas))
-        allocate(rh_prof_cas(nlev_cas))
-        allocate(rv_prof_cas(nlev_cas))
-        allocate(u_prof_cas(nlev_cas))
-        allocate(v_prof_cas(nlev_cas))
-        allocate(vitw_prof_cas(nlev_cas))
-        allocate(omega_prof_cas(nlev_cas))
-        allocate(ug_prof_cas(nlev_cas))
-        allocate(vg_prof_cas(nlev_cas))
-        allocate(ht_prof_cas(nlev_cas))
-        allocate(hth_prof_cas(nlev_cas))
-        allocate(hq_prof_cas(nlev_cas))
-        allocate(hu_prof_cas(nlev_cas))
-        allocate(hv_prof_cas(nlev_cas))
-        allocate(vt_prof_cas(nlev_cas))
-        allocate(vth_prof_cas(nlev_cas))
-        allocate(vq_prof_cas(nlev_cas))
-        allocate(vu_prof_cas(nlev_cas))
-        allocate(vv_prof_cas(nlev_cas))
-        allocate(dt_prof_cas(nlev_cas))
-        allocate(dth_prof_cas(nlev_cas))
-        allocate(dtrad_prof_cas(nlev_cas))
-        allocate(dq_prof_cas(nlev_cas))
-        allocate(du_prof_cas(nlev_cas))
-        allocate(dv_prof_cas(nlev_cas))
-        allocate(uw_prof_cas(nlev_cas))
-        allocate(vw_prof_cas(nlev_cas))
-        allocate(q1_prof_cas(nlev_cas))
-        allocate(q2_prof_cas(nlev_cas))
-
-        print*,'Allocations OK'
-        call old_read_SCM (nid,nlev_cas,nt_cas,                                                                     &
-     &     ap_cas,bp_cas,z_cas,plev_cas,zh_cas,plevh_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,                    &
-     &     ql_cas,qi_cas,rh_cas,rv_cas,u_cas,v_cas,vitw_cas,omega_cas,ug_cas,vg_cas,du_cas,hu_cas,vu_cas,        &
-     &     dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas,               &
-     &     dr_cas,hr_cas,vr_cas,dtrad_cas,sens_cas,lat_cas,ts_cas,ps_cas,ustar_cas,tke_cas,                      &
-     &     uw_cas,vw_cas,q1_cas,q2_cas,orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough, &
-     &     o3_cas,rugos_cas,clay_cas,sand_cas)
-        print*,'Read2 cas OK'
-        do ii=1,nlev_cas
-        print*,'apres read2_cas, plev_cas=',ii,plev_cas(ii,1)
-        enddo
-
-
-END SUBROUTINE old_read_SCM_cas
+    !profils moyens:
+    allocate(plev_cas(nlev_cas,nt_cas),plevh_cas(nlev_cas+1))        
+    allocate(z_cas(nlev_cas,nt_cas),zh_cas(nlev_cas+1))
+    allocate(ap_cas(nlev_cas+1),bp_cas(nt_cas+1))
+    allocate(t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas),qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas), &
+         qi_cas(nlev_cas,nt_cas),rh_cas(nlev_cas,nt_cas))
+    allocate(th_cas(nlev_cas,nt_cas),thl_cas(nlev_cas,nt_cas),thv_cas(nlev_cas,nt_cas),rv_cas(nlev_cas,nt_cas))
+    allocate(u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas),vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas))
+
+    !forcing
+    allocate(ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas),dt_cas(nlev_cas,nt_cas),dtrad_cas(nlev_cas,nt_cas))
+    allocate(hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas),dq_cas(nlev_cas,nt_cas))
+    allocate(hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas),dth_cas(nlev_cas,nt_cas))
+    allocate(hr_cas(nlev_cas,nt_cas),vr_cas(nlev_cas,nt_cas),dr_cas(nlev_cas,nt_cas))
+    allocate(hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas),du_cas(nlev_cas,nt_cas))
+    allocate(hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas),dv_cas(nlev_cas,nt_cas))
+    allocate(ug_cas(nlev_cas,nt_cas))
+    allocate(vg_cas(nlev_cas,nt_cas))
+    allocate(lat_cas(nt_cas),sens_cas(nt_cas),ts_cas(nt_cas),ps_cas(nt_cas),ustar_cas(nt_cas),tke_cas(nt_cas))
+    allocate(uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas),q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas))
+
+
+
+    !champs interpoles
+    allocate(plev_prof_cas(nlev_cas))
+    allocate(t_prof_cas(nlev_cas))
+    allocate(theta_prof_cas(nlev_cas))
+    allocate(thl_prof_cas(nlev_cas))
+    allocate(thv_prof_cas(nlev_cas))
+    allocate(q_prof_cas(nlev_cas))
+    allocate(qv_prof_cas(nlev_cas))
+    allocate(ql_prof_cas(nlev_cas))
+    allocate(qi_prof_cas(nlev_cas))
+    allocate(rh_prof_cas(nlev_cas))
+    allocate(rv_prof_cas(nlev_cas))
+    allocate(u_prof_cas(nlev_cas))
+    allocate(v_prof_cas(nlev_cas))
+    allocate(vitw_prof_cas(nlev_cas))
+    allocate(omega_prof_cas(nlev_cas))
+    allocate(ug_prof_cas(nlev_cas))
+    allocate(vg_prof_cas(nlev_cas))
+    allocate(ht_prof_cas(nlev_cas))
+    allocate(hth_prof_cas(nlev_cas))
+    allocate(hq_prof_cas(nlev_cas))
+    allocate(hu_prof_cas(nlev_cas))
+    allocate(hv_prof_cas(nlev_cas))
+    allocate(vt_prof_cas(nlev_cas))
+    allocate(vth_prof_cas(nlev_cas))
+    allocate(vq_prof_cas(nlev_cas))
+    allocate(vu_prof_cas(nlev_cas))
+    allocate(vv_prof_cas(nlev_cas))
+    allocate(dt_prof_cas(nlev_cas))
+    allocate(dth_prof_cas(nlev_cas))
+    allocate(dtrad_prof_cas(nlev_cas))
+    allocate(dq_prof_cas(nlev_cas))
+    allocate(du_prof_cas(nlev_cas))
+    allocate(dv_prof_cas(nlev_cas))
+    allocate(uw_prof_cas(nlev_cas))
+    allocate(vw_prof_cas(nlev_cas))
+    allocate(q1_prof_cas(nlev_cas))
+    allocate(q2_prof_cas(nlev_cas))
+
+    print*,'Allocations OK'
+    call old_read_SCM (nid,nlev_cas,nt_cas,                                                                     &
+         ap_cas,bp_cas,z_cas,plev_cas,zh_cas,plevh_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,                    &
+         ql_cas,qi_cas,rh_cas,rv_cas,u_cas,v_cas,vitw_cas,omega_cas,ug_cas,vg_cas,du_cas,hu_cas,vu_cas,        &
+         dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas,               &
+         dr_cas,hr_cas,vr_cas,dtrad_cas,sens_cas,lat_cas,ts_cas,ps_cas,ustar_cas,tke_cas,                      &
+         uw_cas,vw_cas,q1_cas,q2_cas,orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough, &
+         o3_cas,rugos_cas,clay_cas,sand_cas)
+    print*,'Read2 cas OK'
+    do ii=1,nlev_cas
+       print*,'apres read2_cas, plev_cas=',ii,plev_cas(ii,1)
+    enddo
+
+
+  END SUBROUTINE old_read_SCM_cas
 
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-SUBROUTINE deallocate2_1D_cases
-!profils environnementaux:
-        deallocate(plev_cas,plevh_cas)
-        
-        deallocate(z_cas,zh_cas)
-        deallocate(ap_cas,bp_cas)
-        deallocate(t_cas,q_cas,qv_cas,ql_cas,qi_cas,rh_cas)
-        deallocate(th_cas,thl_cas,thv_cas,rv_cas)
-        deallocate(u_cas,v_cas,vitw_cas,omega_cas)
-        
-!forcing
-        deallocate(ht_cas,vt_cas,dt_cas,dtrad_cas)
-        deallocate(hq_cas,vq_cas,dq_cas)
-        deallocate(hth_cas,vth_cas,dth_cas)
-        deallocate(hr_cas,vr_cas,dr_cas)
-        deallocate(hu_cas,vu_cas,du_cas)
-        deallocate(hv_cas,vv_cas,dv_cas)
-        deallocate(ug_cas)
-        deallocate(vg_cas)
-        deallocate(lat_cas,sens_cas,ts_cas,ps_cas,ustar_cas,tke_cas,uw_cas,vw_cas,q1_cas,q2_cas)
-
-!champs interpoles
-        deallocate(plev_prof_cas)
-        deallocate(t_prof_cas)
-        deallocate(theta_prof_cas)
-        deallocate(thl_prof_cas)
-        deallocate(thv_prof_cas)
-        deallocate(q_prof_cas)
-        deallocate(qv_prof_cas)
-        deallocate(ql_prof_cas)
-        deallocate(qi_prof_cas)
-        deallocate(rh_prof_cas)
-        deallocate(rv_prof_cas)
-        deallocate(u_prof_cas)
-        deallocate(v_prof_cas)
-        deallocate(vitw_prof_cas)
-        deallocate(omega_prof_cas)
-        deallocate(ug_prof_cas)
-        deallocate(vg_prof_cas)
-        deallocate(ht_prof_cas)
-        deallocate(hq_prof_cas)
-        deallocate(hu_prof_cas)
-        deallocate(hv_prof_cas)
-        deallocate(vt_prof_cas)
-        deallocate(vq_prof_cas)
-        deallocate(vu_prof_cas)
-        deallocate(vv_prof_cas)
-        deallocate(dt_prof_cas)
-        deallocate(dtrad_prof_cas)
-        deallocate(dq_prof_cas)
-        deallocate(du_prof_cas)
-        deallocate(dv_prof_cas)
-        deallocate(t_prof_cas)
-        deallocate(u_prof_cas)
-        deallocate(v_prof_cas)
-        deallocate(uw_prof_cas)
-        deallocate(vw_prof_cas)
-        deallocate(q1_prof_cas)
-        deallocate(q2_prof_cas)
-
-END SUBROUTINE deallocate2_1D_cases
+  SUBROUTINE deallocate2_1D_cases
+    !profils environnementaux:
+    deallocate(plev_cas,plevh_cas)
+
+    deallocate(z_cas,zh_cas)
+    deallocate(ap_cas,bp_cas)
+    deallocate(t_cas,q_cas,qv_cas,ql_cas,qi_cas,rh_cas)
+    deallocate(th_cas,thl_cas,thv_cas,rv_cas)
+    deallocate(u_cas,v_cas,vitw_cas,omega_cas)
+
+    !forcing
+    deallocate(ht_cas,vt_cas,dt_cas,dtrad_cas)
+    deallocate(hq_cas,vq_cas,dq_cas)
+    deallocate(hth_cas,vth_cas,dth_cas)
+    deallocate(hr_cas,vr_cas,dr_cas)
+    deallocate(hu_cas,vu_cas,du_cas)
+    deallocate(hv_cas,vv_cas,dv_cas)
+    deallocate(ug_cas)
+    deallocate(vg_cas)
+    deallocate(lat_cas,sens_cas,ts_cas,ps_cas,ustar_cas,tke_cas,uw_cas,vw_cas,q1_cas,q2_cas)
+
+    !champs interpoles
+    deallocate(plev_prof_cas)
+    deallocate(t_prof_cas)
+    deallocate(theta_prof_cas)
+    deallocate(thl_prof_cas)
+    deallocate(thv_prof_cas)
+    deallocate(q_prof_cas)
+    deallocate(qv_prof_cas)
+    deallocate(ql_prof_cas)
+    deallocate(qi_prof_cas)
+    deallocate(rh_prof_cas)
+    deallocate(rv_prof_cas)
+    deallocate(u_prof_cas)
+    deallocate(v_prof_cas)
+    deallocate(vitw_prof_cas)
+    deallocate(omega_prof_cas)
+    deallocate(ug_prof_cas)
+    deallocate(vg_prof_cas)
+    deallocate(ht_prof_cas)
+    deallocate(hq_prof_cas)
+    deallocate(hu_prof_cas)
+    deallocate(hv_prof_cas)
+    deallocate(vt_prof_cas)
+    deallocate(vq_prof_cas)
+    deallocate(vu_prof_cas)
+    deallocate(vv_prof_cas)
+    deallocate(dt_prof_cas)
+    deallocate(dtrad_prof_cas)
+    deallocate(dq_prof_cas)
+    deallocate(du_prof_cas)
+    deallocate(dv_prof_cas)
+    deallocate(t_prof_cas)
+    deallocate(u_prof_cas)
+    deallocate(v_prof_cas)
+    deallocate(uw_prof_cas)
+    deallocate(vw_prof_cas)
+    deallocate(q1_prof_cas)
+    deallocate(q2_prof_cas)
+
+  END SUBROUTINE deallocate2_1D_cases
 
 
 END MODULE mod_1D_cases_read2
 !=====================================================================
-      subroutine read_cas2(nid,nlevel,ntime                          &
-     &     ,zz,pp,temp,qv,rh,theta,rv,u,v,ug,vg,w,                   &
-     &     du,hu,vu,dv,hv,vv,dt,dtrad,ht,vt,dq,hq,vq,                     &
-     &     dth,hth,vth,dr,hr,vr,sens,flat,ts,ustar,uw,vw,q1,q2)
-
-!program reading forcing of the case study
-      implicit none
+subroutine read_cas2(nid,nlevel,ntime                          &
+     ,zz,pp,temp,qv,rh,theta,rv,u,v,ug,vg,w,                   &
+     du,hu,vu,dv,hv,vv,dt,dtrad,ht,vt,dq,hq,vq,                     &
+     dth,hth,vth,dr,hr,vr,sens,flat,ts,ustar,uw,vw,q1,q2)
+
+  !program reading forcing of the case study
+  use netcdf, only: nf90_get_var
+  implicit none
 #include "netcdf.inc"
 
-      integer ntime,nlevel
-
-      real zz(nlevel,ntime)
-      real pp(nlevel,ntime)
-      real temp(nlevel,ntime),qv(nlevel,ntime),rh(nlevel,ntime)
-      real theta(nlevel,ntime),rv(nlevel,ntime)
-      real u(nlevel,ntime)
-      real v(nlevel,ntime)
-      real ug(nlevel,ntime)
-      real vg(nlevel,ntime)
-      real w(nlevel,ntime)
-      real du(nlevel,ntime),hu(nlevel,ntime),vu(nlevel,ntime)
-      real dv(nlevel,ntime),hv(nlevel,ntime),vv(nlevel,ntime)
-      real dt(nlevel,ntime),ht(nlevel,ntime),vt(nlevel,ntime)
-      real dtrad(nlevel,ntime)
-      real dq(nlevel,ntime),hq(nlevel,ntime),vq(nlevel,ntime)
-      real dth(nlevel,ntime),hth(nlevel,ntime),vth(nlevel,ntime)
-      real dr(nlevel,ntime),hr(nlevel,ntime),vr(nlevel,ntime)
-      real flat(ntime),sens(ntime),ts(ntime),ustar(ntime)
-      real uw(nlevel,ntime),vw(nlevel,ntime),q1(nlevel,ntime),q2(nlevel,ntime),resul(nlevel,ntime),resul1(ntime)
-
-
-      integer nid, ierr, ierr1,ierr2,rid,i
-      integer nbvar3d
-      parameter(nbvar3d=39)
-      integer var3didin(nbvar3d)
-      character*5 name_var(1:nbvar3d)
-      data name_var/'zz','pp','temp','qv','rh','theta','rv','u','v','ug','vg','w','advu','hu','vu',&
-     &'advv','hv','vv','advT','hT','vT','advq','hq','vq','advth','hth','vth','advr','hr','vr',&
-     &'radT','uw','vw','q1','q2','sens','flat','ts','ustar'/
-
-       do i=1,nbvar3d
-         print *,'Dans read_cas2, on va lire ',nid,i,name_var(i)
-       enddo
-       do i=1,nbvar3d
-         ierr=NF_INQ_VARID(nid,name_var(i),var3didin(i)) 
-         print *,'ierr=',i,ierr,name_var(i),var3didin(i)
-         if(ierr/=NF_NOERR) then
-           print *,'Variable manquante dans cas.nc:',name_var(i)
-         endif
-       enddo
-       do i=1,nbvar3d
-         print *,'Dans read_cas2, on va lire ',var3didin(i),name_var(i)
-         if(i.LE.35) then
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul)
-#endif
-         print *,'Dans read_cas2, on a lu ',ierr,var3didin(i),name_var(i)
-         if(ierr/=NF_NOERR) then
-            print *,'Pb a la lecture de cas.nc: ',name_var(i)
-            stop "getvarup"
-         endif
-         else
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul1)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul1)
-#endif
-         print *,'Dans read_cas2, on a lu ',ierr,var3didin(i),name_var(i)
-         if(ierr/=NF_NOERR) then
-            print *,'Pb a la lecture de cas.nc: ',name_var(i)
-            stop "getvarup"
-         endif
-         endif
-         select case(i)
-           case(1) ; zz=resul
-           case(2) ; pp=resul
-           case(3) ; temp=resul
-           case(4) ; qv=resul
-           case(5) ; rh=resul
-           case(6) ; theta=resul
-           case(7) ; rv=resul
-           case(8) ; u=resul
-           case(9) ; v=resul
-           case(10) ; ug=resul
-           case(11) ; vg=resul
-           case(12) ; w=resul
-           case(13) ; du=resul
-           case(14) ; hu=resul
-           case(15) ; vu=resul
-           case(16) ; dv=resul
-           case(17) ; hv=resul
-           case(18) ; vv=resul
-           case(19) ; dt=resul
-           case(20) ; ht=resul
-           case(21) ; vt=resul
-           case(22) ; dq=resul
-           case(23) ; hq=resul
-           case(24) ; vq=resul
-           case(25) ; dth=resul
-           case(26) ; hth=resul
-           case(27) ; vth=resul
-           case(28) ; dr=resul
-           case(29) ; hr=resul
-           case(30) ; vr=resul
-           case(31) ; dtrad=resul
-           case(32) ; uw=resul
-           case(33) ; vw=resul
-           case(34) ; q1=resul
-           case(35) ; q2=resul
-           case(36) ; sens=resul1
-           case(37) ; flat=resul1
-           case(38) ; ts=resul1
-           case(39) ; ustar=resul1
-         end select
-       enddo
-
-         return 
-         end subroutine read_cas2
+  integer ntime,nlevel
+
+  real zz(nlevel,ntime)
+  real pp(nlevel,ntime)
+  real temp(nlevel,ntime),qv(nlevel,ntime),rh(nlevel,ntime)
+  real theta(nlevel,ntime),rv(nlevel,ntime)
+  real u(nlevel,ntime)
+  real v(nlevel,ntime)
+  real ug(nlevel,ntime)
+  real vg(nlevel,ntime)
+  real w(nlevel,ntime)
+  real du(nlevel,ntime),hu(nlevel,ntime),vu(nlevel,ntime)
+  real dv(nlevel,ntime),hv(nlevel,ntime),vv(nlevel,ntime)
+  real dt(nlevel,ntime),ht(nlevel,ntime),vt(nlevel,ntime)
+  real dtrad(nlevel,ntime)
+  real dq(nlevel,ntime),hq(nlevel,ntime),vq(nlevel,ntime)
+  real dth(nlevel,ntime),hth(nlevel,ntime),vth(nlevel,ntime)
+  real dr(nlevel,ntime),hr(nlevel,ntime),vr(nlevel,ntime)
+  real flat(ntime),sens(ntime),ts(ntime),ustar(ntime)
+  real uw(nlevel,ntime),vw(nlevel,ntime),q1(nlevel,ntime),q2(nlevel,ntime),resul(nlevel,ntime),resul1(ntime)
+
+
+  integer nid, ierr, ierr1,ierr2,rid,i
+  integer nbvar3d
+  parameter(nbvar3d=39)
+  integer var3didin(nbvar3d)
+  character*5 name_var(1:nbvar3d)
+  data name_var/'zz','pp','temp','qv','rh','theta','rv','u','v','ug','vg','w','advu','hu','vu',&
+       'advv','hv','vv','advT','hT','vT','advq','hq','vq','advth','hth','vth','advr','hr','vr',&
+       'radT','uw','vw','q1','q2','sens','flat','ts','ustar'/
+
+
+  do i=1,nbvar3d
+     print *,'Dans read_cas2, on va lire ',nid,i,name_var(i)
+  enddo
+  do i=1,nbvar3d
+     ierr=NF_INQ_VARID(nid,name_var(i),var3didin(i)) 
+     print *,'ierr=',i,ierr,name_var(i),var3didin(i)
+     if(ierr/=NF_NOERR) then
+        print *,'Variable manquante dans cas.nc:',name_var(i)
+     endif
+  enddo
+  do i=1,nbvar3d
+     print *,'Dans read_cas2, on va lire ',var3didin(i),name_var(i)
+     if(i.LE.35) then
+        ierr = NF90_GET_VAR(nid,var3didin(i),resul, count = [1, 1, nlevel, ntime])
+        print *,'Dans read_cas2, on a lu ',ierr,var3didin(i),name_var(i)
+        if(ierr/=NF_NOERR) then
+           print *,'Pb a la lecture de cas.nc: ',name_var(i)
+           stop "getvarup"
+        endif
+     else
+        print *,'Dans read_cas2, on a lu ',ierr,var3didin(i),name_var(i)
+        ierr = NF90_GET_VAR(nid,var3didin(i),resul1, count = [1, 1, ntime])
+        if(ierr/=NF_NOERR) then
+           print *,'Pb a la lecture de cas.nc: ',name_var(i)
+           stop "getvarup"
+        endif
+     endif
+     select case(i)
+     case(1) ; zz=resul
+     case(2) ; pp=resul
+     case(3) ; temp=resul
+     case(4) ; qv=resul
+     case(5) ; rh=resul
+     case(6) ; theta=resul
+     case(7) ; rv=resul
+     case(8) ; u=resul
+     case(9) ; v=resul
+     case(10) ; ug=resul
+     case(11) ; vg=resul
+     case(12) ; w=resul
+     case(13) ; du=resul
+     case(14) ; hu=resul
+     case(15) ; vu=resul
+     case(16) ; dv=resul
+     case(17) ; hv=resul
+     case(18) ; vv=resul
+     case(19) ; dt=resul
+     case(20) ; ht=resul
+     case(21) ; vt=resul
+     case(22) ; dq=resul
+     case(23) ; hq=resul
+     case(24) ; vq=resul
+     case(25) ; dth=resul
+     case(26) ; hth=resul
+     case(27) ; vth=resul
+     case(28) ; dr=resul
+     case(29) ; hr=resul
+     case(30) ; vr=resul
+     case(31) ; dtrad=resul
+     case(32) ; uw=resul
+     case(33) ; vw=resul
+     case(34) ; q1=resul
+     case(35) ; q2=resul
+     case(36) ; sens=resul1
+     case(37) ; flat=resul1
+     case(38) ; ts=resul1
+     case(39) ; ustar=resul1
+     end select
+  enddo
+
+  return 
+end subroutine read_cas2
 !======================================================================
-      subroutine read2_cas(nid,nlevel,ntime,                                       &
-     &     ap,bp,zz,pp,zzh,pph,temp,theta,thv,thl,qv,ql,qi,rh,rv,u,v,vitw,omega,ug,vg,&
-     &     du,hu,vu,dv,hv,vv,dt,ht,vt,dq,hq,vq,                                    &
-     &     dth,hth,vth,dr,hr,vr,dtrad,sens,flat,ts,ps,ustar,tke,uw,vw,q1,q2,       &
-     &     orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,          &
-     &     heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas)
-
-!program reading forcing of the case study
-      implicit none
+subroutine read2_cas(nid,nlevel,ntime,                                       &
+     ap,bp,zz,pp,zzh,pph,temp,theta,thv,thl,qv,ql,qi,rh,rv,u,v,vitw,omega,ug,vg,&
+     du,hu,vu,dv,hv,vv,dt,ht,vt,dq,hq,vq,                                    &
+     dth,hth,vth,dr,hr,vr,dtrad,sens,flat,ts,ps,ustar,tke,uw,vw,q1,q2,       &
+     orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,          &
+     heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas)
+
+  !program reading forcing of the case study
+  use netcdf, only: nf90_get_var
+  implicit none
 #include "netcdf.inc"
 
-      integer ntime,nlevel
-
-      real ap(nlevel+1),bp(nlevel+1)
-      real zz(nlevel,ntime),zzh(nlevel+1)
-      real pp(nlevel,ntime),pph(nlevel+1)
-      real temp(nlevel,ntime),qv(nlevel,ntime),ql(nlevel,ntime),qi(nlevel,ntime),rh(nlevel,ntime)
-      real theta(nlevel,ntime),thv(nlevel,ntime),thl(nlevel,ntime),rv(nlevel,ntime)
-      real u(nlevel,ntime),v(nlevel,ntime)
-      real ug(nlevel,ntime),vg(nlevel,ntime)
-      real vitw(nlevel,ntime),omega(nlevel,ntime)
-      real du(nlevel,ntime),hu(nlevel,ntime),vu(nlevel,ntime)
-      real dv(nlevel,ntime),hv(nlevel,ntime),vv(nlevel,ntime)
-      real dt(nlevel,ntime),ht(nlevel,ntime),vt(nlevel,ntime)
-      real dtrad(nlevel,ntime)
-      real dq(nlevel,ntime),hq(nlevel,ntime),vq(nlevel,ntime)
-      real dth(nlevel,ntime),hth(nlevel,ntime),vth(nlevel,ntime),hthl(nlevel,ntime)
-      real dr(nlevel,ntime),hr(nlevel,ntime),vr(nlevel,ntime)
-      real flat(ntime),sens(ntime),ustar(ntime)
-      real uw(nlevel,ntime),vw(nlevel,ntime),q1(nlevel,ntime),q2(nlevel,ntime)
-      real ts(ntime),ps(ntime),tke(ntime)
-      real orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas
-      real apbp(nlevel+1),resul(nlevel,ntime),resul1(nlevel),resul2(ntime),resul3
-
-
-      integer nid, ierr,ierr1,ierr2,rid,i
-      integer nbvar3d
-      parameter(nbvar3d=62)
-      integer var3didin(nbvar3d),missing_var(nbvar3d)
-      character*12 name_var(1:nbvar3d)
-      data name_var/'coor_par_a','coor_par_b','height_h','pressure_h',&
-     &'w','omega','ug','vg','uadv','uadvh','uadvv','vadv','vadvh','vadvv','tadv','tadvh','tadvv',&
-     &'qadv','qadvh','qadvv','thadv','thadvh','thadvv','thladvh','radv','radvh','radvv','radcool','q1','q2','ustress','vstress', &
-     'rh',&
-     &'height_f','pressure_f','temp','theta','thv','thl','qv','ql','qi','rv','u','v',&
-     &'sfc_sens_flx','sfc_lat_flx','ts','ps','ustar','tke',&
-     &'orog','albedo','emiss','t_skin','q_skin','mom_rough','heat_rough','o3','rugos','clay','sand'/
-      do i=1,nbvar3d
-        missing_var(i)=0.
-      enddo
-
-!-----------------------------------------------------------------------
-       do i=1,nbvar3d
-         ierr=NF_INQ_VARID(nid,name_var(i),var3didin(i)) 
-         if(ierr/=NF_NOERR) then
-           print *,'Variable manquante dans cas.nc:',i,name_var(i)
-           ierr=NF_NOERR
-           missing_var(i)=1
-         else
-!-----------------------------------------------------------------------
-           if(i.LE.4) then     ! Lecture des coord pression en (nlevelp1,lat,lon)
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),apbp)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),apbp)
-#endif
+  integer ntime,nlevel
+
+  real ap(nlevel+1),bp(nlevel+1)
+  real zz(nlevel,ntime),zzh(nlevel+1)
+  real pp(nlevel,ntime),pph(nlevel+1)
+  real temp(nlevel,ntime),qv(nlevel,ntime),ql(nlevel,ntime),qi(nlevel,ntime),rh(nlevel,ntime)
+  real theta(nlevel,ntime),thv(nlevel,ntime),thl(nlevel,ntime),rv(nlevel,ntime)
+  real u(nlevel,ntime),v(nlevel,ntime)
+  real ug(nlevel,ntime),vg(nlevel,ntime)
+  real vitw(nlevel,ntime),omega(nlevel,ntime)
+  real du(nlevel,ntime),hu(nlevel,ntime),vu(nlevel,ntime)
+  real dv(nlevel,ntime),hv(nlevel,ntime),vv(nlevel,ntime)
+  real dt(nlevel,ntime),ht(nlevel,ntime),vt(nlevel,ntime)
+  real dtrad(nlevel,ntime)
+  real dq(nlevel,ntime),hq(nlevel,ntime),vq(nlevel,ntime)
+  real dth(nlevel,ntime),hth(nlevel,ntime),vth(nlevel,ntime),hthl(nlevel,ntime)
+  real dr(nlevel,ntime),hr(nlevel,ntime),vr(nlevel,ntime)
+  real flat(ntime),sens(ntime),ustar(ntime)
+  real uw(nlevel,ntime),vw(nlevel,ntime),q1(nlevel,ntime),q2(nlevel,ntime)
+  real ts(ntime),ps(ntime),tke(ntime)
+  real orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas
+  real apbp(nlevel+1),resul(nlevel,ntime),resul1(nlevel),resul2(ntime),resul3
+
+
+  integer nid, ierr,ierr1,ierr2,rid,i
+  integer nbvar3d
+  parameter(nbvar3d=62)
+  integer var3didin(nbvar3d),missing_var(nbvar3d)
+  character*12 name_var(1:nbvar3d)
+  data name_var/'coor_par_a','coor_par_b','height_h','pressure_h',&
+       'w','omega','ug','vg','uadv','uadvh','uadvv','vadv','vadvh','vadvv','tadv','tadvh','tadvv',&
+       'qadv','qadvh','qadvv','thadv','thadvh','thadvv','thladvh','radv','radvh','radvv','radcool','q1','q2','ustress','vstress', &
+       'rh',&
+       'height_f','pressure_f','temp','theta','thv','thl','qv','ql','qi','rv','u','v',&
+       'sfc_sens_flx','sfc_lat_flx','ts','ps','ustar','tke',&
+       'orog','albedo','emiss','t_skin','q_skin','mom_rough','heat_rough','o3','rugos','clay','sand'/
+  do i=1,nbvar3d
+     missing_var(i)=0.
+  enddo
+
+  !-----------------------------------------------------------------------
+  do i=1,nbvar3d
+     ierr=NF_INQ_VARID(nid,name_var(i),var3didin(i)) 
+     if(ierr/=NF_NOERR) then
+        print *,'Variable manquante dans cas.nc:',i,name_var(i)
+        ierr=NF_NOERR
+        missing_var(i)=1
+     else
+        !-----------------------------------------------------------------------
+        if(i.LE.4) then     ! Lecture des coord pression en (nlevelp1,lat,lon)
+           ierr = NF90_GET_VAR(nid,var3didin(i),apbp, count = [1, 1, nlevel + 1])
            print *,'read2_cas(apbp), on a lu ',i,name_var(i)
            if(ierr/=NF_NOERR) then
@@ -730,11 +718,7 @@
               stop "getvarup"
            endif
-!-----------------------------------------------------------------------
-           else if(i.gt.4.and.i.LE.45) then   ! Lecture des variables en (time,nlevel,lat,lon)
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul)
-#endif
+           !-----------------------------------------------------------------------
+        else if(i.gt.4.and.i.LE.45) then   ! Lecture des variables en (time,nlevel,lat,lon)
+           ierr = NF90_GET_VAR(nid,var3didin(i),resul, count = [1, 1, nlevel, ntime])
            print *,'read2_cas(resul), on a lu ',i,name_var(i)
            if(ierr/=NF_NOERR) then
@@ -742,11 +726,7 @@
               stop "getvarup"
            endif
-!-----------------------------------------------------------------------
-           else if (i.gt.45.and.i.LE.51) then   ! Lecture des variables en (time,lat,lon)
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul2)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul2)
-#endif
+           !-----------------------------------------------------------------------
+        else if (i.gt.45.and.i.LE.51) then   ! Lecture des variables en (time,lat,lon)
+           ierr = NF90_GET_VAR(nid,var3didin(i),resul2, count = [1, 1, ntime])
            print *,'read2_cas(resul2), on a lu ',i,name_var(i)
            if(ierr/=NF_NOERR) then
@@ -754,11 +734,7 @@
               stop "getvarup"
            endif
-!-----------------------------------------------------------------------
-           else     ! Lecture des constantes (lat,lon)
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul3)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul3)
-#endif
+           !-----------------------------------------------------------------------
+        else     ! Lecture des constantes (lat,lon)
+           ierr = NF90_GET_VAR(nid,var3didin(i),resul3)
            print *,'read2_cas(resul3), on a lu ',i,name_var(i)
            if(ierr/=NF_NOERR) then
@@ -766,155 +742,152 @@
               stop "getvarup"
            endif
-           endif
-         endif
-!-----------------------------------------------------------------------
-         select case(i)
-           case(1) ; ap=apbp       ! donnees indexees en nlevel+1
-           case(2) ; bp=apbp
-           case(3) ; zzh=apbp
-           case(4) ; pph=apbp
-           case(5) ; vitw=resul    ! donnees indexees en nlevel,time
-           case(6) ; omega=resul
-           case(7) ; ug=resul
-           case(8) ; vg=resul
-           case(9) ; du=resul
-           case(10) ; hu=resul
-           case(11) ; vu=resul
-           case(12) ; dv=resul
-           case(13) ; hv=resul
-           case(14) ; vv=resul
-           case(15) ; dt=resul
-           case(16) ; ht=resul
-           case(17) ; vt=resul
-           case(18) ; dq=resul
-           case(19) ; hq=resul
-           case(20) ; vq=resul
-           case(21) ; dth=resul
-           case(22) ; hth=resul
-           case(23) ; vth=resul
-           case(24) ; hthl=resul
-           case(25) ; dr=resul
-           case(26) ; hr=resul
-           case(27) ; vr=resul
-           case(28) ; dtrad=resul
-           case(29) ; q1=resul
-           case(30) ; q2=resul
-           case(31) ; uw=resul
-           case(32) ; vw=resul
-           case(33) ; rh=resul
-           case(34) ; zz=resul      ! donnees en time,nlevel pour profil initial
-           case(35) ; pp=resul
-           case(36) ; temp=resul
-           case(37) ; theta=resul
-           case(38) ; thv=resul
-           case(39) ; thl=resul
-           case(40) ; qv=resul
-           case(41) ; ql=resul
-           case(42) ; qi=resul
-           case(43) ; rv=resul
-           case(44) ; u=resul
-           case(45) ; v=resul
-           case(46) ; sens=resul2   ! donnees indexees en time
-           case(47) ; flat=resul2
-           case(48) ; ts=resul2
-           case(49) ; ps=resul2
-           case(50) ; ustar=resul2
-           case(51) ; tke=resul2
-           case(52) ; orog_cas=resul3      ! constantes
-           case(53) ; albedo_cas=resul3
-           case(54) ; emiss_cas=resul3
-           case(55) ; t_skin_cas=resul3
-           case(56) ; q_skin_cas=resul3
-           case(57) ; mom_rough=resul3
-           case(58) ; heat_rough=resul3
-           case(59) ; o3_cas=resul3        
-           case(60) ; rugos_cas=resul3
-           case(61) ; clay_cas=resul3
-           case(62) ; sand_cas=resul3
-         end select
-         resul=0.
-         resul1=0.
-         resul2=0.
-         resul3=0.
-       enddo
-!-----------------------------------------------------------------------
-
-
-         return 
-         end subroutine read2_cas
+        endif
+     endif
+     !-----------------------------------------------------------------------
+     select case(i)
+     case(1) ; ap=apbp       ! donnees indexees en nlevel+1
+     case(2) ; bp=apbp
+     case(3) ; zzh=apbp
+     case(4) ; pph=apbp
+     case(5) ; vitw=resul    ! donnees indexees en nlevel,time
+     case(6) ; omega=resul
+     case(7) ; ug=resul
+     case(8) ; vg=resul
+     case(9) ; du=resul
+     case(10) ; hu=resul
+     case(11) ; vu=resul
+     case(12) ; dv=resul
+     case(13) ; hv=resul
+     case(14) ; vv=resul
+     case(15) ; dt=resul
+     case(16) ; ht=resul
+     case(17) ; vt=resul
+     case(18) ; dq=resul
+     case(19) ; hq=resul
+     case(20) ; vq=resul
+     case(21) ; dth=resul
+     case(22) ; hth=resul
+     case(23) ; vth=resul
+     case(24) ; hthl=resul
+     case(25) ; dr=resul
+     case(26) ; hr=resul
+     case(27) ; vr=resul
+     case(28) ; dtrad=resul
+     case(29) ; q1=resul
+     case(30) ; q2=resul
+     case(31) ; uw=resul
+     case(32) ; vw=resul
+     case(33) ; rh=resul
+     case(34) ; zz=resul      ! donnees en time,nlevel pour profil initial
+     case(35) ; pp=resul
+     case(36) ; temp=resul
+     case(37) ; theta=resul
+     case(38) ; thv=resul
+     case(39) ; thl=resul
+     case(40) ; qv=resul
+     case(41) ; ql=resul
+     case(42) ; qi=resul
+     case(43) ; rv=resul
+     case(44) ; u=resul
+     case(45) ; v=resul
+     case(46) ; sens=resul2   ! donnees indexees en time
+     case(47) ; flat=resul2
+     case(48) ; ts=resul2
+     case(49) ; ps=resul2
+     case(50) ; ustar=resul2
+     case(51) ; tke=resul2
+     case(52) ; orog_cas=resul3      ! constantes
+     case(53) ; albedo_cas=resul3
+     case(54) ; emiss_cas=resul3
+     case(55) ; t_skin_cas=resul3
+     case(56) ; q_skin_cas=resul3
+     case(57) ; mom_rough=resul3
+     case(58) ; heat_rough=resul3
+     case(59) ; o3_cas=resul3        
+     case(60) ; rugos_cas=resul3
+     case(61) ; clay_cas=resul3
+     case(62) ; sand_cas=resul3
+     end select
+     resul=0.
+     resul1=0.
+     resul2=0.
+     resul3=0.
+  enddo
+  !-----------------------------------------------------------------------
+
+
+  return 
+end subroutine read2_cas
 
 !======================================================================
-      subroutine old_read_SCM(nid,nlevel,ntime,                                       &
-     &     ap,bp,zz,pp,zzh,pph,temp,theta,thv,thl,qv,ql,qi,rh,rv,u,v,vitw,omega,ug,vg,&
-     &     du,hu,vu,dv,hv,vv,dt,ht,vt,dq,hq,vq,                                    &
-     &     dth,hth,vth,dr,hr,vr,dtrad,sens,flat,ts,ps,ustar,tke,uw,vw,q1,q2,       &
-     &     orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,          &
-     &     heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas)
-
-!program reading forcing of the case study
-      implicit none
+subroutine old_read_SCM(nid,nlevel,ntime,                                       &
+     ap,bp,zz,pp,zzh,pph,temp,theta,thv,thl,qv,ql,qi,rh,rv,u,v,vitw,omega,ug,vg,&
+     du,hu,vu,dv,hv,vv,dt,ht,vt,dq,hq,vq,                                    &
+     dth,hth,vth,dr,hr,vr,dtrad,sens,flat,ts,ps,ustar,tke,uw,vw,q1,q2,       &
+     orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,          &
+     heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas)
+
+  !program reading forcing of the case study
+  use netcdf, only: nf90_get_var
+  implicit none
 #include "netcdf.inc"
 
-      integer ntime,nlevel,k,t
-
-      real ap(nlevel+1),bp(nlevel+1)
-      real zz(nlevel,ntime),zzh(nlevel+1)
-      real pp(nlevel,ntime),pph(nlevel+1)
-!profils initiaux
-      real temp0(nlevel),qv0(nlevel),ql0(nlevel),qi0(nlevel),u0(nlevel),v0(nlevel),tke0(nlevel)
-      real pp0(nlevel)    
-      real temp(nlevel,ntime),qv(nlevel,ntime),ql(nlevel,ntime),qi(nlevel,ntime),rh(nlevel,ntime)
-      real theta(nlevel,ntime),thv(nlevel,ntime),thl(nlevel,ntime),rv(nlevel,ntime)
-      real u(nlevel,ntime),v(nlevel,ntime),tke(nlevel,ntime)
-      real ug(nlevel,ntime),vg(nlevel,ntime)
-      real vitw(nlevel,ntime),omega(nlevel,ntime)
-      real du(nlevel,ntime),hu(nlevel,ntime),vu(nlevel,ntime)
-      real dv(nlevel,ntime),hv(nlevel,ntime),vv(nlevel,ntime)
-      real dt(nlevel,ntime),ht(nlevel,ntime),vt(nlevel,ntime)
-      real dtrad(nlevel,ntime)
-      real dq(nlevel,ntime),hq(nlevel,ntime),vq(nlevel,ntime)
-      real dth(nlevel,ntime),hth(nlevel,ntime),vth(nlevel,ntime),hthl(nlevel,ntime)
-      real dr(nlevel,ntime),hr(nlevel,ntime),vr(nlevel,ntime)
-      real flat(ntime),sens(ntime),ustar(ntime)
-      real uw(nlevel,ntime),vw(nlevel,ntime),q1(nlevel,ntime),q2(nlevel,ntime)
-      real ts(ntime),ps(ntime)
-      real orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas
-      real apbp(nlevel+1),resul(nlevel,ntime),resul1(nlevel),resul2(ntime),resul3
-
-
-      integer nid, ierr,ierr1,ierr2,rid,i
-      integer nbvar3d
-      parameter(nbvar3d=70)
-      integer var3didin(nbvar3d),missing_var(nbvar3d)
-      character*13 name_var(1:nbvar3d)
-      data name_var/'coor_par_a','coor_par_b','height_h','pressure_h',&
-     &'temp','qv','ql','qi','u','v','tke','pressure',&
-     &'w','omega','ug','vg','uadv','uadvh','uadvv','vadv','vadvh','vadvv','tadv','tadvh','tadvv',&
-     &'qvadv','qvadvh','qvadvv','thadv','thadvh','thadvv','thladvh','radv','radvh','radvv','radcool','q1','q2','ustress','vstress', &
-     'rh',&
-     &'height_f','pressure_forc','tempt','theta','thv','thl','qvt','qlt','qit','rv','ut','vt','tket',&
-     &'sfc_sens_flx','sfc_lat_flx','ts','ps','ustar',&
-     &'orog','albedo','emiss','t_skin','q_skin','mom_rough','heat_rough','o3','rugos','clay','sand'/
-      do i=1,nbvar3d
-        missing_var(i)=0.
-      enddo
-
-!-----------------------------------------------------------------------
-
-     print*,'ON EST LA'
-       do i=1,nbvar3d
-         ierr=NF_INQ_VARID(nid,name_var(i),var3didin(i)) 
-         if(ierr/=NF_NOERR) then
-           print *,'Variable manquante dans cas.nc:',i,name_var(i)
-           ierr=NF_NOERR
-           missing_var(i)=1
-         else
-!-----------------------------------------------------------------------
-           if(i.LE.4) then     ! Lecture des coord pression en (nlevelp1,lat,lon)
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),apbp)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),apbp)
-#endif
+  integer ntime,nlevel,k,t
+
+  real ap(nlevel+1),bp(nlevel+1)
+  real zz(nlevel,ntime),zzh(nlevel+1)
+  real pp(nlevel,ntime),pph(nlevel+1)
+  !profils initiaux
+  real temp0(nlevel),qv0(nlevel),ql0(nlevel),qi0(nlevel),u0(nlevel),v0(nlevel),tke0(nlevel)
+  real pp0(nlevel)    
+  real temp(nlevel,ntime),qv(nlevel,ntime),ql(nlevel,ntime),qi(nlevel,ntime),rh(nlevel,ntime)
+  real theta(nlevel,ntime),thv(nlevel,ntime),thl(nlevel,ntime),rv(nlevel,ntime)
+  real u(nlevel,ntime),v(nlevel,ntime),tke(nlevel,ntime)
+  real ug(nlevel,ntime),vg(nlevel,ntime)
+  real vitw(nlevel,ntime),omega(nlevel,ntime)
+  real du(nlevel,ntime),hu(nlevel,ntime),vu(nlevel,ntime)
+  real dv(nlevel,ntime),hv(nlevel,ntime),vv(nlevel,ntime)
+  real dt(nlevel,ntime),ht(nlevel,ntime),vt(nlevel,ntime)
+  real dtrad(nlevel,ntime)
+  real dq(nlevel,ntime),hq(nlevel,ntime),vq(nlevel,ntime)
+  real dth(nlevel,ntime),hth(nlevel,ntime),vth(nlevel,ntime),hthl(nlevel,ntime)
+  real dr(nlevel,ntime),hr(nlevel,ntime),vr(nlevel,ntime)
+  real flat(ntime),sens(ntime),ustar(ntime)
+  real uw(nlevel,ntime),vw(nlevel,ntime),q1(nlevel,ntime),q2(nlevel,ntime)
+  real ts(ntime),ps(ntime)
+  real orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas
+  real apbp(nlevel+1),resul(nlevel,ntime),resul1(nlevel),resul2(ntime),resul3
+
+
+  integer nid, ierr,ierr1,ierr2,rid,i
+  integer nbvar3d
+  parameter(nbvar3d=70)
+  integer var3didin(nbvar3d),missing_var(nbvar3d)
+  character*13 name_var(1:nbvar3d)
+  data name_var/'coor_par_a','coor_par_b','height_h','pressure_h',&
+       'temp','qv','ql','qi','u','v','tke','pressure',&
+       'w','omega','ug','vg','uadv','uadvh','uadvv','vadv','vadvh','vadvv','tadv','tadvh','tadvv',&
+       'qvadv','qvadvh','qvadvv','thadv','thadvh','thadvv','thladvh','radv','radvh','radvv','radcool','q1','q2','ustress', &
+       'vstress','rh',&
+       'height_f','pressure_forc','tempt','theta','thv','thl','qvt','qlt','qit','rv','ut','vt','tket',&
+       'sfc_sens_flx','sfc_lat_flx','ts','ps','ustar',&
+       'orog','albedo','emiss','t_skin','q_skin','mom_rough','heat_rough','o3','rugos','clay','sand'/
+  do i=1,nbvar3d
+     missing_var(i)=0.
+  enddo
+
+  !-----------------------------------------------------------------------
+
+  print*,'ON EST LA'
+  do i=1,nbvar3d
+     ierr=NF_INQ_VARID(nid,name_var(i),var3didin(i)) 
+     if(ierr/=NF_NOERR) then
+        print *,'Variable manquante dans cas.nc:',i,name_var(i)
+        ierr=NF_NOERR
+        missing_var(i)=1
+     else
+        !-----------------------------------------------------------------------
+        if(i.LE.4) then     ! Lecture des coord pression en (nlevelp1,lat,lon)
+           ierr = NF90_GET_VAR(nid,var3didin(i),apbp)
            print *,'read2_cas(apbp), on a lu ',i,name_var(i)
            if(ierr/=NF_NOERR) then
@@ -922,11 +895,7 @@
               stop "getvarup"
            endif
-!-----------------------------------------------------------------------
-           else if(i.gt.4.and.i.LE.12) then   ! Lecture des variables en (time,nlevel,lat,lon)
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul1)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul1)
-#endif
+           !-----------------------------------------------------------------------
+        else if(i.gt.4.and.i.LE.12) then   ! Lecture des variables en (time,nlevel,lat,lon)
+           ierr = NF90_GET_VAR(nid,var3didin(i),resul1)
            print *,'read2_cas(resul1), on a lu ',i,name_var(i)
            if(ierr/=NF_NOERR) then
@@ -934,12 +903,8 @@
               stop "getvarup"
            endif
-         print*,'Lecture de la variable #i ',i,name_var(i),minval(resul1),maxval(resul1)
-!-----------------------------------------------------------------------
-           else if(i.gt.12.and.i.LE.54) then   ! Lecture des variables en (time,nlevel,lat,lon)
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul)
-#endif
+           print*,'Lecture de la variable #i ',i,name_var(i),minval(resul1),maxval(resul1)
+           !-----------------------------------------------------------------------
+        else if(i.gt.12.and.i.LE.54) then   ! Lecture des variables en (time,nlevel,lat,lon)
+           ierr = NF90_GET_VAR(nid,var3didin(i),resul)
            print *,'read2_cas(resul), on a lu ',i,name_var(i)
            if(ierr/=NF_NOERR) then
@@ -947,12 +912,8 @@
               stop "getvarup"
            endif
-         print*,'Lecture de la variable #i ',i,name_var(i),minval(resul),maxval(resul)
-!-----------------------------------------------------------------------
-           else if (i.gt.54.and.i.LE.65) then   ! Lecture des variables en (time,lat,lon)
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul2)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul2)
-#endif
+           print*,'Lecture de la variable #i ',i,name_var(i),minval(resul),maxval(resul)
+           !-----------------------------------------------------------------------
+        else if (i.gt.54.and.i.LE.65) then   ! Lecture des variables en (time,lat,lon)
+           ierr = NF90_GET_VAR(nid,var3didin(i),resul2)
            print *,'read2_cas(resul2), on a lu ',i,name_var(i)
            if(ierr/=NF_NOERR) then
@@ -960,12 +921,8 @@
               stop "getvarup"
            endif
-         print*,'Lecture de la variable #i  ',i,name_var(i),minval(resul2),maxval(resul2)
-!-----------------------------------------------------------------------
-           else     ! Lecture des constantes (lat,lon)
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul3)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul3)
-#endif
+           print*,'Lecture de la variable #i  ',i,name_var(i),minval(resul2),maxval(resul2)
+           !-----------------------------------------------------------------------
+        else     ! Lecture des constantes (lat,lon)
+           ierr = NF90_GET_VAR(nid,var3didin(i),resul3)
            print *,'read2_cas(resul3), on a lu ',i,name_var(i)
            if(ierr/=NF_NOERR) then
@@ -973,546 +930,546 @@
               stop "getvarup"
            endif
-         print*,'Lecture de la variable #i ',i,name_var(i),resul3
-           endif
-         endif
-!-----------------------------------------------------------------------
-         select case(i)
-         !case(1) ; ap=apbp       ! donnees indexees en nlevel+1
-         ! case(2) ; bp=apbp
-           case(3) ; zzh=apbp
-           case(4) ; pph=apbp
-           case(5) ; temp0=resul1    ! donnees initiales
-           case(6) ; qv0=resul1
-           case(7) ; ql0=resul1
-           case(8) ; qi0=resul1
-           case(9) ; u0=resul1
-           case(10) ; v0=resul1
-           case(11) ; tke0=resul1
-           case(12) ; pp0=resul1
-           case(13) ; vitw=resul    ! donnees indexees en nlevel,time
-           case(14) ; omega=resul
-           case(15) ; ug=resul
-           case(16) ; vg=resul
-           case(17) ; du=resul
-           case(18) ; hu=resul
-           case(19) ; vu=resul
-           case(20) ; dv=resul
-           case(21) ; hv=resul
-           case(22) ; vv=resul
-           case(23) ; dt=resul
-           case(24) ; ht=resul
-           case(25) ; vt=resul
-           case(26) ; dq=resul
-           case(27) ; hq=resul
-           case(28) ; vq=resul
-           case(29) ; dth=resul
-           case(30) ; hth=resul
-           case(31) ; vth=resul
-           case(32) ; hthl=resul
-           case(33) ; dr=resul
-           case(34) ; hr=resul
-           case(35) ; vr=resul
-           case(36) ; dtrad=resul
-           case(37) ; q1=resul
-           case(38) ; q2=resul
-           case(39) ; uw=resul
-           case(40) ; vw=resul
-           case(41) ; rh=resul
-           case(42) ; zz=resul      ! donnees en time,nlevel pour profil initial
-           case(43) ; pp=resul
-           case(44) ; temp=resul
-           case(45) ; theta=resul
-           case(46) ; thv=resul
-           case(47) ; thl=resul
-           case(48) ; qv=resul
-           case(49) ; ql=resul
-           case(50) ; qi=resul
-           case(51) ; rv=resul
-           case(52) ; u=resul
-           case(53) ; v=resul
-           case(54) ; tke=resul
-           case(55) ; sens=resul2   ! donnees indexees en time
-           case(56) ; flat=resul2
-           case(57) ; ts=resul2
-           case(58) ; ps=resul2
-           case(59) ; ustar=resul2
-           case(60) ; orog_cas=resul3      ! constantes
-           case(61) ; albedo_cas=resul3
-           case(62) ; emiss_cas=resul3
-           case(63) ; t_skin_cas=resul3
-           case(64) ; q_skin_cas=resul3
-           case(65) ; mom_rough=resul3
-           case(66) ; heat_rough=resul3
-           case(67) ; o3_cas=resul3        
-           case(68) ; rugos_cas=resul3
-           case(69) ; clay_cas=resul3
-           case(70) ; sand_cas=resul3
-         end select
-         resul=0.
-         resul1=0.
-         resul2=0.
-         resul3=0.
-       enddo
-         print*,'Lecture de la variable APRES ,sens ',minval(sens),maxval(sens)
-         print*,'Lecture de la variable APRES ,flat ',minval(flat),maxval(flat)
-
-!CR:ATTENTION EN ATTENTE DE REGLER LA QUESTION DU PAS DE TEMPS INITIAL
-       do t=1,ntime
-          do k=1,nlevel
-             temp(k,t)=temp0(k)
-             qv(k,t)=qv0(k)
-             ql(k,t)=ql0(k)
-             qi(k,t)=qi0(k)
-             u(k,t)=u0(k)
-             v(k,t)=v0(k)
-             tke(k,t)=tke0(k)
-          enddo
-       enddo
-!-----------------------------------------------------------------------
-
-         return 
-         end subroutine old_read_SCM
+           print*,'Lecture de la variable #i ',i,name_var(i),resul3
+        endif
+     endif
+     !-----------------------------------------------------------------------
+     select case(i)
+        !case(1) ; ap=apbp       ! donnees indexees en nlevel+1
+        ! case(2) ; bp=apbp
+     case(3) ; zzh=apbp
+     case(4) ; pph=apbp
+     case(5) ; temp0=resul1    ! donnees initiales
+     case(6) ; qv0=resul1
+     case(7) ; ql0=resul1
+     case(8) ; qi0=resul1
+     case(9) ; u0=resul1
+     case(10) ; v0=resul1
+     case(11) ; tke0=resul1
+     case(12) ; pp0=resul1
+     case(13) ; vitw=resul    ! donnees indexees en nlevel,time
+     case(14) ; omega=resul
+     case(15) ; ug=resul
+     case(16) ; vg=resul
+     case(17) ; du=resul
+     case(18) ; hu=resul
+     case(19) ; vu=resul
+     case(20) ; dv=resul
+     case(21) ; hv=resul
+     case(22) ; vv=resul
+     case(23) ; dt=resul
+     case(24) ; ht=resul
+     case(25) ; vt=resul
+     case(26) ; dq=resul
+     case(27) ; hq=resul
+     case(28) ; vq=resul
+     case(29) ; dth=resul
+     case(30) ; hth=resul
+     case(31) ; vth=resul
+     case(32) ; hthl=resul
+     case(33) ; dr=resul
+     case(34) ; hr=resul
+     case(35) ; vr=resul
+     case(36) ; dtrad=resul
+     case(37) ; q1=resul
+     case(38) ; q2=resul
+     case(39) ; uw=resul
+     case(40) ; vw=resul
+     case(41) ; rh=resul
+     case(42) ; zz=resul      ! donnees en time,nlevel pour profil initial
+     case(43) ; pp=resul
+     case(44) ; temp=resul
+     case(45) ; theta=resul
+     case(46) ; thv=resul
+     case(47) ; thl=resul
+     case(48) ; qv=resul
+     case(49) ; ql=resul
+     case(50) ; qi=resul
+     case(51) ; rv=resul
+     case(52) ; u=resul
+     case(53) ; v=resul
+     case(54) ; tke=resul
+     case(55) ; sens=resul2   ! donnees indexees en time
+     case(56) ; flat=resul2
+     case(57) ; ts=resul2
+     case(58) ; ps=resul2
+     case(59) ; ustar=resul2
+     case(60) ; orog_cas=resul3      ! constantes
+     case(61) ; albedo_cas=resul3
+     case(62) ; emiss_cas=resul3
+     case(63) ; t_skin_cas=resul3
+     case(64) ; q_skin_cas=resul3
+     case(65) ; mom_rough=resul3
+     case(66) ; heat_rough=resul3
+     case(67) ; o3_cas=resul3        
+     case(68) ; rugos_cas=resul3
+     case(69) ; clay_cas=resul3
+     case(70) ; sand_cas=resul3
+     end select
+     resul=0.
+     resul1=0.
+     resul2=0.
+     resul3=0.
+  enddo
+  print*,'Lecture de la variable APRES ,sens ',minval(sens),maxval(sens)
+  print*,'Lecture de la variable APRES ,flat ',minval(flat),maxval(flat)
+
+  !CR:ATTENTION EN ATTENTE DE REGLER LA QUESTION DU PAS DE TEMPS INITIAL
+  do t=1,ntime
+     do k=1,nlevel
+        temp(k,t)=temp0(k)
+        qv(k,t)=qv0(k)
+        ql(k,t)=ql0(k)
+        qi(k,t)=qi0(k)
+        u(k,t)=u0(k)
+        v(k,t)=v0(k)
+        tke(k,t)=tke0(k)
+     enddo
+  enddo
+  !-----------------------------------------------------------------------
+
+  return 
+end subroutine old_read_SCM
 !======================================================================
 
 !======================================================================
-        SUBROUTINE interp_case_time2(day,day1,annee_ref                &
-!    &         ,year_cas,day_cas,nt_cas,pdt_forc,nlev_cas      &
-     &         ,nt_cas,nlev_cas                                       &
-     &         ,ts_cas,ps_cas,plev_cas,t_cas,q_cas,u_cas,v_cas               &
-     &         ,ug_cas,vg_cas,vitw_cas,du_cas,hu_cas,vu_cas           &
-     &         ,dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dtrad_cas   &
-     &         ,dq_cas,hq_cas,vq_cas,lat_cas,sens_cas,ustar_cas       &
-     &         ,uw_cas,vw_cas,q1_cas,q2_cas                           &
-     &         ,ts_prof_cas,plev_prof_cas,t_prof_cas,q_prof_cas       &
-     &         ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas         &
-     &         ,vitw_prof_cas,du_prof_cas,hu_prof_cas,vu_prof_cas     &
-     &         ,dv_prof_cas,hv_prof_cas,vv_prof_cas,dt_prof_cas       &
-     &         ,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas    &
-     &         ,hq_prof_cas,vq_prof_cas,lat_prof_cas,sens_prof_cas    &
-     &         ,ustar_prof_cas,uw_prof_cas,vw_prof_cas,q1_prof_cas,q2_prof_cas)
-          
-
-        implicit none
-
-!---------------------------------------------------------------------------------------
-! Time interpolation of a 2D field to the timestep corresponding to day
-!
-! day: current julian day (e.g. 717538.2)
-! day1: first day of the simulation
-! nt_cas: total nb of data in the forcing 
-! pdt_cas: total time interval (in sec) between 2 forcing data
-!---------------------------------------------------------------------------------------
+SUBROUTINE interp_case_time2(day,day1,annee_ref                &
+     !    &         ,year_cas,day_cas,nt_cas,pdt_forc,nlev_cas      &
+     ,nt_cas,nlev_cas                                       &
+     ,ts_cas,ps_cas,plev_cas,t_cas,q_cas,u_cas,v_cas               &
+     ,ug_cas,vg_cas,vitw_cas,du_cas,hu_cas,vu_cas           &
+     ,dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dtrad_cas   &
+     ,dq_cas,hq_cas,vq_cas,lat_cas,sens_cas,ustar_cas       &
+     ,uw_cas,vw_cas,q1_cas,q2_cas                           &
+     ,ts_prof_cas,plev_prof_cas,t_prof_cas,q_prof_cas       &
+     ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas         &
+     ,vitw_prof_cas,du_prof_cas,hu_prof_cas,vu_prof_cas     &
+     ,dv_prof_cas,hv_prof_cas,vv_prof_cas,dt_prof_cas       &
+     ,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas    &
+     ,hq_prof_cas,vq_prof_cas,lat_prof_cas,sens_prof_cas    &
+     ,ustar_prof_cas,uw_prof_cas,vw_prof_cas,q1_prof_cas,q2_prof_cas)
+
+
+  implicit none
+
+  !---------------------------------------------------------------------------------------
+  ! Time interpolation of a 2D field to the timestep corresponding to day
+  !
+  ! day: current julian day (e.g. 717538.2)
+  ! day1: first day of the simulation
+  ! nt_cas: total nb of data in the forcing 
+  ! pdt_cas: total time interval (in sec) between 2 forcing data
+  !---------------------------------------------------------------------------------------
 
 #include "compar1d.h"
 #include "date_cas.h"
 
-! inputs:
-        integer annee_ref
-        integer nt_cas,nlev_cas
-        real day, day1,day_cas
-        real ts_cas(nt_cas),ps_cas(nt_cas)
-        real plev_cas(nlev_cas,nt_cas)
-        real t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas)
-        real u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas)
-        real ug_cas(nlev_cas,nt_cas),vg_cas(nlev_cas,nt_cas)
-        real vitw_cas(nlev_cas,nt_cas)
-        real du_cas(nlev_cas,nt_cas),hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas)
-        real dv_cas(nlev_cas,nt_cas),hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas)
-        real dt_cas(nlev_cas,nt_cas),ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas)
-        real dtrad_cas(nlev_cas,nt_cas)
-        real dq_cas(nlev_cas,nt_cas),hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas)
-        real lat_cas(nt_cas)
-        real sens_cas(nt_cas)
-        real ustar_cas(nt_cas),uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas)
-        real q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas)
-
-! outputs:
-        real plev_prof_cas(nlev_cas)
-        real t_prof_cas(nlev_cas),q_prof_cas(nlev_cas)
-        real u_prof_cas(nlev_cas),v_prof_cas(nlev_cas)
-        real ug_prof_cas(nlev_cas),vg_prof_cas(nlev_cas)
-        real vitw_prof_cas(nlev_cas)
-        real du_prof_cas(nlev_cas),hu_prof_cas(nlev_cas),vu_prof_cas(nlev_cas)
-        real dv_prof_cas(nlev_cas),hv_prof_cas(nlev_cas),vv_prof_cas(nlev_cas)
-        real dt_prof_cas(nlev_cas),ht_prof_cas(nlev_cas),vt_prof_cas(nlev_cas)
-        real dtrad_prof_cas(nlev_cas)
-        real dq_prof_cas(nlev_cas),hq_prof_cas(nlev_cas),vq_prof_cas(nlev_cas)
-        real lat_prof_cas,sens_prof_cas,ts_prof_cas,ustar_prof_cas
-        real uw_prof_cas(nlev_cas),vw_prof_cas(nlev_cas),q1_prof_cas(nlev_cas),q2_prof_cas(nlev_cas)
-! local:
-        integer it_cas1, it_cas2,k
-        real timeit,time_cas1,time_cas2,frac
-
-
-        print*,'Check time',day1,day_ju_ini_cas,day_deb+1,pdt_cas
-
-! On teste si la date du cas AMMA est correcte.
-! C est pour memoire car en fait les fichiers .def
-! sont censes etre corrects.
-! A supprimer a terme (MPL 20150623)
-!     if ((forcing_type.eq.10).and.(1.eq.0)) then
-! Check that initial day of the simulation consistent with AMMA case:
-!      if (annee_ref.ne.2006) then
-!       print*,'Pour AMMA, annee_ref doit etre 2006'
-!       print*,'Changer annee_ref dans run.def'
-!       stop
-!      endif
-!      if (annee_ref.eq.2006 .and. day1.lt.day_cas) then
-!       print*,'AMMA a debute le 10 juillet 2006',day1,day_cas
-!       print*,'Changer dayref dans run.def'
-!       stop
-!      endif
-!      if (annee_ref.eq.2006 .and. day1.gt.day_cas+1) then
-!       print*,'AMMA a fini le 11 juillet'
-!       print*,'Changer dayref ou nday dans run.def'
-!       stop
-!      endif
-!      endif
-
-! Determine timestep relative to the 1st day:
-!       timeit=(day-day1)*86400.
-!       if (annee_ref.eq.1992) then
-!        timeit=(day-day_cas)*86400.
-!       else
-!        timeit=(day+61.-1.)*86400. ! 61 days between Nov01 and Dec31 1992
-!       endif
-      timeit=(day-day_ju_ini_cas)*86400
-      print *,'day=',day
-      print *,'day_ju_ini_cas=',day_ju_ini_cas
-      print *,'pdt_cas=',pdt_cas
-      print *,'timeit=',timeit
-      print *,'nt_cas=',nt_cas
-
-! Determine the closest observation times:
-!       it_cas1=INT(timeit/pdt_cas)+1
-!       it_cas2=it_cas1 + 1
-!       time_cas1=(it_cas1-1)*pdt_cas
-!       time_cas2=(it_cas2-1)*pdt_cas
-
-       it_cas1=INT(timeit/pdt_cas)+1
-       IF (it_cas1 .EQ. nt_cas) THEN
-       it_cas2=it_cas1 
-       ELSE
-       it_cas2=it_cas1 + 1
-       ENDIF
-       time_cas1=(it_cas1-1)*pdt_cas
-       time_cas2=(it_cas2-1)*pdt_cas
-       print *,'it_cas1,it_cas2,time_cas1,time_cas2=',it_cas1,it_cas2,time_cas1,time_cas2
-
-       if (it_cas1 .gt. nt_cas) then
-        write(*,*) 'PB-stop: day, day_ju_ini_cas,it_cas1, it_cas2, timeit: '            &
-     &        ,day,day_ju_ini_cas,it_cas1,it_cas2,timeit
-        stop
-       endif
-
-! time interpolation:
-       IF (it_cas1 .EQ. it_cas2) THEN
-          frac=0.
-       ELSE
-          frac=(time_cas2-timeit)/(time_cas2-time_cas1)
-          frac=max(frac,0.0)
-       ENDIF
-
-       lat_prof_cas = lat_cas(it_cas2)                                       &
-     &          -frac*(lat_cas(it_cas2)-lat_cas(it_cas1)) 
-       sens_prof_cas = sens_cas(it_cas2)                                     &
-     &          -frac*(sens_cas(it_cas2)-sens_cas(it_cas1))
-       ts_prof_cas = ts_cas(it_cas2)                                         &
-     &          -frac*(ts_cas(it_cas2)-ts_cas(it_cas1))
-       ustar_prof_cas = ustar_cas(it_cas2)                                   &
-     &          -frac*(ustar_cas(it_cas2)-ustar_cas(it_cas1))
-
-       do k=1,nlev_cas
-        plev_prof_cas(k) = plev_cas(k,it_cas2)                               &
-     &          -frac*(plev_cas(k,it_cas2)-plev_cas(k,it_cas1))
-        t_prof_cas(k) = t_cas(k,it_cas2)                               &
-     &          -frac*(t_cas(k,it_cas2)-t_cas(k,it_cas1))
-        q_prof_cas(k) = q_cas(k,it_cas2)                               &
-     &          -frac*(q_cas(k,it_cas2)-q_cas(k,it_cas1))
-        u_prof_cas(k) = u_cas(k,it_cas2)                               &
-     &          -frac*(u_cas(k,it_cas2)-u_cas(k,it_cas1))
-        v_prof_cas(k) = v_cas(k,it_cas2)                               &
-     &          -frac*(v_cas(k,it_cas2)-v_cas(k,it_cas1))
-        ug_prof_cas(k) = ug_cas(k,it_cas2)                               &
-     &          -frac*(ug_cas(k,it_cas2)-ug_cas(k,it_cas1))
-        vg_prof_cas(k) = vg_cas(k,it_cas2)                               &
-     &          -frac*(vg_cas(k,it_cas2)-vg_cas(k,it_cas1))
-        vitw_prof_cas(k) = vitw_cas(k,it_cas2)                               &
-     &          -frac*(vitw_cas(k,it_cas2)-vitw_cas(k,it_cas1))
-        du_prof_cas(k) = du_cas(k,it_cas2)                                   &
-     &          -frac*(du_cas(k,it_cas2)-du_cas(k,it_cas1))
-        hu_prof_cas(k) = hu_cas(k,it_cas2)                                   &
-     &          -frac*(hu_cas(k,it_cas2)-hu_cas(k,it_cas1))
-        vu_prof_cas(k) = vu_cas(k,it_cas2)                                   &
-     &          -frac*(vu_cas(k,it_cas2)-vu_cas(k,it_cas1))
-        dv_prof_cas(k) = dv_cas(k,it_cas2)                                   &
-     &          -frac*(dv_cas(k,it_cas2)-dv_cas(k,it_cas1))
-        hv_prof_cas(k) = hv_cas(k,it_cas2)                                   &
-     &          -frac*(hv_cas(k,it_cas2)-hv_cas(k,it_cas1))
-        vv_prof_cas(k) = vv_cas(k,it_cas2)                                   &
-     &          -frac*(vv_cas(k,it_cas2)-vv_cas(k,it_cas1))
-        dt_prof_cas(k) = dt_cas(k,it_cas2)                                   &
-     &          -frac*(dt_cas(k,it_cas2)-dt_cas(k,it_cas1))
-        ht_prof_cas(k) = ht_cas(k,it_cas2)                                   &
-     &          -frac*(ht_cas(k,it_cas2)-ht_cas(k,it_cas1))
-        vt_prof_cas(k) = vt_cas(k,it_cas2)                                   &
-     &          -frac*(vt_cas(k,it_cas2)-vt_cas(k,it_cas1))
-        dtrad_prof_cas(k) = dtrad_cas(k,it_cas2)                                   &
-     &          -frac*(dtrad_cas(k,it_cas2)-dtrad_cas(k,it_cas1))
-        dq_prof_cas(k) = dq_cas(k,it_cas2)                                   &
-     &          -frac*(dq_cas(k,it_cas2)-dq_cas(k,it_cas1))
-        hq_prof_cas(k) = hq_cas(k,it_cas2)                                   &
-     &          -frac*(hq_cas(k,it_cas2)-hq_cas(k,it_cas1))
-        vq_prof_cas(k) = vq_cas(k,it_cas2)                                   &
-     &          -frac*(vq_cas(k,it_cas2)-vq_cas(k,it_cas1))
-       uw_prof_cas(k) = uw_cas(k,it_cas2)                                   &
-     &          -frac*(uw_cas(k,it_cas2)-uw_cas(k,it_cas1))
-       vw_prof_cas(k) = vw_cas(k,it_cas2)                                   &
-     &          -frac*(vw_cas(k,it_cas2)-vw_cas(k,it_cas1))
-       q1_prof_cas(k) = q1_cas(k,it_cas2)                                   &
-     &          -frac*(q1_cas(k,it_cas2)-q1_cas(k,it_cas1))
-       q2_prof_cas(k) = q2_cas(k,it_cas2)                                   &
-     &          -frac*(q2_cas(k,it_cas2)-q2_cas(k,it_cas1))
-        enddo
-
-        return
-        END SUBROUTINE interp_case_time2
+  ! inputs:
+  integer annee_ref
+  integer nt_cas,nlev_cas
+  real day, day1,day_cas
+  real ts_cas(nt_cas),ps_cas(nt_cas)
+  real plev_cas(nlev_cas,nt_cas)
+  real t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas)
+  real u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas)
+  real ug_cas(nlev_cas,nt_cas),vg_cas(nlev_cas,nt_cas)
+  real vitw_cas(nlev_cas,nt_cas)
+  real du_cas(nlev_cas,nt_cas),hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas)
+  real dv_cas(nlev_cas,nt_cas),hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas)
+  real dt_cas(nlev_cas,nt_cas),ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas)
+  real dtrad_cas(nlev_cas,nt_cas)
+  real dq_cas(nlev_cas,nt_cas),hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas)
+  real lat_cas(nt_cas)
+  real sens_cas(nt_cas)
+  real ustar_cas(nt_cas),uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas)
+  real q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas)
+
+  ! outputs:
+  real plev_prof_cas(nlev_cas)
+  real t_prof_cas(nlev_cas),q_prof_cas(nlev_cas)
+  real u_prof_cas(nlev_cas),v_prof_cas(nlev_cas)
+  real ug_prof_cas(nlev_cas),vg_prof_cas(nlev_cas)
+  real vitw_prof_cas(nlev_cas)
+  real du_prof_cas(nlev_cas),hu_prof_cas(nlev_cas),vu_prof_cas(nlev_cas)
+  real dv_prof_cas(nlev_cas),hv_prof_cas(nlev_cas),vv_prof_cas(nlev_cas)
+  real dt_prof_cas(nlev_cas),ht_prof_cas(nlev_cas),vt_prof_cas(nlev_cas)
+  real dtrad_prof_cas(nlev_cas)
+  real dq_prof_cas(nlev_cas),hq_prof_cas(nlev_cas),vq_prof_cas(nlev_cas)
+  real lat_prof_cas,sens_prof_cas,ts_prof_cas,ustar_prof_cas
+  real uw_prof_cas(nlev_cas),vw_prof_cas(nlev_cas),q1_prof_cas(nlev_cas),q2_prof_cas(nlev_cas)
+  ! local:
+  integer it_cas1, it_cas2,k
+  real timeit,time_cas1,time_cas2,frac
+
+
+  print*,'Check time',day1,day_ju_ini_cas,day_deb+1,pdt_cas
+
+  ! On teste si la date du cas AMMA est correcte.
+  ! C est pour memoire car en fait les fichiers .def
+  ! sont censes etre corrects.
+  ! A supprimer a terme (MPL 20150623)
+  !     if ((forcing_type.eq.10).and.(1.eq.0)) then
+  ! Check that initial day of the simulation consistent with AMMA case:
+  !      if (annee_ref.ne.2006) then
+  !       print*,'Pour AMMA, annee_ref doit etre 2006'
+  !       print*,'Changer annee_ref dans run.def'
+  !       stop
+  !      endif
+  !      if (annee_ref.eq.2006 .and. day1.lt.day_cas) then
+  !       print*,'AMMA a debute le 10 juillet 2006',day1,day_cas
+  !       print*,'Changer dayref dans run.def'
+  !       stop
+  !      endif
+  !      if (annee_ref.eq.2006 .and. day1.gt.day_cas+1) then
+  !       print*,'AMMA a fini le 11 juillet'
+  !       print*,'Changer dayref ou nday dans run.def'
+  !       stop
+  !      endif
+  !      endif
+
+  ! Determine timestep relative to the 1st day:
+  !       timeit=(day-day1)*86400.
+  !       if (annee_ref.eq.1992) then
+  !        timeit=(day-day_cas)*86400.
+  !       else
+  !        timeit=(day+61.-1.)*86400. ! 61 days between Nov01 and Dec31 1992
+  !       endif
+  timeit=(day-day_ju_ini_cas)*86400
+  print *,'day=',day
+  print *,'day_ju_ini_cas=',day_ju_ini_cas
+  print *,'pdt_cas=',pdt_cas
+  print *,'timeit=',timeit
+  print *,'nt_cas=',nt_cas
+
+  ! Determine the closest observation times:
+  !       it_cas1=INT(timeit/pdt_cas)+1
+  !       it_cas2=it_cas1 + 1
+  !       time_cas1=(it_cas1-1)*pdt_cas
+  !       time_cas2=(it_cas2-1)*pdt_cas
+
+  it_cas1=INT(timeit/pdt_cas)+1
+  IF (it_cas1 .EQ. nt_cas) THEN
+     it_cas2=it_cas1 
+  ELSE
+     it_cas2=it_cas1 + 1
+  ENDIF
+  time_cas1=(it_cas1-1)*pdt_cas
+  time_cas2=(it_cas2-1)*pdt_cas
+  print *,'it_cas1,it_cas2,time_cas1,time_cas2=',it_cas1,it_cas2,time_cas1,time_cas2
+
+  if (it_cas1 .gt. nt_cas) then
+     write(*,*) 'PB-stop: day, day_ju_ini_cas,it_cas1, it_cas2, timeit: '            &
+          ,day,day_ju_ini_cas,it_cas1,it_cas2,timeit
+     stop
+  endif
+
+  ! time interpolation:
+  IF (it_cas1 .EQ. it_cas2) THEN
+     frac=0.
+  ELSE
+     frac=(time_cas2-timeit)/(time_cas2-time_cas1)
+     frac=max(frac,0.0)
+  ENDIF
+
+  lat_prof_cas = lat_cas(it_cas2)                                       &
+       -frac*(lat_cas(it_cas2)-lat_cas(it_cas1)) 
+  sens_prof_cas = sens_cas(it_cas2)                                     &
+       -frac*(sens_cas(it_cas2)-sens_cas(it_cas1))
+  ts_prof_cas = ts_cas(it_cas2)                                         &
+       -frac*(ts_cas(it_cas2)-ts_cas(it_cas1))
+  ustar_prof_cas = ustar_cas(it_cas2)                                   &
+       -frac*(ustar_cas(it_cas2)-ustar_cas(it_cas1))
+
+  do k=1,nlev_cas
+     plev_prof_cas(k) = plev_cas(k,it_cas2)                               &
+          -frac*(plev_cas(k,it_cas2)-plev_cas(k,it_cas1))
+     t_prof_cas(k) = t_cas(k,it_cas2)                               &
+          -frac*(t_cas(k,it_cas2)-t_cas(k,it_cas1))
+     q_prof_cas(k) = q_cas(k,it_cas2)                               &
+          -frac*(q_cas(k,it_cas2)-q_cas(k,it_cas1))
+     u_prof_cas(k) = u_cas(k,it_cas2)                               &
+          -frac*(u_cas(k,it_cas2)-u_cas(k,it_cas1))
+     v_prof_cas(k) = v_cas(k,it_cas2)                               &
+          -frac*(v_cas(k,it_cas2)-v_cas(k,it_cas1))
+     ug_prof_cas(k) = ug_cas(k,it_cas2)                               &
+          -frac*(ug_cas(k,it_cas2)-ug_cas(k,it_cas1))
+     vg_prof_cas(k) = vg_cas(k,it_cas2)                               &
+          -frac*(vg_cas(k,it_cas2)-vg_cas(k,it_cas1))
+     vitw_prof_cas(k) = vitw_cas(k,it_cas2)                               &
+          -frac*(vitw_cas(k,it_cas2)-vitw_cas(k,it_cas1))
+     du_prof_cas(k) = du_cas(k,it_cas2)                                   &
+          -frac*(du_cas(k,it_cas2)-du_cas(k,it_cas1))
+     hu_prof_cas(k) = hu_cas(k,it_cas2)                                   &
+          -frac*(hu_cas(k,it_cas2)-hu_cas(k,it_cas1))
+     vu_prof_cas(k) = vu_cas(k,it_cas2)                                   &
+          -frac*(vu_cas(k,it_cas2)-vu_cas(k,it_cas1))
+     dv_prof_cas(k) = dv_cas(k,it_cas2)                                   &
+          -frac*(dv_cas(k,it_cas2)-dv_cas(k,it_cas1))
+     hv_prof_cas(k) = hv_cas(k,it_cas2)                                   &
+          -frac*(hv_cas(k,it_cas2)-hv_cas(k,it_cas1))
+     vv_prof_cas(k) = vv_cas(k,it_cas2)                                   &
+          -frac*(vv_cas(k,it_cas2)-vv_cas(k,it_cas1))
+     dt_prof_cas(k) = dt_cas(k,it_cas2)                                   &
+          -frac*(dt_cas(k,it_cas2)-dt_cas(k,it_cas1))
+     ht_prof_cas(k) = ht_cas(k,it_cas2)                                   &
+          -frac*(ht_cas(k,it_cas2)-ht_cas(k,it_cas1))
+     vt_prof_cas(k) = vt_cas(k,it_cas2)                                   &
+          -frac*(vt_cas(k,it_cas2)-vt_cas(k,it_cas1))
+     dtrad_prof_cas(k) = dtrad_cas(k,it_cas2)                                   &
+          -frac*(dtrad_cas(k,it_cas2)-dtrad_cas(k,it_cas1))
+     dq_prof_cas(k) = dq_cas(k,it_cas2)                                   &
+          -frac*(dq_cas(k,it_cas2)-dq_cas(k,it_cas1))
+     hq_prof_cas(k) = hq_cas(k,it_cas2)                                   &
+          -frac*(hq_cas(k,it_cas2)-hq_cas(k,it_cas1))
+     vq_prof_cas(k) = vq_cas(k,it_cas2)                                   &
+          -frac*(vq_cas(k,it_cas2)-vq_cas(k,it_cas1))
+     uw_prof_cas(k) = uw_cas(k,it_cas2)                                   &
+          -frac*(uw_cas(k,it_cas2)-uw_cas(k,it_cas1))
+     vw_prof_cas(k) = vw_cas(k,it_cas2)                                   &
+          -frac*(vw_cas(k,it_cas2)-vw_cas(k,it_cas1))
+     q1_prof_cas(k) = q1_cas(k,it_cas2)                                   &
+          -frac*(q1_cas(k,it_cas2)-q1_cas(k,it_cas1))
+     q2_prof_cas(k) = q2_cas(k,it_cas2)                                   &
+          -frac*(q2_cas(k,it_cas2)-q2_cas(k,it_cas1))
+  enddo
+
+  return
+END SUBROUTINE interp_case_time2
 
 !**********************************************************************************************
-        SUBROUTINE interp2_case_time(day,day1,annee_ref                           &
-!    &         ,year_cas,day_cas,nt_cas,pdt_forc,nlev_cas                         &
-     &         ,nt_cas,nlev_cas                                                   &
-     &         ,ts_cas,ps_cas,plev_cas,t_cas,theta_cas,thv_cas,thl_cas            &
-     &         ,qv_cas,ql_cas,qi_cas,u_cas,v_cas                                  &
-     &         ,ug_cas,vg_cas,vitw_cas,omega_cas,du_cas,hu_cas,vu_cas             &
-     &         ,dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dtrad_cas               &
-     &         ,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas                      &
-     &         ,lat_cas,sens_cas,ustar_cas                                        &
-     &         ,uw_cas,vw_cas,q1_cas,q2_cas,tke_cas                               &
-!
-     &         ,ts_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas               &
-     &         ,thv_prof_cas,thl_prof_cas,qv_prof_cas,ql_prof_cas,qi_prof_cas     &
-     &         ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas                     &
-     &         ,vitw_prof_cas,omega_prof_cas,du_prof_cas,hu_prof_cas,vu_prof_cas  &
-     &         ,dv_prof_cas,hv_prof_cas,vv_prof_cas,dt_prof_cas                   &
-     &         ,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas                &
-     &         ,hq_prof_cas,vq_prof_cas,dth_prof_cas,hth_prof_cas,vth_prof_cas    &
-     &         ,lat_prof_cas,sens_prof_cas                                        &
-     &         ,ustar_prof_cas,uw_prof_cas,vw_prof_cas,q1_prof_cas,q2_prof_cas,tke_prof_cas)
-          
-
-        implicit none
-
-!---------------------------------------------------------------------------------------
-! Time interpolation of a 2D field to the timestep corresponding to day
-!
-! day: current julian day (e.g. 717538.2)
-! day1: first day of the simulation
-! nt_cas: total nb of data in the forcing 
-! pdt_cas: total time interval (in sec) between 2 forcing data
-!---------------------------------------------------------------------------------------
+SUBROUTINE interp2_case_time(day,day1,annee_ref                           &
+     !    &         ,year_cas,day_cas,nt_cas,pdt_forc,nlev_cas                         &
+     ,nt_cas,nlev_cas                                                   &
+     ,ts_cas,ps_cas,plev_cas,t_cas,theta_cas,thv_cas,thl_cas            &
+     ,qv_cas,ql_cas,qi_cas,u_cas,v_cas                                  &
+     ,ug_cas,vg_cas,vitw_cas,omega_cas,du_cas,hu_cas,vu_cas             &
+     ,dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dtrad_cas               &
+     ,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas                      &
+     ,lat_cas,sens_cas,ustar_cas                                        &
+     ,uw_cas,vw_cas,q1_cas,q2_cas,tke_cas                               &
+     !
+     ,ts_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas               &
+     ,thv_prof_cas,thl_prof_cas,qv_prof_cas,ql_prof_cas,qi_prof_cas     &
+     ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas                     &
+     ,vitw_prof_cas,omega_prof_cas,du_prof_cas,hu_prof_cas,vu_prof_cas  &
+     ,dv_prof_cas,hv_prof_cas,vv_prof_cas,dt_prof_cas                   &
+     ,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas                &
+     ,hq_prof_cas,vq_prof_cas,dth_prof_cas,hth_prof_cas,vth_prof_cas    &
+     ,lat_prof_cas,sens_prof_cas                                        &
+     ,ustar_prof_cas,uw_prof_cas,vw_prof_cas,q1_prof_cas,q2_prof_cas,tke_prof_cas)
+
+
+  implicit none
+
+  !---------------------------------------------------------------------------------------
+  ! Time interpolation of a 2D field to the timestep corresponding to day
+  !
+  ! day: current julian day (e.g. 717538.2)
+  ! day1: first day of the simulation
+  ! nt_cas: total nb of data in the forcing 
+  ! pdt_cas: total time interval (in sec) between 2 forcing data
+  !---------------------------------------------------------------------------------------
 
 #include "compar1d.h"
 #include "date_cas.h"
 
-! inputs:
-        integer annee_ref
-        integer nt_cas,nlev_cas
-        real day, day1,day_cas
-        real ts_cas(nt_cas),ps_cas(nt_cas)
-        real plev_cas(nlev_cas,nt_cas)
-        real t_cas(nlev_cas,nt_cas),theta_cas(nlev_cas,nt_cas),thv_cas(nlev_cas,nt_cas),thl_cas(nlev_cas,nt_cas)
-        real qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas),qi_cas(nlev_cas,nt_cas)
-        real u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas)
-        real ug_cas(nlev_cas,nt_cas),vg_cas(nlev_cas,nt_cas)
-        real vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas)
-        real du_cas(nlev_cas,nt_cas),hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas)
-        real dv_cas(nlev_cas,nt_cas),hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas)
-        real dt_cas(nlev_cas,nt_cas),ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas)
-        real dth_cas(nlev_cas,nt_cas),hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas)
-        real dtrad_cas(nlev_cas,nt_cas)
-        real dq_cas(nlev_cas,nt_cas),hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas)
-        real lat_cas(nt_cas),sens_cas(nt_cas),tke_cas(nt_cas)
-        real ustar_cas(nt_cas),uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas)
-        real q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas)
-
-! outputs:
-        real plev_prof_cas(nlev_cas)
-        real t_prof_cas(nlev_cas),theta_prof_cas(nlev_cas),thl_prof_cas(nlev_cas),thv_prof_cas(nlev_cas)
-        real qv_prof_cas(nlev_cas),ql_prof_cas(nlev_cas),qi_prof_cas(nlev_cas)
-        real u_prof_cas(nlev_cas),v_prof_cas(nlev_cas)
-        real ug_prof_cas(nlev_cas),vg_prof_cas(nlev_cas)
-        real vitw_prof_cas(nlev_cas),omega_prof_cas(nlev_cas)
-        real du_prof_cas(nlev_cas),hu_prof_cas(nlev_cas),vu_prof_cas(nlev_cas)
-        real dv_prof_cas(nlev_cas),hv_prof_cas(nlev_cas),vv_prof_cas(nlev_cas)
-        real dt_prof_cas(nlev_cas),ht_prof_cas(nlev_cas),vt_prof_cas(nlev_cas)
-        real dth_prof_cas(nlev_cas),hth_prof_cas(nlev_cas),vth_prof_cas(nlev_cas)
-        real dtrad_prof_cas(nlev_cas)
-        real dq_prof_cas(nlev_cas),hq_prof_cas(nlev_cas),vq_prof_cas(nlev_cas)
-        real lat_prof_cas,sens_prof_cas,tke_prof_cas,ts_prof_cas,ustar_prof_cas
-        real uw_prof_cas(nlev_cas),vw_prof_cas(nlev_cas),q1_prof_cas(nlev_cas),q2_prof_cas(nlev_cas)
-! local:
-        integer it_cas1, it_cas2,k
-        real timeit,time_cas1,time_cas2,frac
-
-
-        print*,'Check time',day1,day_ju_ini_cas,day_deb+1,pdt_cas
-!       do k=1,nlev_cas
-!       print*,'debut de interp2_case_time, plev_cas=',k,plev_cas(k,1)
-!       enddo
-
-! On teste si la date du cas AMMA est correcte.
-! C est pour memoire car en fait les fichiers .def
-! sont censes etre corrects.
-! A supprimer a terme (MPL 20150623)
-!     if ((forcing_type.eq.10).and.(1.eq.0)) then
-! Check that initial day of the simulation consistent with AMMA case:
-!      if (annee_ref.ne.2006) then
-!       print*,'Pour AMMA, annee_ref doit etre 2006'
-!       print*,'Changer annee_ref dans run.def'
-!       stop
-!      endif
-!      if (annee_ref.eq.2006 .and. day1.lt.day_cas) then
-!       print*,'AMMA a debute le 10 juillet 2006',day1,day_cas
-!       print*,'Changer dayref dans run.def'
-!       stop
-!      endif
-!      if (annee_ref.eq.2006 .and. day1.gt.day_cas+1) then
-!       print*,'AMMA a fini le 11 juillet'
-!       print*,'Changer dayref ou nday dans run.def'
-!       stop
-!      endif
-!      endif
-
-! Determine timestep relative to the 1st day:
-!       timeit=(day-day1)*86400.
-!       if (annee_ref.eq.1992) then
-!        timeit=(day-day_cas)*86400.
-!       else
-!        timeit=(day+61.-1.)*86400. ! 61 days between Nov01 and Dec31 1992
-!       endif
-      timeit=(day-day_ju_ini_cas)*86400
-      print *,'day=',day
-      print *,'day_ju_ini_cas=',day_ju_ini_cas
-      print *,'pdt_cas=',pdt_cas
-      print *,'timeit=',timeit
-      print *,'nt_cas=',nt_cas
-
-! Determine the closest observation times:
-!       it_cas1=INT(timeit/pdt_cas)+1
-!       it_cas2=it_cas1 + 1
-!       time_cas1=(it_cas1-1)*pdt_cas
-!       time_cas2=(it_cas2-1)*pdt_cas
-
-       it_cas1=INT(timeit/pdt_cas)+1
-       IF (it_cas1 .EQ. nt_cas) THEN
-       it_cas2=it_cas1 
-       ELSE
-       it_cas2=it_cas1 + 1
-       ENDIF
-       time_cas1=(it_cas1-1)*pdt_cas
-       time_cas2=(it_cas2-1)*pdt_cas
-      print *,'timeit,pdt_cas,nt_cas=',timeit,pdt_cas,nt_cas
-      print *,'it_cas1,it_cas2,time_cas1,time_cas2=',it_cas1,it_cas2,time_cas1,time_cas2
-
-       if (it_cas1 .gt. nt_cas) then 
-        write(*,*) 'PB-stop: day, day_ju_ini_cas,it_cas1, it_cas2, timeit: '            &
-     &        ,day,day_ju_ini_cas,it_cas1,it_cas2,timeit
-        stop
-       endif
-
-! time interpolation:
-       IF (it_cas1 .EQ. it_cas2) THEN
-          frac=0.
-       ELSE
-          frac=(time_cas2-timeit)/(time_cas2-time_cas1)
-          frac=max(frac,0.0)
-       ENDIF
-
-       lat_prof_cas = lat_cas(it_cas2)                                   &
-     &          -frac*(lat_cas(it_cas2)-lat_cas(it_cas1)) 
-       sens_prof_cas = sens_cas(it_cas2)                                 &
-     &          -frac*(sens_cas(it_cas2)-sens_cas(it_cas1))
-       tke_prof_cas = tke_cas(it_cas2)                                   &
-     &          -frac*(tke_cas(it_cas2)-tke_cas(it_cas1))
-       ts_prof_cas = ts_cas(it_cas2)                                     &
-     &          -frac*(ts_cas(it_cas2)-ts_cas(it_cas1))
-       ustar_prof_cas = ustar_cas(it_cas2)                               &
-     &          -frac*(ustar_cas(it_cas2)-ustar_cas(it_cas1))
-
-       do k=1,nlev_cas
-        plev_prof_cas(k) = plev_cas(k,it_cas2)                           &     
-     &          -frac*(plev_cas(k,it_cas2)-plev_cas(k,it_cas1))
-        t_prof_cas(k) = t_cas(k,it_cas2)                                 &        
-     &          -frac*(t_cas(k,it_cas2)-t_cas(k,it_cas1))
-        print *,'k,frac,plev_cas1,plev_cas2=',k,frac,plev_cas(k,it_cas1),plev_cas(k,it_cas2)
-        theta_prof_cas(k) = theta_cas(k,it_cas2)                         &                      
-     &          -frac*(theta_cas(k,it_cas2)-theta_cas(k,it_cas1))
-        thv_prof_cas(k) = thv_cas(k,it_cas2)                             &          
-     &          -frac*(thv_cas(k,it_cas2)-thv_cas(k,it_cas1))
-        thl_prof_cas(k) = thl_cas(k,it_cas2)                             &              
-     &          -frac*(thl_cas(k,it_cas2)-thl_cas(k,it_cas1))
-        qv_prof_cas(k) = qv_cas(k,it_cas2)                               &
-     &          -frac*(qv_cas(k,it_cas2)-qv_cas(k,it_cas1))
-        ql_prof_cas(k) = ql_cas(k,it_cas2)                               &
-     &          -frac*(ql_cas(k,it_cas2)-ql_cas(k,it_cas1))
-        qi_prof_cas(k) = qi_cas(k,it_cas2)                               &
-     &          -frac*(qi_cas(k,it_cas2)-qi_cas(k,it_cas1))
-        u_prof_cas(k) = u_cas(k,it_cas2)                                 &
-     &          -frac*(u_cas(k,it_cas2)-u_cas(k,it_cas1))
-        v_prof_cas(k) = v_cas(k,it_cas2)                                 &
-     &          -frac*(v_cas(k,it_cas2)-v_cas(k,it_cas1))
-        ug_prof_cas(k) = ug_cas(k,it_cas2)                               &
-     &          -frac*(ug_cas(k,it_cas2)-ug_cas(k,it_cas1))
-        vg_prof_cas(k) = vg_cas(k,it_cas2)                               &
-     &          -frac*(vg_cas(k,it_cas2)-vg_cas(k,it_cas1))
-        vitw_prof_cas(k) = vitw_cas(k,it_cas2)                           &
-     &          -frac*(vitw_cas(k,it_cas2)-vitw_cas(k,it_cas1))
-        omega_prof_cas(k) = omega_cas(k,it_cas2)                         &
-     &          -frac*(omega_cas(k,it_cas2)-omega_cas(k,it_cas1))
-        du_prof_cas(k) = du_cas(k,it_cas2)                               &
-     &          -frac*(du_cas(k,it_cas2)-du_cas(k,it_cas1))
-        hu_prof_cas(k) = hu_cas(k,it_cas2)                               &
-     &          -frac*(hu_cas(k,it_cas2)-hu_cas(k,it_cas1))
-        vu_prof_cas(k) = vu_cas(k,it_cas2)                               &
-     &          -frac*(vu_cas(k,it_cas2)-vu_cas(k,it_cas1))
-        dv_prof_cas(k) = dv_cas(k,it_cas2)                               &
-     &          -frac*(dv_cas(k,it_cas2)-dv_cas(k,it_cas1))
-        hv_prof_cas(k) = hv_cas(k,it_cas2)                               &
-     &          -frac*(hv_cas(k,it_cas2)-hv_cas(k,it_cas1))
-        vv_prof_cas(k) = vv_cas(k,it_cas2)                               &
-     &          -frac*(vv_cas(k,it_cas2)-vv_cas(k,it_cas1))
-        dt_prof_cas(k) = dt_cas(k,it_cas2)                               &
-     &          -frac*(dt_cas(k,it_cas2)-dt_cas(k,it_cas1))
-        ht_prof_cas(k) = ht_cas(k,it_cas2)                               &
-     &          -frac*(ht_cas(k,it_cas2)-ht_cas(k,it_cas1))
-        vt_prof_cas(k) = vt_cas(k,it_cas2)                               &
-     &          -frac*(vt_cas(k,it_cas2)-vt_cas(k,it_cas1))
-        dth_prof_cas(k) = dth_cas(k,it_cas2)                             &
-     &          -frac*(dth_cas(k,it_cas2)-dth_cas(k,it_cas1))
-        hth_prof_cas(k) = hth_cas(k,it_cas2)                             &
-     &          -frac*(hth_cas(k,it_cas2)-hth_cas(k,it_cas1))
-        vth_prof_cas(k) = vth_cas(k,it_cas2)                             &
-     &          -frac*(vth_cas(k,it_cas2)-vth_cas(k,it_cas1))
-        dtrad_prof_cas(k) = dtrad_cas(k,it_cas2)                         &
-     &          -frac*(dtrad_cas(k,it_cas2)-dtrad_cas(k,it_cas1))
-        dq_prof_cas(k) = dq_cas(k,it_cas2)                               &
-     &          -frac*(dq_cas(k,it_cas2)-dq_cas(k,it_cas1))
-        hq_prof_cas(k) = hq_cas(k,it_cas2)                               &
-     &          -frac*(hq_cas(k,it_cas2)-hq_cas(k,it_cas1))
-        vq_prof_cas(k) = vq_cas(k,it_cas2)                               &
-     &          -frac*(vq_cas(k,it_cas2)-vq_cas(k,it_cas1))
-       uw_prof_cas(k) = uw_cas(k,it_cas2)                                &
-     &          -frac*(uw_cas(k,it_cas2)-uw_cas(k,it_cas1))
-       vw_prof_cas(k) = vw_cas(k,it_cas2)                                &
-     &          -frac*(vw_cas(k,it_cas2)-vw_cas(k,it_cas1))
-       q1_prof_cas(k) = q1_cas(k,it_cas2)                                &
-     &          -frac*(q1_cas(k,it_cas2)-q1_cas(k,it_cas1))
-       q2_prof_cas(k) = q2_cas(k,it_cas2)                                &
-     &          -frac*(q2_cas(k,it_cas2)-q2_cas(k,it_cas1))
-        enddo
-
-        return
-        END SUBROUTINE interp2_case_time
+  ! inputs:
+  integer annee_ref
+  integer nt_cas,nlev_cas
+  real day, day1,day_cas
+  real ts_cas(nt_cas),ps_cas(nt_cas)
+  real plev_cas(nlev_cas,nt_cas)
+  real t_cas(nlev_cas,nt_cas),theta_cas(nlev_cas,nt_cas),thv_cas(nlev_cas,nt_cas),thl_cas(nlev_cas,nt_cas)
+  real qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas),qi_cas(nlev_cas,nt_cas)
+  real u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas)
+  real ug_cas(nlev_cas,nt_cas),vg_cas(nlev_cas,nt_cas)
+  real vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas)
+  real du_cas(nlev_cas,nt_cas),hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas)
+  real dv_cas(nlev_cas,nt_cas),hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas)
+  real dt_cas(nlev_cas,nt_cas),ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas)
+  real dth_cas(nlev_cas,nt_cas),hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas)
+  real dtrad_cas(nlev_cas,nt_cas)
+  real dq_cas(nlev_cas,nt_cas),hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas)
+  real lat_cas(nt_cas),sens_cas(nt_cas),tke_cas(nt_cas)
+  real ustar_cas(nt_cas),uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas)
+  real q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas)
+
+  ! outputs:
+  real plev_prof_cas(nlev_cas)
+  real t_prof_cas(nlev_cas),theta_prof_cas(nlev_cas),thl_prof_cas(nlev_cas),thv_prof_cas(nlev_cas)
+  real qv_prof_cas(nlev_cas),ql_prof_cas(nlev_cas),qi_prof_cas(nlev_cas)
+  real u_prof_cas(nlev_cas),v_prof_cas(nlev_cas)
+  real ug_prof_cas(nlev_cas),vg_prof_cas(nlev_cas)
+  real vitw_prof_cas(nlev_cas),omega_prof_cas(nlev_cas)
+  real du_prof_cas(nlev_cas),hu_prof_cas(nlev_cas),vu_prof_cas(nlev_cas)
+  real dv_prof_cas(nlev_cas),hv_prof_cas(nlev_cas),vv_prof_cas(nlev_cas)
+  real dt_prof_cas(nlev_cas),ht_prof_cas(nlev_cas),vt_prof_cas(nlev_cas)
+  real dth_prof_cas(nlev_cas),hth_prof_cas(nlev_cas),vth_prof_cas(nlev_cas)
+  real dtrad_prof_cas(nlev_cas)
+  real dq_prof_cas(nlev_cas),hq_prof_cas(nlev_cas),vq_prof_cas(nlev_cas)
+  real lat_prof_cas,sens_prof_cas,tke_prof_cas,ts_prof_cas,ustar_prof_cas
+  real uw_prof_cas(nlev_cas),vw_prof_cas(nlev_cas),q1_prof_cas(nlev_cas),q2_prof_cas(nlev_cas)
+  ! local:
+  integer it_cas1, it_cas2,k
+  real timeit,time_cas1,time_cas2,frac
+
+
+  print*,'Check time',day1,day_ju_ini_cas,day_deb+1,pdt_cas
+  !       do k=1,nlev_cas
+  !       print*,'debut de interp2_case_time, plev_cas=',k,plev_cas(k,1)
+  !       enddo
+
+  ! On teste si la date du cas AMMA est correcte.
+  ! C est pour memoire car en fait les fichiers .def
+  ! sont censes etre corrects.
+  ! A supprimer a terme (MPL 20150623)
+  !     if ((forcing_type.eq.10).and.(1.eq.0)) then
+  ! Check that initial day of the simulation consistent with AMMA case:
+  !      if (annee_ref.ne.2006) then
+  !       print*,'Pour AMMA, annee_ref doit etre 2006'
+  !       print*,'Changer annee_ref dans run.def'
+  !       stop
+  !      endif
+  !      if (annee_ref.eq.2006 .and. day1.lt.day_cas) then
+  !       print*,'AMMA a debute le 10 juillet 2006',day1,day_cas
+  !       print*,'Changer dayref dans run.def'
+  !       stop
+  !      endif
+  !      if (annee_ref.eq.2006 .and. day1.gt.day_cas+1) then
+  !       print*,'AMMA a fini le 11 juillet'
+  !       print*,'Changer dayref ou nday dans run.def'
+  !       stop
+  !      endif
+  !      endif
+
+  ! Determine timestep relative to the 1st day:
+  !       timeit=(day-day1)*86400.
+  !       if (annee_ref.eq.1992) then
+  !        timeit=(day-day_cas)*86400.
+  !       else
+  !        timeit=(day+61.-1.)*86400. ! 61 days between Nov01 and Dec31 1992
+  !       endif
+  timeit=(day-day_ju_ini_cas)*86400
+  print *,'day=',day
+  print *,'day_ju_ini_cas=',day_ju_ini_cas
+  print *,'pdt_cas=',pdt_cas
+  print *,'timeit=',timeit
+  print *,'nt_cas=',nt_cas
+
+  ! Determine the closest observation times:
+  !       it_cas1=INT(timeit/pdt_cas)+1
+  !       it_cas2=it_cas1 + 1
+  !       time_cas1=(it_cas1-1)*pdt_cas
+  !       time_cas2=(it_cas2-1)*pdt_cas
+
+  it_cas1=INT(timeit/pdt_cas)+1
+  IF (it_cas1 .EQ. nt_cas) THEN
+     it_cas2=it_cas1 
+  ELSE
+     it_cas2=it_cas1 + 1
+  ENDIF
+  time_cas1=(it_cas1-1)*pdt_cas
+  time_cas2=(it_cas2-1)*pdt_cas
+  print *,'timeit,pdt_cas,nt_cas=',timeit,pdt_cas,nt_cas
+  print *,'it_cas1,it_cas2,time_cas1,time_cas2=',it_cas1,it_cas2,time_cas1,time_cas2
+
+  if (it_cas1 .gt. nt_cas) then 
+     write(*,*) 'PB-stop: day, day_ju_ini_cas,it_cas1, it_cas2, timeit: '            &
+          ,day,day_ju_ini_cas,it_cas1,it_cas2,timeit
+     stop
+  endif
+
+  ! time interpolation:
+  IF (it_cas1 .EQ. it_cas2) THEN
+     frac=0.
+  ELSE
+     frac=(time_cas2-timeit)/(time_cas2-time_cas1)
+     frac=max(frac,0.0)
+  ENDIF
+
+  lat_prof_cas = lat_cas(it_cas2)                                   &
+       -frac*(lat_cas(it_cas2)-lat_cas(it_cas1)) 
+  sens_prof_cas = sens_cas(it_cas2)                                 &
+       -frac*(sens_cas(it_cas2)-sens_cas(it_cas1))
+  tke_prof_cas = tke_cas(it_cas2)                                   &
+       -frac*(tke_cas(it_cas2)-tke_cas(it_cas1))
+  ts_prof_cas = ts_cas(it_cas2)                                     &
+       -frac*(ts_cas(it_cas2)-ts_cas(it_cas1))
+  ustar_prof_cas = ustar_cas(it_cas2)                               &
+       -frac*(ustar_cas(it_cas2)-ustar_cas(it_cas1))
+
+  do k=1,nlev_cas
+     plev_prof_cas(k) = plev_cas(k,it_cas2)                           &     
+          -frac*(plev_cas(k,it_cas2)-plev_cas(k,it_cas1))
+     t_prof_cas(k) = t_cas(k,it_cas2)                                 &        
+          -frac*(t_cas(k,it_cas2)-t_cas(k,it_cas1))
+     print *,'k,frac,plev_cas1,plev_cas2=',k,frac,plev_cas(k,it_cas1),plev_cas(k,it_cas2)
+     theta_prof_cas(k) = theta_cas(k,it_cas2)                         &                      
+          -frac*(theta_cas(k,it_cas2)-theta_cas(k,it_cas1))
+     thv_prof_cas(k) = thv_cas(k,it_cas2)                             &          
+          -frac*(thv_cas(k,it_cas2)-thv_cas(k,it_cas1))
+     thl_prof_cas(k) = thl_cas(k,it_cas2)                             &              
+          -frac*(thl_cas(k,it_cas2)-thl_cas(k,it_cas1))
+     qv_prof_cas(k) = qv_cas(k,it_cas2)                               &
+          -frac*(qv_cas(k,it_cas2)-qv_cas(k,it_cas1))
+     ql_prof_cas(k) = ql_cas(k,it_cas2)                               &
+          -frac*(ql_cas(k,it_cas2)-ql_cas(k,it_cas1))
+     qi_prof_cas(k) = qi_cas(k,it_cas2)                               &
+          -frac*(qi_cas(k,it_cas2)-qi_cas(k,it_cas1))
+     u_prof_cas(k) = u_cas(k,it_cas2)                                 &
+          -frac*(u_cas(k,it_cas2)-u_cas(k,it_cas1))
+     v_prof_cas(k) = v_cas(k,it_cas2)                                 &
+          -frac*(v_cas(k,it_cas2)-v_cas(k,it_cas1))
+     ug_prof_cas(k) = ug_cas(k,it_cas2)                               &
+          -frac*(ug_cas(k,it_cas2)-ug_cas(k,it_cas1))
+     vg_prof_cas(k) = vg_cas(k,it_cas2)                               &
+          -frac*(vg_cas(k,it_cas2)-vg_cas(k,it_cas1))
+     vitw_prof_cas(k) = vitw_cas(k,it_cas2)                           &
+          -frac*(vitw_cas(k,it_cas2)-vitw_cas(k,it_cas1))
+     omega_prof_cas(k) = omega_cas(k,it_cas2)                         &
+          -frac*(omega_cas(k,it_cas2)-omega_cas(k,it_cas1))
+     du_prof_cas(k) = du_cas(k,it_cas2)                               &
+          -frac*(du_cas(k,it_cas2)-du_cas(k,it_cas1))
+     hu_prof_cas(k) = hu_cas(k,it_cas2)                               &
+          -frac*(hu_cas(k,it_cas2)-hu_cas(k,it_cas1))
+     vu_prof_cas(k) = vu_cas(k,it_cas2)                               &
+          -frac*(vu_cas(k,it_cas2)-vu_cas(k,it_cas1))
+     dv_prof_cas(k) = dv_cas(k,it_cas2)                               &
+          -frac*(dv_cas(k,it_cas2)-dv_cas(k,it_cas1))
+     hv_prof_cas(k) = hv_cas(k,it_cas2)                               &
+          -frac*(hv_cas(k,it_cas2)-hv_cas(k,it_cas1))
+     vv_prof_cas(k) = vv_cas(k,it_cas2)                               &
+          -frac*(vv_cas(k,it_cas2)-vv_cas(k,it_cas1))
+     dt_prof_cas(k) = dt_cas(k,it_cas2)                               &
+          -frac*(dt_cas(k,it_cas2)-dt_cas(k,it_cas1))
+     ht_prof_cas(k) = ht_cas(k,it_cas2)                               &
+          -frac*(ht_cas(k,it_cas2)-ht_cas(k,it_cas1))
+     vt_prof_cas(k) = vt_cas(k,it_cas2)                               &
+          -frac*(vt_cas(k,it_cas2)-vt_cas(k,it_cas1))
+     dth_prof_cas(k) = dth_cas(k,it_cas2)                             &
+          -frac*(dth_cas(k,it_cas2)-dth_cas(k,it_cas1))
+     hth_prof_cas(k) = hth_cas(k,it_cas2)                             &
+          -frac*(hth_cas(k,it_cas2)-hth_cas(k,it_cas1))
+     vth_prof_cas(k) = vth_cas(k,it_cas2)                             &
+          -frac*(vth_cas(k,it_cas2)-vth_cas(k,it_cas1))
+     dtrad_prof_cas(k) = dtrad_cas(k,it_cas2)                         &
+          -frac*(dtrad_cas(k,it_cas2)-dtrad_cas(k,it_cas1))
+     dq_prof_cas(k) = dq_cas(k,it_cas2)                               &
+          -frac*(dq_cas(k,it_cas2)-dq_cas(k,it_cas1))
+     hq_prof_cas(k) = hq_cas(k,it_cas2)                               &
+          -frac*(hq_cas(k,it_cas2)-hq_cas(k,it_cas1))
+     vq_prof_cas(k) = vq_cas(k,it_cas2)                               &
+          -frac*(vq_cas(k,it_cas2)-vq_cas(k,it_cas1))
+     uw_prof_cas(k) = uw_cas(k,it_cas2)                                &
+          -frac*(uw_cas(k,it_cas2)-uw_cas(k,it_cas1))
+     vw_prof_cas(k) = vw_cas(k,it_cas2)                                &
+          -frac*(vw_cas(k,it_cas2)-vw_cas(k,it_cas1))
+     q1_prof_cas(k) = q1_cas(k,it_cas2)                                &
+          -frac*(q1_cas(k,it_cas2)-q1_cas(k,it_cas1))
+     q2_prof_cas(k) = q2_cas(k,it_cas2)                                &
+          -frac*(q2_cas(k,it_cas2)-q2_cas(k,it_cas1))
+  enddo
+
+  return
+END SUBROUTINE interp2_case_time
 
 !**********************************************************************************************
Index: LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/mod_1D_cases_read_std.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/mod_1D_cases_read_std.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/mod_1D_cases_read_std.F90	(revision 4446)
@@ -5,79 +5,79 @@
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!Declarations specifiques au cas standard
-        character*80 :: fich_cas
-! Discr?tisation 
-        integer nlev_cas, nt_cas
-
-
-!profils environnementaux
-        real, allocatable::  plev_cas(:,:),plevh_cas(:)
-        real, allocatable::  ap_cas(:),bp_cas(:)
-
-        real, allocatable::  z_cas(:,:),zh_cas(:)
-        real, allocatable::  t_cas(:,:),q_cas(:,:),qv_cas(:,:),ql_cas(:,:),qi_cas(:,:),rh_cas(:,:)
-        real, allocatable::  th_cas(:,:),thv_cas(:,:),thl_cas(:,:),rv_cas(:,:)
-        real, allocatable::  u_cas(:,:),v_cas(:,:),vitw_cas(:,:),omega_cas(:,:),tke_cas(:,:)
-
-!forcing
-        real, allocatable::  ht_cas(:,:),vt_cas(:,:),dt_cas(:,:),dtrad_cas(:,:)
-        real, allocatable::  hth_cas(:,:),vth_cas(:,:),dth_cas(:,:)
-        real, allocatable::  hq_cas(:,:),vq_cas(:,:),dq_cas(:,:)
-        real, allocatable::  hr_cas(:,:),vr_cas(:,:),dr_cas(:,:)
-        real, allocatable::  hu_cas(:,:),vu_cas(:,:),du_cas(:,:)
-        real, allocatable::  hv_cas(:,:),vv_cas(:,:),dv_cas(:,:)
-        real, allocatable::  ug_cas(:,:),vg_cas(:,:)
-        real, allocatable::  temp_nudg_cas(:,:),qv_nudg_cas(:,:),u_nudg_cas(:,:),v_nudg_cas(:,:)
-        real, allocatable::  invtau_temp_nudg_cas(:,:),invtau_qv_nudg_cas(:,:),invtau_u_nudg_cas(:,:),invtau_v_nudg_cas(:,:)
-        real, allocatable::  lat_cas(:),sens_cas(:),ts_cas(:),ps_cas(:),ustar_cas(:)
-        real, allocatable::  uw_cas(:,:),vw_cas(:,:),q1_cas(:,:),q2_cas(:,:),tkes_cas(:)
-
-!champs interpoles
-        real, allocatable::  plev_prof_cas(:)
-        real, allocatable::  t_prof_cas(:)
-        real, allocatable::  theta_prof_cas(:)
-        real, allocatable::  thl_prof_cas(:)
-        real, allocatable::  thv_prof_cas(:)
-        real, allocatable::  q_prof_cas(:)
-        real, allocatable::  qv_prof_cas(:)
-        real, allocatable::  ql_prof_cas(:)
-        real, allocatable::  qi_prof_cas(:)
-        real, allocatable::  rh_prof_cas(:)
-        real, allocatable::  rv_prof_cas(:)
-        real, allocatable::  u_prof_cas(:)
-        real, allocatable::  v_prof_cas(:)        
-        real, allocatable::  vitw_prof_cas(:)
-        real, allocatable::  omega_prof_cas(:)
-        real, allocatable::  tke_prof_cas(:)
-        real, allocatable::  ug_prof_cas(:)
-        real, allocatable::  vg_prof_cas(:)
-        real, allocatable::  temp_nudg_prof_cas(:),qv_nudg_prof_cas(:),u_nudg_prof_cas(:),v_nudg_prof_cas(:)
-        real, allocatable::  invtau_temp_nudg_prof_cas(:),invtau_qv_nudg_prof_cas(:),invtau_u_nudg_prof_cas(:),invtau_v_nudg_prof_cas(:)
-
-        real, allocatable::  ht_prof_cas(:)
-        real, allocatable::  hth_prof_cas(:)
-        real, allocatable::  hq_prof_cas(:)
-        real, allocatable::  vt_prof_cas(:)
-        real, allocatable::  vth_prof_cas(:)
-        real, allocatable::  vq_prof_cas(:)
-        real, allocatable::  dt_prof_cas(:)
-        real, allocatable::  dth_prof_cas(:)
-        real, allocatable::  dtrad_prof_cas(:)
-        real, allocatable::  dq_prof_cas(:)
-        real, allocatable::  hu_prof_cas(:)
-        real, allocatable::  hv_prof_cas(:)
-        real, allocatable::  vu_prof_cas(:)
-        real, allocatable::  vv_prof_cas(:)
-        real, allocatable::  du_prof_cas(:)
-        real, allocatable::  dv_prof_cas(:)
-        real, allocatable::  uw_prof_cas(:)
-        real, allocatable::  vw_prof_cas(:)
-        real, allocatable::  q1_prof_cas(:)
-        real, allocatable::  q2_prof_cas(:)
-
-
-        real o3_cas,lat_prof_cas,sens_prof_cas,ts_prof_cas,ps_prof_cas,ustar_prof_cas,tkes_prof_cas
-        real orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough,rugos_cas,sand_cas,clay_cas
-      
+  !Declarations specifiques au cas standard
+  character*80 :: fich_cas
+  ! Discr?tisation 
+  integer nlev_cas, nt_cas
+
+
+  !profils environnementaux
+  real, allocatable::  plev_cas(:,:),plevh_cas(:)
+  real, allocatable::  ap_cas(:),bp_cas(:)
+
+  real, allocatable::  z_cas(:,:),zh_cas(:)
+  real, allocatable::  t_cas(:,:),q_cas(:,:),qv_cas(:,:),ql_cas(:,:),qi_cas(:,:),rh_cas(:,:)
+  real, allocatable::  th_cas(:,:),thv_cas(:,:),thl_cas(:,:),rv_cas(:,:)
+  real, allocatable::  u_cas(:,:),v_cas(:,:),vitw_cas(:,:),omega_cas(:,:),tke_cas(:,:)
+
+  !forcing
+  real, allocatable::  ht_cas(:,:),vt_cas(:,:),dt_cas(:,:),dtrad_cas(:,:)
+  real, allocatable::  hth_cas(:,:),vth_cas(:,:),dth_cas(:,:)
+  real, allocatable::  hq_cas(:,:),vq_cas(:,:),dq_cas(:,:)
+  real, allocatable::  hr_cas(:,:),vr_cas(:,:),dr_cas(:,:)
+  real, allocatable::  hu_cas(:,:),vu_cas(:,:),du_cas(:,:)
+  real, allocatable::  hv_cas(:,:),vv_cas(:,:),dv_cas(:,:)
+  real, allocatable::  ug_cas(:,:),vg_cas(:,:)
+  real, allocatable::  temp_nudg_cas(:,:),qv_nudg_cas(:,:),u_nudg_cas(:,:),v_nudg_cas(:,:)
+  real, allocatable::  invtau_temp_nudg_cas(:,:),invtau_qv_nudg_cas(:,:),invtau_u_nudg_cas(:,:),invtau_v_nudg_cas(:,:)
+  real, allocatable::  lat_cas(:),sens_cas(:),tskin_cas(:),ts_cas(:),ps_cas(:),ustar_cas(:)
+  real, allocatable::  uw_cas(:,:),vw_cas(:,:),q1_cas(:,:),q2_cas(:,:),tkes_cas(:)
+
+  !champs interpoles
+  real, allocatable::  plev_prof_cas(:)
+  real, allocatable::  t_prof_cas(:)
+  real, allocatable::  theta_prof_cas(:)
+  real, allocatable::  thl_prof_cas(:)
+  real, allocatable::  thv_prof_cas(:)
+  real, allocatable::  q_prof_cas(:)
+  real, allocatable::  qv_prof_cas(:)
+  real, allocatable::  ql_prof_cas(:)
+  real, allocatable::  qi_prof_cas(:)
+  real, allocatable::  rh_prof_cas(:)
+  real, allocatable::  rv_prof_cas(:)
+  real, allocatable::  u_prof_cas(:)
+  real, allocatable::  v_prof_cas(:)        
+  real, allocatable::  vitw_prof_cas(:)
+  real, allocatable::  omega_prof_cas(:)
+  real, allocatable::  tke_prof_cas(:)
+  real, allocatable::  ug_prof_cas(:)
+  real, allocatable::  vg_prof_cas(:)
+  real, allocatable::  temp_nudg_prof_cas(:),qv_nudg_prof_cas(:),u_nudg_prof_cas(:),v_nudg_prof_cas(:)
+  real, allocatable::  invtau_temp_nudg_prof_cas(:),invtau_qv_nudg_prof_cas(:),invtau_u_nudg_prof_cas(:),invtau_v_nudg_prof_cas(:)
+
+  real, allocatable::  ht_prof_cas(:)
+  real, allocatable::  hth_prof_cas(:)
+  real, allocatable::  hq_prof_cas(:)
+  real, allocatable::  vt_prof_cas(:)
+  real, allocatable::  vth_prof_cas(:)
+  real, allocatable::  vq_prof_cas(:)
+  real, allocatable::  dt_prof_cas(:)
+  real, allocatable::  dth_prof_cas(:)
+  real, allocatable::  dtrad_prof_cas(:)
+  real, allocatable::  dq_prof_cas(:)
+  real, allocatable::  hu_prof_cas(:)
+  real, allocatable::  hv_prof_cas(:)
+  real, allocatable::  vu_prof_cas(:)
+  real, allocatable::  vv_prof_cas(:)
+  real, allocatable::  du_prof_cas(:)
+  real, allocatable::  dv_prof_cas(:)
+  real, allocatable::  uw_prof_cas(:)
+  real, allocatable::  vw_prof_cas(:)
+  real, allocatable::  q1_prof_cas(:)
+  real, allocatable::  q2_prof_cas(:)
+
+
+  real o3_cas,lat_prof_cas,sens_prof_cas,ts_prof_cas,tskin_prof_cas,ps_prof_cas,ustar_prof_cas,tkes_prof_cas
+  real orog_cas,albedo_cas,emiss_cas,q_skin_cas,mom_rough,heat_rough,rugos_cas,sand_cas,clay_cas
+
 
 
@@ -85,1148 +85,1131 @@
 
 
-!**********************************************************************************************
-SUBROUTINE read_SCM_cas
-      implicit none
+  !**********************************************************************************************
+  SUBROUTINE read_SCM_cas
+    use netcdf, only: nf90_get_var
+    implicit none
 
 #include "netcdf.inc"
 #include "date_cas.h"
 
-      INTEGER nid,rid,ierr
-      INTEGER ii,jj,timeid
-      REAL, ALLOCATABLE :: time_val(:)
-
-      fich_cas='cas.nc'
-      print*,'fich_cas ',fich_cas
-      ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
-      print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
-      if (ierr.NE.NF_NOERR) then
-         write(*,*) 'ERROR: GROS Pb opening forcings nc file '
-         write(*,*) NF_STRERROR(ierr)
-         stop ""
-      endif
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lat',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension lat'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,ii)
-      print*,'OK1 read2: nid,rid,lat',nid,rid,ii
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lon',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension lon'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,jj)
-      print*,'OK2 read2: nid,rid,lat',nid,rid,jj
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'lev',rid)
-      IF (ierr.NE.NF_NOERR) THEN
-         print*, 'Oh probleme lecture dimension nlev'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,nlev_cas)
-      print*,'OK3 read2: nid,rid,nlev_cas',nid,rid,nlev_cas
-      IF ( .NOT. ( nlev_cas > 10 .AND. nlev_cas < 200000 )) THEN
-              print*,'Valeur de nlev_cas peu probable'
-              STOP
-      ENDIF
-!.......................................................................
-      ierr=NF_INQ_DIMID(nid,'time',rid)
-      nt_cas=0
-      IF (ierr.NE.NF_NOERR) THEN
-        stop 'Oh probleme lecture dimension time'
-      ENDIF
-      ierr=NF_INQ_DIMLEN(nid,rid,nt_cas)
-      print*,'OK4 read2: nid,rid,nt_cas',nid,rid,nt_cas
-! Lecture de l'axe des temps
-      print*,'LECTURE DU TEMPS'
-      ierr=NF_INQ_VARID(nid,'time',timeid)
-         if(ierr/=NF_NOERR) then
-           print *,'Variable time manquante dans cas.nc:'
-           ierr=NF_NOERR
-         else
-                 allocate(time_val(nt_cas))
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,timeid,time_val)
-#else
-           ierr = NF_GET_VAR_REAL(nid,timeid,time_val)
-#endif
-           if(ierr/=NF_NOERR) then
-              print *,'Pb a la lecture de time cas.nc: '
-           endif
-   endif
-   IF (nt_cas>1) THEN
-           pdt_cas=time_val(2)-time_val(1)
-   ELSE
-           pdt_cas=0.
-   ENDIF
+    INTEGER nid,rid,ierr
+    INTEGER ii,jj,timeid
+    REAL, ALLOCATABLE :: time_val(:)
+
+    fich_cas='cas.nc'
+    print*,'fich_cas ',fich_cas
+    ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
+    print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
+    if (ierr.NE.NF_NOERR) then
+       write(*,*) 'ERROR: GROS Pb opening forcings nc file '
+       write(*,*) NF_STRERROR(ierr)
+       stop ""
+    endif
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lat',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension lat'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,ii)
+    print*,'OK1 read_SCM_cas: nid,rid,lat',nid,rid,ii
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lon',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension lon'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,jj)
+    print*,'OK2 read_SCM_cas: nid,rid,lat',nid,rid,jj
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'lev',rid)
+    IF (ierr.NE.NF_NOERR) THEN
+       print*, 'Oh probleme lecture dimension nlev'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,nlev_cas)
+    print*,'OK3 read_SCM_cas: nid,rid,nlev_cas',nid,rid,nlev_cas
+    IF ( .NOT. ( nlev_cas > 10 .AND. nlev_cas < 200000 )) THEN
+       print*,'Valeur de nlev_cas peu probable'
+       STOP
+    ENDIF
+    !.......................................................................
+    ierr=NF_INQ_DIMID(nid,'time',rid)
+    nt_cas=0
+    IF (ierr.NE.NF_NOERR) THEN
+       stop 'Oh probleme lecture dimension time'
+    ENDIF
+    ierr=NF_INQ_DIMLEN(nid,rid,nt_cas)
+    print*,'OK4 read_SCM_cas: nid,rid,nt_cas',nid,rid,nt_cas
+    ! Lecture de l'axe des temps
+    print*,'LECTURE DU TEMPS'
+    ierr=NF_INQ_VARID(nid,'time',timeid)
+    if(ierr/=NF_NOERR) then
+       print *,'Variable time manquante dans cas.nc:'
+       ierr=NF_NOERR
+    else
+       allocate(time_val(nt_cas))
+       ierr = NF90_GET_VAR(nid,timeid,time_val)
+       if(ierr/=NF_NOERR) then
+          print *,'A Pb a la lecture de time cas.nc: '
+       endif
+    endif
+    IF (nt_cas>1) THEN
+       pdt_cas=time_val(2)-time_val(1)
+    ELSE
+       pdt_cas=0.
+    ENDIF
 
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!profils moyens:
-        allocate(plev_cas(nlev_cas,nt_cas),plevh_cas(nlev_cas+1))        
-        allocate(z_cas(nlev_cas,nt_cas),zh_cas(nlev_cas+1))
-        allocate(ap_cas(nlev_cas+1),bp_cas(nt_cas+1))
-        allocate(t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas),qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas), &
-             qi_cas(nlev_cas,nt_cas),rh_cas(nlev_cas,nt_cas))
-        allocate(th_cas(nlev_cas,nt_cas),thl_cas(nlev_cas,nt_cas),thv_cas(nlev_cas,nt_cas),rv_cas(nlev_cas,nt_cas))
-        allocate(u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas),vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas))
-        allocate(tke_cas(nlev_cas,nt_cas))
-!forcing
-        allocate(ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas),dt_cas(nlev_cas,nt_cas),dtrad_cas(nlev_cas,nt_cas))
-        allocate(hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas),dq_cas(nlev_cas,nt_cas))
-        allocate(hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas),dth_cas(nlev_cas,nt_cas))
-        allocate(hr_cas(nlev_cas,nt_cas),vr_cas(nlev_cas,nt_cas),dr_cas(nlev_cas,nt_cas))
-        allocate(hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas),du_cas(nlev_cas,nt_cas))
-        allocate(hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas),dv_cas(nlev_cas,nt_cas))
-        allocate(ug_cas(nlev_cas,nt_cas),vg_cas(nlev_cas,nt_cas))
-        allocate(temp_nudg_cas(nlev_cas,nt_cas),qv_nudg_cas(nlev_cas,nt_cas))
-        allocate(u_nudg_cas(nlev_cas,nt_cas),v_nudg_cas(nlev_cas,nt_cas))
-        allocate(invtau_temp_nudg_cas(nlev_cas,nt_cas),invtau_qv_nudg_cas(nlev_cas,nt_cas))
-        allocate(invtau_u_nudg_cas(nlev_cas,nt_cas),invtau_v_nudg_cas(nlev_cas,nt_cas))
-        allocate(lat_cas(nt_cas),sens_cas(nt_cas),ts_cas(nt_cas),ps_cas(nt_cas),ustar_cas(nt_cas),tkes_cas(nt_cas))
-        allocate(uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas),q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas))
-
-
-
-!champs interpoles
-        allocate(plev_prof_cas(nlev_cas))
-        allocate(t_prof_cas(nlev_cas))
-        allocate(theta_prof_cas(nlev_cas))
-        allocate(thl_prof_cas(nlev_cas))
-        allocate(thv_prof_cas(nlev_cas))
-        allocate(q_prof_cas(nlev_cas))
-        allocate(qv_prof_cas(nlev_cas))
-        allocate(ql_prof_cas(nlev_cas))
-        allocate(qi_prof_cas(nlev_cas))
-        allocate(rh_prof_cas(nlev_cas))
-        allocate(rv_prof_cas(nlev_cas))
-        allocate(u_prof_cas(nlev_cas))
-        allocate(v_prof_cas(nlev_cas))
-        allocate(vitw_prof_cas(nlev_cas))
-        allocate(omega_prof_cas(nlev_cas))
-        allocate(tke_prof_cas(nlev_cas))
-        allocate(ug_prof_cas(nlev_cas))
-        allocate(vg_prof_cas(nlev_cas))
-        allocate(temp_nudg_prof_cas(nlev_cas),qv_nudg_prof_cas(nlev_cas))
-        allocate(u_nudg_prof_cas(nlev_cas),v_nudg_prof_cas(nlev_cas))
-        allocate(invtau_temp_nudg_prof_cas(nlev_cas),invtau_qv_nudg_prof_cas(nlev_cas))
-        allocate(invtau_u_nudg_prof_cas(nlev_cas),invtau_v_nudg_prof_cas(nlev_cas))
-        allocate(ht_prof_cas(nlev_cas))
-        allocate(hth_prof_cas(nlev_cas))
-        allocate(hq_prof_cas(nlev_cas))
-        allocate(hu_prof_cas(nlev_cas))
-        allocate(hv_prof_cas(nlev_cas))
-        allocate(vt_prof_cas(nlev_cas))
-        allocate(vth_prof_cas(nlev_cas))
-        allocate(vq_prof_cas(nlev_cas))
-        allocate(vu_prof_cas(nlev_cas))
-        allocate(vv_prof_cas(nlev_cas))
-        allocate(dt_prof_cas(nlev_cas))
-        allocate(dth_prof_cas(nlev_cas))
-        allocate(dtrad_prof_cas(nlev_cas))
-        allocate(dq_prof_cas(nlev_cas))
-        allocate(du_prof_cas(nlev_cas))
-        allocate(dv_prof_cas(nlev_cas))
-        allocate(uw_prof_cas(nlev_cas))
-        allocate(vw_prof_cas(nlev_cas))
-        allocate(q1_prof_cas(nlev_cas))
-        allocate(q2_prof_cas(nlev_cas))
-
-        print*,'Allocations OK'
-        CALL read_SCM (nid,nlev_cas,nt_cas,                                                                     &
-     &     ap_cas,bp_cas,z_cas,plev_cas,zh_cas,plevh_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,                   &
-     &     ql_cas,qi_cas,rh_cas,rv_cas,u_cas,v_cas,vitw_cas,omega_cas,tke_cas,ug_cas,vg_cas,                            &
-     &     temp_nudg_cas,qv_nudg_cas,u_nudg_cas,v_nudg_cas,                                                     &
-     &     invtau_temp_nudg_cas,invtau_qv_nudg_cas,invtau_u_nudg_cas,invtau_v_nudg_cas,                         &
-     &     du_cas,hu_cas,vu_cas,                                                                                &
-     &     dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas,               &
-     &     dr_cas,hr_cas,vr_cas,dtrad_cas,sens_cas,lat_cas,ts_cas,ps_cas,ustar_cas,tkes_cas,                      &
-     &     uw_cas,vw_cas,q1_cas,q2_cas,orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough, &
-     &     o3_cas,rugos_cas,clay_cas,sand_cas)
-        print*,'read_SCM cas OK'
-        do ii=1,nlev_cas
-        print*,'apres read2_SCM, plev_cas=',ii,plev_cas(ii,1)
-        !print*,'apres read_SCM, plev_cas=',ii,omega_cas(ii,nt_cas/2+1)
-        enddo
-
-
-END SUBROUTINE read_SCM_cas
+    !profils moyens:
+    allocate(plev_cas(nlev_cas,nt_cas),plevh_cas(nlev_cas+1))        
+    allocate(z_cas(nlev_cas,nt_cas),zh_cas(nlev_cas+1))
+    allocate(ap_cas(nlev_cas+1),bp_cas(nt_cas+1))
+    allocate(t_cas(nlev_cas,nt_cas),q_cas(nlev_cas,nt_cas),qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas), &
+         qi_cas(nlev_cas,nt_cas),rh_cas(nlev_cas,nt_cas))
+    allocate(th_cas(nlev_cas,nt_cas),thl_cas(nlev_cas,nt_cas),thv_cas(nlev_cas,nt_cas),rv_cas(nlev_cas,nt_cas))
+    allocate(u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas),vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas))
+    allocate(tke_cas(nlev_cas,nt_cas))
+    !forcing
+    allocate(ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas),dt_cas(nlev_cas,nt_cas),dtrad_cas(nlev_cas,nt_cas))
+    allocate(hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas),dq_cas(nlev_cas,nt_cas))
+    allocate(hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas),dth_cas(nlev_cas,nt_cas))
+    allocate(hr_cas(nlev_cas,nt_cas),vr_cas(nlev_cas,nt_cas),dr_cas(nlev_cas,nt_cas))
+    allocate(hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas),du_cas(nlev_cas,nt_cas))
+    allocate(hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas),dv_cas(nlev_cas,nt_cas))
+    allocate(ug_cas(nlev_cas,nt_cas),vg_cas(nlev_cas,nt_cas))
+    allocate(temp_nudg_cas(nlev_cas,nt_cas),qv_nudg_cas(nlev_cas,nt_cas))
+    allocate(u_nudg_cas(nlev_cas,nt_cas),v_nudg_cas(nlev_cas,nt_cas))
+    allocate(invtau_temp_nudg_cas(nlev_cas,nt_cas),invtau_qv_nudg_cas(nlev_cas,nt_cas))
+    allocate(invtau_u_nudg_cas(nlev_cas,nt_cas),invtau_v_nudg_cas(nlev_cas,nt_cas))
+    allocate(lat_cas(nt_cas),sens_cas(nt_cas),ts_cas(nt_cas),tskin_cas(nt_cas),ps_cas(nt_cas),ustar_cas(nt_cas),tkes_cas(nt_cas))
+    allocate(uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas),q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas))
+
+
+
+    !champs interpoles
+    allocate(plev_prof_cas(nlev_cas))
+    allocate(t_prof_cas(nlev_cas))
+    allocate(theta_prof_cas(nlev_cas))
+    allocate(thl_prof_cas(nlev_cas))
+    allocate(thv_prof_cas(nlev_cas))
+    allocate(q_prof_cas(nlev_cas))
+    allocate(qv_prof_cas(nlev_cas))
+    allocate(ql_prof_cas(nlev_cas))
+    allocate(qi_prof_cas(nlev_cas))
+    allocate(rh_prof_cas(nlev_cas))
+    allocate(rv_prof_cas(nlev_cas))
+    allocate(u_prof_cas(nlev_cas))
+    allocate(v_prof_cas(nlev_cas))
+    allocate(vitw_prof_cas(nlev_cas))
+    allocate(omega_prof_cas(nlev_cas))
+    allocate(tke_prof_cas(nlev_cas))
+    allocate(ug_prof_cas(nlev_cas))
+    allocate(vg_prof_cas(nlev_cas))
+    allocate(temp_nudg_prof_cas(nlev_cas),qv_nudg_prof_cas(nlev_cas))
+    allocate(u_nudg_prof_cas(nlev_cas),v_nudg_prof_cas(nlev_cas))
+    allocate(invtau_temp_nudg_prof_cas(nlev_cas),invtau_qv_nudg_prof_cas(nlev_cas))
+    allocate(invtau_u_nudg_prof_cas(nlev_cas),invtau_v_nudg_prof_cas(nlev_cas))
+    allocate(ht_prof_cas(nlev_cas))
+    allocate(hth_prof_cas(nlev_cas))
+    allocate(hq_prof_cas(nlev_cas))
+    allocate(hu_prof_cas(nlev_cas))
+    allocate(hv_prof_cas(nlev_cas))
+    allocate(vt_prof_cas(nlev_cas))
+    allocate(vth_prof_cas(nlev_cas))
+    allocate(vq_prof_cas(nlev_cas))
+    allocate(vu_prof_cas(nlev_cas))
+    allocate(vv_prof_cas(nlev_cas))
+    allocate(dt_prof_cas(nlev_cas))
+    allocate(dth_prof_cas(nlev_cas))
+    allocate(dtrad_prof_cas(nlev_cas))
+    allocate(dq_prof_cas(nlev_cas))
+    allocate(du_prof_cas(nlev_cas))
+    allocate(dv_prof_cas(nlev_cas))
+    allocate(uw_prof_cas(nlev_cas))
+    allocate(vw_prof_cas(nlev_cas))
+    allocate(q1_prof_cas(nlev_cas))
+    allocate(q2_prof_cas(nlev_cas))
+
+    print*,'Allocations OK'
+    CALL read_SCM (nid,nlev_cas,nt_cas,                                                                     &
+         ap_cas,bp_cas,z_cas,plev_cas,zh_cas,plevh_cas,t_cas,th_cas,thv_cas,thl_cas,qv_cas,                   &
+         ql_cas,qi_cas,rh_cas,rv_cas,u_cas,v_cas,vitw_cas,omega_cas,tke_cas,ug_cas,vg_cas,                            &
+         temp_nudg_cas,qv_nudg_cas,u_nudg_cas,v_nudg_cas,                                                     &
+         invtau_temp_nudg_cas,invtau_qv_nudg_cas,invtau_u_nudg_cas,invtau_v_nudg_cas,                         &
+         du_cas,hu_cas,vu_cas,                                                                                &
+         dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas,               &
+         dr_cas,hr_cas,vr_cas,dtrad_cas,sens_cas,lat_cas,ts_cas,tskin_cas,ps_cas,ustar_cas,tkes_cas,            &
+         uw_cas,vw_cas,q1_cas,q2_cas,orog_cas,albedo_cas,emiss_cas,q_skin_cas,mom_rough,heat_rough, &
+         o3_cas,rugos_cas,clay_cas,sand_cas)
+    print*,'read_SCM cas OK'
+    do ii=1,nlev_cas
+       print*,'apres read_SCM_cas, plev_cas=',ii,plev_cas(ii,1)
+       !print*,'apres read_SCM, plev_cas=',ii,omega_cas(ii,nt_cas/2+1)
+    enddo
+
+
+  END SUBROUTINE read_SCM_cas
 
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-SUBROUTINE deallocate2_1D_cases
-!profils environnementaux:
-        deallocate(plev_cas,plevh_cas)
-        
-        deallocate(z_cas,zh_cas)
-        deallocate(ap_cas,bp_cas)
-        deallocate(t_cas,q_cas,qv_cas,ql_cas,qi_cas,rh_cas)
-        deallocate(th_cas,thl_cas,thv_cas,rv_cas)
-        deallocate(u_cas,v_cas,vitw_cas,omega_cas,tke_cas)
-        
-!forcing
-        deallocate(ht_cas,vt_cas,dt_cas,dtrad_cas)
-        deallocate(hq_cas,vq_cas,dq_cas)
-        deallocate(hth_cas,vth_cas,dth_cas)
-        deallocate(hr_cas,vr_cas,dr_cas)
-        deallocate(hu_cas,vu_cas,du_cas)
-        deallocate(hv_cas,vv_cas,dv_cas)
-        deallocate(ug_cas)
-        deallocate(vg_cas)
-        deallocate(lat_cas,sens_cas,ts_cas,ps_cas,ustar_cas,tkes_cas,uw_cas,vw_cas,q1_cas,q2_cas)
-
-!champs interpoles
-        deallocate(plev_prof_cas)
-        deallocate(t_prof_cas)
-        deallocate(theta_prof_cas)
-        deallocate(thl_prof_cas)
-        deallocate(thv_prof_cas)
-        deallocate(q_prof_cas)
-        deallocate(qv_prof_cas)
-        deallocate(ql_prof_cas)
-        deallocate(qi_prof_cas)
-        deallocate(rh_prof_cas)
-        deallocate(rv_prof_cas)
-        deallocate(u_prof_cas)
-        deallocate(v_prof_cas)
-        deallocate(vitw_prof_cas)
-        deallocate(omega_prof_cas)
-        deallocate(tke_prof_cas)
-        deallocate(ug_prof_cas)
-        deallocate(vg_prof_cas)
-        deallocate(temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas)
-        deallocate(invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas)
-        deallocate(ht_prof_cas)
-        deallocate(hq_prof_cas)
-        deallocate(hu_prof_cas)
-        deallocate(hv_prof_cas)
-        deallocate(vt_prof_cas)
-        deallocate(vq_prof_cas)
-        deallocate(vu_prof_cas)
-        deallocate(vv_prof_cas)
-        deallocate(dt_prof_cas)
-        deallocate(dtrad_prof_cas)
-        deallocate(dq_prof_cas)
-        deallocate(du_prof_cas)
-        deallocate(dv_prof_cas)
-        deallocate(t_prof_cas)
-        deallocate(u_prof_cas)
-        deallocate(v_prof_cas)
-        deallocate(uw_prof_cas)
-        deallocate(vw_prof_cas)
-        deallocate(q1_prof_cas)
-        deallocate(q2_prof_cas)
-
-END SUBROUTINE deallocate2_1D_cases
-
-
-!=====================================================================
-      SUBROUTINE read_SCM(nid,nlevel,ntime,                                       &
-     &     ap,bp,zz,pp,zzh,pph,temp,theta,thv,thl,qv,ql,qi,rh,rv,u,v,vitw,omega,tke,ug,vg,&
-     &     temp_nudg,qv_nudg,u_nudg,v_nudg,                                        &
-     &     invtau_temp_nudg,invtau_qv_nudg,invtau_u_nudg,invtau_v_nudg,             &
-     &     du,hu,vu,dv,hv,vv,dt,ht,vt,dq,hq,vq,                                    &
-     &     dth,hth,vth,dr,hr,vr,dtrad,sens,flat,ts,ps,ustar,tkes,uw,vw,q1,q2,       &
-     &     orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,          &
-     &     heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas)
-
-!program reading forcing of the case study
-      implicit none
+  SUBROUTINE deallocate2_1D_cases
+    !profils environnementaux:
+    deallocate(plev_cas,plevh_cas)
+
+    deallocate(z_cas,zh_cas)
+    deallocate(ap_cas,bp_cas)
+    deallocate(t_cas,q_cas,qv_cas,ql_cas,qi_cas,rh_cas)
+    deallocate(th_cas,thl_cas,thv_cas,rv_cas)
+    deallocate(u_cas,v_cas,vitw_cas,omega_cas,tke_cas)
+
+    !forcing
+    deallocate(ht_cas,vt_cas,dt_cas,dtrad_cas)
+    deallocate(hq_cas,vq_cas,dq_cas)
+    deallocate(hth_cas,vth_cas,dth_cas)
+    deallocate(hr_cas,vr_cas,dr_cas)
+    deallocate(hu_cas,vu_cas,du_cas)
+    deallocate(hv_cas,vv_cas,dv_cas)
+    deallocate(ug_cas)
+    deallocate(vg_cas)
+    deallocate(lat_cas,sens_cas,tskin_cas,ts_cas,ps_cas,ustar_cas,tkes_cas,uw_cas,vw_cas,q1_cas,q2_cas)
+
+    !champs interpoles
+    deallocate(plev_prof_cas)
+    deallocate(t_prof_cas)
+    deallocate(theta_prof_cas)
+    deallocate(thl_prof_cas)
+    deallocate(thv_prof_cas)
+    deallocate(q_prof_cas)
+    deallocate(qv_prof_cas)
+    deallocate(ql_prof_cas)
+    deallocate(qi_prof_cas)
+    deallocate(rh_prof_cas)
+    deallocate(rv_prof_cas)
+    deallocate(u_prof_cas)
+    deallocate(v_prof_cas)
+    deallocate(vitw_prof_cas)
+    deallocate(omega_prof_cas)
+    deallocate(tke_prof_cas)
+    deallocate(ug_prof_cas)
+    deallocate(vg_prof_cas)
+    deallocate(temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas)
+    deallocate(invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas)
+    deallocate(ht_prof_cas)
+    deallocate(hq_prof_cas)
+    deallocate(hu_prof_cas)
+    deallocate(hv_prof_cas)
+    deallocate(vt_prof_cas)
+    deallocate(vq_prof_cas)
+    deallocate(vu_prof_cas)
+    deallocate(vv_prof_cas)
+    deallocate(dt_prof_cas)
+    deallocate(dtrad_prof_cas)
+    deallocate(dq_prof_cas)
+    deallocate(du_prof_cas)
+    deallocate(dv_prof_cas)
+    deallocate(t_prof_cas)
+    deallocate(u_prof_cas)
+    deallocate(v_prof_cas)
+    deallocate(uw_prof_cas)
+    deallocate(vw_prof_cas)
+    deallocate(q1_prof_cas)
+    deallocate(q2_prof_cas)
+
+  END SUBROUTINE deallocate2_1D_cases
+
+
+  !=====================================================================
+  SUBROUTINE read_SCM(nid,nlevel,ntime,                                       &
+       ap,bp,zz,pp,zzh,pph,temp,theta,thv,thl,qv,ql,qi,rh,rv,u,v,vitw,omega,tke,ug,vg,&
+       temp_nudg,qv_nudg,u_nudg,v_nudg,                                        &
+       invtau_temp_nudg,invtau_qv_nudg,invtau_u_nudg,invtau_v_nudg,             &
+       du,hu,vu,dv,hv,vv,dt,ht,vt,dq,hq,vq,                                    &
+       dth,hth,vth,dr,hr,vr,dtrad,sens,flat,ts,tskin,ps,ustar,tkes,uw,vw,q1,q2,       &
+       orog_cas,albedo_cas,emiss_cas,q_skin_cas,mom_rough,          &
+       heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas)
+
+    !program reading forcing of the case study
+    use netcdf, only: nf90_get_var
+    implicit none
 #include "netcdf.inc"
 #include "compar1d.h"
 
-      integer ntime,nlevel,k,t
-
-      real ap(nlevel+1),bp(nlevel+1)
-      real zz(nlevel,ntime),zzh(nlevel+1)
-      real pp(nlevel,ntime),pph(nlevel+1)
-!profils initiaux
-      real temp0(nlevel),qv0(nlevel),ql0(nlevel),qi0(nlevel),u0(nlevel),v0(nlevel),tke0(nlevel)
-      real pp0(nlevel)    
-      real temp(nlevel,ntime),qv(nlevel,ntime),ql(nlevel,ntime),qi(nlevel,ntime),rh(nlevel,ntime)
-      real theta(nlevel,ntime),thv(nlevel,ntime),thl(nlevel,ntime),rv(nlevel,ntime)
-      real u(nlevel,ntime),v(nlevel,ntime),tkes(ntime)
-      real temp_nudg(nlevel,ntime),qv_nudg(nlevel,ntime),u_nudg(nlevel,ntime),v_nudg(nlevel,ntime)
-      real invtau_temp_nudg(nlevel,ntime),invtau_qv_nudg(nlevel,ntime),invtau_u_nudg(nlevel,ntime),invtau_v_nudg(nlevel,ntime)
-      real ug(nlevel,ntime),vg(nlevel,ntime)
-      real vitw(nlevel,ntime),omega(nlevel,ntime),tke(nlevel,ntime)
-      real du(nlevel,ntime),hu(nlevel,ntime),vu(nlevel,ntime)
-      real dv(nlevel,ntime),hv(nlevel,ntime),vv(nlevel,ntime)
-      real dt(nlevel,ntime),ht(nlevel,ntime),vt(nlevel,ntime)
-      real dtrad(nlevel,ntime)
-      real dq(nlevel,ntime),hq(nlevel,ntime),vq(nlevel,ntime)
-      real dth(nlevel,ntime),hth(nlevel,ntime),vth(nlevel,ntime),hthl(nlevel,ntime)
-      real dr(nlevel,ntime),hr(nlevel,ntime),vr(nlevel,ntime)
-      real flat(ntime),sens(ntime),ustar(ntime)
-      real uw(nlevel,ntime),vw(nlevel,ntime),q1(nlevel,ntime),q2(nlevel,ntime)
-      real ts(ntime),ps(ntime)
-      real orog_cas,albedo_cas,emiss_cas,t_skin_cas,q_skin_cas,mom_rough,heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas
-      real apbp(nlevel+1),resul(nlevel,ntime),resul1(nlevel),resul2(ntime),resul3
-
-
-      integer nid, ierr,ierr1,ierr2,rid,i,int_test
-      integer nbvar3d
-      parameter(nbvar3d=78)
-      integer var3didin(nbvar3d),missing_var(nbvar3d)
-      character*13 name_var(1:nbvar3d)
-
-
-!      data name_var/ &
-!     ! coordonnees pression (n+1 niveaux) #4
-!     & 'coor_par_a','coor_par_b','height_h','pressure_h',& ! #1-#4
-!     ! coordonnees pression (n niveaux) #8
-!     &'temp','qv','ql','qi','u','v','tke','pressure',& ! #5-#12
-!     ! coordonnees pression + temps #42
-!     &'w','omega','ug','vg','uadv','uadvh','uadvv','vadv','vadvh','vadvv','temp_adv','tadvh','tadvv',& !  #13 - #25
-!     &'qv_adv','qvadvh','qvadvv','thadv','thadvh','thadvv','thladvh',                             & ! #26 - #32
-!     & 'radv','radvh','radvv','radcool','q1','q2','ustress','vstress',                           & ! #33 - #40
-!     & 'rh','temp_nudging','qv_nudging','u_nudging','v_nudging',                                       & ! #41-45
-!     &'height_f','pressure_forc','tempt','theta','thv','thl','qvt','qlt','qit','rv','ut','vt',   & ! #46-58
-!     ! coordonnees temps #12
-!     &'tkes','sfc_sens_flx','sfc_lat_flx','ts','ps','ustar',&
-!     &'orog','albedo','emiss','t_skin','q_skin','mom_rough','heat_rough',&
-!     ! scalaires #4
-!     &'o3','rugos','clay','sand'/
-
-
-
-      data name_var/ &
-     ! coordonnees pression (n+1 niveaux) #4
-     & 'coor_par_a','coor_par_b','zf','pressure_h',& ! #1-#4
-     ! coordonnees pression (n niveaux) #8
-     & 'ta','qv','ql','qi','ua','va','tke','pa',& ! #5-#12
-     ! coordonnees pression + temps #46
-     & 'wa','wap','ug','vg','tnua_adv','tnua_advh','tnua_advv','tnva_adv','tnva_advh','tnva_advv','tnta_adv','tnta_advh','tnta_advv',& !  #13 - #25
-     & 'tnqv_adv','tnqv_advh','tnqv_advv','thadv','thadvh','thadvv','thladvh',                             & ! #26 - #32
-     & 'radv','radvh','radvv','tnta_rad','q1','q2','ustress','vstress',                           & ! #33 - #40
-     & 'rh','ta_nud','qv_nud','ua_nud','va_nud',                                       & ! #41-45
-     & 'zh_forc','pa_forc','tat','thetat','thetavt','thetalt','qvt','qlt','qit','rv','uat','vat',   & ! #46-57
-     & 'nudging_constant_ta', 'nudging_constant_qv', 'nudging_constant_ua', 'nudging_constant_va',           & ! # 58-61
-     ! coordonnees temps #12
-     & 'tkes','hfss','hfls','ts_forc','ps_forc','ustar', &                                        ! 62-67
-     & 'orog','albedo','emiss','t_skin','q_skin','z0','z0h',       &                    ! 68-74
-     ! scalaires #4                               
-     & 'O3','rugos','clay','sand'/                                                      ! 75-78
-
-
-!-----------------------------------------------------------------------
-! First check that we are using a version > v2 of the 1D standard format
-! use the difference between 'temp' (old version) and 'ta' (new version)
-!-----------------------------------------------------------------------
-
-
-         ierr=NF_INQ_VARID(nid,'ta',int_test)
-         if(ierr/=NF_NOERR) then
-           print*, '++++++++++++++++++++++++++++++'
-           print*, 'variable ta missing in cas.nc '
-           print*, 'You are probably using an obsolete version of the 1D cases'
-           print*, 'please dowload the last version of the 1D archive from https://lmdz.lmd.jussieu.fr/pub/'
-           print*, '++++++++++++++++++++++++++++++'
-           CALL abort_gcm ('mod_1D_cases_read_std','bad version of 1D directory',0)
-         endif
-     
-!-----------------------------------------------------------------------
-! Checking availability of variable #i in the cas.nc file
-!     missing_var=1 if the variable is missing
-!-----------------------------------------------------------------------
-
-       do i=1,nbvar3d
-         missing_var(i)=0.
-         ierr=NF_INQ_VARID(nid,name_var(i),var3didin(i)) 
-         print*, 'name_var(i)', name_var(i), var3didin(i)
-         if(ierr/=NF_NOERR) then
-           print *,'Variable manquante dans cas.nc:',i,name_var(i)
-           ierr=NF_NOERR
-           missing_var(i)=1
-         else
-
-!-----------------------------------------------------------------------
-! Activating keys depending on the presence of specific variables in cas.nc
-!-----------------------------------------------------------------------
-if ( 1 == 1 ) THEN
-! A MODIFIER: il faudrait dire nudging_temp mais faut le declarer dans compar1d.h etc...        
-!           if ( name_var(i) == 'temp_nudging' .and. nint(nudging_t)==0) stop 'Nudging inconsistency temp'
-            if ( name_var(i) == 'qv_nud' .and. nint(nudging_qv)==0) stop 'Nudging inconsistency qv'
-            if ( name_var(i) == 'ua_nud' .and. nint(nudging_u)==0) stop 'Nudging inconsistency u'
-            if ( name_var(i) == 'va_nud' .and. nint(nudging_v)==0) stop 'Nudging inconsistency v'
-    ELSE
+    integer ntime,nlevel,k,t
+
+    real ap(nlevel+1),bp(nlevel+1)
+    real zz(nlevel,ntime),zzh(nlevel+1)
+    real pp(nlevel,ntime),pph(nlevel+1)
+    !profils initiaux
+    real temp0(nlevel),qv0(nlevel),ql0(nlevel),qi0(nlevel),u0(nlevel),v0(nlevel),tke0(nlevel)
+    real pp0(nlevel)    
+    real temp(nlevel,ntime),qv(nlevel,ntime),ql(nlevel,ntime),qi(nlevel,ntime),rh(nlevel,ntime)
+    real theta(nlevel,ntime),thv(nlevel,ntime),thl(nlevel,ntime),rv(nlevel,ntime)
+    real u(nlevel,ntime),v(nlevel,ntime),tkes(ntime)
+    real temp_nudg(nlevel,ntime),qv_nudg(nlevel,ntime),u_nudg(nlevel,ntime),v_nudg(nlevel,ntime)
+    real invtau_temp_nudg(nlevel,ntime),invtau_qv_nudg(nlevel,ntime),invtau_u_nudg(nlevel,ntime),invtau_v_nudg(nlevel,ntime)
+    real ug(nlevel,ntime),vg(nlevel,ntime)
+    real vitw(nlevel,ntime),omega(nlevel,ntime),tke(nlevel,ntime)
+    real du(nlevel,ntime),hu(nlevel,ntime),vu(nlevel,ntime)
+    real dv(nlevel,ntime),hv(nlevel,ntime),vv(nlevel,ntime)
+    real dt(nlevel,ntime),ht(nlevel,ntime),vt(nlevel,ntime)
+    real dtrad(nlevel,ntime)
+    real dq(nlevel,ntime),hq(nlevel,ntime),vq(nlevel,ntime)
+    real dth(nlevel,ntime),hth(nlevel,ntime),vth(nlevel,ntime),hthl(nlevel,ntime)
+    real dr(nlevel,ntime),hr(nlevel,ntime),vr(nlevel,ntime)
+    real flat(ntime),sens(ntime),ustar(ntime)
+    real uw(nlevel,ntime),vw(nlevel,ntime),q1(nlevel,ntime),q2(nlevel,ntime)
+    real ts(ntime),tskin(ntime),ps(ntime)
+    real orog_cas,albedo_cas,emiss_cas,q_skin_cas,mom_rough,heat_rough,o3_cas,rugos_cas,clay_cas,sand_cas
+    real apbp(nlevel+1),resul(nlevel,ntime),resul1(nlevel),resul2(ntime),resul3
+
+
+    integer nid, ierr,ierr1,ierr2,rid,i,int_test
+    integer nbvar3d
+    parameter(nbvar3d=78)
+    integer var3didin(nbvar3d),missing_var(nbvar3d)
+    character*13 name_var(1:nbvar3d)
+
+
+    !      data name_var/ &
+    !     ! coordonnees pression (n+1 niveaux) #4
+    !     & 'coor_par_a','coor_par_b','height_h','pressure_h',& ! #1-#4
+    !     ! coordonnees pression (n niveaux) #8
+    !     &'temp','qv','ql','qi','u','v','tke','pressure',& ! #5-#12
+    !     ! coordonnees pression + temps #42
+    !     &'w','omega','ug','vg','uadv','uadvh','uadvv','vadv','vadvh','vadvv','temp_adv','tadvh','tadvv',& !  #13 - #25
+    !     &'qv_adv','qvadvh','qvadvv','thadv','thadvh','thadvv','thladvh',                             & ! #26 - #32
+    !     & 'radv','radvh','radvv','radcool','q1','q2','ustress','vstress',                           & ! #33 - #40
+    !     & 'rh','temp_nudging','qv_nudging','u_nudging','v_nudging',                                       & ! #41-45
+    !     &'height_f','pressure_forc','tempt','theta','thv','thl','qvt','qlt','qit','rv','ut','vt',   & ! #46-58
+    !     ! coordonnees temps #12
+    !     &'tkes','sfc_sens_flx','sfc_lat_flx','ts','ps','ustar',&
+    !     &'orog','albedo','emiss','t_skin','q_skin','mom_rough','heat_rough',&
+    !     ! scalaires #4
+    !     &'o3','rugos','clay','sand'/
+
+
+
+    data name_var/ &
+                                ! coordonnees pression (n+1 niveaux) #4
+         'coor_par_a','coor_par_b','zf','pressure_h',& ! #1-#4
+                                ! coordonnees pression (n niveaux) #8
+         'ta','qv','ql','qi','ua','va','tke','pa',& ! #5-#12
+                                ! coordonnees pression + temps #46
+         'wa','wap','ug','vg','tnua_adv','tnua_advh','tnua_advv','tnva_adv','tnva_advh','tnva_advv','tnta_adv','tnta_advh',& !  #13 - #25
+         'tnta_advv','tnqv_adv','tnqv_advh','tnqv_advv','thadv','thadvh','thadvv','thladvh',                             & ! #26 - #32
+         'radv','radvh','radvv','tnta_rad','q1','q2','ustress','vstress',                           & ! #33 - #40
+         'rh','ta_nud','qv_nud','ua_nud','va_nud',                                       & ! #41-45
+         'zh_forc','pa_forc','tat','thetat','thetavt','thetalt','qvt','qlt','qit','rvt','uat','vat',   & ! #46-57
+         'nudging_constant_ta', 'nudging_constant_qv', 'nudging_constant_ua', 'nudging_constant_va',           & ! # 58-61
+                                ! coordonnees temps #12
+         'tkes','hfss','hfls','ts_forc','tskin','ps_forc','ustar', &                     ! 62-68
+                                  ! scalaires 
+         'orog','albedo','emiss','q_skin','z0','z0h',       &                    ! 69-74
+         'O3','rugos','clay','sand'/                                                      ! 75-78
+
+
+    !-----------------------------------------------------------------------
+    ! First check that we are using a version > v2 of the 1D standard format
+    ! use the difference between 'temp' (old version) and 'ta' (new version)
+    !-----------------------------------------------------------------------
+
+
+    ierr=NF_INQ_VARID(nid,'ta',int_test)
+    if(ierr/=NF_NOERR) then
+       print*, '++++++++++++++++++++++++++++++'
+       print*, 'variable ta missing in cas.nc '
+       print*, 'You are probably using an obsolete version of the 1D cases'
+       print*, 'please dowload the last version of the 1D archive from https://lmdz.lmd.jussieu.fr/pub/'
+       print*, '++++++++++++++++++++++++++++++'
+       CALL abort_gcm ('mod_1D_cases_read_std','bad version of 1D directory',0)
+    endif
+
+    !-----------------------------------------------------------------------
+    ! Checking availability of variable #i in the cas.nc file
+    !     missing_var=1 if the variable is missing
+    !-----------------------------------------------------------------------
+
+    do i=1,nbvar3d
+       missing_var(i)=0.
+       ierr=NF_INQ_VARID(nid,name_var(i),var3didin(i)) 
+       print*, 'name_var(i)', name_var(i), var3didin(i)
+       if(ierr/=NF_NOERR) then
+          print *,'Variable manquante dans cas.nc:',i,name_var(i)
+          ierr=NF_NOERR
+          missing_var(i)=1
+       else
+
+          !-----------------------------------------------------------------------
+          ! Activating keys depending on the presence of specific variables in cas.nc
+          !-----------------------------------------------------------------------
+          if ( 1 == 1 ) THEN
+             ! A MODIFIER: il faudrait dire nudging_temp mais faut le declarer dans compar1d.h etc...        
+             !           if ( name_var(i) == 'temp_nudging' .and. nint(nudging_t)==0) stop 'Nudging inconsistency temp'
+             if ( name_var(i) == 'qv_nud' .and. nint(nudging_qv)==0) stop 'Nudging inconsistency qv'
+             if ( name_var(i) == 'ua_nud' .and. nint(nudging_u)==0) stop 'Nudging inconsistency u'
+             if ( name_var(i) == 'va_nud' .and. nint(nudging_v)==0) stop 'Nudging inconsistency v'
+          ELSE
              print*,'GUIDAGE : CONSISTENCY CHECK DEACTIVATED FOR TESTS of SANDU/REF'
-    ENDIF
-
-!-----------------------------------------------------------------------
-! Reading variables 1D (N+1) vertical variables (nlevelp1,lat,lon)
-!-----------------------------------------------------------------------
-           if(i.LE.4) then
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),apbp)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),apbp)
-#endif
-           print *,'read2_cas(apbp), on a lu ',i,name_var(i)
-           if(ierr/=NF_NOERR) then
-              print *,'Pb a la lecture de cas.nc: ',name_var(i)
-              stop "getvarup"
-           endif
-
-!-----------------------------------------------------------------------
-!  Reading 1D (N) vertical varialbes    (nlevel,lat,lon)   
-!-----------------------------------------------------------------------
-           else if(i.gt.4.and.i.LE.12) then  
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul1)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul1)
-#endif
-           print *,'read2_cas(resul1), on a lu ',i,name_var(i)
-           if(ierr/=NF_NOERR) then
-              print *,'Pb a la lecture de cas.nc: ',name_var(i)
-              stop "getvarup"
-           endif
-         print*,'Lecture de la variable #i ',i,name_var(i),minval(resul1),maxval(resul1)
-
-!-----------------------------------------------------------------------
-!  Reading 2D tim-vertical variables  (time,nlevel,lat,lon)
-!  TBD : seems to be the same as above.
-!-----------------------------------------------------------------------
-           else if(i.gt.12.and.i.LE.61) then
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul)
-#endif
-           print *,'read2_cas(resul), on a lu ',i,name_var(i)
-           if(ierr/=NF_NOERR) then
-              print *,'Pb a la lecture de cas.nc: ',name_var(i)
-              stop "getvarup"
-           endif
-         print*,'Lecture de la variable #i ',i,name_var(i),minval(resul),maxval(resul)
-
-!-----------------------------------------------------------------------
-!  Reading 1D time variables (time,lat,lon)
-!-----------------------------------------------------------------------
-           else if (i.gt.62.and.i.LE.75) then
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul2)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul2)
-#endif
-           print *,'read2_cas(resul2), on a lu ',i,name_var(i)
-           if(ierr/=NF_NOERR) then
-              print *,'Pb a la lecture de cas.nc: ',name_var(i)
-              stop "getvarup"
-           endif
-         print*,'Lecture de la variable #i  ',i,name_var(i),minval(resul2),maxval(resul2)
-
-!-----------------------------------------------------------------------
-! Reading scalar variables (lat,lon)
-!-----------------------------------------------------------------------
-           else
-#ifdef NC_DOUBLE
-           ierr = NF_GET_VAR_DOUBLE(nid,var3didin(i),resul3)
-#else
-           ierr = NF_GET_VAR_REAL(nid,var3didin(i),resul3)
-#endif
-           print *,'read2_cas(resul3), on a lu ',i,name_var(i)
-           if(ierr/=NF_NOERR) then
-              print *,'Pb a la lecture de cas.nc: ',name_var(i)
-              stop "getvarup"
-           endif
-         print*,'Lecture de la variable #i ',i,name_var(i),resul3
-           endif
-         endif
-
-!-----------------------------------------------------------------------
-! Attributing variables
-!-----------------------------------------------------------------------
-         select case(i)
-         !case(1) ; ap=apbp       ! donnees indexees en nlevel+1
-         ! case(2) ; bp=apbp
-           case(3) ; zzh=apbp
-           case(4) ; pph=apbp
-           case(5) ; temp0=resul1    ! donnees initiales
-           case(6) ; qv0=resul1
-           case(7) ; ql0=resul1
-           case(8) ; qi0=resul1
-           case(9) ; u0=resul1
-           case(10) ; v0=resul1
-           case(11) ; tke0=resul1
-           case(12) ; pp0=resul1
-           case(13) ; vitw=resul    ! donnees indexees en nlevel,time
-           case(14) ; omega=resul
-           case(15) ; ug=resul
-           case(16) ; vg=resul
-           case(17) ; du=resul
-           case(18) ; hu=resul
-           case(19) ; vu=resul
-           case(20) ; dv=resul
-           case(21) ; hv=resul
-           case(22) ; vv=resul
-           case(23) ; dt=resul
-           case(24) ; ht=resul
-           case(25) ; vt=resul
-           case(26) ; dq=resul
-           case(27) ; hq=resul
-           case(28) ; vq=resul
-           case(29) ; dth=resul
-           case(30) ; hth=resul
-           case(31) ; vth=resul
-           case(32) ; hthl=resul
-           case(33) ; dr=resul
-           case(34) ; hr=resul
-           case(35) ; vr=resul
-           case(36) ; dtrad=resul
-           case(37) ; q1=resul
-           case(38) ; q2=resul
-           case(39) ; uw=resul
-           case(40) ; vw=resul
-           case(41) ; rh=resul
-           case(42) ; temp_nudg=resul
-           case(43) ; qv_nudg=resul
-           case(44) ; u_nudg=resul
-           case(45) ; v_nudg=resul
-           case(46) ; zz=resul      ! donnees en time,nlevel pour profil initial
-           case(47) ; pp=resul
-           case(48) ; temp=resul
-           case(49) ; theta=resul
-           case(50) ; thv=resul
-           case(51) ; thl=resul
-           case(52) ; qv=resul
-           case(53) ; ql=resul
-           case(54) ; qi=resul
-           case(55) ; rv=resul
-           case(56) ; u=resul
-           case(57) ; v=resul
-           case(58) ; invtau_temp_nudg=resul
-           case(59) ; invtau_qv_nudg=resul
-           case(60) ; invtau_u_nudg=resul
-           case(61) ; invtau_v_nudg=resul
-           case(62) ; tkes=resul2   ! donnees indexees en time
-           case(63) ; sens=resul2
-           case(64) ; flat=resul2
-           case(65) ; ts=resul2
-           case(66) ; ps=resul2
-           case(67) ; ustar=resul2
-           case(68) ; orog_cas=resul3      ! constantes
-           case(69) ; albedo_cas=resul3
-           case(70) ; emiss_cas=resul3
-           case(71) ; t_skin_cas=resul3
-           case(72) ; q_skin_cas=resul3
-           case(73) ; mom_rough=resul3
-           case(74) ; heat_rough=resul3
-           case(75) ; o3_cas=resul3        
-           case(76) ; rugos_cas=resul3
-           case(77) ; clay_cas=resul3
-           case(78) ; sand_cas=resul3
-         end select
-         resul=0.
-         resul1=0.
-         resul2=0.
-         resul3=0.
+          ENDIF
+
+          !-----------------------------------------------------------------------
+          ! Reading variables 1D (N+1) vertical variables (nlevelp1,lat,lon)
+          !-----------------------------------------------------------------------
+          if(i.LE.4) then
+             ierr = NF90_GET_VAR(nid,var3didin(i),apbp)
+             print *,'read_SCM(apbp), on a lu ',i,name_var(i)
+             if(ierr/=NF_NOERR) then
+                print *,'B Pb a la lecture de cas.nc: ',name_var(i)
+                stop "getvarup"
+             endif
+
+             !-----------------------------------------------------------------------
+             !  Reading 1D (N) vertical varialbes    (nlevel,lat,lon)   
+             !-----------------------------------------------------------------------
+          else if(i.gt.4.and.i.LE.12) then  
+             ierr = NF90_GET_VAR(nid,var3didin(i),resul1)
+             print *,'read_SCM(resul1), on a lu ',i,name_var(i)
+             if(ierr/=NF_NOERR) then
+                print *,'C Pb a la lecture de cas.nc: ',name_var(i)
+                stop "getvarup"
+             endif
+             print*,'Lecture de la variable #i ',i,name_var(i),minval(resul1),maxval(resul1)
+
+             !-----------------------------------------------------------------------
+             !  Reading 2D tim-vertical variables  (time,nlevel,lat,lon)
+             !  TBD : seems to be the same as above.
+             !-----------------------------------------------------------------------
+          else if(i.gt.12.and.i.LE.61) then
+             ierr = NF90_GET_VAR(nid,var3didin(i),resul)
+             print *,'read_SCM(resul), on a lu ',i,name_var(i)
+             if(ierr/=NF_NOERR) then
+                print *,'D Pb a la lecture de cas.nc: ',name_var(i)
+                stop "getvarup"
+             endif
+             print*,'Lecture de la variable #i ',i,name_var(i),minval(resul),maxval(resul)
+
+             !-----------------------------------------------------------------------
+             !  Reading 1D time variables (time,lat,lon)
+             !-----------------------------------------------------------------------
+          else if (i.gt.62.and.i.LE.75) then
+             ierr = NF90_GET_VAR(nid,var3didin(i),resul2)
+             print *,'read_SCM(resul2), on a lu ',i,name_var(i)
+             if(ierr/=NF_NOERR) then
+                print *,'E Pb a la lecture de cas.nc: ',name_var(i)
+                stop "getvarup"
+             endif
+             print*,'Lecture de la variable #i  ',i,name_var(i),minval(resul2),maxval(resul2)
+
+             !-----------------------------------------------------------------------
+             ! Reading scalar variables (lat,lon)
+             !-----------------------------------------------------------------------
+          else
+             ierr = NF90_GET_VAR(nid,var3didin(i),resul3)
+             print *,'read_SCM(resul3), on a lu ',i,name_var(i)
+             if(ierr/=NF_NOERR) then
+                print *,'F Pb a la lecture de cas.nc: ',name_var(i)
+                stop "getvarup"
+             endif
+             print*,'Lecture de la variable #i ',i,name_var(i),resul3
+          endif
+       endif
+
+       !-----------------------------------------------------------------------
+       ! Attributing variables
+       !-----------------------------------------------------------------------
+       select case(i)
+          !case(1) ; ap=apbp       ! donnees indexees en nlevel+1
+          ! case(2) ; bp=apbp
+       case(3) ; zzh=apbp
+       case(4) ; pph=apbp
+       case(5) ; temp0=resul1    ! donnees initiales
+       case(6) ; qv0=resul1
+       case(7) ; ql0=resul1
+       case(8) ; qi0=resul1
+       case(9) ; u0=resul1
+       case(10) ; v0=resul1
+       case(11) ; tke0=resul1
+       case(12) ; pp0=resul1
+       case(13) ; vitw=resul    ! donnees indexees en nlevel,time
+       case(14) ; omega=resul
+       case(15) ; ug=resul
+       case(16) ; vg=resul
+       case(17) ; du=resul
+       case(18) ; hu=resul
+       case(19) ; vu=resul
+       case(20) ; dv=resul
+       case(21) ; hv=resul
+       case(22) ; vv=resul
+       case(23) ; dt=resul
+       case(24) ; ht=resul
+       case(25) ; vt=resul
+       case(26) ; dq=resul
+       case(27) ; hq=resul
+       case(28) ; vq=resul
+       case(29) ; dth=resul
+       case(30) ; hth=resul
+       case(31) ; vth=resul
+       case(32) ; hthl=resul
+       case(33) ; dr=resul
+       case(34) ; hr=resul
+       case(35) ; vr=resul
+       case(36) ; dtrad=resul
+       case(37) ; q1=resul
+       case(38) ; q2=resul
+       case(39) ; uw=resul
+       case(40) ; vw=resul
+       case(41) ; rh=resul
+       case(42) ; temp_nudg=resul
+       case(43) ; qv_nudg=resul
+       case(44) ; u_nudg=resul
+       case(45) ; v_nudg=resul
+       case(46) ; zz=resul      ! donnees en time,nlevel pour profil initial
+       case(47) ; pp=resul
+       case(48) ; temp=resul
+       case(49) ; theta=resul
+       case(50) ; thv=resul
+       case(51) ; thl=resul
+       case(52) ; qv=resul
+       case(53) ; ql=resul
+       case(54) ; qi=resul
+       case(55) ; rv=resul
+       case(56) ; u=resul
+       case(57) ; v=resul
+       case(58) ; invtau_temp_nudg=resul
+       case(59) ; invtau_qv_nudg=resul
+       case(60) ; invtau_u_nudg=resul
+       case(61) ; invtau_v_nudg=resul
+       case(62) ; tkes=resul2   ! donnees indexees en time
+       case(63) ; sens=resul2
+       case(64) ; flat=resul2
+       case(65) ; ts=resul2
+       case(66) ; tskin=resul2        
+       case(67) ; ps=resul2
+       case(68) ; ustar=resul2
+       case(69) ; orog_cas=resul3      ! constantes
+       case(70) ; albedo_cas=resul3
+       case(71) ; emiss_cas=resul3
+       case(72) ; q_skin_cas=resul3
+       case(73) ; mom_rough=resul3
+       case(74) ; heat_rough=resul3
+       case(75) ; o3_cas=resul3        
+       case(76) ; rugos_cas=resul3
+       case(77) ; clay_cas=resul3
+       case(78) ; sand_cas=resul3
+       end select
+       resul=0.
+       resul1=0.
+       resul2=0.
+       resul3=0.
+    enddo
+    print*,'Lecture de la variable APRES ,sens ',minval(sens),maxval(sens)
+    print*,'Lecture de la variable APRES ,flat ',minval(flat),maxval(flat)
+
+    !CR:ATTENTION EN ATTENTE DE REGLER LA QUESTION DU PAS DE TEMPS INITIAL
+    do t=1,ntime
+       do k=1,nlevel
+          temp(k,t)=temp0(k)
+          qv(k,t)=qv0(k)
+          ql(k,t)=ql0(k)
+          qi(k,t)=qi0(k)
+          u(k,t)=u0(k)
+          v(k,t)=v0(k)
+          tke(k,t)=tke0(k)
        enddo
-         print*,'Lecture de la variable APRES ,sens ',minval(sens),maxval(sens)
-         print*,'Lecture de la variable APRES ,flat ',minval(flat),maxval(flat)
-
-!CR:ATTENTION EN ATTENTE DE REGLER LA QUESTION DU PAS DE TEMPS INITIAL
-       do t=1,ntime
-          do k=1,nlevel
-             temp(k,t)=temp0(k)
-             qv(k,t)=qv0(k)
-             ql(k,t)=ql0(k)
-             qi(k,t)=qi0(k)
-             u(k,t)=u0(k)
-             v(k,t)=v0(k)
-             tke(k,t)=tke0(k)
-          enddo
-       enddo
-       !!!! TRAVAIL : EN FONCTION DES DECISIONS SUR LA SPECIFICATION DE W
-       !!!omega=-vitw*pres*rg/(rd*temp)
-!-----------------------------------------------------------------------
-
-         return 
-         END SUBROUTINE read_SCM
-!======================================================================
-
-!======================================================================
-
-!**********************************************************************************************
-
-!**********************************************************************************************
-        SUBROUTINE interp_case_time_std(day,day1,annee_ref                           &
-!    &         ,year_cas,day_cas,nt_cas,pdt_forc,nlev_cas                         &
-     &         ,nt_cas,nlev_cas                                                   &
-     &         ,ts_cas,ps_cas,plev_cas,t_cas,theta_cas,thv_cas,thl_cas            &
-     &         ,qv_cas,ql_cas,qi_cas,u_cas,v_cas                                  &
-     &         ,ug_cas,vg_cas,temp_nudg_cas,qv_nudg_cas,u_nudg_cas,v_nudg_cas     &
-     &         ,invtau_temp_nudg_cas,invtau_qv_nudg_cas,invtau_u_nudg_cas,invtau_v_nudg_cas     &
-     &         ,vitw_cas,omega_cas,tke_cas,du_cas,hu_cas,vu_cas             &
-     &         ,dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dtrad_cas               &
-     &         ,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas                      &
-     &         ,lat_cas,sens_cas,ustar_cas                                        &
-     &         ,uw_cas,vw_cas,q1_cas,q2_cas,tkes_cas                               &
-!
-     &         ,ts_prof_cas,ps_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas               &
-     &         ,thv_prof_cas,thl_prof_cas,qv_prof_cas,ql_prof_cas,qi_prof_cas     &
-     &         ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas                     &
-     &         ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas     &
-     &         ,invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas     &     
-     &         ,vitw_prof_cas,omega_prof_cas,tke_prof_cas,du_prof_cas,hu_prof_cas,vu_prof_cas  &
-     &         ,dv_prof_cas,hv_prof_cas,vv_prof_cas,dt_prof_cas                   &
-     &         ,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas                &
-     &         ,hq_prof_cas,vq_prof_cas,dth_prof_cas,hth_prof_cas,vth_prof_cas    &
-     &         ,lat_prof_cas,sens_prof_cas                                        &
-     &         ,ustar_prof_cas,uw_prof_cas,vw_prof_cas,q1_prof_cas,q2_prof_cas,tkes_prof_cas)
-
-
-
-
-
-
-       implicit none
-
-!---------------------------------------------------------------------------------------
-! Time interpolation of a 2D field to the timestep corresponding to day
-!
-! day: current julian day (e.g. 717538.2)
-! day1: first day of the simulation
-! nt_cas: total nb of data in the forcing 
-! pdt_cas: total time interval (in sec) between 2 forcing data
-!---------------------------------------------------------------------------------------
+    enddo
+!!!! TRAVAIL : EN FONCTION DES DECISIONS SUR LA SPECIFICATION DE W
+!!!omega=-vitw*pres*rg/(rd*temp)
+    !-----------------------------------------------------------------------
+
+    return 
+  END SUBROUTINE read_SCM
+  !======================================================================
+
+  !======================================================================
+
+  !**********************************************************************************************
+
+  !**********************************************************************************************
+  SUBROUTINE interp_case_time_std(day,day1,annee_ref                           &
+       !    &         ,year_cas,day_cas,nt_cas,pdt_forc,nlev_cas                         &
+       ,nt_cas,nlev_cas                                                   &
+       ,ts_cas,tskin_cas,ps_cas,plev_cas,t_cas,theta_cas,thv_cas,thl_cas            &
+       ,qv_cas,ql_cas,qi_cas,u_cas,v_cas                                  &
+       ,ug_cas,vg_cas,temp_nudg_cas,qv_nudg_cas,u_nudg_cas,v_nudg_cas     &
+       ,invtau_temp_nudg_cas,invtau_qv_nudg_cas,invtau_u_nudg_cas,invtau_v_nudg_cas     &
+       ,vitw_cas,omega_cas,tke_cas,du_cas,hu_cas,vu_cas             &
+       ,dv_cas,hv_cas,vv_cas,dt_cas,ht_cas,vt_cas,dtrad_cas               &
+       ,dq_cas,hq_cas,vq_cas,dth_cas,hth_cas,vth_cas                      &
+       ,lat_cas,sens_cas,ustar_cas                                        &
+       ,uw_cas,vw_cas,q1_cas,q2_cas,tkes_cas                               &
+       !
+       ,ts_prof_cas,tskin_prof_cas,ps_prof_cas,plev_prof_cas,t_prof_cas,theta_prof_cas               &
+       ,thv_prof_cas,thl_prof_cas,qv_prof_cas,ql_prof_cas,qi_prof_cas     &
+       ,u_prof_cas,v_prof_cas,ug_prof_cas,vg_prof_cas                     &
+       ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas     &
+       ,invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas     &     
+       ,vitw_prof_cas,omega_prof_cas,tke_prof_cas,du_prof_cas,hu_prof_cas,vu_prof_cas  &
+       ,dv_prof_cas,hv_prof_cas,vv_prof_cas,dt_prof_cas                   &
+       ,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas                &
+       ,hq_prof_cas,vq_prof_cas,dth_prof_cas,hth_prof_cas,vth_prof_cas    &
+       ,lat_prof_cas,sens_prof_cas                                        &
+       ,ustar_prof_cas,uw_prof_cas,vw_prof_cas,q1_prof_cas,q2_prof_cas,tkes_prof_cas)
+
+
+
+
+
+
+    implicit none
+
+    !---------------------------------------------------------------------------------------
+    ! Time interpolation of a 2D field to the timestep corresponding to day
+    !
+    ! day: current julian day (e.g. 717538.2)
+    ! day1: first day of the simulation
+    ! nt_cas: total nb of data in the forcing 
+    ! pdt_cas: total time interval (in sec) between 2 forcing data
+    !---------------------------------------------------------------------------------------
 
 #include "compar1d.h"
 #include "date_cas.h"
 
-! inputs:
-        integer annee_ref
-        integer nt_cas,nlev_cas
-        real day, day1,day_cas
-        real ts_cas(nt_cas),ps_cas(nt_cas)
-        real plev_cas(nlev_cas,nt_cas)
-        real t_cas(nlev_cas,nt_cas),theta_cas(nlev_cas,nt_cas)
-        real thv_cas(nlev_cas,nt_cas), thl_cas(nlev_cas,nt_cas)
-        real qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas),qi_cas(nlev_cas,nt_cas)
-        real u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas)
-        real ug_cas(nlev_cas,nt_cas),vg_cas(nlev_cas,nt_cas)
-        real temp_nudg_cas(nlev_cas,nt_cas),qv_nudg_cas(nlev_cas,nt_cas)
-        real u_nudg_cas(nlev_cas,nt_cas),v_nudg_cas(nlev_cas,nt_cas)
-
-        real invtau_temp_nudg_cas(nlev_cas,nt_cas),invtau_qv_nudg_cas(nlev_cas,nt_cas)
-        real invtau_u_nudg_cas(nlev_cas,nt_cas),invtau_v_nudg_cas(nlev_cas,nt_cas)
-
-        real vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas),tke_cas(nlev_cas,nt_cas)
-        real du_cas(nlev_cas,nt_cas),hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas)
-        real dv_cas(nlev_cas,nt_cas),hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas)
-        real dt_cas(nlev_cas,nt_cas),ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas)
-        real dth_cas(nlev_cas,nt_cas),hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas)
-        real dtrad_cas(nlev_cas,nt_cas)
-        real dq_cas(nlev_cas,nt_cas),hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas)
-        real lat_cas(nt_cas),sens_cas(nt_cas),tkes_cas(nt_cas)
-        real ustar_cas(nt_cas),uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas)
-        real q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas)
-
-! outputs:
-        real plev_prof_cas(nlev_cas)
-        real t_prof_cas(nlev_cas),theta_prof_cas(nlev_cas),thl_prof_cas(nlev_cas),thv_prof_cas(nlev_cas)
-        real qv_prof_cas(nlev_cas),ql_prof_cas(nlev_cas),qi_prof_cas(nlev_cas)
-        real u_prof_cas(nlev_cas),v_prof_cas(nlev_cas)
-        real ug_prof_cas(nlev_cas),vg_prof_cas(nlev_cas)
-        real temp_nudg_prof_cas(nlev_cas),qv_nudg_prof_cas(nlev_cas)
-        real u_nudg_prof_cas(nlev_cas),v_nudg_prof_cas(nlev_cas)
-
-        real invtau_temp_nudg_prof_cas(nlev_cas),invtau_qv_nudg_prof_cas(nlev_cas)
-        real invtau_u_nudg_prof_cas(nlev_cas),invtau_v_nudg_prof_cas(nlev_cas)
-
-        real vitw_prof_cas(nlev_cas),omega_prof_cas(nlev_cas),tke_prof_cas(nlev_cas)
-        real du_prof_cas(nlev_cas),hu_prof_cas(nlev_cas),vu_prof_cas(nlev_cas)
-        real dv_prof_cas(nlev_cas),hv_prof_cas(nlev_cas),vv_prof_cas(nlev_cas)
-        real dt_prof_cas(nlev_cas),ht_prof_cas(nlev_cas),vt_prof_cas(nlev_cas)
-        real dth_prof_cas(nlev_cas),hth_prof_cas(nlev_cas),vth_prof_cas(nlev_cas)
-        real dtrad_prof_cas(nlev_cas)
-        real dq_prof_cas(nlev_cas),hq_prof_cas(nlev_cas),vq_prof_cas(nlev_cas)
-        real lat_prof_cas,sens_prof_cas,tkes_prof_cas,ts_prof_cas,ps_prof_cas,ustar_prof_cas
-        real uw_prof_cas(nlev_cas),vw_prof_cas(nlev_cas),q1_prof_cas(nlev_cas),q2_prof_cas(nlev_cas)
-! local:
-        integer it_cas1, it_cas2,k
-        real timeit,time_cas1,time_cas2,frac
-
-
-        print*,'Check time',day1,day_ju_ini_cas,day_deb+1,pdt_cas
-!       do k=1,nlev_cas
-!       print*,'debut de interp2_case_time, plev_cas=',k,plev_cas(k,1)
-!       enddo
-
-! On teste si la date du cas AMMA est correcte.
-! C est pour memoire car en fait les fichiers .def
-! sont censes etre corrects.
-! A supprimer a terme (MPL 20150623)
-!     if ((forcing_type.eq.10).and.(1.eq.0)) then
-! Check that initial day of the simulation consistent with AMMA case:
-!      if (annee_ref.ne.2006) then
-!       print*,'Pour AMMA, annee_ref doit etre 2006'
-!       print*,'Changer annee_ref dans run.def'
-!       stop
-!      endif
-!      if (annee_ref.eq.2006 .and. day1.lt.day_cas) then
-!       print*,'AMMA a debute le 10 juillet 2006',day1,day_cas
-!       print*,'Changer dayref dans run.def'
-!       stop
-!      endif
-!      if (annee_ref.eq.2006 .and. day1.gt.day_cas+1) then
-!       print*,'AMMA a fini le 11 juillet'
-!       print*,'Changer dayref ou nday dans run.def'
-!       stop
-!      endif
-!      endif
-
-! Determine timestep relative to the 1st day:
-!       timeit=(day-day1)*86400.
-!       if (annee_ref.eq.1992) then
-!        timeit=(day-day_cas)*86400.
-!       else
-!        timeit=(day+61.-1.)*86400. ! 61 days between Nov01 and Dec31 1992
-!       endif
-      timeit=(day-day_ju_ini_cas)*86400
-      print *,'day=',day
-      print *,'day_ju_ini_cas=',day_ju_ini_cas
-      print *,'pdt_cas=',pdt_cas
-      print *,'timeit=',timeit
-      print *,'nt_cas=',nt_cas
-
-! Determine the closest observation times:
-!       it_cas1=INT(timeit/pdt_cas)+1
-!       it_cas2=it_cas1 + 1
-!       time_cas1=(it_cas1-1)*pdt_cas
-!       time_cas2=(it_cas2-1)*pdt_cas
-
-       it_cas1=INT(timeit/pdt_cas)+1
-       IF (it_cas1 .EQ. nt_cas) THEN
+    ! inputs:
+    integer annee_ref
+    integer nt_cas,nlev_cas
+    real day, day1,day_cas
+    real ts_cas(nt_cas),tskin_cas(nt_cas),ps_cas(nt_cas)
+    real plev_cas(nlev_cas,nt_cas)
+    real t_cas(nlev_cas,nt_cas),theta_cas(nlev_cas,nt_cas)
+    real thv_cas(nlev_cas,nt_cas), thl_cas(nlev_cas,nt_cas)
+    real qv_cas(nlev_cas,nt_cas),ql_cas(nlev_cas,nt_cas),qi_cas(nlev_cas,nt_cas)
+    real u_cas(nlev_cas,nt_cas),v_cas(nlev_cas,nt_cas)
+    real ug_cas(nlev_cas,nt_cas),vg_cas(nlev_cas,nt_cas)
+    real temp_nudg_cas(nlev_cas,nt_cas),qv_nudg_cas(nlev_cas,nt_cas)
+    real u_nudg_cas(nlev_cas,nt_cas),v_nudg_cas(nlev_cas,nt_cas)
+
+    real invtau_temp_nudg_cas(nlev_cas,nt_cas),invtau_qv_nudg_cas(nlev_cas,nt_cas)
+    real invtau_u_nudg_cas(nlev_cas,nt_cas),invtau_v_nudg_cas(nlev_cas,nt_cas)
+
+    real vitw_cas(nlev_cas,nt_cas),omega_cas(nlev_cas,nt_cas),tke_cas(nlev_cas,nt_cas)
+    real du_cas(nlev_cas,nt_cas),hu_cas(nlev_cas,nt_cas),vu_cas(nlev_cas,nt_cas)
+    real dv_cas(nlev_cas,nt_cas),hv_cas(nlev_cas,nt_cas),vv_cas(nlev_cas,nt_cas)
+    real dt_cas(nlev_cas,nt_cas),ht_cas(nlev_cas,nt_cas),vt_cas(nlev_cas,nt_cas)
+    real dth_cas(nlev_cas,nt_cas),hth_cas(nlev_cas,nt_cas),vth_cas(nlev_cas,nt_cas)
+    real dtrad_cas(nlev_cas,nt_cas)
+    real dq_cas(nlev_cas,nt_cas),hq_cas(nlev_cas,nt_cas),vq_cas(nlev_cas,nt_cas)
+    real lat_cas(nt_cas),sens_cas(nt_cas),tkes_cas(nt_cas)
+    real ustar_cas(nt_cas),uw_cas(nlev_cas,nt_cas),vw_cas(nlev_cas,nt_cas)
+    real q1_cas(nlev_cas,nt_cas),q2_cas(nlev_cas,nt_cas)
+
+    ! outputs:
+    real plev_prof_cas(nlev_cas)
+    real t_prof_cas(nlev_cas),theta_prof_cas(nlev_cas),thl_prof_cas(nlev_cas),thv_prof_cas(nlev_cas)
+    real qv_prof_cas(nlev_cas),ql_prof_cas(nlev_cas),qi_prof_cas(nlev_cas)
+    real u_prof_cas(nlev_cas),v_prof_cas(nlev_cas)
+    real ug_prof_cas(nlev_cas),vg_prof_cas(nlev_cas)
+    real temp_nudg_prof_cas(nlev_cas),qv_nudg_prof_cas(nlev_cas)
+    real u_nudg_prof_cas(nlev_cas),v_nudg_prof_cas(nlev_cas)
+
+    real invtau_temp_nudg_prof_cas(nlev_cas),invtau_qv_nudg_prof_cas(nlev_cas)
+    real invtau_u_nudg_prof_cas(nlev_cas),invtau_v_nudg_prof_cas(nlev_cas)
+
+    real vitw_prof_cas(nlev_cas),omega_prof_cas(nlev_cas),tke_prof_cas(nlev_cas)
+    real du_prof_cas(nlev_cas),hu_prof_cas(nlev_cas),vu_prof_cas(nlev_cas)
+    real dv_prof_cas(nlev_cas),hv_prof_cas(nlev_cas),vv_prof_cas(nlev_cas)
+    real dt_prof_cas(nlev_cas),ht_prof_cas(nlev_cas),vt_prof_cas(nlev_cas)
+    real dth_prof_cas(nlev_cas),hth_prof_cas(nlev_cas),vth_prof_cas(nlev_cas)
+    real dtrad_prof_cas(nlev_cas)
+    real dq_prof_cas(nlev_cas),hq_prof_cas(nlev_cas),vq_prof_cas(nlev_cas)
+    real lat_prof_cas,sens_prof_cas,tkes_prof_cas,ts_prof_cas,tskin_prof_cas,ps_prof_cas,ustar_prof_cas
+    real uw_prof_cas(nlev_cas),vw_prof_cas(nlev_cas),q1_prof_cas(nlev_cas),q2_prof_cas(nlev_cas)
+    ! local:
+    integer it_cas1, it_cas2,k
+    real timeit,time_cas1,time_cas2,frac
+
+
+    print*,'Check time',day1,day_ju_ini_cas,day_deb+1,pdt_cas
+    !       do k=1,nlev_cas
+    !       print*,'debut de interp2_case_time, plev_cas=',k,plev_cas(k,1)
+    !       enddo
+
+    ! On teste si la date du cas AMMA est correcte.
+    ! C est pour memoire car en fait les fichiers .def
+    ! sont censes etre corrects.
+    ! A supprimer a terme (MPL 20150623)
+    !     if ((forcing_type.eq.10).and.(1.eq.0)) then
+    ! Check that initial day of the simulation consistent with AMMA case:
+    !      if (annee_ref.ne.2006) then
+    !       print*,'Pour AMMA, annee_ref doit etre 2006'
+    !       print*,'Changer annee_ref dans run.def'
+    !       stop
+    !      endif
+    !      if (annee_ref.eq.2006 .and. day1.lt.day_cas) then
+    !       print*,'AMMA a debute le 10 juillet 2006',day1,day_cas
+    !       print*,'Changer dayref dans run.def'
+    !       stop
+    !      endif
+    !      if (annee_ref.eq.2006 .and. day1.gt.day_cas+1) then
+    !       print*,'AMMA a fini le 11 juillet'
+    !       print*,'Changer dayref ou nday dans run.def'
+    !       stop
+    !      endif
+    !      endif
+
+    ! Determine timestep relative to the 1st day:
+    !       timeit=(day-day1)*86400.
+    !       if (annee_ref.eq.1992) then
+    !        timeit=(day-day_cas)*86400.
+    !       else
+    !        timeit=(day+61.-1.)*86400. ! 61 days between Nov01 and Dec31 1992
+    !       endif
+    timeit=(day-day_ju_ini_cas)*86400
+    print *,'day=',day
+    print *,'day_ju_ini_cas=',day_ju_ini_cas
+    print *,'pdt_cas=',pdt_cas
+    print *,'timeit=',timeit
+    print *,'nt_cas=',nt_cas
+
+    ! Determine the closest observation times:
+    !       it_cas1=INT(timeit/pdt_cas)+1
+    !       it_cas2=it_cas1 + 1
+    !       time_cas1=(it_cas1-1)*pdt_cas
+    !       time_cas2=(it_cas2-1)*pdt_cas
+
+    it_cas1=INT(timeit/pdt_cas)+1
+    IF (it_cas1 .EQ. nt_cas) THEN
        it_cas2=it_cas1 
-       ELSE
+    ELSE
        it_cas2=it_cas1 + 1
-       ENDIF
-       time_cas1=(it_cas1-1)*pdt_cas
-       time_cas2=(it_cas2-1)*pdt_cas
-!     print *,'timeit,pdt_cas,nt_cas=',timeit,pdt_cas,nt_cas
-!     print *,'it_cas1,it_cas2,time_cas1,time_cas2=',it_cas1,it_cas2,time_cas1,time_cas2
-
-       if (it_cas1 .gt. nt_cas) then 
-        write(*,*) 'PB-stop: day, day_ju_ini_cas,it_cas1, it_cas2, timeit: '            &
-     &        ,day,day_ju_ini_cas,it_cas1,it_cas2,timeit
-        stop
-       endif
-
-! time interpolation:
-       IF (it_cas1 .EQ. it_cas2) THEN
-          frac=0.
-       ELSE
-          frac=(time_cas2-timeit)/(time_cas2-time_cas1)
-          frac=max(frac,0.0)
-       ENDIF
-
-       lat_prof_cas = lat_cas(it_cas2)                                   &
-     &          -frac*(lat_cas(it_cas2)-lat_cas(it_cas1)) 
-       sens_prof_cas = sens_cas(it_cas2)                                 &
-     &          -frac*(sens_cas(it_cas2)-sens_cas(it_cas1))
-       tkes_prof_cas = tkes_cas(it_cas2)                                   &
-     &          -frac*(tkes_cas(it_cas2)-tkes_cas(it_cas1))
-       ts_prof_cas = ts_cas(it_cas2)                                     &
-     &          -frac*(ts_cas(it_cas2)-ts_cas(it_cas1))
-       ps_prof_cas = ps_cas(it_cas2)                                     &
-     &          -frac*(ps_cas(it_cas2)-ps_cas(it_cas1))
-       ustar_prof_cas = ustar_cas(it_cas2)                               &
-     &          -frac*(ustar_cas(it_cas2)-ustar_cas(it_cas1))
-
-       do k=1,nlev_cas
-        plev_prof_cas(k) = plev_cas(k,it_cas2)                           &     
-     &          -frac*(plev_cas(k,it_cas2)-plev_cas(k,it_cas1))
-        t_prof_cas(k) = t_cas(k,it_cas2)                                 &        
-     &          -frac*(t_cas(k,it_cas2)-t_cas(k,it_cas1))
-        !print *,'k,frac,plev_cas1,plev_cas2=',k,frac,plev_cas(k,it_cas1),plev_cas(k,it_cas2)
-        theta_prof_cas(k) = theta_cas(k,it_cas2)                         &                      
-     &          -frac*(theta_cas(k,it_cas2)-theta_cas(k,it_cas1))
-        thv_prof_cas(k) = thv_cas(k,it_cas2)                             &          
-     &          -frac*(thv_cas(k,it_cas2)-thv_cas(k,it_cas1))
-        thl_prof_cas(k) = thl_cas(k,it_cas2)                             &              
-     &          -frac*(thl_cas(k,it_cas2)-thl_cas(k,it_cas1))
-        qv_prof_cas(k) = qv_cas(k,it_cas2)                               &
-     &          -frac*(qv_cas(k,it_cas2)-qv_cas(k,it_cas1))
-        ql_prof_cas(k) = ql_cas(k,it_cas2)                               &
-     &          -frac*(ql_cas(k,it_cas2)-ql_cas(k,it_cas1))
-        qi_prof_cas(k) = qi_cas(k,it_cas2)                               &
-     &          -frac*(qi_cas(k,it_cas2)-qi_cas(k,it_cas1))
-        u_prof_cas(k) = u_cas(k,it_cas2)                                 &
-     &          -frac*(u_cas(k,it_cas2)-u_cas(k,it_cas1))
-        v_prof_cas(k) = v_cas(k,it_cas2)                                 &
-     &          -frac*(v_cas(k,it_cas2)-v_cas(k,it_cas1))
-        ug_prof_cas(k) = ug_cas(k,it_cas2)                               &
-     &          -frac*(ug_cas(k,it_cas2)-ug_cas(k,it_cas1))
-        vg_prof_cas(k) = vg_cas(k,it_cas2)                               &
-     &          -frac*(vg_cas(k,it_cas2)-vg_cas(k,it_cas1))
-        temp_nudg_prof_cas(k) = temp_nudg_cas(k,it_cas2)                    &
-     &          -frac*(temp_nudg_cas(k,it_cas2)-temp_nudg_cas(k,it_cas1))
-        qv_nudg_prof_cas(k) = qv_nudg_cas(k,it_cas2)                        &
-     &          -frac*(qv_nudg_cas(k,it_cas2)-qv_nudg_cas(k,it_cas1))
-        u_nudg_prof_cas(k) = u_nudg_cas(k,it_cas2)                          &
-     &          -frac*(u_nudg_cas(k,it_cas2)-u_nudg_cas(k,it_cas1))
-        v_nudg_prof_cas(k) = v_nudg_cas(k,it_cas2)                          &
-     &          -frac*(v_nudg_cas(k,it_cas2)-v_nudg_cas(k,it_cas1))
-        invtau_temp_nudg_prof_cas(k) = invtau_temp_nudg_cas(k,it_cas2)                    &
-     &          -frac*(invtau_temp_nudg_cas(k,it_cas2)-invtau_temp_nudg_cas(k,it_cas1))
-        invtau_qv_nudg_prof_cas(k) = invtau_qv_nudg_cas(k,it_cas2)                        &
-     &          -frac*(invtau_qv_nudg_cas(k,it_cas2)-invtau_qv_nudg_cas(k,it_cas1))
-        invtau_u_nudg_prof_cas(k) = invtau_u_nudg_cas(k,it_cas2)                          &
-     &          -frac*(invtau_u_nudg_cas(k,it_cas2)-invtau_u_nudg_cas(k,it_cas1))
-        invtau_v_nudg_prof_cas(k) = invtau_v_nudg_cas(k,it_cas2)                          &
-     &          -frac*(invtau_v_nudg_cas(k,it_cas2)-invtau_v_nudg_cas(k,it_cas1))
-        vitw_prof_cas(k) = vitw_cas(k,it_cas2)                           &
-     &          -frac*(vitw_cas(k,it_cas2)-vitw_cas(k,it_cas1))
-        omega_prof_cas(k) = omega_cas(k,it_cas2)                         &
-     &          -frac*(omega_cas(k,it_cas2)-omega_cas(k,it_cas1))
-        tke_prof_cas(k) = tke_cas(k,it_cas2)                         &
-     &          -frac*(tke_cas(k,it_cas2)-tke_cas(k,it_cas1))
-        du_prof_cas(k) = du_cas(k,it_cas2)                               &
-     &          -frac*(du_cas(k,it_cas2)-du_cas(k,it_cas1))
-        hu_prof_cas(k) = hu_cas(k,it_cas2)                               &
-     &          -frac*(hu_cas(k,it_cas2)-hu_cas(k,it_cas1))
-        vu_prof_cas(k) = vu_cas(k,it_cas2)                               &
-     &          -frac*(vu_cas(k,it_cas2)-vu_cas(k,it_cas1))
-        dv_prof_cas(k) = dv_cas(k,it_cas2)                               &
-     &          -frac*(dv_cas(k,it_cas2)-dv_cas(k,it_cas1))
-        hv_prof_cas(k) = hv_cas(k,it_cas2)                               &
-     &          -frac*(hv_cas(k,it_cas2)-hv_cas(k,it_cas1))
-        vv_prof_cas(k) = vv_cas(k,it_cas2)                               &
-     &          -frac*(vv_cas(k,it_cas2)-vv_cas(k,it_cas1))
-        dt_prof_cas(k) = dt_cas(k,it_cas2)                               &
-     &          -frac*(dt_cas(k,it_cas2)-dt_cas(k,it_cas1))
-        ht_prof_cas(k) = ht_cas(k,it_cas2)                               &
-     &          -frac*(ht_cas(k,it_cas2)-ht_cas(k,it_cas1))
-        vt_prof_cas(k) = vt_cas(k,it_cas2)                               &
-     &          -frac*(vt_cas(k,it_cas2)-vt_cas(k,it_cas1))
-        dth_prof_cas(k) = dth_cas(k,it_cas2)                             &
-     &          -frac*(dth_cas(k,it_cas2)-dth_cas(k,it_cas1))
-        hth_prof_cas(k) = hth_cas(k,it_cas2)                             &
-     &          -frac*(hth_cas(k,it_cas2)-hth_cas(k,it_cas1))
-        vth_prof_cas(k) = vth_cas(k,it_cas2)                             &
-     &          -frac*(vth_cas(k,it_cas2)-vth_cas(k,it_cas1))
-        dtrad_prof_cas(k) = dtrad_cas(k,it_cas2)                         &
-     &          -frac*(dtrad_cas(k,it_cas2)-dtrad_cas(k,it_cas1))
-        dq_prof_cas(k) = dq_cas(k,it_cas2)                               &
-     &          -frac*(dq_cas(k,it_cas2)-dq_cas(k,it_cas1))
-        hq_prof_cas(k) = hq_cas(k,it_cas2)                               &
-     &          -frac*(hq_cas(k,it_cas2)-hq_cas(k,it_cas1))
-        vq_prof_cas(k) = vq_cas(k,it_cas2)                               &
-     &          -frac*(vq_cas(k,it_cas2)-vq_cas(k,it_cas1))
+    ENDIF
+    time_cas1=(it_cas1-1)*pdt_cas
+    time_cas2=(it_cas2-1)*pdt_cas
+    !     print *,'timeit,pdt_cas,nt_cas=',timeit,pdt_cas,nt_cas
+    !     print *,'it_cas1,it_cas2,time_cas1,time_cas2=',it_cas1,it_cas2,time_cas1,time_cas2
+
+    if (it_cas1 .gt. nt_cas) then 
+       write(*,*) 'PB-stop: day, day_ju_ini_cas,it_cas1, it_cas2, timeit: '            &
+            ,day,day_ju_ini_cas,it_cas1,it_cas2,timeit
+       stop
+    endif
+
+    ! time interpolation:
+    IF (it_cas1 .EQ. it_cas2) THEN
+       frac=0.
+    ELSE
+       frac=(time_cas2-timeit)/(time_cas2-time_cas1)
+       frac=max(frac,0.0)
+    ENDIF
+
+    lat_prof_cas = lat_cas(it_cas2)                                   &
+         -frac*(lat_cas(it_cas2)-lat_cas(it_cas1)) 
+    sens_prof_cas = sens_cas(it_cas2)                                 &
+         -frac*(sens_cas(it_cas2)-sens_cas(it_cas1))
+    tkes_prof_cas = tkes_cas(it_cas2)                                   &
+         -frac*(tkes_cas(it_cas2)-tkes_cas(it_cas1))
+    ts_prof_cas = ts_cas(it_cas2)                                     &
+         -frac*(ts_cas(it_cas2)-ts_cas(it_cas1))
+    tskin_prof_cas = tskin_cas(it_cas2)                                     &
+         -frac*(tskin_cas(it_cas2)-tskin_cas(it_cas1))
+    ps_prof_cas = ps_cas(it_cas2)                                     &
+         -frac*(ps_cas(it_cas2)-ps_cas(it_cas1))
+    ustar_prof_cas = ustar_cas(it_cas2)                               &
+         -frac*(ustar_cas(it_cas2)-ustar_cas(it_cas1))
+
+    do k=1,nlev_cas
+       plev_prof_cas(k) = plev_cas(k,it_cas2)                           &     
+            -frac*(plev_cas(k,it_cas2)-plev_cas(k,it_cas1))
+       t_prof_cas(k) = t_cas(k,it_cas2)                                 &        
+            -frac*(t_cas(k,it_cas2)-t_cas(k,it_cas1))
+       !print *,'k,frac,plev_cas1,plev_cas2=',k,frac,plev_cas(k,it_cas1),plev_cas(k,it_cas2)
+       theta_prof_cas(k) = theta_cas(k,it_cas2)                         &                      
+            -frac*(theta_cas(k,it_cas2)-theta_cas(k,it_cas1))
+       thv_prof_cas(k) = thv_cas(k,it_cas2)                             &          
+            -frac*(thv_cas(k,it_cas2)-thv_cas(k,it_cas1))
+       thl_prof_cas(k) = thl_cas(k,it_cas2)                             &              
+            -frac*(thl_cas(k,it_cas2)-thl_cas(k,it_cas1))
+       qv_prof_cas(k) = qv_cas(k,it_cas2)                               &
+            -frac*(qv_cas(k,it_cas2)-qv_cas(k,it_cas1))
+       ql_prof_cas(k) = ql_cas(k,it_cas2)                               &
+            -frac*(ql_cas(k,it_cas2)-ql_cas(k,it_cas1))
+       qi_prof_cas(k) = qi_cas(k,it_cas2)                               &
+            -frac*(qi_cas(k,it_cas2)-qi_cas(k,it_cas1))
+       u_prof_cas(k) = u_cas(k,it_cas2)                                 &
+            -frac*(u_cas(k,it_cas2)-u_cas(k,it_cas1))
+       v_prof_cas(k) = v_cas(k,it_cas2)                                 &
+            -frac*(v_cas(k,it_cas2)-v_cas(k,it_cas1))
+       ug_prof_cas(k) = ug_cas(k,it_cas2)                               &
+            -frac*(ug_cas(k,it_cas2)-ug_cas(k,it_cas1))
+       vg_prof_cas(k) = vg_cas(k,it_cas2)                               &
+            -frac*(vg_cas(k,it_cas2)-vg_cas(k,it_cas1))
+       temp_nudg_prof_cas(k) = temp_nudg_cas(k,it_cas2)                    &
+            -frac*(temp_nudg_cas(k,it_cas2)-temp_nudg_cas(k,it_cas1))
+       qv_nudg_prof_cas(k) = qv_nudg_cas(k,it_cas2)                        &
+            -frac*(qv_nudg_cas(k,it_cas2)-qv_nudg_cas(k,it_cas1))
+       u_nudg_prof_cas(k) = u_nudg_cas(k,it_cas2)                          &
+            -frac*(u_nudg_cas(k,it_cas2)-u_nudg_cas(k,it_cas1))
+       v_nudg_prof_cas(k) = v_nudg_cas(k,it_cas2)                          &
+            -frac*(v_nudg_cas(k,it_cas2)-v_nudg_cas(k,it_cas1))
+       invtau_temp_nudg_prof_cas(k) = invtau_temp_nudg_cas(k,it_cas2)                    &
+            -frac*(invtau_temp_nudg_cas(k,it_cas2)-invtau_temp_nudg_cas(k,it_cas1))
+       invtau_qv_nudg_prof_cas(k) = invtau_qv_nudg_cas(k,it_cas2)                        &
+            -frac*(invtau_qv_nudg_cas(k,it_cas2)-invtau_qv_nudg_cas(k,it_cas1))
+       invtau_u_nudg_prof_cas(k) = invtau_u_nudg_cas(k,it_cas2)                          &
+            -frac*(invtau_u_nudg_cas(k,it_cas2)-invtau_u_nudg_cas(k,it_cas1))
+       invtau_v_nudg_prof_cas(k) = invtau_v_nudg_cas(k,it_cas2)                          &
+            -frac*(invtau_v_nudg_cas(k,it_cas2)-invtau_v_nudg_cas(k,it_cas1))
+       vitw_prof_cas(k) = vitw_cas(k,it_cas2)                           &
+            -frac*(vitw_cas(k,it_cas2)-vitw_cas(k,it_cas1))
+       omega_prof_cas(k) = omega_cas(k,it_cas2)                         &
+            -frac*(omega_cas(k,it_cas2)-omega_cas(k,it_cas1))
+       tke_prof_cas(k) = tke_cas(k,it_cas2)                         &
+            -frac*(tke_cas(k,it_cas2)-tke_cas(k,it_cas1))
+       du_prof_cas(k) = du_cas(k,it_cas2)                               &
+            -frac*(du_cas(k,it_cas2)-du_cas(k,it_cas1))
+       hu_prof_cas(k) = hu_cas(k,it_cas2)                               &
+            -frac*(hu_cas(k,it_cas2)-hu_cas(k,it_cas1))
+       vu_prof_cas(k) = vu_cas(k,it_cas2)                               &
+            -frac*(vu_cas(k,it_cas2)-vu_cas(k,it_cas1))
+       dv_prof_cas(k) = dv_cas(k,it_cas2)                               &
+            -frac*(dv_cas(k,it_cas2)-dv_cas(k,it_cas1))
+       hv_prof_cas(k) = hv_cas(k,it_cas2)                               &
+            -frac*(hv_cas(k,it_cas2)-hv_cas(k,it_cas1))
+       vv_prof_cas(k) = vv_cas(k,it_cas2)                               &
+            -frac*(vv_cas(k,it_cas2)-vv_cas(k,it_cas1))
+       dt_prof_cas(k) = dt_cas(k,it_cas2)                               &
+            -frac*(dt_cas(k,it_cas2)-dt_cas(k,it_cas1))
+       ht_prof_cas(k) = ht_cas(k,it_cas2)                               &
+            -frac*(ht_cas(k,it_cas2)-ht_cas(k,it_cas1))
+       vt_prof_cas(k) = vt_cas(k,it_cas2)                               &
+            -frac*(vt_cas(k,it_cas2)-vt_cas(k,it_cas1))
+       dth_prof_cas(k) = dth_cas(k,it_cas2)                             &
+            -frac*(dth_cas(k,it_cas2)-dth_cas(k,it_cas1))
+       hth_prof_cas(k) = hth_cas(k,it_cas2)                             &
+            -frac*(hth_cas(k,it_cas2)-hth_cas(k,it_cas1))
+       vth_prof_cas(k) = vth_cas(k,it_cas2)                             &
+            -frac*(vth_cas(k,it_cas2)-vth_cas(k,it_cas1))
+       dtrad_prof_cas(k) = dtrad_cas(k,it_cas2)                         &
+            -frac*(dtrad_cas(k,it_cas2)-dtrad_cas(k,it_cas1))
+       dq_prof_cas(k) = dq_cas(k,it_cas2)                               &
+            -frac*(dq_cas(k,it_cas2)-dq_cas(k,it_cas1))
+       hq_prof_cas(k) = hq_cas(k,it_cas2)                               &
+            -frac*(hq_cas(k,it_cas2)-hq_cas(k,it_cas1))
+       vq_prof_cas(k) = vq_cas(k,it_cas2)                               &
+            -frac*(vq_cas(k,it_cas2)-vq_cas(k,it_cas1))
        uw_prof_cas(k) = uw_cas(k,it_cas2)                                &
-     &          -frac*(uw_cas(k,it_cas2)-uw_cas(k,it_cas1))
+            -frac*(uw_cas(k,it_cas2)-uw_cas(k,it_cas1))
        vw_prof_cas(k) = vw_cas(k,it_cas2)                                &
-     &          -frac*(vw_cas(k,it_cas2)-vw_cas(k,it_cas1))
+            -frac*(vw_cas(k,it_cas2)-vw_cas(k,it_cas1))
        q1_prof_cas(k) = q1_cas(k,it_cas2)                                &
-     &          -frac*(q1_cas(k,it_cas2)-q1_cas(k,it_cas1))
+            -frac*(q1_cas(k,it_cas2)-q1_cas(k,it_cas1))
        q2_prof_cas(k) = q2_cas(k,it_cas2)                                &
-     &          -frac*(q2_cas(k,it_cas2)-q2_cas(k,it_cas1))
-        enddo
-
-        return
-        END SUBROUTINE interp_case_time_std
-
-!**********************************************************************************************
-!=====================================================================
-       SUBROUTINE interp2_case_vertical_std(play,plev,nlev_cas,plev_prof_cas                           &
-     &         ,t_prof_cas,th_prof_cas,thv_prof_cas,thl_prof_cas                                       &
-     &         ,qv_prof_cas,ql_prof_cas,qi_prof_cas,u_prof_cas,v_prof_cas                              &
-     &         ,ug_prof_cas,vg_prof_cas                                                                &
-     &         ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas                    &
-     &         ,invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas &     
-     &         ,vitw_prof_cas,omega_prof_cas,tke_prof_cas                                              &
-     &         ,du_prof_cas,hu_prof_cas,vu_prof_cas,dv_prof_cas,hv_prof_cas,vv_prof_cas                &
-     &         ,dt_prof_cas,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas,hq_prof_cas,vq_prof_cas &
-     &         ,dth_prof_cas,hth_prof_cas,vth_prof_cas                                                 &
-!
-     &         ,t_mod_cas,theta_mod_cas,thv_mod_cas,thl_mod_cas                                        &
-     &         ,qv_mod_cas,ql_mod_cas,qi_mod_cas,u_mod_cas,v_mod_cas                                   &
-     &         ,ug_mod_cas,vg_mod_cas                                                                  &
-     &         ,temp_nudg_mod_cas,qv_nudg_mod_cas,u_nudg_mod_cas,v_nudg_mod_cas                        &
-     &         ,invtau_temp_nudg_mod_cas,invtau_qv_nudg_mod_cas,invtau_u_nudg_mod_cas,invtau_v_nudg_mod_cas                        &     
-     &         ,w_mod_cas,omega_mod_cas,tke_mod_cas                                                    &
-     &         ,du_mod_cas,hu_mod_cas,vu_mod_cas,dv_mod_cas,hv_mod_cas,vv_mod_cas                      &
-     &         ,dt_mod_cas,ht_mod_cas,vt_mod_cas,dtrad_mod_cas,dq_mod_cas,hq_mod_cas,vq_mod_cas        &
-     &         ,dth_mod_cas,hth_mod_cas,vth_mod_cas,mxcalc)
- 
-       implicit none
- 
+            -frac*(q2_cas(k,it_cas2)-q2_cas(k,it_cas1))
+    enddo
+
+    return
+  END SUBROUTINE interp_case_time_std
+
+  !**********************************************************************************************
+  !=====================================================================
+  SUBROUTINE interp2_case_vertical_std(play,plev,nlev_cas,plev_prof_cas                           &
+       ,t_prof_cas,th_prof_cas,thv_prof_cas,thl_prof_cas                                       &
+       ,qv_prof_cas,ql_prof_cas,qi_prof_cas,u_prof_cas,v_prof_cas                              &
+       ,ug_prof_cas,vg_prof_cas                                                                &
+       ,temp_nudg_prof_cas,qv_nudg_prof_cas,u_nudg_prof_cas,v_nudg_prof_cas                    &
+       ,invtau_temp_nudg_prof_cas,invtau_qv_nudg_prof_cas,invtau_u_nudg_prof_cas,invtau_v_nudg_prof_cas &     
+       ,vitw_prof_cas,omega_prof_cas,tke_prof_cas                                              &
+       ,du_prof_cas,hu_prof_cas,vu_prof_cas,dv_prof_cas,hv_prof_cas,vv_prof_cas                &
+       ,dt_prof_cas,ht_prof_cas,vt_prof_cas,dtrad_prof_cas,dq_prof_cas,hq_prof_cas,vq_prof_cas &
+       ,dth_prof_cas,hth_prof_cas,vth_prof_cas                                                 &
+       !
+       ,t_mod_cas,theta_mod_cas,thv_mod_cas,thl_mod_cas                                        &
+       ,qv_mod_cas,ql_mod_cas,qi_mod_cas,u_mod_cas,v_mod_cas                                   &
+       ,ug_mod_cas,vg_mod_cas                                                                  &
+       ,temp_nudg_mod_cas,qv_nudg_mod_cas,u_nudg_mod_cas,v_nudg_mod_cas                        &
+       ,invtau_temp_nudg_mod_cas,invtau_qv_nudg_mod_cas,invtau_u_nudg_mod_cas,invtau_v_nudg_mod_cas                        &     
+       ,w_mod_cas,omega_mod_cas,tke_mod_cas                                                    &
+       ,du_mod_cas,hu_mod_cas,vu_mod_cas,dv_mod_cas,hv_mod_cas,vv_mod_cas                      &
+       ,dt_mod_cas,ht_mod_cas,vt_mod_cas,dtrad_mod_cas,dq_mod_cas,hq_mod_cas,vq_mod_cas        &
+       ,dth_mod_cas,hth_mod_cas,vth_mod_cas,mxcalc)
+
+    implicit none
+
 #include "YOMCST.h"
 #include "dimensions.h"
 
-!-------------------------------------------------------------------------
-! Vertical interpolation of generic case forcing data onto mod_casel levels
-!-------------------------------------------------------------------------
- 
-       integer nlevmax
-       parameter (nlevmax=41)
-       integer nlev_cas,mxcalc
-!       real play(llm), plev_prof(nlevmax) 
-!       real t_prof(nlevmax),q_prof(nlevmax)
-!       real u_prof(nlevmax),v_prof(nlevmax), w_prof(nlevmax)
-!       real ht_prof(nlevmax),vt_prof(nlevmax)
-!       real hq_prof(nlevmax),vq_prof(nlevmax)
- 
-       real play(llm), plev(llm+1), plev_prof_cas(nlev_cas) 
-       real t_prof_cas(nlev_cas),th_prof_cas(nlev_cas),thv_prof_cas(nlev_cas),thl_prof_cas(nlev_cas)
-       real qv_prof_cas(nlev_cas),ql_prof_cas(nlev_cas),qi_prof_cas(nlev_cas)
-       real u_prof_cas(nlev_cas),v_prof_cas(nlev_cas)
-       real ug_prof_cas(nlev_cas),vg_prof_cas(nlev_cas), vitw_prof_cas(nlev_cas),omega_prof_cas(nlev_cas),tke_prof_cas(nlev_cas)
-       real temp_nudg_prof_cas(nlev_cas),qv_nudg_prof_cas(nlev_cas)
-       real u_nudg_prof_cas(nlev_cas),v_nudg_prof_cas(nlev_cas)
-       real invtau_temp_nudg_prof_cas(nlev_cas),invtau_qv_nudg_prof_cas(nlev_cas)
-       real invtau_u_nudg_prof_cas(nlev_cas),invtau_v_nudg_prof_cas(nlev_cas)
-
-       real du_prof_cas(nlev_cas),hu_prof_cas(nlev_cas),vu_prof_cas(nlev_cas)
-       real dv_prof_cas(nlev_cas),hv_prof_cas(nlev_cas),vv_prof_cas(nlev_cas)
-       real dt_prof_cas(nlev_cas),ht_prof_cas(nlev_cas),vt_prof_cas(nlev_cas),dtrad_prof_cas(nlev_cas)
-       real dth_prof_cas(nlev_cas),hth_prof_cas(nlev_cas),vth_prof_cas(nlev_cas)
-       real dq_prof_cas(nlev_cas),hq_prof_cas(nlev_cas),vq_prof_cas(nlev_cas)
- 
-       real t_mod_cas(llm),theta_mod_cas(llm),thv_mod_cas(llm),thl_mod_cas(llm)
-       real qv_mod_cas(llm),ql_mod_cas(llm),qi_mod_cas(llm)
-       real u_mod_cas(llm),v_mod_cas(llm)
-       real ug_mod_cas(llm),vg_mod_cas(llm), w_mod_cas(llm),omega_mod_cas(llm),tke_mod_cas(llm+1)
-       real temp_nudg_mod_cas(llm),qv_nudg_mod_cas(llm)
-       real u_nudg_mod_cas(llm),v_nudg_mod_cas(llm)
-       real invtau_temp_nudg_mod_cas(llm),invtau_qv_nudg_mod_cas(llm)
-       real invtau_u_nudg_mod_cas(llm),invtau_v_nudg_mod_cas(llm)
-       real du_mod_cas(llm),hu_mod_cas(llm),vu_mod_cas(llm)
-       real dv_mod_cas(llm),hv_mod_cas(llm),vv_mod_cas(llm)
-       real dt_mod_cas(llm),ht_mod_cas(llm),vt_mod_cas(llm),dtrad_mod_cas(llm)
-       real dth_mod_cas(llm),hth_mod_cas(llm),vth_mod_cas(llm)
-       real dq_mod_cas(llm),hq_mod_cas(llm),vq_mod_cas(llm)
- 
-       integer l,k,k1,k2
-       real frac,frac1,frac2,fact
- 
-
-
-! for variables defined at the middle of layers
-
-       do l = 1, llm
-
-        if (play(l).ge.plev_prof_cas(nlev_cas)) then
- 
-        mxcalc=l
-!        print *,'debut interp2, mxcalc=',mxcalc
-         k1=0
-         k2=0
-
-         if (play(l).le.plev_prof_cas(1)) then
-
-         do k = 1, nlev_cas-1
-          if (play(l).le.plev_prof_cas(k).and. play(l).gt.plev_prof_cas(k+1)) then
-            k1=k
-            k2=k+1
-          endif
-         enddo
-
-         if (k1.eq.0 .or. k2.eq.0) then
-          write(*,*) 'PB! k1, k2 = ',k1,k2
-          write(*,*) 'l,play(l) = ',l,play(l)/100
-         do k = 1, nlev_cas-1
-          write(*,*) 'k,plev_prof_cas(k) = ',k,plev_prof_cas(k)/100
-         enddo
-         endif
-
-
-
-         frac = (plev_prof_cas(k2)-play(l))/(plev_prof_cas(k2)-plev_prof_cas(k1))
-         
-         t_mod_cas(l)= t_prof_cas(k2) - frac*(t_prof_cas(k2)-t_prof_cas(k1))
-         theta_mod_cas(l)= th_prof_cas(k2) - frac*(th_prof_cas(k2)-th_prof_cas(k1))
-         if(theta_mod_cas(l).NE.0) t_mod_cas(l)= theta_mod_cas(l)*(play(l)/100000.)**(RD/RCPD)
-         thv_mod_cas(l)= thv_prof_cas(k2) - frac*(thv_prof_cas(k2)-thv_prof_cas(k1))
-         thl_mod_cas(l)= thl_prof_cas(k2) - frac*(thl_prof_cas(k2)-thl_prof_cas(k1))
-         qv_mod_cas(l)= qv_prof_cas(k2) - frac*(qv_prof_cas(k2)-qv_prof_cas(k1))
-         ql_mod_cas(l)= ql_prof_cas(k2) - frac*(ql_prof_cas(k2)-ql_prof_cas(k1))
-         qi_mod_cas(l)= qi_prof_cas(k2) - frac*(qi_prof_cas(k2)-qi_prof_cas(k1))
-         u_mod_cas(l)= u_prof_cas(k2) - frac*(u_prof_cas(k2)-u_prof_cas(k1))
-         v_mod_cas(l)= v_prof_cas(k2) - frac*(v_prof_cas(k2)-v_prof_cas(k1))
-         ug_mod_cas(l)= ug_prof_cas(k2) - frac*(ug_prof_cas(k2)-ug_prof_cas(k1))
-         vg_mod_cas(l)= vg_prof_cas(k2) - frac*(vg_prof_cas(k2)-vg_prof_cas(k1))
-         temp_nudg_mod_cas(l)= temp_nudg_prof_cas(k2) - frac*(temp_nudg_prof_cas(k2)-temp_nudg_prof_cas(k1))
-         qv_nudg_mod_cas(l)= qv_nudg_prof_cas(k2) - frac*(qv_nudg_prof_cas(k2)-qv_nudg_prof_cas(k1))
-         u_nudg_mod_cas(l)= u_nudg_prof_cas(k2) - frac*(u_nudg_prof_cas(k2)-u_nudg_prof_cas(k1))
-         v_nudg_mod_cas(l)= v_nudg_prof_cas(k2) - frac*(v_nudg_prof_cas(k2)-v_nudg_prof_cas(k1))
-
-         invtau_temp_nudg_mod_cas(l)= invtau_temp_nudg_prof_cas(k2) - frac*(invtau_temp_nudg_prof_cas(k2)-invtau_temp_nudg_prof_cas(k1))
-         invtau_qv_nudg_mod_cas(l)= invtau_qv_nudg_prof_cas(k2) - frac*(invtau_qv_nudg_prof_cas(k2)-invtau_qv_nudg_prof_cas(k1))
-         invtau_u_nudg_mod_cas(l)= invtau_u_nudg_prof_cas(k2) - frac*(invtau_u_nudg_prof_cas(k2)-invtau_u_nudg_prof_cas(k1))
-         invtau_v_nudg_mod_cas(l)= invtau_v_nudg_prof_cas(k2) - frac*(invtau_v_nudg_prof_cas(k2)-invtau_v_nudg_prof_cas(k1))
-
-         w_mod_cas(l)= vitw_prof_cas(k2) - frac*(vitw_prof_cas(k2)-vitw_prof_cas(k1))
-         omega_mod_cas(l)= omega_prof_cas(k2) - frac*(omega_prof_cas(k2)-omega_prof_cas(k1))
-         du_mod_cas(l)= du_prof_cas(k2) - frac*(du_prof_cas(k2)-du_prof_cas(k1))
-         hu_mod_cas(l)= hu_prof_cas(k2) - frac*(hu_prof_cas(k2)-hu_prof_cas(k1))
-         vu_mod_cas(l)= vu_prof_cas(k2) - frac*(vu_prof_cas(k2)-vu_prof_cas(k1))
-         dv_mod_cas(l)= dv_prof_cas(k2) - frac*(dv_prof_cas(k2)-dv_prof_cas(k1))
-         hv_mod_cas(l)= hv_prof_cas(k2) - frac*(hv_prof_cas(k2)-hv_prof_cas(k1))
-         vv_mod_cas(l)= vv_prof_cas(k2) - frac*(vv_prof_cas(k2)-vv_prof_cas(k1))
-         dt_mod_cas(l)= dt_prof_cas(k2) - frac*(dt_prof_cas(k2)-dt_prof_cas(k1))
-         ht_mod_cas(l)= ht_prof_cas(k2) - frac*(ht_prof_cas(k2)-ht_prof_cas(k1))
-         vt_mod_cas(l)= vt_prof_cas(k2) - frac*(vt_prof_cas(k2)-vt_prof_cas(k1))
-         dth_mod_cas(l)= dth_prof_cas(k2) - frac*(dth_prof_cas(k2)-dth_prof_cas(k1))
-         hth_mod_cas(l)= hth_prof_cas(k2) - frac*(hth_prof_cas(k2)-hth_prof_cas(k1))
-         vth_mod_cas(l)= vth_prof_cas(k2) - frac*(vth_prof_cas(k2)-vth_prof_cas(k1))
-         dq_mod_cas(l)= dq_prof_cas(k2) - frac*(dq_prof_cas(k2)-dq_prof_cas(k1))
-         hq_mod_cas(l)= hq_prof_cas(k2) - frac*(hq_prof_cas(k2)-hq_prof_cas(k1))
-         vq_mod_cas(l)= vq_prof_cas(k2) - frac*(vq_prof_cas(k2)-vq_prof_cas(k1))
-         dtrad_mod_cas(l)= dtrad_prof_cas(k2) - frac*(dtrad_prof_cas(k2)-dtrad_prof_cas(k1))
-     
-         else !play>plev_prof_cas(1)
-
-         k1=1
-         k2=2
-         print *,'interp2_vert, k1,k2=',plev_prof_cas(k1),plev_prof_cas(k2)
-         frac1 = (play(l)-plev_prof_cas(k2))/(plev_prof_cas(k1)-plev_prof_cas(k2))
-         frac2 = (play(l)-plev_prof_cas(k1))/(plev_prof_cas(k1)-plev_prof_cas(k2))
-         t_mod_cas(l)= frac1*t_prof_cas(k1) - frac2*t_prof_cas(k2)
-         theta_mod_cas(l)= frac1*th_prof_cas(k1) - frac2*th_prof_cas(k2)
-         if(theta_mod_cas(l).NE.0) t_mod_cas(l)= theta_mod_cas(l)*(play(l)/100000.)**(RD/RCPD)
-         thv_mod_cas(l)= frac1*thv_prof_cas(k1) - frac2*thv_prof_cas(k2)
-         thl_mod_cas(l)= frac1*thl_prof_cas(k1) - frac2*thl_prof_cas(k2)
-         qv_mod_cas(l)= frac1*qv_prof_cas(k1) - frac2*qv_prof_cas(k2)
-         ql_mod_cas(l)= frac1*ql_prof_cas(k1) - frac2*ql_prof_cas(k2)
-         qi_mod_cas(l)= frac1*qi_prof_cas(k1) - frac2*qi_prof_cas(k2)
-         u_mod_cas(l)= frac1*u_prof_cas(k1) - frac2*u_prof_cas(k2)
-         v_mod_cas(l)= frac1*v_prof_cas(k1) - frac2*v_prof_cas(k2)
-         ug_mod_cas(l)= frac1*ug_prof_cas(k1) - frac2*ug_prof_cas(k2)
-         vg_mod_cas(l)= frac1*vg_prof_cas(k1) - frac2*vg_prof_cas(k2)
-         temp_nudg_mod_cas(l)= frac1*temp_nudg_prof_cas(k1) - frac2*temp_nudg_prof_cas(k2)
-         qv_nudg_mod_cas(l)= frac1*qv_nudg_prof_cas(k1) - frac2*qv_nudg_prof_cas(k2)
-         u_nudg_mod_cas(l)= frac1*u_nudg_prof_cas(k1) - frac2*u_nudg_prof_cas(k2)
-         v_nudg_mod_cas(l)= frac1*v_nudg_prof_cas(k1) - frac2*v_nudg_prof_cas(k2)
-
-         invtau_temp_nudg_mod_cas(l)= frac1*invtau_temp_nudg_prof_cas(k1) - frac2*invtau_temp_nudg_prof_cas(k2)
-         invtau_qv_nudg_mod_cas(l)= frac1*invtau_qv_nudg_prof_cas(k1) - frac2*invtau_qv_nudg_prof_cas(k2)
-         invtau_u_nudg_mod_cas(l)= frac1*invtau_u_nudg_prof_cas(k1) - frac2*invtau_u_nudg_prof_cas(k2)
-         invtau_v_nudg_mod_cas(l)= frac1*invtau_v_nudg_prof_cas(k1) - frac2*invtau_v_nudg_prof_cas(k2)
-
-         w_mod_cas(l)= frac1*vitw_prof_cas(k1) - frac2*vitw_prof_cas(k2)
-         omega_mod_cas(l)= frac1*omega_prof_cas(k1) - frac2*omega_prof_cas(k2)
-         du_mod_cas(l)= frac1*du_prof_cas(k1) - frac2*du_prof_cas(k2)
-         hu_mod_cas(l)= frac1*hu_prof_cas(k1) - frac2*hu_prof_cas(k2)
-         vu_mod_cas(l)= frac1*vu_prof_cas(k1) - frac2*vu_prof_cas(k2)
-         dv_mod_cas(l)= frac1*dv_prof_cas(k1) - frac2*dv_prof_cas(k2)
-         hv_mod_cas(l)= frac1*hv_prof_cas(k1) - frac2*hv_prof_cas(k2)
-         vv_mod_cas(l)= frac1*vv_prof_cas(k1) - frac2*vv_prof_cas(k2)
-         dt_mod_cas(l)= frac1*dt_prof_cas(k1) - frac2*dt_prof_cas(k2)
-         ht_mod_cas(l)= frac1*ht_prof_cas(k1) - frac2*ht_prof_cas(k2)
-         vt_mod_cas(l)= frac1*vt_prof_cas(k1) - frac2*vt_prof_cas(k2)
-         dth_mod_cas(l)= frac1*dth_prof_cas(k1) - frac2*dth_prof_cas(k2)
-         hth_mod_cas(l)= frac1*hth_prof_cas(k1) - frac2*hth_prof_cas(k2)
-         vth_mod_cas(l)= frac1*vth_prof_cas(k1) - frac2*vth_prof_cas(k2)
-         dq_mod_cas(l)= frac1*dq_prof_cas(k1) - frac2*dq_prof_cas(k2)
-         hq_mod_cas(l)= frac1*hq_prof_cas(k1) - frac2*hq_prof_cas(k2)
-         vq_mod_cas(l)= frac1*vq_prof_cas(k1) - frac2*vq_prof_cas(k2)
-         dtrad_mod_cas(l)= frac1*dtrad_prof_cas(k1) - frac2*dtrad_prof_cas(k2)
-
-         endif ! play.le.plev_prof_cas(1)
-
-        else ! above max altitude of forcing file
- 
-!jyg
-         fact=20.*(plev_prof_cas(nlev_cas)-play(l))/plev_prof_cas(nlev_cas) !jyg
-         fact = max(fact,0.)                                           !jyg
-         fact = exp(-fact)                                             !jyg
-         t_mod_cas(l)= t_prof_cas(nlev_cas)                            !jyg
-         theta_mod_cas(l)= th_prof_cas(nlev_cas)                       !jyg
-         thv_mod_cas(l)= thv_prof_cas(nlev_cas)                        !jyg
-         thl_mod_cas(l)= thl_prof_cas(nlev_cas)                        !jyg
-         qv_mod_cas(l)= qv_prof_cas(nlev_cas)*fact                     !jyg
-         ql_mod_cas(l)= ql_prof_cas(nlev_cas)*fact                     !jyg
-         qi_mod_cas(l)= qi_prof_cas(nlev_cas)*fact                     !jyg
-         u_mod_cas(l)= u_prof_cas(nlev_cas)*fact                       !jyg
-         v_mod_cas(l)= v_prof_cas(nlev_cas)*fact                       !jyg
-         ug_mod_cas(l)= ug_prof_cas(nlev_cas)                          !jyg
-         vg_mod_cas(l)= vg_prof_cas(nlev_cas)                          !jyg
-         temp_nudg_mod_cas(l)= temp_nudg_prof_cas(nlev_cas)            !jyg
-         qv_nudg_mod_cas(l)= qv_nudg_prof_cas(nlev_cas)                !jyg
-         u_nudg_mod_cas(l)= u_nudg_prof_cas(nlev_cas)                  !jyg
-         v_nudg_mod_cas(l)= v_nudg_prof_cas(nlev_cas)                  !jyg
-
-         invtau_temp_nudg_mod_cas(l)= invtau_temp_nudg_prof_cas(nlev_cas)            !jyg
-         invtau_qv_nudg_mod_cas(l)= invtau_qv_nudg_prof_cas(nlev_cas)                !jyg
-         invtau_u_nudg_mod_cas(l)= invtau_u_nudg_prof_cas(nlev_cas)                  !jyg
-         invtau_v_nudg_mod_cas(l)= invtau_v_nudg_prof_cas(nlev_cas)                  !jyg
-
-         thv_mod_cas(l)= thv_prof_cas(nlev_cas)                        !jyg
-         w_mod_cas(l)= 0.0                                             !jyg
-         omega_mod_cas(l)= 0.0                                         !jyg
-         du_mod_cas(l)= du_prof_cas(nlev_cas)*fact 
-         hu_mod_cas(l)= hu_prof_cas(nlev_cas)*fact                     !jyg
-         vu_mod_cas(l)= vu_prof_cas(nlev_cas)*fact                     !jyg
-         dv_mod_cas(l)= dv_prof_cas(nlev_cas)*fact
-         hv_mod_cas(l)= hv_prof_cas(nlev_cas)*fact                     !jyg
-         vv_mod_cas(l)= vv_prof_cas(nlev_cas)*fact                     !jyg
-         dt_mod_cas(l)= dt_prof_cas(nlev_cas) 
-         ht_mod_cas(l)= ht_prof_cas(nlev_cas)                          !jyg
-         vt_mod_cas(l)= vt_prof_cas(nlev_cas)                          !jyg
-         dth_mod_cas(l)= dth_prof_cas(nlev_cas) 
-         hth_mod_cas(l)= hth_prof_cas(nlev_cas)                        !jyg
-         vth_mod_cas(l)= vth_prof_cas(nlev_cas)                        !jyg
-         dq_mod_cas(l)= dq_prof_cas(nlev_cas)*fact 
-         hq_mod_cas(l)= hq_prof_cas(nlev_cas)*fact                     !jyg
-         vq_mod_cas(l)= vq_prof_cas(nlev_cas)*fact                     !jyg
-         dtrad_mod_cas(l)= dtrad_prof_cas(nlev_cas)*fact               !jyg
- 
-        endif ! play
- 
-       enddo ! l
-
-! for variables defined at layer interfaces (EV):
-
-
-       do l = 1, llm+1
-
-        if (plev(l).ge.plev_prof_cas(nlev_cas)) then
-
-         mxcalc=l
-         k1=0
-         k2=0
-
-         if (plev(l).le.plev_prof_cas(1)) then
-
-         do k = 1, nlev_cas-1
-          if (plev(l).le.plev_prof_cas(k).and. plev(l).gt.plev_prof_cas(k+1)) then
-            k1=k
-            k2=k+1
-          endif
-         enddo
-
-         if (k1.eq.0 .or. k2.eq.0) then
-          write(*,*) 'PB! k1, k2 = ',k1,k2
-          write(*,*) 'l,plev(l) = ',l,plev(l)/100
-         do k = 1, nlev_cas-1
-          write(*,*) 'k,plev_prof_cas(k) = ',k,plev_prof_cas(k)/100
-         enddo
-         endif
-
-         frac = (plev_prof_cas(k2)-plev(l))/(plev_prof_cas(k2)-plev_prof_cas(k1))
-         tke_mod_cas(l)= tke_prof_cas(k2) - frac*(tke_prof_cas(k2)-tke_prof_cas(k1))
-         else !play>plev_prof_cas(1)
-         k1=1
-         k2=2
-         tke_mod_cas(l)= frac1*tke_prof_cas(k1) - frac2*tke_prof_cas(k2)
-
-         endif ! plev.le.plev_prof_cas(1)
-
-        else ! above max altitude of forcing file
-
-         tke_mod_cas(l)=0.0
-
-        endif ! plev
-
-       enddo ! l
-
-
-
-          return
-          end SUBROUTINE interp2_case_vertical_std
-!***************************************************************************** 
+    !-------------------------------------------------------------------------
+    ! Vertical interpolation of generic case forcing data onto mod_casel levels
+    !-------------------------------------------------------------------------
+
+    integer nlevmax
+    parameter (nlevmax=41)
+    integer nlev_cas,mxcalc
+    !       real play(llm), plev_prof(nlevmax) 
+    !       real t_prof(nlevmax),q_prof(nlevmax)
+    !       real u_prof(nlevmax),v_prof(nlevmax), w_prof(nlevmax)
+    !       real ht_prof(nlevmax),vt_prof(nlevmax)
+    !       real hq_prof(nlevmax),vq_prof(nlevmax)
+
+    real play(llm), plev(llm+1), plev_prof_cas(nlev_cas) 
+    real t_prof_cas(nlev_cas),th_prof_cas(nlev_cas),thv_prof_cas(nlev_cas),thl_prof_cas(nlev_cas)
+    real qv_prof_cas(nlev_cas),ql_prof_cas(nlev_cas),qi_prof_cas(nlev_cas)
+    real u_prof_cas(nlev_cas),v_prof_cas(nlev_cas)
+    real ug_prof_cas(nlev_cas),vg_prof_cas(nlev_cas), vitw_prof_cas(nlev_cas),omega_prof_cas(nlev_cas),tke_prof_cas(nlev_cas)
+    real temp_nudg_prof_cas(nlev_cas),qv_nudg_prof_cas(nlev_cas)
+    real u_nudg_prof_cas(nlev_cas),v_nudg_prof_cas(nlev_cas)
+    real invtau_temp_nudg_prof_cas(nlev_cas),invtau_qv_nudg_prof_cas(nlev_cas)
+    real invtau_u_nudg_prof_cas(nlev_cas),invtau_v_nudg_prof_cas(nlev_cas)
+
+    real du_prof_cas(nlev_cas),hu_prof_cas(nlev_cas),vu_prof_cas(nlev_cas)
+    real dv_prof_cas(nlev_cas),hv_prof_cas(nlev_cas),vv_prof_cas(nlev_cas)
+    real dt_prof_cas(nlev_cas),ht_prof_cas(nlev_cas),vt_prof_cas(nlev_cas),dtrad_prof_cas(nlev_cas)
+    real dth_prof_cas(nlev_cas),hth_prof_cas(nlev_cas),vth_prof_cas(nlev_cas)
+    real dq_prof_cas(nlev_cas),hq_prof_cas(nlev_cas),vq_prof_cas(nlev_cas)
+
+    real t_mod_cas(llm),theta_mod_cas(llm),thv_mod_cas(llm),thl_mod_cas(llm)
+    real qv_mod_cas(llm),ql_mod_cas(llm),qi_mod_cas(llm)
+    real u_mod_cas(llm),v_mod_cas(llm)
+    real ug_mod_cas(llm),vg_mod_cas(llm), w_mod_cas(llm),omega_mod_cas(llm),tke_mod_cas(llm+1)
+    real temp_nudg_mod_cas(llm),qv_nudg_mod_cas(llm)
+    real u_nudg_mod_cas(llm),v_nudg_mod_cas(llm)
+    real invtau_temp_nudg_mod_cas(llm),invtau_qv_nudg_mod_cas(llm)
+    real invtau_u_nudg_mod_cas(llm),invtau_v_nudg_mod_cas(llm)
+    real du_mod_cas(llm),hu_mod_cas(llm),vu_mod_cas(llm)
+    real dv_mod_cas(llm),hv_mod_cas(llm),vv_mod_cas(llm)
+    real dt_mod_cas(llm),ht_mod_cas(llm),vt_mod_cas(llm),dtrad_mod_cas(llm)
+    real dth_mod_cas(llm),hth_mod_cas(llm),vth_mod_cas(llm)
+    real dq_mod_cas(llm),hq_mod_cas(llm),vq_mod_cas(llm)
+
+    integer l,k,k1,k2
+    real frac,frac1,frac2,fact
+
+
+
+    ! for variables defined at the middle of layers
+
+    do l = 1, llm
+
+       if (play(l).ge.plev_prof_cas(nlev_cas)) then
+
+          mxcalc=l
+          !        print *,'debut interp2, mxcalc=',mxcalc
+          k1=0
+          k2=0
+
+          if (play(l).le.plev_prof_cas(1)) then
+
+             do k = 1, nlev_cas-1
+                if (play(l).le.plev_prof_cas(k).and. play(l).gt.plev_prof_cas(k+1)) then
+                   k1=k
+                   k2=k+1
+                endif
+             enddo
+
+             if (k1.eq.0 .or. k2.eq.0) then
+                write(*,*) 'PB! k1, k2 = ',k1,k2
+                write(*,*) 'l,play(l) = ',l,play(l)/100
+                do k = 1, nlev_cas-1
+                   write(*,*) 'k,plev_prof_cas(k) = ',k,plev_prof_cas(k)/100
+                enddo
+             endif
+
+
+
+             frac = (plev_prof_cas(k2)-play(l))/(plev_prof_cas(k2)-plev_prof_cas(k1))
+
+             t_mod_cas(l)= t_prof_cas(k2) - frac*(t_prof_cas(k2)-t_prof_cas(k1))
+             theta_mod_cas(l)= th_prof_cas(k2) - frac*(th_prof_cas(k2)-th_prof_cas(k1))
+             if(theta_mod_cas(l).NE.0) t_mod_cas(l)= theta_mod_cas(l)*(play(l)/100000.)**(RD/RCPD)
+             thv_mod_cas(l)= thv_prof_cas(k2) - frac*(thv_prof_cas(k2)-thv_prof_cas(k1))
+             thl_mod_cas(l)= thl_prof_cas(k2) - frac*(thl_prof_cas(k2)-thl_prof_cas(k1))
+             qv_mod_cas(l)= qv_prof_cas(k2) - frac*(qv_prof_cas(k2)-qv_prof_cas(k1))
+             ql_mod_cas(l)= ql_prof_cas(k2) - frac*(ql_prof_cas(k2)-ql_prof_cas(k1))
+             qi_mod_cas(l)= qi_prof_cas(k2) - frac*(qi_prof_cas(k2)-qi_prof_cas(k1))
+             u_mod_cas(l)= u_prof_cas(k2) - frac*(u_prof_cas(k2)-u_prof_cas(k1))
+             v_mod_cas(l)= v_prof_cas(k2) - frac*(v_prof_cas(k2)-v_prof_cas(k1))
+             ug_mod_cas(l)= ug_prof_cas(k2) - frac*(ug_prof_cas(k2)-ug_prof_cas(k1))
+             vg_mod_cas(l)= vg_prof_cas(k2) - frac*(vg_prof_cas(k2)-vg_prof_cas(k1))
+             temp_nudg_mod_cas(l)= temp_nudg_prof_cas(k2) - frac*(temp_nudg_prof_cas(k2)-temp_nudg_prof_cas(k1))
+             qv_nudg_mod_cas(l)= qv_nudg_prof_cas(k2) - frac*(qv_nudg_prof_cas(k2)-qv_nudg_prof_cas(k1))
+             u_nudg_mod_cas(l)= u_nudg_prof_cas(k2) - frac*(u_nudg_prof_cas(k2)-u_nudg_prof_cas(k1))
+             v_nudg_mod_cas(l)= v_nudg_prof_cas(k2) - frac*(v_nudg_prof_cas(k2)-v_nudg_prof_cas(k1))
+
+             invtau_temp_nudg_mod_cas(l)= invtau_temp_nudg_prof_cas(k2) &
+                  - frac*(invtau_temp_nudg_prof_cas(k2)-invtau_temp_nudg_prof_cas(k1))
+             invtau_qv_nudg_mod_cas(l)= invtau_qv_nudg_prof_cas(k2) - frac*(invtau_qv_nudg_prof_cas(k2)-invtau_qv_nudg_prof_cas(k1))
+             invtau_u_nudg_mod_cas(l)= invtau_u_nudg_prof_cas(k2) - frac*(invtau_u_nudg_prof_cas(k2)-invtau_u_nudg_prof_cas(k1))
+             invtau_v_nudg_mod_cas(l)= invtau_v_nudg_prof_cas(k2) - frac*(invtau_v_nudg_prof_cas(k2)-invtau_v_nudg_prof_cas(k1))
+
+             w_mod_cas(l)= vitw_prof_cas(k2) - frac*(vitw_prof_cas(k2)-vitw_prof_cas(k1))
+             omega_mod_cas(l)= omega_prof_cas(k2) - frac*(omega_prof_cas(k2)-omega_prof_cas(k1))
+             du_mod_cas(l)= du_prof_cas(k2) - frac*(du_prof_cas(k2)-du_prof_cas(k1))
+             hu_mod_cas(l)= hu_prof_cas(k2) - frac*(hu_prof_cas(k2)-hu_prof_cas(k1))
+             vu_mod_cas(l)= vu_prof_cas(k2) - frac*(vu_prof_cas(k2)-vu_prof_cas(k1))
+             dv_mod_cas(l)= dv_prof_cas(k2) - frac*(dv_prof_cas(k2)-dv_prof_cas(k1))
+             hv_mod_cas(l)= hv_prof_cas(k2) - frac*(hv_prof_cas(k2)-hv_prof_cas(k1))
+             vv_mod_cas(l)= vv_prof_cas(k2) - frac*(vv_prof_cas(k2)-vv_prof_cas(k1))
+             dt_mod_cas(l)= dt_prof_cas(k2) - frac*(dt_prof_cas(k2)-dt_prof_cas(k1))
+             ht_mod_cas(l)= ht_prof_cas(k2) - frac*(ht_prof_cas(k2)-ht_prof_cas(k1))
+             vt_mod_cas(l)= vt_prof_cas(k2) - frac*(vt_prof_cas(k2)-vt_prof_cas(k1))
+             dth_mod_cas(l)= dth_prof_cas(k2) - frac*(dth_prof_cas(k2)-dth_prof_cas(k1))
+             hth_mod_cas(l)= hth_prof_cas(k2) - frac*(hth_prof_cas(k2)-hth_prof_cas(k1))
+             vth_mod_cas(l)= vth_prof_cas(k2) - frac*(vth_prof_cas(k2)-vth_prof_cas(k1))
+             dq_mod_cas(l)= dq_prof_cas(k2) - frac*(dq_prof_cas(k2)-dq_prof_cas(k1))
+             hq_mod_cas(l)= hq_prof_cas(k2) - frac*(hq_prof_cas(k2)-hq_prof_cas(k1))
+             vq_mod_cas(l)= vq_prof_cas(k2) - frac*(vq_prof_cas(k2)-vq_prof_cas(k1))
+             dtrad_mod_cas(l)= dtrad_prof_cas(k2) - frac*(dtrad_prof_cas(k2)-dtrad_prof_cas(k1))
+
+          else !play>plev_prof_cas(1)
+
+             k1=1
+             k2=2
+             print *,'interp2_vert, k1,k2=',plev_prof_cas(k1),plev_prof_cas(k2)
+             frac1 = (play(l)-plev_prof_cas(k2))/(plev_prof_cas(k1)-plev_prof_cas(k2))
+             frac2 = (play(l)-plev_prof_cas(k1))/(plev_prof_cas(k1)-plev_prof_cas(k2))
+             t_mod_cas(l)= frac1*t_prof_cas(k1) - frac2*t_prof_cas(k2)
+             theta_mod_cas(l)= frac1*th_prof_cas(k1) - frac2*th_prof_cas(k2)
+             if(theta_mod_cas(l).NE.0) t_mod_cas(l)= theta_mod_cas(l)*(play(l)/100000.)**(RD/RCPD)
+             thv_mod_cas(l)= frac1*thv_prof_cas(k1) - frac2*thv_prof_cas(k2)
+             thl_mod_cas(l)= frac1*thl_prof_cas(k1) - frac2*thl_prof_cas(k2)
+             qv_mod_cas(l)= frac1*qv_prof_cas(k1) - frac2*qv_prof_cas(k2)
+             ql_mod_cas(l)= frac1*ql_prof_cas(k1) - frac2*ql_prof_cas(k2)
+             qi_mod_cas(l)= frac1*qi_prof_cas(k1) - frac2*qi_prof_cas(k2)
+             u_mod_cas(l)= frac1*u_prof_cas(k1) - frac2*u_prof_cas(k2)
+             v_mod_cas(l)= frac1*v_prof_cas(k1) - frac2*v_prof_cas(k2)
+             ug_mod_cas(l)= frac1*ug_prof_cas(k1) - frac2*ug_prof_cas(k2)
+             vg_mod_cas(l)= frac1*vg_prof_cas(k1) - frac2*vg_prof_cas(k2)
+             temp_nudg_mod_cas(l)= frac1*temp_nudg_prof_cas(k1) - frac2*temp_nudg_prof_cas(k2)
+             qv_nudg_mod_cas(l)= frac1*qv_nudg_prof_cas(k1) - frac2*qv_nudg_prof_cas(k2)
+             u_nudg_mod_cas(l)= frac1*u_nudg_prof_cas(k1) - frac2*u_nudg_prof_cas(k2)
+             v_nudg_mod_cas(l)= frac1*v_nudg_prof_cas(k1) - frac2*v_nudg_prof_cas(k2)
+
+             invtau_temp_nudg_mod_cas(l)= frac1*invtau_temp_nudg_prof_cas(k1) - frac2*invtau_temp_nudg_prof_cas(k2)
+             invtau_qv_nudg_mod_cas(l)= frac1*invtau_qv_nudg_prof_cas(k1) - frac2*invtau_qv_nudg_prof_cas(k2)
+             invtau_u_nudg_mod_cas(l)= frac1*invtau_u_nudg_prof_cas(k1) - frac2*invtau_u_nudg_prof_cas(k2)
+             invtau_v_nudg_mod_cas(l)= frac1*invtau_v_nudg_prof_cas(k1) - frac2*invtau_v_nudg_prof_cas(k2)
+
+             w_mod_cas(l)= frac1*vitw_prof_cas(k1) - frac2*vitw_prof_cas(k2)
+             omega_mod_cas(l)= frac1*omega_prof_cas(k1) - frac2*omega_prof_cas(k2)
+             du_mod_cas(l)= frac1*du_prof_cas(k1) - frac2*du_prof_cas(k2)
+             hu_mod_cas(l)= frac1*hu_prof_cas(k1) - frac2*hu_prof_cas(k2)
+             vu_mod_cas(l)= frac1*vu_prof_cas(k1) - frac2*vu_prof_cas(k2)
+             dv_mod_cas(l)= frac1*dv_prof_cas(k1) - frac2*dv_prof_cas(k2)
+             hv_mod_cas(l)= frac1*hv_prof_cas(k1) - frac2*hv_prof_cas(k2)
+             vv_mod_cas(l)= frac1*vv_prof_cas(k1) - frac2*vv_prof_cas(k2)
+             dt_mod_cas(l)= frac1*dt_prof_cas(k1) - frac2*dt_prof_cas(k2)
+             ht_mod_cas(l)= frac1*ht_prof_cas(k1) - frac2*ht_prof_cas(k2)
+             vt_mod_cas(l)= frac1*vt_prof_cas(k1) - frac2*vt_prof_cas(k2)
+             dth_mod_cas(l)= frac1*dth_prof_cas(k1) - frac2*dth_prof_cas(k2)
+             hth_mod_cas(l)= frac1*hth_prof_cas(k1) - frac2*hth_prof_cas(k2)
+             vth_mod_cas(l)= frac1*vth_prof_cas(k1) - frac2*vth_prof_cas(k2)
+             dq_mod_cas(l)= frac1*dq_prof_cas(k1) - frac2*dq_prof_cas(k2)
+             hq_mod_cas(l)= frac1*hq_prof_cas(k1) - frac2*hq_prof_cas(k2)
+             vq_mod_cas(l)= frac1*vq_prof_cas(k1) - frac2*vq_prof_cas(k2)
+             dtrad_mod_cas(l)= frac1*dtrad_prof_cas(k1) - frac2*dtrad_prof_cas(k2)
+
+          endif ! play.le.plev_prof_cas(1)
+
+       else ! above max altitude of forcing file
+
+          !jyg
+          fact=20.*(plev_prof_cas(nlev_cas)-play(l))/plev_prof_cas(nlev_cas) !jyg
+          fact = max(fact,0.)                                           !jyg
+          fact = exp(-fact)                                             !jyg
+          t_mod_cas(l)= t_prof_cas(nlev_cas)                            !jyg
+          theta_mod_cas(l)= th_prof_cas(nlev_cas)                       !jyg
+          thv_mod_cas(l)= thv_prof_cas(nlev_cas)                        !jyg
+          thl_mod_cas(l)= thl_prof_cas(nlev_cas)                        !jyg
+          qv_mod_cas(l)= qv_prof_cas(nlev_cas)*fact                     !jyg
+          ql_mod_cas(l)= ql_prof_cas(nlev_cas)*fact                     !jyg
+          qi_mod_cas(l)= qi_prof_cas(nlev_cas)*fact                     !jyg
+          u_mod_cas(l)= u_prof_cas(nlev_cas)*fact                       !jyg
+          v_mod_cas(l)= v_prof_cas(nlev_cas)*fact                       !jyg
+          ug_mod_cas(l)= ug_prof_cas(nlev_cas)                          !jyg
+          vg_mod_cas(l)= vg_prof_cas(nlev_cas)                          !jyg
+          temp_nudg_mod_cas(l)= temp_nudg_prof_cas(nlev_cas)            !jyg
+          qv_nudg_mod_cas(l)= qv_nudg_prof_cas(nlev_cas)                !jyg
+          u_nudg_mod_cas(l)= u_nudg_prof_cas(nlev_cas)                  !jyg
+          v_nudg_mod_cas(l)= v_nudg_prof_cas(nlev_cas)                  !jyg
+
+          invtau_temp_nudg_mod_cas(l)= invtau_temp_nudg_prof_cas(nlev_cas)            !jyg
+          invtau_qv_nudg_mod_cas(l)= invtau_qv_nudg_prof_cas(nlev_cas)                !jyg
+          invtau_u_nudg_mod_cas(l)= invtau_u_nudg_prof_cas(nlev_cas)                  !jyg
+          invtau_v_nudg_mod_cas(l)= invtau_v_nudg_prof_cas(nlev_cas)                  !jyg
+
+          thv_mod_cas(l)= thv_prof_cas(nlev_cas)                        !jyg
+          w_mod_cas(l)= 0.0                                             !jyg
+          omega_mod_cas(l)= 0.0                                         !jyg
+          du_mod_cas(l)= du_prof_cas(nlev_cas)*fact 
+          hu_mod_cas(l)= hu_prof_cas(nlev_cas)*fact                     !jyg
+          vu_mod_cas(l)= vu_prof_cas(nlev_cas)*fact                     !jyg
+          dv_mod_cas(l)= dv_prof_cas(nlev_cas)*fact
+          hv_mod_cas(l)= hv_prof_cas(nlev_cas)*fact                     !jyg
+          vv_mod_cas(l)= vv_prof_cas(nlev_cas)*fact                     !jyg
+          dt_mod_cas(l)= dt_prof_cas(nlev_cas) 
+          ht_mod_cas(l)= ht_prof_cas(nlev_cas)                          !jyg
+          vt_mod_cas(l)= vt_prof_cas(nlev_cas)                          !jyg
+          dth_mod_cas(l)= dth_prof_cas(nlev_cas) 
+          hth_mod_cas(l)= hth_prof_cas(nlev_cas)                        !jyg
+          vth_mod_cas(l)= vth_prof_cas(nlev_cas)                        !jyg
+          dq_mod_cas(l)= dq_prof_cas(nlev_cas)*fact 
+          hq_mod_cas(l)= hq_prof_cas(nlev_cas)*fact                     !jyg
+          vq_mod_cas(l)= vq_prof_cas(nlev_cas)*fact                     !jyg
+          dtrad_mod_cas(l)= dtrad_prof_cas(nlev_cas)*fact               !jyg
+
+       endif ! play
+
+    enddo ! l
+
+    ! for variables defined at layer interfaces (EV):
+
+
+    do l = 1, llm+1
+
+       if (plev(l).ge.plev_prof_cas(nlev_cas)) then
+
+          mxcalc=l
+          k1=0
+          k2=0
+
+          if (plev(l).le.plev_prof_cas(1)) then
+
+             do k = 1, nlev_cas-1
+                if (plev(l).le.plev_prof_cas(k).and. plev(l).gt.plev_prof_cas(k+1)) then
+                   k1=k
+                   k2=k+1
+                endif
+             enddo
+
+             if (k1.eq.0 .or. k2.eq.0) then
+                write(*,*) 'PB! k1, k2 = ',k1,k2
+                write(*,*) 'l,plev(l) = ',l,plev(l)/100
+                do k = 1, nlev_cas-1
+                   write(*,*) 'k,plev_prof_cas(k) = ',k,plev_prof_cas(k)/100
+                enddo
+             endif
+
+             frac = (plev_prof_cas(k2)-plev(l))/(plev_prof_cas(k2)-plev_prof_cas(k1))
+             tke_mod_cas(l)= tke_prof_cas(k2) - frac*(tke_prof_cas(k2)-tke_prof_cas(k1))
+          else !play>plev_prof_cas(1)
+             k1=1
+             k2=2
+             frac1 = (play(l)-plev_prof_cas(k2))/(plev_prof_cas(k1)-plev_prof_cas(k2))
+             frac2 = (play(l)-plev_prof_cas(k1))/(plev_prof_cas(k1)-plev_prof_cas(k2))
+             tke_mod_cas(l)= frac1*tke_prof_cas(k1) - frac2*tke_prof_cas(k2)
+
+          endif ! plev.le.plev_prof_cas(1)
+
+       else ! above max altitude of forcing file
+
+          tke_mod_cas(l)=0.0
+
+       endif ! plev
+
+    enddo ! l
+
+
+
+    return
+  end SUBROUTINE interp2_case_vertical_std
+  !***************************************************************************** 
 
 
Index: LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/old_1DUTILS_read_interp.h
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/old_1DUTILS_read_interp.h	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/old_1DUTILS_read_interp.h	(revision 4446)
@@ -146,5 +146,5 @@
 !program reading forcings of the TWP-ICE experiment
 
-!      use netcdf
+        use netcdf, only: nf90_get_var
 
       implicit none
@@ -314,9 +314,5 @@
        enddo
           
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(1),lat)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(1),lat)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(1),lat)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -325,9 +321,5 @@
 !         write(*,*)'lecture lat ok',lat
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(2),lon)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(2),lon)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(2),lon)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -336,9 +328,5 @@
 !         write(*,*)'lecture lon ok',lon
  
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(3),alt)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(3),alt)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(3),alt)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -347,9 +335,5 @@
 !          write(*,*)'lecture alt ok',alt
  
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(4),phis)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(4),phis)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(4),phis)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -358,9 +342,5 @@
 !          write(*,*)'lecture phis ok',phis
           
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(5),T)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(5),T)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(5),T)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -369,9 +349,5 @@
 !         write(*,*)'lecture T ok'
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(6),q)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(6),q)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(6),q)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -385,9 +361,5 @@
        enddo
        enddo
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(7),u)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(7),u)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(7),u)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -396,9 +368,5 @@
 !         write(*,*)'lecture u ok'
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(8),v)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(8),v)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(8),v)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -407,9 +375,5 @@
 !         write(*,*)'lecture v ok'
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(9),omega)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(9),omega)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(9),omega)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -424,9 +388,5 @@
        enddo
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(10),div)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(10),div)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(10),div)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -435,9 +395,5 @@
 !         write(*,*)'lecture div ok'
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(11),T_adv_h)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(11),T_adv_h)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(11),T_adv_h)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -453,9 +409,5 @@
 
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(12),T_adv_v)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(12),T_adv_v)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(12),T_adv_v)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -470,9 +422,5 @@
        enddo
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(13),q_adv_h)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(13),q_adv_h)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(13),q_adv_h)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -488,9 +436,5 @@
 
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(14),q_adv_v)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(14),q_adv_v)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(14),q_adv_v)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -506,59 +450,35 @@
 
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(15),s)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(15),s)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
-
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(16),s_adv_h)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(16),s_adv_h)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
-
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(17),s_adv_v)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(17),s_adv_v)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
-
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(18),p_srf_aver)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(18),p_srf_aver)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
-
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(19),p_srf_center)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(19),p_srf_center)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
-
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(20),T_srf)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(20),T_srf)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(15),s)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+         ierr = NF90_GET_VAR(nid,var3didin(16),s_adv_h)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+         ierr = NF90_GET_VAR(nid,var3didin(17),s_adv_v)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+         ierr = NF90_GET_VAR(nid,var3didin(18),p_srf_aver)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+         ierr = NF90_GET_VAR(nid,var3didin(19),p_srf_center)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+         ierr = NF90_GET_VAR(nid,var3didin(20),T_srf)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -572,5 +492,5 @@
          subroutine catchaxis(nid,ttm,llm,time,lev,ierr)
 
-!         use netcdf
+         use netcdf, only: nf90_get_var
 
          implicit none
@@ -610,11 +530,6 @@
          endif
 
-!#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,timevar,time)
-         ierr = NF_GET_VAR_DOUBLE(nid,levvar,lev)
-!#else
-!        ierr = NF_GET_VAR_REAL(nid,timevar,time)
-!        ierr = NF_GET_VAR_REAL(nid,levvar,lev)
-!#endif
+         ierr = NF90_GET_VAR(nid,timevar,time)
+         ierr = NF90_GET_VAR(nid,levvar,lev)
 
        return
@@ -2255,4 +2170,5 @@
 
 
+      use netcdf, only: nf90_get_var
       implicit none
 
@@ -2364,9 +2280,5 @@
 !      call catchaxis(nid,ntime,nlevel,time,z,ierr)
  
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(1),zz)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(1),zz)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(1),zz)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2375,9 +2287,5 @@
 !          write(*,*)'lecture z ok',zz
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(2),thl)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(2),thl)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(2),thl)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2386,9 +2294,5 @@
 !          write(*,*)'lecture thl ok',thl
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(3),qt)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(3),qt)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(3),qt)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2397,9 +2301,5 @@
 !          write(*,*)'lecture qt ok',qt
  
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(4),u)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(4),u)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(4),u)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2408,9 +2308,5 @@
 !          write(*,*)'lecture u ok',u
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(5),v)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(5),v)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(5),v)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2419,9 +2315,5 @@
 !          write(*,*)'lecture v ok',v
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(6),tke)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(6),tke)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(6),tke)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2430,9 +2322,5 @@
 !          write(*,*)'lecture tke ok',tke
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(7),ug)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(7),ug)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(7),ug)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2441,9 +2329,5 @@
 !          write(*,*)'lecture ug ok',ug
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(8),vg)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(8),vg)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(8),vg)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2452,9 +2336,5 @@
 !          write(*,*)'lecture vg ok',vg
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(9),wls)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(9),wls)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(9),wls)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2463,9 +2343,5 @@
 !          write(*,*)'lecture wls ok',wls
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(10),dqtdx)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(10),dqtdx)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(10),dqtdx)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2474,9 +2350,5 @@
 !          write(*,*)'lecture dqtdx ok',dqtdx
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(11),dqtdy)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(11),dqtdy)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(11),dqtdy)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2485,9 +2357,5 @@
 !          write(*,*)'lecture dqtdy ok',dqtdy
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(12),dqtdt)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(12),dqtdt)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(12),dqtdt)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2496,9 +2364,5 @@
 !          write(*,*)'lecture dqtdt ok',dqtdt
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(13),thl_rad)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(13),thl_rad)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(13),thl_rad)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2517,4 +2381,5 @@
 !program reading initial profils and forcings of the Dice case study
 
+      use netcdf, only: nf90_get_var
 
       implicit none
@@ -2685,9 +2550,5 @@
 !      call catchaxis(nid,ntime,nlevel,time,z,ierr)
  
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(1),zz)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(1),zz)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(1),zz)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2696,9 +2557,5 @@
 !          write(*,*)'lecture zz ok',zz
  
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(11),pres)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(11),pres)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(11),pres)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2707,9 +2564,5 @@
 !          write(*,*)'lecture pres ok',pres
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(12),th)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(12),th)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(12),th)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2721,9 +2574,5 @@
            enddo
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(13),qv)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(13),qv)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(13),qv)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2732,9 +2581,5 @@
 !          write(*,*)'lecture qv ok',qv
  
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(14),u)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(14),u)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(14),u)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2743,9 +2588,5 @@
 !          write(*,*)'lecture u ok',u
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(15),v)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(15),v)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(15),v)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2754,9 +2595,5 @@
 !          write(*,*)'lecture v ok',v
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(16),o3)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(16),o3)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(16),o3)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2765,9 +2602,5 @@
 !          write(*,*)'lecture o3 ok',o3
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(2),shf)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(2),shf)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(2),shf)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2776,9 +2609,5 @@
 !          write(*,*)'lecture shf ok',shf
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(3),lhf)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(3),lhf)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(3),lhf)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2787,9 +2616,5 @@
 !          write(*,*)'lecture lhf ok',lhf
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(4),lwup)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(4),lwup)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(4),lwup)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2798,9 +2623,5 @@
 !          write(*,*)'lecture lwup ok',lwup
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(5),swup)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(5),swup)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(5),swup)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2809,9 +2630,5 @@
 !          write(*,*)'lecture swup ok',swup
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(6),tg)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(6),tg)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(6),tg)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2820,9 +2637,5 @@
 !          write(*,*)'lecture tg ok',tg
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(7),ustar)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(7),ustar)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(7),ustar)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2831,9 +2644,5 @@
 !          write(*,*)'lecture ustar ok',ustar
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(8),psurf)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(8),psurf)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(8),psurf)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2842,9 +2651,5 @@
 !          write(*,*)'lecture psurf ok',psurf
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(9),ug)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(9),ug)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(9),ug)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2853,9 +2658,5 @@
 !          write(*,*)'lecture ug ok',ug
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(10),vg)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(10),vg)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(10),vg)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2864,9 +2665,5 @@
 !          write(*,*)'lecture vg ok',vg
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(17),hadvt)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(17),hadvt)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(17),hadvt)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2875,9 +2672,5 @@
 !          write(*,*)'lecture hadvt ok',hadvt
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(18),hadvq)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(18),hadvq)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(18),hadvq)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2886,9 +2679,5 @@
 !          write(*,*)'lecture hadvq ok',hadvq
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(19),hadvu)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(19),hadvu)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(19),hadvu)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2897,9 +2686,5 @@
 !          write(*,*)'lecture hadvu ok',hadvu
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(20),hadvv)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(20),hadvv)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(20),hadvv)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2908,9 +2693,5 @@
 !          write(*,*)'lecture hadvv ok',hadvv
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(21),w)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(21),w)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(21),w)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2919,9 +2700,5 @@
 !          write(*,*)'lecture w ok',w
 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(22),omega)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(22),omega)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(22),omega)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
@@ -2938,4 +2715,5 @@
 !program reading initial profils and forcings of the Gabls4 case study
 
+      use netcdf, only: nf90_get_var
 
       implicit none
@@ -3068,149 +2846,89 @@
 !      call catchaxis(nid,ntime,nlevel,time,z,ierr)
  
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(1),zz_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(1),zz_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(2),depth_sn)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(2),depth_sn)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(3),ug_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(3),ug_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(4),vg_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(4),vg_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(5),pf_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(5),pf_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
-
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(6),th_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(6),th_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
-
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(7),t_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(7),t_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
-
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(8),qv_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(8),qv_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(9),u_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(9),u_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(10),v_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(10),v_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(11),hadvt_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(11),hadvt_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(12),hadvq_i)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(12),hadvq_i)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(14),tsnow)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(14),tsnow)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
- 
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(15),snow_dens)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(15),snow_dens)
-#endif
-         if(ierr/=NF_NOERR) then
-            write(*,*) NF_STRERROR(ierr)
-            stop "getvarup"
-         endif
-
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid,var3didin(16),tg)
-#else
-         ierr = NF_GET_VAR_REAL(nid,var3didin(16),tg)
-#endif
+         ierr = NF90_GET_VAR(nid,var3didin(1),zz_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(2),depth_sn)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(3),ug_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(4),vg_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(5),pf_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+         ierr = NF90_GET_VAR(nid,var3didin(6),th_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+         ierr = NF90_GET_VAR(nid,var3didin(7),t_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+         ierr = NF90_GET_VAR(nid,var3didin(8),qv_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(9),u_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(10),v_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(11),hadvt_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(12),hadvq_i)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(14),tsnow)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+ 
+         ierr = NF90_GET_VAR(nid,var3didin(15),snow_dens)
+         if(ierr/=NF_NOERR) then
+            write(*,*) NF_STRERROR(ierr)
+            stop "getvarup"
+         endif
+
+         ierr = NF90_GET_VAR(nid,var3didin(16),tg)
          if(ierr/=NF_NOERR) then
             write(*,*) NF_STRERROR(ierr)
Index: LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/old_1D_read_forc_cases.h
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/old_1D_read_forc_cases.h	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/old_1D_read_forc_cases.h	(revision 4446)
@@ -843,5 +843,5 @@
       if (forcing_case) then
 
-         write(*,*),'avant call read_1D_cas'
+         write(*,*) 'avant call read_1D_cas'
          call read_1D_cas
          write(*,*) 'Forcing read'
@@ -918,5 +918,5 @@
       if (forcing_case2) then
 
-         write(*,*),'avant call read2_1D_cas'
+         write(*,*) 'avant call read2_1D_cas'
          call read2_1D_cas
          write(*,*) 'Forcing read'
@@ -1017,5 +1017,5 @@
       if (forcing_SCM) then
 
-         write(*,*),'avant call old_read_SCM_cas'
+         write(*,*) 'avant call old_read_SCM_cas'
          call old_read_SCM_cas
          write(*,*) 'Forcing read' 
Index: LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/old_lmdz1d.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/old_lmdz1d.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/old_lmdz1d.F90	(revision 4446)
@@ -494,5 +494,5 @@
 !      calend = 'earth_365d'
       if (calend == 'earth_360d') then
-        call ioconf_calendar('360d')
+        call ioconf_calendar('360_day')
         write(*,*)'CALENDRIER CHOISI: Terrestre a 360 jours/an'
       else if (calend == 'earth_365d') then
@@ -613,5 +613,5 @@
       call init_dimphy1D(1,llm)
       call suphel
-      call infotrac_init 
+      call init_infotrac
 
       if (nqtot>nqmx) STOP 'Augmenter nqmx dans lmdz1d.F'
Index: LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/replay1d.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/replay1d.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/replay1d.F90	(revision 4446)
@@ -1,8 +1,10 @@
 PROGRAM rejouer
 
-  USE mod_const_mpi, ONLY: comm_lmdz
-  USE inigeomphy_mod, ONLY: inigeomphy
- USE comvert_mod, ONLY: presnivs
+USE mod_const_mpi, ONLY: comm_lmdz
+USE inigeomphy_mod, ONLY: inigeomphy
+USE comvert_mod, ONLY: presnivs
 USE comvert_mod, only :  preff, pa
+USE ioipsl, only: getin
+
 
 
@@ -17,7 +19,9 @@
 
 integer ntime
-integer jour0,mois0,an0
-integer it
+integer jour0,mois0,an0,day_step,anneeref,dayref
 integer klev,klon
+CHARACTER (len=10) :: calend
+CHARACTER(len=20) :: calendrier
+
 
 !---------------------------------------------------------------------
@@ -31,6 +35,6 @@
 
 preff=101325.
+!preff=100000.
 pa=50000.
-open(82,file='dump_param.bin',form='unformatted',status='old')
   CALL disvert()
   CALL inigeomphy(1,1,llm, &
@@ -43,26 +47,40 @@
 
 CALL suphel
-ntime=100
-jour0=1
-mois0=1
-an0=2000
+!ntime=4320
+ntime=10000000
+dayref=1
+anneeref=2000
+call getin('dayref',dayref)
+call getin('anneeref',anneeref)
+call getin('calend',calend)
+call getin('day_step',day_step)
+calendrier=calend
+if ( calendrier == "earth_360d" ) calendrier="360_day"
+
+
+jour0=dayref
+mois0=(jour0-1)/30+1
+jour0=jour0-30*((jour0-1)/30)
+an0=anneeref
+
+!print*,"REPLAY1D jour0,mois0,an0",jour0,mois0,an0
+
+
 klon=1
 klev=llm
-call iotd_ini('phys.nc',1,1,klev,0.,0.,presnivs,jour0,mois0,an0,0.,900.,'360d')
+call iotd_ini('phys.nc',1,1,klev,0.,0.,presnivs,jour0,mois0,an0,0.,86400./day_step,calendrier)
+! Consistent with ... CALL iophys_ini(600.)
 
 !---------------------------------------------------------------------
 ! Initialisation de la parametrisation
 !---------------------------------------------------------------------
-      call get_ini_module
+call get_ini_module
 
 !---------------------------------------------------------------------
 ! Boucle en temps sur l'appel à la parametrisation
 !---------------------------------------------------------------------
-      DO it=1,ntime
-         print*,'Pas de temps ',it,klon,klev
-         call call_param_replay(klon,klev)
-      ENDDO
-      END
+call call_param_replay(klon,klev)
 
+end
 
 !---------------------------------------------------------------------
Index: LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/scm.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/scm.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/dyn1d/scm.F90	(revision 4446)
@@ -327,5 +327,5 @@
 !      calend = 'earth_365d'
       if (calend == 'earth_360d') then
-        call ioconf_calendar('360d')
+        call ioconf_calendar('360_day')
         write(*,*)'CALENDRIER CHOISI: Terrestre a 360 jours/an'
       else if (calend == 'earth_365d') then
@@ -393,5 +393,5 @@
       call init_dimphy1D(1,llm)
       call suphel
-      call infotrac_init 
+      call init_infotrac
 
       if (nqtot>nqmx) STOP 'Augmenter nqmx dans lmdz1d.F'
@@ -496,11 +496,4 @@
         stop 'in initialization'
       endif ! forcing_GCM2SCM
-
-      print*,'mxcalc=',mxcalc
-!     print*,'zlay=',zlay(mxcalc)
-!      print*,'play=',play(mxcalc)
-
-!! When surface temperature is forced
-      tg= tsurf ! surface T used in read_tsurf1d
 
 
Index: LMDZ6/branches/Portage_acc/libf/phylmd/ecrad/random_numbers_mix.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/ecrad/random_numbers_mix.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/ecrad/random_numbers_mix.F90	(revision 4446)
@@ -239,8 +239,9 @@
   ! Generate uniformly distributed random numbers in the range 0.0<= px < 1.0
   !--------------------------------------------------------------------------------
-  INTEGER(KIND=JPIM), PARAMETER :: IVAR=Z"3FFFFFFF"
+!  INTEGER(KIND=JPIM), PARAMETER :: IVAR=Z"3FFFFFFF"
+  INTEGER(KIND=JPIM) :: IVAR
+  DATA IVAR /Z"3FFFFFFF"/
   TYPE(RANDOMNUMBERSTREAM), INTENT(INOUT) :: YD_STREAM
   REAL(KIND=JPRB), DIMENSION(:),     INTENT(  OUT) :: PX
-
   INTEGER(KIND=JPIM)                :: JJ, JK, IN, IFILLED
   
Index: LMDZ6/branches/Portage_acc/libf/phylmd/ecrad/srtm_taumol22.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/ecrad/srtm_taumol22.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/ecrad/srtm_taumol22.F90	(revision 4446)
@@ -84,7 +84,9 @@
 I_LAYSOLFR(KIDIA:KFDIA) = K_LAYTROP(KIDIA:KFDIA)
 
-DO I_LAY = 1, I_NLAYERS
+!AI inversion des boucles pb avec option de compil O3
+DO IPLON = KIDIA, KFDIA
+  DO I_LAY = 1, I_NLAYERS
   I_LAY_NEXT = MIN(I_NLAYERS, I_LAY+1)
-  DO IPLON = KIDIA, KFDIA
+!  DO IPLON = KIDIA, KFDIA
     IF (PRMU0(IPLON) > 0.0_JPRB) THEN
       IF (I_LAY <= K_LAYTROP(IPLON)) THEN
Index: LMDZ6/branches/Portage_acc/libf/phylmd/ener_conserv.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/ener_conserv.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/ener_conserv.F90	(revision 4446)
@@ -1,4 +1,4 @@
 subroutine ener_conserv(klon,klev,pdtphys, &
- &                      puo,pvo,pto,pqo,pql0,pqs0, &
+ &                      puo,pvo,pto,qx,ivap,iliq,isol, &
  &                      pun,pvn,ptn,pqn,pqln,pqsn,dtke,masse,exner,d_t_ec)
 
@@ -28,4 +28,5 @@
 USE phys_output_var_mod, ONLY : bils_ec,bils_ech,bils_tke,bils_kinetic,bils_enthalp,bils_latent,bils_diss
 USE add_phys_tend_mod, ONLY : fl_cor_ebil 
+USE infotrac_phy, ONLY: nqtot
 
 
@@ -39,5 +40,7 @@
 INTEGER, INTENT(IN) :: klon,klev
 REAL, INTENT(IN) :: pdtphys
-REAL, DIMENSION(klon,klev), INTENT(IN)      :: puo,pvo,pto,pqo,pql0,pqs0
+REAL, DIMENSION(klon,klev), INTENT(IN)      :: puo,pvo,pto
+REAL, DIMENSION(klon,klev,nqtot), INTENT(IN):: qx
+INTEGER, INTENT(IN)                         :: ivap, iliq, isol
 REAL, DIMENSION(klon,klev), INTENT(IN)      :: pun,pvn,ptn,pqn,pqln,pqsn
 REAL, DIMENSION(klon,klev), INTENT(IN)      :: masse,exner
@@ -50,5 +53,5 @@
 REAL, DIMENSION(klon,klev+1) :: fluxu,fluxv,fluxt
 REAL, DIMENSION(klon,klev+1) :: dddu,dddv,dddt
-REAL, DIMENSION(klon,klev) :: d_u,d_v,d_t,zv,zu,d_t_ech
+REAL, DIMENSION(klon,klev) :: d_u,d_v,d_t,zv,zu,d_t_ech, pqo, pql0, pqs0
 REAL ZRCPD
 
@@ -59,4 +62,10 @@
 modname='ener_conser'
 d_t_ec(:,:)=0.
+
+IF(ivap == 0) CALL abort_physic (modname,'can''t run without water vapour',1)
+IF(iliq == 0) CALL abort_physic (modname,'can''t run without liquid water',1)
+pqo  = qx(:,:,ivap)
+pql0 = qx(:,:,iliq)
+IF(isol /= 0) pqs0 = qx(:,:,isol)
 
 IF (iflag_ener_conserv==-1) THEN
Index: LMDZ6/branches/Portage_acc/libf/phylmd/fisrtilp.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/fisrtilp.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/fisrtilp.F90	(revision 4446)
@@ -89,7 +89,7 @@
   ! Coeffients de fraction lessivee : pour OFF-LINE
   !
-  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: pfrac_nucl
-  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: pfrac_1nucl
-  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: pfrac_impa
+  REAL, DIMENSION(klon,klev),      INTENT(INOUT)  :: pfrac_nucl
+  REAL, DIMENSION(klon,klev),      INTENT(INOUT)  :: pfrac_1nucl
+  REAL, DIMENSION(klon,klev),      INTENT(INOUT)  :: pfrac_impa
   !
   ! Fraction d'aerosols lessivee par impaction et par nucleation
@@ -1565,5 +1565,7 @@
         DO i=1, klon
             IF (zrflclr(i) + ziflclr(i) .GT. 0 ) THEN
-                znebprecipclr(i) = min(znebprecipclr(i), max(zrflclr(i)/(znebprecipclr(i)*rain_int_min), ziflclr(i)/(znebprecipclr(i)*rain_int_min)))
+               znebprecipclr(i) = min(znebprecipclr(i), max(zrflclr(i) &
+                    /(znebprecipclr(i)*rain_int_min), &
+                    ziflclr(i)/(znebprecipclr(i)*rain_int_min)))
             ELSE
                 znebprecipclr(i)=0.
@@ -1571,5 +1573,7 @@
 
             IF (zrflcld(i) + ziflcld(i) .GT. 0 ) THEN
-                znebprecipcld(i) = min(znebprecipcld(i), max(zrflcld(i)/(znebprecipcld(i)*rain_int_min), ziflcld(i)/(znebprecipcld(i)*rain_int_min)))
+               znebprecipcld(i) = min(znebprecipcld(i), &
+                    max(zrflcld(i)/(znebprecipcld(i)*rain_int_min), &
+                    ziflcld(i)/(znebprecipcld(i)*rain_int_min)))
             ELSE
                 znebprecipcld(i)=0.
Index: LMDZ6/branches/Portage_acc/libf/phylmd/ice_sursat_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/ice_sursat_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/ice_sursat_mod.F90	(revision 4446)
@@ -3,19 +3,12 @@
 IMPLICIT NONE
 
+!--flight inventories
+!
 REAL, SAVE, ALLOCATABLE :: flight_m(:,:)    !--flown distance m s-1 per cell
 !$OMP THREADPRIVATE(flight_m)
 REAL, SAVE, ALLOCATABLE :: flight_h2o(:,:)  !--emitted kg H2O s-1 per cell
 !$OMP THREADPRIVATE(flight_h2o)
-
-!--parameters for gamma function
-!--Karcher and Lohmann (2002)
-!--gamma = 2.583 - t / 207.83
-! REAL, SAVE, PARAMETER :: gamma0=2.583, Tgamma=207.83
-!--Ren and MacKenzie (2005) reused by Kärcher
-!--gamma = 2.349 - t / 259.0
-REAL, PARAMETER :: gamma0=2.349, Tgamma=259.0
-!
-!--number of clouds in cell (needs to be parametrized at some point)
-REAL, PARAMETER :: N_cld = 100.
+!
+!--Fixed Parameters
 !
 !--safety parameters for ERF function
@@ -43,11 +36,19 @@
 !  alpha_cld ). Dans le rapport il est appelé beta. Il varie entre 0 et 5
 !  (tun_ratqs = 0 => pas de modification de ratqs).
-
+!
+!--gamma0 and Tgamma: define RHcrit limit above which heterogeneous freezing occurs as a function of T
+!--Karcher and Lohmann (2002)
+!--gamma = 2.583 - t / 207.83
+!--Ren and MacKenzie (2005) reused by Kärcher
+!--gamma = 2.349 - t / 259.0
+!
+!--N_cld: number of clouds in cell (needs to be parametrized at some point)
+!
+!--contrail cross section: typical value found in Freudenthaler et al, GRL, 22, 3501-3504, 1995
+!--in m2, 1000x200 = 200 000 m2 after 15 min
+!
 REAL, SAVE :: chi=1.1, l_turb=50.0, tun_N=1.3, tun_ratqs=3.0
-!$OMP THREADPRIVATE(chi,l_turb,tun_N,tun_ratqs)
-!
-!--contrail cross section, typical value found in Freudenthaler et al, GRL, 22, 3501-3504, 1995
-!--in m2, 1000x200 = 200 000 m2 after 15 min
-REAL, PARAMETER :: contrail_cross_section=200000.0  
+REAL, SAVE :: gamma0=2.349, Tgamma=259.0, N_cld=100, contrail_cross_section=200000.0
+!$OMP THREADPRIVATE(chi,l_turb,tun_N,tun_ratqs,gamma0,Tgamma,N_cld,contrail_cross_section)
 
 CONTAINS
@@ -66,9 +67,18 @@
   CALL getin_p('flag_tun_N',tun_N)
   CALL getin_p('flag_tun_ratqs',tun_ratqs)
-
+  CALL getin_p('gamma0',gamma0)
+  CALL getin_p('Tgamma',Tgamma)
+  CALL getin_p('N_cld',N_cld)
+  CALL getin_p('contrail_cross_section',contrail_cross_section)
+
+  WRITE(lunout,*) 'Parameters for ice_sursat param'
   WRITE(lunout,*) 'flag_chi = ', chi
   WRITE(lunout,*) 'flag_l_turb = ', l_turb
   WRITE(lunout,*) 'flag_tun_N = ', tun_N
   WRITE(lunout,*) 'flag_tun_ratqs = ', tun_ratqs
+  WRITE(lunout,*) 'gamma0 = ', gamma0
+  WRITE(lunout,*) 'Tgamma = ', Tgamma
+  WRITE(lunout,*) 'N_cld = ', N_cld
+  WRITE(lunout,*) 'contrail_cross_section = ', contrail_cross_section
 
 END SUBROUTINE ice_sursat_init
@@ -384,7 +394,7 @@
      !
      !--Estimating gamma 
-     gamma_ss = gamma0 - t_actuel/Tgamma
-     !gamma_prec = gamma0 - t_ancien(i,k)/Tgamma      !--formulation initiale d Audran
-     gamma_prec = gamma0 - t/Tgamma                   !--autre formulation possible basée sur le T du pas de temps
+     gamma_ss = MAX(1.0, gamma0 - t_actuel/Tgamma)
+     !gamma_prec = MAX(1.0, gamma0 - t_ancien(i,k)/Tgamma)      !--formulation initiale d Audran
+     gamma_prec = MAX(1.0, gamma0 - t/Tgamma)                   !--autre formulation possible basée sur le T du pas de temps
      !
      ! Initialisation de qvc : q_sat du pas de temps precedent
@@ -421,5 +431,7 @@
         ! On approxime en serie entiere erf-1(x)
         qvc = 2.*rneb-1.
-        qvc = qvc + PI/12.*qvc**3 + 7.*PI**2/480.*qvc**5 + 127.*PI**3/40320.*qvc**7 + 4369.*PI**4/5806080.*qvc**9 + 34807.*PI**5/182476800.*qvc**11
+        qvc = qvc + PI/12.*qvc**3 + 7.*PI**2/480.*qvc**5 &
+             + 127.*PI**3/40320.*qvc**7 + 4369.*PI**4/5806080.*qvc**9 &
+             + 34807.*PI**5/182476800.*qvc**11
         qvc = sqrt(PI)/2.*qvc
         qvc = (qvc-pdf_b)*pdf_k*sqrt(2.)
Index: LMDZ6/branches/Portage_acc/libf/phylmd/infotrac_phy.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/infotrac_phy.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/infotrac_phy.F90	(revision 4446)
@@ -1,10 +1,10 @@
-
-! $Id: $
-
+!$Id: infotrac.F90 4301 2022-10-20 11:57:21Z dcugnet $
+!
 MODULE infotrac_phy
 
-   USE       strings_mod, ONLY: msg, maxlen, strStack, strHead, strIdx, int2str
-   USE readTracFiles_mod, ONLY: trac_type, isot_type, keys_type, delPhase, getKey, tnom_iso => newH2OIso
-
+   USE       strings_mod, ONLY: msg, fmsg, maxlen, cat, dispTable, int2str, bool2str, strStack, strParse, strIdx
+   USE readTracFiles_mod, ONLY: trac_type, nphas, readTracersFiles, tracers, setGeneration, itZonIso, nbIso, tran0, delPhase, &
+                        getKey, isot_type, nzone, readIsotopesFile, isotope, maxTableWidth, iqIsoPha, ntiso, ixIso, addPhase, &
+                   indexUpdate, isoSelect, niso,  testTracersFiles, isoPhas, isoZone, isoName, isoKeys, iH2O, isoCheck, addKey
    IMPLICIT NONE
 
@@ -16,7 +16,11 @@
    PUBLIC :: nqtot,   nbtr,   nqo,   nqCO2,   nqtottr      !--- Main dimensions
    PUBLIC :: conv_flg, pbl_flg                             !--- Convection & boundary layer activation keys
+#ifdef CPP_StratAer
+   PUBLIC :: nbtr_bin, nbtr_sulgas                         !--- Number of aerosols bins and sulfur gases for StratAer model
+   PUBLIC :: id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat, id_TEST_strat
+#endif
 
    !=== FOR ISOTOPES: General
-   PUBLIC :: isotopes,  nbIso                              !--- Derived type, full isotopes families database + nb of families
+   PUBLIC :: isot_type, 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
@@ -26,14 +30,9 @@
    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 :: iqTraPha                                      !--- idx of tagging tracer in iName = function(isotope idx, phase idx)
+   PUBLIC :: itZonIso                                      !--- idx "it" (in "isoName(1:niso)") = function(tagging idx, isotope idx)
+   PUBLIC :: iqIsoPha                                      !--- idx "iq" (in "qx") = function(isotope idx, phase idx) + aliases
    PUBLIC :: isoCheck                                      !--- Run isotopes checking routines
    !=== FOR BOTH TRACERS AND ISOTOPES
    PUBLIC :: getKey                                        !--- Get a key from "tracers" or "isotope"
-
-   PUBLIC :: ntraciso, ntraceurs_zone, indnum_fn_num, use_iso, index_trac, iqiso
-   PUBLIC :: niso_possibles, ok_iso_verif
-
-   INTERFACE isoSelect; MODULE PROCEDURE isoSelectByIndex, isoSelectByName; END INTERFACE isoSelect
 
 !=== CONVENTIONS FOR TRACERS NUMBERS:
@@ -71,17 +70,15 @@
 !  | 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                |
+!  | nqChildren  | Number of childs            (1st generation only)    | nqfils      | 1:nqtot                |
+!  | keys        | key/val pairs accessible with "getKey" routine       | /           |                        |
 !  | 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       | /           |                        |
 !  +-------------+------------------------------------------------------+-------------+------------------------+
 !
@@ -96,55 +93,21 @@
 !  | zone   | nzone  | Geographic tagging zones   list + number         | / | ntraceurs_zone |                 |
 !  | phase  | nphas  | Phases                     list + number         |                    | [g][l][s], 1:3  |
-!  | iqTraPha        | Index in "qx"           = f(name(1:ntiso)),phas) | iqiso              | 1:nqtot         |
+!  | 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
-!$OMP THREADPRIVATE(nqtot, nbtr, nqo, nbIso, nqtottr, nqCO2, type_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, POINTER :: 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, POINTER ::  niso, nzone, &    !--- NUMBER OF ISOTOPES, TAGGING ZONES AND PHASES
-                                             nphas, ntiso, &    !--- NUMBER OF PHASES AND ISOTOPES + ISOTOPIC TAGGING TRACERS
-                                            itZonIso(:,:), &    !--- INDEX IN "isoTrac" AS f(tagging zone idx,  isotope idx)
-                                            iqTraPha(:,:)       !--- 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,iqTraPha)
-
-   !=== 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)
+   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
+                                  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(s)
+!$OMP THREADPRIVATE(nqtot, nbtr, nqo, nqtottr, nqCO2, type_trac)
+
+   !=== VARIABLES 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)
-
-   !--- Aliases for older names + quantities to be removed             (will be replaced by:)
-   INTEGER, POINTER, SAVE :: ntraciso, ntraceurs_zone           !--- -> ntiso, nzone
-!$OMP THREADPRIVATE         (ntraciso, ntraceurs_zone)   
-   INTEGER, POINTER, SAVE :: index_trac(:,:), iqiso(:,:)        !--- -> itZonIso, iqTraPha
-!$OMP THREADPRIVATE         (index_trac,      iqiso)
-   INTEGER, SAVE :: niso_possibles                              !--- suppressed (use effective niso instead)
-!$OMP THREADPRIVATE(niso_possibles)
-   LOGICAL, SAVE :: ok_iso_verif                                !--- -> isoCheck
-!$OMP THREADPRIVATE(ok_iso_verif)
-   LOGICAL, SAVE, ALLOCATABLE :: use_iso(:)                     !--- suppressed
-!$OMP THREADPRIVATE             (use_iso)
-   INTEGER, SAVE, ALLOCATABLE :: indnum_fn_num(:)
-!$OMP THREADPRIVATE             (indnum_fn_num)
 
 #ifdef CPP_StratAer
@@ -158,48 +121,308 @@
 CONTAINS
 
-SUBROUTINE init_infotrac_phy(type_trac_, tracers_, isotopes_, nqtottr_, nqCO2_, pbl_flg_, conv_flg_)
-
-   USE print_control_mod, ONLY: prt_level, lunout
-
+SUBROUTINE init_infotrac_phy
+   USE ioipsl_getin_p_mod, ONLY: getin_p
+#ifdef REPROBUS
+   USE CHEM_REP, ONLY: Init_chem_rep_trac
+#endif
    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
+!==============================================================================================================================
+!
+!   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
+!   -------
+!
+!   Modifications:
+!   --------------
+!   05/94: F.Forget      Modif special traceur
+!   02/02: M-A Filiberti Lecture de traceur.def
+!   01/22: D. Cugnet     Nouveaux tracer.def et tracer_*.def + encapsulation (types trac_type et isot_type)
+!
+!   Objet:
+!   ------
+!   GCM LMD nouvelle grille
+!
+!==============================================================================================================================
+!   ... modification de l'integration de q ( 26/04/94 ) ....
+!------------------------------------------------------------------------------------------------------------------------------
+! Declarations:
+   INCLUDE "dimensions.h"
+   INCLUDE "iniprint.h"
+
+!------------------------------------------------------------------------------------------------------------------------------
+! Local variables
+   INTEGER, ALLOCATABLE :: hadv(:), vadv(:)                          !--- Horizontal/vertical transport scheme number
+#ifdef INCA
+   INTEGER, ALLOCATABLE :: had (:), hadv_inca(:), conv_flg_inca(:), &!--- Variables specific to INCA
+                           vad (:), vadv_inca(:),  pbl_flg_inca(:)
+   CHARACTER(LEN=8), ALLOCATABLE :: solsym_inca(:)                   !--- Tracers names for INCA
+   INTEGER :: nqINCA
+#endif
 #ifdef CPP_StratAer
    CHARACTER(LEN=maxlen), ALLOCATABLE :: tnames(:)
 #endif
-   CHARACTER(LEN=maxlen) :: modname="init_infotrac_phy"
-
-   type_trac = type_trac_
-   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)
-   nbtr      = SIZE(conv_flg)
-   nbIso     = SIZE(isotopes_)
-
-   !=== Determine selected isotopes class related quantities:
-   !    ixIso, isotope, niso,isoKeys, ntiso,isoName, nzone,isoZone, nphas,isoPhas, itZonIso, iqTraPha, 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
-
+   CHARACTER(LEN=2)      ::   suff(9)                                !--- Suffixes for schemes of order 3 or 4 (Prather)
+   CHARACTER(LEN=3)      :: descrq(30)                               !--- Advection scheme description tags
+   CHARACTER(LEN=maxlen) :: msg1, texp, ttp                          !--- String for messages and expanded tracers type
+   INTEGER :: fType                                                  !--- Tracers description file type ; 0: none
+                                                                     !--- 1/2/3: "traceur.def"/"tracer.def"/"tracer_*.def"
+   INTEGER :: nqtrue                                                 !--- Tracers nb from tracer.def (no higher order moments)
+   INTEGER :: iad                                                    !--- Advection scheme number
+   INTEGER :: ic, iq, jq, it, nt, im, nm, iz, k                      !--- Indexes and temporary variables
+   LOGICAL :: lerr, ll, lInit
+   CHARACTER(LEN=1) :: p
+   TYPE(trac_type), ALLOCATABLE, TARGET :: ttr(:)
+   TYPE(trac_type), POINTER             :: t1, t(:)
+   INTEGER :: ierr
+
+   CHARACTER(LEN=*), PARAMETER :: modname="init_infotrac_phy"
+!------------------------------------------------------------------------------------------------------------------------------
+! Initialization :
+!------------------------------------------------------------------------------------------------------------------------------
+   suff          = ['x ','y ','z ','xx','xy','xz','yy','yz','zz']
+   descrq( 1:30) =  '   '
+   descrq( 1: 2) = ['LMV','BAK']
+   descrq(10:20) = ['VL1','VLP','FH1','FH2','VLH','   ','PPM','PPS','PPP','   ','SLP']
+   descrq(30)    =  'PRA'
+
+   CALL getin_p('type_trac',type_trac)
+   CALL msg('type_trac = "'//TRIM(type_trac)//'"', modname)
+   lInit = .NOT.ALLOCATED(tracers)
+
+!##############################################################################################################################
+   IF(lInit) THEN                                                    !=== SKIPED IF ALREADY DONE IN dyn3d_common/infotrac  ####
+!##############################################################################################################################
+   !--- MESSAGE ABOUT THE CHOSEN CONFIGURATION
+   msg1 = 'For type_trac = "'//TRIM(type_trac)//'":'
+   SELECT CASE(type_trac)
+      CASE('inca'); CALL msg(TRIM(msg1)//' coupling with INCA chemistry model',        modname)
+      CASE('inco'); CALL msg(TRIM(msg1)//' coupling jointly with INCA and CO2 cycle',  modname)
+      CASE('repr'); CALL msg(TRIM(msg1)//' coupling with REPROBUS chemistry model',    modname)
+      CASE('co2i'); CALL msg(TRIM(msg1)//' you have chosen to run with CO2 cycle',     modname)
+      CASE('coag'); CALL msg(TRIM(msg1)//' tracers are treated for COAGULATION tests', modname)
+      CASE('lmdz'); CALL msg(TRIM(msg1)//' tracers are treated in LMDZ only',          modname)
+      CASE DEFAULT; CALL abort_gcm(modname,'type_trac='//TRIM(type_trac)//' not possible yet.',1)
+   END SELECT
+
+   !--- COHERENCE TEST BETWEEN "type_trac" AND PREPROCESSING KEYS
+   SELECT CASE(type_trac)
+      CASE('inca', 'inco')
+#ifndef INCA
+         CALL abort_gcm(modname, 'You must add cpp key INCA and compile with INCA code', 1)
+#endif
+      CASE('repr')
+#ifndef REPROBUS
+         CALL abort_gcm(modname, 'You must add cpp key REPROBUS and compile with REPROBUS code', 1)
+#endif
+      CASE('coag')
+#ifndef CPP_StratAer
+         CALL abort_gcm(modname, 'You must add cpp key StratAer and compile with StratAer code', 1)
+#endif
+   END SELECT
+!##############################################################################################################################
+   END IF
+!##############################################################################################################################
+
+   nqCO2 = COUNT( [type_trac == 'inco', type_trac == 'co2i'] )
+
+!==============================================================================================================================
+! 1) Get the numbers of: true (first order only) tracers "nqtrue", water tracers "nqo" (vapor/liquid/solid)
+!==============================================================================================================================
+   texp = type_trac                                                  !=== EXPANDED VERSION OF "type_trac", WITH "|" SEPARATOR
+   IF(texp == 'inco') texp = 'co2i|inca'
+   IF(texp /= 'lmdz') texp = 'lmdz|'//TRIM(texp)
+
+   !=== DETERMINE THE TYPE OF THE INPUT TRACERS DESCRIPTION FILE
+   IF(testTracersFiles(modname, texp, fType, lInit)) CALL abort_gcm(modname, 'problem with tracers file(s)',1)
+   ttp = type_trac; IF(fType /= 1) ttp = texp
+
+!##############################################################################################################################
+   IF(lInit) THEN
+      IF(readTracersFiles(ttp, type_trac == 'repr')) CALL abort_gcm(modname, 'problem with tracers file(s)',1)
+   ELSE
+      CALL msg('No tracers description file(s) reading needed: already done in the dynamics', modname)
+   END IF
+!##############################################################################################################################
+
+   !---------------------------------------------------------------------------------------------------------------------------
+   IF(fType == 0) CALL abort_gcm(modname, 'Missing tracers file: "traceur.def", "tracer.def" or "tracer_<keyword>.def file.',1)
+   !---------------------------------------------------------------------------------------------------------------------------
+   IF(fType == 1 .AND. ANY(['inca','inco']==type_trac) .AND. lInit) THEN  !=== OLD STYLE INCA "traceur.def" (single type_trac)
+   !---------------------------------------------------------------------------------------------------------------------------
+#ifdef INCA
+      nqo = SIZE(tracers) - nqCO2
+      CALL Init_chem_inca_trac(nqINCA)                               !--- Get nqINCA from INCA
+      nbtr = nqINCA + nqCO2                                          !--- Number of tracers passed to phytrac
+      nqtrue = nbtr + nqo                                            !--- Total number of "true" tracers
+      IF(ALL([2,3] /= nqo)) CALL abort_gcm(modname, 'Only 2 or 3 water phases allowed ; found nqo='//TRIM(int2str(nqo)), 1)
+      ALLOCATE(hadv(nqtrue), hadv_inca(nqINCA), conv_flg_inca(nqINCA), solsym_inca(nqINCA))
+      ALLOCATE(vadv(nqtrue), vadv_inca(nqINCA),  pbl_flg_inca(nqINCA))
+      CALL init_transport(solsym_inca, conv_flg_inca, pbl_flg_inca, hadv_inca, vadv_inca)
+      ALLOCATE(ttr(nqtrue))
+      ttr(1:nqo+nqCO2)                  = tracers
+      ttr(1    :      nqo   )%component = 'lmdz'
+      ttr(1+nqo:nqCO2+nqo   )%component = 'co2i'
+      ttr(1+nqo+nqCO2:nqtrue)%component = 'inca'
+      ttr(1+nqo      :nqtrue)%name      = [('CO2     ', k=1, nqCO2), solsym_inca]
+      ttr(1+nqo+nqCO2:nqtrue)%parent    = tran0
+      ttr(1+nqo+nqCO2:nqtrue)%phase     = 'g'
+      lerr = getKey('hadv', had, ky=tracers(:)%keys)
+      lerr = getKey('vadv', vad, ky=tracers(:)%keys)
+      hadv(1:nqo+nqCO2) = had(:); hadv(1+nqo+nqCO2:nqtrue) = hadv_inca
+      vadv(1:nqo+nqCO2) = vad(:); vadv(1+nqo+nqCO2:nqtrue) = vadv_inca
+      CALL MOVE_ALLOC(FROM=ttr, TO=tracers)
+      DO iq = 1, nqtrue
+         t1 => tracers(iq)
+         CALL addKey('name',      t1%name,      t1%keys)
+         CALL addKey('component', t1%component, t1%keys)
+         CALL addKey('parent',    t1%parent,    t1%keys)
+         CALL addKey('phase',     t1%phase,     t1%keys)
+      END DO
+      IF(setGeneration(tracers)) CALL abort_gcm(modname,'See below',1) !- SET FIELDS %iGeneration, %gen0Name
+      DEALLOCATE(had, hadv_inca, vad, vadv_inca, conv_flg_inca, pbl_flg_inca, solsym_inca)
+#endif
+   !---------------------------------------------------------------------------------------------------------------------------
+   ELSE                                                              !=== OTHER CASES (OLD OR NEW FORMAT, NO INCA MODULE)
+   !---------------------------------------------------------------------------------------------------------------------------
+      nqo    =        COUNT(delPhase(tracers(:)%name)     == 'H2O' &
+                               .AND. tracers(:)%component == 'lmdz') !--- Number of water phases
+      nqtrue = SIZE(tracers)                                         !--- Total number of "true" tracers
+      nbtr   = nqtrue-COUNT(delPhase(tracers(:)%gen0Name) == 'H2O' &
+                               .AND. tracers(:)%component == 'lmdz') !--- Number of tracers passed to phytrac
+#ifdef INCA
+      nqINCA = COUNT(tracers(:)%component == 'inca')
+#endif
+      lerr = getKey('hadv', hadv, ky=tracers(:)%keys)
+      lerr = getKey('vadv', vadv, ky=tracers(:)%keys)
+   !---------------------------------------------------------------------------------------------------------------------------
+   END IF
+   !---------------------------------------------------------------------------------------------------------------------------
+
+   !--- Transfert the number of tracers to Reprobus
+#ifdef REPROBUS
+   CALL Init_chem_rep_trac(nbtr, nqo, tracers(:)%name)
+#endif
+
+!##############################################################################################################################
+   IF(lInit) THEN                                                    !=== SKIPED IF ALREADY DONE IN dyn3d_common/infotrac  ####
+!##############################################################################################################################
+
+!==============================================================================================================================
+! 2) Calculate nqtot, number of tracers needed (greater if advection schemes 20 or 30 have been chosen).
+!==============================================================================================================================
+   DO iq = 1, nqtrue
+      IF( hadv(iq)<20 .OR. (ANY(hadv(iq)==[20,30]) .AND. hadv(iq)==vadv(iq)) ) CYCLE
+      WRITE(msg1,'("The choice hadv=",i0,", vadv=",i0,a)')hadv(iq),vadv(iq),' for "'//TRIM(tracers(iq)%name)//'" is not available'
+      CALL abort_gcm(modname, TRIM(msg1), 1)
+   END DO
+   nqtot =    COUNT( hadv< 20 .AND. vadv< 20 ) &                     !--- No additional tracer
+         +  4*COUNT( hadv==20 .AND. vadv==20 ) &                     !--- 3  additional tracers
+         + 10*COUNT( hadv==30 .AND. vadv==30 )                       !--- 9  additional tracers
+
+   !--- More tracers due to the choice of advection scheme => assign total number of tracers
+   IF( nqtot /= nqtrue ) THEN
+      CALL msg('The choice of advection scheme for one or more tracers makes it necessary to add tracers')
+      CALL msg('The number of true tracers is '//TRIM(int2str(nqtrue)))
+      CALL msg('The total number of tracers needed is '//TRIM(int2str(nqtot)))
+   END IF
+
+!==============================================================================================================================
+! 3) Determine the advection scheme ; needed to compute the full tracers list, the long names and nqtot.
+!==============================================================================================================================
+   ALLOCATE(ttr(nqtot))
+   jq = nqtrue+1; tracers(:)%iadv = -1
+   DO iq = 1, nqtrue
+      t1 => tracers(iq)
+
+      !--- VERIFY THE CHOICE OF ADVECTION SCHEME
+      iad = -1
+      IF(hadv(iq)     ==    vadv(iq)    ) iad = hadv(iq)
+      IF(hadv(iq)==10 .AND. vadv(iq)==16) iad = 11
+      WRITE(msg1,'("Bad choice of advection scheme for ",a,": hadv = ",i0,", vadv = ",i0)')TRIM(t1%name), hadv(iq), vadv(iq)
+      IF(iad == -1) CALL abort_gcm(modname, msg1, 1)
+
+      !--- SET FIELDS %longName, %isInPhysics
+      t1%longName   = t1%name; IF(iad > 0) t1%longName=TRIM(t1%name)//descrq(iad)
+      t1%isInPhysics= delPhase(t1%gen0Name) /= 'H2O' &
+                          .OR. t1%component /= 'lmdz' !=== OTHER EXCEPTIONS TO BE ADDED: CO2i, SURSATURATED WATER CLOUD...
+      ttr(iq)       = t1
+
+      !--- DEFINE THE HIGHER ORDER TRACERS, IF ANY
+      nm = 0
+      IF(iad == 20) nm = 3                                           !--- 2nd order scheme
+      IF(iad == 30) nm = 9                                           !--- 3rd order scheme
+      IF(nm == 0) CYCLE                                              !--- No higher moments
+      ttr(jq+1:jq+nm)             = t1
+      ttr(jq+1:jq+nm)%name        = [(TRIM(t1%name)    //'-'//TRIM(suff(im)), im=1, nm) ]
+      ttr(jq+1:jq+nm)%parent      = [(TRIM(t1%parent)  //'-'//TRIM(suff(im)), im=1, nm) ]
+      ttr(jq+1:jq+nm)%longName    = [(TRIM(t1%longName)//'-'//TRIM(suff(im)), im=1, nm) ]
+      jq = jq + nm
+   END DO
+   DEALLOCATE(hadv, vadv)
+   CALL MOVE_ALLOC(FROM=ttr, TO=tracers)
+
+   !--- SET FIELDS %iqParent, %nqChildren, %iGeneration, %iqDescen, %nqDescen
+   CALL indexUpdate(tracers)
+
+!##############################################################################################################################
+   END IF
+!##############################################################################################################################
+
+!##############################################################################################################################
+   IF(.NOT.lInit) THEN
+!##############################################################################################################################
+     nqtot = SIZE(tracers)
+!##############################################################################################################################
+   ELSE
+!##############################################################################################################################
+
+   !=== READ PHYSICAL PARAMETERS FOR ISOTOPES
+   niso = 0; nzone = 0; nphas = nqo; ntiso = 0; isoCheck = .FALSE.
+   IF(readIsotopesFile()) CALL abort_gcm(modname, 'Problem when reading isotopes parameters', 1)
+
+!##############################################################################################################################
+   END IF
+!##############################################################################################################################
+   !--- Convection / boundary layer activation for all tracers
+   ALLOCATE(conv_flg(nbtr)); conv_flg(1:nbtr) = 1
+   ALLOCATE( pbl_flg(nbtr));  pbl_flg(1:nbtr) = 1
+
+   !--- Note: nqtottr can differ from nbtr when nmom/=0
+   nqtottr = nqtot - COUNT(delPhase(tracers%gen0Name) == 'H2O' .AND. tracers%component == 'lmdz')
+   IF(COUNT(tracers%iso_iName == 0) - COUNT(delPhase(tracers%name) == 'H2O' .AND. tracers%component == 'lmdz') /= nqtottr) &
+      CALL abort_gcm(modname, 'pb dans le calcul de nqtottr', 1)
+
+   !=== DISPLAY THE RESULTS
+   CALL msg('nqo    = '//TRIM(int2str(nqo)),    modname)
+   CALL msg('nbtr   = '//TRIM(int2str(nbtr)),   modname)
+   CALL msg('nqtrue = '//TRIM(int2str(nqtrue)), modname)
+   CALL msg('nqtot  = '//TRIM(int2str(nqtot)),  modname)
+   CALL msg('niso   = '//TRIM(int2str(niso)),   modname)
+   CALL msg('ntiso  = '//TRIM(int2str(ntiso)),  modname)
+#ifdef INCA
+   CALL msg('nqCO2  = '//TRIM(int2str(nqCO2)),  modname)
+   CALL msg('nqINCA = '//TRIM(int2str(nqINCA)), modname)
+#endif
+   t => tracers
+   CALL msg('Information stored in infotrac_phy :', modname)
+   IF(dispTable('issssssssiiiiiiii', &
+      ['iq    ', 'name  ', 'lName ', 'gen0N ', 'parent', 'type  ', 'phase ', 'compon', 'isPhy ',           &
+                 'iGen  ', 'iqPar ', 'nqDes ', 'nqChld', 'iGroup', 'iName ', 'iZone ', 'iPhase'],          &
+      cat(t%name, t%longName, t%gen0Name, t%parent, t%type, t%phase, t%component, bool2str(t%isInPhysics)),&
+      cat([(iq, iq=1, nqtot)], t%iGeneration, t%iqParent, t%nqDescen, t%nqChildren, t%iso_iGroup,          &
+                  t%iso_iName, t%iso_iZone, t%iso_iPhase), nColMax=maxTableWidth, nHead=2, sub=modname))   &
+      CALL abort_gcm(modname, "problem with the tracers table content", 1)
+   IF(niso > 0) THEN
+      CALL msg('Where, for isotopes family "'//TRIM(isotope%parent)//'":', modname)
+      CALL msg('  isoKeys%name = '//strStack(isoKeys%name), modname)
+      CALL msg('  isoName = '//strStack(isoName),      modname)
+      CALL msg('  isoZone = '//strStack(isoZone),      modname)
+      CALL msg('  isoPhas = '//TRIM(isoPhas),          modname)
+   ELSE
+      CALL msg('No isotopes identified.', modname)
+   END IF
+
+#ifdef ISOVERIF
+   CALL msg('iso_iName = '//strStack(int2str(PACK(tracers(:)%iso_iName, MASK=tracers(:)%iso_iGroup==iH2O))), modname)
+#endif
 #ifdef CPP_StratAer
    IF (type_trac == 'coag') THEN
@@ -208,5 +431,5 @@
       tnames = PACK(tracers(:)%name, MASK=tracers(:)%isInPhysics)
       id_BIN01_strat = strIdx(tnames, 'BIN01'   )
-      id_OCS_strat   = strIdx(tnames, 'GASOSC'  )
+      id_OCS_strat   = strIdx(tnames, 'GASOCS'  )
       id_SO2_strat   = strIdx(tnames, 'GASSO2'  )
       id_H2SO4_strat = strIdx(tnames, 'GASH2SO4')
@@ -221,62 +444,7 @@
    END IF
 #endif
-
-   !--- Isotopic quantities (to be removed soon)
-   ntraciso       => ntiso
-   ntraceurs_zone => nzone
-   iqiso          => iqTraPha
-   index_trac     => itZonIso
-   ok_iso_verif   = isoCheck
-   niso_possibles = SIZE(tnom_iso)
-   indnum_fn_num  = [(strIdx(isotope%keys(:)%name, tnom_iso(ixt)), ixt=1, niso_possibles)]
-   use_iso        = indnum_fn_num /= 0
-#ifdef ISOVERIF
-   CALL msg('iso_iName = '//strStack(int2str(PACK(tracers(:)%iso_iName, MASK=tracers(:)%iso_iGroup==iH2O))), modname)
-#endif
+   CALL msg('end', modname)
 
 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
-   CALL msg('no isotope family named "'//TRIM(iName)//'"', ll=lerr .AND. lV)
-   IF(lerr) RETURN
-   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
-   iqTraPha => isotope%iqTraPha
-END FUNCTION isoSelectByIndex
-!==============================================================================================================================
-
-
 END MODULE infotrac_phy
Index: LMDZ6/branches/Portage_acc/libf/phylmd/iophy.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/iophy.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/iophy.F90	(revision 4446)
@@ -1048,5 +1048,7 @@
 
     !Et sinon on.... écrit
-    IF (SIZE(field)/=klon .AND. SIZE(field)/=klev .AND. SIZE(field)/=klev+1) CALL abort_physic('iophy::histwrite2d_phy','Field first DIMENSION not equal to klon/klev',1)    
+    IF (SIZE(field)/=klon .AND. SIZE(field)/=klev .AND. SIZE(field)/=klev+1) &
+         CALL abort_physic('iophy::histwrite2d_phy',&
+         'Field first DIMENSION not equal to klon/klev',1)
     IF (prt_level >= 10) THEn
       WRITE (lunout,*)"histwrite2d_phy: .not.vars_defined ; time to gather and write ", trim(var%name)
@@ -1246,12 +1248,16 @@
 
     !Et sinon on.... écrit
-    IF (SIZE(field,1)/=klon .AND. SIZE(field,1)/=klev .AND. SIZE(field,1)/=klev+1) CALL abort_physic('iophy::histwrite3d_phy','Field first DIMENSION not equal to klon/klev',1)
+    IF (SIZE(field,1)/=klon .AND. SIZE(field,1)/=klev &
+         .AND. SIZE(field,1)/=klev+1) &
+         CALL abort_physic('iophy::histwrite3d_phy', &
+         'Field first DIMENSION not equal to klon/klev',1)
 
     nlev=SIZE(field,2)
-    IF (nlev.EQ.klev+1) THEN
-        nlevx=klev
-    ELSE
-        nlevx=nlev
-    ENDIF
+    nlevx=nlev
+!    IF (nlev.EQ.klev+1) THEN
+!        nlevx=klev
+!    ELSE
+!        nlevx=nlev
+!    ENDIF
 
     IF (SIZE(field,1) == klon) then
Index: LMDZ6/branches/Portage_acc/libf/phylmd/iophys.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/iophys.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/iophys.F90	(revision 4446)
@@ -170,8 +170,11 @@
 mois0=day_ref/30+1
 an0=annee_ref
-t0=(day_ini-1)*RDAY
+!FH BIZARE QUAND 1D ...  t0=(day_ini-1)*RDAY
+t0=0.
 calendrier=calend
-
-if ( calendrier == "earth_360d" ) calendrier="360d"
+if ( calendrier == "earth_360d" ) calendrier="360_day"
+
+print*,'iophys_ini annee_ref day_ref',annee_ref,day_ref,day_ini,calend,t0
+
 
 call iotd_ini('phys.nc', &
Index: LMDZ6/branches/Portage_acc/libf/phylmd/iotd_ecrit.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/iotd_ecrit.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/iotd_ecrit.F90	(revision 4446)
@@ -22,4 +22,5 @@
 !=================================================================
  
+      use netcdf, only: nf90_put_var
       implicit none
 
@@ -108,5 +109,5 @@
 
 
-           ierr= NF_PUT_VARA_REAL(nid,varid,ntime,1,date)
+           ierr= NF90_PUT_VAR(nid,varid,date,[ntime])
 
 !          print*,'date ',date,ierr,nid
@@ -172,5 +173,5 @@
 
 
-      ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,zx)
+      ierr= NF90_PUT_VAR(nid,varid,zx,corner,edges)
 
       if (ierr.ne.NF_NOERR) then
Index: LMDZ6/branches/Portage_acc/libf/phylmd/lscp_ini_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/lscp_ini_mod.F90	(revision 4446)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/lscp_ini_mod.F90	(revision 4446)
@@ -0,0 +1,90 @@
+module lscp_ini_mod
+
+implicit none
+
+  ! PARAMETERS for lscp:
+  !--------------------
+  
+  REAL, SAVE :: seuil_neb=0.001                 ! cloud fraction threshold: a cloud really exists when exceeded
+  !$OMP THREADPRIVATE(seuil_neb)
+
+  INTEGER, SAVE :: ninter=5                     ! number of iterations to calculate autoconversion to precipitation
+  !$OMP THREADPRIVATE(ninter)
+
+  INTEGER,SAVE :: iflag_evap_prec=1             ! precipitation evaporation flag. 0: nothing, 1: "old way", 
+                                                ! 2: Max cloud fraction above to calculate the max of reevaporation
+                                                ! 4: LTP'method i.e. evaporation in the clear-sky fraction of the mesh only
+  !$OMP THREADPRIVATE(iflag_evap_prec)
+
+  REAL t_coup                                   ! temperature threshold which determines the phase 
+  PARAMETER (t_coup=234.0)                      ! for which the saturation vapor pressure is calculated
+
+  REAL DDT0                                     ! iteration parameter 
+  PARAMETER (DDT0=.01)
+
+  REAL ztfondue                                 ! parameter to calculate melting fraction of precipitation
+  PARAMETER (ztfondue=278.15)
+
+  REAL, SAVE    :: rain_int_min=0.001           ! Minimum local rain intensity [mm/s] before the decrease in associated precipitation fraction 
+  !$OMP THREADPRIVATE(rain_int_min)
+
+  REAL, SAVE :: a_tr_sca(4)                     ! Variables for tracers temporary: alpha parameter for scavenging, 4 possible scavenging processes
+  !$OMP THREADPRIVATE(a_tr_sca)
+  
+  INTEGER, SAVE ::  iflag_mpc_bl=0              ! flag to activate boundary layer mixed phase cloud param
+  !$OMP THREADPRIVATE(iflag_mpc_bl)
+  
+  LOGICAL, SAVE :: ok_radocond_snow=.false.       ! take into account the mass of ice precip in the cloud ice content seen by radiation
+  !$OMP THREADPRIVATE(ok_radocond_snow)
+
+  LOGICAL, SAVE :: ok_debug_autoconversion=.true.   ! removes a bug in the autoconversion process
+  !$OMP THREADPRIVATE(ok_debug_autoconversion)
+
+
+CONTAINS
+
+SUBROUTINE lscp_ini(dtime,ok_ice_sursat)
+
+
+   USE ioipsl_getin_p_mod, ONLY : getin_p
+   USE print_control_mod, ONLY: prt_level, lunout
+   USE ice_sursat_mod, ONLY: ice_sursat_init
+
+   REAL, INTENT(IN)      :: dtime
+   LOGICAL, INTENT(IN)   :: ok_ice_sursat  
+
+    CALL getin_p('ninter',ninter)
+    CALL getin_p('iflag_evap_prec',iflag_evap_prec)
+    CALL getin_p('seuil_neb',seuil_neb)
+    CALL getin_p('rain_int_min',rain_int_min) 
+    CALL getin_p('iflag_mpc_bl',iflag_mpc_bl)
+    CALL getin_p('ok_radocond_snow',ok_radocond_snow) 
+    CALL getin_p('ok_debug_autoconversion',ok_debug_autoconversion)    
+    WRITE(lunout,*) 'lscp, ninter:', ninter
+    WRITE(lunout,*) 'lscp, iflag_evap_prec:', iflag_evap_prec
+    WRITE(lunout,*) 'lscp, seuil_neb:', seuil_neb
+    WRITE(lunout,*) 'lscp, rain_int_min:', rain_int_min
+    WRITE(lunout,*) 'lscp, iflag_mpc_bl:', iflag_mpc_bl
+    WRITE(lunout,*) 'lscp, ok_radocond_snow:', ok_radocond_snow
+    WRITE(lunout,*) 'lscp, ok_debug_autoconversion:', ok_debug_autoconversion
+
+    ! check for precipitation sub-time steps
+    IF (ABS(dtime/REAL(ninter)-360.0).GT.0.001) THEN
+        WRITE(lunout,*) 'lscp: it is not expected, see Z.X.Li', dtime
+        WRITE(lunout,*) 'I would prefer a 6 min sub-timestep'
+    ENDIF
+
+
+    !AA Temporary initialisation
+    a_tr_sca(1) = -0.5
+    a_tr_sca(2) = -0.5
+    a_tr_sca(3) = -0.5
+    a_tr_sca(4) = -0.5
+    
+    IF (ok_ice_sursat) CALL ice_sursat_init()
+
+
+
+end subroutine lscp_ini
+
+end module lscp_ini_mod
Index: LMDZ6/branches/Portage_acc/libf/phylmd/lscp_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/lscp_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/lscp_mod.F90	(revision 4446)
@@ -1,3 +1,3 @@
-MODULE LSCP_mod
+MODULE lscp_mod
 
 IMPLICIT NONE
@@ -6,13 +6,14 @@
 
 !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-SUBROUTINE LSCP(dtime,missing_val,                      &
+SUBROUTINE lscp(klon,klev,dtime,missing_val,            &
      paprs,pplay,t,q,ptconv,ratqs,                      &
-     d_t, d_q, d_ql, d_qi, rneb, rneb_seri,             &
-     radliq, radicefrac, rain, snow,                    &
-     pfrac_impa, pfrac_nucl, pfrac_1nucl,               &
+     d_t, d_q, d_ql, d_qi, rneb, rneblsvol, rneb_seri,  &
+     radocond, radicefrac, rain, snow,                    &
      frac_impa, frac_nucl, beta,                        &
      prfl, psfl, rhcl, zqta, fraca,                     &
      ztv, zpspsk, ztla, zthl, iflag_cld_th,             &
-     iflag_ice_thermo, ok_ice_sursat)
+     iflag_ice_thermo, ok_ice_sursat, qsatl, qsats,     &
+     qclr, qcld, qss, qvc, rnebclr, rnebss, gamma_ss,   &
+     Tcontr, qcontr, qcontr2, fcontrN, fcontrP)
 
 !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -23,10 +24,10 @@
 !--------------------------------------------------------------------------------
 ! Aim: Large Scale Clouds and Precipitation (LSCP)
-!      
+!
 ! This code is a new version of the fisrtilp.F90 routine, which is itself a 
 ! merge of 'first' (superrsaturation physics, P. LeVan K. Laval)
 ! and 'ilp' (il pleut, L. Li)
 !
-! Compared to fisrtilp, LSCP 
+! Compared to the original fisrtilp code, lscp
 ! -> assumes thermcep = .TRUE. all the time (fisrtilp inconsistent when .FALSE.)
 ! -> consider always precipitation thermalisation (fl_cor_ebil>0)
@@ -40,20 +41,21 @@
 ! References: 
 !
+! - Bony, S., & Emanuel, K. A. 2001, JAS, doi: 10.1175/1520-0469(2001)058<3158:APOTCA>2.0.CO;2
 ! - Hourdin et al. 2013, Clim Dyn, doi:10.1007/s00382-012-1343-y
 ! - Jam et al. 2013, Boundary-Layer Meteorol, doi:10.1007/s10546-012-9789-3
+! - Jouhaud, et al. 2018. JAMES, doi:10.1029/2018MS001379
 ! - Madeleine et al. 2020, JAMES, doi:10.1029/2020MS002046
+! - Touzze-Peifert Ludo, PhD thesis, p117-124
 ! -------------------------------------------------------------------------------
 ! Code structure:
 !
-! P0>     Thermalization of the  precipitation coming from the overlying layer
+! P0>     Thermalization of the precipitation coming from the overlying layer
 ! P1>     Evaporation of the precipitation (falling from the k+1 level)
 ! P2>     Cloud formation (at the k level) 
-! P2.A.0> Cloud properties calculation from a rectangular pdf
-! P2.A.1> With the new PDFs, calculation of cloud properties using the inital
+! P2.A.1> With the PDFs, calculation of cloud properties using the inital
 !         values of T and Q
 ! P2.A.2> Coupling between condensed water and temperature
 ! P2.A.3> Calculation of final quantities associated with cloud formation
-! P2.B>   'All or nothing' cloud
-! P2.C>   Release of Latent heat after cloud formation
+! P2.B>   Release of Latent heat after cloud formation
 ! P3>     Autoconversion to precipitation (k-level)
 ! P4>     Wet scavenging
@@ -64,5 +66,5 @@
 ! water used in the physics and the dynamics 
 ! 
-! During the autoconversion to precipitation (P3 step), radliq (cloud water used
+! During the autoconversion to precipitation (P3 step), radocond (cloud water used
 ! by the radiation scheme) is calculated as an average of the water that remains
 ! in the cloud during the precipitation and not the water remaining at the end
@@ -74,63 +76,56 @@
 ! Radiation:
 ! xflwc(newmicro)+xfiwc(newmicro) =
-!   cldliq(physiq)=radliq(fisrt)=lwcon(nc)+iwcon(nc)
-!
-! Physics/Dynamics:
-! ql_seri(physiq)+qs_seri(physiq)=ocond(nc)
+!   radocond=lwcon(nc)+iwcon(nc)
 !
 ! Notetheless, be aware of:
 !
-! radliq(fisrt) .NE. ocond(nc)
+! radocond .NE. ocond(nc)
 ! i.e.:
 ! lwcon(nc)+iwcon(nc) .NE. ocond(nc)
+! but oliq+(ocond-oliq) .EQ. ocond
 ! (which is not trivial)
 !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-  
-USE dimphy
+!
 USE print_control_mod, ONLY: prt_level, lunout
-USE cloudth_mod 
-USE ioipsl_getin_p_mod, ONLY : getin_p
-USE phys_local_var_mod, ONLY: ql_seri,qs_seri
-USE phys_local_var_mod, ONLY: rneblsvol
-USE lscp_tools_mod, ONLY : CALC_QSAT_ECMWF, ICEFRAC_LSCP, CALC_GAMMASAT, FALLICE_VELOCITY
-USE ice_sursat_mod
-!--ice supersaturation
-USE phys_local_var_mod, ONLY: zqsats, zqsatl
-USE phys_local_var_mod, ONLY: qclr, qcld, qss, qvc, rnebclr, rnebss, gamma_ss
-USE phys_local_var_mod, ONLY: Tcontr, qcontr, qcontr2, fcontrN, fcontrP
+USE cloudth_mod, ONLY : cloudth, cloudth_v3, cloudth_v6, cloudth_mpc 
+USE lscp_tools_mod, ONLY : calc_qsat_ecmwf, icefrac_lscp, calc_gammasat, fallice_velocity
+USE ice_sursat_mod, ONLY : ice_sursat
+
+USE lscp_ini_mod, ONLY : seuil_neb, ninter, iflag_evap_prec, t_coup, DDT0, ztfondue, rain_int_min
+USE lscp_ini_mod, ONLY : iflag_mpc_bl, ok_radocond_snow, a_tr_sca, ok_debug_autoconversion
+
 
 IMPLICIT NONE
 
 !===============================================================================
-! VARIABLE DECLARATION
+! VARIABLES DECLARATION
 !===============================================================================
 
 include "YOMCST.h"
 include "YOETHF.h"
-include "FCTTRE.h"
 include "fisrtilp.h"
 include "nuage.h" 
 
-  
 ! INPUT VARIABLES:
 !-----------------
 
+  INTEGER,                         INTENT(IN)   :: klon,klev       ! number of horizontal grid points and vertical levels
   REAL,                            INTENT(IN)   :: dtime           ! time step [s]
-  REAL, INTENT(IN)                              :: missing_val     ! missing value for output
+  REAL,                            INTENT(IN)   :: missing_val     ! missing value for output
 
   REAL, DIMENSION(klon,klev+1),    INTENT(IN)   :: paprs           ! inter-layer pressure [Pa]
   REAL, DIMENSION(klon,klev),      INTENT(IN)   :: pplay           ! mid-layer pressure [Pa]
   REAL, DIMENSION(klon,klev),      INTENT(IN)   :: t               ! temperature (K)
-  REAL, DIMENSION(klon,klev),      INTENT(IN)   :: q               ! specific humidity [kg/kg]
+  REAL, DIMENSION(klon,klev),      INTENT(IN)   :: q               ! total specific humidity (= vapor phase) [kg/kg] 
   INTEGER,                         INTENT(IN)   :: iflag_cld_th    ! flag that determines the distribution of convective clouds
   INTEGER,                         INTENT(IN)   :: iflag_ice_thermo! flag to activate the ice thermodynamics
-                                                                   ! CR: if iflag_ice_thermo=2, only convection is active    
+                                                                   ! CR: if iflag_ice_thermo=2, only convection is active
   LOGICAL,                         INTENT(IN)   :: ok_ice_sursat   ! flag to determine if ice sursaturation is activated
 
   LOGICAL, DIMENSION(klon,klev),   INTENT(IN)   :: ptconv          ! grid points where deep convection scheme is active
 
-  
+
   !Inputs associated with thermal plumes
-  
+
   REAL, DIMENSION(klon,klev),      INTENT(IN)   :: ztv             ! virtual potential temperature [K]
   REAL, DIMENSION(klon,klev),      INTENT(IN)   :: zqta            ! specific humidity within thermals [kg/kg]
@@ -144,6 +139,6 @@
 
   REAL, DIMENSION(klon,klev),      INTENT(INOUT):: ratqs            ! function of pressure that sets the large-scale
-                                                                    ! cloud PDF (sigma=ratqs*qt)
-  
+  REAL, DIMENSION(klon,klev),      INTENT(INOUT):: beta             ! conversion rate of condensed water
+
 
   ! Input sursaturation en glace
@@ -158,19 +153,15 @@
   REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: d_qi             ! cloud ice mass increment [kg/kg]
   REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: rneb             ! cloud fraction [-]
-  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: radliq           ! condensed water used in the radiation scheme [kg/kg]
+  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: rneblsvol        ! cloud fraction per unit volume [-]  
+  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: radocond         ! condensed water used in the radiation scheme [kg/kg]
   REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: radicefrac       ! ice fraction of condensed water for radiation scheme
   REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: rhcl             ! clear-sky relative humidity [-]
-  REAL, DIMENSION(klon),           INTENT(OUT)  :: rain             ! large-scale rainfall [kg/s/m2] 
-  REAL, DIMENSION(klon),           INTENT(OUT)  :: snow             ! large-scale snowfall [kg/s/m2]
+  REAL, DIMENSION(klon),           INTENT(OUT)  :: rain             ! surface large-scale rainfall [kg/s/m2] 
+  REAL, DIMENSION(klon),           INTENT(OUT)  :: snow             ! surface large-scale snowfall [kg/s/m2]
+  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: qsatl            ! saturation specific humidity wrt liquid [kg/kg]
+  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: qsats            ! saturation specific humidity wrt ice [kg/kg]  
   REAL, DIMENSION(klon,klev+1),    INTENT(OUT)  :: prfl             ! large-scale rainfall flux in the column [kg/s/m2]
   REAL, DIMENSION(klon,klev+1),    INTENT(OUT)  :: psfl             ! large-scale snowfall flux in the column [kg/s/m2]
 
- 
-  ! cofficients of scavenging fraction (for off-line)
- 
-  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: pfrac_nucl       ! scavenging fraction due tu nucleation [-]
-  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: pfrac_1nucl      ! scavenging fraction due tu nucleation with a -1 factor [-]
-  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: pfrac_impa       ! scavening fraction due to impaction [-]
-  
   ! fraction of aerosol scavenging through impaction and nucleation (for on-line)
   
@@ -178,39 +169,22 @@
   REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: frac_nucl        ! scavenging fraction due tu nucleation [-]
   
-
-
-
-  ! PROGRAM PARAMETERS:
-  !--------------------
+  ! for supersaturation and contrails parameterisation
   
+  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: qclr             ! specific total water content in clear sky region [kg/kg]
+  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: qcld             ! specific total water content in cloudy region [kg/kg]
+  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: qss              ! specific total water content in supersat region [kg/kg]
+  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: qvc              ! specific vapor content in clouds [kg/kg] 
+  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: rnebclr          ! mesh fraction of clear sky [-]   
+  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: rnebss           ! mesh fraction of ISSR [-]  
+  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: gamma_ss         ! coefficient governing the ice nucleation RHi threshold [-]      
+  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: Tcontr           ! threshold temperature for contrail formation [K]
+  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: qcontr           ! threshold humidity for contrail formation [kg/kg]
+  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: qcontr2          ! // (2nd expression more consistent with LMDZ expression of q)          
+  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: fcontrN          ! fraction of grid favourable to non-persistent contrails
+  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: fcontrP          ! fraction of grid favourable to persistent contrails
   
-  REAL, SAVE :: seuil_neb=0.001                                     ! cloud fraction threshold: a cloud really exists when exceeded
-  !$OMP THREADPRIVATE(seuil_neb)
-
-  INTEGER, SAVE :: ninter=5                                         ! number of iterations to calculate autoconversion to precipitation
-  !$OMP THREADPRIVATE(ninter)
-
-  INTEGER,SAVE :: iflag_evap_prec=1                                 ! precipitation evap. flag. 0: nothing, 1: "old way", 2: Max cloud fraction above to calculate the max of reevaporation
-                                                                    ! 4: LTP'method i.e. evaporation in the clear-sky fraction of the mesh only
-  !$OMP THREADPRIVATE(iflag_evap_prec)
-                                                                    
-
-  REAL t_coup                                                       ! temperature threshold which determines the phase 
-  PARAMETER (t_coup=234.0)                                          ! for which the saturation vapor pressure is calculated
-
-  REAL DDT0                                                         ! iteration parameter 
-  PARAMETER (DDT0=.01)
-
-  REAL ztfondue                                                     ! parameter to calculate melting fraction of precipitation
-  PARAMETER (ztfondue=278.15)
-
-  REAL, SAVE    :: rain_int_min=0.001                               ! Minimum local rain intensity [mm/s] before the decrease in associated precipitation fraction 
-  !$OMP THREADPRIVATE(rain_int_min)
-
-
 
   ! LOCAL VARIABLES:
   !----------------
-
 
   REAL qsl(klon), qsi(klon)
@@ -218,12 +192,12 @@
   REAL ctot(klon,klev)
   REAL ctot_vol(klon,klev)
-  REAL zqs(klon), zdqs(klon), zdelta, zcor, zcvm5  
+  REAL zqs(klon), zdqs(klon), zdelta, zcor, zcvm5
   REAL zdqsdT_raw(klon)
-  REAL gammasat(klon),dgammasatdt(klon)                                 ! coefficient to make cold condensation at the correct RH and derivative wrt T
+  REAL gammasat(klon),dgammasatdt(klon)                ! coefficient to make cold condensation at the correct RH and derivative wrt T
   REAL Tbef(klon),qlbef(klon),DT(klon),num,denom
   REAL cste
   REAL zpdf_sig(klon),zpdf_k(klon),zpdf_delta(klon)
   REAL Zpdf_a(klon),zpdf_b(klon),zpdf_e1(klon),zpdf_e2(klon)
-  REAL erf   
+  REAL erf
   REAL qcloud(klon), icefrac_mpc(klon,klev), qincloud_mpc(klon)
   REAL zrfl(klon), zrfln(klon), zqev, zqevt 
@@ -245,38 +219,28 @@
   ! Variables precipitation energy conservation
   REAL zmqc(klon)
-  ! Variables for tracers
-  ! temporary: alpha parameter for scavenging
-  ! 4 possible scavenging processes
-  REAL a_tr_sca(4)
-  save a_tr_sca
-  !$OMP THREADPRIVATE(a_tr_sca)  
   REAL zalpha_tr
   REAL zfrac_lessi
   REAL zprec_cond(klon)
-  REAL beta(klon,klev)                   ! conversion rate of condensed water
   REAL zmair(klon), zcpair, zcpeau
   REAL zlh_solid(klon), zm_solid         ! for liquid -> solid conversion
-  REAL zrflclr(klon), zrflcld(klon)                                                                    
-  REAL d_zrfl_clr_cld(klon), d_zifl_clr_cld(klon)                                                   
+  REAL zrflclr(klon), zrflcld(klon)
+  REAL d_zrfl_clr_cld(klon), d_zifl_clr_cld(klon)
   REAL d_zrfl_cld_clr(klon), d_zifl_cld_clr(klon) 
-  REAL ziflclr(klon), ziflcld(klon)                                                                    
-  REAL znebprecipclr(klon), znebprecipcld(klon)                                                        
-  REAL tot_zneb(klon), tot_znebn(klon), d_tot_zneb(klon)                                              
+  REAL ziflclr(klon), ziflcld(klon)
+  REAL znebprecipclr(klon), znebprecipcld(klon)
+  REAL tot_zneb(klon), tot_znebn(klon), d_tot_zneb(klon)
   REAL d_znebprecip_clr_cld(klon), d_znebprecip_cld_clr(klon)
   REAL velo(klon,klev), vr
   REAL qlmpc, qimpc, rnebmpc
-  REAL radliqi(klon,klev), radliql(klon,klev)
+  REAL radocondi(klon,klev), radocondl(klon,klev)
 
   INTEGER i, k, n, kk
   INTEGER n_i(klon), iter
-  INTEGER ncoreczq  
+  INTEGER ncoreczq
   INTEGER mpc_bl_points(klon,klev)
-  INTEGER,SAVE :: itap=0
-  !$OMP THREADPRIVATE(itap)
 
   LOGICAL lognormale(klon)
-  LOGICAL convergence(klon)
-  LOGICAL appel1er
-  SAVE appel1er
+  LOGICAL keepgoing(klon)
+  LOGICAL,SAVE :: appel1er
   !$OMP THREADPRIVATE(appel1er)
 
@@ -290,5 +254,5 @@
 !===============================================================================
 
-! Few initial checksS
+! Few initial checks
 
 IF (iflag_t_glace.EQ.0) THEN
@@ -302,74 +266,30 @@
 ENDIF
 
-IF (.NOT.thermcep) THEN
-     abort_message = 'lscp cannot be used when thermcep=false'
-     CALL abort_physic(modname,abort_message,1)
+IF (iflag_fisrtilp_qsat .LT. 0) THEN
+    abort_message = 'lscp cannot be used with iflag_fisrtilp<0'
+    CALL abort_physic(modname,abort_message,1)
 ENDIF
 
-IF (iflag_fisrtilp_qsat .LT. 0) THEN
-        abort_message = 'lscp cannot be used with iflag_fisrtilp<0'
-     CALL abort_physic(modname,abort_message,1)
-ENDIF
-
-
 ! Few initialisations
 
-itap=itap+1
-znebprecip(:)=0.
+znebprecip(:)=0.0
 ctot_vol(1:klon,1:klev)=0.0
 rneblsvol(1:klon,1:klev)=0.0
-smallestreal=1.e-9                                                                                  
-znebprecipclr(:)=0.    
-znebprecipcld(:)=0.                                                                            
+smallestreal=1.e-9
+znebprecipclr(:)=0.0
+znebprecipcld(:)=0.0
 mpc_bl_points(:,:)=0
 
 IF (prt_level>9) WRITE(lunout,*) 'NUAGES4 A. JAM'
-
-IF (appel1er) THEN
-    CALL getin_p('ninter',ninter)
-    CALL getin_p('iflag_evap_prec',iflag_evap_prec)
-    CALL getin_p('seuil_neb',seuil_neb)
-    CALL getin_p('rain_int_min',rain_int_min) 
-    WRITE(lunout,*) 'lscp, ninter:', ninter
-    WRITE(lunout,*) 'lscp, iflag_evap_prec:', iflag_evap_prec
-    WRITE(lunout,*) 'lscp, seuil_neb:', seuil_neb
-    WRITE(lunout,*) 'lscp, rain_int_min:', rain_int_min
-
-    ! check for precipitation sub-time steps
-    IF (ABS(dtime/REAL(ninter)-360.0).GT.0.001) THEN
-        WRITE(lunout,*) 'lscp: it is not expected, see Z.X.Li', dtime
-        WRITE(lunout,*) 'I would prefer a 6 min sub-timestep'
-    ENDIF
-     
-    !AA Temporary initialisation
-    a_tr_sca(1) = -0.5
-    a_tr_sca(2) = -0.5
-    a_tr_sca(3) = -0.5
-    a_tr_sca(4) = -0.5
-
-    !AA Set scavenged fractions to 1
-    DO k = 1, klev
-        DO i = 1, klon
-            pfrac_nucl(i,k)=1.
-            pfrac_1nucl(i,k)=1.
-            pfrac_impa(i,k)=1.
-            beta(i,k)=0.       
-        ENDDO
-    ENDDO
-
-    IF (ok_ice_sursat) CALL ice_sursat_init()
-
-    appel1er = .FALSE.
-
-ENDIF     !(appel1er)  
 
 ! AA for 'safety' reasons
 zalpha_tr   = 0.
 zfrac_lessi = 0.
-
-! Initialisation of output variables (JYG):
+beta(:,:)= 0.
+
+! Initialisation of variables:
+
 prfl(:,:) = 0.0
 psfl(:,:) = 0.0
-
 d_t(:,:) = 0.0
 d_q(:,:) = 0.0
@@ -377,9 +297,8 @@
 d_qi(:,:) = 0.0
 rneb(:,:) = 0.0
-radliq(:,:) = 0.0
+radocond(:,:) = 0.0
 radicefrac(:,:) = 0.0
-frac_nucl(:,:) = 1. 
-frac_impa(:,:) = 1. 
-
+frac_nucl(:,:) = 1.0 
+frac_impa(:,:) = 1.0 
 rain(:) = 0.0
 snow(:) = 0.0
@@ -393,17 +312,17 @@
 ziflprev(:)=0.0
 zneb(:) = seuil_neb
-zrflclr(:) = 0.0                                                                            
-ziflclr(:) = 0.0                                                                            
-zrflcld(:) = 0.0                                                                               
-ziflcld(:) = 0.0                                                                                  
-tot_zneb(:) = 0.0                                                                                 
-tot_znebn(:) = 0.0                                                                               
-d_tot_zneb(:) = 0.0   
-qzero(:)=0.0
-
-!--ice sursaturation
-gamma_ss(:,:) = 1.
-qss(:,:) = 0.
-rnebss(:,:) = 0.
+zrflclr(:) = 0.0
+ziflclr(:) = 0.0
+zrflcld(:) = 0.0
+ziflcld(:) = 0.0
+tot_zneb(:) = 0.0
+tot_znebn(:) = 0.0
+d_tot_zneb(:) = 0.0
+qzero(:) = 0.0
+
+!--ice supersaturation
+gamma_ss(:,:) = 1.0
+qss(:,:) = 0.0
+rnebss(:,:) = 0.0
 Tcontr(:,:) = missing_val
 qcontr(:,:) = missing_val
@@ -412,4 +331,7 @@
 fcontrP(:,:) = 0.0
 
+!c_iso: variable initialisation for iso 
+
+
 !===============================================================================
 !              BEGINNING OF VERTICAL LOOP FROM TOP TO BOTTOM
@@ -419,5 +341,4 @@
 
 DO k = klev, 1, -1
-
 
     ! Initialisation temperature and specific humidity
@@ -425,4 +346,5 @@
         zt(i)=t(i,k)
         zq(i)=q(i,k)
+        !c_iso init of iso
     ENDDO
     
@@ -430,14 +352,18 @@
     ! P0> Thermalization of precipitation falling from the overlying layer
     ! --------------------------------------------------------------------
-    ! Computes air temperature variation due to latent heat transported by
+    ! Computes air temperature variation due to enthalpy transported by
     ! precipitation. Precipitation is then thermalized with the air in the
     ! layer. 
     ! The precipitation should remain thermalized throughout the different
-    ! thermodynamical transformations. The corresponding water mass should
+    ! thermodynamical transformations. 
+    ! The corresponding water mass should
     ! be added when calculating the layer's enthalpy change with 
     ! temperature
+    ! See lmdzpedia page todoan
+    ! todoan: check consistency with ice phase
+    ! todoan: understand why several steps
     ! ---------------------------------------------------------------------
     
-    IF (k.LE.klevm1) THEN 
+    IF (k.LE.klev-1) THEN 
 
         DO i = 1, klon
@@ -447,6 +373,6 @@
             ! RVTMP2=rcpv/rcpd-1
             zcpair=RCPD*(1.0+RVTMP2*zq(i)) 
-            zcpeau=RCPD*RVTMP2             
-                                          
+            zcpeau=RCPD*RVTMP2
+
             ! zmqc: precipitation mass that has to be thermalized with 
             ! layer's air so that precipitation at the ground has the
@@ -456,8 +382,8 @@
             zt(i) = ( (t(i,k+1)+d_t(i,k+1))*zmqc(i)*zcpeau + zcpair*zt(i) ) &
              / (zcpair + zmqc(i)*zcpeau)
-           
+
         ENDDO
  
-    ELSE  
+    ELSE
  
         DO i = 1, klon 
@@ -474,25 +400,26 @@
     ! --------------------------------------------------------------------
 
-
-    IF (iflag_evap_prec.GE.1) THEN
+    IF (iflag_evap_prec.GE.1) THEN 
 
         ! Calculation of saturation specific humidity
         ! depending on temperature:
-        CALL CALC_QSAT_ECMWF(klon,zt(:),qzero(:),pplay(:,k),RTT,0,.false.,zqs(:),zdqs(:))
+        CALL calc_qsat_ecmwf(klon,zt(:),qzero(:),pplay(:,k),RTT,0,.false.,zqs(:),zdqs(:))
         ! wrt liquid water
-        CALL CALC_QSAT_ECMWF(klon,zt(:),qzero(:),pplay(:,k),RTT,1,.false.,qsl(:),dqsl(:))
+        CALL calc_qsat_ecmwf(klon,zt(:),qzero(:),pplay(:,k),RTT,1,.false.,qsl(:),dqsl(:))
         ! wrt ice
-        CALL CALC_QSAT_ECMWF(klon,zt(:),qzero(:),pplay(:,k),RTT,2,.false.,qsi(:),dqsi(:))
+        CALL calc_qsat_ecmwf(klon,zt(:),qzero(:),pplay(:,k),RTT,2,.false.,qsi(:),dqsi(:))
 
         DO i = 1, klon
-     
+
             ! if precipitation
             IF (zrfl(i)+zifl(i).GT.0.) THEN
-                    
-            ! LTP: we only account for precipitation evaporation in the clear-sky (iflag_evap_prec=4).
-                IF (iflag_evap_prec.EQ.4) THEN                                                          
-                    zrfl(i) = zrflclr(i)                                                          
-                    zifl(i) = ziflclr(i)                                                           
-                ENDIF                      
+
+            ! LudoTP: we only account for precipitation evaporation in the clear-sky (iflag_evap_prec=4).
+            ! c_iso: likely important to distinguish cs from neb isotope precipitation
+
+                IF (iflag_evap_prec.EQ.4) THEN
+                    zrfl(i) = zrflclr(i)
+                    zifl(i) = ziflclr(i)
+                ENDIF
 
                 IF (iflag_evap_prec.EQ.1) THEN
@@ -501,14 +428,12 @@
                     znebprecip(i)=MAX(zneb(i),znebprecip(i))
                 ENDIF
-     
-                                                                                                                                                                                                                  
-                IF (iflag_evap_prec.EQ.4) THEN                                                                 
-                ! Max evaporation not to saturate the whole mesh                                             
-                    zqev0 = MAX(0.0, zqs(i)-zq(i))                                                              
-                ELSE       
-                ! Max evap not to saturate the fraction below the cloud                                                   
-                    zqev0 = MAX(0.0, (zqs(i)-zq(i))*znebprecip(i))                                                                                  
-                ENDIF   
-
+
+                IF (iflag_evap_prec.EQ.4) THEN
+                ! Max evaporation not to saturate the whole mesh
+                    zqev0 = MAX(0.0, zqs(i)-zq(i))
+                ELSE
+                ! Max evap not to saturate the fraction below the cloud
+                    zqev0 = MAX(0.0, (zqs(i)-zq(i))*znebprecip(i))
+                ENDIF
 
                 ! Evaporation of liquid precipitation coming from above
@@ -530,8 +455,7 @@
                 ENDIF
 
-
                 zqevt = MAX(0.0,MIN(zqevt,zrfl(i))) &
-                *RG*dtime/(paprs(i,k)-paprs(i,k+1)) 
-         
+                    *RG*dtime/(paprs(i,k)-paprs(i,k+1)) 
+
                 ! sublimation of the solid precipitation coming from above
                 IF (iflag_evap_prec.EQ.3) THEN
@@ -547,7 +471,7 @@
                     *(paprs(i,k)-paprs(i,k+1))/pplay(i,k)*zt(i)*RD/RG
                 ENDIF
-            
+
                 zqevti = MAX(0.0,MIN(zqevti,zifl(i))) &
-                *RG*dtime/(paprs(i,k)-paprs(i,k+1))   
+                *RG*dtime/(paprs(i,k)-paprs(i,k+1))
 
                 ! A. JAM
@@ -556,5 +480,6 @@
                 ! does not reach saturation. In this case, we 
                 ! redistribute zqev0 conserving the ratio liquid/ice 
-   
+
+                ! todoan: check the consistency of this formula
                 IF (zqevt+zqevti.GT.zqev0) THEN
                     zqev=zqev0*zqevt/(zqevt+zqevti)
@@ -566,5 +491,5 @@
 
 
-                ! New solid and liquid precipitation fluxes
+                ! New solid and liquid precipitation fluxes after evap and sublimation
                 zrfln(i) = Max(0.,zrfl(i) - zqev*(paprs(i,k)-paprs(i,k+1))  &
                          /RG/dtime)
@@ -572,8 +497,8 @@
                          /RG/dtime)
 
+
                 ! vapor, temperature, precip fluxes update
                 zq(i) = zq(i) - (zrfln(i)+zifln(i)-zrfl(i)-zifl(i)) &
                 * (RG/(paprs(i,k)-paprs(i,k+1)))*dtime
-                ! precip thermalization
                 zmqc(i) = zmqc(i) + (zrfln(i)+zifln(i)-zrfl(i)-zifl(i)) &
                 * (RG/(paprs(i,k)-paprs(i,k+1)))*dtime
@@ -589,27 +514,43 @@
                 zifl(i) = zifln(i)
 
-                IF (iflag_evap_prec.EQ.4) THEN                                                                 
-                    zrflclr(i) = zrfl(i)                                                                  
-                    ziflclr(i) = zifl(i)    
-                    IF(zrflclr(i) + ziflclr(i).LE.0) THEN                                                
-                        znebprecipclr(i) = 0.                                                          
-                    ENDIF                                                                                
-                    zrfl(i) = zrflclr(i) + zrflcld(i)                                                      
-                    zifl(i) = ziflclr(i) + ziflcld(i)                                                      
-                ENDIF      
-
-
-                ! CR Be careful: ice melting has been moved
-                zmelt = ((zt(i)-273.15)/(ztfondue-273.15)) ! JYG
+                ! c_iso here call_reevap that updates isotopic zrfl, zifl (in inout)
+                !                         due to evap + sublim                                     
+                                           
+
+                IF (iflag_evap_prec.EQ.4) THEN
+                    zrflclr(i) = zrfl(i)
+                    ziflclr(i) = zifl(i)
+                    IF(zrflclr(i) + ziflclr(i).LE.0) THEN
+                        znebprecipclr(i) = 0.0
+                    ENDIF
+                    zrfl(i) = zrflclr(i) + zrflcld(i)
+                    zifl(i) = ziflclr(i) + ziflcld(i)
+                ENDIF
+
+                ! c_iso duplicate for isotopes or loop on isotopes
+
+                ! Melting:
+                zmelt = ((zt(i)-RTT)/(ztfondue-RTT)) ! JYG
                 ! precip fraction that is melted
                 zmelt = MIN(MAX(zmelt,0.),1.)
-                ! Ice melting
-                IF (iflag_evap_prec.EQ.4) THEN                                                              
-                    zrflclr(i)=zrflclr(i)+zmelt*ziflclr(i)                                            
-                    zrflcld(i)=zrflcld(i)+zmelt*ziflcld(i)                                              
-                    zrfl(i)=zrflclr(i)+zrflcld(i)                                                       
-                ELSE                                                                                        
-                    zrfl(i)=zrfl(i)+zmelt*zifl(i)                                                      
-                ENDIF                  
+
+                ! update of rainfall and snowfall due to melting
+                IF (iflag_evap_prec.EQ.4) THEN
+                    zrflclr(i)=zrflclr(i)+zmelt*ziflclr(i)
+                    zrflcld(i)=zrflcld(i)+zmelt*ziflcld(i)
+                    zrfl(i)=zrflclr(i)+zrflcld(i)
+
+                    ziflclr(i)=ziflclr(i)*(1.-zmelt)
+                    ziflcld(i)=ziflcld(i)*(1.-zmelt)
+                    zifl(i)=ziflclr(i)+ziflcld(i)
+
+                ELSE
+                    zrfl(i)=zrfl(i)+zmelt*zifl(i)
+
+                    zifl(i)=zifl(i)*(1.-zmelt)
+                ENDIF
+
+
+                ! c_iso: melting of isotopic precipi with zmelt (no fractionation)
 
                 ! Latent heat of melting with precipitation thermalization
@@ -617,11 +558,4 @@
                 *RLMLT/RCPD/(1.0+RVTMP2*(zq(i)+zmqc(i)))
                 
-                IF (iflag_evap_prec.EQ.4) THEN                                                             
-                    ziflclr(i)=ziflclr(i)*(1.-zmelt)                                                    
-                    ziflcld(i)=ziflcld(i)*(1.-zmelt)                                                    
-                    zifl(i)=ziflclr(i)+ziflcld(i)                                                       
-                ELSE                                                                                      
-                    zifl(i)=zifl(i)*(1.-zmelt)                                                          
-                ENDIF
 
             ELSE
@@ -632,5 +566,5 @@
 
         ENDDO
-         
+
     ENDIF ! (iflag_evap_prec>=1)
 
@@ -638,13 +572,10 @@
     ! End precip evaporation
     ! --------------------------------------------------------------------
-
-
-
     
     ! Calculation of qsat, L/Cp*dqsat/dT and ncoreczq counter
     !-------------------------------------------------------
-      
+
      qtot(:)=zq(:)+zmqc(:)
-     CALL CALC_QSAT_ECMWF(klon,zt(:),qtot(:),pplay(:,k),RTT,0,.false.,zqs(:),zdqs(:))
+     CALL calc_qsat_ecmwf(klon,zt(:),qtot(:),pplay(:,k),RTT,0,.false.,zqs(:),zdqs(:))
      DO i = 1, klon
             zdelta = MAX(0.,SIGN(1.,RTT-zt(i)))
@@ -654,8 +585,8 @@
                 zq(i)=1.e-15
             ENDIF
+            ! c_iso: do something similar for isotopes
 
      ENDDO
     
-
     ! --------------------------------------------------------------------
     ! P2> Cloud formation
@@ -670,7 +601,6 @@
     ! -------------------------------------------------------------------
 
-           
         ! P2.1> With the PDFs (log-normal, bigaussian) 
-        ! cloud propertues calculation with the initial values of t and q
+        ! cloud properties calculation with the initial values of t and q
         ! ----------------------------------------------------------------
 
@@ -697,8 +627,7 @@
                          ratqs,zqs,t)
 
-
                 !Jean Jouhaud's version, Decembre 2018 
-                !-------------------------------------              
-             
+                !-------------------------------------
+
                 ELSEIF (iflag_cloudth_vert.EQ.6) THEN
 
@@ -714,5 +643,5 @@
                 ! + stationary mixed-phase cloud model
 
-                    CALL cloudth_mpc(klon,klev,k,mpc_bl_points,            &
+                    CALL cloudth_mpc(klon,klev,k,iflag_mpc_bl,mpc_bl_points, &
                          t,ztv,zq,zqta,fraca, zpspsk,                      &
                          paprs,pplay,ztla,zthl,ratqs,zqs,psfl,             &
@@ -740,5 +669,5 @@
 
         ELSE
-                ! When iflag_cld_th=5, we always assume  
+                ! When iflag_cld_th=5, we always assume
                 ! bi-gaussian distribution
             lognormale = .FALSE.
@@ -746,5 +675,4 @@
         ENDIF
 
-
         DT(:) = 0.
         n_i(:)=0
@@ -754,16 +682,18 @@
         ! Treatment of non-boundary layer clouds (lognormale)
         ! condensation with qsat(T) variation (adaptation)
-        ! Iterative Loop to converge towards qsat
-        
-        
+        ! Iterative resolution to converge towards qsat
+        ! with update of temperature, ice fraction and qsat at 
+        ! each iteration
+
+        ! todoan -> sensitivity to iflag_fisrtilp_qsat
         DO iter=1,iflag_fisrtilp_qsat+1
-                
+
                 DO i=1,klon
 
-                    ! convergence = .true. until when convergence is not satisfied
-                    convergence(i)=ABS(DT(i)).GT.DDT0
-                   
-                    IF ((convergence(i) .OR. (n_i(i) .EQ. 0)) .AND. lognormale(i)) THEN
-                          
+                    ! keepgoing = .true. while convergence is not satisfied
+                    keepgoing(i)=ABS(DT(i)).GT.DDT0
+
+                    IF ((keepgoing(i) .OR. (n_i(i) .EQ. 0)) .AND. lognormale(i)) THEN
+
                         ! if not convergence:
 
@@ -776,26 +706,24 @@
                         !---------------------------------------------------------------
 
-                        ! new temperature:
+                        ! new temperature that only serves in the iteration process:
                         Tbef(i)=Tbef(i)+DT(i)
 
                         ! Rneb, qzn and zcond for lognormal PDFs
                         qtot(i)=zq(i)+zmqc(i)
-                    
+
                       ENDIF
 
                   ENDDO
 
-                  ! Calculation of saturation specific humidity and ce fraction
-                  CALL CALC_QSAT_ECMWF(klon,Tbef(:),qtot(:),pplay(:,k),RTT,0,.false.,zqs(:),zdqs(:))
-                  CALL CALC_GAMMASAT(klon,Tbef(:),qtot(:),pplay(:,k),gammasat(:),dgammasatdt(:))
+                  ! Calculation of saturation specific humidity and ice fraction
+                  CALL calc_qsat_ecmwf(klon,Tbef(:),qtot(:),pplay(:,k),RTT,0,.false.,zqs(:),zdqs(:))
+                  CALL calc_gammasat(klon,Tbef(:),qtot(:),pplay(:,k),gammasat(:),dgammasatdt(:))
                   ! saturation may occur at a humidity different from qsat (gamma qsat), so gamma correction for dqs
                   zdqs(:) = gammasat(:)*zdqs(:)+zqs(:)*dgammasatdt(:)
-                  CALL ICEFRAC_LSCP(klon, zt(:),pplay(:,k)/paprs(:,1),zfice(:),dzfice(:))
-
-
-
-                  DO i=1,klon
-
-                      IF ((convergence(i) .OR. (n_i(i) .EQ. 0)) .AND. lognormale(i)) THEN
+                  CALL icefrac_lscp(klon, zt(:),pplay(:,k)/paprs(:,1),zfice(:),dzfice(:))
+
+                  DO i=1,klon !todoan : check if loop in i is needed
+
+                      IF ((keepgoing(i) .OR. (n_i(i) .EQ. 0)) .AND. lognormale(i)) THEN
 
                         zpdf_sig(i)=ratqs(i,k)*zq(i)
@@ -810,6 +738,5 @@
                         zpdf_e2(i)=sign(min(ABS(zpdf_e2(i)),5.),zpdf_e2(i))
                         zpdf_e2(i)=1.-erf(zpdf_e2(i))
-             
-                        !--ice sursaturation by Audran
+
                         IF ((.NOT.ok_ice_sursat).OR.(Tbef(i).GT.t_glace_min)) THEN
 
@@ -826,7 +753,7 @@
                           fcontrP(i,k)=0.0  !--idem
                           qss(i,k)=0.0      !--idem
-                       
-                        ELSE
-               
+
+                       ELSE ! in case of ice supersaturation by Audran
+
                         !------------------------------------
                         ! ICE SUPERSATURATION
@@ -834,6 +761,6 @@
 
                         CALL ice_sursat(pplay(i,k), paprs(i,k)-paprs(i,k+1), dtime, i, k, t(i,k), zq(i), &
-                             gamma_ss(i,k), zqs(i), Tbef(i), rneb_seri(i,k), ratqs(i,k),               &  
-                             rneb(i,k), zqn(i), rnebss(i,k), qss(i,k),                                 & 
+                             gamma_ss(i,k), zqs(i), Tbef(i), rneb_seri(i,k), ratqs(i,k),                 &
+                             rneb(i,k), zqn(i), rnebss(i,k), qss(i,k),                                   & 
                              Tcontr(i,k), qcontr(i,k), qcontr2(i,k), fcontrN(i,k), fcontrP(i,k) )
 
@@ -862,18 +789,18 @@
                         qlbef(i)=max(0.,zqn(i)-zqs(i))
                         num = -Tbef(i)+zt(i)+rneb(i,k)*((1-zfice(i))*RLVTT &
-                        &   +zfice(i)*RLSTT)/RCPD/(1.0+RVTMP2*(zq(i)+zmqc(i)))*qlbef(i)
+                              +zfice(i)*RLSTT)/RCPD/(1.0+RVTMP2*(zq(i)+zmqc(i)))*qlbef(i)
                         denom = 1.+rneb(i,k)*((1-zfice(i))*RLVTT+zfice(i)*RLSTT)/cste*zdqs(i) &
                               -(RLSTT-RLVTT)/RCPD/(1.0+RVTMP2*(zq(i)+zmqc(i)))*rneb(i,k)      &
-                        &     *qlbef(i)*dzfice(i)
+                              *qlbef(i)*dzfice(i)
+                        ! here we update a provisory temperature variable that only serves in the iteration
+                        ! process
                         DT(i)=num/denom
                         n_i(i)=n_i(i)+1
 
-                    ENDIF ! end convergence
+                    ENDIF ! end keepgoing
 
                 ENDDO     ! end loop on i
 
         ENDDO         ! iter=1,iflag_fisrtilp_qsat+1
-
-
 
         ! P2.3> Final quantities calculation 
@@ -886,10 +813,8 @@
         ! ----------------------------------------------------------------
 
-
-
         ! Water vapor update, Phase determination and subsequent latent heat exchange
 
         ! Partition function in stratiform clouds (will be overwritten in boundary-layer MPCs)
-        CALL ICEFRAC_LSCP(klon,zt(:),pplay(:,k)/paprs(:,1),zfice(:), dzfice(:))
+        CALL icefrac_lscp(klon,zt(:),pplay(:,k)/paprs(:,1),zfice(:), dzfice(:))
 
         DO i=1, klon
@@ -923,9 +848,11 @@
                 ENDIF
 
-
                 ! water vapor update 
-                zq(i) = zq(i) - zcond(i)        
-            
+                zq(i) = zq(i) - zcond(i)
+
             ENDIF
+
+            ! c_iso : routine that computes in-cloud supersaturation
+            ! c_iso condensation of isotopes (zcond, zsursat, zfice, zq in input) 
 
             ! temperature update due to phase change
@@ -935,5 +862,4 @@
         ENDDO
 
-
         ! If vertical heterogeneity, change volume fraction 
         IF (iflag_cloudth_vert .GE. 3) THEN
@@ -945,5 +871,5 @@
     ! P3> Precipitation formation 
     ! ----------------------------------------------------------------
-    
+
     ! LTP:
     IF (iflag_evap_prec==4) THEN
@@ -955,6 +881,6 @@
         
         DO i=1, klon
-                tot_znebn(i) = 1 - (1-tot_zneb(i))*(1 - max(rneb(i,k),zneb(i))) &
-                        /(1-min(zneb(i),1-smallestreal))
+                tot_znebn(i) = 1. - (1.-tot_zneb(i))*(1 - max(rneb(i,k),zneb(i))) &
+                        /(1.-min(zneb(i),1.-smallestreal))
                 d_tot_zneb(i) = tot_znebn(i) - tot_zneb(i)
                 tot_zneb(i) = tot_znebn(i)
@@ -963,5 +889,5 @@
                 !1) Cloudy to clear air
                 d_znebprecip_cld_clr(i) = znebprecipcld(i) - min(rneb(i,k),znebprecipcld(i)) 
-                IF (znebprecipcld(i) .GT. 0) THEN
+                IF (znebprecipcld(i) .GT. 0.) THEN
                         d_zrfl_cld_clr(i) = d_znebprecip_cld_clr(i)/znebprecipcld(i)*zrflcld(i) 
                         d_zifl_cld_clr(i) = d_znebprecip_cld_clr(i)/znebprecipcld(i)*ziflcld(i) 
@@ -972,6 +898,5 @@
 
                 !2) Clear to cloudy air
-                d_znebprecip_clr_cld(i) = max(0., min(znebprecipclr(i), rneb(i,k) &
-                        - d_tot_zneb(i) - zneb(i)))
+                d_znebprecip_clr_cld(i) = max(0., min(znebprecipclr(i), rneb(i,k) - d_tot_zneb(i) - zneb(i)))
                 IF (znebprecipclr(i) .GT. 0) THEN
                         d_zrfl_clr_cld(i) = d_znebprecip_clr_cld(i)/znebprecipclr(i)*zrflclr(i) 
@@ -983,5 +908,5 @@
 
                 !Update variables
-                znebprecipcld(i) = znebprecipcld(i) + d_znebprecip_clr_cld(i) - d_znebprecip_cld_clr(i)  
+                znebprecipcld(i) = znebprecipcld(i) + d_znebprecip_clr_cld(i) - d_znebprecip_cld_clr(i)
                 znebprecipclr(i) = znebprecipclr(i) + d_znebprecip_cld_clr(i) - d_znebprecip_clr_cld(i) 
                 zrflcld(i) = zrflcld(i) + d_zrfl_clr_cld(i) - d_zrfl_cld_clr(i) 
@@ -990,8 +915,9 @@
                 ziflclr(i) = ziflclr(i) + d_zifl_cld_clr(i) - d_zifl_clr_cld(i)
 
+                ! c_iso  do the same thing for isotopes precip
         ENDDO
     ENDIF
 
-    ! Initialisation of zoliq and radliq variables
+    ! Initialisation of zoliq and radocond variables
 
     DO i = 1, klon
@@ -999,15 +925,15 @@
             zoliqi(i)= zoliq(i)*zfice(i)
             zoliql(i)= zoliq(i)*(1.-zfice(i))
+            ! c_iso : initialisation of zoliq* also for isotopes
             zrho(i,k)  = pplay(i,k) / zt(i) / RD
             zdz(i)   = (paprs(i,k)-paprs(i,k+1)) / (zrho(i,k)*RG)
             iwc(i)   = 0. 
             zneb(i)  = MAX(rneb(i,k),seuil_neb)
-            radliq(i,k) = zoliq(i)/REAL(ninter+1)
+            radocond(i,k) = zoliq(i)/REAL(ninter+1)
             radicefrac(i,k) = zfice(i)
-            radliqi(i,k)=zoliq(i)*zfice(i)/REAL(ninter+1)
-            radliql(i,k)=zoliq(i)*(1.-zfice(i))/REAL(ninter+1)
+            radocondi(i,k)=zoliq(i)*zfice(i)/REAL(ninter+1)
+            radocondl(i,k)=zoliq(i)*(1.-zfice(i))/REAL(ninter+1)
     ENDDO
 
-    ! -------------------------------------------------------------------------------
     ! Autoconversion
     ! -------------------------------------------------------------------------------
@@ -1021,5 +947,5 @@
         ENDDO
 
-        CALL FALLICE_VELOCITY(klon,iwc(:),zt(:),zrho(:,k),pplay(:,k),ptconv(:,k),velo(:,k))
+        CALL fallice_velocity(klon,iwc(:),zt(:),zrho(:,k),pplay(:,k),ptconv(:,k),velo(:,k))
 
         DO i = 1, klon
@@ -1031,4 +957,5 @@
                 zsnow=0.
                 zprecip=0.
+                ! c_iso same init for isotopes. Externalisation?
 
                 IF (zneb(i).EQ.seuil_neb) THEN
@@ -1037,4 +964,35 @@
                     zrain= 0.0
                 ELSE
+
+                    IF (ok_debug_autoconversion) THEN ! if condition to be removed after test phase
+
+                    ! water quantity to remove: zchau (Sundqvist, 1978)
+                    ! same thing for the ice: zfroi (Zender & Kiehl, 1997)
+                    IF (ptconv(i,k)) THEN ! if convective point
+                        zcl=cld_lc_con
+                        zct=1./cld_tau_con
+                        zfroi = dtime/REAL(ninter)/zdz(i)*zoliqi(i)*velo(i,k)
+                    ELSE
+                        zcl=cld_lc_lsc
+                        zct=1./cld_tau_lsc
+                        zfroi = dtime/REAL(ninter)/zdz(i)*zoliqi(i) &   ! dqice/dt=1/rho*d(rho*wice*qice)/dz
+                            *velo(i,k)
+                    ENDIF
+
+                    ! if vertical heterogeneity is taken into account, we use
+                    ! the "true" volume fraction instead of a modified 
+                    ! surface fraction (which is larger and artificially
+                    ! reduces the in-cloud water).
+
+                    IF ((iflag_cloudth_vert.GE.3).AND.(iflag_rain_incloud_vol.EQ.1)) THEN
+                        zchau = zct   *dtime/REAL(ninter) * zoliql(i) &
+                        *(1.0-EXP(-(zoliql(i)/ctot_vol(i,k)/zcl)**2))
+                    ELSE
+                        zchau = zct   *dtime/REAL(ninter) * zoliql(i) &
+                        *(1.0-EXP(-(zoliql(i)/zneb(i)/zcl)**2))        ! dqliq/dt=-qliq/tau*(1-exp(-qcin/clw)**2)
+                    ENDIF
+
+                    ELSE ! with old bug in autoconversion 
+
                     ! water quantity to remove: zchau (Sundqvist, 1978)
                     ! same thing for the ice: zfroi (Zender & Kiehl, 1997)
@@ -1055,4 +1013,5 @@
                     ! reduces the in-cloud water).
 
+
                     IF ((iflag_cloudth_vert.GE.3).AND.(iflag_rain_incloud_vol.EQ.1)) THEN
                         zchau = zct   *dtime/REAL(ninter) * zoliq(i) &
@@ -1063,18 +1022,22 @@
                     ENDIF
 
-                    zrain   = MIN(MAX(zchau,0.0),zoliq(i)*(1.-zfice(i)))
-                    zsnow   = MIN(MAX(zfroi,0.0),zoliq(i)*zfice(i)) 
+                    ENDIF ! ok_debug_autoconversion
+
+                    zrain   = MIN(MAX(zchau,0.0),zoliql(i))
+                    zsnow   = MIN(MAX(zfroi,0.0),zoliqi(i)) 
                     zprecip = MAX(zrain + zsnow,0.0)
 
                 ENDIF
-            
+
                 zoliql(i) = MAX(zoliq(i)*(1.-zfice(i))-1.*zrain  , 0.0)
                 zoliqi(i) = MAX(zoliq(i)*zfice(i)-1.*zsnow  , 0.0)
                 zoliq(i)  = MAX(zoliq(i)-zprecip , 0.0)
 
-                radliq(i,k) = radliq(i,k) + zoliq(i)/REAL(ninter+1)
-                radliql(i,k) = radliql(i,k) + zoliql(i)/REAL(ninter+1)
-                radliqi(i,k) = radliqi(i,k) + zoliqi(i)/REAL(ninter+1)
-           
+                ! c_iso: call isotope_conversion (for readibility) or duplicate 
+
+                radocond(i,k) = radocond(i,k) + zoliq(i)/REAL(ninter+1)
+                radocondl(i,k) = radocondl(i,k) + zoliql(i)/REAL(ninter+1)
+                radocondi(i,k) = radocondi(i,k) + zoliqi(i)/REAL(ninter+1)
+
             ENDIF ! rneb >0
 
@@ -1083,15 +1046,15 @@
     ENDDO      ! n = 1,niter
 
-    
-
     ! Precipitation flux calculation
 
     DO i = 1, klon
-
-
-            ziflprev(i)=zifl(i)
+            
+            IF (iflag_evap_prec.EQ.4) THEN
+                ziflprev(i)=ziflcld(i)
+            ELSE
+                ziflprev(i)=zifl(i)*zneb(i)
+            ENDIF
 
             IF (rneb(i,k) .GT. 0.0) THEN
-                
 
                ! CR&JYG: We account for the Wegener-Findeisen-Bergeron process in the precipitation flux:
@@ -1126,51 +1089,50 @@
                     ! iced water budget
                     zqpreci(i) = max (zqpreci(i) - Deltaqprecl - Deltaq, 0.)
-           
-                IF (iflag_evap_prec.EQ.4) THEN                                                            
-                    zrflcld(i) = zrflcld(i)+zqprecl(i) &                                                   
-                    *(paprs(i,k)-paprs(i,k+1))/(RG*dtime)                                                
-                    ziflcld(i) = ziflcld(i)+ zqpreci(i) &                                                  
-                        *(paprs(i,k)-paprs(i,k+1))/(RG*dtime)                                            
-                    znebprecipcld(i) = rneb(i,k)                                                          
-                    zrfl(i) = zrflcld(i) + zrflclr(i)                                                      
-                    zifl(i) = ziflcld(i) + ziflclr(i)                                                    
-                ELSE                                 
+
+                    ! c_iso : mv here condensation of isotopes + redispatchage en precip 
+
+                IF (iflag_evap_prec.EQ.4) THEN
+                    zrflcld(i) = zrflcld(i)+zqprecl(i) &
+                    *(paprs(i,k)-paprs(i,k+1))/(RG*dtime)
+                    ziflcld(i) = ziflcld(i)+ zqpreci(i) &
+                        *(paprs(i,k)-paprs(i,k+1))/(RG*dtime)
+                    znebprecipcld(i) = rneb(i,k)
+                    zrfl(i) = zrflcld(i) + zrflclr(i)
+                    zifl(i) = ziflcld(i) + ziflclr(i)
+                ELSE
                     zrfl(i) = zrfl(i)+ zqprecl(i)        &
                     *(paprs(i,k)-paprs(i,k+1))/(RG*dtime) 
                     zifl(i) = zifl(i)+ zqpreci(i)        &
-                   *(paprs(i,k)-paprs(i,k+1))/(RG*dtime)  
-                ENDIF
+                   *(paprs(i,k)-paprs(i,k+1))/(RG*dtime)
+                ENDIF
+                ! c_iso : same for isotopes
  
            ENDIF ! rneb>0
 
-
    ENDDO
 
-
-
-
-    ! LTP: limit of surface cloud fraction covered by precipitation when the local intensity of the flux is below rain_int_min                                                                              
+    ! LTP: limit of surface cloud fraction covered by precipitation when the local intensity of the flux is below rain_int_min
     ! if iflag_evap_pre=4
-    IF (iflag_evap_prec.EQ.4) THEN  
-
-        DO i=1,klon                                        
-                
-            IF ((zrflclr(i) + ziflclr(i)) .GT. 0. ) THEN     
+    IF (iflag_evap_prec.EQ.4) THEN
+
+        DO i=1,klon
+
+            IF ((zrflclr(i) + ziflclr(i)) .GT. 0. ) THEN
                 znebprecipclr(i) = min(znebprecipclr(i),max(zrflclr(i)/ &
                 (MAX(znebprecipclr(i),seuil_neb)*rain_int_min), ziflclr(i)/(MAX(znebprecipclr(i),seuil_neb)*rain_int_min)))
             ELSE
-                znebprecipclr(i)=0.                                                                   
-            ENDIF  
-                                                                                                         
-            IF ((zrflcld(i) + ziflcld(i)) .GT. 0.) THEN                                                  
+                znebprecipclr(i)=0.0
+            ENDIF
+
+            IF ((zrflcld(i) + ziflcld(i)) .GT. 0.) THEN
                 znebprecipcld(i) = min(znebprecipcld(i), max(zrflcld(i)/ &
                 (MAX(znebprecipcld(i),seuil_neb)*rain_int_min), ziflcld(i)/(MAX(znebprecipcld(i),seuil_neb)*rain_int_min)))
-            ELSE                                                                                     
-                znebprecipcld(i)=0.                                                                    
-            ENDIF     
-
-        ENDDO       
-
-    ENDIF  
+            ELSE
+                znebprecipcld(i)=0.0
+            ENDIF
+
+        ENDDO
+
+    ENDIF
 
     ! End of precipitation formation
@@ -1186,16 +1148,16 @@
         d_qi(i,k) = zfice(i)*zoliq(i)
         d_q(i,k) = zq(i) - q(i,k)
+        ! c_iso: same for isotopes
         d_t(i,k) = zt(i) - t(i,k)
     ENDDO
 
     ! Calculation of the concentration of condensates seen by the radiation scheme
-    ! for liquid phase, we take radliql
-    ! for ice phase, we take radliqi if we neglect snowfall, otherwise (ok_radliq_snow=true) 
-    ! we recaulate radliqi to account for contributions from the precipitation flux
-
-
-    IF ((ok_radliq_snow) .AND. (k .LT. klev)) THEN
+    ! for liquid phase, we take radocondl
+    ! for ice phase, we take radocondi if we neglect snowfall, otherwise (ok_radocond_snow=true) 
+    ! we recaulate radocondi to account for contributions from the precipitation flux
+
+    IF ((ok_radocond_snow) .AND. (k .LT. klev)) THEN
         ! for the solid phase (crystals + snowflakes)
-        ! we recalculate radliqi by summing
+        ! we recalculate radocondi by summing
         ! the ice content calculated in the mesh
         ! + the contribution of the non-evaporated snowfall 
@@ -1203,25 +1165,22 @@
         DO i=1,klon
            IF (ziflprev(i) .NE. 0.0) THEN
-              radliqi(i,k)=zoliq(i)*zfice(i)+zqpreci(i)+ziflprev(i)/zrho(i,k+1)/velo(i,k+1)
+              radocondi(i,k)=zoliq(i)*zfice(i)+zqpreci(i)+ziflprev(i)/zrho(i,k+1)/velo(i,k+1)
            ELSE
-              radliqi(i,k)=zoliq(i)*zfice(i)+zqpreci(i)  
+              radocondi(i,k)=zoliq(i)*zfice(i)+zqpreci(i)
            ENDIF
-           radliq(i,k)=radliql(i,k)+radliqi(i,k)
+           radocond(i,k)=radocondl(i,k)+radocondi(i,k)
         ENDDO
     ENDIF
 
-    ! caculate the percentage of ice in "radliq" so cloud+precip seen by the radiation scheme
+    ! caculate the percentage of ice in "radocond" so cloud+precip seen by the radiation scheme
     DO i=1,klon
-        IF (radliq(i,k) .GT. 0.) THEN
-            radicefrac(i,k)=MIN(MAX(radliqi(i,k)/radliq(i,k),0.),1.)
+        IF (radocond(i,k) .GT. 0.) THEN
+            radicefrac(i,k)=MIN(MAX(radocondi(i,k)/radocond(i,k),0.),1.)
         ENDIF
     ENDDO
-
-
 
     ! ----------------------------------------------------------------
     ! P4> Wet scavenging
     ! ----------------------------------------------------------------
-
 
     !Scavenging through nucleation in the layer
@@ -1246,16 +1205,13 @@
 
             zfrac_lessi = 1. - EXP(zalpha_tr*zprec_cond(i)/zneb(i))
-            pfrac_nucl(i,k)=pfrac_nucl(i,k)*(1.-zneb(i)*zfrac_lessi)
             frac_nucl(i,k)= 1.-zneb(i)*zfrac_lessi 
-    
+
             ! Nucleation with a factor of -1 instead of -0.5
             zfrac_lessi = 1. - EXP(-zprec_cond(i)/zneb(i))
-            pfrac_1nucl(i,k)=pfrac_1nucl(i,k)*(1.-zneb(i)*zfrac_lessi)
 
         ENDIF
-        
-    ENDDO      
-
-     
+
+    ENDDO
+
     ! Scavenging through impaction in the underlying layer
 
@@ -1273,5 +1229,4 @@
 
               zfrac_lessi = 1. - EXP(zalpha_tr*zprec_cond(i)/zneb(i))
-              pfrac_impa(i,kk)=pfrac_impa(i,kk)*(1.-zneb(i)*zfrac_lessi)
               frac_impa(i,kk)= 1.-zneb(i)*zfrac_lessi
 
@@ -1281,5 +1236,5 @@
 
     ENDDO
-     
+
     !--save some variables for ice supersaturation
     !
@@ -1294,10 +1249,10 @@
         qclr(i,k) = MAX(1.e-10,zq(i) - qvc(i,k) - qss(i,k))  !--added by OB because of pathologic cases with the lognormal
         qcld(i,k) = qvc(i,k) + zcond(i)
-   END DO
+   ENDDO
    !q_sat
-   CALL CALC_QSAT_ECMWF(klon,Tbef(:),qzero(:),pplay(:,k),RTT,1,.false.,zqsatl(:,k),zdqs(:))
-   CALL CALC_QSAT_ECMWF(klon,Tbef(:),qzero(:),pplay(:,k),RTT,2,.false.,zqsats(:,k),zdqs(:))     
-
-END DO
+   CALL calc_qsat_ecmwf(klon,Tbef(:),qzero(:),pplay(:,k),RTT,1,.false.,qsatl(:,k),zdqs(:))
+   CALL calc_qsat_ecmwf(klon,Tbef(:),qzero(:),pplay(:,k),RTT,2,.false.,qsats(:,k),zdqs(:))
+
+ENDDO
 
 !======================================================================
@@ -1309,4 +1264,5 @@
       snow(i) = zifl(i)
       rain(i) = zrfl(i)
+      ! c_iso final output
   ENDDO
 
@@ -1315,6 +1271,6 @@
   ENDIF
 
-END SUBROUTINE LSCP
+END SUBROUTINE lscp
 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
-END MODULE LSCP_MOD
+END MODULE lscp_mod
Index: LMDZ6/branches/Portage_acc/libf/phylmd/mo_simple_plumes.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/mo_simple_plumes.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/mo_simple_plumes.F90	(revision 4446)
@@ -38,5 +38,5 @@
 !$OMP THREADPRIVATE(sp_initialized)
 
-  REAL ::                                      &
+  REAL, SAVE ::                                &
        plume_lat      (nplumes)               ,& !< latitude of plume center (AOD maximum)
        plume_lon      (nplumes)               ,& !< longitude of plume center (AOD maximum)
@@ -54,6 +54,4 @@
        theta          (nfeatures,nplumes)     ,& !< Rotation angle of plume feature
        ftr_weight     (nfeatures,nplumes)     ,& !< Feature weights 
-       time_weight    (nfeatures,nplumes)     ,& !< Time weights 
-       time_weight_bg (nfeatures,nplumes)     ,& !< as time_weight but for natural background in Twomey effect 
        year_weight    (nyears,nplumes)        ,& !< Yearly weight for plume
        ann_cycle      (nfeatures,ntimes,nplumes) !< annual cycle for plume feature
@@ -61,4 +59,8 @@
 !$OMP THREADPRIVATE(sig_lon_E,sig_lon_W,sig_lat_E,sig_lat_W,theta,ftr_weight,year_weight,ann_cycle)
 
+  REAL ::                                      &
+       time_weight    (nfeatures,nplumes)     ,& !< Time weights 
+       time_weight_bg (nfeatures,nplumes)        !< as time_weight but for natural background in Twomey effect 
+
   PUBLIC sp_aop_profile
 
@@ -80,5 +82,4 @@
     CHARACTER (len = 50)     :: modname = 'mo_simple_plumes.sp_setup'
     CHARACTER (len = 80)     :: abort_message
-
     !
     ! ---------- 
@@ -130,4 +131,5 @@
           CALL abort_physic(modname,abort_message,1)
        ENDIF
+       !
        iret = nf90_inq_varid(ncid, "plume_lon", VarId)
        iret = nf90_get_var(ncid, VarID, plume_lon(:), start=(/1/),count=(/nplumes/))
@@ -136,4 +138,5 @@
           CALL abort_physic(modname,abort_message,1)
        ENDIF
+       !
        iret = nf90_inq_varid(ncid, "beta_a"   , VarId)
        iret = nf90_get_var(ncid, VarID, beta_a(:)   , start=(/1/),count=(/nplumes/))
@@ -142,4 +145,5 @@
           CALL abort_physic(modname,abort_message,1)
        ENDIF
+       !
        iret = nf90_inq_varid(ncid, "beta_b"   , VarId)
        iret = nf90_get_var(ncid, VarID, beta_b(:)   , start=(/1/),count=(/nplumes/))
@@ -148,4 +152,5 @@
           CALL abort_physic(modname,abort_message,1)
        ENDIF
+       !
        iret = nf90_inq_varid(ncid, "aod_spmx" , VarId)
        iret = nf90_get_var(ncid, VarID, aod_spmx(:)  , start=(/1/),count=(/nplumes/))
@@ -154,4 +159,5 @@
           CALL abort_physic(modname,abort_message,1)
        ENDIF
+       !
        iret = nf90_inq_varid(ncid, "aod_fmbg" , VarId)
        iret = nf90_get_var(ncid, VarID, aod_fmbg(:)  , start=(/1/),count=(/nplumes/))
@@ -160,4 +166,5 @@
           CALL abort_physic(modname,abort_message,1)
        ENDIF
+       !
        iret = nf90_inq_varid(ncid, "ssa550"   , VarId)
        iret = nf90_get_var(ncid, VarID, ssa550(:)  , start=(/1/),count=(/nplumes/))
@@ -166,4 +173,5 @@
           CALL abort_physic(modname,abort_message,1)
        ENDIF
+       !
        iret = nf90_inq_varid(ncid, "asy550"   , VarId)
        iret = nf90_get_var(ncid, VarID, asy550(:)  , start=(/1/),count=(/nplumes/))
@@ -172,4 +180,5 @@
           CALL abort_physic(modname,abort_message,1)
        ENDIF
+       !
        iret = nf90_inq_varid(ncid, "angstrom" , VarId)
        iret = nf90_get_var(ncid, VarID, angstrom(:), start=(/1/),count=(/nplumes/))
@@ -185,4 +194,5 @@
           CALL abort_physic(modname,abort_message,1)
        ENDIF
+       !
        iret = nf90_inq_varid(ncid, "sig_lat_E"     , VarId)
        iret = nf90_get_var(ncid, VarID, sig_lat_E(:,:)    , start=(/1,1/),count=(/nfeatures,nplumes/))
@@ -191,4 +201,5 @@
           CALL abort_physic(modname,abort_message,1)
        ENDIF
+       !
        iret = nf90_inq_varid(ncid, "sig_lon_E"     , VarId)
        iret = nf90_get_var(ncid, VarID, sig_lon_E(:,:)    , start=(/1,1/),count=(/nfeatures,nplumes/))
@@ -197,4 +208,5 @@
           CALL abort_physic(modname,abort_message,1)
        ENDIF
+       !
        iret = nf90_inq_varid(ncid, "sig_lon_W"     , VarId)
        iret = nf90_get_var(ncid, VarID, sig_lon_W(:,:)    , start=(/1,1/),count=(/nfeatures,nplumes/))
@@ -203,4 +215,5 @@
           CALL abort_physic(modname,abort_message,1)
        ENDIF
+       !
        iret = nf90_inq_varid(ncid, "theta"         , VarId)
        iret = nf90_get_var(ncid, VarID, theta(:,:)        , start=(/1,1/),count=(/nfeatures,nplumes/))
@@ -209,4 +222,5 @@
           CALL abort_physic(modname,abort_message,1)
        ENDIF
+       !
        iret = nf90_inq_varid(ncid, "ftr_weight"    , VarId)
        iret = nf90_get_var(ncid, VarID, ftr_weight(:,:)   , start=(/1,1/),count=(/nfeatures,nplumes/))
@@ -215,4 +229,5 @@
           CALL abort_physic(modname,abort_message,1)
        ENDIF
+       !
        iret = nf90_inq_varid(ncid, "year_weight"   , VarId)
        iret = nf90_get_var(ncid, VarID, year_weight(:,:)  , start=(/1,1/),count=(/nyears,nplumes   /))
@@ -221,4 +236,5 @@
           CALL abort_physic(modname,abort_message,1)
        ENDIF
+       !
        iret = nf90_inq_varid(ncid, "ann_cycle"     , VarId)
        iret = nf90_get_var(ncid, VarID, ann_cycle(:,:,:)  , start=(/1,1,1/),count=(/nfeatures,ntimes,nplumes/))
@@ -288,5 +304,5 @@
       time_weight_bg(1,iplume) = ann_cycle(1,iweek,iplume)
       time_weight_bg(2,iplume) = ann_cycle(2,iweek,iplume) 
-    END DO
+    ENDDO
     
     RETURN
@@ -375,11 +391,11 @@
         z_beta(icol,k)   = MERGE(1.0, 0.0, z(icol,k) >= oro(icol))
         eta(icol,k)      = MAX(0.0,MIN(1.0,z(icol,k)/15000.))
-      END DO
-    END DO
+      ENDDO
+    ENDDO
     DO icol=1,ncol
       dNovrN(icol)   = 1.0
       caod_sp(icol)  = 0.0
       caod_bg(icol)  = 0.02
-    END DO
+    ENDDO
     !
     ! sum contribution from plumes to construct composite profiles of aerosol optical properties
@@ -391,16 +407,16 @@
       DO icol=1,ncol
         beta_sum(icol) = 0.
-      END DO
+      ENDDO
       DO k=1,nlevels
         DO icol=1,ncol
           prof(icol,k)   = (eta(icol,k)**(beta_a(iplume)-1.) * (1.-eta(icol,k))**(beta_b(iplume)-1.)) * dz(icol,k)
           beta_sum(icol) = beta_sum(icol) + prof(icol,k)
-        END DO
-      END DO
+        ENDDO
+      ENDDO
       DO k=1,nlevels
         DO icol=1,ncol
           prof(icol,k)   = ( prof(icol,k) / beta_sum(icol) ) * z_beta(icol,k)
-        END DO
-      END DO
+        ENDDO
+      ENDDO
       !
       ! calculate plume weights
@@ -443,5 +459,5 @@
         ssa(icol) = (ssa550(iplume) * lfactor**4) / ((ssa550(iplume) * lfactor**4) + ((1-ssa550(iplume)) * lfactor))
         asy(icol) =  asy550(iplume) * SQRT(lfactor)
-      END DO
+      ENDDO
       !
       ! distribute plume optical properties across its vertical profile weighting by optical depth and scaling for
@@ -458,7 +474,7 @@
           ssa_prof(icol,k) = ssa_prof(icol,k) + aod_lmd * ssa(icol)
           aod_prof(icol,k) = aod_prof(icol,k) + aod_lmd
-        END DO
-      END DO
-    END DO
+        ENDDO
+      ENDDO
+    ENDDO
     !
     ! complete optical depth weighting
@@ -468,6 +484,6 @@
         asy_prof(icol,k) = MERGE(asy_prof(icol,k)/ssa_prof(icol,k), 0.0, ssa_prof(icol,k) > TINY(1.))
         ssa_prof(icol,k) = MERGE(ssa_prof(icol,k)/aod_prof(icol,k), 1.0, aod_prof(icol,k) > TINY(1.))
-      END DO
-    END DO
+      ENDDO
+    ENDDO
     !
     ! calculate effective radius normalization (divisor) factor
@@ -475,5 +491,5 @@
     DO icol=1,ncol
       dNovrN(icol) = LOG((1000.0 * (caod_sp(icol) + caod_bg(icol))) + 1.0)/LOG((1000.0 * caod_bg(icol)) + 1.0)
-    END DO
+    ENDDO
 
     RETURN
Index: LMDZ6/branches/Portage_acc/libf/phylmd/nuage.h
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/nuage.h	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/nuage.h	(revision 4446)
@@ -12,6 +12,6 @@
       INTEGER iflag_rain_incloud_vol
    
-      INTEGER iflag_mpc_bl, iflag_gammasat, iflag_vice, iflag_rei
-      LOGICAL ok_icefra_lscp, ok_radliq_snow
+      INTEGER iflag_gammasat, iflag_vice, iflag_rei
+      LOGICAL ok_icefra_lscp
 
       common /nuagecom/ rad_froid,rad_chau1, rad_chau2,t_glace_max,     &
@@ -21,6 +21,6 @@
      &                  iflag_t_glace,iflag_cloudth_vert,iflag_cld_cv,  &
      &                  iflag_rain_incloud_vol,                         &
-     &                  ok_icefra_lscp,ok_radliq_snow,                  &
-     &                  iflag_mpc_bl, iflag_gammasat, iflag_vice,       &
+     &                  ok_icefra_lscp,                  &
+     &                  iflag_gammasat, iflag_vice,       &
      &                  iflag_rei    
 !$OMP THREADPRIVATE(/nuagecom/)
Index: LMDZ6/branches/Portage_acc/libf/phylmd/oasis.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/oasis.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/oasis.F90	(revision 4446)
@@ -24,4 +24,7 @@
   USE mod_prism_get_proto
   USE mod_prism_put_proto
+#endif
+#ifdef CPP_CPLOCNINCA
+  USE incaoasis, ONLY : inforcv
 #endif
 #endif
@@ -59,7 +62,8 @@
   INTEGER, PARAMETER :: ids_qraiic = 28
   INTEGER, PARAMETER :: ids_qsnoic = 29
-  INTEGER, PARAMETER :: ids_delta_sst = 30, ids_delta_sal = 31
-  
-  INTEGER, PARAMETER :: maxsend    = 31  ! Maximum number of fields to send
+  INTEGER, PARAMETER :: ids_delta_sst = 30, ids_delta_sal = 31, ids_dter = 32, &
+       ids_dser = 33, ids_dt_ds = 34
+  
+  INTEGER, PARAMETER :: maxsend    = 34  ! Maximum number of fields to send
   
   ! Id for fields received from ocean
@@ -79,4 +83,8 @@
   INTEGER, PARAMETER :: maxrecv    = 9  ! Maximum number of fields to receive
   
+#ifdef CPP_CPLOCNINCA
+  INTEGER, PARAMETER :: idr_ocedms = 1
+  INTEGER, PARAMETER :: maxrcv = 1
+#endif
 
   TYPE, PUBLIC ::   FLD_CPL            ! Type for coupling field information
@@ -194,4 +202,10 @@
        infosend(ids_delta_sal)%action = .TRUE.
        infosend(ids_delta_sal)%name = 'CODELSSS'
+       infosend(ids_dter)%action = .TRUE.
+       infosend(ids_dter)%name = 'CODELTER'
+       infosend(ids_dser)%action = .TRUE.
+       infosend(ids_dser)%name = 'CODELSER'
+       infosend(ids_dt_ds)%action = .TRUE.
+       infosend(ids_dt_ds)%name = 'CODTDS'
     end if
            
@@ -247,4 +261,7 @@
        inforecv(idr_oceco2)%action = .TRUE. ; inforecv(idr_oceco2)%name = 'SICO2FLX'
    ENDIF
+#ifdef CPP_CPLOCNINCA
+       inforcv(idr_ocedms)%action = .TRUE. ; inforcv(idr_ocedms)%name = 'SIDMSFLX'
+#endif
 
 !************************************************************************************
@@ -331,5 +348,22 @@
        ENDIF
     END DO
-    
+
+! Now, if also coupling CPL with INCA, initialize here fields to be exchanged.
+#ifdef CPP_CPLOCNINCA
+    DO jf=1,maxrcv 
+       IF (inforcv(jf)%action) THEN
+          CALL prism_def_var_proto(inforcv(jf)%nid, inforcv(jf)%name, il_part_id, &
+               il_var_nodims, PRISM_In, il_var_actual_shape, il_var_type, &
+               ierror)
+          IF (ierror .NE. PRISM_Ok) THEN
+             WRITE(lunout,*) 'inicma : Problem with prism_def_var_proto for field : ',&
+                  inforcv(jf)%name
+             abort_message=' Problem in call to prism_def_var_proto for fields to receive'
+             CALL abort_physic(modname,abort_message,1)
+          ENDIF
+       ENDIF
+    END DO
+#endif
+ 
 !************************************************************************************
 ! Atmospheric Fields to send
Index: LMDZ6/branches/Portage_acc/libf/phylmd/ocean_cpl_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/ocean_cpl_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/ocean_cpl_mod.F90	(revision 4446)
@@ -56,5 +56,5 @@
        qsurf, evap, fluxsens, fluxlat, flux_u1, flux_v1, &
        tsurf_new, dflux_s, dflux_l, sens_prec_liq, sss, delta_sal, rhoa, &
-       delta_sst)
+       delta_sst, dTer, dSer, dt_ds)
 
 !
@@ -103,4 +103,16 @@
     ! only if activate_ocean_skin >= 1.
 
+    REAL, intent(in):: dter(:) ! (knon)
+    ! Temperature variation in the diffusive microlayer, that is
+    ! ocean-air interface temperature minus subskin temperature. In
+    ! K.
+
+    REAL, intent(in):: dser(:) ! (knon)
+    ! Salinity variation in the diffusive microlayer, that is
+    ! ocean-air interface salinity minus subskin salinity. In ppt.
+
+    real, intent(in):: dt_ds(:) ! (knon)
+    ! (tks / tkt) * dTer, in K
+
 ! In/Output arguments
 !****************************************************************************************
@@ -219,5 +231,5 @@
          fluxsens, precip_rain, precip_snow, evap, tsurf_new, fder_new, alb1, &
          flux_u1, flux_v1, windsp, sens_prec_liq, sens_prec_sol, lat_prec_liq, &
-         lat_prec_sol, delta_sst, delta_sal)
+         lat_prec_sol, delta_sst, delta_sal, dTer, dSer, dt_ds)
 
   END SUBROUTINE ocean_cpl_noice
Index: LMDZ6/branches/Portage_acc/libf/phylmd/pbl_surface_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/pbl_surface_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/pbl_surface_mod.F90	(revision 4446)
@@ -14,5 +14,5 @@
   USE mod_grid_phy_lmdz,   ONLY : klon_glo
   USE ioipsl
-  USE surface_data,        ONLY : type_ocean, ok_veget
+  USE surface_data,        ONLY : type_ocean, ok_veget, landice_opt
   USE surf_land_mod,       ONLY : surf_land
   USE surf_landice_mod,    ONLY : surf_landice
@@ -313,6 +313,7 @@
     USE print_control_mod,  ONLY : prt_level,lunout
     USE ioipsl_getin_p_mod, ONLY : getin_p
-    use phys_state_var_mod, only: ds_ns, dt_ns, delta_sst, delta_sal, zsig, zmea
-    use phys_output_var_mod, only: dter, dser, tkt, tks, taur, sss
+    use phys_state_var_mod, only: ds_ns, dt_ns, delta_sst, delta_sal, dter, &
+         dser, dt_ds, zsig, zmea
+    use phys_output_var_mod, only: tkt, tks, taur, sss
 #ifdef CPP_XIOS
     USE wxios, ONLY: missing_val
@@ -875,8 +876,8 @@
     ! Martin
 
-    REAL, DIMENSION(klon):: ydelta_sst, ydelta_sal, yds_ns, ydt_ns, ydter, ydser, &
-         ytkt, ytks, ytaur, ysss
-    ! compression of delta_sst, delta_sal, ds_ns, dt_ns, dter, dser, tkt, tks,
-    ! taur, sss on ocean points
+    REAL, DIMENSION(klon):: ydelta_sst, ydelta_sal, yds_ns, ydt_ns, ydter, &
+         ydser, ydt_ds, ytkt, ytks, ytaur, ysss
+    ! compression of delta_sst, delta_sal, ds_ns, dt_ns, dter, dser,
+    ! dt_ds, tkt, tks, taur, sss on ocean points
 
 !****************************************************************************************
@@ -1533,4 +1534,7 @@
              ydelta_sal(:knon) = delta_sal(ni(:knon))
              ydelta_sst(:knon) = delta_sst(ni(:knon))
+             ydter(:knon) = dter(ni(:knon))
+             ydser(:knon) = dser(ni(:knon))
+             ydt_ds(:knon) = dt_ds(ni(:knon))
           end if
           
@@ -2056,41 +2060,46 @@
        CASE(is_lic)
           ! Martin
-          CALL surf_landice(itap, dtime, knon, ni, &
-               rlon, rlat, debut, lafin, &
-               yrmu0, ylwdown, yalb, zgeo1, &
-               ysolsw, ysollw, yts, ypplay(:,1), &
-!!jyg               ycdragh, ycdragm, yrain_f, ysnow_f, yt(:,1), yq(:,1),&
-               ycdragh, ycdragm, yrain_f, ysnow_f, yt1, yq1,&
-               AcoefH, AcoefQ, BcoefH, BcoefQ, &
-               AcoefU, AcoefV, BcoefU, BcoefV, &
-               ypsref, yu1, yv1, ygustiness, yrugoro, pctsrf, &
-               ysnow, yqsurf, yqsol, yagesno, &
-               ytsoil, yz0m, yz0h, SFRWL, yalb_dir_new, yalb_dif_new, yevap,yfluxsens,yfluxlat, &
-               ytsurf_new, y_dflux_t, y_dflux_q, &
-               yzmea, yzsig, ycldt, &
-               ysnowhgt, yqsnow, ytoice, ysissnow, &
-               yalb3_new, yrunoff, &
-               y_flux_u1, y_flux_v1)
-
-!jyg<
-!!          alb3_lic(:)=0.
-!>jyg
-          DO j = 1, knon
-             i = ni(j)
-             alb3_lic(i) = yalb3_new(j)
-             snowhgt(i)   = ysnowhgt(j)
-             qsnow(i)     = yqsnow(j)
-             to_ice(i)    = ytoice(j)
-             sissnow(i)   = ysissnow(j)
-             runoff(i)    = yrunoff(j)
-          ENDDO
-          ! Martin
-! Special DICE MPL 05082013 puis BOMEX MPL 20150410
-       IF (ok_prescr_ust) THEN
-          DO j=1,knon
-          y_flux_u1(j)=ycdragm(j)*(1.+sqrt(yu(j,1)*yu(j,1)+yv(j,1)*yv(j,1)))*yu(j,1)*ypplay(j,1)/RD/yt(j,1)
-          y_flux_v1(j)=ycdragm(j)*(1.+sqrt(yu(j,1)*yu(j,1)+yv(j,1)*yv(j,1)))*yv(j,1)*ypplay(j,1)/RD/yt(j,1)
-          ENDDO
-      ENDIF
+
+          IF (landice_opt .LT. 2) THEN
+             ! Land ice is treated by LMDZ and not by ORCHIDEE
+             CALL surf_landice(itap, dtime, knon, ni, &
+                  rlon, rlat, debut, lafin, &
+                  yrmu0, ylwdown, yalb, zgeo1, &
+                  ysolsw, ysollw, yts, ypplay(:,1), &
+                  !!jyg               ycdragh, ycdragm, yrain_f, ysnow_f, yt(:,1), yq(:,1),&
+                  ycdragh, ycdragm, yrain_f, ysnow_f, yt1, yq1,&
+                  AcoefH, AcoefQ, BcoefH, BcoefQ, &
+                  AcoefU, AcoefV, BcoefU, BcoefV, &
+                  ypsref, yu1, yv1, ygustiness, yrugoro, pctsrf, &
+                  ysnow, yqsurf, yqsol, yagesno, &
+                  ytsoil, yz0m, yz0h, SFRWL, yalb_dir_new, yalb_dif_new, yevap,yfluxsens,yfluxlat, &
+                  ytsurf_new, y_dflux_t, y_dflux_q, &
+                  yzmea, yzsig, ycldt, &
+                  ysnowhgt, yqsnow, ytoice, ysissnow, &
+                  yalb3_new, yrunoff, &
+                  y_flux_u1, y_flux_v1)
+             
+             !jyg<
+             !!          alb3_lic(:)=0.
+             !>jyg
+             DO j = 1, knon
+                i = ni(j)
+                alb3_lic(i) = yalb3_new(j)
+                snowhgt(i)   = ysnowhgt(j)
+                qsnow(i)     = yqsnow(j)
+                to_ice(i)    = ytoice(j)
+                sissnow(i)   = ysissnow(j)
+                runoff(i)    = yrunoff(j)
+             ENDDO
+             ! Martin
+             ! Special DICE MPL 05082013 puis BOMEX MPL 20150410
+             IF (ok_prescr_ust) THEN
+                DO j=1,knon
+                   y_flux_u1(j)=ycdragm(j)*(1.+sqrt(yu(j,1)*yu(j,1)+yv(j,1)*yv(j,1)))*yu(j,1)*ypplay(j,1)/RD/yt(j,1)
+                   y_flux_v1(j)=ycdragm(j)*(1.+sqrt(yu(j,1)*yu(j,1)+yv(j,1)*yv(j,1)))*yv(j,1)*ypplay(j,1)/RD/yt(j,1)
+                ENDDO
+             ENDIF
+             
+          END IF
           
        CASE(is_oce)
@@ -2108,5 +2117,5 @@
                y_flux_u1, y_flux_v1, ydelta_sst(:knon), ydelta_sal(:knon), &
                yds_ns(:knon), ydt_ns(:knon), ydter(:knon), ydser(:knon), &
-               ytkt(:knon), ytks(:knon), ytaur(:knon), ysss)
+               ydt_ds(:knon), ytkt(:knon), ytks(:knon), ytaur(:knon), ysss)
       IF (prt_level >=10) THEN
           print *,'arg de surf_ocean: ycdragh ',ycdragh
@@ -2855,4 +2864,9 @@
           taur(ni(:knon)) = ytaur(:knon)
           sss(ni(:knon)) = ysss(:knon)
+
+          if (activate_ocean_skin == 2 .and. type_ocean == "couple") then
+             dt_ds = missing_val
+             dt_ds(ni(:knon)) = ydt_ds(:knon)
+          end if
        end if
 
@@ -3522,5 +3536,6 @@
 
     USE indice_sol_mod
-    use phys_state_var_mod, only: delta_sal, ds_ns, dt_ns, delta_sst
+    use phys_state_var_mod, only: delta_sal, ds_ns, dt_ns, delta_sst, dter, &
+         dser, dt_ds
     use config_ocean_skin_m, only: activate_ocean_skin
 
@@ -3615,4 +3630,7 @@
                          delta_sal(i) = 0.
                          delta_sst(i) = 0.
+                         dter(i) = 0.
+                         dser(i) = 0.
+                         dt_ds(i) = 0.
                       end if
                       
Index: LMDZ6/branches/Portage_acc/libf/phylmd/phyaqua_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/phyaqua_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/phyaqua_mod.F90	(revision 4446)
@@ -573,4 +573,5 @@
     USE mod_phys_lmdz_transfert_para, ONLY: gather
     USE phys_cal_mod, ONLY: year_len
+    use netcdf, only: nf90_def_var, nf90_double, nf90_float
     IMPLICIT NONE
     include "netcdf.inc"
@@ -617,14 +618,14 @@
 
 #ifdef NC_DOUBLE
-      ierr = nf_def_var(nid, 'TEMPS', nf_double, 1, ntim, id_tim)
-#else
-      ierr = nf_def_var(nid, 'TEMPS', nf_float, 1, ntim, id_tim)
+      ierr = nf90_def_var(nid, 'TEMPS', nf90_double, [ntim], id_tim)
+#else
+      ierr = nf90_def_var(nid, 'TEMPS', nf90_float, [ntim], id_tim)
 #endif
       ierr = nf_put_att_text(nid, id_tim, 'title', 17, 'Jour dans l annee')
 
 #ifdef NC_DOUBLE
-      ierr = nf_def_var(nid, 'NAT', nf_double, 2, dims, id_nat)
-#else
-      ierr = nf_def_var(nid, 'NAT', nf_float, 2, dims, id_nat)
+      ierr = nf90_def_var(nid, 'NAT', nf90_double, dims, id_nat)
+#else
+      ierr = nf90_def_var(nid, 'NAT', nf90_float, dims, id_nat)
 #endif
       ierr = nf_put_att_text(nid, id_nat, 'title', 23, &
@@ -632,7 +633,7 @@
 
 #ifdef NC_DOUBLE
-      ierr = nf_def_var(nid, 'SST', nf_double, 2, dims, id_sst)
-#else
-      ierr = nf_def_var(nid, 'SST', nf_float, 2, dims, id_sst)
+      ierr = nf90_def_var(nid, 'SST', nf90_double, dims, id_sst)
+#else
+      ierr = nf90_def_var(nid, 'SST', nf90_float, dims, id_sst)
 #endif
       ierr = nf_put_att_text(nid, id_sst, 'title', 35, &
@@ -640,7 +641,7 @@
 
 #ifdef NC_DOUBLE
-      ierr = nf_def_var(nid, 'BILS', nf_double, 2, dims, id_bils)
-#else
-      ierr = nf_def_var(nid, 'BILS', nf_float, 2, dims, id_bils)
+      ierr = nf90_def_var(nid, 'BILS', nf90_double, dims, id_bils)
+#else
+      ierr = nf90_def_var(nid, 'BILS', nf90_float, dims, id_bils)
 #endif
       ierr = nf_put_att_text(nid, id_bils, 'title', 32, &
@@ -648,39 +649,39 @@
 
 #ifdef NC_DOUBLE
-      ierr = nf_def_var(nid, 'ALB', nf_double, 2, dims, id_alb)
-#else
-      ierr = nf_def_var(nid, 'ALB', nf_float, 2, dims, id_alb)
+      ierr = nf90_def_var(nid, 'ALB', nf90_double, dims, id_alb)
+#else
+      ierr = nf90_def_var(nid, 'ALB', nf90_float, dims, id_alb)
 #endif
       ierr = nf_put_att_text(nid, id_alb, 'title', 19, 'Albedo a la surface')
 
 #ifdef NC_DOUBLE
-      ierr = nf_def_var(nid, 'RUG', nf_double, 2, dims, id_rug)
-#else
-      ierr = nf_def_var(nid, 'RUG', nf_float, 2, dims, id_rug)
+      ierr = nf90_def_var(nid, 'RUG', nf90_double, dims, id_rug)
+#else
+      ierr = nf90_def_var(nid, 'RUG', nf90_float, dims, id_rug)
 #endif
       ierr = nf_put_att_text(nid, id_rug, 'title', 8, 'Rugosite')
 
 #ifdef NC_DOUBLE
-      ierr = nf_def_var(nid, 'FTER', nf_double, 2, dims, id_fter)
-#else
-      ierr = nf_def_var(nid, 'FTER', nf_float, 2, dims, id_fter)
+      ierr = nf90_def_var(nid, 'FTER', nf90_double, dims, id_fter)
+#else
+      ierr = nf90_def_var(nid, 'FTER', nf90_float, dims, id_fter)
 #endif
       ierr = nf_put_att_text(nid, id_fter, 'title',10,'Frac. Land')
 #ifdef NC_DOUBLE
-      ierr = nf_def_var(nid, 'FOCE', nf_double, 2, dims, id_foce)
-#else
-      ierr = nf_def_var(nid, 'FOCE', nf_float, 2, dims, id_foce)
+      ierr = nf90_def_var(nid, 'FOCE', nf90_double, dims, id_foce)
+#else
+      ierr = nf90_def_var(nid, 'FOCE', nf90_float, dims, id_foce)
 #endif
       ierr = nf_put_att_text(nid, id_foce, 'title',11,'Frac. Ocean')
 #ifdef NC_DOUBLE
-      ierr = nf_def_var(nid, 'FSIC', nf_double, 2, dims, id_fsic)
-#else
-      ierr = nf_def_var(nid, 'FSIC', nf_float, 2, dims, id_fsic)
+      ierr = nf90_def_var(nid, 'FSIC', nf90_double, dims, id_fsic)
+#else
+      ierr = nf90_def_var(nid, 'FSIC', nf90_float, dims, id_fsic)
 #endif
       ierr = nf_put_att_text(nid, id_fsic, 'title',13,'Frac. Sea Ice')
 #ifdef NC_DOUBLE
-      ierr = nf_def_var(nid, 'FLIC', nf_double, 2, dims, id_flic)
-#else
-      ierr = nf_def_var(nid, 'FLIC', nf_float, 2, dims, id_flic)
+      ierr = nf90_def_var(nid, 'FLIC', nf90_double, dims, id_flic)
+#else
+      ierr = nf90_def_var(nid, 'FLIC', nf90_float, dims, id_flic)
 #endif
       ierr = nf_put_att_text(nid, id_flic, 'title',14,'Frac. Land Ice')
Index: LMDZ6/branches/Portage_acc/libf/phylmd/phyetat0.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/phyetat0.F90	(revision 4445)
+++ 	(revision )
@@ -1,657 +1,0 @@
-! $Id$
-
-SUBROUTINE phyetat0 (fichnom, clesphy0, tabcntr0)
-
-  USE dimphy, only: klon, zmasq, klev
-  USE iophy, ONLY : init_iophy_new
-  USE ocean_cpl_mod,    ONLY : ocean_cpl_init
-  USE fonte_neige_mod,  ONLY : fonte_neige_init
-  USE pbl_surface_mod,  ONLY : pbl_surface_init
-  USE surface_data,     ONLY : type_ocean, version_ocean
-  USE phys_state_var_mod, ONLY : ancien_ok, clwcon, detr_therm, phys_tstep, &
-       qsol, fevap, z0m, z0h, agesno, &
-       du_gwd_rando, du_gwd_front, entr_therm, f0, fm_therm, &
-       falb_dir, falb_dif, prw_ancien, prlw_ancien, prsw_ancien, &
-       ftsol, pbl_tke, pctsrf, q_ancien, ql_ancien, qs_ancien, rneb_ancien, radpas, radsol, rain_fall, ratqs, &
-       rnebcon, rugoro, sig1, snow_fall, solaire_etat0, sollw, sollwdown, &
-       solsw, solswfdiff, t_ancien, u_ancien, v_ancien, w01, wake_cstar, wake_deltaq, &
-       wake_deltat, wake_delta_pbl_TKE, delta_tsurf, beta_aridity, wake_fip, wake_pe, &
-       wake_s, wake_dens, awake_dens, cv_gen, zgam, zmax0, zmea, zpic, zsig, &
-       zstd, zthe, zval, ale_bl, ale_bl_trig, alp_bl, u10m, v10m, treedrg, &
-       ale_wake, ale_bl_stat, ds_ns, dt_ns, delta_sst, delta_sal, ratqs_inter
-!FC
-  USE geometry_mod,     ONLY: longitude_deg, latitude_deg
-  USE iostart,          ONLY: close_startphy, get_field, get_var, open_startphy
-  USE infotrac_phy,     ONLY: nqtot, nbtr, type_trac, tracers
-  USE traclmdz_mod,     ONLY: traclmdz_from_restart
-  USE carbon_cycle_mod, ONLY: carbon_cycle_tr, carbon_cycle_cpl, co2_send
-  USE indice_sol_mod,   ONLY: nbsrf, is_ter, epsfra, is_lic, is_oce, is_sic
-  USE ocean_slab_mod,   ONLY: nslay, tslab, seaice, tice, ocean_slab_init
-  USE time_phylmdz_mod, ONLY: init_iteration, pdtphys, itau_phy
-#ifdef CPP_XIOS
-  USE wxios, ONLY: missing_val
-#else
-  use netcdf, only: missing_val => nf90_fill_real
-#endif
-  use config_ocean_skin_m, only: activate_ocean_skin
-
-  IMPLICIT none
-  !======================================================================
-  ! Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
-  ! Objet: Lecture de l'etat initial pour la physique
-  !======================================================================
-  include "dimsoil.h"
-  include "clesphys.h"
-  include "alpale.h"
-  include "compbl.h"
-  include "YOMCST.h"
-  !======================================================================
-  CHARACTER*(*) fichnom
-
-  ! les variables globales lues dans le fichier restart
-
-  REAL tsoil(klon, nsoilmx, nbsrf)
-  REAL qsurf(klon, nbsrf)
-  REAL snow(klon, nbsrf)
-  real fder(klon)
-  REAL run_off_lic_0(klon)
-  REAL fractint(klon)
-  REAL trs(klon, nbtr)
-  REAL zts(klon)
-  ! pour drag arbres FC
-  REAL drg_ter(klon,klev)
-
-  CHARACTER*6 ocean_in
-  LOGICAL ok_veget_in
-
-  INTEGER        longcles
-  PARAMETER    ( longcles = 20 )
-  REAL clesphy0( longcles )
-
-  REAL xmin, xmax
-
-  INTEGER nid, nvarid
-  INTEGER ierr, i, nsrf, isoil , k
-  INTEGER length
-  PARAMETER (length=100)
-  INTEGER it, iq, isw
-  REAL tab_cntrl(length), tabcntr0(length)
-  CHARACTER*7 str7
-  CHARACTER*2 str2
-  LOGICAL :: found,phyetat0_get,phyetat0_srf
-  REAL :: lon_startphy(klon), lat_startphy(klon)
-
-  ! FH1D
-  !     real iolat(jjm+1)
-  !real iolat(jjm+1-1/(iim*jjm))
-
-  ! Ouvrir le fichier contenant l'etat initial:
-
-  CALL open_startphy(fichnom)
-
-  ! Lecture des parametres de controle:
-
-  CALL get_var("controle", tab_cntrl)
-
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-  ! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
-  ! Les constantes de la physiques sont lues dans la physique seulement.
-  ! Les egalites du type
-  !             tab_cntrl( 5 )=clesphy0(1)
-  ! sont remplacees par
-  !             clesphy0(1)=tab_cntrl( 5 )
-  ! On inverse aussi la logique.
-  ! On remplit les tab_cntrl avec les parametres lus dans les .def
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-  DO i = 1, length
-     tabcntr0( i ) = tab_cntrl( i )
-  ENDDO
-
-  tab_cntrl(1)=pdtphys
-  tab_cntrl(2)=radpas
-
-  ! co2_ppm : value from the previous time step
-  IF (carbon_cycle_tr .OR. carbon_cycle_cpl) THEN
-     co2_ppm = tab_cntrl(3)
-     RCO2    = co2_ppm * 1.0e-06 * RMCO2 / RMD
-     ! ELSE : keep value from .def
-  ENDIF
-
-! co2_ppm0 : initial value of atmospheric CO2 (from create_etat0_limit.e .def)
-! co2_ppm0   = tab_cntrl(16)
-! initial value for interactive CO2 run when there is no tracer field for CO2 in restart
-  co2_ppm0=284.32
-
-  solaire_etat0      = tab_cntrl(4)
-  tab_cntrl(5)=iflag_con
-  tab_cntrl(6)=nbapp_rad
-
-  IF (iflag_cycle_diurne.GE.1) tab_cntrl( 7) = iflag_cycle_diurne
-  IF (soil_model) tab_cntrl( 8) =1.
-  IF (new_oliq) tab_cntrl( 9) =1.
-  IF (ok_orodr) tab_cntrl(10) =1.
-  IF (ok_orolf) tab_cntrl(11) =1.
-  IF (ok_limitvrai) tab_cntrl(12) =1.
-
-  itau_phy = tab_cntrl(15)
-
-  clesphy0(1)=tab_cntrl( 5 )
-  clesphy0(2)=tab_cntrl( 6 )
-  clesphy0(3)=tab_cntrl( 7 )
-  clesphy0(4)=tab_cntrl( 8 )
-  clesphy0(5)=tab_cntrl( 9 )
-  clesphy0(6)=tab_cntrl( 10 )
-  clesphy0(7)=tab_cntrl( 11 )
-  clesphy0(8)=tab_cntrl( 12 )
-
-  ! set time iteration
-   CALL init_iteration(itau_phy)
-
-  ! read latitudes and make a sanity check (because already known from dyn)
-  CALL get_field("latitude",lat_startphy)
-  DO i=1,klon
-    IF (ABS(lat_startphy(i)-latitude_deg(i))>=1) THEN
-      WRITE(*,*) "phyetat0: Error! Latitude discrepancy wrt startphy file:",&
-                 " i=",i," lat_startphy(i)=",lat_startphy(i),&
-                 " latitude_deg(i)=",latitude_deg(i)
-      ! This is presumably serious enough to abort run
-      CALL abort_physic("phyetat0","discrepancy in latitudes!",1)
-    ENDIF
-    IF (ABS(lat_startphy(i)-latitude_deg(i))>=0.0001) THEN
-      WRITE(*,*) "phyetat0: Warning! Latitude discrepancy wrt startphy file:",&
-                 " i=",i," lat_startphy(i)=",lat_startphy(i),&
-                 " latitude_deg(i)=",latitude_deg(i)
-    ENDIF
-  ENDDO
-
-  ! read longitudes and make a sanity check (because already known from dyn)
-  CALL get_field("longitude",lon_startphy)
-  DO i=1,klon
-    IF (ABS(lon_startphy(i)-longitude_deg(i))>=1) THEN
-      IF (ABS(360-ABS(lon_startphy(i)-longitude_deg(i)))>=1) THEN
-        WRITE(*,*) "phyetat0: Error! Longitude discrepancy wrt startphy file:",&
-                   " i=",i," lon_startphy(i)=",lon_startphy(i),&
-                   " longitude_deg(i)=",longitude_deg(i)
-        ! This is presumably serious enough to abort run
-        CALL abort_physic("phyetat0","discrepancy in longitudes!",1)
-      ENDIF
-    ENDIF
-    IF (ABS(lon_startphy(i)-longitude_deg(i))>=1) THEN
-      IF (ABS(360-ABS(lon_startphy(i)-longitude_deg(i))) > 0.0001) THEN
-        WRITE(*,*) "phyetat0: Warning! Longitude discrepancy wrt startphy file:",&
-                   " i=",i," lon_startphy(i)=",lon_startphy(i),&
-                   " longitude_deg(i)=",longitude_deg(i)
-      ENDIF 
-    ENDIF
-  ENDDO
-
-  ! Lecture du masque terre mer
-
-  CALL get_field("masque", zmasq, found)
-  IF (.NOT. found) THEN
-     PRINT*, 'phyetat0: Le champ <masque> est absent'
-     PRINT *, 'fichier startphy non compatible avec phyetat0'
-  ENDIF
-
-  ! Lecture des fractions pour chaque sous-surface
-
-  ! initialisation des sous-surfaces
-
-  pctsrf = 0.
-
-  ! fraction de terre
-
-  CALL get_field("FTER", pctsrf(:, is_ter), found)
-  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FTER> est absent'
-
-  ! fraction de glace de terre
-
-  CALL get_field("FLIC", pctsrf(:, is_lic), found)
-  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FLIC> est absent'
-
-  ! fraction d'ocean
-
-  CALL get_field("FOCE", pctsrf(:, is_oce), found)
-  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FOCE> est absent'
-
-  ! fraction glace de mer
-
-  CALL get_field("FSIC", pctsrf(:, is_sic), found)
-  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FSIC> est absent'
-
-  !  Verification de l'adequation entre le masque et les sous-surfaces
-
-  fractint( 1 : klon) = pctsrf(1 : klon, is_ter)  &
-       + pctsrf(1 : klon, is_lic)
-  DO i = 1 , klon
-     IF ( abs(fractint(i) - zmasq(i) ) .GT. EPSFRA ) THEN
-        WRITE(*, *) 'phyetat0: attention fraction terre pas ',  &
-             'coherente ', i, zmasq(i), pctsrf(i, is_ter) &
-             , pctsrf(i, is_lic)
-        WRITE(*, *) 'Je force la coherence zmasq=fractint'
-        zmasq(i) = fractint(i)
-     ENDIF
-  ENDDO
-  fractint (1 : klon) =  pctsrf(1 : klon, is_oce)  &
-       + pctsrf(1 : klon, is_sic)
-  DO i = 1 , klon
-     IF ( abs( fractint(i) - (1. - zmasq(i))) .GT. EPSFRA ) THEN
-        WRITE(*, *) 'phyetat0 attention fraction ocean pas ',  &
-             'coherente ', i, zmasq(i) , pctsrf(i, is_oce) &
-             , pctsrf(i, is_sic)
-        WRITE(*, *) 'Je force la coherence zmasq=1.-fractint'
-        zmasq(i) = 1. - fractint(i)
-     ENDIF
-  ENDDO
-
-!===================================================================
-! Lecture des temperatures du sol:
-!===================================================================
-
-  found=phyetat0_get(1,ftsol(:,1),"TS","Surface temperature",283.)
-  IF (found) THEN
-     DO nsrf=2,nbsrf
-        ftsol(:,nsrf)=ftsol(:,1)
-     ENDDO
-  ELSE
-     found=phyetat0_srf(1,ftsol,"TS","Surface temperature",283.)
-  ENDIF
-
-!===================================================================
-  ! Lecture des albedo difus et direct
-!===================================================================
-
-  DO nsrf = 1, nbsrf
-     DO isw=1, nsw
-        IF (isw.GT.99) THEN
-           PRINT*, "Trop de bandes SW"
-           call abort_physic("phyetat0", "", 1)
-        ENDIF
-        WRITE(str2, '(i2.2)') isw
-        found=phyetat0_srf(1,falb_dir(:, isw,:),"A_dir_SW"//str2//"srf","Direct Albedo",0.2)
-        found=phyetat0_srf(1,falb_dif(:, isw,:),"A_dif_SW"//str2//"srf","Direct Albedo",0.2)
-     ENDDO
-  ENDDO
-
-  found=phyetat0_srf(1,u10m,"U10M","u a 10m",0.)
-  found=phyetat0_srf(1,v10m,"V10M","v a 10m",0.)
-
-!===================================================================
-  ! Lecture des temperatures du sol profond:
-!===================================================================
-
-   DO isoil=1, nsoilmx
-        IF (isoil.GT.99) THEN
-           PRINT*, "Trop de couches "
-           call abort_physic("phyetat0", "", 1)
-        ENDIF
-        WRITE(str2,'(i2.2)') isoil
-        found=phyetat0_srf(1,tsoil(:, isoil,:),"Tsoil"//str2//"srf","Temp soil",0.)
-        IF (.NOT. found) THEN
-           PRINT*, "phyetat0: Le champ <Tsoil"//str7//"> est absent"
-           PRINT*, "          Il prend donc la valeur de surface"
-           tsoil(:, isoil, :)=ftsol(:, :)
-        ENDIF
-   ENDDO
-
-!=======================================================================
-! Lecture precipitation/evaporation
-!=======================================================================
-
-  found=phyetat0_srf(1,qsurf,"QS","Near surface hmidity",0.)
-  found=phyetat0_get(1,qsol,"QSOL","Surface hmidity / bucket",0.)
-  found=phyetat0_srf(1,snow,"SNOW","Surface snow",0.)
-  found=phyetat0_srf(1,fevap,"EVAP","evaporation",0.)
-  found=phyetat0_get(1,snow_fall,"snow_f","snow fall",0.)
-  found=phyetat0_get(1,rain_fall,"rain_f","rain fall",0.)
-
-!=======================================================================
-! Radiation
-!=======================================================================
-
-  found=phyetat0_get(1,solsw,"solsw","net SW radiation surf",0.)
-  found=phyetat0_get(1,solswfdiff,"solswfdiff","fraction of SW radiation surf that is diffuse",1.)
-  found=phyetat0_get(1,sollw,"sollw","net LW radiation surf",0.)
-  found=phyetat0_get(1,sollwdown,"sollwdown","down LW radiation surf",0.)
-  IF (.NOT. found) THEN
-     sollwdown(:) = 0. ;  zts(:)=0.
-     DO nsrf=1,nbsrf
-        zts(:)=zts(:)+ftsol(:,nsrf)*pctsrf(:,nsrf)
-     ENDDO
-     sollwdown(:)=sollw(:)+RSIGMA*zts(:)**4
-  ENDIF
-
-  found=phyetat0_get(1,radsol,"RADS","Solar radiation",0.)
-  found=phyetat0_get(1,fder,"fder","Flux derivative",0.) 
-
-
-  ! Lecture de la longueur de rugosite 
-  found=phyetat0_srf(1,z0m,"RUG","Z0m ancien",0.001)
-  IF (found) THEN
-     z0h(:,1:nbsrf)=z0m(:,1:nbsrf)
-  ELSE
-     found=phyetat0_srf(1,z0m,"Z0m","Roughness length, momentum ",0.001)
-     found=phyetat0_srf(1,z0h,"Z0h","Roughness length, enthalpy ",0.001)
-  ENDIF
-!FC
-  IF (ifl_pbltree>0) THEN
-!CALL get_field("FTER", pctsrf(:, is_ter), found)
-    treedrg(:,1:klev,1:nbsrf)= 0.0
-    CALL get_field("treedrg_ter", drg_ter(:,:), found)
-!  found=phyetat0_srf(1,treedrg,"treedrg","drag from vegetation" , 0.)
-    !lecture du profile de freinage des arbres
-    IF (.not. found ) THEN
-      treedrg(:,1:klev,1:nbsrf)= 0.0
-    ELSE
-      treedrg(:,1:klev,is_ter)= drg_ter(:,:)
-!     found=phyetat0_srf(klev,treedrg,"treedrg","freinage arbres",0.)
-    ENDIF
-  ELSE
-    ! initialize treedrg(), because it will be written in restartphy.nc
-    treedrg(:,:,:) = 0.0 
-  ENDIF
-
-  ! Lecture de l'age de la neige:
-  found=phyetat0_srf(1,agesno,"AGESNO","SNOW AGE",0.001)
-
-  ancien_ok=.true.
-  ancien_ok=ancien_ok.AND.phyetat0_get(klev,t_ancien,"TANCIEN","TANCIEN",0.)
-  ancien_ok=ancien_ok.AND.phyetat0_get(klev,q_ancien,"QANCIEN","QANCIEN",0.)
-  ancien_ok=ancien_ok.AND.phyetat0_get(klev,ql_ancien,"QLANCIEN","QLANCIEN",0.)
-  ancien_ok=ancien_ok.AND.phyetat0_get(klev,qs_ancien,"QSANCIEN","QSANCIEN",0.)
-  ancien_ok=ancien_ok.AND.phyetat0_get(klev,rneb_ancien,"RNEBANCIEN","RNEBANCIEN",0.)
-  ancien_ok=ancien_ok.AND.phyetat0_get(klev,u_ancien,"UANCIEN","UANCIEN",0.)
-  ancien_ok=ancien_ok.AND.phyetat0_get(klev,v_ancien,"VANCIEN","VANCIEN",0.)
-  ancien_ok=ancien_ok.AND.phyetat0_get(1,prw_ancien,"PRWANCIEN","PRWANCIEN",0.)
-  ancien_ok=ancien_ok.AND.phyetat0_get(1,prlw_ancien,"PRLWANCIEN","PRLWANCIEN",0.)
-  ancien_ok=ancien_ok.AND.phyetat0_get(1,prsw_ancien,"PRSWANCIEN","PRSWANCIEN",0.)
-
-  ! Ehouarn: addtional tests to check if t_ancien, q_ancien contain
-  !          dummy values (as is the case when generated by ce0l,
-  !          or by iniaqua)
-  IF ( (maxval(q_ancien).EQ.minval(q_ancien))       .OR. &
-       (maxval(ql_ancien).EQ.minval(ql_ancien))     .OR. &
-       (maxval(qs_ancien).EQ.minval(qs_ancien))     .OR. &
-       (maxval(rneb_ancien).EQ.minval(rneb_ancien)) .OR. &
-       (maxval(prw_ancien).EQ.minval(prw_ancien))   .OR. &
-       (maxval(prlw_ancien).EQ.minval(prlw_ancien)) .OR. &
-       (maxval(prsw_ancien).EQ.minval(prsw_ancien)) .OR. &
-       (maxval(t_ancien).EQ.minval(t_ancien)) ) THEN
-    ancien_ok=.false.
-  ENDIF
-
-  found=phyetat0_get(klev,clwcon,"CLWCON","CLWCON",0.)
-  found=phyetat0_get(klev,rnebcon,"RNEBCON","RNEBCON",0.)
-  found=phyetat0_get(klev,ratqs,"RATQS","RATQS",0.)
-
-  found=phyetat0_get(1,run_off_lic_0,"RUNOFFLIC0","RUNOFFLIC0",0.)
-
-!==================================
-!  TKE
-!==================================
-!
-  IF (iflag_pbl>1) then
-     found=phyetat0_srf(klev+1,pbl_tke,"TKE","Turb. Kinetic. Energ. ",1.e-8)
-  ENDIF
-
-  IF (iflag_pbl>1 .AND. iflag_wake>=1  .AND. iflag_pbl_split >=1 ) then
-    found=phyetat0_srf(klev+1,wake_delta_pbl_tke,"DELTATKE","Del TKE wk/env",0.)
-!!    found=phyetat0_srf(1,delta_tsurf,"DELTA_TSURF","Delta Ts wk/env ",0.)
-    found=phyetat0_srf(1,delta_tsurf,"DELTATS","Delta Ts wk/env ",0.)
-!!    found=phyetat0_srf(1,beta_aridity,"BETA_S","Aridity factor ",1.)
-    found=phyetat0_srf(1,beta_aridity,"BETAS","Aridity factor ",1.)
-  ENDIF   !(iflag_pbl>1 .AND. iflag_wake>=1 .AND. iflag_pbl_split >=1 )
-
-!==================================
-!  thermiques, poches, convection
-!==================================
-
-! Emanuel
-  found=phyetat0_get(klev,sig1,"sig1","sig1",0.)
-  found=phyetat0_get(klev,w01,"w01","w01",0.)
-
-! Wake
-  found=phyetat0_get(klev,wake_deltat,"WAKE_DELTAT","Delta T wake/env",0.)
-  found=phyetat0_get(klev,wake_deltaq,"WAKE_DELTAQ","Delta hum. wake/env",0.)
-  found=phyetat0_get(1,wake_s,"WAKE_S","Wake frac. area",0.)
-!jyg<
-!  Set wake_dens to -1000. when there is no restart so that the actual
-!  initialization is made in calwake.
-!!  found=phyetat0_get(1,wake_dens,"WAKE_DENS","Wake num. /unit area",0.)
-  found=phyetat0_get(1,wake_dens,"WAKE_DENS","Wake num. /unit area",-1000.)
-  found=phyetat0_get(1,awake_dens,"AWAKE_DENS","Active Wake num. /unit area",0.)
-  found=phyetat0_get(1,cv_gen,"CV_GEN","CB birth rate",0.)
-!>jyg
-  found=phyetat0_get(1,wake_cstar,"WAKE_CSTAR","WAKE_CSTAR",0.)
-  found=phyetat0_get(1,wake_pe,"WAKE_PE","WAKE_PE",0.)
-  found=phyetat0_get(1,wake_fip,"WAKE_FIP","WAKE_FIP",0.)
-
-! Thermiques
-  found=phyetat0_get(1,zmax0,"ZMAX0","ZMAX0",40.)
-  found=phyetat0_get(1,f0,"F0","F0",1.e-5)
-  found=phyetat0_get(klev+1,fm_therm,"FM_THERM","Thermals mass flux",0.)
-  found=phyetat0_get(klev,entr_therm,"ENTR_THERM","Thermals Entrain.",0.)
-  found=phyetat0_get(klev,detr_therm,"DETR_THERM","Thermals Detrain.",0.)
-
-! ALE/ALP
-  found=phyetat0_get(1,ale_bl,"ALE_BL","ALE BL",0.)
-  found=phyetat0_get(1,ale_bl_trig,"ALE_BL_TRIG","ALE BL_TRIG",0.)
-  found=phyetat0_get(1,alp_bl,"ALP_BL","ALP BL",0.)
-  found=phyetat0_get(1,ale_wake,"ALE_WAKE","ALE_WAKE",0.)
-  found=phyetat0_get(1,ale_bl_stat,"ALE_BL_STAT","ALE_BL_STAT",0.)
-
-! fisrtilp/Clouds 0.002 could be ratqsbas. But can stay like this as well
-  found=phyetat0_get(klev,ratqs_inter,"RATQS_INTER","Relative width of the lsc sugrid scale water",0.002)
-
-!===========================================
-  ! Read and send field trs to traclmdz
-!===========================================
-
-  IF (type_trac == 'lmdz') THEN
-     it = 0
-     DO iq = 1, nqtot
-        IF(.NOT.(tracers(iq)%isAdvected .AND. tracers(iq)%isInPhysics)) CYCLE
-        it = it+1
-        found=phyetat0_get(1,trs(:,it),"trs_"//TRIM(tracers(iq)%name), &
-                                  "Surf trac"//TRIM(tracers(iq)%name),0.)
-     END DO
-     CALL traclmdz_from_restart(trs)
-  ENDIF
-
-!--OB now this is for co2i - ThL: and therefore also for inco
-  IF (type_trac == 'co2i' .OR. type_trac == 'inco') THEN
-     IF (carbon_cycle_cpl) THEN
-        ALLOCATE(co2_send(klon), stat=ierr)
-        IF (ierr /= 0) CALL abort_physic('phyetat0', 'pb allocation co2_send', 1)
-        found=phyetat0_get(1,co2_send,"co2_send","co2 send",co2_ppm)
-     ENDIF
-  ENDIF
-
-!===========================================
-!  ondes de gravite / relief
-!===========================================
-
-!  ondes de gravite non orographiques
-  IF (ok_gwd_rando) found = &
-       phyetat0_get(klev,du_gwd_rando,"du_gwd_rando","du_gwd_rando",0.)
-  IF (.NOT. ok_hines .AND. ok_gwd_rando) found &
-       = phyetat0_get(klev,du_gwd_front,"du_gwd_front","du_gwd_front",0.)
-
-!  prise en compte du relief sous-maille
-  found=phyetat0_get(1,zmea,"ZMEA","sub grid orography",0.)
-  found=phyetat0_get(1,zstd,"ZSTD","sub grid orography",0.)
-  found=phyetat0_get(1,zsig,"ZSIG","sub grid orography",0.)
-  found=phyetat0_get(1,zgam,"ZGAM","sub grid orography",0.)
-  found=phyetat0_get(1,zthe,"ZTHE","sub grid orography",0.)
-  found=phyetat0_get(1,zpic,"ZPIC","sub grid orography",0.)
-  found=phyetat0_get(1,zval,"ZVAL","sub grid orography",0.)
-  found=phyetat0_get(1,zmea,"ZMEA","sub grid orography",0.)
-  found=phyetat0_get(1,rugoro,"RUGSREL","sub grid orography",0.)
-
-!===========================================
-! Initialize ocean
-!===========================================
-
-  IF ( type_ocean == 'slab' ) THEN
-      CALL ocean_slab_init(phys_tstep, pctsrf)
-      IF (nslay.EQ.1) THEN
-        found=phyetat0_get(1,tslab,"tslab01","tslab",0.)
-        IF (.NOT. found) THEN
-            found=phyetat0_get(1,tslab,"tslab","tslab",0.)
-        ENDIF
-      ELSE
-          DO i=1,nslay
-            WRITE(str2,'(i2.2)') i
-            found=phyetat0_get(1,tslab(:,i),"tslab"//str2,"tslab",0.)  
-          ENDDO
-      ENDIF
-      IF (.NOT. found) THEN 
-          PRINT*, "phyetat0: Le champ <tslab> est absent"
-          PRINT*, "Initialisation a tsol_oce"
-          DO i=1,nslay
-              tslab(:,i)=MAX(ftsol(:,is_oce),271.35)
-          ENDDO
-      ENDIF 
-
-      ! Sea ice variables
-      IF (version_ocean == 'sicINT') THEN
-          found=phyetat0_get(1,tice,"slab_tice","slab_tice",0.)
-          IF (.NOT. found) THEN 
-              PRINT*, "phyetat0: Le champ <tice> est absent"
-              PRINT*, "Initialisation a tsol_sic"
-                  tice(:)=ftsol(:,is_sic)
-          ENDIF 
-          found=phyetat0_get(1,seaice,"seaice","seaice",0.)
-          IF (.NOT. found) THEN
-              PRINT*, "phyetat0: Le champ <seaice> est absent"
-              PRINT*, "Initialisation a 0/1m suivant fraction glace"
-              seaice(:)=0.
-              WHERE (pctsrf(:,is_sic).GT.EPSFRA)
-                  seaice=917.
-              ENDWHERE
-          ENDIF
-      ENDIF !sea ice INT
-  ENDIF ! Slab        
-
-  if (activate_ocean_skin >= 1) then
-     if (activate_ocean_skin == 2 .and. type_ocean == 'couple') then
-        found = phyetat0_get(1, delta_sal, "delta_sal", &
-             "ocean-air interface salinity minus bulk salinity", 0.)
-        found = phyetat0_get(1, delta_sst, "delta_SST", &
-             "ocean-air interface temperature minus bulk SST", 0.)
-     end if
-     
-     found = phyetat0_get(1, ds_ns, "dS_ns", "delta salinity near surface", 0.)
-     found = phyetat0_get(1, dt_ns, "dT_ns", "delta temperature near surface", &
-          0.)
-
-     where (pctsrf(:, is_oce) == 0.)
-        ds_ns = missing_val
-        dt_ns = missing_val
-        delta_sst = missing_val
-        delta_sal = missing_val
-     end where
-  end if
-
-  ! on ferme le fichier
-  CALL close_startphy
-
-  ! Initialize module pbl_surface_mod 
-
-  CALL pbl_surface_init(fder, snow, qsurf, tsoil)
-
-  ! Initialize module ocean_cpl_mod for the case of coupled ocean
-  IF ( type_ocean == 'couple' ) THEN
-     CALL ocean_cpl_init(phys_tstep, longitude_deg, latitude_deg)
-  ENDIF
-
-!  CALL init_iophy_new(latitude_deg, longitude_deg)
-
-  ! Initilialize module fonte_neige_mod      
-  CALL fonte_neige_init(run_off_lic_0)
-
-END SUBROUTINE phyetat0
-
-!===================================================================
-FUNCTION phyetat0_get(nlev,field,name,descr,default)
-!===================================================================
-! Lecture d'un champ avec contrôle
-! Function logique dont le resultat indique si la lecture
-! s'est bien passée
-! On donne une valeur par defaut dans le cas contraire
-!===================================================================
-
-USE iostart, ONLY : get_field
-USE dimphy, only: klon 
-USE print_control_mod, ONLY: lunout
-
-IMPLICIT NONE
-
-LOGICAL phyetat0_get
-
-! arguments
-INTEGER,INTENT(IN) :: nlev
-CHARACTER*(*),INTENT(IN) :: name,descr
-REAL,INTENT(IN) :: default
-REAL,DIMENSION(klon,nlev),INTENT(INOUT) :: field
-
-! Local variables
-LOGICAL found
-
-   CALL get_field(name, field, found)
-   IF (.NOT. found) THEN
-     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)
-   phyetat0_get=found
-
-RETURN
-END FUNCTION phyetat0_get
-
-!================================================================
-FUNCTION phyetat0_srf(nlev,field,name,descr,default)
-!===================================================================
-! Lecture d'un champ par sous-surface avec contrôle
-! Function logique dont le resultat indique si la lecture
-! s'est bien passée
-! On donne une valeur par defaut dans le cas contraire
-!===================================================================
-
-USE iostart, ONLY : get_field
-USE dimphy, only: klon 
-USE indice_sol_mod, only: nbsrf
-USE print_control_mod, ONLY: lunout
-
-IMPLICIT NONE
-
-LOGICAL phyetat0_srf
-! arguments
-INTEGER,INTENT(IN) :: nlev
-CHARACTER*(*),INTENT(IN) :: name,descr
-REAL,INTENT(IN) :: default
-REAL,DIMENSION(klon,nlev,nbsrf),INTENT(INOUT) :: field
-
-! Local variables
-LOGICAL found,phyetat0_get
-INTEGER nsrf
-CHARACTER*2 str2
-  
-     IF (nbsrf.GT.99) THEN
-        WRITE(lunout,*) "Trop de sous-mailles"
-        call abort_physic("phyetat0", "", 1)
-     ENDIF
-
-     DO nsrf = 1, nbsrf
-        WRITE(str2, '(i2.2)') nsrf
-        found= phyetat0_get(nlev,field(:,:, nsrf), &
-        name//str2,descr//" srf:"//str2,default)
-     ENDDO
-
-     phyetat0_srf=found
-
-RETURN
-END FUNCTION phyetat0_srf
-
Index: LMDZ6/branches/Portage_acc/libf/phylmd/phyetat0_get_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/phyetat0_get_mod.F90	(revision 4446)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/phyetat0_get_mod.F90	(revision 4446)
@@ -0,0 +1,143 @@
+MODULE phyetat0_get_mod
+
+  PRIVATE
+  PUBLIC :: phyetat0_get, phyetat0_srf
+
+  INTERFACE phyetat0_get
+    MODULE PROCEDURE phyetat0_get10, phyetat0_get20, phyetat0_get11, phyetat0_get21
+  END INTERFACE phyetat0_get
+  INTERFACE phyetat0_srf
+    MODULE PROCEDURE phyetat0_srf20, phyetat0_srf30, phyetat0_srf21, phyetat0_srf31
+  END INTERFACE phyetat0_srf
+
+CONTAINS
+
+!==============================================================================
+LOGICAL FUNCTION phyetat0_get10(field, name, descr, default) RESULT(lFound)
+! Read a field. Check whether reading succeded and use default value if not.
+  IMPLICIT NONE
+  REAL,             INTENT(INOUT) :: field(:) ! klon
+  CHARACTER(LEN=*), INTENT(IN)    :: name
+  CHARACTER(LEN=*), INTENT(IN)    :: descr
+  REAL,             INTENT(IN)    :: default
+!------------------------------------------------------------------------------
+  REAL :: fld(SIZE(field),1)
+  lFound = phyetat0_get21(fld, [name], descr, default); field = fld(:,1)
+END FUNCTION phyetat0_get10
+!==============================================================================
+LOGICAL FUNCTION phyetat0_get20(field, name, descr, default) RESULT(lFound)
+! Same as phyetat0_get11, field on multiple levels.
+  IMPLICIT NONE
+  REAL,             INTENT(INOUT) :: field(:,:) ! klon, nlev
+  CHARACTER(LEN=*), INTENT(IN)    :: name
+  CHARACTER(LEN=*), INTENT(IN)    :: descr
+  REAL,             INTENT(IN)    :: default
+!-----------------------------------------------------------------------------
+  lFound = phyetat0_get21(field, [name], descr, default)
+END FUNCTION phyetat0_get20
+!==============================================================================
+LOGICAL FUNCTION phyetat0_get11(field, name, descr, default) RESULT(lFound)
+! Same as phyetat0_get11, multiple names.
+  IMPLICIT NONE
+  REAL,             INTENT(INOUT) :: field(:) ! klon
+  CHARACTER(LEN=*), INTENT(IN)    :: name(:)
+  CHARACTER(LEN=*), INTENT(IN)    :: descr
+  REAL,             INTENT(IN)    :: default
+!-----------------------------------------------------------------------------
+  REAL :: fld(SIZE(field),1)
+  lFound = phyetat0_get21(fld, name, descr, default); field = fld(:,1)
+END FUNCTION phyetat0_get11
+!==============================================================================
+LOGICAL FUNCTION phyetat0_get21(field, name, descr, default, tname) RESULT(lFound)
+! Same as phyetat0_get11, field on multiple levels, multiple names.
+  USE iostart,           ONLY: get_field
+  USE print_control_mod, ONLY: lunout
+  IMPLICIT NONE
+  REAL,             INTENT(INOUT) :: field(:,:) ! klon, nlev
+  CHARACTER(LEN=*), INTENT(IN)    :: name(:)
+  CHARACTER(LEN=*), INTENT(IN)    :: descr
+  REAL,             INTENT(IN)    :: default
+  CHARACTER(LEN=*), OPTIONAL, INTENT(OUT) :: tname
+!-----------------------------------------------------------------------------
+  CHARACTER(LEN=LEN(name)) :: tnam
+  INTEGER :: i
+  DO i = 1, SIZE(name)
+    CALL get_field(TRIM(name(i)), field, lFound)
+    IF(lFound) EXIT
+    WRITE(lunout,*) "phyetat0: Missing field <",TRIM(name(i)),"> "
+  END DO
+  IF(.NOT.lFound) THEN
+    WRITE(lunout,*) "Slightly distorted start ; continuing."
+    field(:,:) = default
+    tnam = name(1)
+  ELSE
+    tnam = name(i)
+  END IF
+  WRITE(lunout,'(2(a,ES14.7))') 'phyetat0: '//TRIM(tnam)//' ('//TRIM(descr)//') min/max=', &
+    MINval(field),' ',MAXval(field)
+  IF(PRESENT(tname)) tname = tnam
+END FUNCTION phyetat0_get21
+!==============================================================================
+LOGICAL FUNCTION phyetat0_srf20(field, name, descr, default) RESULT(lFound)
+! Read a field per sub-surface.
+! Check whether reading succeded and use default value if not.
+  IMPLICIT NONE
+  REAL,             INTENT(INOUT) :: field(:,:)
+  CHARACTER(LEN=*), INTENT(IN)    :: name
+  CHARACTER(LEN=*), INTENT(IN)    :: descr
+  REAL,             INTENT(IN)    :: default
+!-----------------------------------------------------------------------------
+  REAL :: fld(SIZE(field,1),1,SIZE(field,2))
+  lFound = phyetat0_srf31(fld, [name], descr, default); field = fld(:,1,:)
+END FUNCTION phyetat0_srf20
+
+!==============================================================================
+LOGICAL FUNCTION phyetat0_srf30(field, name, descr, default) RESULT(lFound)
+! Same as phyetat0_sfr11, multiple names tested one after the other.
+  IMPLICIT NONE
+  REAL,             INTENT(INOUT) :: field(:,:,:)
+  CHARACTER(LEN=*), INTENT(IN)    :: name
+  CHARACTER(LEN=*), INTENT(IN)    :: descr
+  REAL,             INTENT(IN)    :: default
+!-----------------------------------------------------------------------------
+  lFound = phyetat0_srf31(field, [name], descr, default)
+END FUNCTION phyetat0_srf30
+
+!==============================================================================
+LOGICAL FUNCTION phyetat0_srf21(field, name, descr, default) RESULT(lFound)
+! Same as phyetat0_sfr11, field on multiple levels.
+  IMPLICIT NONE
+  REAL,             INTENT(INOUT) :: field(:,:)
+  CHARACTER(LEN=*), INTENT(IN)    :: name(:)
+  CHARACTER(LEN=*), INTENT(IN)    :: descr
+  REAL,             INTENT(IN)    :: default
+!-----------------------------------------------------------------------------
+  REAL :: fld(SIZE(field,1),1,SIZE(field,2))
+  lFound = phyetat0_srf31(fld, name, descr, default); field = fld(:,1,:)
+END FUNCTION phyetat0_srf21
+
+!==============================================================================
+LOGICAL FUNCTION phyetat0_srf31(field, name, descr, default) RESULT(lFound)
+! Same as phyetat0_sfr11, field on multiple levels, multiple names tested one after the other.
+  USE iostart,           ONLY: get_field
+  USE print_control_mod, ONLY: lunout
+  USE strings_mod,       ONLY: int2str, maxlen
+  IMPLICIT NONE
+  REAL,             INTENT(INOUT) :: field(:,:,:)
+  CHARACTER(LEN=*), INTENT(IN)    :: name(:)
+  CHARACTER(LEN=*), INTENT(IN)    :: descr
+  REAL,             INTENT(IN)    :: default
+!-----------------------------------------------------------------------------
+  INTEGER :: nsrf, i
+  CHARACTER(LEN=maxlen) :: nam(SIZE(name)), tname, des
+  IF(SIZE(field,3)>99) CALL abort_physic("phyetat0", "Too much sub-cells", 1)
+  DO nsrf = 1, SIZE(field,3)
+    DO i = 1, SIZE(name); nam(i) = TRIM(name(i))//TRIM(int2str(nsrf,2)); END DO
+    des = TRIM(descr)//" srf:"//int2str(nsrf,2)
+    lFound = phyetat0_get21(field(:,:,nsrf), nam, TRIM(des), default, tname)
+  END DO
+  WRITE(lunout,'(2(a,ES14.7))') 'phyetat0: '//TRIM(tname)//' ('//TRIM(descr)//') min/max=', &
+    MINval(field),' ',MAXval(field)
+END FUNCTION phyetat0_srf31
+
+END MODULE phyetat0_get_mod
Index: LMDZ6/branches/Portage_acc/libf/phylmd/phyetat0_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/phyetat0_mod.F90	(revision 4446)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/phyetat0_mod.F90	(revision 4446)
@@ -0,0 +1,608 @@
+! $Id$
+
+MODULE phyetat0_mod
+
+  PRIVATE
+  PUBLIC :: phyetat0
+
+CONTAINS
+
+SUBROUTINE phyetat0 (fichnom, clesphy0, tabcntr0)
+
+  USE dimphy, only: klon, zmasq, klev
+  USE iophy, ONLY : init_iophy_new
+  USE ocean_cpl_mod,    ONLY : ocean_cpl_init
+  USE fonte_neige_mod,  ONLY : fonte_neige_init
+  USE pbl_surface_mod,  ONLY : pbl_surface_init
+  USE surface_data,     ONLY : type_ocean, version_ocean
+  USE phyetat0_get_mod, ONLY : phyetat0_get, phyetat0_srf
+  USE phys_state_var_mod, ONLY : ancien_ok, clwcon, detr_therm, phys_tstep, &
+       qsol, fevap, z0m, z0h, agesno, &
+       du_gwd_rando, du_gwd_front, entr_therm, f0, fm_therm, &
+       falb_dir, falb_dif, prw_ancien, prlw_ancien, prsw_ancien, &
+       ftsol, pbl_tke, pctsrf, q_ancien, ql_ancien, qs_ancien, rneb_ancien, radpas, radsol, rain_fall, ratqs, &
+       rnebcon, rugoro, sig1, snow_fall, solaire_etat0, sollw, sollwdown, &
+       solsw, solswfdiff, t_ancien, u_ancien, v_ancien, w01, wake_cstar, wake_deltaq, &
+       wake_deltat, wake_delta_pbl_TKE, delta_tsurf, beta_aridity, wake_fip, wake_pe, &
+       wake_s, wake_dens, awake_dens, cv_gen, zgam, zmax0, zmea, zpic, zsig, &
+       zstd, zthe, zval, ale_bl, ale_bl_trig, alp_bl, u10m, v10m, treedrg, &
+       ale_wake, ale_bl_stat, ds_ns, dt_ns, delta_sst, delta_sal, dter, dser, &
+       dt_ds, ratqs_inter
+!FC
+  USE geometry_mod,     ONLY: longitude_deg, latitude_deg
+  USE iostart,          ONLY: close_startphy, get_field, get_var, open_startphy
+  USE infotrac_phy,     ONLY: nqtot, nbtr, type_trac, tracers
+  USE readTracFiles_mod,ONLY: maxlen, new2oldH2O
+  USE traclmdz_mod,     ONLY: traclmdz_from_restart
+  USE carbon_cycle_mod, ONLY: carbon_cycle_init, carbon_cycle_cpl, carbon_cycle_tr, carbon_cycle_rad, co2_send, RCO2_glo
+  USE indice_sol_mod,   ONLY: nbsrf, is_ter, epsfra, is_lic, is_oce, is_sic
+  USE ocean_slab_mod,   ONLY: nslay, tslab, seaice, tice, ocean_slab_init
+  USE time_phylmdz_mod, ONLY: init_iteration, pdtphys, itau_phy
+#ifdef CPP_XIOS
+  USE wxios, ONLY: missing_val
+#else
+  use netcdf, only: missing_val => nf90_fill_real
+#endif
+  use config_ocean_skin_m, only: activate_ocean_skin
+
+  IMPLICIT none
+  !======================================================================
+  ! Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
+  ! Objet: Lecture de l'etat initial pour la physique
+  !======================================================================
+  include "dimsoil.h"
+  include "clesphys.h"
+  include "alpale.h"
+  include "compbl.h"
+  include "YOMCST.h"
+  !======================================================================
+  CHARACTER*(*) fichnom
+
+  ! les variables globales lues dans le fichier restart
+
+  REAL tsoil(klon, nsoilmx, nbsrf)
+  REAL qsurf(klon, nbsrf)
+  REAL snow(klon, nbsrf)
+  real fder(klon)
+  REAL run_off_lic_0(klon)
+  REAL fractint(klon)
+  REAL trs(klon, nbtr)
+  REAL zts(klon)
+  ! pour drag arbres FC
+  REAL drg_ter(klon,klev)
+
+  CHARACTER*6 ocean_in
+  LOGICAL ok_veget_in
+
+  INTEGER        longcles
+  PARAMETER    ( longcles = 20 )
+  REAL clesphy0( longcles )
+
+  REAL xmin, xmax
+
+  INTEGER nid, nvarid
+  INTEGER ierr, i, nsrf, isoil , k
+  INTEGER length
+  PARAMETER (length=100)
+  INTEGER it, iq, isw
+  REAL tab_cntrl(length), tabcntr0(length)
+  CHARACTER*7 str7
+  CHARACTER*2 str2
+  LOGICAL :: found
+  REAL :: lon_startphy(klon), lat_startphy(klon)
+  CHARACTER(LEN=maxlen) :: tname, t(2)
+
+  ! FH1D
+  !     real iolat(jjm+1)
+  !real iolat(jjm+1-1/(iim*jjm))
+
+  ! Ouvrir le fichier contenant l'etat initial:
+
+  CALL open_startphy(fichnom)
+
+  ! Lecture des parametres de controle:
+
+  CALL get_var("controle", tab_cntrl)
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  ! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
+  ! Les constantes de la physiques sont lues dans la physique seulement.
+  ! Les egalites du type
+  !             tab_cntrl( 5 )=clesphy0(1)
+  ! sont remplacees par
+  !             clesphy0(1)=tab_cntrl( 5 )
+  ! On inverse aussi la logique.
+  ! On remplit les tab_cntrl avec les parametres lus dans les .def
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  DO i = 1, length
+     tabcntr0( i ) = tab_cntrl( i )
+  ENDDO
+
+  tab_cntrl(1)=pdtphys
+  tab_cntrl(2)=radpas
+
+  ! co2_ppm : value from the previous time step
+
+  ! co2_ppm0 : initial value of atmospheric CO2 (from create_etat0_limit.e .def)
+  co2_ppm0 = 284.32
+  ! when no initial value is available e.g., from a restart 
+  ! this variable must be set  in a .def file which will then be 
+  ! used by the conf_phys_m.F90 routine.
+  ! co2_ppm0 = 284.32 (illustrative example on how to set the variable in .def
+  ! file, for a pre-industrial CO2 concentration value)
+
+  IF (carbon_cycle_tr .OR. carbon_cycle_cpl) THEN
+     co2_ppm = tab_cntrl(3)
+     RCO2    = co2_ppm * 1.0e-06 * RMCO2 / RMD
+     IF (tab_cntrl(17) > 0. .AND. carbon_cycle_rad) THEN
+           RCO2_glo = tab_cntrl(17)
+       ELSE
+           RCO2_glo    = co2_ppm0 * 1.0e-06 * RMCO2 / RMD
+     ENDIF
+     ! ELSE : keep value from .def
+  ENDIF
+
+  solaire_etat0      = tab_cntrl(4)
+  tab_cntrl(5)=iflag_con
+  tab_cntrl(6)=nbapp_rad
+
+  IF (iflag_cycle_diurne.GE.1) tab_cntrl( 7) = iflag_cycle_diurne
+  IF (soil_model) tab_cntrl( 8) =1.
+  IF (new_oliq) tab_cntrl( 9) =1.
+  IF (ok_orodr) tab_cntrl(10) =1.
+  IF (ok_orolf) tab_cntrl(11) =1.
+  IF (ok_limitvrai) tab_cntrl(12) =1.
+
+  itau_phy = tab_cntrl(15)
+
+  clesphy0(1)=tab_cntrl( 5 )
+  clesphy0(2)=tab_cntrl( 6 )
+  clesphy0(3)=tab_cntrl( 7 )
+  clesphy0(4)=tab_cntrl( 8 )
+  clesphy0(5)=tab_cntrl( 9 )
+  clesphy0(6)=tab_cntrl( 10 )
+  clesphy0(7)=tab_cntrl( 11 )
+  clesphy0(8)=tab_cntrl( 12 )
+  clesphy0(9)=tab_cntrl( 17 )
+
+  ! set time iteration
+   CALL init_iteration(itau_phy)
+
+  ! read latitudes and make a sanity check (because already known from dyn)
+  CALL get_field("latitude",lat_startphy)
+  DO i=1,klon
+    IF (ABS(lat_startphy(i)-latitude_deg(i))>=1) THEN
+      WRITE(*,*) "phyetat0: Error! Latitude discrepancy wrt startphy file:",&
+                 " i=",i," lat_startphy(i)=",lat_startphy(i),&
+                 " latitude_deg(i)=",latitude_deg(i)
+      ! This is presumably serious enough to abort run
+      CALL abort_physic("phyetat0","discrepancy in latitudes!",1)
+    ENDIF
+    IF (ABS(lat_startphy(i)-latitude_deg(i))>=0.0001) THEN
+      WRITE(*,*) "phyetat0: Warning! Latitude discrepancy wrt startphy file:",&
+                 " i=",i," lat_startphy(i)=",lat_startphy(i),&
+                 " latitude_deg(i)=",latitude_deg(i)
+    ENDIF
+  ENDDO
+
+  ! read longitudes and make a sanity check (because already known from dyn)
+  CALL get_field("longitude",lon_startphy)
+  DO i=1,klon
+    IF (ABS(lon_startphy(i)-longitude_deg(i))>=1) THEN
+      IF (ABS(360-ABS(lon_startphy(i)-longitude_deg(i)))>=1) THEN
+        WRITE(*,*) "phyetat0: Error! Longitude discrepancy wrt startphy file:",&
+                   " i=",i," lon_startphy(i)=",lon_startphy(i),&
+                   " longitude_deg(i)=",longitude_deg(i)
+        ! This is presumably serious enough to abort run
+        CALL abort_physic("phyetat0","discrepancy in longitudes!",1)
+      ENDIF
+    ENDIF
+    IF (ABS(lon_startphy(i)-longitude_deg(i))>=1) THEN
+      IF (ABS(360-ABS(lon_startphy(i)-longitude_deg(i))) > 0.0001) THEN
+        WRITE(*,*) "phyetat0: Warning! Longitude discrepancy wrt startphy file:",&
+                   " i=",i," lon_startphy(i)=",lon_startphy(i),&
+                   " longitude_deg(i)=",longitude_deg(i)
+      ENDIF 
+    ENDIF
+  ENDDO
+
+  ! Lecture du masque terre mer
+
+  CALL get_field("masque", zmasq, found)
+  IF (.NOT. found) THEN
+     PRINT*, 'phyetat0: Le champ <masque> est absent'
+     PRINT *, 'fichier startphy non compatible avec phyetat0'
+  ENDIF
+
+  ! Lecture des fractions pour chaque sous-surface
+
+  ! initialisation des sous-surfaces
+
+  pctsrf = 0.
+
+  ! fraction de terre
+
+  CALL get_field("FTER", pctsrf(:, is_ter), found)
+  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FTER> est absent'
+
+  ! fraction de glace de terre
+
+  CALL get_field("FLIC", pctsrf(:, is_lic), found)
+  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FLIC> est absent'
+
+  ! fraction d'ocean
+
+  CALL get_field("FOCE", pctsrf(:, is_oce), found)
+  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FOCE> est absent'
+
+  ! fraction glace de mer
+
+  CALL get_field("FSIC", pctsrf(:, is_sic), found)
+  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FSIC> est absent'
+
+  !  Verification de l'adequation entre le masque et les sous-surfaces
+
+  fractint( 1 : klon) = pctsrf(1 : klon, is_ter)  &
+       + pctsrf(1 : klon, is_lic)
+  DO i = 1 , klon
+     IF ( abs(fractint(i) - zmasq(i) ) .GT. EPSFRA ) THEN
+        WRITE(*, *) 'phyetat0: attention fraction terre pas ',  &
+             'coherente ', i, zmasq(i), pctsrf(i, is_ter) &
+             , pctsrf(i, is_lic)
+        WRITE(*, *) 'Je force la coherence zmasq=fractint'
+        zmasq(i) = fractint(i)
+     ENDIF
+  ENDDO
+  fractint (1 : klon) =  pctsrf(1 : klon, is_oce)  &
+       + pctsrf(1 : klon, is_sic)
+  DO i = 1 , klon
+     IF ( abs( fractint(i) - (1. - zmasq(i))) .GT. EPSFRA ) THEN
+        WRITE(*, *) 'phyetat0 attention fraction ocean pas ',  &
+             'coherente ', i, zmasq(i) , pctsrf(i, is_oce) &
+             , pctsrf(i, is_sic)
+        WRITE(*, *) 'Je force la coherence zmasq=1.-fractint'
+        zmasq(i) = 1. - fractint(i)
+     ENDIF
+  ENDDO
+
+!===================================================================
+! Lecture des temperatures du sol:
+!===================================================================
+
+  found=phyetat0_get(ftsol(:,1),"TS","Surface temperature",283.)
+  IF (found) THEN
+     DO nsrf=2,nbsrf
+        ftsol(:,nsrf)=ftsol(:,1)
+     ENDDO
+  ELSE
+     found=phyetat0_srf(ftsol,"TS","Surface temperature",283.)
+  ENDIF
+
+!===================================================================
+  ! Lecture des albedo difus et direct
+!===================================================================
+
+  DO nsrf = 1, nbsrf
+     DO isw=1, nsw
+        IF (isw.GT.99) THEN
+           PRINT*, "Trop de bandes SW"
+           call abort_physic("phyetat0", "", 1)
+        ENDIF
+        WRITE(str2, '(i2.2)') isw
+        found=phyetat0_srf(falb_dir(:, isw,:),"A_dir_SW"//str2//"srf","Direct Albedo",0.2)
+        found=phyetat0_srf(falb_dif(:, isw,:),"A_dif_SW"//str2//"srf","Direct Albedo",0.2)
+     ENDDO
+  ENDDO
+
+  found=phyetat0_srf(u10m,"U10M","u a 10m",0.)
+  found=phyetat0_srf(v10m,"V10M","v a 10m",0.)
+
+!===================================================================
+  ! Lecture des temperatures du sol profond:
+!===================================================================
+
+   DO isoil=1, nsoilmx
+        IF (isoil.GT.99) THEN
+           PRINT*, "Trop de couches "
+           call abort_physic("phyetat0", "", 1)
+        ENDIF
+        WRITE(str2,'(i2.2)') isoil
+        found=phyetat0_srf(tsoil(:, isoil,:),"Tsoil"//str2//"srf","Temp soil",0.)
+        IF (.NOT. found) THEN
+           PRINT*, "phyetat0: Le champ <Tsoil"//str7//"> est absent"
+           PRINT*, "          Il prend donc la valeur de surface"
+           tsoil(:, isoil, :)=ftsol(:, :)
+        ENDIF
+   ENDDO
+
+!=======================================================================
+! Lecture precipitation/evaporation
+!=======================================================================
+
+  found=phyetat0_srf(qsurf,"QS","Near surface hmidity",0.)
+  found=phyetat0_get(qsol,"QSOL","Surface hmidity / bucket",0.)
+  found=phyetat0_srf(snow,"SNOW","Surface snow",0.)
+  found=phyetat0_srf(fevap,"EVAP","evaporation",0.)
+  found=phyetat0_get(snow_fall,"snow_f","snow fall",0.)
+  found=phyetat0_get(rain_fall,"rain_f","rain fall",0.)
+
+!=======================================================================
+! Radiation
+!=======================================================================
+
+  found=phyetat0_get(solsw,"solsw","net SW radiation surf",0.)
+  found=phyetat0_get(solswfdiff,"solswfdiff","fraction of SW radiation surf that is diffuse",1.)
+  found=phyetat0_get(sollw,"sollw","net LW radiation surf",0.)
+  found=phyetat0_get(sollwdown,"sollwdown","down LW radiation surf",0.)
+  IF (.NOT. found) THEN
+     sollwdown(:) = 0. ;  zts(:)=0.
+     DO nsrf=1,nbsrf
+        zts(:)=zts(:)+ftsol(:,nsrf)*pctsrf(:,nsrf)
+     ENDDO
+     sollwdown(:)=sollw(:)+RSIGMA*zts(:)**4
+  ENDIF
+
+  found=phyetat0_get(radsol,"RADS","Solar radiation",0.)
+  found=phyetat0_get(fder,"fder","Flux derivative",0.) 
+
+
+  ! Lecture de la longueur de rugosite 
+  found=phyetat0_srf(z0m,"RUG","Z0m ancien",0.001)
+  IF (found) THEN
+     z0h(:,1:nbsrf)=z0m(:,1:nbsrf)
+  ELSE
+     found=phyetat0_srf(z0m,"Z0m","Roughness length, momentum ",0.001)
+     found=phyetat0_srf(z0h,"Z0h","Roughness length, enthalpy ",0.001)
+  ENDIF
+!FC
+  IF (ifl_pbltree>0) THEN
+!CALL get_field("FTER", pctsrf(:, is_ter), found)
+    treedrg(:,1:klev,1:nbsrf)= 0.0
+    CALL get_field("treedrg_ter", drg_ter(:,:), found)
+!  found=phyetat0_srf(treedrg,"treedrg","drag from vegetation" , 0.)
+    !lecture du profile de freinage des arbres
+    IF (.not. found ) THEN
+      treedrg(:,1:klev,1:nbsrf)= 0.0
+    ELSE
+      treedrg(:,1:klev,is_ter)= drg_ter(:,:)
+!     found=phyetat0_get(treedrg,"treedrg","freinage arbres",0.)
+    ENDIF
+  ELSE
+    ! initialize treedrg(), because it will be written in restartphy.nc
+    treedrg(:,:,:) = 0.0 
+  ENDIF
+
+  ! Lecture de l'age de la neige:
+  found=phyetat0_srf(agesno,"AGESNO","SNOW AGE",0.001)
+
+  ancien_ok=.true.
+  ancien_ok=ancien_ok.AND.phyetat0_get(t_ancien,"TANCIEN","TANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(q_ancien,"QANCIEN","QANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(ql_ancien,"QLANCIEN","QLANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(qs_ancien,"QSANCIEN","QSANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(rneb_ancien,"RNEBANCIEN","RNEBANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(u_ancien,"UANCIEN","UANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(v_ancien,"VANCIEN","VANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(prw_ancien,"PRWANCIEN","PRWANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(prlw_ancien,"PRLWANCIEN","PRLWANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(prsw_ancien,"PRSWANCIEN","PRSWANCIEN",0.)
+
+  ! Ehouarn: addtional tests to check if t_ancien, q_ancien contain
+  !          dummy values (as is the case when generated by ce0l,
+  !          or by iniaqua)
+  IF ( (maxval(q_ancien).EQ.minval(q_ancien))       .OR. &
+       (maxval(ql_ancien).EQ.minval(ql_ancien))     .OR. &
+       (maxval(qs_ancien).EQ.minval(qs_ancien))     .OR. &
+       (maxval(rneb_ancien).EQ.minval(rneb_ancien)) .OR. &
+       (maxval(prw_ancien).EQ.minval(prw_ancien))   .OR. &
+       (maxval(prlw_ancien).EQ.minval(prlw_ancien)) .OR. &
+       (maxval(prsw_ancien).EQ.minval(prsw_ancien)) .OR. &
+       (maxval(t_ancien).EQ.minval(t_ancien)) ) THEN
+    ancien_ok=.false.
+  ENDIF
+
+  found=phyetat0_get(clwcon,"CLWCON","CLWCON",0.)
+  found=phyetat0_get(rnebcon,"RNEBCON","RNEBCON",0.)
+  found=phyetat0_get(ratqs,"RATQS","RATQS",0.)
+
+  found=phyetat0_get(run_off_lic_0,"RUNOFFLIC0","RUNOFFLIC0",0.)
+
+!==================================
+!  TKE
+!==================================
+!
+  IF (iflag_pbl>1) then
+     found=phyetat0_srf(pbl_tke,"TKE","Turb. Kinetic. Energ. ",1.e-8)
+  ENDIF
+
+  IF (iflag_pbl>1 .AND. iflag_wake>=1  .AND. iflag_pbl_split >=1 ) then
+    found=phyetat0_srf(wake_delta_pbl_tke,"DELTATKE","Del TKE wk/env",0.)
+!!    found=phyetat0_srf(delta_tsurf,"DELTA_TSURF","Delta Ts wk/env ",0.)
+    found=phyetat0_srf(delta_tsurf,"DELTATS","Delta Ts wk/env ",0.)
+!!    found=phyetat0_srf(beta_aridity,"BETA_S","Aridity factor ",1.)
+    found=phyetat0_srf(beta_aridity,"BETAS","Aridity factor ",1.)
+  ENDIF   !(iflag_pbl>1 .AND. iflag_wake>=1 .AND. iflag_pbl_split >=1 )
+
+!==================================
+!  thermiques, poches, convection
+!==================================
+
+! Emanuel
+  found=phyetat0_get(sig1,"sig1","sig1",0.)
+  found=phyetat0_get(w01,"w01","w01",0.)
+
+! Wake
+  found=phyetat0_get(wake_deltat,"WAKE_DELTAT","Delta T wake/env",0.)
+  found=phyetat0_get(wake_deltaq,"WAKE_DELTAQ","Delta hum. wake/env",0.)
+  found=phyetat0_get(wake_s,"WAKE_S","Wake frac. area",0.)
+!jyg<
+!  Set wake_dens to -1000. when there is no restart so that the actual
+!  initialization is made in calwake.
+!!  found=phyetat0_get(1,wake_dens,"WAKE_DENS","Wake num. /unit area",0.)
+  found=phyetat0_get(wake_dens,"WAKE_DENS","Wake num. /unit area",-1000.)
+  found=phyetat0_get(awake_dens,"AWAKE_DENS","Active Wake num. /unit area",0.)
+  found=phyetat0_get(cv_gen,"CV_GEN","CB birth rate",0.)
+!>jyg
+  found=phyetat0_get(wake_cstar,"WAKE_CSTAR","WAKE_CSTAR",0.)
+  found=phyetat0_get(wake_pe,"WAKE_PE","WAKE_PE",0.)
+  found=phyetat0_get(wake_fip,"WAKE_FIP","WAKE_FIP",0.)
+
+! Thermiques
+  found=phyetat0_get(zmax0,"ZMAX0","ZMAX0",40.)
+  found=phyetat0_get(f0,"F0","F0",1.e-5)
+  found=phyetat0_get(fm_therm,"FM_THERM","Thermals mass flux",0.)
+  found=phyetat0_get(entr_therm,"ENTR_THERM","Thermals Entrain.",0.)
+  found=phyetat0_get(detr_therm,"DETR_THERM","Thermals Detrain.",0.)
+
+! ALE/ALP
+  found=phyetat0_get(ale_bl,"ALE_BL","ALE BL",0.)
+  found=phyetat0_get(ale_bl_trig,"ALE_BL_TRIG","ALE BL_TRIG",0.)
+  found=phyetat0_get(alp_bl,"ALP_BL","ALP BL",0.)
+  found=phyetat0_get(ale_wake,"ALE_WAKE","ALE_WAKE",0.)
+  found=phyetat0_get(ale_bl_stat,"ALE_BL_STAT","ALE_BL_STAT",0.)
+
+! fisrtilp/Clouds 0.002 could be ratqsbas. But can stay like this as well
+  found=phyetat0_get(ratqs_inter,"RATQS_INTER","Relative width of the lsc sugrid scale water",0.002)
+
+!===========================================
+  ! Read and send field trs to traclmdz
+!===========================================
+
+!--OB now this is for co2i - ThL: and therefore also for inco
+  IF (ANY(type_trac == ['co2i','inco'])) THEN
+     IF (carbon_cycle_cpl) THEN
+        ALLOCATE(co2_send(klon), stat=ierr)
+        IF (ierr /= 0) CALL abort_physic('phyetat0', 'pb allocation co2_send', 1)
+        found=phyetat0_get(co2_send,"co2_send","co2 send",co2_ppm0)
+     ENDIF
+  ELSE IF (type_trac == 'lmdz') THEN
+     it = 0
+     DO iq = 1, nqtot
+        IF(.NOT.(tracers(iq)%isAdvected .AND. tracers(iq)%isInPhysics)) CYCLE
+        it = it+1
+        tname = tracers(iq)%name
+        t(1) = 'trs_'//TRIM(tname); t(2) = 'trs_'//TRIM(new2oldH2O(tname))
+        found = phyetat0_get(trs(:,it), t(:), "Surf trac"//TRIM(tname), 0.)
+     END DO
+     CALL traclmdz_from_restart(trs)
+  ENDIF
+
+
+!===========================================
+!  ondes de gravite / relief
+!===========================================
+
+!  ondes de gravite non orographiques
+  IF (ok_gwd_rando) found = &
+       phyetat0_get(du_gwd_rando,"du_gwd_rando","du_gwd_rando",0.)
+  IF (.NOT. ok_hines .AND. ok_gwd_rando) found &
+       = phyetat0_get(du_gwd_front,"du_gwd_front","du_gwd_front",0.)
+
+!  prise en compte du relief sous-maille
+  found=phyetat0_get(zmea,"ZMEA","sub grid orography",0.)
+  found=phyetat0_get(zstd,"ZSTD","sub grid orography",0.)
+  found=phyetat0_get(zsig,"ZSIG","sub grid orography",0.)
+  found=phyetat0_get(zgam,"ZGAM","sub grid orography",0.)
+  found=phyetat0_get(zthe,"ZTHE","sub grid orography",0.)
+  found=phyetat0_get(zpic,"ZPIC","sub grid orography",0.)
+  found=phyetat0_get(zval,"ZVAL","sub grid orography",0.)
+  found=phyetat0_get(zmea,"ZMEA","sub grid orography",0.)
+  found=phyetat0_get(rugoro,"RUGSREL","sub grid orography",0.)
+
+!===========================================
+! Initialize ocean
+!===========================================
+
+  IF ( type_ocean == 'slab' ) THEN
+      CALL ocean_slab_init(phys_tstep, pctsrf)
+      IF (nslay.EQ.1) THEN
+        found=phyetat0_get(tslab,["tslab01","tslab  "],"tslab",0.)
+      ELSE
+          DO i=1,nslay
+            WRITE(str2,'(i2.2)') i
+            found=phyetat0_get(tslab(:,i),"tslab"//str2,"tslab",0.)  
+          ENDDO
+      ENDIF
+      IF (.NOT. found) THEN 
+          PRINT*, "phyetat0: Le champ <tslab> est absent"
+          PRINT*, "Initialisation a tsol_oce"
+          DO i=1,nslay
+              tslab(:,i)=MAX(ftsol(:,is_oce),271.35)
+          ENDDO
+      ENDIF 
+
+      ! Sea ice variables
+      IF (version_ocean == 'sicINT') THEN
+          found=phyetat0_get(tice,"slab_tice","slab_tice",0.)
+          IF (.NOT. found) THEN 
+              PRINT*, "phyetat0: Le champ <tice> est absent"
+              PRINT*, "Initialisation a tsol_sic"
+                  tice(:)=ftsol(:,is_sic)
+          ENDIF 
+          found=phyetat0_get(seaice,"seaice","seaice",0.)
+          IF (.NOT. found) THEN
+              PRINT*, "phyetat0: Le champ <seaice> est absent"
+              PRINT*, "Initialisation a 0/1m suivant fraction glace"
+              seaice(:)=0.
+              WHERE (pctsrf(:,is_sic).GT.EPSFRA)
+                  seaice=917.
+              ENDWHERE
+          ENDIF
+      ENDIF !sea ice INT
+  ENDIF ! Slab        
+
+  if (activate_ocean_skin >= 1) then
+     if (activate_ocean_skin == 2 .and. type_ocean == 'couple') then
+        found = phyetat0_get(delta_sal, "delta_sal", &
+             "ocean-air interface salinity minus bulk salinity", 0.)
+        found = phyetat0_get(delta_sst, "delta_SST", &
+             "ocean-air interface temperature minus bulk SST", 0.)
+        found = phyetat0_get(dter, "dter", &
+             "ocean-air interface temperature minus subskin temperature", 0.)
+        found = phyetat0_get(dser, "dser", &
+             "ocean-air interface salinity minus subskin salinity", 0.)
+        found = phyetat0_get(dt_ds, "dt_ds", "(tks / tkt) * dTer", 0.)
+
+        where (pctsrf(:, is_oce) == 0.)
+           delta_sst = missing_val
+           delta_sal = missing_val
+           dter = missing_val
+           dser = missing_val
+           dt_ds = missing_val
+        end where
+     end if
+     
+     found = phyetat0_get(ds_ns, "dS_ns", "delta salinity near surface", 0.)
+     found = phyetat0_get(dt_ns, "dT_ns", "delta temperature near surface", &
+          0.)
+
+     where (pctsrf(:, is_oce) == 0.)
+        ds_ns = missing_val
+        dt_ns = missing_val
+        delta_sst = missing_val
+        delta_sal = missing_val
+     end where
+  end if
+
+  ! on ferme le fichier
+  CALL close_startphy
+
+  ! Initialize module pbl_surface_mod 
+
+  CALL pbl_surface_init(fder, snow, qsurf, tsoil)
+
+  ! Initialize module ocean_cpl_mod for the case of coupled ocean
+  IF ( type_ocean == 'couple' ) THEN
+     CALL ocean_cpl_init(phys_tstep, longitude_deg, latitude_deg)
+  ENDIF
+
+!  CALL init_iophy_new(latitude_deg, longitude_deg)
+
+  ! Initilialize module fonte_neige_mod      
+  CALL fonte_neige_init(run_off_lic_0)
+
+END SUBROUTINE phyetat0
+
+END MODULE phyetat0_mod
+
Index: LMDZ6/branches/Portage_acc/libf/phylmd/phyredem.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/phyredem.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/phyredem.F90	(revision 4446)
@@ -30,5 +30,5 @@
                                 du_gwd_rando, du_gwd_front, u10m, v10m, &
                                 treedrg, solswfdiff, delta_sal, ds_ns, dt_ns, &
-                                delta_sst, ratqs_inter
+                                delta_sst, ratqs_inter, dter, dser, dt_ds
 
   USE geometry_mod, ONLY : longitude_deg, latitude_deg
@@ -36,5 +36,5 @@
   USE traclmdz_mod, ONLY : traclmdz_to_restart
   USE infotrac_phy, ONLY: type_trac, nqtot, tracers, nbtr
-  USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, co2_send
+  USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, co2_send, carbon_cycle_rad, RCO2_glo
   USE indice_sol_mod, ONLY: nbsrf, is_oce, is_sic, is_ter, is_lic, epsfra
   USE surface_data, ONLY: type_ocean, version_ocean
@@ -108,5 +108,10 @@
 
   ! co2_ppm0 : initial value of atmospheric CO2
-  tab_cntrl(16) = co2_ppm0
+  ! tab_cntrl(16) = co2_ppm0
+
+  !  PC -- initial value of RCO2 for the radiation scheme
+  !  tab_cntrl(17) = co2_ppm * 1.0e-06 * RMCO2 / RMD
+  IF (carbon_cycle_rad) tab_cntrl(17) = RCO2_glo
+  !PRINT*, "PC : phyredem RCO2_glo =",RCO2_glo
 
   DO pass=1,2   ! pass=1 netcdf definition ; pass=2 netcdf write
@@ -140,5 +145,4 @@
 
     CALL put_field(pass,"FLIC", "fraction glace de terre", pctsrf(:, is_lic))
-
     ! 3. fraction ocean
 
@@ -325,16 +329,5 @@
 
 
-    ! trs from traclmdz_mod
-    IF (type_trac == 'lmdz') THEN
-       CALL traclmdz_to_restart(trs)
-       it = 0
-       DO iq = 1, nqtot
-          IF(.NOT.(tracers(iq)%isAdvected .AND. tracers(iq)%isInPhysics)) CYCLE
-          it = it+1
-          CALL put_field(pass,"trs_"//tracers(iq)%name, "", trs(:, it))
-       END DO
-    END IF
-
-    IF (type_trac == 'co2i' .OR. type_trac == 'inco') THEN
+    IF (ANY(type_trac == ['co2i','inco'])) THEN
        IF (carbon_cycle_cpl) THEN
           IF (.NOT. ALLOCATED(co2_send)) THEN
@@ -345,4 +338,14 @@
           CALL put_field(pass,"co2_send", "co2_ppm for coupling", co2_send)
        END IF
+
+    ! trs from traclmdz_mod
+    ELSE IF (type_trac == 'lmdz') THEN
+       CALL traclmdz_to_restart(trs)
+       it = 0
+       DO iq = 1, nqtot
+          IF(.NOT.(tracers(iq)%isAdvected .AND. tracers(iq)%isInPhysics)) CYCLE
+          it = it+1
+          CALL put_field(pass,"trs_"//tracers(iq)%name, "", trs(:, it))
+       END DO
     END IF
 
@@ -375,4 +378,11 @@
           CALL put_field(pass, "delta_SST", &
                "ocean-air interface temperature minus bulk SST", delta_sst)
+          CALL put_field(pass, "dter", &
+               "ocean-air interface temperature minus subskin temperature", &
+               dter)
+          CALL put_field(pass, "dser", &
+               "ocean-air interface salinity minus subskin salinity", dser)
+          CALL put_field(pass, "dt_ds", &
+               "(tks / tkt) * dTer", dt_ds)
        end if
        
Index: LMDZ6/branches/Portage_acc/libf/phylmd/phys_cal_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/phys_cal_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/phys_cal_mod.F90	(revision 4446)
@@ -51,5 +51,5 @@
     IF (is_omp_master) THEN
       IF (calend == 'earth_360d') THEN
-        CALL ioconf_calendar('360d')
+        CALL ioconf_calendar('360_day')
       ELSE IF (calend == 'earth_365d') THEN
         CALL ioconf_calendar('noleap')
Index: LMDZ6/branches/Portage_acc/libf/phylmd/phys_output_ctrlout_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 4446)
@@ -1413,7 +1413,7 @@
     'ec550aer', 'Extinction at 550nm', 'm^-1', (/ ('', i=1, 10) /))
   TYPE(ctrl_out), SAVE :: o_lwcon = ctrl_out((/ 2, 5, 10, 10, 10, 10, 11, 11, 11, 11/), &
-    'lwcon', 'Cloud liquid water content', 'kg/kg', (/ ('', i=1, 10) /))
+    'lwcon', 'Cloud liquid water content seen by radiation', 'kg/kg', (/ ('', i=1, 10) /))
   TYPE(ctrl_out), SAVE :: o_iwcon = ctrl_out((/ 2, 5, 10, 10, 10, 10, 11, 11, 11, 11/), &
-    'iwcon', 'Cloud ice water content', 'kg/kg', (/ ('', i=1, 10) /))
+    'iwcon', 'Cloud ice water content seen by radiation', 'kg/kg', (/ ('', i=1, 10) /))
   TYPE(ctrl_out), SAVE :: o_temp = ctrl_out((/ 2, 3, 4, 10, 10, 10, 11, 11, 11, 11/), &
     'temp', 'Air temperature', 'K', (/ ('', i=1, 10) /))
Index: LMDZ6/branches/Portage_acc/libf/phylmd/phys_output_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/phys_output_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/phys_output_mod.F90	(revision 4446)
@@ -35,5 +35,5 @@
     USE iophy 
     USE dimphy
-    USE infotrac_phy, ONLY: nqtot, tracers, type_trac, niso, ntraciso
+    USE infotrac_phy, ONLY: nqtot, tracers, niso
     USE strings_mod,  ONLY: maxlen
     USE ioipsl
@@ -45,5 +45,5 @@
     USE mod_grid_phy_lmdz, only: klon_glo,nbp_lon,nbp_lat
     USE print_control_mod, ONLY: prt_level,lunout
-    USE vertical_layers_mod, ONLY: ap,bp,preff,presnivs, aps, bps, pseudoalt
+    USE vertical_layers_mod, ONLY: ap,bp,preff,presnivs, aps, bps, pseudoalt, presinter
     USE time_phylmdz_mod, ONLY: day_ini, itau_phy, start_time, annee_ref, day_ref
 #ifdef CPP_XIOS
@@ -347,4 +347,6 @@
     CALL wxios_add_vaxis("presnivs", &
             levmax(iff) - levmin(iff) + 1, presnivs(levmin(iff):levmax(iff)))
+    CALL wxios_add_vaxis("presinter", &
+            klev + 1, presinter(1:klev+1))
     CALL wxios_add_vaxis("Ahyb", &
             levmax(iff) - levmin(iff) + 1, aps(levmin(iff):levmax(iff)), positif='down', &
Index: LMDZ6/branches/Portage_acc/libf/phylmd/phys_output_var_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/phys_output_var_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/phys_output_var_mod.F90	(revision 4446)
@@ -135,25 +135,17 @@
   ! Ocean-atmosphere interface, subskin ocean and near-surface ocean:
   
-  REAL, ALLOCATABLE, SAVE:: dter(:)
-  ! Temperature variation in the diffusive microlayer, that is
-  ! ocean-air interface temperature minus subskin temperature. In K.
-      
-  REAL, SAVE, ALLOCATABLE:: dser(:)
-  ! Temperature variation in the diffusive microlayer, that is
-  ! subskin temperature minus ocean-air interface temperature. In K.
-
-  REAL, SAVE, ALLOCATABLE:: tkt(:)
+  REAL, SAVE, ALLOCATABLE:: tkt(:) ! (klon)
   ! épaisseur (m) de la couche de diffusion thermique (microlayer)
   ! cool skin thickness
 
-  REAL, SAVE, ALLOCATABLE:: tks(:)
+  REAL, SAVE, ALLOCATABLE:: tks(:) ! (klon)
   ! épaisseur (m) de la couche de diffusion de masse (microlayer)
   
-  REAL, SAVE, ALLOCATABLE:: taur(:) ! momentum flux due to rain, in Pa
-
-  REAL, SAVE, ALLOCATABLE:: sss(:)
+  REAL, SAVE, ALLOCATABLE:: taur(:) ! (klon) momentum flux due to rain, in Pa
+
+  REAL, SAVE, ALLOCATABLE:: sss(:) ! (klon)
   ! bulk salinity of the surface layer of the ocean, in ppt
   
-  !$OMP THREADPRIVATE(dter, dser, tkt, tks, taur, sss)
+  !$OMP THREADPRIVATE(tkt, tks, taur, sss)
 
 CONTAINS
@@ -216,6 +208,6 @@
     IF (ok_gwd_rando) allocate(zustr_gwd_rando(klon), zvstr_gwd_rando(klon))
 
-    if (activate_ocean_skin >= 1) allocate(dter(klon), dser(klon), tkt(klon), &
-         tks(klon), taur(klon), sss(klon))
+    if (activate_ocean_skin >= 1) allocate(tkt(klon), tks(klon), taur(klon), &
+         sss(klon))
 
   END SUBROUTINE phys_output_var_init
Index: LMDZ6/branches/Portage_acc/libf/phylmd/phys_output_write_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/phys_output_write_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/phys_output_write_mod.F90	(revision 4446)
@@ -25,5 +25,5 @@
 
     USE dimphy, ONLY: klon, klev, klevp1
-    USE infotrac_phy, ONLY: nbtr, nqtot, nqo, type_trac, tracers, niso, ntraciso
+    USE infotrac_phy, ONLY: nbtr, nqtot, nqo, type_trac, tracers, niso, ntiso
     USE strings_mod,  ONLY: maxlen
     USE mod_phys_lmdz_para, ONLY: is_north_pole_phy,is_south_pole_phy
@@ -271,5 +271,5 @@
         xtrain_con, xtsnow_con, xtrain_fall, xtsnow_fall, &
 #endif
-         dt_ns, delta_sst
+         dt_ns, delta_sst, dter, dser
 
     USE phys_local_var_mod, ONLY: zxfluxlat, slp, ptstar, pt0, zxtsol, zt2m, &
@@ -390,5 +390,5 @@
          alt_tropo, &
 !Ionela
-         ok_4xCO2atm, dter, dser, tkt, tks, taur, sss
+         ok_4xCO2atm, tkt, tks, taur, sss
 
     USE ocean_slab_mod, ONLY: nslay, tslab, slab_bilg, tice, seaice, &
@@ -481,4 +481,5 @@
 #ifdef CPP_StratAer 
     LOGICAL, PARAMETER :: debug_strataer=.FALSE.
+    CHARACTER(LEN=maxlen) :: unt
 #endif
     REAL,DIMENSION(klon,klev) :: z, dz
@@ -942,5 +943,5 @@
        CALL histwrite_phy(o_SWupTOAclr, zx_tmp_fi2d)
 
-       IF ((type_trac/='inca') .OR. (config_inca=='aeNP')) THEN 
+       IF (type_trac/='inca' .OR. config_inca=='aeNP') THEN 
           IF (vars_defined) THEN
              zx_tmp_fi2d(:) = swupc0(:,klevp1)*swradcorr(:)
@@ -1014,5 +1015,5 @@
        CALL histwrite_phy(o_SWupSFCclr, zx_tmp_fi2d)
 
-       IF ((type_trac/='inca') .OR. (config_inca=='aeNP')) THEN 
+       IF (type_trac/='inca' .OR. config_inca=='aeNP') THEN 
           IF (vars_defined) THEN
              zx_tmp_fi2d(:) = swupc0(:,1)*swradcorr(:)
@@ -1031,5 +1032,5 @@
        CALL histwrite_phy(o_SWdnSFCclr, zx_tmp_fi2d)
 
-       IF ((type_trac/='inca') .OR. (config_inca=='aeNP')) THEN 
+       IF (type_trac/='inca' .OR. config_inca=='aeNP') THEN 
           IF (vars_defined) THEN
              zx_tmp_fi2d(:) = swdnc0(:,1)*swradcorr(:)
@@ -1053,5 +1054,5 @@
        CALL histwrite_phy(o_LWdnSFCclr, sollwdownclr)
 
-       IF ((type_trac/='inca') .OR. (config_inca=='aeNP')) THEN 
+       IF (type_trac/='inca' .OR. config_inca=='aeNP') THEN 
           IF (vars_defined) THEN
              zx_tmp_fi2d(:) = lwupc0(:,klevp1)
@@ -1060,5 +1061,5 @@
        ENDIF
 
-       IF ((type_trac/='inca') .OR. (config_inca=='aeNP')) THEN 
+       IF (type_trac/='inca' .OR. config_inca=='aeNP') THEN 
           IF (vars_defined) THEN
              zx_tmp_fi2d(:) = -1.*lwdnc0(:,1)
@@ -1569,5 +1570,5 @@
 !This is warranted by treating INCA aerosols as offline aerosols
        IF (flag_aerosol.GT.0) THEN
-          IF ((type_trac/='inca') .OR. (config_inca=='aeNP')) THEN 
+          IF (type_trac/='inca' .OR. config_inca=='aeNP') THEN 
 
              CALL histwrite_phy(o_od443aer, od443aer)
@@ -1692,5 +1693,5 @@
           CALL histwrite_phy(o_solswad0, zx_tmp_fi2d)
           
-          IF ((type_trac/='inca') .OR. (config_inca=='aeNP')) THEN 
+          IF (type_trac/='inca' .OR. config_inca=='aeNP') THEN 
 
              CALL histwrite_phy(o_toplwad, toplwad_aero)
@@ -1769,5 +1770,5 @@
        ! Champs 3D:
        IF (ok_ade .OR. ok_aie) then
-          IF ((type_trac/='inca') .OR. (config_inca=='aeNP')) THEN 
+          IF (type_trac/='inca' .OR. config_inca=='aeNP') THEN 
              CALL histwrite_phy(o_ec550aer, ec550aer)
           ENDIF
@@ -2228,5 +2229,5 @@
        CALL histwrite_phy(o_rsucs, zx_tmp_fi3d1)
 
-       IF ((type_trac/='inca') .OR. (config_inca=='aeNP')) THEN 
+       IF (type_trac/='inca' .OR. config_inca=='aeNP') THEN 
           IF (vars_defined) THEN
              DO k=1, klevp1
@@ -2244,5 +2245,5 @@
        CALL histwrite_phy(o_rsdcs, zx_tmp_fi3d1)
 
-       IF ((type_trac/='inca') .OR. (config_inca=='aeNP')) THEN 
+       IF (type_trac/='inca' .OR. config_inca=='aeNP') THEN 
           IF (vars_defined) THEN
              DO k=1, klevp1
@@ -2489,5 +2490,64 @@
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        IF (iflag_phytrac == 1 ) then
-         IF (type_trac == 'lmdz' .OR. type_trac == 'coag') THEN
+!
+         IF (type_trac == 'co2i') THEN
+           itr = 0
+           DO iq = 1, nqtot
+             IF(.NOT.tracers(iq)%isInPhysics) CYCLE
+             itr = itr + 1
+!            write(*,*) 'phys_output_write_mod 2370: itr=',itr
+             !--3D fields
+             CALL histwrite_phy(o_trac(itr), tr_seri(:,:,itr))
+             CALL histwrite_phy(o_dtr_vdf(itr),d_tr_cl(:,:,itr))
+             CALL histwrite_phy(o_dtr_the(itr),d_tr_th(:,:,itr))
+             CALL histwrite_phy(o_dtr_con(itr),d_tr_cv(:,:,itr))
+             !--2D fields
+             !--CO2 burden
+             zx_tmp_fi2d=0.
+             IF (vars_defined) THEN
+                DO k=1,klev
+                   zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+zmasse(:,k)*tr_seri(:,k,itr)
+                ENDDO
+             ENDIF
+             CALL histwrite_phy(o_trac_cum(itr), zx_tmp_fi2d)
+           ENDDO !--iq
+           !--CO2 net fluxes
+           CALL histwrite_phy(o_flx_co2_land,  fco2_land)
+           CALL histwrite_phy(o_flx_co2_ocean, fco2_ocean)
+           CALL histwrite_phy(o_flx_co2_ocean_cor, fco2_ocean_cor)
+           CALL histwrite_phy(o_flx_co2_land_cor, fco2_land_cor)
+           CALL histwrite_phy(o_flx_co2_ff,    fco2_ff)
+           CALL histwrite_phy(o_flx_co2_bb,    fco2_bb)
+
+         ELSE IF (type_trac == 'inco') THEN
+           itr = 0
+           DO iq = 1, nqtot
+             IF(.NOT.tracers(iq)%isInPhysics) CYCLE
+             itr = itr+1
+             IF(tracers(iq)%component /= 'co2i') CYCLE
+             !--3D fields
+             CALL histwrite_phy(o_trac   (itr),tr_seri(:,:,itr))
+             CALL histwrite_phy(o_dtr_vdf(itr),d_tr_cl(:,:,itr))
+             CALL histwrite_phy(o_dtr_the(itr),d_tr_th(:,:,itr))
+             CALL histwrite_phy(o_dtr_con(itr),d_tr_cv(:,:,itr))
+             !--2D fields
+             !--CO2 burden
+             zx_tmp_fi2d=0.
+             IF (vars_defined) THEN
+                DO k=1,klev
+                   zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+zmasse(:,k)*tr_seri(:,k,itr)
+                ENDDO
+             ENDIF
+             CALL histwrite_phy(o_trac_cum(itr), zx_tmp_fi2d)
+           ENDDO !--iq
+           !--CO2 net fluxes
+           CALL histwrite_phy(o_flx_co2_land,  fco2_land)
+           CALL histwrite_phy(o_flx_co2_ocean, fco2_ocean)
+           CALL histwrite_phy(o_flx_co2_ocean_cor, fco2_ocean_cor)
+           CALL histwrite_phy(o_flx_co2_land_cor, fco2_land_cor)
+           CALL histwrite_phy(o_flx_co2_ff,    fco2_ff)
+           CALL histwrite_phy(o_flx_co2_bb,    fco2_bb)
+
+         ELSE IF (ANY(type_trac==['lmdz','coag'])) THEN
            itr = 0
            DO iq = 1, nqtot
@@ -2521,65 +2581,4 @@
            ENDDO !--iq
          ENDIF   !--type_trac
-!
-         IF (type_trac == 'co2i') THEN
-           itr = 0
-           DO iq = 1, nqtot
-             IF(.NOT.tracers(iq)%isInPhysics) CYCLE
-             itr = itr + 1
-!            write(*,*) 'phys_output_write_mod 2370: itr=',itr
-             !--3D fields
-             CALL histwrite_phy(o_trac(itr), tr_seri(:,:,itr))
-             CALL histwrite_phy(o_dtr_vdf(itr),d_tr_cl(:,:,itr))
-             CALL histwrite_phy(o_dtr_the(itr),d_tr_th(:,:,itr))
-             CALL histwrite_phy(o_dtr_con(itr),d_tr_cv(:,:,itr))
-             !--2D fields
-             !--CO2 burden
-             zx_tmp_fi2d=0.
-             IF (vars_defined) THEN
-                DO k=1,klev
-                   zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+zmasse(:,k)*tr_seri(:,k,itr)
-                ENDDO
-             ENDIF
-             CALL histwrite_phy(o_trac_cum(itr), zx_tmp_fi2d)
-           ENDDO !--iq
-           !--CO2 net fluxes
-           CALL histwrite_phy(o_flx_co2_land,  fco2_land)
-           CALL histwrite_phy(o_flx_co2_ocean, fco2_ocean)
-           CALL histwrite_phy(o_flx_co2_ocean_cor, fco2_ocean_cor)
-           CALL histwrite_phy(o_flx_co2_land_cor, fco2_land_cor)
-           CALL histwrite_phy(o_flx_co2_ff,    fco2_ff)
-           CALL histwrite_phy(o_flx_co2_bb,    fco2_bb)
-         ENDIF !--type_trac co2i
-
-         IF (type_trac == 'inco') THEN
-           itr = 0
-           DO iq = 1, nqtot
-             IF(.NOT.tracers(iq)%isInPhysics) CYCLE
-             itr = itr+1
-             IF(tracers(iq)%component /= 'co2i') CYCLE
-             !--3D fields
-             CALL histwrite_phy(o_trac   (itr),tr_seri(:,:,itr))
-             CALL histwrite_phy(o_dtr_vdf(itr),d_tr_cl(:,:,itr))
-             CALL histwrite_phy(o_dtr_the(itr),d_tr_th(:,:,itr))
-             CALL histwrite_phy(o_dtr_con(itr),d_tr_cv(:,:,itr))
-             !--2D fields
-             !--CO2 burden
-             zx_tmp_fi2d=0.
-             IF (vars_defined) THEN
-                DO k=1,klev
-                   zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+zmasse(:,k)*tr_seri(:,k,itr)
-                ENDDO
-             ENDIF
-             CALL histwrite_phy(o_trac_cum(itr), zx_tmp_fi2d)
-           ENDDO !--iq
-           !--CO2 net fluxes
-           CALL histwrite_phy(o_flx_co2_land,  fco2_land)
-           CALL histwrite_phy(o_flx_co2_ocean, fco2_ocean)
-           CALL histwrite_phy(o_flx_co2_ocean_cor, fco2_ocean_cor)
-           CALL histwrite_phy(o_flx_co2_land_cor, fco2_land_cor)
-           CALL histwrite_phy(o_flx_co2_ff,    fco2_ff)
-           CALL histwrite_phy(o_flx_co2_bb,    fco2_bb)
-         ENDIF !--type_trac inco
-
        ENDIF   !(iflag_phytrac==1)
 
@@ -2598,5 +2597,5 @@
 
 #ifdef ISO
-    do ixt=1,ntraciso
+    do ixt=1,ntiso
 !        write(*,*) 'ixt'
         IF (vars_defined) zx_tmp_fi2d(:) = xtrain_fall(ixt,:) + xtsnow_fall(ixt,:)
@@ -2652,5 +2651,5 @@
 
     !write(*,*) 'phys_output_write_mod 2531'
-    enddo !do ixt=1,ntraciso    
+    enddo
 #endif
 
Index: LMDZ6/branches/Portage_acc/libf/phylmd/phys_state_var_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/phys_state_var_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/phys_state_var_mod.F90	(revision 4446)
@@ -491,5 +491,16 @@
       ! Ocean-air interface salinity minus bulk salinity, in ppt
       
-      !$OMP THREADPRIVATE(delta_sal, ds_ns, dt_ns, delta_sst)
+      REAL, ALLOCATABLE, SAVE:: dter(:) ! (klon)
+      ! Temperature variation in the diffusive microlayer, that is
+      ! ocean-air interface temperature minus subskin temperature. In K.
+
+      REAL, SAVE, ALLOCATABLE:: dser(:) ! (klon)
+      ! Salinity variation in the diffusive microlayer, that is
+      ! ocean-air interface salinity minus subskin salinity. In ppt.
+
+      real, SAVE, ALLOCATABLE:: dt_ds(:) ! (klon)
+      ! (tks / tkt) * dTer, in K
+
+      !$OMP THREADPRIVATE(delta_sal, ds_ns, dt_ns, delta_sst, dter, dser, dt_ds)
 
     CONTAINS
@@ -501,8 +512,9 @@
 USE infotrac_phy, ONLY : nbtr
 #ifdef ISO
-USE infotrac_phy, ONLY : ntraciso,niso
+USE infotrac_phy, ONLY : ntraciso=>ntiso,niso
 #endif
 USE indice_sol_mod
 use config_ocean_skin_m, only: activate_ocean_skin
+use surface_data, only: type_ocean
 IMPLICIT NONE
 
@@ -562,4 +574,8 @@
       ALLOCATE(coefh(klon,klev+1,nbsrf+1))
       ALLOCATE(coefm(klon,klev+1,nbsrf+1))
+      ! initialize cleanly coefh,coefm
+      ! (most of the time in the code these are assumed to be on klev levels)
+      coefh(:,:,:)=0
+      coefm(:,:,:)=0
       ALLOCATE(zmax0(klon), f0(klon))
       ALLOCATE(sig1(klon,klev), w01(klon,klev))
@@ -724,6 +740,11 @@
         du_gwd_front(:,:) = 0 !ym missing init   
       ENDIF
-      if (activate_ocean_skin >= 1) ALLOCATE(delta_sal(klon), ds_ns(klon), &
-           dt_ns(klon), delta_sst(klon))
+
+      if (activate_ocean_skin >= 1) then
+         ALLOCATE(delta_sal(klon), ds_ns(klon), dt_ns(klon), delta_sst(klon), &
+              dter(klon), dser(klon))
+         if (activate_ocean_skin == 2 .and. type_ocean == "couple") &
+              allocate(dt_ds(klon))
+      end if
 
     END SUBROUTINE phys_state_var_init
@@ -735,4 +756,5 @@
 USE indice_sol_mod
 use config_ocean_skin_m, only: activate_ocean_skin
+use surface_data, only: type_ocean
 IMPLICIT NONE
 include "clesphys.h"
@@ -863,6 +885,9 @@
       DEALLOCATE(ratqs_inter)
 
-      if (activate_ocean_skin >= 1) deALLOCATE(delta_sal, ds_ns, dt_ns, &
-           delta_sst)
+      if (activate_ocean_skin >= 1) then
+         deALLOCATE(delta_sal, ds_ns, dt_ns, delta_sst, dter, dser)
+         if (activate_ocean_skin == 2 .and. type_ocean == "couple") &
+              deALLOCATE(dt_ds)
+      end if
 
 #ifdef ISO    
Index: LMDZ6/branches/Portage_acc/libf/phylmd/physiq_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/physiq_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/physiq_mod.F90	(revision 4446)
@@ -34,6 +34,5 @@
     USE FLOTT_GWD_rando_m, only: FLOTT_GWD_rando
     USE fonte_neige_mod, ONLY  : fonte_neige_get_vars
-    USE geometry_mod, ONLY: cell_area, latitude_deg, longitude_deg, longitude,latitude, &
-         boundslon,boundslat, dx, dy, ind_cell_glo
+    USE geometry_mod, ONLY: cell_area, latitude_deg, longitude_deg
     USE indice_sol_mod, ONLY: nbsrf,is_ave, is_ter, is_oce, is_lic, is_sic 
 !    USE ioipsl, ONLY : histbeg, histvert, histdef, histend, histsync
@@ -42,5 +41,5 @@
     USE ioipsl_getin_p_mod, ONLY : getin_p
 !    USE indice_sol_mod
-    USE infotrac_phy, ONLY: nqtot, nbtr, nqo, tracers, type_trac, nqCO2
+    USE infotrac_phy, ONLY: nqtot, nbtr, nqo, tracers, type_trac
     USE readTracFiles_mod, ONLY: addPhase
     USE strings_mod,  ONLY: strIdx
@@ -56,4 +55,5 @@
     USE pbl_surface_mod, ONLY : pbl_surface
     USE phyaqua_mod, only: zenang_an
+    USE phyetat0_mod, only: phyetat0
     USE phystokenc_mod, ONLY: offline, phystokenc
     USE phys_cal_mod, only: year_len, mth_len, days_elapsed, jh_1jan, &
@@ -127,16 +127,18 @@
     USE regr_horiz_time_climoz_m, ONLY: regr_horiz_time_climoz
     USE regr_pr_time_av_m, only: regr_pr_time_av
-    USE surface_data,     ONLY : type_ocean, ok_veget, landice_opt
-    USE time_phylmdz_mod, only: annee_ref, current_time, day_ini, day_ref, &
-          day_step_phy, itau_phy, pdtphys, raz_date, start_time, update_time, ndays
+    USE surface_data,     ONLY : type_ocean, ok_veget
+    USE time_phylmdz_mod, only: current_time, itau_phy, pdtphys, raz_date, update_time
     USE tracinca_mod, ONLY: config_inca
     USE tropopause_m,     ONLY: dyn_tropopause
     USE ice_sursat_mod,  ONLY: flight_init, airplane
 !    USE vampir
-    USE VERTICAL_LAYERS_MOD, ONLY: aps,bps, ap, bp
     USE write_field_phy, ONLY : writefield_phy
+#ifdef CPP_XIOS
+    USE wxios, ONLY: g_ctx, wxios_set_context
+#endif
     USE lscp_mod, ONLY : lscp
     USE wake_ini_mod, ONLY : wake_ini
     USE thermcell_ini_mod, ONLY : thermcell_ini
+    USE lscp_ini_mod, ONLY : lscp_ini
 
     !USE cmp_seri_mod
@@ -156,8 +158,16 @@
 
 
+#ifdef INCA
+    USE geometry_mod,      ONLY: longitude, latitude, boundslon, boundslat, ind_cell_glo
+    USE time_phylmdz_mod,  ONLY: ndays
+    USE infotrac_phy,      ONLY: nqCO2
+#endif
 #ifdef REPROBUS
-    USE CHEM_REP, ONLY : Init_chem_rep_xjour, &
-         d_q_rep,d_ql_rep,d_qi_rep,ptrop,ttrop, &
-         ztrop, gravit,itroprep, Z1,Z2,fac,B
+    USE chem_rep, ONLY: Init_chem_rep_xjour, d_q_rep, d_ql_rep, d_qi_rep, &
+                        ptrop, ttrop, ztrop, gravit, itroprep, Z1, Z2, fac, B
+#endif
+#if defined INCA || defined REPROBUS
+    USE time_phylmdz_mod,    ONLY: annee_ref, day_ini, day_ref, start_time
+    USE vertical_layers_mod, ONLY: aps, bps, ap, bp
 #endif
 
@@ -165,5 +175,5 @@
 #ifdef CPP_RRTM
     USE YOERAD, ONLY : NRADLP
-    USE YOESW, ONLY : RSUN
+!    USE YOESW, ONLY : RSUN
 #endif
 
@@ -175,6 +185,7 @@
 
 #ifdef CPP_XIOS
-    USE xios, ONLY: xios_update_calendar, xios_context_finalize, &
-            xios_get_field_attr, xios_field_is_active
+    USE xios, ONLY: xios_update_calendar, xios_context_finalize
+    USE xios, ONLY: xios_get_field_attr, xios_field_is_active, xios_context
+    USE xios, ONLY: xios_set_current_context
     USE wxios, ONLY: missing_val, missing_val_omp
 #endif
@@ -200,6 +211,6 @@
        d_t_ajsb,d_q_ajsb, &
        d_t_ajs,d_q_ajs,d_u_ajs,d_v_ajs, &
-       d_t_ajs_w,d_q_ajs_w, &
-       d_t_ajs_x,d_q_ajs_x, &
+!       d_t_ajs_w,d_q_ajs_w, &
+!       d_t_ajs_x,d_q_ajs_x, &
        !
        d_t_eva,d_q_eva,d_ql_eva,d_qi_eva, &
@@ -214,5 +225,5 @@
        d_ts, &
        !
-       d_t_oli,d_u_oli,d_v_oli, &
+!       d_t_oli,d_u_oli,d_v_oli, &
        d_t_oro,d_u_oro,d_v_oro, &
        d_t_oro_gw,d_u_oro_gw,d_v_oro_gw, &
@@ -333,4 +344,8 @@
        sij, &
        !
+       rneblsvol, &
+       zqsatl, zqsats, &
+       qclr, qcld, qss, qvc, rnebclr, rnebss, gamma_ss, &
+       Tcontr, qcontr, qcontr2, fcontrN, fcontrP, &
        cldemi,  &
        cldfra, cldtau, fiwc,  &
@@ -359,5 +374,4 @@
        zxsnow,snowhgt,qsnow,to_ice,sissnow,runoff,albsol3_lic
        !
-
 
     IMPLICIT NONE
@@ -502,12 +516,7 @@
     !======================================================================
     !
-    INTEGER ivap          ! indice de traceurs pour vapeur d'eau
-    PARAMETER (ivap=1)
-    INTEGER iliq          ! indice de traceurs pour eau liquide
-    PARAMETER (iliq=2)
-    INTEGER isol          ! indice de traceurs pour eau glace
-    PARAMETER (isol=3)
-    INTEGER irneb         ! indice de traceurs pour fraction nuageuse LS (optional)
-    PARAMETER (irneb=4)   
+    ! indices de traceurs eau vapeur, liquide, glace, fraction nuageuse LS (optional)
+    INTEGER,SAVE :: ivap, iliq, isol, irneb
+!$OMP THREADPRIVATE(ivap, iliq, isol, irneb)
     !
     !
@@ -578,5 +587,4 @@
     !
     !
-    INTEGER debug
     INTEGER n
     !ym      INTEGER npoints
@@ -635,5 +643,5 @@
     ! Upmost level reached by deep convection and related variable (jyg)
     !
-    INTEGER izero
+!    INTEGER izero
     INTEGER k_upper_cv
     !------------------------------------------------------------------
@@ -805,5 +813,4 @@
     REAL beta_prec_fisrt(klon,klev) ! taux de conv de l'eau cond (fisrt)
     ! RomP <<<
-    REAL          :: calday
 
     !IM cf FH pour Tiedtke 080604
@@ -859,5 +866,4 @@
     !C      EXTERNAL o3cm      ! initialiser l'ozone
     EXTERNAL orbite    ! calculer l'orbite terrestre
-    EXTERNAL phyetat0  ! lire l'etat initial de la physique
     EXTERNAL phyredem  ! ecrire l'etat de redemarrage de la physique
     EXTERNAL suphel    ! initialiser certaines constantes
@@ -880,5 +886,5 @@
     REAL dialiq(klon,klev)  ! eau liquide nuageuse
     REAL diafra(klon,klev)  ! fraction nuageuse
-    REAL cldliq(klon,klev)  ! eau liquide nuageuse
+    REAL radocond(klon,klev)  ! eau condensee nuageuse
     !
     !XXX PB 
@@ -903,7 +909,4 @@
     REAL conv_t(klon,klev) ! convergence de la temperature(K/s)
     !
-#ifdef INCA
-    REAL zxsnow_dummy(klon)
-#endif
     REAL zsav_tsol(klon)
     !
@@ -920,5 +923,5 @@
     real zqsat(klon,klev)
     !
-    INTEGER i, k, iq, j, nsrf, ll, l, itr
+    INTEGER i, k, iq, nsrf, l, itr
     !
     REAL t_coup
@@ -1029,4 +1032,5 @@
 
     REAL picefra(klon,klev)
+    REAL zrel_mount(klon)
     !IM cf. AM 081204 END
     !
@@ -1235,4 +1239,5 @@
 
 #ifdef INCA
+    REAL :: calday, zxsnow_dummy(klon)
     ! set de variables utilisees pour l'initialisation des valeurs provenant de INCA
     REAL, DIMENSION(klon,klev,naero_grp,nbands) :: init_tauinca
@@ -1292,5 +1297,9 @@
     phys_tstep=NINT(pdtphys)
 #ifdef CPP_XIOS
-    IF (.NOT. debut .AND. is_omp_master) CALL xios_update_calendar(itap+1)
+! switch to XIOS LMDZ physics context 
+    IF (.NOT. debut .AND. is_omp_master) THEN
+       CALL wxios_set_context()
+       CALL xios_update_calendar(itap+1)
+    ENDIF
 #endif
 
@@ -1326,4 +1335,8 @@
 
     IF (first) THEN 
+       ivap = strIdx(tracers(:)%name, addPhase('H2O', 'g'))
+       iliq = strIdx(tracers(:)%name, addPhase('H2O', 'l'))
+       isol = strIdx(tracers(:)%name, addPhase('H2O', 's'))
+       irneb= strIdx(tracers(:)%name, addPhase('H2O', 'r'))
        CALL init_etat0_limit_unstruct
        IF (.NOT. create_etat0_limit) CALL init_limit_read(days_elapsed)
@@ -1358,6 +1371,4 @@
        CALL strataer_init
 #endif
-
-       !!CALL flight_init
 
        print*, '================================================='
@@ -1526,5 +1537,5 @@
        tau_overturning_th(:)=0.
 
-       IF (type_trac == 'inca' .OR. type_trac == 'inco') THEN
+       IF (ANY(type_trac == ['inca','inco'])) THEN
           ! jg : initialisation jusqu'au ces variables sont dans restart
           ccm(:,:,:) = 0.
@@ -1808,5 +1819,7 @@
        CALL thermcell_ini(iflag_thermals,prt_level,tau_thermals,lunout, &
    &    RG,RD,RCPD,RKAPPA,RLVTT,RETV, RTT)
-
+       IF (ok_new_lscp) then
+           CALL lscp_ini(pdtphys,ok_ice_sursat)
+       endif
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
@@ -2096,5 +2109,5 @@
        !c         ENDDO
        !
-       IF (type_trac == 'inca' .OR. type_trac == 'inco') THEN			! ModThL
+       IF (ANY(type_trac == ['inca','inco'])) THEN ! ModThL
 #ifdef INCA
           CALL VTe(VTphysiq)
@@ -2110,32 +2123,57 @@
                longitude, latitude, &
                boundslon, boundslat, &
-               dx, dy, cell_area, ind_cell_glo) 
-
-
-          CALL chemini(  pplay, &
-               nbp_lon, nbp_lat, &
-               latitude_deg, &
-               longitude_deg, &
-               presnivs, &
-               calday, &
-               klon, &
-               nqtot, &
-               nqo+nqCO2, &
-               pdtphys, &
-               annee_ref, &
-               year_cur, &
-               day_ref,  &
-               day_ini, &
-               start_time, &
-               itau_phy, &
-               date0, &
-               io_lon, &
-               io_lat, &
-               chemistry_couple, &
-               init_source, &
-               init_tauinca, &
-               init_pizinca, &
-               init_cginca, &
-               init_ccminca)
+               cell_area, ind_cell_glo) 
+
+          if (grid_type==unstructured) THEN 
+             CALL chemini(  pplay, &
+                  nbp_lon, nbp_lat, &
+                  latitude_deg, &
+                  longitude_deg, &
+                  presnivs, &
+                  calday, &
+                  klon, &
+                  nqtot, &
+                  nqo+nqCO2, &
+                  pdtphys, &
+                  annee_ref, &
+                  year_cur, &
+                  day_ref,  &
+                  day_ini, &
+                  start_time, &
+                  itau_phy, &
+                  date0, &
+                  chemistry_couple, &
+                  init_source, &
+                  init_tauinca, &
+                  init_pizinca, &
+                  init_cginca, &
+                  init_ccminca)
+          ELSE
+             CALL chemini(  pplay, &
+                  nbp_lon, nbp_lat, &
+                  latitude_deg, &
+                  longitude_deg, &
+                  presnivs, &
+                  calday, &
+                  klon, &
+                  nqtot, &
+                  nqo+nqCO2, &
+                  pdtphys, &
+                  annee_ref, &
+                  year_cur, &
+                  day_ref,  &
+                  day_ini, &
+                  start_time, &
+                  itau_phy, &
+                  date0, &
+                  chemistry_couple, &
+                  init_source, &
+                  init_tauinca, &
+                  init_pizinca, &
+                  init_cginca, &
+                  init_ccminca, &
+                  io_lon, &
+                  io_lat)
+          ENDIF
 
 
@@ -3695,13 +3733,14 @@
     ENDIF
 
-    CALL lscp(phys_tstep,missing_val,paprs,pplay, &
+    CALL lscp(klon,klev,phys_tstep,missing_val,paprs,pplay, &
          t_seri, q_seri,ptconv,ratqs, &
-         d_t_lsc, d_q_lsc, d_ql_lsc, d_qi_lsc, rneb, rneb_seri, & 
-         cldliq, picefra, rain_lsc, snow_lsc, &
-         pfrac_impa, pfrac_nucl, pfrac_1nucl, &
+         d_t_lsc, d_q_lsc, d_ql_lsc, d_qi_lsc, rneb, rneblsvol, rneb_seri, & 
+         radocond, picefra, rain_lsc, snow_lsc, &
          frac_impa, frac_nucl, beta_prec_fisrt, &
          prfl, psfl, rhcl,  &
          zqasc, fraca,ztv,zpspsk,ztla,zthl,iflag_cld_th, &
-         iflag_ice_thermo, ok_ice_sursat)
+         iflag_ice_thermo, ok_ice_sursat, zqsatl, zqsats, &
+         qclr, qcld, qss, qvc, rnebclr, rnebss, gamma_ss, &
+         Tcontr, qcontr, qcontr2, fcontrN, fcontrP )
 
     ELSE
@@ -3709,5 +3748,5 @@
     CALL fisrtilp(phys_tstep,paprs,pplay, &
          t_seri, q_seri,ptconv,ratqs, &
-         d_t_lsc, d_q_lsc, d_ql_lsc, d_qi_lsc, rneb, cldliq, &
+         d_t_lsc, d_q_lsc, d_ql_lsc, d_qi_lsc, rneb, radocond, &
          rain_lsc, snow_lsc, &
          pfrac_impa, pfrac_nucl, pfrac_1nucl, &
@@ -3756,5 +3795,5 @@
           cldfra(i,k) = rneb(i,k)
           !CR: a quoi ca sert? Faut-il ajouter qs_seri?
-          IF (.NOT.new_oliq) cldliq(i,k) = ql_seri(i,k)
+          IF (.NOT.new_oliq) radocond(i,k) = ql_seri(i,k)
        ENDDO
     ENDDO
@@ -3820,5 +3859,5 @@
           DO i = 1, klon
              IF (diafra(i,k).GT.cldfra(i,k)) THEN
-                cldliq(i,k) = dialiq(i,k)
+                radocond(i,k) = dialiq(i,k)
                 cldfra(i,k) = diafra(i,k)
              ENDIF
@@ -3857,9 +3896,9 @@
                 DO i=1,klon
                    IF (ptconv(i,k).AND.ptconvth(i,k)) THEN
-                      cldliq(i,k)=cldliq(i,k)+rnebcon(i,k)*clwcon(i,k)
+                      radocond(i,k)=radocond(i,k)+rnebcon(i,k)*clwcon(i,k)
                       cldfra(i,k)=min(cldfra(i,k)+rnebcon(i,k),1.)
                    ELSE IF (ptconv(i,k)) THEN
                       cldfra(i,k)=rnebcon(i,k)
-                      cldliq(i,k)=rnebcon(i,k)*clwcon(i,k)
+                      radocond(i,k)=rnebcon(i,k)*clwcon(i,k)
                    ENDIF
                 ENDDO
@@ -3870,5 +3909,5 @@
                 DO i=1,klon
                    cldfra(i,k)=min(cldfra(i,k)+rnebcon(i,k),1.)
-                   cldliq(i,k)=cldliq(i,k)+rnebcon(i,k)*clwcon(i,k)
+                   radocond(i,k)=radocond(i,k)+rnebcon(i,k)*clwcon(i,k)
                 ENDDO
              ENDDO
@@ -3888,5 +3927,5 @@
                    IF (ptconv(i,k).AND. .NOT.ptconvth(i,k)) THEN
                       cldfra(i,k)=rnebcon(i,k)
-                      cldliq(i,k)=rnebcon(i,k)*clwcon(i,k)
+                      radocond(i,k)=rnebcon(i,k)*clwcon(i,k)
                    ENDIF
                 ENDDO
@@ -3899,5 +3938,5 @@
           ! Ancienne version
           cldfra(:,:)=min(max(cldfra(:,:),rnebcon(:,:)),1.)
-          cldliq(:,:)=cldliq(:,:)+rnebcon(:,:)*clwcon(:,:)
+          radocond(:,:)=radocond(:,:)+rnebcon(:,:)*clwcon(:,:)
        ENDIF
 
@@ -3919,5 +3958,5 @@
           DO i = 1, klon
              IF (diafra(i,k).GT.cldfra(i,k)) THEN
-                cldliq(i,k) = dialiq(i,k)
+                radocond(i,k) = dialiq(i,k)
                 cldfra(i,k) = diafra(i,k)
              ENDIF
@@ -3987,5 +4026,5 @@
     ENDDO
 
-    IF (type_trac == 'inca' .OR. type_trac == 'inco') THEN	! ModThL
+    IF (ANY(type_trac == ['inca','inco'])) THEN ! ModThL
 #ifdef INCA
        CALL VTe(VTphysiq)
@@ -4228,5 +4267,5 @@
           ENDIF
           CALL newmicro (flag_aerosol, ok_cdnc, bl95_b0, bl95_b1, &
-               paprs, pplay, t_seri, cldliq, picefra, cldfra, &
+               paprs, pplay, t_seri, radocond, picefra, cldfra, &
                cldtau, cldemi, cldh, cldl, cldm, cldt, cldq, &
                flwp, fiwp, flwc, fiwc, &
@@ -4236,5 +4275,5 @@
        ELSE
           CALL nuage (paprs, pplay, &
-               t_seri, cldliq, picefra, cldfra, cldtau, cldemi, &
+               t_seri, radocond, picefra, cldfra, cldtau, cldemi, &
                cldh, cldl, cldm, cldt, cldq, &
                ok_aie, &
@@ -4372,7 +4411,5 @@
           ! 
           !--interactive CO2 in ppm from carbon cycle
-          IF (carbon_cycle_rad.AND..NOT.debut) THEN
-            RCO2=RCO2_glo
-          ENDIF
+          IF (carbon_cycle_rad) RCO2=RCO2_glo
           !
           IF (prt_level .GE.10) THEN
@@ -4430,16 +4467,4 @@
  
 #ifndef CPP_XIOS
-          !--OB 30/05/2016 modified 21/10/2016
-          !--here we return swaero_diag and dryaod_diag to FALSE
-          !--and histdef will switch it back to TRUE if necessary
-          !--this is necessary to get the right swaero at first step
-          !--but only in the case of no XIOS as XIOS is covered elsewhere 
-          IF (debut) swaerofree_diag = .FALSE.
-          IF (debut) swaero_diag = .FALSE.
-          IF (debut) dryaod_diag = .FALSE.
-          !--IM 15/09/2017 here we return ok_4xCO2atm to FALSE
-          !--as for swaero_diag, see above
-          IF (debut) ok_4xCO2atm = .FALSE.
-
           !
           !IM 2eme calcul radiatif pour le cas perturbe ou au moins un
@@ -4601,6 +4626,9 @@
        DO i=1,klon
           itest(i)=0
-          !        IF ((zstd(i).gt.10.0)) THEN
-          IF (((zpic(i)-zmea(i)).GT.100.).AND.(zstd(i).GT.10.0)) THEN
+          zrel_mount(i)=zstd(i)/(max(zsig(i),1.E-8)*sqrt(cell_area(i)))
+          !zrel_mount: relative mountain height wrt relief explained by mean slope
+          ! -> condition on zrel_mount can deactivate the drag on tilted planar terrains
+          !    such as ice sheets (work by V. Wiener)
+          IF (((zpic(i)-zmea(i)).GT.100.).AND.(zstd(i).GT.10.0).AND.(zrel_mount(i).GE.zrel_mount_t)) THEN
              itest(i)=1
              igwd=igwd+1
@@ -4651,5 +4679,9 @@
        DO i=1,klon
           itest(i)=0
-          IF ((zpic(i)-zmea(i)).GT.100.) THEN
+          !zrel_mount: relative mountain height wrt relief explained by mean slope
+          ! -> condition on zrel_mount can deactivate the lifting on tilted planar terrains
+          !    such as ice sheets (work by V. Wiener)
+          zrel_mount(i)=zstd(i)/(max(zsig(i),1.E-8)*sqrt(cell_area(i)))
+          IF (((zpic(i)-zmea(i)).GT.100.).AND.(zrel_mount(i).GE.zrel_mount_t)) THEN
              itest(i)=1
              igwd=igwd+1
@@ -5020,5 +5052,5 @@
     !
 
-    IF (type_trac=='repr') THEN
+    IF (type_trac == 'repr') THEN
 !MM pas d'impact, car on recupere q_seri,tr_seri,t_seri via phys_local_var_mod
 !MM                               dans Reprobus
@@ -5070,5 +5102,5 @@
          presnivs, pphis,     pphi,     albsol1, &
          sh_in,   ch_in,    rhcl,      cldfra,   rneb, &
-         diafra,   cldliq,    itop_con, ibas_con, &
+         diafra,   radocond,    itop_con, ibas_con, &
          pmflxr,   pmflxs,    prfl,     psfl, &
          da,       phi,       mp,       upwd, &
@@ -5118,17 +5150,16 @@
     ! Calculer le transport de l'eau et de l'energie (diagnostique)
     !
-    CALL transp (paprs,zxtsol, &
-         t_seri, q_seri, ql_seri, qs_seri, u_seri, v_seri, zphi, &
-         ve, vq, ue, uq, vwat, uwat)
+    CALL transp (paprs,zxtsol, t_seri, q_seri, ql_seri, qs_seri, u_seri, v_seri, zphi, &
+                 ue, ve, uq, vq, uwat, vwat)
     !
     !IM global posePB BEG
     IF(1.EQ.0) THEN
        !
-       CALL transp_lay (paprs,zxtsol, &
-            t_seri, q_seri, u_seri, v_seri, zphi, &
+       CALL transp_lay (paprs,zxtsol, t_seri, q_seri, u_seri, v_seri, zphi, &
             ve_lay, vq_lay, ue_lay, uq_lay)
        !
     ENDIF !(1.EQ.0) THEN
     !IM global posePB END
+    !
     ! Accumuler les variables a stocker dans les fichiers histoire:
     !
@@ -5141,5 +5172,5 @@
     d_t_ec(:,:)=0.
     forall (k=1: nbp_lev) exner(:, k) = (pplay(:, k)/paprs(:,1))**RKAPPA
-    CALL ener_conserv(klon,klev,pdtphys,u,v,t,qx(:,:,ivap),qx(:,:,iliq),qx(:,:,isol), &
+    CALL ener_conserv(klon,klev,pdtphys,u,v,t,qx,ivap,iliq,isol, &
          u_seri,v_seri,t_seri,q_seri,ql_seri,qs_seri,pbl_tke(:,:,is_ave)-tke0(:,:), &
          zmasse,exner,d_t_ec)
@@ -5174,5 +5205,5 @@
     ENDDO
     !
-    IF (type_trac == 'inca' .OR. type_trac == 'inco') THEN
+    IF (ANY(type_trac == ['inca','inco'])) THEN
 #ifdef INCA
        CALL VTe(VTphysiq)
@@ -5198,4 +5229,9 @@
     ENDIF
 
+    IF (type_trac == 'repr') THEN
+#ifdef REPROBUS
+        CALL coord_hyb_rep(paprs, pplay, aps, bps, ap, bp, cell_area)
+#endif
+    ENDIF
 
     !
@@ -5231,16 +5267,15 @@
     ENDDO
     !
-    IF (nqtot > nqo) THEN
-       itr = 0
-       DO iq = 1, nqtot
-          IF(.NOT.tracers(iq)%isInPhysics) CYCLE
-          itr = itr+1
-          DO  k = 1, klev
-             DO  i = 1, klon
-                d_qx(i,k,iq) = ( tr_seri(i,k,itr) - qx(i,k,iq) ) / phys_tstep
-             ENDDO
+    ! DC: All iterations are cycled if nqtot==nqo, so no nqtot>nqo condition required
+    itr = 0
+    DO iq = 1, nqtot
+       IF(.NOT.tracers(iq)%isInPhysics) CYCLE
+       itr = itr+1
+       DO  k = 1, klev
+          DO  i = 1, klon
+             d_qx(i,k,iq) = ( tr_seri(i,k,itr) - qx(i,k,iq) ) / phys_tstep
           ENDDO
        ENDDO
-    ENDIF
+    ENDDO
     !
     !IM rajout diagnostiques bilan KP pour analyse MJO par Jun-Ichi Yano
@@ -5455,5 +5490,5 @@
 
 #ifdef INCA
-       if (type_trac == 'inca' ) then 
+       if (type_trac == 'inca') then 
           IF (is_omp_master .and. grid_type==unstructured) THEN 
              CALL finalize_inca
Index: LMDZ6/branches/Portage_acc/libf/phylmd/phytrac_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/phytrac_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/phytrac_mod.F90	(revision 4446)
@@ -78,12 +78,12 @@
     !      
     !===============================================================================
-    SELECT CASE(type_trac)
-    CASE('co2i')
+    !   -- CO2 interactif --
+    IF(ANY(type_trac == ['co2i','inco'])) CALL tracco2i_init()
+
+       !   -- type_trac == 'co2i' ! PC 
        !   -- CO2 interactif --
-       CALL tracco2i_init()
-    CASE('inco')
-       CALL tracco2i_init()
-    END SELECT
-
+       !   -- source is updated with FF and BB emissions 
+       !   -- and net fluxes from ocean and orchidee 
+       !   -- sign convention : positive into the atmosphere
 
   END SUBROUTINE phytrac_init
@@ -184,5 +184,5 @@
     REAL,DIMENSION(klon),INTENT(IN)        :: pphis
     REAL,DIMENSION(klev),INTENT(IN)        :: presnivs 
-    REAL,DIMENSION(klon,klev),INTENT(IN)   :: cldliq  ! eau liquide nuageuse
+    REAL,DIMENSION(klon,klev),INTENT(IN)   :: cldliq  ! eau condensee totale
     REAL,DIMENSION(klon,klev),INTENT(IN)   :: cldfra  ! fraction nuageuse (tous les nuages)
     REAL,DIMENSION(klon,klev),INTENT(IN)   :: diafra  ! fraction nuageuse (convection ou stratus artificiels)
@@ -491,13 +491,10 @@
 
        ! Initialize module for specific tracers
-       SELECT CASE(type_trac)
-       CASE('lmdz')
-          CALL traclmdz_init(pctsrf,xlat,xlon,ftsol,tr_seri,t_seri,pplay,sh,pdtphys,aerosol,lessivage)
-       CASE('inca')
+       IF(type_trac == 'inca') THEN
           source(:,:)=init_source(:,:)
           CALL tracinca_init(aerosol,lessivage)
-       CASE('repr')
+       ELSE IF(type_trac == 'repr') THEN
           source(:,:)=0.
-       CASE('co2i')
+       ELSE IF(type_trac == 'co2i') THEN
           source(:,:)=0.
           lessivage  = .FALSE.
@@ -507,5 +504,5 @@
           iflag_vdf_trac= 1
           iflag_con_trac= 1
-       CASE('inco')
+       ELSE IF(type_trac == 'inco') THEN
           source(:,1:nqCO2) = 0.                          ! from CO2i ModThL
           source(:,nqCO2+1:nbtr)=init_source(:,:)         ! from INCA ModThL
@@ -517,5 +514,5 @@
           iflag_con_trac = 1                              ! From CO2i
 #ifdef CPP_StratAer
-       CASE('coag')
+       ELSE IF(type_trac == 'coag') THEN
           source(:,:)=0.
           DO it= 1, nbtr_sulgas
@@ -527,5 +524,7 @@
           ENDDO
 #endif
-       END SELECT
+       ELSE IF(type_trac == 'lmdz') THEN
+          CALL traclmdz_init(pctsrf,xlat,xlon,ftsol,tr_seri,t_seri,pplay,sh,pdtphys,aerosol,lessivage)
+       END IF
 
        !
@@ -540,19 +539,7 @@
           !
           DO it=1, nbtr
-             SELECT CASE(type_trac)
-             CASE('lmdz')
-                IF (convscav.and.aerosol(it)) THEN
-                   flag_cvltr(it)=.TRUE.
-                   ccntrAA(it) =ccntrAA_in    !--a modifier par JYG a lire depuis fichier 
-                   ccntrENV(it)=ccntrENV_in
-                   coefcoli(it)=coefcoli_in
-                ELSE 
-                   flag_cvltr(it)=.FALSE.
-                ENDIF
-
-             CASE('repr')
+             IF(type_trac == 'repr') THEN
                  flag_cvltr(it)=.FALSE.
-
-             CASE('inca')
+             ELSE IF(type_trac == 'inca') THEN
 !                IF ((it.EQ.id_Rn222) .OR. ((it.GE.id_SO2) .AND. (it.LE.id_NH3)) ) THEN 
 !                   !--gas-phase species
@@ -578,12 +565,11 @@
                 !--for now we do not scavenge in cvltr
                 flag_cvltr(it)=.FALSE.
-
-             CASE('co2i')
+             ELSE IF(type_trac == 'co2i') THEN
                 !--co2 tracers are not scavenged
                 flag_cvltr(it)=.FALSE.
-             CASE('inco')     ! Add ThL
+             ELSE IF(type_trac == 'inco') THEN     ! Add ThL
                 flag_cvltr(it)=.FALSE.
 #ifdef CPP_StratAer
-             CASE('coag')
+             ELSE IF(type_trac == 'coag') THEN
                 IF (convscav.and.aerosol(it)) THEN
                    flag_cvltr(it)=.TRUE.
@@ -595,6 +581,14 @@
                 ENDIF
 #endif
-
-             END SELECT
+             ELSE IF(type_trac == 'lmdz') THEN
+                IF (convscav.and.aerosol(it)) THEN
+                   flag_cvltr(it)=.TRUE.
+                   ccntrAA(it) =ccntrAA_in    !--a modifier par JYG a lire depuis fichier 
+                   ccntrENV(it)=ccntrENV_in
+                   coefcoli(it)=coefcoli_in
+                ELSE 
+                   flag_cvltr(it)=.FALSE.
+                ENDIF
+             END IF
           ENDDO
           !
@@ -620,8 +614,6 @@
        write(lunout,*)  'flag_cvltr    = ', flag_cvltr
 
-       IF (lessivage .AND. (type_trac .EQ. 'inca' .OR. type_trac .EQ. 'inco')) THEN     ! Mod ThL
+       IF (lessivage .AND. ANY(type_trac == ['inca','inco'])) &
           CALL abort_physic('phytrac', 'lessivage=T config_inca=inca impossible',1)
-!          STOP
-       ENDIF
        !
     ENDIF ! of IF (debutphy)
@@ -646,18 +638,10 @@
     !      
     !===============================================================================
-    SELECT CASE(type_trac)
-    CASE('lmdz')
-       !    -- Traitement des traceurs avec traclmdz
-       CALL traclmdz(nstep, julien, gmtime, pdtphys, t_seri, paprs, pplay, &
-            cdragh,  coefh, yu1, yv1, ftsol, pctsrf, xlat, xlon,iflag_vdf_trac>=0,sh, &
-            rh, pphi, ustar, wstar, ale_bl, ale_wake,  u10m, v10m, &
-            tr_seri, source, d_tr_cl,d_tr_dec, zmasse)               !RomP
-
-    CASE('inca')
+    IF(type_trac == 'inca') THEN
        !    -- CHIMIE INCA  config_inca = aero or chem --
        ! Appel fait en fin de phytrac pour avoir les emissions modifiees par 
        ! la couche limite et la convection avant le calcul de la chimie 
 
-    CASE('repr')
+    ELSE IF(type_trac == 'repr') THEN
        !   -- CHIMIE REPROBUS --
        CALL tracreprobus(pdtphys, gmtime, debutphy, julien, &
@@ -666,5 +650,5 @@
             tr_seri)
 
-    CASE('co2i')
+    ELSE IF(type_trac == 'co2i') THEN
        !   -- CO2 interactif --
        !   -- source is updated with FF and BB emissions 
@@ -675,5 +659,5 @@
             xlat, xlon, pphis, pphi, &
             t_seri, pplay, paprs, tr_seri, source)
-    CASE('inco')      ! Add ThL
+    ELSE IF(type_trac == 'inco') THEN      ! Add ThL
        CALL tracco2i(pdtphys, debutphy, &
             xlat, xlon, pphis, pphi, &
@@ -681,5 +665,5 @@
 
 #ifdef CPP_StratAer
-    CASE('coag')
+    ELSE IF(type_trac == 'coag') THEN
        !   --STRATOSPHERIC AER IN THE STRAT --
        CALL traccoag(pdtphys, gmtime, debutphy, julien, &
@@ -688,6 +672,11 @@
             tr_seri)
 #endif
-
-    END SELECT
+    ELSE IF(type_trac == 'lmdz') THEN
+       !    -- Traitement des traceurs avec traclmdz
+       CALL traclmdz(nstep, julien, gmtime, pdtphys, t_seri, paprs, pplay, &
+            cdragh,  coefh, yu1, yv1, ftsol, pctsrf, xlat, xlon,iflag_vdf_trac>=0,sh, &
+            rh, pphi, ustar, wstar, ale_bl, ale_wake,  u10m, v10m, &
+            tr_seri, source, d_tr_cl,d_tr_dec, zmasse)               !RomP
+    END IF
     !======================================================================
     !       -- Calcul de l'effet de la convection --
@@ -720,6 +709,4 @@
                 !--beware this interface is a bit weird because it is called for each tracer 
                 !--with the full array tr_seri even if only item it is processed
-
-                print*,'CV SCAV ',it,ccntrAA(it),ccntrENV(it)
 
                 CALL cvltr_scav(pdtphys, da, phi,phi2,d1a,dam, mp,ep,         &
@@ -1102,5 +1089,5 @@
 
     !    -- CHIMIE INCA  config_inca = aero or chem --
-    IF (type_trac == 'inca' .OR. type_trac == 'inco') THEN  ! ModThL
+    IF (ANY(type_trac == ['inca','inco'])) THEN  ! ModThL
 
        CALL tracinca(&
Index: LMDZ6/branches/Portage_acc/libf/phylmd/read_pstoke.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/read_pstoke.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/read_pstoke.F90	(revision 4446)
@@ -252,9 +252,5 @@
 
     ! niveaux de pression
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidpl, 1, zklevo, pl)
-#else
-    status = nf_get_vara_real(ncidp, varidpl, 1, zklevo, pl)
-#endif
+    status = nf90_get_var(ncidp, varidpl, pl, [1], [ncklevo])
 
     ! lecture de aire et phis
@@ -271,17 +267,9 @@
 
     ! phis
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidps, start, count, phisfi2)
-#else
-    status = nf_get_vara_real(ncidp, varidps, start, count, phisfi2)
-#endif
+    status = nf90_get_var(ncidp, varidps, phisfi2, start, count)
     CALL gr_ecrit_fi(1, klono, imo, jmo+1, phisfi2, phisfi)
 
     ! aire
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidai, start, count, airefi2)
-#else
-    status = nf_get_vara_real(ncidp, varidai, start, count, airefi2)
-#endif
+    status = nf90_get_var(ncidp, varidai, airefi2, start, count)
     CALL gr_ecrit_fi(1, klono, imo, jmo+1, airefi2, airefi)
   ELSE
@@ -309,75 +297,39 @@
     ! *** Lessivage******************************************************
     ! frac_impa
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidfi, start, count, frac_impa2)
-#else
-    status = nf_get_vara_real(ncidp, varidfi, start, count, frac_impa2)
-#endif
+    status = nf90_get_var(ncidp, varidfi, frac_impa2, start, count)
     CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, frac_impa2, frac_impa)
 
     ! frac_nucl
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidfn, start, count, frac_nucl2)
-#else
-    status = nf_get_vara_real(ncidp, varidfn, start, count, frac_nucl2)
-#endif
+    status = nf90_get_var(ncidp, varidfn, frac_nucl2, start, count)
     CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, frac_nucl2, frac_nucl)
 
     ! *** Temperature ******************************************************
     ! abder t
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidt, start, count, t2)
-#else
-    status = nf_get_vara_real(ncidp, varidt, start, count, t2)
-#endif
+    status = nf90_get_var(ncidp, varidt, t2, start, count)
     CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, t2, t)
 
     ! *** Flux pour le calcul de la convection TIEDTK ***********************
     ! mfu
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidmfu, start, count, mfu2)
-#else
-    status = nf_get_vara_real(ncidp, varidmfu, start, count, mfu2)
-#endif
+    status = nf90_get_var(ncidp, varidmfu, mfu2, start, count)
     CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, mfu2, mfu)
 
     ! mfd
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidmfd, start, count, mfd2)
-#else
-    status = nf_get_vara_real(ncidp, varidmfd, start, count, mfd2)
-#endif
+    status = nf90_get_var(ncidp, varidmfd, mfd2, start, count)
     CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, mfd2, mfd)
 
     ! en_u
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidenu, start, count, en_u2)
-#else
-    status = nf_get_vara_real(ncidp, varidenu, start, count, en_u2)
-#endif
+    status = nf90_get_var(ncidp, varidenu, en_u2, start, count)
     CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, en_u2, en_u)
 
     ! de_u
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, variddeu, start, count, de_u2)
-#else
-    status = nf_get_vara_real(ncidp, variddeu, start, count, de_u2)
-#endif
+    status = nf90_get_var(ncidp, variddeu, de_u2, start, count)
     CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, de_u2, de_u)
 
     ! en_d
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidend, start, count, en_d2)
-#else
-    status = nf_get_vara_real(ncidp, varidend, start, count, en_d2)
-#endif
+    status = nf90_get_var(ncidp, varidend, en_d2, start, count)
     CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, en_d2, en_d)
 
     ! de_d
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidded, start, count, de_d2)
-#else
-    status = nf_get_vara_real(ncidp, varidded, start, count, de_d2)
-#endif
+    status = nf90_get_var(ncidp, varidded, de_d2, start, count)
     CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, de_d2, de_d)
 
@@ -385,9 +337,5 @@
     ! turbulent**********************************
     ! coefh
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidch, start, count, coefh2)
-#else
-    status = nf_get_vara_real(ncidp, varidch, start, count, coefh2)
-#endif
+    status = nf90_get_var(ncidp, varidch, coefh2, start, count)
     CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, coefh2, coefh)
 
@@ -395,16 +343,8 @@
     ! Thermiques************************
     ! abder thermiques
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidfmth, start, count, fm_therm2)
-#else
-    status = nf_get_vara_real(ncidp, varidfmth, start, count, fm_therm2)
-#endif
+    status = nf90_get_var(ncidp, varidfmth, fm_therm2, start, count)
     CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, fm_therm2, fm_therm)
 
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidenth, start, count, en_therm2)
-#else
-    status = nf_get_vara_real(ncidp, varidenth, start, count, en_therm2)
-#endif
+    status = nf90_get_var(ncidp, varidenth, en_therm2, start, count)
     CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, en_therm2, en_therm)
 
@@ -416,83 +356,43 @@
     count(4) = 0
     ! pyu1
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidyu1, start, count, pyu12)
-#else
-    status = nf_get_vara_real(ncidp, varidyu1, start, count, pyu12)
-#endif
+    status = nf90_get_var(ncidp, varidyu1, pyu12, start, count)
     CALL gr_ecrit_fi(1, klono, imo, jmo+1, pyu12, pyu1)
 
     ! pyv1
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidyv1, start, count, pyv12)
-#else
-    status = nf_get_vara_real(ncidp, varidyv1, start, count, pyv12)
-#endif
+    status = nf90_get_var(ncidp, varidyv1, pyv12, start, count)
     CALL gr_ecrit_fi(1, klono, imo, jmo+1, pyv12, pyv1)
 
     ! *** Temperature au sol ********************************************
     ! ftsol1
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidfts1, start, count, ftsol12)
-#else
-    status = nf_get_vara_real(ncidp, varidfts1, start, count, ftsol12)
-#endif
+    status = nf90_get_var(ncidp, varidfts1, ftsol12, start, count)
     CALL gr_ecrit_fi(1, klono, imo, jmo+1, ftsol12, ftsol1)
 
     ! ftsol2
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidfts2, start, count, ftsol22)
-#else
-    status = nf_get_vara_real(ncidp, varidfts2, start, count, ftsol22)
-#endif
+    status = nf90_get_var(ncidp, varidfts2, ftsol22, start, count)
     CALL gr_ecrit_fi(1, klono, imo, jmo+1, ftsol22, ftsol2)
 
     ! ftsol3
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidfts3, start, count, ftsol32)
-#else
-    status = nf_get_vara_real(ncidp, varidfts3, start, count, ftsol32)
-#endif
+    status = nf90_get_var(ncidp, varidfts3, ftsol32, start, count)
     CALL gr_ecrit_fi(1, klono, imo, jmo+1, ftsol32, ftsol3)
 
     ! ftsol4
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidfts4, start, count, ftsol42)
-#else
-    status = nf_get_vara_real(ncidp, varidfts4, start, count, ftsol42)
-#endif
+    status = nf90_get_var(ncidp, varidfts4, ftsol42, start, count)
     CALL gr_ecrit_fi(1, klono, imo, jmo+1, ftsol42, ftsol4)
 
     ! *** Nature du sol **************************************************
     ! psrf1
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidpsr1, start, count, psrf12)
-#else
-    status = nf_get_vara_real(ncidp, varidpsr1, start, count, psrf12)
-#endif
+    status = nf90_get_var(ncidp, varidpsr1, psrf12, start, count)
     CALL gr_ecrit_fi(1, klono, imo, jmo+1, psrf12, psrf1)
 
     ! psrf2
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidpsr2, start, count, psrf22)
-#else
-    status = nf_get_vara_real(ncidp, varidpsr2, start, count, psrf22)
-#endif
+    status = nf90_get_var(ncidp, varidpsr2, psrf22, start, count)
     CALL gr_ecrit_fi(1, klono, imo, jmo+1, psrf22, psrf2)
 
     ! psrf3
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidpsr3, start, count, psrf32)
-#else
-    status = nf_get_vara_real(ncidp, varidpsr3, start, count, psrf32)
-#endif
+    status = nf90_get_var(ncidp, varidpsr3, psrf32, start, count)
     CALL gr_ecrit_fi(1, klono, imo, jmo+1, psrf32, psrf3)
 
     ! psrf4
-#ifdef NC_DOUBLE
-    status = nf_get_vara_double(ncidp, varidpsr4, start, count, psrf42)
-#else
-    status = nf_get_vara_real(ncidp, varidpsr4, start, count, psrf42)
-#endif
+    status = nf90_get_var(ncidp, varidpsr4, psrf42, start, count)
     CALL gr_ecrit_fi(1, klono, imo, jmo+1, psrf42, psrf4)
 
Index: LMDZ6/branches/Portage_acc/libf/phylmd/rrtm/aeropt_6bands_rrtm.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/rrtm/aeropt_6bands_rrtm.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/rrtm/aeropt_6bands_rrtm.F90	(revision 4446)
@@ -318,18 +318,18 @@
    ! Dust insoluble
   0.894, 0.902, 0.937, 0.980, 0.993, 0.967, &
-   ! BC insoluble 
+   ! BC insoluble
+  0.480, 0.469, 0.456, 0.427, 0.349, 0.196, &
+   ! POM insoluble
+  0.956, 0.965, 0.969, 0.953, 0.892, 0.826, &
+   ! Nitrate insoluble
+  1.000, 1.000, 1.000, 1.000, 0.999, 0.707 /
+
+  DATA cg_aeri_6bands/ &
+   ! Dust insoluble
+  0.756, 0.737, 0.713, 0.701, 0.696, 0.672, &
+   ! BC insoluble
   0.820, 0.760, 0.695, 0.603, 0.469, 0.276, &
    ! POM insoluble
   0.687, 0.685, 0.673, 0.637, 0.553, 0.340, &
-   ! Nitrate insoluble
-  1.000, 1.000, 1.000, 1.000, 0.999, 0.707 /
-
-  DATA cg_aeri_6bands/ &
-   ! Dust insoluble
-  0.756, 0.737, 0.713, 0.701, 0.696, 0.672, &
-   ! BC insoluble 
-  0.480, 0.469, 0.456, 0.427, 0.349, 0.196, &
-   ! POM insoluble
-  0.956, 0.965, 0.969, 0.953, 0.892, 0.826, &
    ! Nitrate insoluble
   0.765, 0.754, 0.743, 0.737, 0.739, 0.651 /
Index: LMDZ6/branches/Portage_acc/libf/phylmd/rrtm/rrtm_taumol2.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/rrtm/rrtm_taumol2.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/rrtm/rrtm_taumol2.F90	(revision 4446)
@@ -22,4 +22,7 @@
  & FORREF   ,SELFREF , REFPARAM  
 USE YOERRTBG2, ONLY : CORR1  ,CORR2
+
+USE print_control_mod, ONLY: mydebug=>debug , lunout, prt_level, &
+ & alert_first_call, call_alert, prt_alerte
 
 !  Input
@@ -65,4 +68,7 @@
 !      EQUIVALENCE (TAUAERL(1,2),TAUAER)
 
+    CHARACTER (LEN=20) :: modname='rrtm_taumol2'
+    CHARACTER*80 message
+
 !     Compute the optical depth by interpolating in ln(pressure) and 
 !     temperature.  Below LAYTROP, the water vapor self-continuum is 
@@ -115,6 +121,10 @@
 ! C'est evidemment une correction suspecte
   IF (IFP>200) THEN
+   IF (call_alert) THEN
+      message='WARNING IFP='
+      CALL prt_alerte(message,modname,1)
       PRINT*,'WARNING IFP=',IFP,' 2.E2_JPRB*Z_FP+0.5_JPRB avec Z_FP=',Z_FP
-      IFP=200
+   ENDIF
+   IFP=200
   ENDIF
 
@@ -156,6 +166,10 @@
   IF (IFP <= 0) IFP=0
   IF (IFP>200) THEN
+   IF (call_alert) THEN
+      message='WARNING IFP='
+      CALL prt_alerte(message,modname,1)
       PRINT*,'WARNING IFP=',IFP,' 2.E2_JPRB*Z_FP+0.5_JPRB avec Z_FP=',Z_FP
-      IFP=200
+   ENDIF
+   IFP=200
   ENDIF
 
Index: LMDZ6/branches/Portage_acc/libf/phylmd/rrtm/suecrad.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/rrtm/suecrad.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/rrtm/suecrad.F90	(revision 4446)
@@ -243,8 +243,8 @@
 !      ----------------------------------------------------------------
 
+#include "clesphys.h"
 #include "naerad.h"
 #include "namrgri.h"
 !MPL/IM 20160915 on prend GES de phylmd
-#include "clesphys.h"
 
 !*         1.       INITIALIZE NEUROFLUX LONGWAVE RADIATION
Index: LMDZ6/branches/Portage_acc/libf/phylmd/surf_land_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/surf_land_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/surf_land_mod.F90	(revision 4446)
@@ -24,7 +24,6 @@
     USE dimphy
     USE surface_data, ONLY    : ok_veget
-! >> PC
-    USE carbon_cycle_mod 
-! << PC
+    USE carbon_cycle_mod
+
 
     ! See comments in each module surf_land_orchidee_xxx for compatiblity with ORCHIDEE
@@ -45,4 +44,9 @@
     USE surf_land_orchidee_nounstruct_mod
 #else
+#if ORCHIDEE_NOLIC
+    ! Compilation with cpp key ORCHIDEE_NOLIC
+    USE surf_land_orchidee_nolic_mod
+#else
+    ! Default version
     USE surf_land_orchidee_mod
 #endif
@@ -50,12 +54,10 @@
 #endif
 #endif
-
+#endif
+    
     USE surf_land_bucket_mod
     USE calcul_fluxs_mod
     USE indice_sol_mod
-
-! >> PC
     USE print_control_mod, ONLY: lunout
-! << PC
 
     INCLUDE "dimsoil.h"
Index: LMDZ6/branches/Portage_acc/libf/phylmd/surf_land_orchidee_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/surf_land_orchidee_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/surf_land_orchidee_mod.F90	(revision 4446)
@@ -5,11 +5,12 @@
 #ifndef ORCHIDEE_NOFREIN
 #ifndef ORCHIDEE_NOUNSTRUCT
+#ifndef ORCHIDEE_NOLIC
 !
 ! This module controles the interface towards the model ORCHIDEE.
 !
 ! Compatibility with ORCHIDIEE :
-! The current version can be used with ORCHIDEE/trunk from revision 4465.
+! The current version can be used with ORCHIDEE/trunk from revision 7757. 
 ! This interface is used if none of the cpp keys ORCHIDEE_NOOPENMP, 
-! ORCHIDEE_NOZ0H or ORCHIDEE_NOFREIN is set.
+! ORCHIDEE_NOZ0H, ORCHIDEE_NOFREIN or ORCHIDEE_NOLIC is set.
 !
 ! Subroutines in this module : surf_land_orchidee
@@ -20,8 +21,8 @@
   USE dimphy
 #ifdef CPP_VEGET
-  USE intersurf     ! module d'ORCHIDEE
-#endif
-  USE cpl_mod,      ONLY : cpl_send_land_fields
-  USE surface_data, ONLY : type_ocean
+  USE intersurf     ! module in ORCHIDEE
+#endif
+  USE cpl_mod,      ONLY : cpl_send_land_fields, cpl_send_landice_fields
+  USE surface_data, ONLY : type_ocean, landice_opt
   USE geometry_mod, ONLY : dx, dy, boundslon, boundslat,longitude, latitude, cell_area,  ind_cell_glo
   USE mod_grid_phy_lmdz
@@ -152,4 +153,7 @@
     INTEGER                                   :: error
     REAL, DIMENSION(klon)                     :: swdown_vrai
+    REAL, DIMENSION(klon)                     :: run_off_lic        !! run off from land ice defined in ORCHIDEE, contains calving, melting and liquid precipitation
+    REAL, DIMENSION(klon)                     :: run_off_lic_frac   !! cell fraction corresponding to run_off_lic
+    REAL, DIMENSION(klon)                     :: blowingsnow_flux   !! blowing snow flux
     CHARACTER (len = 20)                      :: modname = 'surf_land_orchidee'
     CHARACTER (len = 80)                      :: abort_message
@@ -570,5 +574,6 @@
                lon_scat, lat_scat, q2m(1:knon), t2m(1:knon), z0h_new(1:knon), nvm_orch, &
                grid=grid_type, bounds_latlon=bounds_lalo, cell_area=area, ind_cell_glo=ind_cell, &
-               field_out_names=cfname_out, field_in_names=cfname_in(1:nbcf_in_orc))
+               field_out_names=cfname_out, field_in_names=cfname_in(1:nbcf_in_orc), &
+               coszang=yrmu0(1:knon))
 #endif         
        ENDIF
@@ -603,5 +608,5 @@
             fields_out=yfields_out(1:knon,1:nbcf_out),  &
             fields_in=yfields_in(1:knon,1:nbcf_in_orc), &
-            coszang=yrmu0(1:knon))
+            coszang=yrmu0(1:knon), run_off_lic=run_off_lic(1:knon), run_off_lic_frac=run_off_lic_frac(1:knon), blowingsnow_flux=blowingsnow_flux(1:knon))
 #endif       
     ENDIF
@@ -616,4 +621,7 @@
        CALL cpl_send_land_fields(itime, knon, knindex, &
             riverflow, coastalflow)
+       IF (landice_opt .GE. 2) THEN
+          CALL cpl_send_landice_fields(itime, knon, knindex, run_off_lic, run_off_lic_frac)
+       END IF
     ENDIF
 
@@ -850,3 +858,4 @@
 #endif
 #endif
+#endif
 END MODULE surf_land_orchidee_mod
Index: LMDZ6/branches/Portage_acc/libf/phylmd/surf_land_orchidee_nolic_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/surf_land_orchidee_nolic_mod.F90	(revision 4446)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/surf_land_orchidee_nolic_mod.F90	(revision 4446)
@@ -0,0 +1,846 @@
+!
+MODULE surf_land_orchidee_nolic_mod
+#ifdef ORCHIDEE_NOLIC
+!
+! This module controles the interface towards the model ORCHIDEE.
+!
+! Compatibility with ORCHIDIEE :
+! This module is compiled only if cpp key ORCHIDEE_NOLIC is defined. 
+! The current version can be used with ORCHIDEE/trunk from revision 4465-7757. 
+! (it can be used for later revisions also but it is not needed.)
+! 
+! Subroutines in this module : surf_land_orchidee
+!                              Init_orchidee_index
+!                              Get_orchidee_communicator
+!                              Init_neighbours
+
+  USE dimphy
+#ifdef CPP_VEGET
+  USE intersurf     ! module d'ORCHIDEE
+#endif
+  USE cpl_mod,      ONLY : cpl_send_land_fields
+  USE surface_data, ONLY : type_ocean
+  USE geometry_mod, ONLY : dx, dy, boundslon, boundslat,longitude, latitude, cell_area,  ind_cell_glo
+  USE mod_grid_phy_lmdz
+  USE mod_phys_lmdz_para, mpi_root_rank=>mpi_master
+  USE carbon_cycle_mod, ONLY : nbcf_in_orc, nbcf_out, fields_in, yfields_in, yfields_out, cfname_in, cfname_out
+  USE nrtype, ONLY : PI
+  
+  IMPLICIT NONE
+
+  PRIVATE
+  PUBLIC  :: surf_land_orchidee
+
+CONTAINS
+!
+!****************************************************************************************
+!  
+  SUBROUTINE surf_land_orchidee(itime, dtime, date0, knon, &
+       knindex, rlon, rlat, yrmu0, pctsrf, &
+       debut, lafin, &
+       plev,  u1_lay, v1_lay, gustiness, temp_air, spechum, epot_air, ccanopy, & 
+       tq_cdrag, petAcoef, peqAcoef, petBcoef, peqBcoef, &
+       precip_rain, precip_snow, lwdown, swnet, swdown, &
+       ps, q2m, t2m, &
+       evap, fluxsens, fluxlat, &              
+       tsol_rad, tsurf_new, alb1_new, alb2_new, &
+       emis_new, z0m_new, z0h_new, qsurf, &
+       veget, lai, height )
+
+    USE mod_surf_para
+    USE mod_synchro_omp
+    USE carbon_cycle_mod
+    USE indice_sol_mod
+    USE print_control_mod, ONLY: lunout
+    USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
+#ifdef CPP_VEGET
+    USE time_phylmdz_mod, ONLY: itau_phy 
+#endif
+!    
+! Cette routine sert d'interface entre le modele atmospherique et le 
+! modele de sol continental. Appel a sechiba
+!
+! L. Fairhead 02/2000
+!
+! input:
+!   itime        numero du pas de temps
+!   dtime        pas de temps de la physique (en s)
+!   nisurf       index de la surface a traiter (1 = sol continental)
+!   knon         nombre de points de la surface a traiter
+!   knindex      index des points de la surface a traiter
+!   rlon         longitudes de la grille entiere
+!   rlat         latitudes de la grille entiere
+!   pctsrf       tableau des fractions de surface de chaque maille
+!   debut        logical: 1er appel a la physique (lire les restart)
+!   lafin        logical: dernier appel a la physique (ecrire les restart)
+!                     (si false calcul simplifie des fluxs sur les continents)
+!   plev         hauteur de la premiere couche (Pa)      
+!   u1_lay       vitesse u 1ere couche
+!   v1_lay       vitesse v 1ere couche
+!   temp_air     temperature de l'air 1ere couche
+!   spechum      humidite specifique 1ere couche
+!   epot_air     temp pot de l'air
+!   ccanopy      concentration CO2 canopee, correspond au co2_send de 
+!                carbon_cycle_mod ou valeur constant co2_ppm
+!   tq_cdrag     cdrag
+!   petAcoef     coeff. A de la resolution de la CL pour t
+!   peqAcoef     coeff. A de la resolution de la CL pour q
+!   petBcoef     coeff. B de la resolution de la CL pour t
+!   peqBcoef     coeff. B de la resolution de la CL pour q
+!   precip_rain  precipitation liquide
+!   precip_snow  precipitation solide
+!   lwdown       flux IR descendant a la surface
+!   swnet        flux solaire net
+!   swdown       flux solaire entrant a la surface
+!   ps           pression au sol
+!   radsol       rayonnement net aus sol (LW + SW)
+!
+! output:
+!   evap         evaporation totale
+!   fluxsens     flux de chaleur sensible
+!   fluxlat      flux de chaleur latente
+!   tsol_rad     
+!   tsurf_new    temperature au sol
+!   alb1_new     albedo in visible SW interval
+!   alb2_new     albedo in near IR interval
+!   emis_new     emissivite
+!   z0m_new      surface roughness for momentum
+!   z0h_new      surface roughness for heat
+!   qsurf        air moisture at surface
+!
+    INCLUDE "YOMCST.h"
+    INCLUDE "dimpft.h"
+!
+! Parametres d'entree
+!****************************************************************************************
+    INTEGER, INTENT(IN)                       :: itime
+    REAL, INTENT(IN)                          :: dtime
+    REAL, INTENT(IN)                          :: date0
+    INTEGER, INTENT(IN)                       :: knon
+    INTEGER, DIMENSION(klon), INTENT(IN)      :: knindex
+    LOGICAL, INTENT(IN)                       :: debut, lafin
+    REAL, DIMENSION(klon,nbsrf), INTENT(IN)   :: pctsrf
+    REAL, DIMENSION(klon), INTENT(IN)         :: rlon, rlat
+    REAL, DIMENSION(klon), INTENT(IN)         :: yrmu0 ! cosine of solar zenith angle
+    REAL, DIMENSION(klon), INTENT(IN)         :: plev
+    REAL, DIMENSION(klon), INTENT(IN)         :: u1_lay, v1_lay, gustiness
+    REAL, DIMENSION(klon), INTENT(IN)         :: temp_air, spechum
+    REAL, DIMENSION(klon), INTENT(IN)         :: epot_air, ccanopy
+    REAL, DIMENSION(klon), INTENT(IN)         :: tq_cdrag
+    REAL, DIMENSION(klon), INTENT(IN)         :: petAcoef, peqAcoef
+    REAL, DIMENSION(klon), INTENT(IN)         :: petBcoef, peqBcoef
+    REAL, DIMENSION(klon), INTENT(IN)         :: precip_rain, precip_snow
+    REAL, DIMENSION(klon), INTENT(IN)         :: lwdown, swnet, swdown, ps
+    REAL, DIMENSION(klon), INTENT(IN)         :: q2m, t2m
+
+! Parametres de sortie
+!****************************************************************************************
+    REAL, DIMENSION(klon), INTENT(OUT)        :: evap, fluxsens, fluxlat, qsurf
+    REAL, DIMENSION(klon), INTENT(OUT)        :: tsol_rad, tsurf_new
+    REAL, DIMENSION(klon), INTENT(OUT)        :: alb1_new, alb2_new
+    REAL, DIMENSION(klon), INTENT(OUT)        :: emis_new, z0m_new, z0h_new
+    REAL, DIMENSION(klon,nvm_lmdz), INTENT(OUT) :: veget
+    REAL, DIMENSION(klon,nvm_lmdz), INTENT(OUT) :: lai
+    REAL, DIMENSION(klon,nvm_lmdz), INTENT(OUT) :: height
+
+! Local
+!****************************************************************************************
+    INTEGER                                   :: ij, jj, igrid, ireal, index, nb
+    INTEGER                                   :: error
+    REAL, DIMENSION(klon)                     :: swdown_vrai
+    CHARACTER (len = 20)                      :: modname = 'surf_land_orchidee'
+    CHARACTER (len = 80)                      :: abort_message
+    LOGICAL,SAVE                              :: check = .FALSE.
+    !$OMP THREADPRIVATE(check)
+
+! type de couplage dans sechiba
+!  character (len=10)   :: coupling = 'implicit' 
+! drapeaux controlant les appels dans SECHIBA
+!  type(control_type), save   :: control_in
+! Preserved albedo
+    REAL, ALLOCATABLE, DIMENSION(:), SAVE     :: albedo_keep, zlev
+    !$OMP THREADPRIVATE(albedo_keep,zlev)
+! coordonnees geographiques
+    REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: lalo
+    !$OMP THREADPRIVATE(lalo)
+! boundaries of cells
+    REAL, ALLOCATABLE, DIMENSION(:,:,:), SAVE   :: bounds_lalo
+    !$OMP THREADPRIVATE(bounds_lalo)
+! pts voisins
+    INTEGER,ALLOCATABLE, DIMENSION(:,:), SAVE :: neighbours
+    !$OMP THREADPRIVATE(neighbours)
+! fractions continents
+    REAL,ALLOCATABLE, DIMENSION(:), SAVE      :: contfrac
+    !$OMP THREADPRIVATE(contfrac)
+! resolution de la grille
+    REAL, ALLOCATABLE, DIMENSION (:,:), SAVE  :: resolution
+    !$OMP THREADPRIVATE(resolution)
+
+    REAL, ALLOCATABLE, DIMENSION (:,:), SAVE  :: lon_scat, lat_scat  
+    !$OMP THREADPRIVATE(lon_scat,lat_scat)
+
+! area of cells
+    REAL, ALLOCATABLE, DIMENSION (:), SAVE  :: area  
+    !$OMP THREADPRIVATE(area)
+
+    LOGICAL, SAVE                             :: lrestart_read = .TRUE.
+    !$OMP THREADPRIVATE(lrestart_read)
+    LOGICAL, SAVE                             :: lrestart_write = .FALSE.
+    !$OMP THREADPRIVATE(lrestart_write)
+
+    REAL, DIMENSION(knon,2)                   :: albedo_out
+
+! Pb de nomenclature
+    REAL, DIMENSION(klon)                     :: petA_orc, peqA_orc
+    REAL, DIMENSION(klon)                     :: petB_orc, peqB_orc
+! Pb de correspondances de grilles
+    INTEGER, DIMENSION(:), SAVE, ALLOCATABLE  :: ig, jg
+    !$OMP THREADPRIVATE(ig,jg)
+    INTEGER :: indi, indj
+    INTEGER, SAVE, ALLOCATABLE,DIMENSION(:)   :: ktindex
+    !$OMP THREADPRIVATE(ktindex)
+
+! Essai cdrag
+    REAL, DIMENSION(klon)                     :: cdrag
+    INTEGER,SAVE                              :: offset
+    !$OMP THREADPRIVATE(offset)
+
+    REAL, DIMENSION(klon_glo)                 :: rlon_g,rlat_g
+    INTEGER, SAVE                             :: orch_comm
+    !$OMP THREADPRIVATE(orch_comm)
+
+    REAL, ALLOCATABLE, DIMENSION(:), SAVE     :: coastalflow
+    !$OMP THREADPRIVATE(coastalflow)
+    REAL, ALLOCATABLE, DIMENSION(:), SAVE     :: riverflow
+    !$OMP THREADPRIVATE(riverflow)
+    
+    INTEGER :: orch_mpi_rank
+    INTEGER :: orch_mpi_size
+    INTEGER :: orch_omp_rank
+    INTEGER :: orch_omp_size
+
+    REAL, ALLOCATABLE, DIMENSION(:)         :: longitude_glo
+    REAL, ALLOCATABLE, DIMENSION(:)         :: latitude_glo
+    REAL, ALLOCATABLE, DIMENSION(:,:)       :: boundslon_glo
+    REAL, ALLOCATABLE, DIMENSION(:,:)       :: boundslat_glo
+    INTEGER, ALLOCATABLE, DIMENSION(:)      :: ind_cell_glo_glo
+    INTEGER, ALLOCATABLE, SAVE,DIMENSION(:) :: ind_cell
+    !$OMP THREADPRIVATE(ind_cell)
+    INTEGER :: begin, end
+!
+! Fin definition
+!****************************************************************************************
+
+    IF (check) WRITE(lunout,*)'Entree ', modname
+  
+! Initialisation
+  
+    IF (debut) THEN
+! Test of coherence between variable ok_veget and cpp key CPP_VEGET
+#ifndef CPP_VEGET
+       abort_message='Pb de coherence: ok_veget = .true. mais CPP_VEGET = .false.'
+       CALL abort_physic(modname,abort_message,1)
+#endif
+
+       CALL Init_surf_para(knon)
+       ALLOCATE(ktindex(knon))
+       IF ( .NOT. ALLOCATED(albedo_keep)) THEN
+!ym          ALLOCATE(albedo_keep(klon))
+!ym bizarre que non alloué en knon precedement
+          ALLOCATE(albedo_keep(knon))
+          ALLOCATE(zlev(knon))
+       ENDIF
+! Pb de correspondances de grilles
+       ALLOCATE(ig(klon))
+       ALLOCATE(jg(klon))
+       ig(1) = 1
+       jg(1) = 1
+       indi = 0
+       indj = 2
+       DO igrid = 2, klon - 1
+          indi = indi + 1
+          IF ( indi > nbp_lon) THEN
+             indi = 1
+             indj = indj + 1
+          ENDIF
+          ig(igrid) = indi
+          jg(igrid) = indj
+       ENDDO
+       ig(klon) = 1
+       jg(klon) = nbp_lat
+
+       IF ((.NOT. ALLOCATED(area))) THEN
+          ALLOCATE(area(knon), stat = error)
+          IF (error /= 0) THEN
+             abort_message='Pb allocation area'
+             CALL abort_physic(modname,abort_message,1)
+          ENDIF
+       ENDIF
+       DO igrid = 1, knon
+          area(igrid) = cell_area(knindex(igrid))
+       ENDDO
+       
+       IF (grid_type==unstructured) THEN
+
+
+         IF ((.NOT. ALLOCATED(lon_scat))) THEN
+            ALLOCATE(lon_scat(nbp_lon,nbp_lat), stat = error)
+            IF (error /= 0) THEN
+               abort_message='Pb allocation lon_scat'
+               CALL abort_physic(modname,abort_message,1)
+            ENDIF
+         ENDIF
+ 
+         IF ((.NOT. ALLOCATED(lat_scat))) THEN
+            ALLOCATE(lat_scat(nbp_lon,nbp_lat), stat = error)
+            IF (error /= 0) THEN
+               abort_message='Pb allocation lat_scat'
+               CALL abort_physic(modname,abort_message,1)
+            ENDIF
+         ENDIF
+         CALL Gather(rlon,rlon_g)
+         CALL Gather(rlat,rlat_g)
+
+         IF (is_mpi_root) THEN
+            index = 1
+            DO jj = 2, nbp_lat-1
+               DO ij = 1, nbp_lon
+                  index = index + 1
+                  lon_scat(ij,jj) = rlon_g(index)
+                  lat_scat(ij,jj) = rlat_g(index)
+               ENDDO
+            ENDDO
+            lon_scat(:,1) = lon_scat(:,2)
+            lat_scat(:,1) = rlat_g(1)
+            lon_scat(:,nbp_lat) = lon_scat(:,2)
+            lat_scat(:,nbp_lat) = rlat_g(klon_glo)
+         ENDIF
+     
+         CALL bcast(lon_scat)
+         CALL bcast(lat_scat)
+                
+       ELSE IF (grid_type==regular_lonlat) THEN
+
+         IF ((.NOT. ALLOCATED(lalo))) THEN
+            ALLOCATE(lalo(knon,2), stat = error)
+            IF (error /= 0) THEN
+               abort_message='Pb allocation lalo'
+               CALL abort_physic(modname,abort_message,1)
+            ENDIF
+         ENDIF
+       
+         IF ((.NOT. ALLOCATED(bounds_lalo))) THEN
+           ALLOCATE(bounds_lalo(knon,nvertex,2), stat = error)
+           IF (error /= 0) THEN
+             abort_message='Pb allocation lalo'
+             CALL abort_physic(modname,abort_message,1)
+           ENDIF
+         ENDIF
+       
+         IF ((.NOT. ALLOCATED(lon_scat))) THEN
+            ALLOCATE(lon_scat(nbp_lon,nbp_lat), stat = error)
+            IF (error /= 0) THEN
+               abort_message='Pb allocation lon_scat'
+               CALL abort_physic(modname,abort_message,1)
+            ENDIF
+         ENDIF
+         IF ((.NOT. ALLOCATED(lat_scat))) THEN
+            ALLOCATE(lat_scat(nbp_lon,nbp_lat), stat = error)
+            IF (error /= 0) THEN
+               abort_message='Pb allocation lat_scat'
+               CALL abort_physic(modname,abort_message,1)
+            ENDIF
+         ENDIF
+         lon_scat = 0.
+         lat_scat = 0.
+         DO igrid = 1, knon
+            index = knindex(igrid)
+            lalo(igrid,2) = rlon(index)
+            lalo(igrid,1) = rlat(index)
+            bounds_lalo(igrid,:,2)=boundslon(index,:)*180./PI
+            bounds_lalo(igrid,:,1)=boundslat(index,:)*180./PI
+         ENDDO
+
+       
+       
+         CALL Gather(rlon,rlon_g)
+         CALL Gather(rlat,rlat_g)
+
+         IF (is_mpi_root) THEN
+            index = 1
+            DO jj = 2, nbp_lat-1
+               DO ij = 1, nbp_lon
+                  index = index + 1
+                  lon_scat(ij,jj) = rlon_g(index)
+                  lat_scat(ij,jj) = rlat_g(index)
+               ENDDO
+            ENDDO
+            lon_scat(:,1) = lon_scat(:,2)
+            lat_scat(:,1) = rlat_g(1)
+            lon_scat(:,nbp_lat) = lon_scat(:,2)
+            lat_scat(:,nbp_lat) = rlat_g(klon_glo)
+         ENDIF
+   
+         CALL bcast(lon_scat)
+         CALL bcast(lat_scat)
+       
+       ENDIF
+!
+! Allouer et initialiser le tableau des voisins et des fraction de continents
+!
+       IF (( .NOT. ALLOCATED(contfrac))) THEN
+          ALLOCATE(contfrac(knon), stat = error)
+          IF (error /= 0) THEN
+             abort_message='Pb allocation contfrac'
+             CALL abort_physic(modname,abort_message,1)
+          ENDIF
+       ENDIF
+
+       DO igrid = 1, knon
+          ireal = knindex(igrid)
+          contfrac(igrid) = pctsrf(ireal,is_ter)
+       ENDDO
+
+
+       IF (grid_type==regular_lonlat) THEN
+ 
+         IF ( (.NOT.ALLOCATED(neighbours))) THEN
+          ALLOCATE(neighbours(knon,8), stat = error)
+          IF (error /= 0) THEN
+             abort_message='Pb allocation neighbours'
+             CALL abort_physic(modname,abort_message,1)
+          ENDIF
+         ENDIF
+         neighbours = -1.
+         CALL Init_neighbours(knon,neighbours,knindex,pctsrf(:,is_ter))
+
+       ELSE IF (grid_type==unstructured) THEN
+ 
+         IF ( (.NOT.ALLOCATED(neighbours))) THEN
+          ALLOCATE(neighbours(knon,12), stat = error)
+          IF (error /= 0) THEN
+             abort_message='Pb allocation neighbours'
+             CALL abort_physic(modname,abort_message,1)
+          ENDIF
+         ENDIF
+         neighbours = -1.
+ 
+       ENDIF
+         
+
+!
+!  Allocation et calcul resolutions
+       IF ( (.NOT.ALLOCATED(resolution))) THEN
+          ALLOCATE(resolution(knon,2), stat = error)
+          IF (error /= 0) THEN
+             abort_message='Pb allocation resolution'
+             CALL abort_physic(modname,abort_message,1)
+          ENDIF
+       ENDIF
+       
+       IF (grid_type==regular_lonlat) THEN
+         DO igrid = 1, knon
+            ij = knindex(igrid)
+            resolution(igrid,1) = dx(ij)
+           resolution(igrid,2) = dy(ij)
+         ENDDO
+       ENDIF
+        
+       ALLOCATE(coastalflow(klon), stat = error)
+       IF (error /= 0) THEN
+          abort_message='Pb allocation coastalflow'
+          CALL abort_physic(modname,abort_message,1)
+       ENDIF
+       
+       ALLOCATE(riverflow(klon), stat = error)
+       IF (error /= 0) THEN
+          abort_message='Pb allocation riverflow'
+          CALL abort_physic(modname,abort_message,1)
+       ENDIF
+!
+! carbon_cycle_cpl not possible with this interface and version of ORHCHIDEE
+!
+! >> PC
+!       IF (carbon_cycle_cpl) THEN
+!          abort_message='carbon_cycle_cpl not yet possible with this interface of ORCHIDEE'
+!          CALL abort_physic(modname,abort_message,1)
+!       END IF
+! << PC
+       
+    ENDIF                          ! (fin debut) 
+ 
+! 
+! Appel a la routine sols continentaux
+!
+    IF (lafin) lrestart_write = .TRUE.
+    IF (check) WRITE(lunout,*)'lafin ',lafin,lrestart_write
+     
+    petA_orc(1:knon) = petBcoef(1:knon) * dtime
+    petB_orc(1:knon) = petAcoef(1:knon)
+    peqA_orc(1:knon) = peqBcoef(1:knon) * dtime
+    peqB_orc(1:knon) = peqAcoef(1:knon)
+
+    cdrag = 0.
+    cdrag(1:knon) = tq_cdrag(1:knon)
+
+! zlev(1:knon) = (100.*plev(1:knon))/((ps(1:knon)/287.05*temp_air(1:knon))*9.80665)
+!    zlev(1:knon) = (100.*plev(1:knon))/((ps(1:knon)/RD*temp_air(1:knon))*RG)
+     zlev(1:knon) = plev(1:knon)*RD*temp_air(1:knon)/((ps(1:knon)*100.0)*RG)
+
+
+! PF et PASB
+!   where(cdrag > 0.01) 
+!     cdrag = 0.01
+!   endwhere
+!  write(*,*)'Cdrag = ',minval(cdrag),maxval(cdrag)
+
+  
+    IF (debut) THEN
+       CALL Init_orchidee_index(knon,knindex,offset,ktindex)
+       CALL Get_orchidee_communicator(orch_comm,orch_mpi_size,orch_mpi_rank, orch_omp_size,orch_omp_rank)
+
+       IF (grid_type==unstructured) THEN
+         IF (knon==0) THEN
+           begin=1
+           end=0
+         ELSE
+           begin=offset+1
+           end=offset+ktindex(knon)
+         ENDIF
+        
+         IF (orch_mpi_rank==orch_mpi_size-1 .AND. orch_omp_rank==orch_omp_size-1) end=nbp_lon*nbp_lat 
+          
+         ALLOCATE(lalo(end-begin+1,2))
+         ALLOCATE(bounds_lalo(end-begin+1,nvertex,2))
+         ALLOCATE(ind_cell(end-begin+1))
+         
+         ALLOCATE(longitude_glo(klon_glo))
+         CALL gather(longitude,longitude_glo)
+         CALL bcast(longitude_glo)
+         lalo(:,2)=longitude_glo(begin:end)*180./PI
+ 
+         ALLOCATE(latitude_glo(klon_glo))
+         CALL gather(latitude,latitude_glo)
+         CALL bcast(latitude_glo)
+         lalo(:,1)=latitude_glo(begin:end)*180./PI
+
+         ALLOCATE(boundslon_glo(klon_glo,nvertex))
+         CALL gather(boundslon,boundslon_glo)
+         CALL bcast(boundslon_glo)
+         bounds_lalo(:,:,2)=boundslon_glo(begin:end,:)*180./PI
+ 
+         ALLOCATE(boundslat_glo(klon_glo,nvertex))
+         CALL gather(boundslat,boundslat_glo)
+         CALL bcast(boundslat_glo)
+         bounds_lalo(:,:,1)=boundslat_glo(begin:end,:)*180./PI
+         
+         ALLOCATE(ind_cell_glo_glo(klon_glo))
+         CALL gather(ind_cell_glo,ind_cell_glo_glo)
+         CALL bcast(ind_cell_glo_glo)
+         ind_cell(:)=ind_cell_glo_glo(begin:end)
+         
+       ENDIF
+       CALL Init_synchro_omp
+
+!$OMP BARRIER
+       
+       IF (knon > 0) THEN
+#ifdef CPP_VEGET
+         CALL Init_intersurf(nbp_lon,nbp_lat,knon,ktindex,offset,orch_omp_size,orch_omp_rank,orch_comm,grid=grid_type)
+#endif
+       ENDIF
+
+       CALL Synchro_omp
+
+       
+       IF (knon > 0) THEN 
+
+#ifdef CPP_VEGET
+
+         CALL intersurf_initialize_gathered (itime+itau_phy-1, nbp_lon, nbp_lat, knon, ktindex, dtime, &
+               lrestart_read, lrestart_write, lalo, contfrac, neighbours, resolution, date0, &
+               zlev,  u1_lay, v1_lay, spechum, temp_air, epot_air, &
+               cdrag, petA_orc, peqA_orc, petB_orc, peqB_orc, &
+               precip_rain, precip_snow, lwdown, swnet, swdown, ps, &
+               evap, fluxsens, fluxlat, coastalflow, riverflow, &
+               tsol_rad, tsurf_new, qsurf, albedo_out, emis_new, z0m_new, &    
+               lon_scat, lat_scat, q2m(1:knon), t2m(1:knon), z0h_new(1:knon), nvm_orch, &
+               grid=grid_type, bounds_latlon=bounds_lalo, cell_area=area, ind_cell_glo=ind_cell, &
+               field_out_names=cfname_out, field_in_names=cfname_in(1:nbcf_in_orc))
+#endif         
+       ENDIF
+
+       CALL Synchro_omp
+
+       albedo_keep(1:knon) = (albedo_out(1:knon,1)+albedo_out(1:knon,2))/2.
+
+    ENDIF
+    
+!  swdown_vrai(1:knon) = swnet(1:knon)/(1. - albedo_keep(1:knon))
+    swdown_vrai(1:knon) = swdown(1:knon)
+!$OMP BARRIER
+
+    IF (knon > 0) THEN
+#ifdef CPP_VEGET    
+       IF (nvm_orch .NE. nvm_lmdz ) THEN
+          abort_message='Pb de dimensiosn PFT: nvm_orch et nvm_lmdz differents.'
+          CALL abort_physic(modname,abort_message,1)
+       ENDIF
+
+       CALL intersurf_main_gathered (itime+itau_phy, nbp_lon, nbp_lat, knon, ktindex, dtime,  &
+            lrestart_read, lrestart_write, lalo, &
+            contfrac, neighbours, resolution, date0, &
+            zlev,  u1_lay(1:knon), v1_lay(1:knon), spechum(1:knon), temp_air(1:knon), epot_air(1:knon), ccanopy(1:knon), &
+            cdrag(1:knon), petA_orc(1:knon), peqA_orc(1:knon), petB_orc(1:knon), peqB_orc(1:knon), &
+            precip_rain(1:knon), precip_snow(1:knon), lwdown(1:knon), swnet(1:knon), swdown_vrai(1:knon), ps(1:knon), &
+            evap(1:knon), fluxsens(1:knon), fluxlat(1:knon), coastalflow(1:knon), riverflow(1:knon), &
+            tsol_rad(1:knon), tsurf_new(1:knon), qsurf(1:knon), albedo_out(1:knon,:), emis_new(1:knon), z0m_new(1:knon), &
+            lon_scat, lat_scat, q2m(1:knon), t2m(1:knon), z0h_new(1:knon),&
+            veget(1:knon,:),lai(1:knon,:),height(1:knon,:),&
+            fields_out=yfields_out(1:knon,1:nbcf_out),  &
+            fields_in=yfields_in(1:knon,1:nbcf_in_orc), &
+            coszang=yrmu0(1:knon))
+#endif       
+    ENDIF
+
+    CALL Synchro_omp
+    
+    albedo_keep(1:knon) = (albedo_out(1:knon,1)+albedo_out(1:knon,2))/2.
+
+!* Send to coupler
+!
+    IF (type_ocean=='couple') THEN
+       CALL cpl_send_land_fields(itime, knon, knindex, &
+            riverflow, coastalflow)
+    ENDIF
+
+    alb1_new(1:knon) = albedo_out(1:knon,1) 
+    alb2_new(1:knon) = albedo_out(1:knon,2)
+
+! Convention orchidee: positif vers le haut
+    fluxsens(1:knon) = -1. * fluxsens(1:knon)
+    fluxlat(1:knon)  = -1. * fluxlat(1:knon)
+    
+!  evap     = -1. * evap
+
+    IF (debut) lrestart_read = .FALSE.
+    
+    IF (debut) CALL Finalize_surf_para
+
+! >> PC
+! Decompressing variables into LMDz for the module carbon_cycle_mod
+! nbcf_in can be zero, in which case the loop does not operate
+! fields_in can then used elsewhere in the model
+     
+     fields_in(:,:)=0.0
+
+     DO nb=1, nbcf_in_orc
+       DO igrid = 1, knon
+        ireal = knindex(igrid)
+        fields_in(ireal,nb)=yfields_in(igrid,nb)
+       ENDDO
+       WRITE(*,*) 'surf_land_orchidee_mod --- yfields_in :',cfname_in(nb)
+     ENDDO
+! >> PC
+    
+  END SUBROUTINE surf_land_orchidee
+!
+!****************************************************************************************
+!
+  SUBROUTINE Init_orchidee_index(knon,knindex,offset,ktindex)
+  USE mod_surf_para
+  USE mod_grid_phy_lmdz
+  
+    INTEGER,INTENT(IN)    :: knon
+    INTEGER,INTENT(IN)    :: knindex(klon)    
+    INTEGER,INTENT(OUT)   :: offset
+    INTEGER,INTENT(OUT)   :: ktindex(klon)
+    
+    INTEGER               :: ktindex_glo(knon_glo)
+    INTEGER               :: offset_para(0:omp_size*mpi_size-1)
+    INTEGER               :: LastPoint
+    INTEGER               :: task
+    
+    ktindex(1:knon)=knindex(1:knon)+(klon_mpi_begin-1)+(klon_omp_begin-1)+nbp_lon-1
+    
+    CALL gather_surf(ktindex(1:knon),ktindex_glo) 
+    
+    IF (is_mpi_root .AND. is_omp_root) THEN
+      LastPoint=0
+      DO Task=0,mpi_size*omp_size-1
+        IF (knon_glo_para(Task)>0) THEN
+           offset_para(task)= LastPoint-MOD(LastPoint,nbp_lon)
+           LastPoint=ktindex_glo(knon_glo_end_para(task))
+        ENDIF
+      ENDDO
+    ENDIF
+    
+    CALL bcast(offset_para)
+    
+    offset=offset_para(omp_size*mpi_rank+omp_rank)
+    
+    ktindex(1:knon)=ktindex(1:knon)-offset
+
+  END SUBROUTINE Init_orchidee_index
+
+!
+!************************* ***************************************************************
+! 
+
+  SUBROUTINE Get_orchidee_communicator(orch_comm, orch_mpi_size, orch_mpi_rank, orch_omp_size,orch_omp_rank)
+  USE  mod_surf_para
+      
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif    
+
+    INTEGER,INTENT(OUT) :: orch_comm
+    INTEGER,INTENT(OUT) :: orch_mpi_size
+    INTEGER,INTENT(OUT) :: orch_mpi_rank
+    INTEGER,INTENT(OUT) :: orch_omp_size
+    INTEGER,INTENT(OUT) :: orch_omp_rank
+    INTEGER             :: color
+    INTEGER             :: i,ierr
+!
+! End definition
+!****************************************************************************************
+    
+    IF (is_omp_root) THEN          
+      
+      IF (knon_mpi==0) THEN 
+         color = 0
+      ELSE 
+         color = 1
+      ENDIF
+    
+#ifdef CPP_MPI    
+      CALL MPI_COMM_SPLIT(COMM_LMDZ_PHY,color,mpi_rank,orch_comm,ierr)
+      CALL MPI_COMM_SIZE(orch_comm,orch_mpi_size,ierr)
+      CALL MPI_COMM_RANK(orch_comm,orch_mpi_rank,ierr)
+#endif
+    
+    ENDIF
+    CALL bcast_omp(orch_comm)
+    
+    IF (knon_mpi /= 0) THEN
+      orch_omp_size=0
+      DO i=0,omp_size-1
+        IF (knon_omp_para(i) /=0) THEN
+          orch_omp_size=orch_omp_size+1
+          IF (i==omp_rank) orch_omp_rank=orch_omp_size-1
+        ENDIF
+      ENDDO
+    ENDIF
+    
+  END SUBROUTINE Get_orchidee_communicator
+!
+!****************************************************************************************
+!  
+
+  SUBROUTINE Init_neighbours(knon,neighbours,knindex,pctsrf)
+    USE mod_grid_phy_lmdz
+    USE mod_surf_para    
+    USE indice_sol_mod
+
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif    
+
+! Input arguments
+!****************************************************************************************
+    INTEGER, INTENT(IN)                     :: knon
+    INTEGER, DIMENSION(klon), INTENT(IN)    :: knindex
+    REAL, DIMENSION(klon), INTENT(IN)       :: pctsrf
+    
+! Output arguments
+!****************************************************************************************
+    INTEGER, DIMENSION(knon,8), INTENT(OUT) :: neighbours
+
+! Local variables
+!****************************************************************************************
+    INTEGER                              :: i, igrid, jj, ij, iglob
+    INTEGER                              :: ierr, ireal, index
+    INTEGER, DIMENSION(8,3)              :: off_ini
+    INTEGER, DIMENSION(8)                :: offset  
+    INTEGER, DIMENSION(nbp_lon,nbp_lat)  :: correspond
+    INTEGER, DIMENSION(knon_glo)         :: ktindex_glo
+    INTEGER, DIMENSION(knon_glo,8)       :: neighbours_glo
+    REAL, DIMENSION(klon_glo)            :: pctsrf_glo
+    INTEGER                              :: ktindex(klon)
+!
+! End definition
+!****************************************************************************************
+
+    ktindex(1:knon)=knindex(1:knon)+(klon_mpi_begin-1)+(klon_omp_begin-1)+nbp_lon-1
+    
+    CALL gather_surf(ktindex(1:knon),ktindex_glo)
+    CALL gather(pctsrf,pctsrf_glo)
+    
+    IF (is_mpi_root .AND. is_omp_root) THEN
+      neighbours_glo(:,:)=-1
+!  Initialisation des offset    
+!
+! offset bord ouest
+       off_ini(1,1) = - nbp_lon   ; off_ini(2,1) = - nbp_lon + 1     ; off_ini(3,1) = 1
+       off_ini(4,1) = nbp_lon + 1 ; off_ini(5,1) = nbp_lon           ; off_ini(6,1) = 2 * nbp_lon - 1
+       off_ini(7,1) = nbp_lon -1  ; off_ini(8,1) = - 1 
+! offset point normal
+       off_ini(1,2) = - nbp_lon   ; off_ini(2,2) = - nbp_lon + 1     ; off_ini(3,2) = 1
+       off_ini(4,2) = nbp_lon + 1 ; off_ini(5,2) = nbp_lon           ; off_ini(6,2) = nbp_lon - 1
+       off_ini(7,2) = -1          ; off_ini(8,2) = - nbp_lon - 1
+! offset bord   est
+       off_ini(1,3) = - nbp_lon   ; off_ini(2,3) = - 2 * nbp_lon + 1 ; off_ini(3,3) = - nbp_lon + 1
+       off_ini(4,3) =  1          ; off_ini(5,3) = nbp_lon           ; off_ini(6,3) = nbp_lon - 1
+       off_ini(7,3) = -1          ; off_ini(8,3) = - nbp_lon - 1
+!
+! Attention aux poles
+!
+       DO igrid = 1, knon_glo
+          index = ktindex_glo(igrid)
+          jj = INT((index - 1)/nbp_lon) + 1
+          ij = index - (jj - 1) * nbp_lon
+          correspond(ij,jj) = igrid
+       ENDDO
+!sonia : Les mailles des voisines doivent etre toutes egales (pour couplage orchidee)
+       IF (knon_glo == 1) THEN
+         igrid = 1
+         DO i = 1,8
+           neighbours_glo(igrid, i) = igrid
+         ENDDO
+       ELSE
+       
+       DO igrid = 1, knon_glo
+          iglob = ktindex_glo(igrid)
+          
+          IF (MOD(iglob, nbp_lon) == 1) THEN
+             offset = off_ini(:,1)
+          ELSE IF(MOD(iglob, nbp_lon) == 0) THEN
+             offset = off_ini(:,3)
+          ELSE
+             offset = off_ini(:,2)
+          ENDIF
+          
+          DO i = 1, 8
+             index = iglob + offset(i)
+             ireal = (MIN(MAX(1, index - nbp_lon + 1), klon_glo))
+             IF (pctsrf_glo(ireal) > EPSFRA) THEN
+                jj = INT((index - 1)/nbp_lon) + 1
+                ij = index - (jj - 1) * nbp_lon
+                neighbours_glo(igrid, i) = correspond(ij, jj)
+             ENDIF
+          ENDDO
+       ENDDO
+       ENDIF !fin knon_glo == 1
+
+    ENDIF
+    
+    DO i = 1, 8
+      CALL scatter_surf(neighbours_glo(:,i),neighbours(1:knon,i))
+    ENDDO
+  END SUBROUTINE Init_neighbours
+
+!
+!****************************************************************************************
+!
+#endif
+END MODULE surf_land_orchidee_nolic_mod
Index: LMDZ6/branches/Portage_acc/libf/phylmd/surf_landice_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/surf_landice_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/surf_landice_mod.F90	(revision 4446)
@@ -30,5 +30,5 @@
     USE cpl_mod,          ONLY : cpl_send_landice_fields
     USE calcul_fluxs_mod
-    USE phys_output_var_mod
+    USE phys_output_var_mod, ONLY : snow_o,zfra_o
 !FC
     USE ioipsl_getin_p_mod, ONLY : getin_p
@@ -115,4 +115,5 @@
     INTEGER                  :: i,j,nt
     REAL, DIMENSION(klon)    :: fqfonte,ffonte
+    REAL, DIMENSION(klon)    :: run_off_lic_frac
     REAL, DIMENSION(klon)    :: emis_new                  !Emissivity
     REAL, DIMENSION(klon)    :: swdown,lwdown
@@ -156,6 +157,4 @@
            PRINT*, 'alb_nir_sno_lic',alb_nir_sno_lic
   
-!  z0m=1.e-3
-!  z0h = z0m
   firstcall=.false.
   ENDIF
@@ -351,7 +350,7 @@
 !
 !****************************************************************************************
-    z0m=1.e-3
-    z0h = z0m
-    z0m = SQRT(z0m**2+rugoro**2)
+    z0m = z0m_landice
+    z0h = z0h_landice
+    !z0m = SQRT(z0m**2+rugoro**2)
 
 
@@ -363,8 +362,15 @@
 ! Send run-off on land-ice to coupler if coupled ocean.
 ! run_off_lic has been calculated in fonte_neige or surf_inlandsis
-!
-!****************************************************************************************
-    IF (type_ocean=='couple') THEN
-       CALL cpl_send_landice_fields(itime, knon, knindex, run_off_lic)
+! If landice_opt>=2, corresponding call is done from surf_land_orchidee
+!****************************************************************************************
+    IF (type_ocean=='couple' .AND. landice_opt .LT. 2) THEN
+       ! Compress fraction where run_off_lic is active (here all pctsrf(is_lic))
+       run_off_lic_frac(:)=0.0
+       DO j = 1, knon
+          i = knindex(j)
+          run_off_lic_frac(j) = pctsrf(i,is_lic)
+       ENDDO
+
+       CALL cpl_send_landice_fields(itime, knon, knindex, run_off_lic, run_off_lic_frac)
     ENDIF
 
@@ -373,14 +379,4 @@
 
   
-!****************************************************************************************
-! Etienne: comment these lines because of duplication just below
-!       snow_o=0.
-!       zfra_o = 0.
-!       DO j = 1, knon
-!           i = knindex(j)
-!           snow_o(i) = snow(j) 
-!           zfra_o(i) = zfra(j)
-!       ENDDO
-!
 !****************************************************************************************
        snow_o=0.
Index: LMDZ6/branches/Portage_acc/libf/phylmd/surf_ocean_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/surf_ocean_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/surf_ocean_mod.F90	(revision 4446)
@@ -20,6 +20,6 @@
        z0m, z0h, SFRWL, alb_dir_new, alb_dif_new, evap, fluxsens, fluxlat, & 
        tsurf_new, dflux_s, dflux_l, lmt_bils, &
-       flux_u1, flux_v1, delta_sst, delta_sal, ds_ns, dt_ns, dter, dser, tkt, tks, &
-       taur, sss)
+       flux_u1, flux_v1, delta_sst, delta_sal, ds_ns, dt_ns, dter, dser, &
+       dt_ds, tkt, tks, taur, sss)
 
     use albedo, only: alboc, alboc_cd
@@ -94,4 +94,16 @@
     ! minus foundation temperature. (Can be negative.) In K.
 
+    REAL, intent(inout):: dter(:) ! (knon)
+    ! Temperature variation in the diffusive microlayer, that is
+    ! ocean-air interface temperature minus subskin temperature. In
+    ! K.
+
+    REAL, intent(inout):: dser(:) ! (knon)
+    ! Salinity variation in the diffusive microlayer, that is
+    ! ocean-air interface salinity minus subskin salinity. In ppt.
+
+    real, intent(inout):: dt_ds(:) ! (knon)
+    ! (tks / tkt) * dTer, in K
+
     ! Output variables
     !**************************************************************************
@@ -109,13 +121,4 @@
     REAL, DIMENSION(klon), INTENT(OUT)       :: flux_u1, flux_v1
 
-    REAL, intent(out):: dter(:) ! (knon)
-    ! Temperature variation in the diffusive microlayer, that is
-    ! ocean-air interface temperature minus subskin temperature. In
-    ! K.
-
-    REAL, intent(out):: dser(:) ! (knon)
-    ! Salinity variation in the diffusive microlayer, that is
-    ! ocean-air interface salinity minus subskin salinity. In ppt.
-
     REAL, intent(out):: tkt(:) ! (knon)
     ! épaisseur (m) de la couche de diffusion thermique (microlayer)
@@ -192,5 +195,5 @@
             qsurf, evap, fluxsens, fluxlat, flux_u1, flux_v1, &
             tsurf_new, dflux_s, dflux_l, sens_prec_liq, sss, delta_sal, rhoa, &
-            delta_sst)
+            delta_sst, dTer, dSer, dt_ds)
 
     CASE('slab')
@@ -331,5 +334,9 @@
        delta_sst = t_int - tsurf_new(:knon)
        delta_sal = s_int - sss(:knon)
-       if (activate_ocean_skin >= 2) tsurf_new(:knon) = t_int
+
+       if (activate_ocean_skin == 2) then
+          tsurf_new(:knon) = t_int
+          if (type_ocean == 'couple') dt_ds = (tks / tkt) * dter
+       end if
     end if
     
Index: LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_down.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_down.F90	(revision 4446)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_down.F90	(revision 4446)
@@ -0,0 +1,300 @@
+SUBROUTINE thermcell_updown_dq(ngrid,nlay,ptimestep,lmax,eup,dup,edn,ddn,masse,trac,dtrac)
+
+USE thermcell_ini_mod, ONLY: iflag_thermals_down
+
+
+!-----------------------------------------------------------------
+! thermcell_updown_dq: computes the tendency of tracers associated
+! with the presence of convective up/down drafts
+! This routine that has been collectively written during the 
+! "ateliers downdrafts" in 2022/2023
+! Maelle, Frédéric, Catherine, Fleur, Florent, Etienne
+!------------------------------------------------------------------
+
+
+   IMPLICIT NONE
+
+! declarations
+!==============================================================
+
+! input/output
+
+   integer,intent(in)  :: ngrid ! number of horizontal grid points
+   integer, intent(in) :: nlay  ! number of vertical layers
+   real,intent(in) :: ptimestep ! time step of the physics [s]
+   real,intent(in), dimension(ngrid,nlay) :: eup ! entrainment to updrafts * dz [same unit as flux]
+   real,intent(in), dimension(ngrid,nlay) :: dup ! detrainment from updrafts * dz [same unit as flux]
+   real,intent(in), dimension(ngrid,nlay) :: edn ! entrainment to downdrafts * dz [same unit as flux]
+   real,intent(in), dimension(ngrid,nlay) :: ddn ! detrainment from downdrafts * dz [same unit as flux]
+   real,intent(in), dimension(ngrid,nlay) :: masse ! mass of layers = rho dz 
+   real,intent(in), dimension(ngrid,nlay) :: trac ! tracer 
+   integer, intent(in), dimension(ngrid) :: lmax ! max level index at which downdraft are present
+   real,intent(out),dimension(ngrid,nlay) ::dtrac ! tendance du traceur
+
+   
+! Local
+
+   real, dimension(ngrid,nlay+1) :: fup,fdn,fc,fthu,fthd,fthe,fthtot
+   real, dimension(ngrid,nlay) :: tracu,tracd,traci,tracold
+   real :: www, mstar_inv
+   integer ig,ilay
+   real, dimension(ngrid,nlay):: s1,s2,num !coefficients pour la resolution implicite
+   integer :: iflag_impl=1 ! 0 pour explicite, 1 pour implicite "classique", 2 pour implicite avec entrainement et detrainement
+   
+   fdn(:,:)=0.
+   fup(:,:)=0.
+   fc(:,:)=0.
+   fthu(:,:)=0.
+   fthd(:,:)=0.
+   fthe(:,:)=0.
+   fthtot(:,:)=0.
+   tracd(:,:)=0.
+   tracu(:,:)=0.
+   traci(:,:)=trac(:,:)
+   tracold(:,:)=trac(:,:)
+   s1(:,:)=0.
+   s2(:,:)=0.
+   num(:,:)=1.
+
+   if ( iflag_thermals_down < 10 ) then
+        stop 'thermcell_down_dq = 0 or >= 10'
+   else
+        iflag_impl=iflag_thermals_down-10
+   endif
+      
+
+   ! lmax : indice tel que fu(kmax+1)=0
+   ! Dans ce cas, pas besoin d'initialiser tracd(lmax) ( =trac(lmax) )
+   ! Boucle pour le downdraft
+   do ilay=nlay,1,-1
+      do ig=1,ngrid
+         !if ( lmax(ig) > nlay - 2 ) stop "les thermiques montent trop haut"
+         if (ilay.le.lmax(ig) .and. lmax(ig)>1 ) then
+            fdn(ig,ilay)=fdn(ig,ilay+1)+edn(ig,ilay)-ddn(ig,ilay)
+            if ( fdn(ig,ilay)+ddn(ig,ilay) > 0. ) then
+               www=fdn(ig,ilay+1)/ (fdn(ig,ilay)+ddn(ig,ilay))
+            else
+               www=0.
+            endif
+            tracd(ig,ilay)=www*tracd(ig,ilay+1) + (1.-www)*trac(ig,ilay)
+         endif
+      enddo 
+   enddo !Fin boucle sur l'updraft
+   fdn(:,1)=0.
+
+   !Boucle pour l'updraft
+   do ilay=1,nlay,1
+      do ig=1,ngrid
+         if (ilay.lt.lmax(ig) .and. lmax(ig)>1) then
+            fup(ig,ilay+1)=fup(ig,ilay)+eup(ig,ilay)-dup(ig,ilay)
+            if (fup(ig,ilay+1)+dup(ig,ilay) > 0.) then
+               www=fup(ig,ilay)/(fup(ig,ilay+1)+dup(ig,ilay))
+            else
+               www=0.
+            endif
+            if (ilay == 1 ) then
+               tracu(ig,ilay)=trac(ig,ilay)
+            else
+               tracu(ig,ilay)=www*tracu(ig,ilay-1)+(1.-www)*trac(ig,ilay)
+            endif
+         endif
+      enddo 
+      enddo !fin boucle sur le downdraft
+
+   ! Calcul des flux des traceurs dans les updraft et les downdrfat 
+   ! et du flux de masse compensateur
+   ! en ilay=1 et nlay+1, fthu=0 et fthd=0
+   fthu(:,1)=0.
+   fthu(:,nlay+1)=0.
+   fthd(:,1)=0.
+   fthd(:,nlay+1)=0.
+   fc(:,1)=0.
+   fc(:,nlay+1)=0.
+   do ilay=2,nlay,1 !boucle sur les interfaces
+     do ig=1,ngrid
+       fthu(ig,ilay)=fup(ig,ilay)*tracu(ig,ilay-1)
+       fthd(ig,ilay)=-fdn(ig,ilay)*tracd(ig,ilay)
+       fc(ig,ilay)=fup(ig,ilay)-fdn(ig,ilay)
+     enddo
+   enddo
+   
+
+   !Boucle pour calculer le flux du traceur flux updraft, flux downdraft, flux compensatoire
+   !Methode explicite : 
+   if(iflag_impl==0) then
+     do ilay=2,nlay,1
+       do ig=1,ngrid
+         !!!!ATTENTION HYPOTHESE de FLUX COMPENSATOIRE DESCENDANT ET DONC comme schema amont on va chercher trac au dessus!!!!!
+         !!!! tentative de prise en compte d'un flux compensatoire montant  !!!!
+         if (fup(ig,ilay)-fdn(ig,ilay) .lt. 0.) then
+            write(*,*) 'flux compensatoire montant, cas non traite par thermcell_updown_dq'
+            stop          
+            !fthe(ig,ilay)=(fup(ig,ilay)-fdn(ig,ilay))*trac(ig,ilay-1)
+         else
+            fthe(ig,ilay)=-(fup(ig,ilay)-fdn(ig,ilay))*trac(ig,ilay)
+         endif
+         !! si on voulait le prendre en compte on
+         !fthe(ig,ilay)=-(fup(ig,ilay)-fdn(ig,ilay))*trac(ig,ilay-1)
+         fthtot(ig,ilay)=fthu(ig,ilay)+fthd(ig,ilay)+fthe(ig,ilay)
+       enddo
+     enddo
+     !Boucle pour calculer trac
+     do ilay=1,nlay
+       do ig=1,ngrid
+         dtrac(ig,ilay)=(fthtot(ig,ilay)-fthtot(ig,ilay+1))/masse(ig,ilay)
+!         trac(ig,ilay)=trac(ig,ilay) + (fthtot(ig,ilay)-fthtot(ig,ilay+1))*(ptimestep/masse(ig,ilay))
+       enddo
+     enddo !fin du calculer de la tendance du traceur avec la methode explicite
+
+   !!! Reecriture du schéma explicite avec les notations du schéma implicite
+   else if(iflag_impl==-1) then
+     write(*,*) 'nouveau schéma explicite !!!'
+     !!! Calcul de s1
+     do ilay=1,nlay
+       do ig=1,ngrid
+         s1(ig,ilay)=fthu(ig,ilay)-fthu(ig,ilay+1)+fthd(ig,ilay)-fthd(ig,ilay+1)
+         s2(ig,ilay)=s1(ig,ilay)+fthe(ig,ilay)-fthe(ig,ilay+1)
+       enddo
+     enddo
+
+     do ilay=2,nlay,1
+       do ig=1,ngrid
+         if (fup(ig,ilay)-fdn(ig,ilay) .lt. 0.) then
+            write(*,*) 'flux compensatoire montant, cas non traite par thermcell_updown_dq'
+            stop          
+         else
+            fthe(ig,ilay)=-(fup(ig,ilay)-fdn(ig,ilay))*trac(ig,ilay)
+         endif
+         fthtot(ig,ilay)=fthu(ig,ilay)+fthd(ig,ilay)+fthe(ig,ilay)
+       enddo
+     enddo
+     !Boucle pour calculer trac
+     do ilay=1,nlay
+       do ig=1,ngrid
+         ! dtrac(ig,ilay)=(fthtot(ig,ilay)-fthtot(ig,ilay+1))/masse(ig,ilay)
+         dtrac(ig,ilay)=(s1(ig,ilay)+fthe(ig,ilay)-fthe(ig,ilay+1))/masse(ig,ilay)
+!         trac(ig,ilay)=trac(ig,ilay) + (fthtot(ig,ilay)-fthtot(ig,ilay+1))*(ptimestep/masse(ig,ilay))
+!         trac(ig,ilay)=trac(ig,ilay) + (s1(ig,ilay)+fthe(ig,ilay)-fthe(ig,ilay+1))*(ptimestep/masse(ig,ilay))
+       enddo
+     enddo !fin du calculer de la tendance du traceur avec la methode explicite
+
+   else if (iflag_impl==1) then
+     do ilay=1,nlay
+       do ig=1,ngrid
+         s1(ig,ilay)=fthu(ig,ilay)-fthu(ig,ilay+1)+fthd(ig,ilay)-fthd(ig,ilay+1)
+       enddo
+     enddo
+     
+     !Boucle pour calculer traci = trac((t+dt)
+     do ilay=nlay-1,1,-1
+       do ig=1,ngrid
+         if((fup(ig,ilay)-fdn(ig,ilay)) .lt. 0) then
+            write(*,*) 'flux compensatoire montant, cas non traite par thermcell_updown_dq dans le cas d une resolution implicite, ilay : ', ilay
+            stop  
+         else
+           mstar_inv=ptimestep/masse(ig,ilay)
+           traci(ig,ilay)=((traci(ig,ilay+1)*fc(ig,ilay+1)+s1(ig,ilay))*mstar_inv+tracold(ig,ilay))/(1.+fc(ig,ilay)*mstar_inv)
+         endif
+       enddo
+     enddo
+     do ilay=1,nlay
+       do ig=1,ngrid
+         dtrac(ig,ilay)=(traci(ig,ilay)-tracold(ig,ilay))/ptimestep
+       enddo
+     enddo
+
+   else
+      write(*,*) 'valeur de iflag_impl non prevue'
+      stop
+
+   endif
+
+ RETURN
+   END
+
+!=========================================================================
+
+   SUBROUTINE thermcell_down(ngrid,nlay,po,pt,pu,pv,pplay,pplev,  &
+     &           lmax,fup,eup,dup,theta)
+
+!--------------------------------------------------------------
+!thermcell_down: calcul des propri??t??s du panache descendant.
+!--------------------------------------------------------------
+
+
+   USE thermcell_ini_mod, ONLY : prt_level,RLvCp,RKAPPA,RETV,fact_thermals_down
+   IMPLICIT NONE
+
+! arguments
+
+   integer,intent(in) :: ngrid,nlay
+   real,intent(in), dimension(ngrid,nlay) :: po,pt,pu,pv,pplay,eup,dup
+   real,intent(in), dimension(ngrid,nlay) :: theta
+   real,intent(in), dimension(ngrid,nlay+1) :: pplev,fup
+   integer, intent(in), dimension(ngrid) :: lmax
+
+
+   
+! Local
+
+   real, dimension(ngrid,nlay) :: edn,ddn,thetad
+   real, dimension(ngrid,nlay+1) :: fdn
+
+   integer ig,ilay
+   real dqsat_dT
+   logical mask(ngrid,nlay)
+
+   edn(:,:)=0.
+   ddn(:,:)=0.
+   fdn(:,:)=0.
+   thetad(:,:)=0.
+
+   ! lmax : indice tel que fu(kmax+1)=0
+   
+   ! Dans ce cas, pas besoin d'initialiser thetad(lmax) ( =theta(lmax) )
+
+! FH MODIFS APRES REUNIONS POUR COMMISSIONS
+! quelques erreurs de declaration
+! probleme si lmax=1 ce qui a l'air d'??tre le cas en d??but de simu. Devrait ??tre 0 ?
+! Remarques :
+! on pourrait ??crire la formule de thetad
+!    www=fdn(ig,ilay+1)/ (fdn(ig,ilay)+ddn(ig,ilay))
+!    thetad(ig,ilay)= www * thetad(ig,ilay+1) + (1.-www) * theta(ig,ilay) 
+! Elle a l'avantage de bien montr?? la conservation, l'id??e fondamentale dans le 
+!   transport qu'on ne fait que sommer des "sources" au travers d'un "propagateur"
+!   (Green)
+! Elle montre aussi beaucoup plus clairement pourquoi on n'a pas ?? se souccier (trop)
+!   de la possible nulit?? du d??nominateur
+
+
+   do ilay=nlay,1,-1
+      do ig=1,ngrid
+         if (ilay.le.lmax(ig).and.lmax(ig)>1) then
+            edn(ig,ilay)=fact_thermals_down*dup(ig,ilay)
+            ddn(ig,ilay)=fact_thermals_down*eup(ig,ilay)
+            fdn(ig,ilay)=fdn(ig,ilay+1)+edn(ig,ilay)-ddn(ig,ilay)
+            thetad(ig,ilay)=( fdn(ig,ilay+1)*thetad(ig,ilay+1) + edn(ig,ilay)*theta(ig,ilay) ) / (fdn(ig,ilay)+ddn(ig,ilay))
+         endif
+      enddo 
+   enddo
+
+   ! Suite du travail :
+   ! Ecrire la conservervation de theta_l dans le panache descendant
+   ! Eventuellement faire la transformation theta_l -> theta_v
+   ! Si l'air est sec (et qu'on oublie le c??t?? theta_v) on peut
+   ! se contenter de conserver theta.
+   !
+   ! Connaissant thetadn, on peut calculer la flotabilit??.
+   ! Connaissant la flotabilit??, on peut calculer w de proche en proche
+   ! On peut calculer le detrainement de facon ?? garder alpha*rho = cste
+   ! On en d??duit l'entrainement lat??ral
+   ! C'est le mod??le des mini-projets.
+
+!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+! Initialisations :
+!------------------
+
+
+!
+ RETURN
+   END
Index: LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_dq.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_dq.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_dq.F90	(revision 4446)
@@ -17,21 +17,20 @@
 !=======================================================================
 
-      integer ngrid,nlay,impl
-
-      real ptimestep
-      real masse(ngrid,nlay),fm(ngrid,nlay+1)
-      real entr(ngrid,nlay)
-      real q(ngrid,nlay)
-      real dq(ngrid,nlay)
-      integer lev_out                           ! niveau pour les print
-
-      real qa(ngrid,nlay),detr(ngrid,nlay),wqd(ngrid,nlay+1)
-
+! arguments
+      integer, intent(in) :: ngrid,nlay,impl
+      real, intent(in) :: ptimestep
+      real, intent(in), dimension(ngrid,nlay) :: masse
+      real, intent(inout), dimension(ngrid,nlay) :: entr,q
+      real, intent(in), dimension(ngrid,nlay+1) :: fm
+      real, intent(out), dimension(ngrid,nlay) :: dq,qa
+      integer, intent(in) :: lev_out                           ! niveau pour les print
+
+! Local
+      real, dimension(ngrid,nlay) :: detr,qold
+      real, dimension(ngrid,nlay+1) :: wqd,fqa
       real zzm
-
       integer ig,k
       real cfl
 
-      real qold(ngrid,nlay),fqa(ngrid,nlay+1)
       integer niter,iter
       CHARACTER (LEN=20) :: modname='thermcell_dq'
@@ -40,9 +39,11 @@
 
 ! Old explicite scheme
-      if (impl<=-1) then
+if (impl<=-1) then
+
          call thermcell_dq_o(ngrid,nlay,impl,ptimestep,fm,entr,  &
      &           masse,q,dq,qa,lev_out)
-         return
-      endif
+
+else
+  
 
 ! Calcul du critere CFL pour l'advection dans la subsidence
@@ -143,6 +144,8 @@
       enddo
 
-return
+endif ! impl=-1
+RETURN
 end
+
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Index: LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_flux2.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_flux2.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_flux2.F90	(revision 4446)
@@ -2,5 +2,5 @@
 ! $Id$
 !
-      SUBROUTINE thermcell_flux2(ngrid,klev,ptimestep,masse, &
+      SUBROUTINE thermcell_flux2(ngrid,nlay,ptimestep,masse, &
      &       lalim,lmax,alim_star,  &
      &       entr_star,detr_star,f,rhobarz,zlev,zw2,fm,entr,  &
@@ -16,31 +16,30 @@
       IMPLICIT NONE
       
+! arguments
+      INTEGER, intent(in) :: ngrid,nlay
+      REAL, intent(in) :: ptimestep
+      REAL, intent(in), dimension(ngrid,nlay) :: masse
+      INTEGER, intent(in), dimension(ngrid) :: lalim,lmax
+      REAL, intent(in), dimension(ngrid,nlay) :: alim_star,entr_star,detr_star
+      REAL, intent(in), dimension(ngrid) :: f
+      REAL, intent(in), dimension(ngrid,nlay) :: rhobarz
+      REAL, intent(in), dimension(ngrid,nlay+1) :: zw2,zlev
+! FH : laisser ca le temps de verifier qu'on a bien fait de commenter les
+!      lignes faisant apparaitre zqla, zmax ...
+!     REAL, intent(in), dimension(ngrid) :: zmax(ngrid)
+!     enlever aussi zqla
+      REAL, intent(in), dimension(ngrid,nlay) :: zqla  ! not used
+      integer, intent(in) :: lev_out, lunout1
+
+      REAL,intent(out), dimension(ngrid,nlay) :: entr,detr
+      REAL,intent(out), dimension(ngrid,nlay+1) :: fm
+
+! local
       INTEGER ig,l
-      INTEGER ngrid,klev
-      
-      REAL alim_star(ngrid,klev),entr_star(ngrid,klev)
-      REAL detr_star(ngrid,klev)
-      REAL zw2(ngrid,klev+1)
-      REAL zlev(ngrid,klev+1)
-      REAL masse(ngrid,klev)
-      REAL ptimestep
-      REAL rhobarz(ngrid,klev)
-      REAL f(ngrid)
-      INTEGER lmax(ngrid)
-      INTEGER lalim(ngrid)
-      REAL zqla(ngrid,klev)
-      REAL zmax(ngrid)
-
+      integer igout,lout
+      REAL zfm
       integer ncorecfm1,ncorecfm2,ncorecfm3,ncorecalpha
       integer ncorecfm4,ncorecfm5,ncorecfm6,ncorecfm7,ncorecfm8
       
-
-      REAL entr(ngrid,klev),detr(ngrid,klev)
-      REAL fm(ngrid,klev+1)
-      REAL zfm
-
-      integer igout,lout
-      integer lev_out
-      integer lunout1
 
       REAL f_old,ddd0,eee0,ddd,eee,zzz
@@ -90,5 +89,5 @@
 
       if (check_debug) then
-      do l=1,klev
+      do l=1,nlay
          do ig=1,ngrid
             if (l.le.lmax(ig)) then
@@ -118,5 +117,5 @@
 !-------------------------------------------------------------------------
 
-      do l=1,klev
+      do l=1,nlay
          entr(:,l)=f(:)*(entr_star(:,l)+alim_star(:,l))
          detr(:,l)=f(:)*detr_star(:,l)
@@ -135,5 +134,5 @@
 
       fm(:,1)=0.
-      do l=1,klev
+      do l=1,nlay
          do ig=1,ngrid
             if (l.lt.lmax(ig)) then
@@ -154,5 +153,5 @@
 ! autres corrections.
 
-      do l=1,klev
+      do l=1,nlay
          do ig=1,ngrid
             if (detr(ig,l).gt.fm(ig,l)) then
@@ -164,5 +163,5 @@
 
 !      if (prt_level.ge.10) &
-!    &    call printflux(ngrid,klev,lunout1,igout,f,lmax,lalim, &
+!    &    call printflux(ngrid,nlay,lunout1,igout,f,lmax,lalim, &
 !    &    ptimestep,masse,entr,detr,fm,'2  ')
 
@@ -178,5 +177,5 @@
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-      do l=1,klev
+      do l=1,nlay
 
          do ig=1,ngrid
@@ -196,5 +195,5 @@
 !-------------------------------------------------------------------------
 
-!     do l=1,klev
+!     do l=1,nlay
          do ig=1,ngrid
             if (fm(ig,l+1).lt.0.) then
@@ -215,5 +214,5 @@
 !-------------------------------------------------------------------------
       if (iflag_thermals_optflux==0) then 
-!     do l=1,klev
+!     do l=1,nlay
          do ig=1,ngrid
           if (l.ge.lalim(ig).and.l.le.lmax(ig) &
@@ -241,5 +240,5 @@
 !-------------------------------------------------------------------------
       if (iflag_thermals_optflux==0) then
-!     do l=1,klev
+!     do l=1,nlay
          do ig=1,ngrid
             if ((fm(ig,l+1).gt.fm(ig,l)).and.(l.gt.lalim(ig))) then
@@ -264,5 +263,5 @@
       if(1.eq.1) then
 
-!     do l=1,klev
+!     do l=1,nlay
 
 
@@ -337,5 +336,5 @@
 !-------------------------------------------------------------------------
 
-!     do l=1,klev
+!     do l=1,nlay
          do ig=1,ngrid
             if (fm(ig,l+1).lt.0.) then
@@ -386,5 +385,5 @@
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-!    do l=1,klev
+!    do l=1,nlay
         do ig=1,ngrid
            if (zw2(ig,l+1).gt.1.e-10) then
@@ -393,6 +392,4 @@
               f_old=fm(ig,l+1)
               fm(ig,l+1)=zfm
-!             zw2(ig,l+1)=0.
-!             zqla(ig,l+1)=0.
               detr(ig,l)=detr(ig,l)+f_old-fm(ig,l+1)
 !             lmax(ig)=l+1
@@ -415,5 +412,5 @@
 
 !      if (prt_level.ge.10) &
-!    &    call printflux(ngrid,klev,lunout1,igout,f,lmax,lalim, &
+!    &    call printflux(ngrid,nlay,lunout1,igout,f,lmax,lalim, &
 !    &    ptimestep,masse,entr,detr,fm,'8  ')
 
@@ -426,5 +423,5 @@
       if (1.eq.1) then
       labort_physic=.false.
-      do l=1,klev-1
+      do l=1,nlay-1
          do ig=1,ngrid
             eee0=entr(ig,l)
@@ -507,8 +504,8 @@
 
 !      if (prt_level.ge.10) &
-!    &    call printflux(ngrid,klev,lunout1,igout,f,lmax,lalim, &
+!    &    call printflux(ngrid,nlay,lunout1,igout,f,lmax,lalim, &
 !    &    ptimestep,masse,entr,detr,fm,'fin')
 
 
-      return
+ RETURN
       end
Index: LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_ini_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_ini_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_ini_mod.F90	(revision 4446)
@@ -3,9 +3,11 @@
 
 save
+
    integer :: dvdq=1,dqimpl=-1,prt_level=0,lunout
    real RG,RD,RCPD,RKAPPA,RLVTT,RLvCp,RETV, RTT
    real           :: r_aspect_thermals,tau_thermals,fact_thermals_ed_dz
    integer        :: iflag_thermals_ed,iflag_thermals_optflux,iflag_thermals_closure
-
+   integer        :: iflag_thermals_down
+   real           :: fact_thermals_down
 
 !$OMP THREADPRIVATE(dvdq,dqimpl,prt_level,lunout)
@@ -13,4 +15,7 @@
 !$OMP THREADPRIVATE(r_aspect_thermals,tau_thermals,fact_thermals_ed_dz)
 !$OMP THREADPRIVATE(iflag_thermals_ed,iflag_thermals_optflux,iflag_thermals_closure)
+!$OMP THREADPRIVATE(iflag_thermals_down)
+!$OMP THREADPRIVATE(fact_thermals_down)
+
 
    REAL, SAVE :: fact_epsilon=0.002
@@ -85,4 +90,10 @@
    CALL getin_p('iflag_thermals_closure',iflag_thermals_closure)
 
+   iflag_thermals_down = 0
+   CALL getin_p('iflag_thermals_down',iflag_thermals_down)
+
+   fact_thermals_down = 0.5
+   CALL getin_p('fact_thermals_down',fact_thermals_down)
+
      CALL getin_p('thermals_fact_epsilon',fact_epsilon)
      CALL getin_p('thermals_betalpha',betalpha)
Index: LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_main.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_main.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_main.F90	(revision 4446)
@@ -1,3 +1,2 @@
-
 ! $Id$
 !
@@ -19,8 +18,9 @@
       USE thermcell_ini_mod, ONLY: thermcell_ini,dqimpl,dvdq,prt_level,lunout,prt_level
       USE thermcell_ini_mod, ONLY: iflag_thermals_closure,iflag_thermals_ed,tau_thermals,r_aspect_thermals
+      USE thermcell_ini_mod, ONLY: iflag_thermals_down, fact_thermals_down
       USE thermcell_ini_mod, ONLY: RD,RG
 
 #ifdef ISO
-  USE infotrac_phy, ONLY : ntraciso
+  USE infotrac_phy, ONLY : ntiso
 #ifdef ISOVERIF
   USE isotopes_mod, ONLY : iso_eau,iso_HDO
@@ -61,4 +61,20 @@
 !    15 and 17 correspond to the activation of the stratocumulus "bidouille"
 !
+! Using
+!    abort_physic 
+!    iso_verif_aberrant_encadre
+!    iso_verif_egalite
+!    test_ltherm
+!    thermcell_closure
+!    thermcell_dq
+!    thermcell_dry
+!    thermcell_dv2
+!    thermcell_env
+!    thermcell_flux2
+!    thermcell_height
+!    thermcell_plume
+!    thermcell_plume_5B
+!    thermcell_plume_6A
+!
 !=======================================================================
 
@@ -75,10 +91,12 @@
       real, intent(in), dimension(ngrid,nlay)    :: pt,pu,pv,po,pplay,pphi,zpspsk
       real, intent(in), dimension(ngrid,nlay+1)  :: pplev
+      integer, intent(out), dimension(ngrid) :: lmax
       real, intent(out), dimension(ngrid,nlay)   :: pdtadj,pduadj,pdvadj,pdoadj,entr0,detr0
       real, intent(out), dimension(ngrid,nlay)   :: ztla,zqla,zqta,zqsatth,zthl
       real, intent(out), dimension(ngrid,nlay+1) :: fm0,zw2,fraca
-      real, intent(out), dimension(ngrid) :: zmax0,f0
+      real, intent(inout), dimension(ngrid) :: zmax0,f0
       real, intent(out), dimension(ngrid,nlay) :: ztva,ztv
       logical, intent(in) :: debut
+      real,intent(out), dimension(ngrid,nlay) :: ratqscth,ratqsdiff
 
       real, intent(out), dimension(ngrid) :: pcon
@@ -105,9 +123,9 @@
       logical sorties
       real, dimension(ngrid) :: linter,zmix, zmax_sec
-      integer,dimension(ngrid) :: lmax,lmin,lmix,lmix_bis,nivcon
+      integer,dimension(ngrid) :: lmin,lmix,lmix_bis,nivcon
       real, dimension(ngrid,nlay) :: ztva_est
       real, dimension(ngrid,nlay) :: deltaz,zlay,zh,zdthladj,zu,zv,zo,zl,zva,zua,zoa
       real, dimension(ngrid,nlay) :: zta,zha,q2,wq,wthl,wthv,thetath2,wth2
-      real, dimension(ngrid,nlay) :: ratqscth,ratqsdiff,rho,masse
+      real, dimension(ngrid,nlay) :: rho,masse
       real, dimension(ngrid,nlay+1) :: zw_est,zlev
       real, dimension(ngrid) :: wmax,wmax_tmp
@@ -116,4 +134,5 @@
       real, dimension(ngrid,nlay) :: zqsat,csc
       real, dimension(ngrid) :: zcon,zcon2,alim_star_tot,f
+      real, dimension(ngrid,nlay) :: entrdn,detrdn
 
       character (len=20) :: modname='thermcell_main'
@@ -122,6 +141,6 @@
 
 #ifdef ISO
-      REAL xtpo(ntraciso,ngrid,nlay),xtpdoadj(ntraciso,ngrid,nlay)
-      REAL xtzo(ntraciso,ngrid,nlay)
+      REAL xtpo(ntiso,ngrid,nlay),xtpdoadj(ntiso,ngrid,nlay)
+      REAL xtzo(ntiso,ngrid,nlay)
       REAL xtpdoadj_tmp(ngrid,nlay)
       REAL xtpo_tmp(ngrid,nlay)
@@ -137,5 +156,4 @@
 !   ---------------
 !
-
    fm=0. ; entr=0. ; detr=0.
 
@@ -360,5 +378,5 @@
      &           zlev,lmax,zmax,zmax0,zmix,wmax)
 ! Attention, w2 est transforme en sa racine carree dans cette routine
-! Le probleme vient du fait que linter et lmix sont souvent égaux à 1.
+! Le probleme vient du fait que linter et lmix sont souvent egaux a 1.
       wmax_tmp=0.
       do  l=1,nlay
@@ -447,4 +465,5 @@
      &       entr_star,detr_star,f,rhobarz,zlev,zw2,fm,entr,  &
      &       detr,zqla,lev_out,lunout1,igout)
+
 !IM 060508    &       detr,zqla,zmax,lev_out,lunout,igout)
 
@@ -470,16 +489,44 @@
       endif
 
+!------------------------------------------------------------------
+! Calcul de la fraction de l'ascendance
+!------------------------------------------------------------------
+      do ig=1,ngrid
+         fraca(ig,1)=0.
+         fraca(ig,nlay+1)=0.
+      enddo
+      do l=2,nlay
+         do ig=1,ngrid
+            if (zw2(ig,l).gt.1.e-10) then
+            fraca(ig,l)=fm(ig,l)/(rhobarz(ig,l)*zw2(ig,l))
+            else
+            fraca(ig,l)=0.
+            endif
+         enddo
+      enddo
+     
 !c------------------------------------------------------------------
 !   calcul du transport vertical
 !------------------------------------------------------------------
-
-      call thermcell_dq(ngrid,nlay,dqimpl,ptimestep,fm0,entr0,masse,  &
-     &                    zthl,zdthladj,zta,lev_out)
-      call thermcell_dq(ngrid,nlay,dqimpl,ptimestep,fm0,entr0,masse,  &
-     &                   po,pdoadj,zoa,lev_out)
+      IF (iflag_thermals_down .GT. 0) THEN
+        if (debut) print*,'WARNING !!! routine thermcell_down en cours de developpement'
+        entrdn=fact_thermals_down*detr0
+        detrdn=fact_thermals_down*entr0 
+        ! we want to transport potential temperature, total water and momentum
+        CALL thermcell_updown_dq(ngrid,nlay,ptimestep,lmax,entr0,detr0,entrdn,detrdn,masse,zthl,zdthladj)
+        CALL thermcell_updown_dq(ngrid,nlay,ptimestep,lmax,entr0,detr0,entrdn,detrdn,masse,po,pdoadj)
+        CALL thermcell_updown_dq(ngrid,nlay,ptimestep,lmax,entr0,detr0,entrdn,detrdn,masse,zu,pduadj)
+        CALL thermcell_updown_dq(ngrid,nlay,ptimestep,lmax,entr0,detr0,entrdn,detrdn,masse,zv,pdvadj)
+      ELSE
+      !--------------------------------------------------------------
+
+        call thermcell_dq(ngrid,nlay,dqimpl,ptimestep,fm0,entr0,masse,  &
+        &                    zthl,zdthladj,zta,lev_out)
+        call thermcell_dq(ngrid,nlay,dqimpl,ptimestep,fm0,entr0,masse,  &
+        &                   po,pdoadj,zoa,lev_out)
 
 #ifdef ISO
-        ! C Risi: on utilise directement la même routine
-        do ixt=1,ntraciso
+        ! C Risi: on utilise directement la meme routine
+        do ixt=1,ntiso
           do ll=1,nlay
             DO ig=1,ngrid
@@ -495,5 +542,5 @@
             enddo
           enddo
-        enddo !do ixt=1,ntraciso
+        enddo
 #endif
 
@@ -519,22 +566,4 @@
 
 
-
-!------------------------------------------------------------------
-! Calcul de la fraction de l'ascendance
-!------------------------------------------------------------------
-      do ig=1,ngrid
-         fraca(ig,1)=0.
-         fraca(ig,nlay+1)=0.
-      enddo
-      do l=2,nlay
-         do ig=1,ngrid
-            if (zw2(ig,l).gt.1.e-10) then
-            fraca(ig,l)=fm(ig,l)/(rhobarz(ig,l)*zw2(ig,l))
-            else
-            fraca(ig,l)=0.
-            endif
-         enddo
-      enddo
-     
 !------------------------------------------------------------------
 !  calcul du transport vertical du moment horizontal
@@ -561,4 +590,5 @@
 
       endif
+    ENDIF
 
 !     print*,'13 OK convect8'
@@ -716,4 +746,5 @@
       real seuil
       character*21 comment
+
       seuil=0.25
 
@@ -741,5 +772,5 @@
 ! nrlmd le 10/04/2012   Transport de la TKE par le thermique moyen pour la fermeture en ALP 
 !                       On transporte pbl_tke pour donner therm_tke
-!                       Copie conforme de la subroutine DTKE dans physiq.F écrite par Frederic Hourdin
+!                       Copie conforme de la subroutine DTKE dans physiq.F ecrite par Frederic Hourdin
 
 !=======================================================================
Index: LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_plume.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_plume.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_plume.F90	(revision 4446)
@@ -63,23 +63,24 @@
 
 
-      REAL wa_moy(ngrid,nlay+1)
-      REAL entr(ngrid,nlay),detr(ngrid,nlay)
-      REAL ztv_est(ngrid,nlay)
-      REAL zqla_est(ngrid,nlay)
-      REAL zta_est(ngrid,nlay)
-      REAL ztemp(ngrid),zqsat(ngrid)
+      REAL,dimension(ngrid,nlay+1) :: wa_moy
+      REAL,dimension(ngrid,nlay) :: entr,detr
+      REAL,dimension(ngrid,nlay) :: ztv_est
+      REAL,dimension(ngrid,nlay) :: zqla_est
+      REAL,dimension(ngrid,nlay) :: zta_est
+      REAL,dimension(ngrid) :: ztemp,zqsat
       REAL zdw2,zdw2bis
       REAL zw2modif
       REAL zw2fact,zw2factbis
-      REAL zeps(ngrid,nlay)
-
-      REAL    wmaxa(ngrid)
+      REAL,dimension(ngrid,nlay) :: zeps
+
+      REAL,dimension(ngrid) :: wmaxa
 
       INTEGER ig,l,k,lt,it,lm,nbpb
 
-      real zdz,zbuoy(ngrid,nlay),zalpha,gamma(ngrid,nlay),zdqt(ngrid,nlay),zw2m
-      real zbuoyjam(ngrid,nlay),zdqtjam(ngrid,nlay)
+      real,dimension(ngrid,nlay) :: zbuoy,gamma,zdqt
+      real zdz,zalpha,zw2m
+      real,dimension(ngrid,nlay) :: zbuoyjam,zdqtjam
       real zdz2,zdz3,lmel,entrbis,zdzbis
-      real d_temp(ngrid)
+      real,dimension(ngrid) :: d_temp
       real ztv1,ztv2,factinv,zinv,zlmel
       real zlmelup,zlmeldwn,zlt,zltdwn,zltup
@@ -90,9 +91,9 @@
       real eps
       logical Zsat
-      LOGICAL active(ngrid),activetmp(ngrid)
+      LOGICAL,dimension(ngrid) :: active,activetmp
       REAL fact_gamma,fact_gamma2,fact_epsilon2
 
 
-      REAL c2(ngrid,nlay)
+      REAL,dimension(ngrid,nlay) :: c2
 
       if (ngrid==1) print*,'THERMCELL PLUME MODIFIE 2014/07/11'
@@ -443,4 +444,4 @@
 
 
-     return 
+ RETURN
      end
Index: LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_plume_6A.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_plume_6A.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_plume_6A.F90	(revision 4446)
@@ -55,7 +55,7 @@
       REAL zw2modif
       REAL zw2fact,zw2factbis
-      REAL zeps(ngrid,nlay)
-
-      REAL    wmaxa(ngrid)
+      REAL,dimension(ngrid,nlay) :: zeps
+
+      REAL, dimension(ngrid) ::    wmaxa(ngrid)
 
       INTEGER ig,l,k,lt,it,lm
@@ -70,8 +70,9 @@
       real,dimension(ngrid,nlay) :: zta_est
 
-      real zdz,zbuoy(ngrid,nlay),zalpha,gamma(ngrid,nlay),zdqt(ngrid,nlay),zw2m
-      real zbuoyjam(ngrid,nlay),zdqtjam(ngrid,nlay)
+      real,dimension(ngrid,nlay) :: zbuoy,gamma,zdqt
+      real zdz,zalpha,zw2m
+      real,dimension(ngrid,nlay) :: zbuoyjam,zdqtjam
       real zbuoybis,zdz2,zdz3,lmel,entrbis,zdzbis
-      real d_temp(ngrid)
+      real, dimension(ngrid) :: d_temp
       real ztv1,ztv2,factinv,zinv,zlmel
       real zlmelup,zlmeldwn,zlt,zltdwn,zltup
@@ -82,8 +83,8 @@
       real eps
       logical Zsat
-      LOGICAL active(ngrid),activetmp(ngrid)
+      LOGICAL,dimension(ngrid) :: active,activetmp
       REAL fact_gamma,fact_gamma2,fact_epsilon2
       REAL coefc
-      REAL c2(ngrid,nlay)
+      REAL,dimension(ngrid,nlay) :: c2
 
       if (ngrid==1) print*,'THERMCELL PLUME MODIFIE 2014/07/11'
@@ -137,4 +138,11 @@
       lmix_bis(:)=2
       wmaxa(:)=0.
+
+! Initialisation a 0  en cas de sortie dans replay
+      zqsat(:)=0.
+      zta_est(:,:)=0.
+      zdqt(:,:)=0.
+      zdqtjam(:,:)=0.
+      c2(:,:)=0.
 
 
Index: LMDZ6/branches/Portage_acc/libf/phylmd/tracco2i_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/tracco2i_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/tracco2i_mod.F90	(revision 4446)
@@ -103,5 +103,5 @@
     IF (debutphy) THEN
 
-! Initialisation de tr_seri(id_CO2) si pas initialise
+! Initialization of tr_seri(id_CO2) If it is not initialized
       IF (MAXVAL(tr_seri(:,:,id_CO2)).LT.1.e-15) THEN 
         tr_seri(:,:,id_CO2)=co2_ppm0*1.e-6/RMD*RMCO2 !--initialised from co2_ppm0 in rdem
@@ -226,5 +226,7 @@
 
       DO i=1, klon  
-          fco2_ocean_cor(i)=(var_fco2_ocean_cor*(RMCO2/RMC)*(pctsrf(i,is_oce)+pctsrf(i,is_sic))/ocean_area_tot/(secinday*year_len))*1.e12
+         fco2_ocean_cor(i)=(var_fco2_ocean_cor*(RMCO2/RMC) &
+              *(pctsrf(i,is_oce)+pctsrf(i,is_sic))/ocean_area_tot &
+              /(secinday*year_len))*1.e12
       ENDDO
 
@@ -305,7 +307,11 @@
 
 !--compute a global mean CO2 value and print its value in ppm
-       IF (is_mpi_root) THEN
+       IF (is_mpi_root .AND. is_omp_root) THEN
          RCO2_tot=SUM(co2_glo*m_air_glo)  !--unit kg CO2
          RCO2_glo=RCO2_tot/SUM(m_air_glo) !--unit kg CO2 / kg air
+         ! the following operation is only to maintain precision consistency
+         ! of RCO2_glo which differs whether it is directly computed or read from
+         ! a restart file (after having been computed)
+         RCO2_glo = FLOAT(INT(RCO2_glo * 1e8))/1e8
          PRINT *,'tracco2i: global CO2 in ppm =', RCO2_glo*1.e6*RMD/RMCO2
          PRINT *,'tracco2i: total CO2 in kg =', RCO2_tot
@@ -314,4 +320,5 @@
        CALL bcast(RCO2_glo)
        day_pre=day_cur
+
 !--if not carbon_cycle_tr, then we reinitialize the CO2 each day to its global mean value
        IF (.NOT.carbon_cycle_tr) THEN 
Index: LMDZ6/branches/Portage_acc/libf/phylmd/tracinca_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/tracinca_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/tracinca_mod.F90	(revision 4446)
@@ -12,4 +12,5 @@
                      ! config_inca='chem' => INCA with chemistry
                      ! config_inca='aero' => INCA with aerosols
+                     ! config_inca='aeNP' => INCA with aerosols NP (?)
 CONTAINS
 
@@ -17,6 +18,5 @@
     ! This subroutine initialize some control varaibles. 
 
-    USE infotrac_phy, ONLY: nbtr
-    USE ioipsl_getin_p_mod, ONLY: getin_p
+    USE infotrac_phy, ONLY: nbtr, type_trac
     IMPLICIT NONE
     
@@ -25,8 +25,15 @@
     LOGICAL,INTENT(OUT) :: lessivage
     
-    
     ! Initialization
     lessivage  =.FALSE.
     aerosol(:) = .FALSE.
+
+    !--- COHERENCE TEST BETWEEN "type_trac" AND "config_inca"
+    IF(ANY(type_trac == ['inca','inco']) .AND. ALL(config_inca /= ['aero','aeNP','chem'])) CALL abort_gcm('tracinca_init', &
+       'INCA enabled, but unknown config_inca = "'//TRIM(config_inca)//'". Please modify "run.def"', 1)
+
+    !--- PROBLEM IF "config_inca" DIFFERS FROM "none" AND INCA HAS NOT BEEN ACTIVATED
+    IF(ALL(type_trac /= ['inca','inco'])  .AND.    config_inca /= 'none')                  CALL abort_gcm('tracinca_init', &
+       'INCA disabled, but config_inca = "'//TRIM(config_inca)//'" should be "none". Please modify "run.def"', 1)
 
   END SUBROUTINE tracinca_init
@@ -82,5 +89,5 @@
     REAL,DIMENSION(klon,klev),INTENT(IN)   :: pphi    ! geopotentiel
     REAL,DIMENSION(klon),INTENT(IN)        :: pphis
-    REAL,DIMENSION(klon,klev),INTENT(IN)   :: cldliq  ! eau liquide nuageuse
+    REAL,DIMENSION(klon,klev),INTENT(IN)   :: cldliq  ! eau condensee pour le radiatif
     REAL,DIMENSION(klon,klev),INTENT(IN)   :: cldfra  ! fraction nuageuse (tous les nuages)
     REAL,DIMENSION(klon,klev),INTENT(IN)   :: diafra  ! fraction nuageuse (convection ou stratus artificiels)
Index: LMDZ6/branches/Portage_acc/libf/phylmd/traclmdz_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/traclmdz_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/traclmdz_mod.F90	(revision 4446)
@@ -96,5 +96,4 @@
     USE indice_sol_mod
     USE print_control_mod, ONLY: lunout
-    USE strings_mod, ONLY: strLower
 
 ! Input variables
@@ -175,24 +174,24 @@
     it = 0
     DO iq = 1, nqtot
-       IF(.NOT.(tracers(iq)%isAdvected .AND. tracers(iq)%isInPhysics)) CYCLE
+       IF(.NOT.(tracers(iq)%isInPhysics)) CYCLE
        it = it+1
-       SELECT CASE(strLower(tracers(iq)%name))
-         CASE("rn");      id_rn     = it ! radon
-         CASE("pb");      id_pb     = it ! plomb
-         CASE("aga");     id_aga    = it ! Age of stratospheric air
-         CASE("be","be7");id_be     = it ! Recherche du Beryllium 7
-         CASE("o3");      id_o3     = it ! Recherche de l'ozone
-         CASE("pcsat");   id_pcsat  = it
-         CASE("pcocsat"); id_pcocsat= it
-         CASE("pcq");     id_pcq    = it
-         CASE("pcs0");    id_pcs0   = it
-         CASE("pcos0");   id_pcos0  = it
-         CASE("pcq0");    id_pcq0   = it
+       SELECT CASE(tracers(iq)%name)
+         CASE("RN");                  id_rn     = it ! radon
+         CASE("PB");                  id_pb     = it ! plomb
+         CASE("Aga","AGA");           id_aga    = it ! Age of stratospheric air
+         CASE("Be","BE","Be7","BE7"); id_be     = it ! Recherche du Beryllium 7
+         CASE("o3","O3");             id_o3     = it ! Recherche de l'ozone
+         CASE("pcsat",  "Pcsat");     id_pcsat  = it
+         CASE("pcocsat","Pcocsat");   id_pcocsat= it
+         CASE("pcq",    "Pcq");       id_pcq    = it
+         CASE("pcs0",   "Pcs0");      id_pcs0   = it
+         CASE("pcos0",  "Pcos0");     id_pcos0  = it
+         CASE("pcq0",   "Pcq0");      id_pcq0   = it
          CASE DEFAULT
            WRITE(lunout,*) 'This is an unknown tracer in LMDZ : ', trim(tracers(iq)%name)
        END SELECT
 
-       SELECT CASE(strLower(tracers(iq)%name))
-         CASE("pb")                        !--- RomP >>> profil initial de PB210 
+       SELECT CASE(tracers(iq)%name)
+         CASE("PB")                        !--- RomP >>> profil initial de PB210 
            OPEN(ilesfil2,file='prof.pb210',status='old',iostat=irr2)
            IF(irr2 == 0) THEN 
@@ -203,7 +202,7 @@
              tr_seri(:,:,id_pb) = plomb(:,:)
            ELSE
-             WRITE(lunout,*)'Prof. Pb210 does not exist: use restart values'
+             WRITE(lunout,*)'prof.pb210 does not exist: use restart values'
            END IF
-         CASE("aga")
+         CASE("Aga","AGA")
            radio(id_aga) = .FALSE.
            aerosol(id_aga) = .FALSE.
@@ -217,5 +216,5 @@
               lev_1p5km=klev/2
            END IF
-         CASE("be","be7")
+         CASE("Be","BE","Be7","BE7")
            ALLOCATE( srcbe(klon,klev) )
            radio(id_be) = .TRUE.
@@ -234,8 +233,8 @@
              WRITE(lunout,*)'Prof. Be7 does not exist: use restart values'
            END IF
-         CASE("o3")                         !--- Parametrisation par la chimie de Cariolle
+         CASE("o3","O3")                    !--- Parametrisation par la chimie de Cariolle
            CALL alloc_coefoz                !--- Allocate ozone coefficients
            CALL press_coefoz                !--- Read input pressure levels
-         CASE("pcs0","pcos0","pcq0")
+         CASE("pcs0","Pcs0", "pcos0","Pcos0", "pcq0","Pcq0")
            conv_flg(it)=0                   !--- No transport by convection for this tracer
        END SELECT
Index: LMDZ6/branches/Portage_acc/libf/phylmd/transp.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/transp.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/transp.F90	(revision 4446)
@@ -2,6 +2,6 @@
 ! $Id$
 
-SUBROUTINE transp(paprs, tsol, t, q, ql, qs, u, v, geom, vtran_e, vtran_q, utran_e, &
-    utran_q, vtran_w, utran_w)
+SUBROUTINE transp(paprs, tsol, t, q, ql, qs, u, v, geom, & 
+                  utran_e, vtran_e, utran_q, vtran_q, utran_w, vtran_w)
 
   USE dimphy
@@ -15,37 +15,43 @@
   include "YOMCST.h"
 
-  REAL paprs(klon, klev+1), tsol(klon)
-  REAL t(klon, klev), q(klon, klev), ql(klon, klev), qs(klon, klev)
-  REAL u(klon, klev), v(klon, klev)
-  REAL utran_e(klon), utran_q(klon), vtran_e(klon), vtran_q(klon)
-  REAL utran_w(klon), vtran_w(klon)
+  !--inputs
+  REAL, INTENT(IN)  :: paprs(klon, klev+1), tsol(klon), geom(klon, klev)
+  REAL, INTENT(IN)  :: t(klon, klev), q(klon, klev), ql(klon, klev), qs(klon, klev)
+  REAL, INTENT(IN)  :: u(klon, klev), v(klon, klev)
+  !--outputs
+  REAL, INTENT(OUT) :: utran_e(klon), vtran_e(klon) !--lateral flux of dry static energy (J m-1 s-1)
+  REAL, INTENT(OUT) :: utran_q(klon), vtran_q(klon) !--lateral flux of water vapour (kg m-1 s-1)
+  REAL, INTENT(OUT) :: utran_w(klon), vtran_w(klon) !--lateral flux of total water (kg m-1 s-1)
+  !--local variables
+  INTEGER i, l
+  REAL e, dm
+  ! ------------------------------------------------------------------
 
-  INTEGER i, l
-  ! ------------------------------------------------------------------
-  REAL geom(klon, klev), e
-  ! ------------------------------------------------------------------
-  DO i = 1, klon
-    utran_e(i) = 0.0
-    utran_q(i) = 0.0
-    vtran_e(i) = 0.0
-    vtran_q(i) = 0.0
-    utran_w(i) = 0.0
-    vtran_w(i) = 0.0
-  END DO
+  !--initialisations
+  utran_e(:) = 0.0
+  utran_q(:) = 0.0
+  vtran_e(:) = 0.0
+  vtran_q(:) = 0.0
+  utran_w(:) = 0.0
+  vtran_w(:) = 0.0
 
+  !--vertical integration of diagnostics
   DO l = 1, klev
     DO i = 1, klon
+      dm= (paprs(i,l)-paprs(i,l+1))/RG  !--mass of layer kg m-2
+      !--moist static energy
 !      e = rcpd*t(i, l) + rlvtt*q(i, l) + geom(i, l)
+      !--dry static energy
       e = rcpd*t(i, l) + geom(i, l)
-      utran_e(i) = utran_e(i) + u(i, l)*e*(paprs(i,l)-paprs(i,l+1))/rg
-      utran_q(i) = utran_q(i) + u(i, l)*q(i, l)*(paprs(i,l)-paprs(i,l+1))/rg
-      utran_w(i) = utran_w(i) + u(i, l)*(q(i, l)+ql(i, l)+qs(i, l))           &
-                                       *(paprs(i,l)-paprs(i,l+1))/rg
-      vtran_e(i) = vtran_e(i) + v(i, l)*e*(paprs(i,l)-paprs(i,l+1))/rg
-      vtran_q(i) = vtran_q(i) + v(i, l)*q(i, l)*(paprs(i,l)-paprs(i,l+1))/rg
-      vtran_w(i) = vtran_w(i) + v(i, l)*(q(i, l)+ql(i, l)+qs(i, l))           &
-                                       *(paprs(i,l)-paprs(i,l+1))/rg
-    END DO
-  END DO
+      utran_e(i) = utran_e(i) + u(i, l)*e*dm
+      vtran_e(i) = vtran_e(i) + v(i, l)*e*dm
+      !--water vapour
+      utran_q(i) = utran_q(i) + u(i, l)*q(i,l)*dm 
+      vtran_q(i) = vtran_q(i) + v(i, l)*q(i,l)*dm
+      !--total water
+      utran_w(i) = utran_w(i) + u(i, l)*(q(i,l)+ql(i,l)+qs(i,l))*dm 
+      vtran_w(i) = vtran_w(i) + v(i, l)*(q(i,l)+ql(i,l)+qs(i,l))*dm
+    ENDDO
+  ENDDO
 
   RETURN
Index: LMDZ6/branches/Portage_acc/libf/phylmd/wake.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/wake.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/wake.F90	(revision 4446)
@@ -7,10 +7,10 @@
                 dtdwn, dqdwn, amdwn, amup, dta, dqa, wgen, &
                 sigd_con, Cin, &
-                deltatw, deltaqw, sigmaw, awdens, wdens, &                  ! state variables
+                deltatw, deltaqw, sigmaw, awdens, wdens, &                  ! state variables           
                 dth, hw, wape, fip, gfl, &
                 dtls, dqls, ktopw, omgbdth, dp_omgb, tu, qu, &
                 dtke, dqke, omg, dp_deltomg, wkspread, cstar, &
-                d_deltat_gw, &
-                d_deltatw2, d_deltaqw2, d_sigmaw2, d_awdens2, d_wdens2)     ! tendencies
+                d_deltat_gw, &                                                      ! tendencies
+                d_deltatw2, d_deltaqw2, d_sigmaw2, d_awdens2, d_wdens2)             ! tendencies
 
 
@@ -27,8 +27,9 @@
   USE wake_ini_mod , ONLY : wake_ini
   USE wake_ini_mod , ONLY : prt_level,epsim1,RG,RD
-  USE wake_ini_mod , ONLY : stark, wdens_ref, coefgw, alpk, wdens_ref, stark, coefgw, alpk
+  USE wake_ini_mod , ONLY : stark, wdens_ref, coefgw, alpk, pupperbyphs
   USE wake_ini_mod , ONLY : crep_upper, crep_sol, tau_cv, rzero, aa0, flag_wk_check_trgl
   USE wake_ini_mod , ONLY : iflag_wk_act, iflag_wk_check_trgl, iflag_wk_pop_dyn, wdensmin
   USE wake_ini_mod , ONLY : sigmad, hwmin, wapecut, cstart, sigmaw_max, dens_rate, epsilon_loc
+  USE wake_ini_mod , ONLY : iflag_wk_profile
 
 
@@ -119,10 +120,10 @@
   ! wdens_ref: initial number of wakes per unit area (3D) or per
   ! unit length (2D), at the beginning of each time step
-  ! Tgw    : 1 sur la période de onde de gravité
-  ! Cgw    : vitesse de propagation de onde de gravité
+  ! Tgw    : 1 sur la periode de onde de gravite
+  ! Cgw    : vitesse de propagation de onde de gravite
   ! LL     : distance entre 2 poches
 
   ! -------------------------------------------------------------------------
-  ! Déclaration de variables
+  ! Declaration de variables
   ! -------------------------------------------------------------------------
 
@@ -163,8 +164,9 @@
   REAL, DIMENSION (klon, klev),     INTENT(OUT)         :: omgbdth, omg
   REAL, DIMENSION (klon, klev),     INTENT(OUT)         :: dp_omgb, dp_deltomg
-  REAL, DIMENSION (klon, klev),     INTENT(OUT)         :: d_deltat_gw
   REAL, DIMENSION (klon),           INTENT(OUT)         :: hw, wape, fip, gfl, cstar
   INTEGER, DIMENSION (klon),        INTENT(OUT)         :: ktopw
-  ! Tendencies of state variables
+  ! Tendencies of state variables (2 is appended to the names of fields which are the cumul of fields 
+  !                                 computed at each sub-timestep; e.g. d_wdens2 is the cumul of d_wdens)
+  REAL, DIMENSION (klon, klev),     INTENT(OUT)         :: d_deltat_gw
   REAL, DIMENSION (klon, klev),     INTENT(OUT)         :: d_deltatw2, d_deltaqw2
   REAL, DIMENSION (klon),           INTENT(OUT)         :: d_sigmaw2, d_awdens2, d_wdens2
@@ -173,5 +175,5 @@
   ! -------------------
 
-  ! Variables à fixer
+  ! Variables a fixer
 
   REAL                                                  :: delta_t_min
@@ -188,14 +190,22 @@
 !!  REAL, DIMENSION (klon)                                :: sigmaw1
 
-  ! Variables liees a la dynamique de population
+  ! Variables liees a la dynamique de population 1
   REAL, DIMENSION(klon)                                 :: act
   REAL, DIMENSION(klon)                                 :: rad_wk, tau_wk_inv
   REAL, DIMENSION(klon)                                 :: f_shear
   REAL, DIMENSION(klon)                                 :: drdt
-  REAL, DIMENSION(klon)                                 :: d_sig_gen, d_sig_death, d_sig_col
+  
+  ! Variables liees a la dynamique de population 2
+  REAL, DIMENSION(klon)                                 :: cont_fact  
+  
+!!  REAL, DIMENSION(klon)                                 :: d_sig_gen, d_sig_death, d_sig_col
   REAL, DIMENSION(klon)                                 :: wape1_act, wape2_act
   LOGICAL, DIMENSION (klon)                             :: kill_wake
   REAL                                                  :: drdt_pos
   REAL                                                  :: tau_wk_inv_min
+  ! Some components of the tendencies of state variables  
+  REAL, DIMENSION (klon)                                :: d_sig_gen2, d_sig_death2, d_sig_col2, d_sig_spread2, d_sig_bnd2
+  REAL, DIMENSION (klon)                                :: d_dens_gen2, d_dens_death2, d_dens_col2, d_dens_bnd2
+  REAL, DIMENSION (klon)                                :: d_adens_death2, d_adens_icol2, d_adens_acol2, d_adens_bnd2
 
   ! Variables pour les GW
@@ -219,6 +229,9 @@
   REAL, DIMENSION (klon, klev)                          :: d_deltatw, d_deltaqw
   REAL, DIMENSION (klon, klev)                          :: d_tenv, d_qe
-  REAL, DIMENSION (klon)                                :: d_awdens, d_wdens
-  REAL, DIMENSION (klon)                                :: d_sigmaw, alpha
+  REAL, DIMENSION (klon)                                :: d_awdens, d_wdens, d_sigmaw 
+  REAL, DIMENSION (klon)                                :: d_sig_gen, d_sig_death, d_sig_col, d_sig_spread, d_sig_bnd
+  REAL, DIMENSION (klon)                                :: d_dens_gen, d_dens_death, d_dens_col, d_dens_bnd
+  REAL, DIMENSION (klon)                                :: d_adens_death, d_adens_icol, d_adens_acol, d_adens_bnd
+  REAL, DIMENSION (klon)                                :: alpha, alpha_tot
   REAL, DIMENSION (klon)                                :: q0_min, q1_min
   LOGICAL, DIMENSION (klon)                             :: wk_adv, ok_qx_qw
@@ -227,6 +240,8 @@
   INTEGER                                               ::isubstep, k, i, igout
 
+  REAL                                                  :: sigmaw_targ
   REAL                                                  :: wdens_targ
-  REAL                                                  :: sigmaw_targ
+  REAL                                                  :: d_sigmaw_targ
+  REAL                                                  :: d_wdens_targ
 
   REAL, DIMENSION (klon)                                :: sum_thu, sum_tu, sum_qu, sum_thvu
@@ -276,5 +291,4 @@
   REAL, DIMENSION(klon)                                 :: awdens_in, wdens_in   ! pour les prints
 
-
   ! -------------------------------------------------------------------------
   ! Initialisations
@@ -289,7 +303,7 @@
   ! Configuration de coefgw,stark,wdens (22/02/06 by YU Jingmei)
 
-  ! coefgw : Coefficient pour les ondes de gravité
+  ! coefgw : Coefficient pour les ondes de gravite
   ! stark : Coefficient k dans Cstar=k*sqrt(2*WAPE)
-  ! wdens : Densité surfacique de poche froide
+  ! wdens : Densite surfacique de poche froide
   ! -------------------------------------------------------------------------
 
@@ -304,6 +318,5 @@
   ! alpk = 0.5
   ! alpk = 0.05
-
-
+!print *,'XXXX dtime input ', dtime
  igout = klon/2+1/klon
 
@@ -380,33 +393,4 @@
    sigmaw_in(:) = sigmaw(:)
 !>jyg
-
-  ! sigmaw1=sigmaw
-  ! IF (sigd_con.GT.sigmaw1) THEN
-  ! print*, 'sigmaw,sigd_con', sigmaw, sigd_con
-  ! ENDIF
-  IF (iflag_wk_pop_dyn >=1) THEN
-    DO i = 1, klon
-      wdens_targ = max(wdens(i),wdensmin)
-      d_wdens2(i) = wdens_targ - wdens(i)
-      wdens(i) = wdens_targ
-    END DO
-  ELSE
-    DO i = 1, klon
-      d_awdens2(i) = 0.
-      d_wdens2(i) = 0.
-    END DO
-  ENDIF  ! (iflag_wk_pop_dyn >=1)
-!
-  DO i = 1, klon
-    ! c      sigmaw(i) = amax1(sigmaw(i),sigd_con(i))
-!jyg<
-!!    sigmaw(i) = amax1(sigmaw(i), sigmad)
-!!    sigmaw(i) = amin1(sigmaw(i), 0.99)
-    sigmaw_targ = min(max(sigmaw(i), sigmad),0.99)
-    d_sigmaw2(i) = sigmaw_targ - sigmaw(i)
-    sigmaw(i) = sigmaw_targ
-!>jyg
-  END DO
-
 !
   IF (iflag_wk_pop_dyn >= 1) THEN
@@ -417,4 +401,57 @@
 !!  ELSE
   ENDIF  ! (iflag_wk_pop_dyn >= 1)
+
+
+  ! sigmaw1=sigmaw
+  ! IF (sigd_con.GT.sigmaw1) THEN
+  ! print*, 'sigmaw,sigd_con', sigmaw, sigd_con
+  ! ENDIF
+  IF (iflag_wk_pop_dyn >= 1) THEN
+    DO i = 1, klon
+      d_dens_gen2(i)   = 0.
+      d_dens_death2(i) = 0.
+      d_dens_col2(i)   = 0.
+      d_awdens2(i) = 0.
+!
+      wdens_targ = max(wdens(i),wdensmin)
+      d_dens_bnd2(i) = wdens_targ - wdens(i)
+      d_wdens2(i) = wdens_targ - wdens(i)
+      wdens(i) = wdens_targ
+    END DO
+    IF (iflag_wk_pop_dyn == 2) THEN
+       DO i = 1, klon  
+          d_adens_death2(i) = 0.
+          d_adens_icol2(i) = 0.
+          d_adens_acol2(i) = 0.
+!      
+          wdens_targ = min(max(awdens(i),0.),wdens(i))
+          d_adens_bnd2(i) = wdens_targ - awdens(i)
+          d_awdens2(i) = wdens_targ - awdens(i)
+          awdens(i) = wdens_targ
+       END DO
+    ENDIF ! (iflag_wk_pop_dyn == 2)
+  ELSE  
+    DO i = 1, klon
+      d_awdens2(i) = 0.
+      d_wdens2(i) = 0.
+    END DO
+  ENDIF  ! (iflag_wk_pop_dyn >= 1)
+!
+  DO i = 1, klon
+    ! c      sigmaw(i) = amax1(sigmaw(i),sigd_con(i))
+!jyg<
+!!    sigmaw(i) = amax1(sigmaw(i), sigmad)
+!!    sigmaw(i) = amin1(sigmaw(i), 0.99)
+    d_sig_gen2(i)   = 0.
+    d_sig_death2(i) = 0.
+    d_sig_col2(i)   = 0.
+    d_sig_spread2(i)= 0.
+    sigmaw_targ = min(max(sigmaw(i), sigmad),0.99)
+    d_sig_bnd2(i) = sigmaw_targ - sigmaw(i)
+    d_sigmaw2(i) = sigmaw_targ - sigmaw(i)
+!  print *,'XXXX1 d_sigmaw2(i), sigmaw(i) ', d_sigmaw2(i), sigmaw(i)
+    sigmaw(i) = sigmaw_targ
+!>jyg
+  END DO
 
   wape(:) = 0.
@@ -446,4 +483,5 @@
 dp_omgbw(:,:) = 0.
 omgbdq(:,:) = 0.
+
 !>jyg
 !
@@ -572,17 +610,7 @@
   END DO
 
-
+  
   ! Choose an integration bound well above wake top
   ! -----------------------------------------------------------------
-
-  ! Pupper = 50000.  ! melting level
-  ! Pupper = 60000.
-  ! Pupper = 80000.  ! essais pour case_e
-  DO i = 1, klon
-    pupper(i) = 0.6*ph(i, 1)
-    pupper(i) = max(pupper(i), 45000.)
-    ! cc        Pupper(i) = 60000.
-  END DO
-
 
   ! Determine Wake top pressure (Ptop) from buoyancy integral
@@ -657,16 +685,13 @@
   ! -5/ Determination de ktop et kupper
 
+  CALL pkupper (klon, klev, ptop, ph, pupper, kupper)
+  
   DO k = klev, 1, -1
     DO i = 1, klon
       IF (ph(i,k+1)<ptop(i)) ktop(i) = k
-      IF (ph(i,k+1)<pupper(i)) kupper(i) = k
-    END DO
-  END DO
-
-  ! On evite kupper = 1 et kupper = klev
-  DO i = 1, klon
-    kupper(i) = max(kupper(i), 2)
-    kupper(i) = min(kupper(i), klev-1)
-  END DO
+    END DO
+  END DO
+  !print*, 'ptop, pupper, ktop, kupper', ptop, pupper, ktop, kupper
+ 
 
 
@@ -808,5 +833,7 @@
 !!      sigmaw(i) = amax1(sigmad, sigd_con(i))
       sigmaw_targ = max(sigmad, sigd_con(i))
+      d_sig_bnd2(i) = d_sig_bnd2(i) + sigmaw_targ - sigmaw(i)
       d_sigmaw2(i) = d_sigmaw2(i) + sigmaw_targ - sigmaw(i)
+!  print *,'XXXX2 d_sigmaw2(i), sigmaw(i) ', d_sigmaw2(i), sigmaw(i)
       sigmaw(i) = sigmaw_targ
 !>jyg
@@ -840,4 +867,5 @@
     ok_qx_qw(i) = q0_min(i) >= 0.
     alpha(i) = 1.
+    alpha_tot(i) = 1.
   END DO
 
@@ -855,7 +883,12 @@
   dtimesub = dtime/nsub
 
+
+  
   ! ------------------------------------------------------------
   DO isubstep = 1, nsub
     ! ------------------------------------------------------------
+  CALL pkupper (klon, klev, ptop, ph, pupper, kupper)
+ 
+    !print*, 'ptop, pupper, ktop, kupper', ptop, pupper, ktop, kupper
 
     ! wk_adv is the logical flag enabling wake evolution in the time advance
@@ -867,9 +900,10 @@
       PRINT *, 'wake-4.1, isubstep,wk_adv(igout),cstar(igout),wape(igout), ptop(igout) ', &
                           isubstep,wk_adv(igout),cstar(igout),wape(igout), ptop(igout)
+     
     ENDIF
 
     ! cc nrlmd   Ajout d'un recalcul de wdens dans le cas d'un entrainement
-    ! négatif de ktop à kupper --------
-    ! cc           On calcule pour cela une densité wdens0 pour laquelle on
+    ! negatif de ktop a kupper --------
+    ! cc           On calcule pour cela une densite wdens0 pour laquelle on
     ! aurait un entrainement nul ---
     !jyg<
@@ -878,5 +912,5 @@
     ! des descentes unsaturees. Nous faisons alors l'hypothese que la 
     ! convection profonde cree directement de nouvelles poches, sans passer 
-    ! par les thermiques. La nouvelle valeur de wdens est alors imposée.
+    ! par les thermiques. La nouvelle valeur de wdens est alors imposee.
 
     DO i = 1, klon
@@ -884,6 +918,10 @@
       ! c     $           isubstep,wk_adv(i),cstar(i),wape(i)
       IF (wk_adv(i) .AND. cstar(i)>0.01) THEN
-        omg(i, kupper(i)+1) = -RG*amdwn(i, kupper(i)+1)/sigmaw(i) + &
+        IF ( iflag_wk_profile == 0 ) THEN
+           omg(i, kupper(i)+1)=-RG*amdwn(i, kupper(i)+1)/sigmaw(i) + &
                                RG*amup(i, kupper(i)+1)/(1.-sigmaw(i))
+        ELSE
+           omg(i, kupper(i)+1)=0.
+        ENDIF
         wdens0 = (sigmaw(i)/(4.*3.14))* &
           ((1.-sigmaw(i))*omg(i,kupper(i)+1)/((ph(i,1)-pupper(i))*cstar(i)))**(2)
@@ -894,4 +932,5 @@
         IF (wdens(i)<=wdens0*1.1) THEN
           IF (iflag_wk_pop_dyn >= 1) THEN
+             d_dens_bnd2(i) = d_dens_bnd2(i) + wdens0 - wdens(i)
              d_wdens2(i) = d_wdens2(i) + wdens0 - wdens(i)
           ENDIF
@@ -908,5 +947,7 @@
 !!        sigmaw(i) = amin1(sigmaw(i), sigmaw_max)
         sigmaw_targ = min(sigmaw(i), sigmaw_max)
+        d_sig_bnd2(i) = d_sig_bnd2(i) + sigmaw_targ - sigmaw(i)
         d_sigmaw2(i) = d_sigmaw2(i) + sigmaw_targ - sigmaw(i)
+!  print *,'XXXX3 d_sigmaw2(i), sigmaw(i) ', d_sigmaw2(i), sigmaw(i)
         sigmaw(i) = sigmaw_targ
 !>jyg
@@ -914,68 +955,40 @@
     END DO
 
-    IF (iflag_wk_pop_dyn >= 1) THEN
+    IF (iflag_wk_pop_dyn == 1) THEN
+  
+     CALL wake_popdyn_1 (klon, klev, dtime, cstar, tau_wk_inv, wgen, wdens, awdens, sigmaw, &
+                  dtimesub, gfl, rad_wk, f_shear, drdt_pos, &
+                  d_awdens, d_wdens, d_sigmaw, &
+                  iflag_wk_act, wk_adv, cin, wape, &
+                  drdt, &
+                  d_dens_gen, d_dens_death, d_dens_col, d_dens_bnd, &
+                  d_sig_gen, d_sig_death, d_sig_col, d_sig_spread, d_sig_bnd, &
+                  d_wdens_targ, d_sigmaw_targ)
+                      
 !    The variable "death_rate" is significant only when iflag_wk_pop_dyn = 0.
 !    Here, it has to be set to zero.
       death_rate(:) = 0.
-
-      IF (iflag_wk_act ==2) THEN
+    
+    ELSEIF (iflag_wk_pop_dyn == 2) THEN
+     CALL wake_popdyn_2 ( klon, klev, wk_adv, dtimesub, wgen, &
+                             sigmaw, wdens, awdens, &   !! states variables
+                             gfl, cstar, cin, wape, rad_wk, &
+                             d_sigmaw, d_wdens, d_awdens, &  !! tendences                              
+                             cont_fact, &
+                             d_sig_gen, d_sig_death, d_sig_col, d_sig_spread, d_sig_bnd, &
+                             d_dens_gen, d_dens_death, d_dens_col, d_dens_bnd, &
+                             d_adens_death, d_adens_icol, d_adens_acol, d_adens_bnd )
+     death_rate(:) = 0.
+sigmaw=sigmaw-d_sigmaw
+wdens=wdens-d_wdens
+awdens=awdens-d_awdens
+   
+    ELSEIF (iflag_wk_pop_dyn == 0) THEN
+    
+    ! cc nrlmd
+
       DO i = 1, klon
         IF (wk_adv(i)) THEN
-          wape1_act(i) = abs(cin(i))
-          wape2_act(i) = 2.*wape1_act(i) + 1.
-          act(i) = min(1., max(0., (wape(i)-wape1_act(i)) / (wape2_act(i)-wape1_act(i)) ))
-        ENDIF  ! (wk_adv(i))
-      ENDDO
-      ENDIF  ! (iflag_wk_act ==2)
-
-
-      DO i = 1, klon
-        IF (wk_adv(i)) THEN
-!!          tau_wk(i) = max(rad_wk(i)/(3.*cstar(i))*((cstar(i)/cstart)**1.5 - 1), 100.)
-          tau_wk_inv(i) = max( (3.*cstar(i))/(rad_wk(i)*((cstar(i)/cstart)**1.5 - 1)), 0.)
-          tau_wk_inv_min = min(tau_wk_inv(i), 1./dtimesub)
-          drdt(i) = (cstar(i) - wgen(i)*(sigmaw(i)/wdens(i)-aa0)/gfl(i)) / &
-                    (1 + 2*f_shear(i)*(2.*sigmaw(i)-aa0*wdens(i)) - 2.*sigmaw(i))
-!!                    (1 - 2*sigmaw(i)*(1.-f_shear(i)))
-          drdt_pos=max(drdt(i),0.)
-
-!!          d_wdens(i) = ( wgen(i)*(1.+2.*(sigmaw(i)-sigmad)) &
-!!                     - wdens(i)*tau_wk_inv_min &
-!!                     - 2.*gfl(i)*wdens(i)*Cstar(i) )*dtimesub
-          d_awdens(i) = ( wgen(i) - (1./tau_cv)*(awdens(i) - act(i)*wdens(i)) )*dtimesub
-          d_wdens(i) = ( wgen(i) - (wdens(i)-awdens(i))*tau_wk_inv_min -  &
-                         2.*wdens(i)*gfl(i)*drdt_pos )*dtimesub
-          d_wdens(i) = max(d_wdens(i), wdensmin-wdens(i))
-
-!!          d_sigmaw(i) = ( (1.-2*f_shear(i)*sigmaw(i))*(gfl(i)*Cstar(i)+wgen(i)*sigmad/wdens(i)) &
-!!                      + 2.*f_shear(i)*wgen(i)*sigmaw(i)**2/wdens(i) &
-!!                      - sigmaw(i)*tau_wk_inv_min )*dtimesub
-          d_sig_gen(i) = wgen(i)*aa0
-          d_sig_death(i) = - sigmaw(i)*(1.-awdens(i)/wdens(i))*tau_wk_inv_min
-!!          d_sig_col(i) = - 2*f_shear(i)*sigmaw(i)*gfl(i)*drdt_pos
-          d_sig_col(i) = - 2*f_shear(i)*(2.*sigmaw(i)-wdens(i)*aa0)*gfl(i)*drdt_pos
-          d_sigmaw(i) = ( d_sig_gen(i) + d_sig_death(i) + d_sig_col(i) + gfl(i)*cstar(i) )*dtimesub
-          d_sigmaw(i) = max(d_sigmaw(i), sigmad-sigmaw(i))
-        ENDIF
-      ENDDO
-
-      IF (prt_level >= 10) THEN
-        print *,'wake, cstar(1), cstar(1)/cstart, rad_wk(1), tau_wk_inv(1), drdt(1) ', &
-                       cstar(1), cstar(1)/cstart, rad_wk(1), tau_wk_inv(1), drdt(1)
-        print *,'wake, wdens(1), awdens(1), act(1), d_awdens(1) ', &
-                       wdens(1), awdens(1), act(1), d_awdens(1)
-        print *,'wake, wgen, -(wdens-awdens)*tau_wk_inv, -2.*wdens*gfl*drdt_pos, d_wdens ', &
-                       wgen(1), -(wdens(1)-awdens(1))*tau_wk_inv(1), -2.*wdens(1)*gfl(1)*drdt_pos, d_wdens(1)
-        print *,'wake, d_sig_gen(1), d_sig_death(1), d_sig_col(1), d_sigmaw(1) ', &
-                       d_sig_gen(1), d_sig_death(1), d_sig_col(1), d_sigmaw(1)
-      ENDIF
-    
-    ELSE  !  (iflag_wk_pop_dyn >= 1)
-
-    ! cc nrlmd
-
-      DO i = 1, klon
-        IF (wk_adv(i)) THEN
-          ! cc nrlmd          Introduction du taux de mortalité des poches et
+          ! cc nrlmd          Introduction du taux de mortalite des poches et
           ! test sur sigmaw_max=0.4
           ! cc         d_sigmaw(i) = gfl(i)*Cstar(i)*dtimesub
@@ -1008,5 +1021,5 @@
     ! IM 060208 differences par rapport au code initial; init. a 0 dp_deltomg
     ! IM 060208 et omg sur les niveaux de 1 a klev+1, alors que avant l'on definit
-    ! IM 060208 au niveau k=1..?
+    ! IM 060208 au niveau k=1...
     !JYG 161013 Correction : maintenant omg est dimensionne a klev.
     DO k = 1, klev
@@ -1082,6 +1095,10 @@
     DO i = 1, klon
       IF (wk_adv(i) .AND. kupper(i)>ktop(i)) THEN
-        omg(i, kupper(i)+1) = -RG*amdwn(i, kupper(i)+1)/sigmaw(i) + &
+        IF ( iflag_wk_profile == 0 ) THEN
+           omg(i, kupper(i)+1) =-RG*amdwn(i, kupper(i)+1)/sigmaw(i) + &
           RG*amup(i, kupper(i)+1)/(1.-sigmaw(i))
+        ELSE
+           omg(i, kupper(i)+1) = 0.
+        ENDIF
         dp_deltomg(i, kupper(i)) = (omgtop(i)-omg(i,kupper(i)+1))/ &
           (ptop(i)-pupper(i))
@@ -1090,5 +1107,5 @@
 
     ! c      DO i=1,klon
-    ! c        print*,'Pente entre 0 et kupper (référence)'
+    ! c        print*,'Pente entre 0 et kupper (reference)'
     ! c     $   	,omg(i,kupper(i)+1)/(pupper(i)-ph(i,1))
     ! c        print*,'Pente entre ktop et kupper'
@@ -1166,4 +1183,5 @@
         IF (wk_adv(i) .AND. k<=kupper(i)+1) THEN
           dth(i, k) = deltatw(i, k)/ppi(i, k)
+! print *, 'VVVVwake k, the(i,k), dth(i,k), sigmaw(i) ', k, the(i,k), dth(i,k), sigmaw(i)
           th1(i, k) = the(i, k) - sigmaw(i)*dth(i, k) ! undisturbed area
           th2(i, k) = the(i, k) + (1.-sigmaw(i))*dth(i, k) ! wake
@@ -1214,9 +1232,10 @@
     END DO
 
-    IF (prt_level>=10) THEN
-      PRINT *, 'wake-4.3, th1(igout,k) ', (k,th1(igout,k), k=1,klev)
-      PRINT *, 'wake-4.3, th2(igout,k) ', (k,th2(igout,k), k=1,klev)
-      PRINT *, 'wake-4.3, dth(igout,k) ', (k,dth(igout,k), k=1,klev)
-      PRINT *, 'wake-4.3, omgbdth(igout,k) ', (k,omgbdth(igout,k), k=1,klev)
+!!    IF (prt_level>=10) THEN
+    IF (prt_level>=10 .and. wk_adv(igout)) THEN
+      PRINT *, 'wake-4.3, th1(igout,k) ', (k,th1(igout,k), k=1,kupper(igout))
+      PRINT *, 'wake-4.3, th2(igout,k) ', (k,th2(igout,k), k=1,kupper(igout))
+      PRINT *, 'wake-4.3, dth(igout,k) ', (k,dth(igout,k), k=1,kupper(igout))
+      PRINT *, 'wake-4.3, omgbdth(igout,k) ', (k,omgbdth(igout,k), k=1,kupper(igout))
     ENDIF
 
@@ -1310,5 +1329,5 @@
 
 
-          ! Coefficient de répartition
+          ! Coefficient de repartition
 
           crep(i, k) = crep_sol*(ph(i,kupper(i))-ph(i,k))/ &
@@ -1340,6 +1359,6 @@
 !
 
-          ! cc nrlmd          Prise en compte du taux de mortalité
-          ! cc               Définitions de entr, detr
+          ! cc nrlmd          Prise en compte du taux de mortalite
+          ! cc               Definitions de entr, detr
 !jyg<
 !!            detr(i, k) = 0.
@@ -1358,5 +1377,5 @@
 
 
-          ! ajout d'un effet onde de gravité -Tgw(k)*deltatw(k) 03/02/06 YU
+          ! ajout d'un effet onde de gravite -Tgw(k)*deltatw(k) 03/02/06 YU
           ! Jingmei
 
@@ -1414,4 +1433,11 @@
     CALL wake_vec_modulation(klon, klev, wk_adv, epsilon_loc, qe, d_qe, deltaqw, &
       d_deltaqw, sigmaw, d_sigmaw, alpha)
+    !
+    ! Alpha_tot = Product of all the alpha's
+    DO i = 1, klon
+      IF (wk_adv(i)) THEN
+        alpha_tot(i) = alpha_tot(i)*alpha(i)    
+      END IF
+    END DO
 
     ! cc nrlmd
@@ -1472,22 +1498,62 @@
         sigmaw(i) = sigmaw(i) + d_sigmaw(i)
         d_sigmaw2(i) = d_sigmaw2(i) + d_sigmaw(i)
+!  print *,'XXXX4 d_sigmaw2(i), sigmaw(i) ', d_sigmaw2(i), sigmaw(i)
       END IF
     END DO
 !jyg<
     IF (iflag_wk_pop_dyn >= 1) THEN
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! sigmaw !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!  Cumulatives
+      DO i = 1, klon
+        IF (wk_adv(i)) THEN
+          d_sig_gen2(i)   = d_sig_gen2(i)   + d_sig_gen(i)
+          d_sig_death2(i) = d_sig_death2(i) + d_sig_death(i)
+          d_sig_col2(i)   = d_sig_col2(i)   + d_sig_col(i)
+          d_sig_spread2(i)= d_sig_spread2(i)+ d_sig_spread(i)
+          d_sig_bnd2(i)   = d_sig_bnd2(i)   + d_sig_bnd(i)
+        END IF
+      END DO
+!  Bounds
+      DO i = 1, klon
+        IF (wk_adv(i)) THEN
+          sigmaw_targ = max(sigmaw(i),sigmad)
+          d_sig_bnd2(i) = d_sig_bnd2(i) + sigmaw_targ - sigmaw(i)
+          d_sigmaw2(i) = d_sigmaw2(i) + sigmaw_targ - sigmaw(i)
+!  print *,'XXXX5 d_sigmaw2(i), sigmaw(i) ', d_sigmaw2(i), sigmaw(i)
+          sigmaw(i) = sigmaw_targ
+        END IF
+      END DO
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! wdens  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!  Cumulatives
+      DO i = 1, klon
+        IF (wk_adv(i)) THEN
+          wdens(i) = wdens(i) + d_wdens(i)
+          d_wdens2(i) = d_wdens2(i) + d_wdens(i)
+          d_dens_gen2(i)   = d_dens_gen2(i)   + d_dens_gen(i)
+          d_dens_death2(i) = d_dens_death2(i) + d_dens_death(i)
+          d_dens_col2(i)   = d_dens_col2(i)   + d_dens_col(i)
+          d_dens_bnd2(i)   = d_dens_bnd2(i)   + d_dens_bnd(i)
+        END IF
+      END DO
+!  Bounds
+      DO i = 1, klon
+        IF (wk_adv(i)) THEN
+          wdens_targ = max(wdens(i),wdensmin)
+          d_dens_bnd2(i) = d_dens_bnd2(i) + wdens_targ - wdens(i)
+          d_wdens2(i) = d_wdens2(i) + wdens_targ - wdens(i)
+          wdens(i) = wdens_targ
+        END IF
+      END DO
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! awdens !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!  Cumulatives
       DO i = 1, klon
         IF (wk_adv(i)) THEN
           awdens(i) = awdens(i) + d_awdens(i)
-          wdens(i) = wdens(i) + d_wdens(i)
           d_awdens2(i) = d_awdens2(i) + d_awdens(i)
-          d_wdens2(i) = d_wdens2(i) + d_wdens(i)
-        END IF
-      END DO
+        END IF
+      END DO
+!  Bounds
       DO i = 1, klon
         IF (wk_adv(i)) THEN
-          wdens_targ = max(wdens(i),wdensmin)
-          d_wdens2(i) = d_wdens2(i) + wdens_targ - wdens(i)
-          wdens(i) = wdens_targ
-!
           wdens_targ = min( max(awdens(i),0.), wdens(i) )
           d_awdens2(i) = d_awdens2(i) + wdens_targ - awdens(i)
@@ -1495,13 +1561,25 @@
         END IF
       END DO
-      DO i = 1, klon
-        IF (wk_adv(i)) THEN
-          sigmaw_targ = max(sigmaw(i),sigmad)
-          d_sigmaw2(i) = d_sigmaw2(i) + sigmaw_targ - sigmaw(i)
-          sigmaw(i) = sigmaw_targ
-        END IF
-      END DO
+!
+      IF (iflag_wk_pop_dyn == 2) THEN
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! awdens again for iflag_wk_pop_dyn = 2!!!!!!
+!  Cumulatives
+          DO i = 1, klon
+             IF (wk_adv(i)) THEN
+                 d_adens_death2(i)   = d_adens_death2(i)   + d_adens_death(i)
+                 d_adens_icol2(i)   = d_adens_icol2(i)   + d_adens_icol(i)
+                 d_adens_acol2(i)   = d_adens_acol2(i)   + d_adens_acol(i)
+                 d_adens_bnd2(i)   = d_adens_bnd2(i)   + d_adens_bnd(i)          
+             END IF
+          END DO
+!  Bounds
+          DO i = 1, klon
+             IF (wk_adv(i)) THEN
+                 wdens_targ = min( max(awdens(i),0.), wdens(i) )
+                 d_adens_bnd2(i) = d_adens_bnd2(i) + wdens_targ - awdens(i)
+             END IF
+          END DO
+      ENDIF ! (iflag_wk_pop_dyn == 2)
     ENDIF  ! (iflag_wk_pop_dyn >= 1)
-!>jyg
 
 
@@ -1744,5 +1822,7 @@
 !!          sigmaw(i) = max(sigmad, sigd_con(i))
           sigmaw_targ = max(sigmad, sigd_con(i))
+          d_sig_bnd2(i) = d_sig_bnd2(i) + sigmaw_targ - sigmaw(i)
           d_sigmaw2(i) = d_sigmaw2(i) + sigmaw_targ - sigmaw(i)
+!  print *,'XXXX6 d_sigmaw2(i), sigmaw(i) ', d_sigmaw2(i), sigmaw(i)
           sigmaw(i) = sigmaw_targ
 !>jyg
@@ -1961,5 +2041,7 @@
 !!      sigmaw(i) = amax1(sigmad, sigd_con(i))
       sigmaw_targ = max(sigmad, sigd_con(i))
+      d_sig_bnd2(i) = d_sig_bnd2(i) + sigmaw_targ - sigmaw(i)
       d_sigmaw2(i) = d_sigmaw2(i) + sigmaw_targ - sigmaw(i)
+!  print *,'XXXX7 d_sigmaw2(i), sigmaw(i) ', d_sigmaw2(i), sigmaw(i)
       sigmaw(i) = sigmaw_targ
 !>jyg
@@ -2058,5 +2140,8 @@
 !!      sigmaw(i) = 0.                        !jyg
       sigmaw_targ = 0.
-      d_sigmaw2(i) = d_sigmaw2(i) + sigmaw_targ - sigmaw(i)
+      d_sig_bnd2(i) = d_sig_bnd2(i) + sigmaw_targ - sigmaw(i)
+!!      d_sigmaw2(i) = d_sigmaw2(i) + sigmaw_targ - sigmaw(i)
+      d_sigmaw2(i) = sigmaw_targ - sigmaw_in(i)      ! _in = correction jyg 20220124
+!  print *,'XXXX8 d_sigmaw2(i), sigmaw(i) ', d_sigmaw2(i), sigmaw(i)
       sigmaw(i) = sigmaw_targ
       IF (iflag_wk_pop_dyn >= 1) THEN
@@ -2064,9 +2149,19 @@
 !!        wdens(i) = 0.
         wdens_targ = 0.
-        d_wdens2(i) = wdens_targ - wdens(i)
+        d_dens_bnd2(i) = d_dens_bnd2(i) + wdens_targ - wdens(i)
+!!        d_wdens2(i) = wdens_targ - wdens(i)
+        d_wdens2(i) = wdens_targ - wdens_in(i)      ! jyg 20220916
         wdens(i) = wdens_targ
         wdens_targ = 0.
-        d_awdens2(i) = wdens_targ - awdens(i)
+!!jyg: bug fix : the d_adens_bnd2 computation must be before the update of awdens.
+        IF (iflag_wk_pop_dyn == 2) THEN
+            d_adens_bnd2(i) = d_adens_bnd2(i) + wdens_targ - awdens(i)
+        ENDIF ! (iflag_wk_pop_dyn == 2)
+!!        d_awdens2(i) = wdens_targ - awdens(i)
+        d_awdens2(i) = wdens_targ - awdens_in(i)    ! jyg 20220916
         awdens(i) = wdens_targ
+!!        IF (iflag_wk_pop_dyn == 2) THEN
+!!            d_adens_bnd2(i) = d_adens_bnd2(i) + wdens_targ - awdens(i)
+!!        ENDIF ! (iflag_wk_pop_dyn == 2)
       ENDIF  ! (iflag_wk_pop_dyn >= 1)
     ELSE  ! (kill_wake(i))
@@ -2106,10 +2201,37 @@
     END DO
   END DO
-
-  DO i = 1, klon
+!jyg<
+  IF (iflag_wk_pop_dyn >= 1) THEN
+  DO i = 1, klon
+      IF (ok_qx_qw(i)) THEN
+    d_sig_gen2(i) = d_sig_gen2(i)/dtime
+    d_sig_death2(i) = d_sig_death2(i)/dtime
+    d_sig_col2(i) = d_sig_col2(i)/dtime
+    d_sig_spread2(i) = d_sig_spread2(i)/dtime
+    d_sig_bnd2(i) = d_sig_bnd2(i)/dtime
     d_sigmaw2(i) = d_sigmaw2(i)/dtime
+!  print *,'XXXX9 d_sigmaw2(i), sigmaw(i), dtime ', d_sigmaw2(i), sigmaw(i), dtime
+!
+    d_dens_gen2(i) = d_dens_gen2(i)/dtime
+    d_dens_death2(i) = d_dens_death2(i)/dtime
+    d_dens_col2(i) = d_dens_col2(i)/dtime
+    d_dens_bnd2(i) = d_dens_bnd2(i)/dtime
     d_awdens2(i) = d_awdens2(i)/dtime
     d_wdens2(i) = d_wdens2(i)/dtime
+      ENDIF
   ENDDO
+  IF (iflag_wk_pop_dyn == 2) THEN
+    DO i = 1, klon
+      IF (ok_qx_qw(i)) THEN
+    d_adens_death2(i) = d_adens_death2(i)/dtime
+    d_adens_icol2(i) = d_adens_icol2(i)/dtime
+    d_adens_acol2(i) = d_adens_acol2(i)/dtime
+    d_adens_bnd2(i) = d_adens_bnd2(i)/dtime
+      ENDIF
+    ENDDO
+   ENDIF ! (iflag_wk_pop_dyn == 2)  
+  ENDIF  ! (iflag_wk_pop_dyn >= 1)
+ 
+!>jyg
 
  RETURN
@@ -2161,5 +2283,5 @@
         discrim = b*b - 4.*a*c
         ! print*, 'x, a, b, c, discrim', x, a, b, c, discrim
-        IF (a+b>=0.) THEN !! Condition suffisante pour la positivité de ovap
+        IF (a+b>=0.) THEN !! Condition suffisante pour la positivite de ovap
           alpha1(i) = 1.
         ELSE
@@ -2186,2 +2308,360 @@
   RETURN
 END SUBROUTINE wake_vec_modulation
+
+
+
+SUBROUTINE pkupper (klon, klev, ptop, ph, pupper, kupper)
+
+USE wake_ini_mod , ONLY : pupperbyphs
+IMPLICIT NONE
+
+INTEGER,  INTENT(IN)                              :: klon,klev
+REAL,     INTENT(IN),   DIMENSION (klon,klev+1)   :: ph
+REAL,     INTENT(IN),   DIMENSION (klon)          :: ptop
+REAL,     INTENT(OUT),  DIMENSION (klon)          :: pupper
+INTEGER,  INTENT(OUT),  DIMENSION (klon)          :: kupper
+INTEGER                                           :: i,k
+
+
+ kupper = 0
+ 
+IF (pupperbyphs<1.) THEN
+ ! Choose an integration bound well above wake top
+  ! -----------------------------------------------------------------
+
+  ! Pupper = 50000.  ! melting level
+  ! Pupper = 60000.
+  ! Pupper = 80000.  ! essais pour case_e
+  DO i = 1, klon
+  !  pupper(i) = 0.6*ph(i, 1)
+    pupper(i) = pupperbyphs*ph(i, 1)
+    pupper(i) = max(pupper(i), 45000.)
+    ! cc        Pupper(i) = 60000.
+  END DO
+
+ELSE
+  
+  DO i=1, klon
+     ! pupper(i) = pupperbyphs*ptop(i)+(1.-pupperbyphs)*ph(i, 1) 
+     pupper(i) = min( pupperbyphs*ptop(i)+(1.-pupperbyphs)*ph(i, 1) , ptop(i)-5000.) 
+  END DO
+END IF
+ 
+  ! -5/ Determination de kupper
+
+  DO k = klev, 1, -1
+    DO i = 1, klon
+      IF (ph(i,k+1)<pupper(i)) kupper(i) = k
+    END DO
+  END DO
+
+  ! On evite kupper = 1 et kupper = klev
+  DO i = 1, klon
+    kupper(i) = max(kupper(i), 2)
+    kupper(i) = min(kupper(i), klev-1)
+  END DO 
+    RETURN
+END SUBROUTINE pkupper
+
+
+SUBROUTINE wake_popdyn_1(klon, klev, dtime, cstar, tau_wk_inv, wgen, wdens, awdens, sigmaw, &
+                  dtimesub, gfl, rad_wk, f_shear, drdt_pos, &
+                  d_awdens, d_wdens, d_sigmaw, &
+                  iflag_wk_act, wk_adv, cin, wape, &
+                  drdt, &
+                  d_dens_gen, d_dens_death, d_dens_col, d_dens_bnd, &
+                  d_sig_gen, d_sig_death, d_sig_col, d_sig_spread, d_sig_bnd, &
+                  d_wdens_targ, d_sigmaw_targ)
+                
+
+  USE wake_ini_mod , ONLY : wake_ini
+  USE wake_ini_mod , ONLY : prt_level,RG
+  USE wake_ini_mod , ONLY : stark, wdens_ref
+  USE wake_ini_mod , ONLY : tau_cv, rzero, aa0
+  USE wake_ini_mod , ONLY : iflag_wk_pop_dyn, wdensmin
+  USE wake_ini_mod , ONLY : sigmad, cstart, sigmaw_max
+  
+IMPLICIT NONE
+
+  INTEGER, INTENT(IN)                                   :: klon,klev
+  LOGICAL, DIMENSION (klon),        INTENT(IN)          :: wk_adv
+  REAL,                             INTENT(IN)          :: dtime
+  REAL,                             INTENT(IN)          :: dtimesub
+  REAL, DIMENSION (klon),           INTENT(IN)          :: wgen
+  REAL, DIMENSION (klon),           INTENT(IN)          :: wdens
+  REAL, DIMENSION (klon),           INTENT(IN)          :: awdens
+  REAL, DIMENSION (klon),           INTENT(IN)          :: sigmaw
+  REAL, DIMENSION (klon),           INTENT(IN)          :: gfl, cstar
+  REAL, DIMENSION (klon),           INTENT(IN)          :: cin, wape
+  REAL, DIMENSION (klon),           INTENT(IN)          :: rad_wk
+  REAL, DIMENSION (klon),           INTENT(IN)          :: f_shear
+  INTEGER,                          INTENT(IN)          :: iflag_wk_act
+
+  
+  !
+ 
+  ! Tendencies of state variables (2 is appended to the names of fields which are the cumul of fields 
+  !                                 computed at each sub-timestep; e.g. d_wdens2 is the cumul of d_wdens)
+  REAL, DIMENSION (klon),           INTENT(OUT)         :: d_sigmaw, d_awdens, d_wdens
+  REAL, DIMENSION (klon),           INTENT(OUT)         :: drdt
+  ! Some components of the tendencies of state variables  
+  REAL, DIMENSION (klon),           INTENT(OUT)         :: d_sig_gen, d_sig_death, d_sig_col, d_sig_bnd
+  REAL, DIMENSION (klon),           INTENT(OUT)         :: d_sig_spread
+  REAL, DIMENSION (klon),           INTENT(OUT)         :: d_dens_gen, d_dens_death, d_dens_col, d_dens_bnd
+  REAL,                             INTENT(OUT)         :: d_wdens_targ, d_sigmaw_targ
+ 
+  
+  REAL                                                  :: delta_t_min
+  INTEGER                                               :: nsub
+  INTEGER                                               :: i, k
+  REAL                                                  :: wdens0
+  ! IM 080208
+  LOGICAL, DIMENSION (klon)                             :: gwake
+  
+   ! Variables liees a la dynamique de population
+  REAL, DIMENSION(klon)                                 :: act
+  REAL, DIMENSION(klon)                                 :: tau_wk_inv
+  REAL, DIMENSION(klon)                                 :: wape1_act, wape2_act
+  LOGICAL, DIMENSION (klon)                             :: kill_wake
+  REAL                                                  :: drdt_pos
+  REAL                                                  :: tau_wk_inv_min
+  
+     
+
+      IF (iflag_wk_act == 0) THEN
+        act(:) = 0.
+      ELSEIF (iflag_wk_act == 1) THEN
+        act(:) = 1.
+      ELSEIF (iflag_wk_act ==2) THEN
+      DO i = 1, klon
+        IF (wk_adv(i)) THEN
+          wape1_act(i) = abs(cin(i))
+          wape2_act(i) = 2.*wape1_act(i) + 1.
+          act(i) = min(1., max(0., (wape(i)-wape1_act(i)) / (wape2_act(i)-wape1_act(i)) ))
+        ENDIF  ! (wk_adv(i))
+      ENDDO
+      ENDIF  ! (iflag_wk_act ==2)
+
+
+      DO i = 1, klon
+       ! print*, 'XXX wk_adv(i)', wk_adv(i)
+        IF (wk_adv(i)) THEN
+!!          tau_wk(i) = max(rad_wk(i)/(3.*cstar(i))*((cstar(i)/cstart)**1.5 - 1), 100.)
+          tau_wk_inv(i) = max( (3.*cstar(i))/(rad_wk(i)*((cstar(i)/cstart)**1.5 - 1)), 0.)
+          tau_wk_inv_min = min(tau_wk_inv(i), 1./dtimesub)
+          drdt(i) = (cstar(i) - wgen(i)*(sigmaw(i)/wdens(i)-aa0)/gfl(i)) / &
+                    (1 + 2*f_shear(i)*(2.*sigmaw(i)-aa0*wdens(i)) - 2.*sigmaw(i))
+!!                    (1 - 2*sigmaw(i)*(1.-f_shear(i)))
+          drdt_pos=max(drdt(i),0.)
+
+!!          d_wdens(i) = ( wgen(i)*(1.+2.*(sigmaw(i)-sigmad)) &
+!!                     - wdens(i)*tau_wk_inv_min &
+!!                     - 2.*gfl(i)*wdens(i)*Cstar(i) )*dtimesub
+!jyg+mlt<
+          d_awdens(i) = ( wgen(i) - (1./tau_cv)*(awdens(i) - act(i)*wdens(i)) )*dtimesub
+          d_dens_gen(i) = wgen(i)
+          d_dens_death(i) = - (wdens(i)-awdens(i))*tau_wk_inv_min 
+          d_dens_col(i) =  -2.*wdens(i)*gfl(i)*drdt_pos 
+          d_dens_gen(i) =  d_dens_gen(i)*dtimesub
+          d_dens_death(i) = d_dens_death(i)*dtimesub
+          d_dens_col(i) =  d_dens_col(i)*dtimesub 
+
+          d_wdens(i) = d_dens_gen(i)+d_dens_death(i)+d_dens_col(i)
+!!          d_wdens(i) = ( wgen(i) - (wdens(i)-awdens(i))*tau_wk_inv_min -  &
+!!                         2.*wdens(i)*gfl(i)*drdt_pos )*dtimesub
+!>jyg+mlt
+!
+!jyg<
+          d_wdens_targ = max(d_wdens(i), wdensmin-wdens(i))
+!!          d_dens_bnd(i) = d_dens_bnd(i) + d_wdens_targ - d_wdens(i)
+          d_dens_bnd(i) = d_wdens_targ - d_wdens(i)
+          d_wdens(i) = d_wdens_targ
+!!          d_wdens(i) = max(d_wdens(i), wdensmin-wdens(i))
+!>jyg
+
+!jyg+mlt<
+!!          d_sigmaw(i) = ( (1.-2*f_shear(i)*sigmaw(i))*(gfl(i)*Cstar(i)+wgen(i)*sigmad/wdens(i)) &
+!!                      + 2.*f_shear(i)*wgen(i)*sigmaw(i)**2/wdens(i) &
+!!                      - sigmaw(i)*tau_wk_inv_min )*dtimesub
+          d_sig_gen(i) = wgen(i)*aa0
+!!          print*, 'XXX sigmaw(i), awdens(i), wdens(i), tau_wk_inv_min', &
+!!                  sigmaw(i), awdens(i), wdens(i), tau_wk_inv_min
+          d_sig_death(i) = - sigmaw(i)*(1.-awdens(i)/wdens(i))*tau_wk_inv_min
+!!        
+          
+          d_sig_col(i) = - 2*f_shear(i)*sigmaw(i)*gfl(i)*drdt_pos
+          d_sig_col(i) = - 2*f_shear(i)*(2.*sigmaw(i)-wdens(i)*aa0)*gfl(i)*drdt_pos
+          d_sig_spread(i) = gfl(i)*cstar(i)
+          d_sig_gen(i) =  d_sig_gen(i)*dtimesub
+          d_sig_death(i) = d_sig_death(i)*dtimesub
+          d_sig_col(i) =  d_sig_col(i)*dtimesub 
+          d_sig_spread(i) =  d_sig_spread(i)*dtimesub 
+          d_sigmaw(i) =  d_sig_gen(i) + d_sig_death(i) + d_sig_col(i) + d_sig_spread(i)
+!>jyg+mlt
+!
+!jyg<
+          d_sigmaw_targ = max(d_sigmaw(i), sigmad-sigmaw(i))
+!!          d_sig_bnd(i) = d_sig_bnd(i) + d_sigmaw_targ - d_sigmaw(i)
+!!          d_sig_bnd_provis(i) = d_sigmaw_targ - d_sigmaw(i)
+          d_sig_bnd(i) = d_sigmaw_targ - d_sigmaw(i)
+          d_sigmaw(i) = d_sigmaw_targ
+!!          d_sigmaw(i) = max(d_sigmaw(i), sigmad-sigmaw(i))
+!>jyg
+        ENDIF
+      ENDDO
+
+      IF (prt_level >= 10) THEN
+        print *,'wake, cstar(1), cstar(1)/cstart, rad_wk(1), tau_wk_inv(1), drdt(1) ', &
+                       cstar(1), cstar(1)/cstart, rad_wk(1), tau_wk_inv(1), drdt(1)
+        print *,'wake, wdens(1), awdens(1), act(1), d_awdens(1) ', &
+                       wdens(1), awdens(1), act(1), d_awdens(1)
+        print *,'wake, wgen, -(wdens-awdens)*tau_wk_inv, -2.*wdens*gfl*drdt_pos, d_wdens ', &
+                       wgen(1), -(wdens(1)-awdens(1))*tau_wk_inv(1), -2.*wdens(1)*gfl(1)*drdt_pos, d_wdens(1)
+        print *,'wake, d_sig_gen(1), d_sig_death(1), d_sig_col(1), d_sigmaw(1) ', &
+                       d_sig_gen(1), d_sig_death(1), d_sig_col(1), d_sigmaw(1)
+      ENDIF
+    
+    RETURN 
+    END SUBROUTINE wake_popdyn_1
+    
+    SUBROUTINE wake_popdyn_2 ( klon, klev, wk_adv, dtimesub, wgen, &
+                             sigmaw, wdens, awdens, &   !! states variables
+                             gfl, cstar, cin, wape, rad_wk, &
+                             d_sigmaw, d_wdens, d_awdens, &  !! tendences 
+                             cont_fact, &
+                             d_sig_gen, d_sig_death, d_sig_col, d_sig_spread, d_sig_bnd, &
+                             d_dens_gen, d_dens_death, d_dens_col, d_dens_bnd, &
+                             d_adens_death, d_adens_icol, d_adens_acol, d_adens_bnd )
+                             
+                                             
+
+  USE wake_ini_mod , ONLY : wake_ini
+  USE wake_ini_mod , ONLY : prt_level,RG
+  USE wake_ini_mod , ONLY : stark, wdens_ref
+  USE wake_ini_mod , ONLY : tau_cv, rzero, aa0
+  USE wake_ini_mod , ONLY : iflag_wk_pop_dyn, wdensmin
+  USE wake_ini_mod , ONLY : sigmad, cstart, sigmaw_max
+  
+IMPLICIT NONE
+
+  INTEGER, INTENT(IN)                                   :: klon,klev
+  LOGICAL, DIMENSION (klon),        INTENT(IN)          :: wk_adv
+  REAL,                             INTENT(IN)          :: dtimesub
+  REAL, DIMENSION (klon),           INTENT(IN)          :: wgen      !! B = birth rate of wakes
+  REAL, DIMENSION (klon),           INTENT(INOUT)       :: sigmaw    !! sigma = fractional area of wakes 
+  REAL, DIMENSION (klon),           INTENT(INOUT)       :: wdens     !! D = number of wakes per unit area 
+  REAL, DIMENSION (klon),           INTENT(INOUT)       :: awdens    !! A = number of active wakes per unit area
+  REAL, DIMENSION (klon),           INTENT(IN)          :: gfl       !! Lg = gust front lenght per unit area
+  REAL, DIMENSION (klon),           INTENT(IN)          :: cstar     !! C* = spreading velocity of wakes
+  REAL, DIMENSION (klon),           INTENT(IN)          :: cin, wape  ! RM : A Faire disparaitre
+  REAL, DIMENSION (klon),           INTENT(IN)          :: rad_wk    !! r = wake radius
+
+!  
+  REAL, DIMENSION (klon),           INTENT(OUT)         :: d_sigmaw, d_wdens, d_awdens
+  REAL, DIMENSION (klon),           INTENT(OUT)         :: cont_fact  !! RM facteur de contact = 2 pi * rad * C*
+  ! Some components of the tendencies of state variables  
+  REAL, DIMENSION (klon),           INTENT(OUT)         :: d_sig_gen, d_sig_death, d_sig_col, d_sig_spread, d_sig_bnd
+  REAL, DIMENSION (klon),           INTENT(OUT)         :: d_dens_gen, d_dens_death, d_dens_col, d_dens_bnd
+  REAL, DIMENSION (klon),           INTENT(OUT)         :: d_adens_death, d_adens_icol, d_adens_acol, d_adens_bnd
+
+
+!! internal variables
+  
+  INTEGER                                               :: i, k
+  REAL, DIMENSION (klon)                                :: tau_wk_inv      !! tau = life time of wakes
+  REAL                                                  :: tau_wk_inv_min
+  REAL, DIMENSION (klon)                                :: tau_prime       !! tau_prime = life time of actives wakes
+  REAL                                                  :: d_wdens_targ, d_sigmaw_targ
+  
+
+!! Equations
+!! dD/dt = B - (D-A)/tau - f D^2
+!! dA/dt = B - A/tau_prime + f (D-A)^2 - f A^2
+!! dsigma/dt = B a0 - sigma/D (D-A)/tau + Lg C* - f (D-A)^2 (sigma/D-a0)
+!!
+!! f = 2 (B (a0-sigma/D) + Lg C*) / (2 (D-A)^2 (2 sigma/D-a0) + D (1-2 sigma))
+
+
+      DO i = 1, klon
+       ! print*, 'XXX wk_adv(i)', wk_adv(i)
+        IF (wk_adv(i)) THEN
+!!          tau_wk(i) = max(rad_wk(i)/(3.*cstar(i))*((cstar(i)/cstart)**1.5 - 1), 100.)
+          tau_wk_inv(i) = max( (3.*cstar(i))/(rad_wk(i)*((cstar(i)/cstart)**1.5 - 1)), 0.)
+          tau_wk_inv_min = min(tau_wk_inv(i), 1./dtimesub)
+          tau_prime(i) = tau_cv
+!!          cont_fact(i) = 2.*(wgen(i)*(aa0-sigmaw(i)/wdens(i)) + gfl(i)*cstar(i)) / &
+!!                             (2.*(wdens(i)-awdens(i))**2*(2.*sigmaw(i)/wdens(i) - aa0) + wdens(i)*(1.-2.*sigmaw(i)))
+!!          cont_fact(i) = 2.*3.14*rad_wk(i)*cstar(i)     ! bug
+!!          cont_fact(i) = 4.*3.14*rad_wk(i)*cstar(i)
+          cont_fact(i) = 2.*gfl(i)*cstar(i)/wdens(i)
+
+          d_sig_gen(i) = wgen(i)*aa0
+          d_sig_death(i) = - sigmaw(i)*(1.-awdens(i)/wdens(i))*tau_wk_inv_min
+          d_sig_col(i) = - cont_fact(i)*(wdens(i)-awdens(i))**2*(2.*sigmaw(i)/wdens(i)-aa0)
+          d_sig_spread(i) = gfl(i)*cstar(i)
+!
+          d_sig_gen(i) =  d_sig_gen(i)*dtimesub
+          d_sig_death(i) = d_sig_death(i)*dtimesub
+          d_sig_col(i) =  d_sig_col(i)*dtimesub 
+          d_sig_spread(i) =  d_sig_spread(i)*dtimesub 
+          d_sigmaw(i) =  d_sig_gen(i) + d_sig_death(i) + d_sig_col(i) + d_sig_spread(i)
+
+         
+          d_sigmaw_targ = max(d_sigmaw(i), sigmad-sigmaw(i))
+!!          d_sig_bnd(i) = d_sig_bnd(i) + d_sigmaw_targ - d_sigmaw(i)
+!!          d_sig_bnd_provis(i) = d_sigmaw_targ - d_sigmaw(i)
+          d_sig_bnd(i) = d_sigmaw_targ - d_sigmaw(i)
+          d_sigmaw(i) = d_sigmaw_targ
+!!          d_sigmaw(i) = max(d_sigmaw(i), sigmad-sigmaw(i))
+         
+         
+          d_dens_gen(i) = wgen(i)
+          d_dens_death(i) = - (wdens(i)-awdens(i))*tau_wk_inv_min 
+          d_dens_col(i) =  - cont_fact(i)*wdens(i)**2
+! 
+          d_dens_gen(i) =  d_dens_gen(i)*dtimesub
+          d_dens_death(i) = d_dens_death(i)*dtimesub
+          d_dens_col(i) =  d_dens_col(i)*dtimesub 
+          d_wdens(i) = d_dens_gen(i) + d_dens_death(i) + d_dens_col(i)
+
+
+          d_adens_death(i) = -awdens(i)/tau_prime(i)
+          d_adens_icol(i) = cont_fact(i)*(wdens(i)-awdens(i))**2
+          d_adens_acol(i) = - cont_fact(i)*awdens(i)**2
+!
+          d_adens_death(i) =  d_adens_death(i)*dtimesub
+          d_adens_icol(i) =   d_adens_icol(i)*dtimesub
+          d_adens_acol(i) =   d_adens_acol(i)*dtimesub
+          d_awdens(i) =   d_dens_gen(i) + d_adens_death(i) + d_adens_icol(i) + d_adens_acol(i)     
+            
+!!
+          d_wdens_targ = max(d_wdens(i), wdensmin-wdens(i))
+!!          d_dens_bnd(i) = d_dens_bnd(i) + d_wdens_targ - d_wdens(i)
+          d_dens_bnd(i) = d_wdens_targ - d_wdens(i)
+          d_wdens(i) = d_wdens_targ
+          
+          d_wdens_targ = min(max(d_awdens(i),-awdens(i)), wdens(i)-awdens(i))
+!!          d_dens_bnd(i) = d_dens_bnd(i) + d_wdens_targ - d_wdens(i)
+          d_adens_bnd(i) = d_wdens_targ - d_awdens(i)
+          d_awdens(i) = d_wdens_targ
+
+
+
+        ENDIF
+      ENDDO
+
+      IF (prt_level >= 10) THEN
+        print *,'wake, cstar(1), cstar(1)/cstart, rad_wk(1), tau_wk_inv(1), cont_fact(1) ', &
+                       cstar(1), cstar(1)/cstart, rad_wk(1), tau_wk_inv(1), cont_fact(1)
+        print *,'wake, wdens(1), awdens(1), d_awdens(1) ', &
+                       wdens(1), awdens(1), d_awdens(1)
+        print *,'wake, d_sig_gen(1), d_sig_death(1), d_sig_col(1), d_sigmaw(1) ', &
+                       d_sig_gen(1), d_sig_death(1), d_sig_col(1), d_sigmaw(1)
+      ENDIF
+sigmaw=sigmaw+d_sigmaw
+wdens=wdens+d_wdens
+awdens=awdens+d_awdens
+
+    RETURN 
+    END SUBROUTINE wake_popdyn_2  
+  
Index: LMDZ6/branches/Portage_acc/libf/phylmd/wake_ini_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/wake_ini_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/wake_ini_mod.F90	(revision 4446)
@@ -17,16 +17,16 @@
 
   ! -------------------------------------------------------------------------
-  ! Déclaration de variables
-  ! -------------------------------------------------------------------------
-
-  ! Variables à fixer
+  ! Declaration de variables
+  ! -------------------------------------------------------------------------
+
+  ! Variables a fixer
 !jyg<
 !!  REAL, SAVE                                            :: stark, wdens_ref, coefgw, alpk
   INTEGER, SAVE, PROTECTED                                         :: prt_level
   REAL, SAVE, PROTECTED, DIMENSION(2)                              :: wdens_ref
-  REAL, SAVE, PROTECTED                                            :: stark, coefgw, alpk
+  REAL, SAVE, PROTECTED                                            :: stark, coefgw, alpk, pupperbyphs
 !>jyg
   REAL, SAVE, PROTECTED                                            :: crep_upper, crep_sol  
-  !$OMP THREADPRIVATE(stark, wdens_ref, coefgw, alpk, crep_upper, crep_sol)
+  !$OMP THREADPRIVATE(stark, wdens_ref, coefgw, alpk, pupperbyphs, crep_upper, crep_sol)
 
   REAL, SAVE, PROTECTED                                            :: tau_cv
@@ -44,4 +44,7 @@
   INTEGER, SAVE, PROTECTED                                         :: iflag_wk_pop_dyn
   !$OMP THREADPRIVATE(iflag_wk_pop_dyn)
+
+  INTEGER, SAVE, PROTECTED                                         :: iflag_wk_profile
+  !$OMP THREADPRIVATE(iflag_wk_profile)
 
   REAL, SAVE, PROTECTED                                            :: wdensmin
@@ -111,7 +114,7 @@
   ! Configuration de coefgw,stark,wdens (22/02/06 by YU Jingmei)
 
-  ! coefgw : Coefficient pour les ondes de gravité
+  ! coefgw : Coefficient pour les ondes de gravite
   ! stark : Coefficient k dans Cstar=k*sqrt(2*WAPE)
-  ! wdens : Densité surfacique de poche froide
+  ! wdens : Densite surfacique de poche froide
   ! -------------------------------------------------------------------------
 
@@ -149,4 +152,9 @@
   alpk=0.25
   CALL getin_p('alpk',alpk)
+  
+  pupperbyphs=0.6
+  CALL getin_p('pupperbyphs',pupperbyphs)
+
+
 !jyg<
 !!  wdens_ref=8.E-12
@@ -170,4 +178,7 @@
                                             ! 2: act(:)=f(Wape)
 
+  iflag_wk_profile = 0
+  CALL getin_p('iflag_wk_profile',iflag_wk_profile) ! switch between wdens prescribed 
+                                                    ! and wdens prognostic
   rzero = 5000.
   CALL getin_p('rzero_wk', rzero)
@@ -184,4 +195,5 @@
   WRITE(*,*) 'stark=', stark
   WRITE(*,*) 'alpk=', alpk
+  WRITE(*,*) 'pupperbyphs=', pupperbyphs
 !jyg<
 !!  WRITE(*,*) 'wdens_ref=', wdens_ref
Index: LMDZ6/branches/Portage_acc/libf/phylmd/write_bilKP_ave.h
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/write_bilKP_ave.h	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/write_bilKP_ave.h	(revision 4446)
@@ -49,5 +49,5 @@
       CALL histwrite_phy(nid_bilKPave,"play",itau_w,paprs)
 c
-cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldliq, zx_tmp_3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, radocond, zx_tmp_3d)
       CALL histwrite_phy(nid_bilKPave,"oliq",itau_w,cldliq)
 c
Index: LMDZ6/branches/Portage_acc/libf/phylmd/write_bilKP_ins.h
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/write_bilKP_ins.h	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/write_bilKP_ins.h	(revision 4446)
@@ -49,5 +49,5 @@
       CALL histwrite_phy(nid_bilKPins,"play",itau_w,paprs)
 c
-cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldliq, zx_tmp_3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, radocond, zx_tmp_3d)
       CALL histwrite_phy(nid_bilKPins,"oliq",itau_w,cldliq)
 c
Index: LMDZ6/branches/Portage_acc/libf/phylmd/yamada4.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/yamada4.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/yamada4.F90	(revision 4446)
@@ -444,5 +444,5 @@
          tkeprov= tkeprov*                           &
            &  (tkeprov+dt*(shear(ig,k)+max(0.,buoy(ig,k))))/ &
-           &  (tkeprov+dt*((-1.)*min(0.,buoy(ig,k))+dissip(ig,k)))
+           &  (tkeprov+dt*((-1.)*min(0.,buoy(ig,k))+dissip(ig,k)+drgpro(ig,k)*tkeprov))
          q2(ig,k)=tkeprov*ydeux
         ENDDO
@@ -497,10 +497,4 @@
          DO ig=1,ngrid
          tkeprov=q2(ig,k)/ydeux
-
-!             if(ifl_pbltree .eq. 0) then
-!         disseff=dissip(ig,k)-min(0.,buoy(ig,k))
-!         tkeexp=exp(-dt*disseff/tkeprov)
-!         tkeprov= shear(ig,k)*tkeprov/disseff*(1.-tkeexp)+tkeprov*tkeexp
-!           else
 !FC on ajoute la dissipation due aux arbres
          disseff=dissip(ig,k)-min(0.,buoy(ig,k)) + drgpro(ig,k)*tkeprov
@@ -510,8 +504,5 @@
          tkeprov= (shear(ig,k)+ &
           & drgpro(ig,k)*(winds(ig,k))**3)*tkeprov/disseff*(1.-tkeexp)+tkeprov*tkeexp
-!               endif
-
          q2(ig,k)=tkeprov*ydeux
-
          ! En cas stable, on traite la flotabilite comme la
          ! dissipation, en supposant que buoy/q2^3 est constant.
@@ -522,14 +513,7 @@
        DO k = 2, klev - 1
          DO ig=1,ngrid
-         !tkeprov=q2(ig,k)/ydeux
-         !tkeprov=tkeprov+max(buoy(ig,k)+shear(ig,k),0.)*dt
-         !disseff=dissip(ig,k)-min(0.,buoy(ig,k)+shear(ig,k)) 
-         !tkeexp=exp(-dt*disseff/tkeprov)
-         !tkeprov= tkeprov*tkeexp
-         !q2(ig,k)=tkeprov*ydeux
          ! En cas stable, on traite la flotabilite comme la
          ! dissipation, en supposant que dissipeff/TKE est constant.
          ! Puis on prend la solution exacte
-         ! 
          ! With drag and dissipation from high vegetation (EV & FC, 05/10/2020)
          winds(ig,k)=sqrt(u(ig,k)**2+v(ig,k)**2)
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/add_phys_tend_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/add_phys_tend_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/add_phys_tend_mod.F90	(revision 4446)
@@ -39,5 +39,5 @@
   USE mod_grid_phy_lmdz, ONLY: nbp_lev
 #ifdef ISO
-  USE infotrac_phy, ONLY: ntraciso
+  USE infotrac_phy, ONLY: ntraciso=>ntiso
   USE isotopes_mod, ONLY: iso_eau
 #endif
@@ -154,5 +154,5 @@
 
 #ifdef ISO
-    USE infotrac_phy, ONLY: ntraciso  
+    USE infotrac_phy, ONLY: ntraciso=>ntiso
 #ifdef ISOVERIF
     USE isotopes_mod, ONLY: iso_eau
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/add_wake_tend.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/add_wake_tend.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/add_wake_tend.F90	(revision 4446)
@@ -18,5 +18,5 @@
 USE print_control_mod, ONLY: prt_level
 #ifdef ISO
-    USE infotrac_phy, ONLY: ntraciso    
+    USE infotrac_phy, ONLY: ntiso    
     USE phys_state_var_mod, ONLY:  wake_deltaxt   
 #endif
@@ -31,5 +31,5 @@
   INTEGER,                       INTENT (IN)         :: abortphy
 #ifdef ISO
-  REAL, DIMENSION(ntraciso,klon, klev),   INTENT (IN)         :: zddeltaxt
+  REAL, DIMENSION(ntiso, klon, klev), INTENT (IN)    :: zddeltaxt
 #endif
 
@@ -61,5 +61,5 @@
                wake_deltaq(i, l) = wake_deltaq(i, l) + zddeltaq(i,l)
 #ifdef ISO
-               do ixt=1,ntraciso
+               do ixt=1,ntiso
                  wake_deltaxt(ixt,i, l) = wake_deltaxt(ixt,i, l) + zddeltaxt(ixt,i,l)
                enddo
@@ -69,5 +69,5 @@
                wake_deltaq(i, l) = 0.
 #ifdef ISO
-               do ixt=1,ntraciso
+               do ixt=1,ntiso
                  wake_deltaxt(ixt,i, l) = 0.0
                enddo
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/ajsec.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/ajsec.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/ajsec.F90	(revision 4446)
@@ -9,5 +9,5 @@
   USE dimphy
 #ifdef ISO
-    USE infotrac_phy, ONLY: ntraciso    
+    USE infotrac_phy, ONLY: ntraciso =>ntiso   
 #ifdef ISOVERIF
   USE isotopes_mod, ONLY : iso_eau,iso_HDO
@@ -303,5 +303,5 @@
   USE dimphy
 #ifdef ISO
-    USE infotrac_phy, ONLY: ntraciso       
+    USE infotrac_phy, ONLY: ntraciso=>ntiso    
 #ifdef ISOVERIF
   USE isotopes_mod, ONLY : iso_eau,iso_HDO
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/calwake.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/calwake.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/calwake.F90	(revision 4446)
@@ -35,5 +35,5 @@
   USE print_control_mod, ONLY: mydebug=>debug , lunout, prt_level
 #ifdef ISO
-  USE infotrac_phy, ONLY : ntraciso
+  USE infotrac_phy, ONLY : ntraciso=>ntiso
 #ifdef ISOVERIF
   USE isotopes_mod, ONLY: iso_eau
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/change_srf_frac_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/change_srf_frac_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/change_srf_frac_mod.F90	(revision 4446)
@@ -39,5 +39,5 @@
     USE print_control_mod, ONLY: lunout
 #ifdef ISO
-  USE infotrac_phy, ONLY: ntraciso    
+  USE infotrac_phy, ONLY: ntiso    
 #endif
     
@@ -66,5 +66,5 @@
 !albedo SB <<<
 #ifdef ISO
-    REAL, DIMENSION(ntraciso,klon,nbsrf), INTENT(INOUT)        :: xtevap
+    REAL, DIMENSION(ntiso,klon,nbsrf), INTENT(INOUT)        :: xtevap
 #endif
 
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/climb_hq_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/climb_hq_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/climb_hq_mod.F90	(revision 4446)
@@ -6,5 +6,5 @@
   USE dimphy
 #ifdef ISO
-  USE infotrac_phy, ONLY: ntraciso ! ajout C Risi pour isos      
+  USE infotrac_phy, ONLY: ntraciso=>ntiso ! ajout C Risi pour isos      
 #endif
 
@@ -59,5 +59,4 @@
             )
 #ifdef ISOVERIF
-!USE infotrac_phy, ONLY: use_iso
 USE isotopes_mod, ONLY: iso_eau,iso_HDO
 !USE isotopes_verif_mod, ONLY: errmax, errmaxrel
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/concvl.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/concvl.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/concvl.F90	(revision 4446)
@@ -44,5 +44,5 @@
   USE infotrac_phy, ONLY: nbtr
 #ifdef ISO
-  USE infotrac_phy, ONLY: ntraciso
+  USE infotrac_phy, ONLY: ntraciso=>ntiso
   USE isotopes_mod, ONLY: iso_eau, bidouille_anti_divergence, ridicule, &
         iso_eau,iso_HDO
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/cv30_routines.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/cv30_routines.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/cv30_routines.F90	(revision 4446)
@@ -165,5 +165,5 @@
     )
 #ifdef ISO
-    USE infotrac_phy, ONLY: ntraciso    
+    USE infotrac_phy, ONLY: ntraciso=>ntiso
 #endif
   IMPLICIT NONE
@@ -370,5 +370,5 @@
 
 #ifdef ISO
-USE infotrac_phy, ONLY: ntraciso
+USE infotrac_phy, ONLY: ntraciso=>ntiso
 USE isotopes_mod, ONLY: pxtmelt,pxtice,pxtmin,pxtmax,cond_temp_env, &
         iso_eau,iso_HDO, ridicule
@@ -947,5 +947,5 @@
   USE print_control_mod, ONLY: lunout
 #ifdef ISO
-    use infotrac_phy, ONLY: ntraciso
+    use infotrac_phy, ONLY: ntraciso=>ntiso
     use isotopes_mod, ONLY: essai_convergence, iso_eau,iso_HDO
 #ifdef ISOVERIF
@@ -1133,5 +1133,5 @@
     ! epmax_cape: ajout arguments
 #ifdef ISO
-use infotrac_phy, ONLY: ntraciso
+use infotrac_phy, ONLY: ntraciso=>ntiso
 USE isotopes_mod, ONLY: pxtmelt,pxtice,pxtmin,pxtmax,cond_temp_env, iso_eau,iso_HDO
 USE isotopes_routines_mod, ONLY: condiso_liq_ice_vectall
@@ -1828,5 +1828,5 @@
 
 #ifdef ISO
-use infotrac_phy, ONLY: ntraciso,niso,index_trac
+use infotrac_phy, ONLY: ntraciso=>ntiso,niso,itZonIso
 USE isotopes_mod, ONLY: pxtmelt,pxtice,pxtmin,pxtmax, iso_eau,iso_HDO, &
         ridicule
@@ -2616,5 +2616,5 @@
         call iso_verif_traceur(xtclw(1,il,im), &
      &          'condiso_liq_ice_vectiso_trac 358')
-        if (iso_verif_positif_nostop(xtclw(index_trac( &
+        if (iso_verif_positif_nostop(xtclw(itZonIso( &
      &           izone_cond,iso_eau),i,k)-xtclw(iso_eau,i,k) &
      &           ,'cv30_routines 909').eq.1) then
@@ -2624,5 +2624,5 @@
      &             niso,ntraciso,index_zone,izone_cond       
                stop
-         endif !if (iso_verif_positif_nostop(xtclw(index_trac(
+         endif !if (iso_verif_positif_nostop(xtclw(itZonIso(
 #endif             
          enddo !do il = 1, ncum   
@@ -2647,5 +2647,5 @@
      &          )
 #ifdef ISO
-    use infotrac_phy, ONLY: ntraciso
+    use infotrac_phy, ONLY: ntraciso=>ntiso
     use isotopes_mod, ONLY: essai_convergence, iso_eau,iso_HDO,ridicule
     use isotopes_routines_mod, ONLY: appel_stewart_vectall
@@ -2659,5 +2659,5 @@
 #ifdef ISOTRAC
     use isotrac_mod, only: option_cond,izone_cond
-    use infotrac_phy, ONLY: index_trac
+    use infotrac_phy, ONLY: itZonIso
 #ifdef ISOVERIF
     use isotopes_verif_mod, ONLY: iso_verif_traceur_justmass, &
@@ -2938,5 +2938,5 @@
            ! on verifie que tout le detrainement est tagge condensat
            if (iso_verif_positif_nostop( &
-     &          xtwdtrain(index_trac(izone_cond,iso_eau),il) &
+     &          xtwdtrain(itZonIso(izone_cond,iso_eau),il) &
      &          -xtwdtrain(iso_eau,il), &
      &          'cv30_routines 2795').eq.1) then
@@ -3200,5 +3200,5 @@
 !        if (option_tmin.ge.1) then
 !           call iso_verif_positif(xtwater(
-!     :           index_trac(izone_cond,iso_eau),il,i+1)
+!     :           itZonIso(izone_cond,iso_eau),il,i+1)
 !     :           -xtwater(iso_eau,il,i+1),
 !     :          'cv30_routines 3083')
@@ -3259,5 +3259,5 @@
 !        if (option_tmin.ge.1) then
 !         call iso_verif_positif(xtwater(
-!     :           index_trac(izone_cond,iso_eau),il,i)
+!     :           itZonIso(izone_cond,iso_eau),il,i)
 !     :           -xtwater(iso_eau,il,i),
 !     :          'cv30_routines 3143')
@@ -3369,6 +3369,5 @@
      &                    )
 #ifdef ISO
-    use infotrac_phy, ONLY: ntraciso,niso, &
-&       ntraceurs_zone,index_trac
+    use infotrac_phy, ONLY: ntraciso=>ntiso, niso, nzone, itZonIso
     use isotopes_mod, ONLY: essai_convergence,ridicule,iso_eau,iso_HDO,iso_O18
 #ifdef ISOVERIF
@@ -5003,5 +5002,5 @@
           do iiso = 1, niso
              
-             ixt_ddft=index_trac(izone_ddft,iiso)  
+             ixt_ddft=itZonIso(izone_ddft,iiso)  
              if (mp(il,i).gt.mp(il,i+1)) then
                 fxtYe(iiso)=0.01*grav*dpinv*mp(il,i) &
@@ -5016,5 +5015,5 @@
      &              -mp(il,i)*(xtp(iiso,il,i)-xt(iiso,il,i-1))) 
         
-             ixt_poubelle=index_trac(izone_poubelle,iiso)
+             ixt_poubelle=itZonIso(izone_poubelle,iiso)
              fxt(ixt_ddft,il,i)=fxt(ixt_ddft,il,i)+fxtYe(iiso)
              fxt(ixt_poubelle,il,i)=fxt(ixt_poubelle,il,i) &
@@ -5033,10 +5032,10 @@
      &              -mp(il,i)*(xtp(iiso,il,i)-xt(iiso,il,i-1)))
 
-                ixt_ddft=index_trac(izone_ddft,iiso) 
+                ixt_ddft=itZonIso(izone_ddft,iiso) 
                 fxtYe(iiso)=0.01*grav*dpinv*mp(il,i) &
      &           *(xt(ixt_ddft,il,i-1)-xt(ixt_ddft,il,i))
                 fxt(ixt_ddft,il,i)=fxt(ixt_ddft,il,i)+fxtYe(iiso)  
 
-               ixt_revap=index_trac(izone_revap,iiso)  
+               ixt_revap=itZonIso(izone_revap,iiso)  
                fxt_revap(iiso)=0.01*grav*dpinv*(mp(il,i+1)* &
      &                  (xtp(ixt_revap,il,i+1)-xt(ixt_revap,il,i)) &
@@ -5049,12 +5048,12 @@
      &                   -xt(ixt_ddft,il,i)-xt(ixt_revap,il,i)
                 if (Xe(iiso).gt.ridicule) then
-                  do izone=1,ntraceurs_zone
+                  do izone=1,nzone
                    if ((izone.ne.izone_revap).and. &
      &                   (izone.ne.izone_ddft)) then
-                    ixt=index_trac(izone,iiso) 
+                    ixt=itZonIso(izone,iiso) 
                     fxt(ixt,il,i)=fxt(ixt,il,i) &
      &                   +xt(ixt,il,i)/Xe(iiso)*fxtXe(iiso)
                    endif !if ((izone.ne.izone_revap).and.
-                  enddo !do izone=1,ntraceurs_zone   
+                  enddo !do izone=1,nzone   
 #ifdef ISOVERIF
 !                write(*,*) 'iiso=',iiso
@@ -5078,8 +5077,8 @@
                 endif
 #endif                   
-                do izone=1,ntraceurs_zone
+                do izone=1,nzone
                    if ((izone.ne.izone_revap).and. &
      &                   (izone.ne.izone_ddft)) then                    
-                    ixt=index_trac(izone,iiso) 
+                    ixt=itZonIso(izone,iiso) 
                     if (izone.eq.izone_poubelle) then
                       fxt(ixt,il,i)=fxt(ixt,il,i)+fxtXe(iiso)
@@ -5088,5 +5087,5 @@
                     endif !if (izone.eq.izone_poubelle) then
                    endif !if ((izone.ne.izone_revap).and.
-                enddo !do izone=1,ntraceurs_zone
+                enddo !do izone=1,nzone
 #ifdef ISOVERIF
                   call iso_verif_traceur_justmass(fxt(1,il,i), &
@@ -5237,6 +5236,6 @@
         enddo !do ixt = 1+niso,ntraciso
 !        write(*,*) 'tmp cv3_yield 4165: i,il=',i,il
-!        ixt_poubelle=index_trac(izone_poubelle,iso_eau)
-!        ixt_ddft=index_trac(izone_ddft,iso_eau)
+!        ixt_poubelle=itZonIso(izone_poubelle,iso_eau)
+!        ixt_ddft=itZonIso(izone_ddft,iso_eau)
 !        write(*,*) 'delt*fxt(ixt_poubelle,il,i)=',
 !     :           delt*fxt(ixt_poubelle,il,i)
@@ -5244,6 +5243,6 @@
 !        write(*,*) 'xt(iso_eau,il,i)=',xt(iso_eau,il,i)
           do iiso = 1, niso
-             ixt_poubelle=index_trac(izone_poubelle,iiso)
-             ixt_ddft=index_trac(izone_ddft,iiso)  
+             ixt_poubelle=itZonIso(izone_poubelle,iiso)
+             ixt_ddft=itZonIso(izone_ddft,iiso)  
              if (mp(il,i).gt.mp(il,i+1)) then
                 fxtYe(iiso)=0.01*grav*dpinv*mp(il,i) &
@@ -6111,5 +6110,5 @@
 
 #ifdef ISO
-    use infotrac_phy, ONLY: ntraciso
+    use infotrac_phy, ONLY: ntraciso=>ntiso
 #ifdef ISOVERIF
     use isotopes_verif_mod, ONLY: Tmin_verif,iso_verif_aberrant, &
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/cv3_enthalpmix.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/cv3_enthalpmix.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/cv3_enthalpmix.F90	(revision 4446)
@@ -7,5 +7,5 @@
                        )
 #ifdef ISO
-    use infotrac_phy, ONLY: ntraciso
+    use infotrac_phy, ONLY: ntiso
 #endif
   ! **************************************************************
@@ -43,5 +43,5 @@
   REAL, DIMENSION (len,nd+1), INTENT (IN)   :: ph
 #ifdef ISO
-  REAL, DIMENSION (ntraciso,len,nd), INTENT (IN)     :: xt
+  REAL, DIMENSION (ntiso,len,nd), INTENT (IN)     :: xt
 #endif
 !input/output:
@@ -54,5 +54,5 @@
   REAL, DIMENSION (len,nd), INTENT (OUT)    :: wi
 #ifdef ISO
-  REAL, DIMENSION (ntraciso,len), INTENT (OUT)     :: xtmix
+  REAL, DIMENSION (ntiso,len), INTENT (OUT)     :: xtmix
 #endif
 !internal variables :
@@ -153,5 +153,5 @@
         vmix(i) = vmix(i) + v(i, j)*wi(i, j)
 #ifdef ISO
-        do ixt=1,ntraciso
+        do ixt=1,ntiso
           xtmix(ixt,i) = xtmix(ixt,i) +  xt(ixt,i, j)*wi(i, j)
         enddo
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/cv3_estatmix.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/cv3_estatmix.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/cv3_estatmix.F90	(revision 4446)
@@ -7,5 +7,5 @@
                        )
 #ifdef ISO
-    use infotrac_phy, ONLY: ntraciso
+    use infotrac_phy, ONLY: ntiso
 #endif
   ! **************************************************************
@@ -46,5 +46,5 @@
   REAL, DIMENSION (len,nd+1), INTENT (IN)   :: ph
 #ifdef ISO
-  REAL, DIMENSION (ntraciso,len,nd), INTENT (IN)     :: xt
+  REAL, DIMENSION (ntiso,len,nd), INTENT (IN)     :: xt
 #endif
 !input/output:
@@ -57,5 +57,5 @@
   REAL, DIMENSION (len,nd), INTENT (OUT)    :: wi
 #ifdef ISO
-  REAL, DIMENSION (ntraciso,len), INTENT (OUT)     :: xtmix
+  REAL, DIMENSION (ntiso,len), INTENT (OUT)     :: xtmix
 #endif
 !internal variables :
@@ -153,5 +153,5 @@
         vmix(i) = vmix(i) +  v(i, j)*wi(i, j)
 #ifdef ISO
-        do ixt=1,ntraciso
+        do ixt=1,ntiso
           xtmix(ixt,i) = xtmix(ixt,i) +  xt(ixt,i, j)*wi(i, j)
         enddo
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/cv3_routines.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/cv3_routines.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/cv3_routines.F90	(revision 4446)
@@ -314,5 +314,5 @@
      &   )
 #ifdef ISO
-    use infotrac_phy, ONLY: ntraciso
+    use infotrac_phy, ONLY: ntraciso=>ntiso
 #ifdef ISOVERIF
     use isotopes_verif_mod, ONLY: iso_verif_positif,iso_verif_noNaN,iso_verif_egalite
@@ -685,5 +685,5 @@
      &                   )
 #ifdef ISO
-USE infotrac_phy, ONLY: ntraciso
+USE infotrac_phy, ONLY: ntraciso=>ntiso
 USE isotopes_mod, ONLY: pxtmelt,pxtice,pxtmin,pxtmax,cond_temp_env, &
         iso_eau,iso_HDO,ridicule
@@ -1274,5 +1274,5 @@
   USE print_control_mod, ONLY: lunout
 #ifdef ISO
-    use infotrac_phy, ONLY: ntraciso
+    use infotrac_phy, ONLY: ntraciso=>ntiso
     use isotopes_mod, ONLY: essai_convergence, iso_eau,iso_HDO
 #ifdef ISOVERIF
@@ -1474,5 +1474,5 @@
   USE print_control_mod, ONLY: prt_level
 #ifdef ISO
-use infotrac_phy, ONLY: ntraciso
+use infotrac_phy, ONLY: ntraciso=>ntiso
 USE isotopes_mod, ONLY: pxtmelt,pxtice,pxtmin,pxtmax,cond_temp_env, &
         iso_eau,iso_HDO
@@ -2777,5 +2777,5 @@
 
 #ifdef ISO
-use infotrac_phy, ONLY: ntraciso,niso,index_trac
+use infotrac_phy, ONLY: ntraciso=>ntiso,niso,itZonIso
 USE isotopes_mod, ONLY: pxtmelt,pxtice,pxtmin,pxtmax, iso_eau,iso_HDO, &
         ridicule
@@ -3580,5 +3580,5 @@
         call iso_verif_traceur(xtclw(1,il,im), &
      &          'condiso_liq_ice_vectiso_trac 358')
-        if (iso_verif_positif_nostop(xtclw(index_trac( &
+        if (iso_verif_positif_nostop(xtclw(itZonIso( &
      &           izone_cond,iso_eau),i,k)-xtclw(iso_eau,i,k) &
      &           ,'cv3_routines 909').eq.1) then
@@ -3588,5 +3588,5 @@
      &             niso,ntraciso,index_zone,izone_cond      
                stop
-         endif !if (iso_verif_positif_nostop(xtclw(index_trac(
+         endif !if (iso_verif_positif_nostop(xtclw(itZonIso(
 #endif             
          enddo !do il = 1, ncum   
@@ -3615,5 +3615,5 @@
   USE print_control_mod, ONLY: prt_level, lunout
 #ifdef ISO
-    use infotrac_phy, ONLY: ntraciso
+    use infotrac_phy, ONLY: ntraciso=>ntiso
     use isotopes_mod, ONLY: essai_convergence, iso_eau,iso_HDO, &
         ridicule
@@ -3628,5 +3628,5 @@
 #ifdef ISOTRAC
     use isotrac_mod, only: option_cond,izone_cond
-    use infotrac_phy, ONLY: index_trac
+    use infotrac_phy, ONLY: itZonIso
 #ifdef ISOVERIF
     use isotopes_verif_mod, ONLY: iso_verif_traceur_justmass, &
@@ -3993,5 +3993,5 @@
           ! on verifie que tout le detrainement est tagge condensat
           if (iso_verif_positif_nostop( &
-     &          xtwdtrain(index_trac(izone_cond,iso_eau),il) &
+     &          xtwdtrain(itZonIso(izone_cond,iso_eau),il) &
      &          -xtwdtrain(iso_eau,il), &
      &          'cv3_routines 2795').eq.1) then
@@ -4535,5 +4535,5 @@
 !        if (option_tmin.ge.1) then
 !           call iso_verif_positif(xtwater(
-!     :           index_trac(izone_cond,iso_eau),il,i+1)
+!     :           itZonIso(izone_cond,iso_eau),il,i+1)
 !     :           -xtwater(iso_eau,il,i+1),
 !     :          'cv3_routines 3083')
@@ -4602,5 +4602,5 @@
 !        if (option_tmin.ge.1) then
 !         call iso_verif_positif(xtwater(
-!     :           index_trac(izone_cond,iso_eau),il,i)
+!     :           itZonIso(izone_cond,iso_eau),il,i)
 !     :           -xtwater(iso_eau,il,i),
 !     :          'cv3_routines 3143')
@@ -4741,6 +4741,5 @@
 
 #ifdef ISO
-    use infotrac_phy, ONLY: ntraciso,niso, &
-&       ntraceurs_zone,index_trac
+    use infotrac_phy, ONLY: ntraciso=>ntiso, niso, nzone, itZonIso
     use isotopes_mod, ONLY: essai_convergence,ridicule,iso_eau,iso_HDO,iso_O18
 #ifdef ISOVERIF
@@ -5889,5 +5888,5 @@
           do iiso = 1, niso
              
-             ixt_ddft=index_trac(izone_ddft,iiso)  
+             ixt_ddft=itZonIso(izone_ddft,iiso)  
              if (mp(il,i).gt.mp(il,i+1)) then
                 fxtYe(iiso)=0.01*grav*dpinv*mp(il,i) &
@@ -5902,5 +5901,5 @@
      &              -mp(il,i)*(xtp(iiso,il,i)-xt(iiso,il,i-1))) 
         
-             ixt_poubelle=index_trac(izone_poubelle,iiso)
+             ixt_poubelle=itZonIso(izone_poubelle,iiso)
              fxt(ixt_ddft,il,i)=fxt(ixt_ddft,il,i)+fxtYe(iiso)
              fxt(ixt_poubelle,il,i)=fxt(ixt_poubelle,il,i) &
@@ -5919,10 +5918,10 @@
      &              -mp(il,i)*(xtp(iiso,il,i)-xt(iiso,il,i-1)))
 
-                ixt_ddft=index_trac(izone_ddft,iiso) 
+                ixt_ddft=itZonIso(izone_ddft,iiso) 
                 fxtYe(iiso)=0.01*grav*dpinv*mp(il,i) &
      &           *(xt(ixt_ddft,il,i-1)-xt(ixt_ddft,il,i))
                 fxt(ixt_ddft,il,i)=fxt(ixt_ddft,il,i)+fxtYe(iiso)  
 
-               ixt_revap=index_trac(izone_revap,iiso)  
+               ixt_revap=itZonIso(izone_revap,iiso)  
                fxt_revap(iiso)=0.01*grav*dpinv*(mp(il,i+1)* &
      &                  (xtp(ixt_revap,il,i+1)-xt(ixt_revap,il,i)) &
@@ -5935,12 +5934,12 @@
      &                   -xt(ixt_ddft,il,i)-xt(ixt_revap,il,i)
                 if (Xe(iiso).gt.ridicule) then
-                  do izone=1,ntraceurs_zone
+                  do izone=1,nzone
                    if ((izone.ne.izone_revap).and. &
      &                   (izone.ne.izone_ddft)) then
-                    ixt=index_trac(izone,iiso) 
+                    ixt=itZonIso(izone,iiso) 
                     fxt(ixt,il,i)=fxt(ixt,il,i) &
      &                   +xt(ixt,il,i)/Xe(iiso)*fxtXe(iiso)
                    endif !if ((izone.ne.izone_revap).and.
-                  enddo !do izone=1,ntraceurs_zone   
+                  enddo !do izone=1,nzone   
 #ifdef ISOVERIF
 !                write(*,*) 'iiso=',iiso
@@ -5964,8 +5963,8 @@
                 endif
 #endif                   
-                do izone=1,ntraceurs_zone
+                do izone=1,nzone
                    if ((izone.ne.izone_revap).and. &
      &                   (izone.ne.izone_ddft)) then                    
-                    ixt=index_trac(izone,iiso) 
+                    ixt=itZonIso(izone,iiso) 
                     if (izone.eq.izone_poubelle) then
                       fxt(ixt,il,i)=fxt(ixt,il,i)+fxtXe(iiso)
@@ -5974,5 +5973,5 @@
                     endif !if (izone.eq.izone_poubelle) then
                    endif !if ((izone.ne.izone_revap).and.
-                enddo !do izone=1,ntraceurs_zone
+                enddo !do izone=1,nzone
 #ifdef ISOVERIF
                   call iso_verif_traceur_justmass(fxt(1,il,i), &
@@ -7459,5 +7458,5 @@
      &     )    
 #ifdef ISO
-    use infotrac_phy, ONLY: ntraciso
+    use infotrac_phy, ONLY: ntraciso=>ntiso
 #ifdef ISOVERIF
     use isotopes_verif_mod, ONLY: Tmin_verif,iso_verif_aberrant, &
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/cv3a_compress.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/cv3a_compress.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/cv3a_compress.F90	(revision 4446)
@@ -34,5 +34,5 @@
   ! **************************************************************
 #ifdef ISO
-    use infotrac_phy, ONLY: ntraciso
+    use infotrac_phy, ONLY: ntraciso=>ntiso
     use isotopes_mod, ONLY: essai_convergence, iso_eau,iso_HDO
 #ifdef ISOVERIF
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/cv3a_uncompress.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/cv3a_uncompress.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/cv3a_uncompress.F90	(revision 4446)
@@ -54,5 +54,5 @@
 
 #ifdef ISO
-  USE infotrac_phy, ONLY : ntraciso
+  USE infotrac_phy, ONLY : ntraciso=>ntiso
 #endif
   IMPLICIT NONE
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/cv3p_mixing.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/cv3p_mixing.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/cv3p_mixing.F90	(revision 4446)
@@ -21,5 +21,5 @@
   USE add_phys_tend_mod, ONLY: fl_cor_ebil
 #ifdef ISO
-  USE infotrac_phy, ONLY: ntraciso
+  USE infotrac_phy, ONLY: ntraciso=>ntiso
   USE isotopes_mod, ONLY: pxtmelt,pxtice
   USE isotopes_routines_mod, ONLY: condiso_liq_ice_vectall
@@ -1301,5 +1301,5 @@
             call iso_verif_egalite_choix(xtent(iso_eau,il,im,jm), &
               qent(il,im,jm),'cv3p_mixing 2112',errmax,errmaxrel)
-          endif !if (use_iso_eau) then
+          endif !if (iso_eau>0) then
 #ifdef ISOTRAC
         call iso_verif_traceur_justmass(xtelij(1,il,im,jm), &   
@@ -1353,5 +1353,5 @@
 !        call iso_verif_traceur(xtclw(1,il,im), &
 !               'cv3p_mixing 358')
-!        if (iso_verif_positif_nostop(xtclw(index_trac( &
+!        if (iso_verif_positif_nostop(xtclw(itZonIso( &
 !                izone_cond,iso_eau),i,k)-xtclw(iso_eau,i,k) &
 !                ,'cv3p_mixing 909').eq.1) then
@@ -1361,5 +1361,5 @@
 !                  niso,ntraciso,index_zone,izone_cond      
 !               stop
-!         endif !if (iso_verif_positif_nostop(xtclw(index_trac(
+!         endif !if (iso_verif_positif_nostop(xtclw(itZonIso(
 !#endif             
 !         enddo !do il = 1, ncum   
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/cv_driver.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/cv_driver.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/cv_driver.F90	(revision 4446)
@@ -25,5 +25,5 @@
   USE dimphy
 #ifdef ISO
-  USE infotrac_phy, ONLY: ntraciso,niso,index_trac,ntraceurs_zone
+  USE infotrac_phy, ONLY: ntraciso=>ntiso,niso,itZonIso,nzone
   USE isotopes_mod, ONLY: iso_eau,iso_HDO,ridicule,bidouille_anti_divergence
 #ifdef ISOVERIF
@@ -511,5 +511,5 @@
     CALL cv_param(nd)
 #ifdef ISO
-       write(*,*) 'cv_driver 454: isos pas prévus ici'
+       write(*,*) 'cv_driver 454: isos pas prevus ici'
        stop
 #endif
@@ -687,5 +687,5 @@
 !c--debug
 #ifdef ISOVERIF
-       write(*,*) 'cv_driver 621: après cv3_undilute1'
+       write(*,*) 'cv_driver 621: apres cv3_undilute1'
        do k = 1, klev
         do i = 1, klon
@@ -752,5 +752,4 @@
         !write(*,*) 'xt1(iso_eau,1,1),q1(1,1)=',xt1(iso_eau,1,1),q1(1,1)
         !write(*,*) 'xt1(iso_eau,14,1),q1(14,1)=',xt1(iso_eau,14,1),q1(14,1) 
-        !write(*,*) 'iso_eau,use_iso=',iso_eau,use_iso
        do k = 1, klev
         do i = 1, nloc
@@ -783,5 +782,5 @@
 #ifdef ISO
 #ifdef ISOVERIF
-       write(*,*) 'cv_driver 720: après cv3_compress'           
+       write(*,*) 'cv_driver 720: apres cv3_compress'           
        do k = 1, klev
         do i = 1, ncum
@@ -883,5 +882,5 @@
                 ,cape,ep,hp,icb,inb,clw,nk,t,h,lv &
                 ,epmax_diag)
-        ! on Ã©crase ep et recalcule hp
+        ! on écrase ep et recalcule hp
     END IF
 
@@ -910,5 +909,5 @@
 #ifdef ISO
 #ifdef ISOVERIF
-       write(*,*) 'cv_driver 837: après cv3_mixing'
+       write(*,*) 'cv_driver 837: apres cv3_mixing'
        do k = 1, klev
        do j = 1, klev
@@ -925,6 +924,6 @@
            call iso_verif_traceur_justmass(xtelij(1,i,j,k), &
      &           'cv_driver 847')
-           ! on ne vérfier pas le deltaD ici car peut dépasser le seuil
-           ! raisonable pour températures très froides.
+           ! on ne verifie pas le deltaD ici car peut depasser le seuil
+           ! raisonable pour temperatures tres froides.
 #endif               
         enddo
@@ -940,5 +939,5 @@
            call iso_verif_traceur(xt(1,i,k),'cv_driver 856')
            if (option_tmin.eq.1) then
-             if (iso_verif_positif_nostop(xtclw(index_trac( &
+             if (iso_verif_positif_nostop(xtclw(itZonIso( &
      &           izone_cond,iso_eau),i,k)-xtclw(iso_eau,i,k) &
      &           ,'cv_driver 909').eq.1) then
@@ -946,5 +945,5 @@
                write(*,*) 'xtclw=',xtclw(:,i,k)
                stop
-             endif !if (iso_verif_positif_nostop(xtclw(index_trac(
+             endif !if (iso_verif_positif_nostop(xtclw(itZonIso(
            endif !if ((option_traceurs.eq.17).or.
 #endif  
@@ -1000,5 +999,5 @@
        write(*,*) 'klev=',klev
 #ifdef ISOVERIF
-       write(*,*) 'cv_driver 930: après cv3_unsat'
+       write(*,*) 'cv_driver 930: apres cv3_unsat'
        do k = 1, klev
         do i = 1, ncum
@@ -1048,6 +1047,6 @@
             do i = 1, ncum
                do iiso=1,niso
-                  ixt_ddft=index_trac(izone_ddft,iiso)
-                  ixt_poubelle=index_trac(izone_poubelle,iiso)
+                  ixt_ddft=itZonIso(izone_ddft,iiso)
+                  ixt_poubelle=itZonIso(izone_poubelle,iiso)
                   xtp(ixt_ddft,i,k)=xtp(ixt_ddft,i,k) &
      &                    +xtp(ixt_poubelle,i,k)
@@ -1063,20 +1062,20 @@
           do k = 1, klev
             do i = 1, ncum
-               do izone=1,ntraceurs_zone
+               do izone=1,nzone
                  if (izone.eq.izone_ddft) then
                    do iiso=1,niso
-                     ixt_ddft=index_trac(izone,iiso)
-                     ixt_revap=index_trac(izone_revap,iiso)
+                     ixt_ddft=itZonIso(izone,iiso)
+                     ixt_revap=itZonIso(izone_revap,iiso)
                      xtp(ixt_ddft,i,k)=xtp(iiso,i,k)-xtp(ixt_revap,i,k)
                    enddo !do iiso=1,niso
                  elseif (izone.eq.izone_ddft) then
-                    ! rien à faire
+                    ! rien a faire
                  else !if (izone.eq.izone_ddft) then
                    do iiso=1,niso
-                     ixt=index_trac(izone,iiso)
+                     ixt=itZonIso(izone,iiso)
                      xtp(ixt,i,k)=0.0
                    enddo !do iiso=1,niso
                  endif !if (izone.eq.izone_ddft) then
-               enddo !do izone=1,ntraceurs_zone
+               enddo !do izone=1,nzone
 #ifdef ISOVERIF
                call iso_verif_traceur(xtp(1,i,k),'cv_driver 1059')
@@ -1247,6 +1246,6 @@
 ! si icvflag_Tpa=0, alors la fraction de glace dans l'ascendance adiabatique est
   ! fonction de la temperature de l'environnement et la temperature de l'ascendance est 
-  ! calculee en deux itérations, une en supposant qu'il n'y a pas de glace et l'autre 
-  ! en ajoutant la glace (ancien schéma d'Arnaud Jam).
+  ! calculee en deux iterations, une en supposant qu'il n'y a pas de glace et l'autre 
+  ! en ajoutant la glace (ancien schema d'Arnaud Jam).
 ! si icvflag_Tpa=1, alors la fraction de glace dans l'ascendance adiabatique est
   ! fonction de la temperature de l'environnement et la temperature de l'ascendance est 
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/cva_driver.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/cva_driver.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/cva_driver.F90	(revision 4446)
@@ -54,5 +54,5 @@
   USE add_phys_tend_mod, ONLY: fl_cor_ebil
 #ifdef ISO
-  USE infotrac_phy, ONLY: ntraciso,niso,niso,index_trac,ntraceurs_zone
+  USE infotrac_phy, ONLY: ntraciso=>ntiso,niso,niso,itZonIso,nzone
   USE isotopes_mod, ONLY: iso_eau,iso_HDO,iso_O18,ridicule,bidouille_anti_divergence
 #ifdef ISOVERIF
@@ -1388,5 +1388,5 @@
            call iso_verif_traceur(xt(1,i,k),'cva_driver 856')
            if (option_tmin.eq.1) then
-             if (iso_verif_positif_nostop(xtclw(index_trac( &
+             if (iso_verif_positif_nostop(xtclw(itZonIso( &
      &           izone_cond,iso_eau),i,k)-xtclw(iso_eau,i,k) &
      &           ,'cva_driver 909').eq.1) then
@@ -1394,5 +1394,5 @@
                write(*,*) 'xtclw=',xtclw(:,i,k)
                stop
-             endif !if (iso_verif_positif_nostop(xtclw(index_trac(
+             endif !if (iso_verif_positif_nostop(xtclw(itZonIso(
            endif !if ((option_traceurs.eq.17).or.
 #endif  
@@ -1509,6 +1509,6 @@
             do i = 1, ncum
                do iiso=1,niso
-                  ixt_ddft=index_trac(izone_ddft,iiso)
-                  ixt_poubelle=index_trac(izone_poubelle,iiso)
+                  ixt_ddft=itZonIso(izone_ddft,iiso)
+                  ixt_poubelle=itZonIso(izone_poubelle,iiso)
                   xtp(ixt_ddft,i,k)=xtp(ixt_ddft,i,k) &
      &                    +xtp(ixt_poubelle,i,k)
@@ -1524,9 +1524,9 @@
           do k=1,nd
             do i = 1, ncum
-               do izone=1,ntraceurs_zone
+               do izone=1,nzone
                  if (izone.eq.izone_ddft) then
                    do iiso=1,niso
-                     ixt_ddft=index_trac(izone,iiso)
-                     ixt_revap=index_trac(izone_revap,iiso)
+                     ixt_ddft=itZonIso(izone,iiso)
+                     ixt_revap=itZonIso(izone_revap,iiso)
                      xtp(ixt_ddft,i,k)=xtp(iiso,i,k)-xtp(ixt_revap,i,k)
                    enddo !do iiso=1,niso
@@ -1535,9 +1535,9 @@
                  else !if (izone.eq.izone_ddft) then
                    do iiso=1,niso
-                     ixt=index_trac(izone,iiso)
+                     ixt=itZonIso(izone,iiso)
                      xtp(ixt,i,k)=0.0
                    enddo !do iiso=1,niso
                  endif !if (izone.eq.izone_ddft) then
-               enddo !do izone=1,ntraceurs_zone
+               enddo !do izone=1,nzone
 #ifdef ISOVERIF
                call iso_verif_traceur(xtp(1,i,k),'cva_driver 1059')
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/fisrtilp.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/fisrtilp.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/fisrtilp.F90	(revision 4446)
@@ -27,5 +27,5 @@
   USE add_phys_tend_mod, only : fl_cor_ebil 
 #ifdef ISO
-  USE infotrac_phy, ONLY: ntraciso,niso,index_trac,ntraceurs_zone
+  USE infotrac_phy, ONLY: ntraciso=>ntiso,niso,itZonIso
   USE isotopes_mod
 !, ONLY: essai_convergence,bidouille_anti_divergence, &
@@ -143,7 +143,7 @@
   ! Coeffients de fraction lessivee : pour OFF-LINE
   !
-  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: pfrac_nucl
-  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: pfrac_1nucl
-  REAL, DIMENSION(klon,klev),      INTENT(OUT)  :: pfrac_impa
+  REAL, DIMENSION(klon,klev),      INTENT(INOUT)  :: pfrac_nucl
+  REAL, DIMENSION(klon,klev),      INTENT(INOUT)  :: pfrac_1nucl
+  REAL, DIMENSION(klon,klev),      INTENT(INOUT)  :: pfrac_impa
   !
   ! Fraction d'aerosols lessivee par impaction et par nucleation
@@ -1510,5 +1510,5 @@
                    zxtn(iso_eau,i)=zqn(i)
 #ifdef ISOTRAC
-                   zxtn(index_trac(izone_poubelle,iso_eau),i)=zqn(i)  
+                   zxtn(itZonIso(izone_poubelle,iso_eau),i)=zqn(i)  
                    if (option_tmin.eq.1) then                   
                      zxtcs(iso_eau,i)=zqcs(i)
@@ -1848,6 +1848,6 @@
            ! part le tag résuel et le condensat
            if (iso_verif_positif_choix_nostop( &
-     &           zxt_ancien(index_trac(izone,iso_eau),i) &
-     &          -zxt(index_trac(izone,iso_eau),i),1e-8,'ilp 1270') &
+     &           zxt_ancien(itZonIso(izone,iso_eau),i) &
+     &          -zxt(itZonIso(izone,iso_eau),i),1e-8,'ilp 1270') &
      &          .eq.1) then
             write(*,*) 'i,izone,rneb=',i,izone,rneb(i,k)
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/fonte_neige_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/fonte_neige_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/fonte_neige_mod.F90	(revision 4446)
@@ -629,5 +629,5 @@
         ! de dépendance circulaire.
 
-    USE infotrac_phy, ONLY: ntraciso,niso
+    USE infotrac_phy, ONLY: ntiso,niso
     USE isotopes_mod, ONLY: iso_eau    
   USE indice_sol_mod    
@@ -639,5 +639,5 @@
          ! inputs
         integer klon,knon
-        real xtprecip_snow(ntraciso,klon),xtprecip_rain(ntraciso,klon)
+        real xtprecip_snow(ntiso,klon),xtprecip_rain(ntiso,klon)
     INTEGER, INTENT(IN)                  :: nisurf
     INTEGER, DIMENSION(klon), INTENT(IN) :: knindex
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/isotopes_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/isotopes_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/isotopes_mod.F90	(revision 4446)
@@ -3,686 +3,404 @@
 
 MODULE isotopes_mod
-USE infotrac_phy, ONLY: ntraciso,niso,indnum_fn_num,use_iso, &
-&       niso_possibles
-IMPLICIT NONE
-SAVE
-
-! contient toutes les variables isotopiques et leur initialisation
-! les routines specifiquement isotopiques sont dans
-! isotopes_routines_mod pour éviter dépendance circulaire avec
-! isotopes_verif_mod.
-
-
-! indices des isotopes
-integer, save :: iso_eau,iso_HDO,iso_O18,iso_O17,iso_HTO ! indices de 1 à niso: les isos n'existant pas sont mis à 0
-!$OMP THREADPRIVATE(iso_eau,iso_HDO,iso_O18,iso_O17,iso_HTO)
-
-integer :: iso_eau_possible,iso_HDO_possible,iso_O18_possible,iso_O17_possible,iso_HTO_possible ! indices de 1 à niso_possibles: ils correspondent aux tableaux définis dans infotrac:
-! tnom_iso=(/'eau','HDO','O18','O17','HTO'/)
-! ce sont ces indices qui doivent être utilisés avec use_iso, puisque use_iso est défini comme DIMENSION(niso_possibles)
-parameter (iso_eau_possible=1)
-parameter (iso_HDO_possible=2)
-parameter (iso_O18_possible=3)
-parameter (iso_O17_possible=4)
-parameter (iso_HTO_possible=5)
-
-integer, save :: ntracisoOR
+   USE strings_mod,  ONLY: msg, real2str, int2str, bool2str, maxlen, strIdx, strStack
+   USE infotrac_phy, ONLY: isoName
+   IMPLICIT NONE
+   INTERFACE get_in; MODULE PROCEDURE getinp_s, getinp_i, getinp_r, getinp_l;  END INTERFACE get_in
+   SAVE
+
+  !--- Contains all isotopic variables + their initialization
+  !--- Isotopes-specific routines are in isotopes_routines_mod to avoid circular dependencies with isotopes_verif_mod.
+
+   !--- Isotopes indices (in [1,niso] ; non-existing => 0 index)
+   INTEGER, SAVE :: iso_eau, iso_HDO, iso_O18, iso_O17, iso_HTO
+!$OMP THREADPRIVATE(iso_eau, iso_HDO, iso_O18, iso_O17, iso_HTO)
+
+   INTEGER, SAVE :: ntracisoOR
 !$OMP THREADPRIVATE(ntracisoOR)
 
-! variables indépendantes des isotopes
-
-real, save :: pxtmelt,pxtice,pxtmin,pxtmax
-!$OMP THREADPRIVATE(pxtmelt,pxtice,pxtmin,pxtmax)
-real, save ::  tdifexp, tv0cin, thumxt1
+   !--- Variables not depending on isotopes
+   REAL,    SAVE :: pxtmelt, pxtice, pxtmin, pxtmax
+!$OMP THREADPRIVATE(pxtmelt, pxtice, pxtmin, pxtmax)
+   REAL,    SAVE :: tdifexp, tv0cin, thumxt1
 !$OMP THREADPRIVATE(tdifexp, tv0cin, thumxt1)
-integer, save ::  ntot 
+   INTEGER, SAVE :: ntot 
 !$OMP THREADPRIVATE(ntot)
-real, save ::  h_land_ice
+   REAL,    SAVE :: h_land_ice
 !$OMP THREADPRIVATE(h_land_ice)
-real, save ::  P_veg
+   REAL,    SAVE :: P_veg
 !$OMP THREADPRIVATE(P_veg)
-real, save ::  musi,lambda_sursat
-!$OMP THREADPRIVATE(lambda_sursat)
-real, save ::  Kd
+   REAL,    SAVE :: musi, lambda_sursat
+!$OMP THREADPRIVATE(musi, lambda_sursat)
+   REAL,    SAVE :: Kd
 !$OMP THREADPRIVATE(Kd)
-real, save ::  rh_cste_surf_cond,T_cste_surf_cond
-!$OMP THREADPRIVATE(rh_cste_surf_cond,T_cste_surf_cond)
-
-logical, save ::   bidouille_anti_divergence
-                ! si true, rappel régulier de xteau vers q, pour éviter dérives lentes
+   REAL,    SAVE :: rh_cste_surf_cond, T_cste_surf_cond
+!$OMP THREADPRIVATE(rh_cste_surf_cond, T_cste_surf_cond)
+   LOGICAL, SAVE :: bidouille_anti_divergence    ! T: regularly, xteau <- q to avoid slow drifts
 !$OMP THREADPRIVATE(bidouille_anti_divergence)
-logical, save ::   essai_convergence 
-                ! si false, on fait rigoureusement comme dans LMDZ sans isotopes, 
-                ! meme si c'est génant pour les isotopes
+   LOGICAL, SAVE :: essai_convergence            ! F: as in LMDZ without isotopes (bad for isotopes)
 !$OMP THREADPRIVATE(essai_convergence)
-integer, save ::   initialisation_iso
-                ! 0: dans fichier
-                ! 1: R=0
-                ! 2: R selon distill rayleigh
-                ! 3: R=Rsmow
+   INTEGER, SAVE :: initialisation_iso           ! 0: file ; 1: R=0 ; 2: R=distill. Rayleigh ; 3: R=Rsmow
 !$OMP THREADPRIVATE(initialisation_iso)
-integer, save ::  modif_SST ! 0 par defaut, 1 si on veut modifier la sst
-                ! 2 et 3: profils de SST
+   INTEGER, SAVE :: modif_SST                    ! 0: default ; 1: modified SST ; 2, 3: SST profiles
 !$OMP THREADPRIVATE(modif_SST)
-real, save ::  deltaTtest ! modif de la SST, uniforme.
+   REAL,    SAVE :: deltaTtest                   ! Uniform modification of the SST
 !$OMP THREADPRIVATE(deltaTtest)
-integer, save ::  modif_sic ! on met des trous dans glace de mer
+   INTEGER, SAVE :: modif_sic                    ! Holes in the Sea Ice
 !$OMP THREADPRIVATE(modif_sic)
-real, save ::  deltasic ! fraction de trous minimale
+   REAL,    SAVE :: deltasic                     ! Minimal holes fraction
 !$OMP THREADPRIVATE(deltasic)
-real, save ::  deltaTtestpoles
+   REAL,    SAVE :: deltaTtestpoles
 !$OMP THREADPRIVATE(deltaTtestpoles)
-real, save ::  sstlatcrit
-!$OMP THREADPRIVATE(sstlatcrit)
-real, save ::  dsstlatcrit
-!$OMP THREADPRIVATE(dsstlatcrit)
-real, save ::  deltaO18_oce
+   REAL,    SAVE :: sstlatcrit, dsstlatcrit
+!$OMP THREADPRIVATE(sstlatcrit, dsstlatcrit)
+   REAL,    SAVE :: deltaO18_oce
 !$OMP THREADPRIVATE(deltaO18_oce)
-integer, save ::  albedo_prescrit ! 0 par defaut
-                        ! 1 si on veut garder albedo constant
+   INTEGER, SAVE :: albedo_prescrit              ! 0: default ; 1: constant albedo
 !$OMP THREADPRIVATE(albedo_prescrit)
-real, save ::  lon_min_albedo,lon_max_albedo
-!$OMP THREADPRIVATE(lon_min_albedo,lon_max_albedo)
-real, save :: lat_min_albedo,lat_max_albedo
-!$OMP THREADPRIVATE(lat_min_albedo,lat_max_albedo)
-real, save ::  deltaP_BL,tdifexp_sol
+   REAL,    SAVE :: lon_min_albedo, lon_max_albedo, lat_min_albedo, lat_max_albedo
+!$OMP THREADPRIVATE(lon_min_albedo, lon_max_albedo, lat_min_albedo, lat_max_albedo)
+   REAL,    SAVE :: deltaP_BL,tdifexp_sol
 !$OMP THREADPRIVATE(deltaP_BL,tdifexp_sol)
-integer, save ::  ruissellement_pluie,alphak_stewart
-!$OMP THREADPRIVATE(ruissellement_pluie,alphak_stewart)
-integer, save ::  calendrier_guide
+   INTEGER, SAVE :: ruissellement_pluie, alphak_stewart
+!$OMP THREADPRIVATE(ruissellement_pluie, alphak_stewart)
+   INTEGER, SAVE :: calendrier_guide
 !$OMP THREADPRIVATE(calendrier_guide)
-integer, save ::  cste_surf_cond
+   INTEGER, SAVE :: cste_surf_cond
 !$OMP THREADPRIVATE(cste_surf_cond)
-real, save ::  mixlen
+   REAL,    SAVE :: mixlen
 !$OMP THREADPRIVATE(mixlen)
-integer, save ::  evap_cont_cste
+   INTEGER, SAVE :: evap_cont_cste
 !$OMP THREADPRIVATE(evap_cont_cste)
-real, save ::  deltaO18_evap_cont,d_evap_cont
-!$OMP THREADPRIVATE(deltaO18_evap_cont,d_evap_cont)
-integer, save ::  nudge_qsol,region_nudge_qsol
-!$OMP THREADPRIVATE(nudge_qsol,region_nudge_qsol)
-integer, save :: nlevmaxO17
+   REAL,    SAVE :: deltaO18_evap_cont, d_evap_cont
+!$OMP THREADPRIVATE(deltaO18_evap_cont, d_evap_cont)
+   INTEGER, SAVE :: nudge_qsol, region_nudge_qsol
+!$OMP THREADPRIVATE(nudge_qsol, region_nudge_qsol)
+   INTEGER, SAVE :: nlevmaxO17
 !$OMP THREADPRIVATE(nlevmaxO17)
-integer, save ::  no_pce
-!	real, save :: slope_limiterxy,slope_limiterz
+   INTEGER, SAVE :: no_pce
 !$OMP THREADPRIVATE(no_pce)
-real, save ::  A_satlim
+   REAL,    SAVE :: A_satlim
 !$OMP THREADPRIVATE(A_satlim)
-integer, save ::  ok_restrict_A_satlim,modif_ratqs
-!$OMP THREADPRIVATE(ok_restrict_A_satlim,modif_ratqs)
-real, save ::  Pcrit_ratqs,ratqsbasnew
-!$OMP THREADPRIVATE(Pcrit_ratqs,ratqsbasnew)
-real, save ::  fac_modif_evaoce
+   INTEGER, SAVE :: ok_restrict_A_satlim, modif_ratqs
+!$OMP THREADPRIVATE(ok_restrict_A_satlim, modif_ratqs)
+   REAL,    SAVE :: Pcrit_ratqs, ratqsbasnew
+!$OMP THREADPRIVATE(Pcrit_ratqs, ratqsbasnew)
+   REAL,    SAVE :: fac_modif_evaoce
 !$OMP THREADPRIVATE(fac_modif_evaoce)
-integer, save ::  ok_bidouille_wake
+   INTEGER, SAVE :: ok_bidouille_wake
 !$OMP THREADPRIVATE(ok_bidouille_wake)
-logical ::  cond_temp_env
+   LOGICAL, SAVE :: cond_temp_env
 !$OMP THREADPRIVATE(cond_temp_env)
 
-
-! variables tableaux fn de niso
-real, ALLOCATABLE, DIMENSION(:), save :: tnat, toce, tcorr
-!$OMP THREADPRIVATE(tnat, toce, tcorr)
-real, ALLOCATABLE, DIMENSION(:), save :: tdifrel
-!$OMP THREADPRIVATE(tdifrel)
-real, ALLOCATABLE, DIMENSION(:), save :: talph1, talph2, talph3
-!$OMP THREADPRIVATE(talph1, talph2, talph3)
-real, ALLOCATABLE, DIMENSION(:), save :: talps1, talps2
-!$OMP THREADPRIVATE(talps1, talps2)
-real, ALLOCATABLE, DIMENSION(:), save :: tkcin0, tkcin1, tkcin2
+   !--- Vectors of length "niso"
+   REAL, ALLOCATABLE, DIMENSION(:), SAVE :: &
+                    tnat, toce, tcorr, tdifrel
+!$OMP THREADPRIVATE(tnat, toce, tcorr, tdifrel)
+   REAL, ALLOCATABLE, DIMENSION(:), SAVE :: &
+                    talph1, talph2, talph3, talps1, talps2
+!$OMP THREADPRIVATE(talph1, talph2, talph3, talps1, talps2)
+   REAL, ALLOCATABLE, DIMENSION(:), SAVE :: &
+                    tkcin0, tkcin1, tkcin2
 !$OMP THREADPRIVATE(tkcin0, tkcin1, tkcin2)
-real, ALLOCATABLE, DIMENSION(:), save :: alpha_liq_sol
-!$OMP THREADPRIVATE(alpha_liq_sol)
-real, ALLOCATABLE, DIMENSION(:), save :: Rdefault, Rmethox
-!$OMP THREADPRIVATE(Rdefault, Rmethox)
-character*3, ALLOCATABLE, DIMENSION(:), save :: striso
-!$OMP THREADPRIVATE(striso)
-real, save :: fac_coeff_eq17_liq, fac_coeff_eq17_ice
+   REAL, ALLOCATABLE, DIMENSION(:), SAVE :: &
+                    alpha_liq_sol, Rdefault, Rmethox
+!$OMP THREADPRIVATE(alpha_liq_sol, Rdefault, Rmethox)
+   REAL, SAVE ::    fac_coeff_eq17_liq, fac_coeff_eq17_ice
 !$OMP THREADPRIVATE(fac_coeff_eq17_liq, fac_coeff_eq17_ice)
 
-      real ridicule ! valeur maximale pour qu'une variable de type
-                    ! rapoport de mélange puisse être considérée comme négligeable. Si
-                    ! négligeable, alors on ne verifie pas si sa compo iso esta bérrante.
-      parameter (ridicule=1e-12)      
-!      parameter (ridicule=1)
-!
-      real ridicule_rain ! valeur limite de ridicule pour les flux de pluies (rain, zrfl...)
-      parameter (ridicule_rain=1e-8) ! en kg/s <-> 1e-3mm/day
-
-      real ridicule_evap ! valeur limite de ridicule pour les evap
-      parameter (ridicule_evap=ridicule_rain*1e-2) ! en kg/s <-> 1e-3mm/day
-
-      real ridicule_qsol ! valeur limite de ridicule pour les qsol
-      parameter (ridicule_qsol=ridicule_rain) ! en kg <-> 1e-8kg
-
-      real ridicule_snow ! valeur limite de ridicule pour les snow
-      parameter (ridicule_snow=ridicule_qsol) ! en kg/s <-> 1e-8kg
-      
-        real expb_max
-        parameter (expb_max=30.0)
-
-        ! spécifique au tritium:
-        
-
-logical, save :: ok_prod_nucl_tritium ! si oui, production de tritium par essais nucleaires
+   !--- Negligible lower thresholds: no need to check for absurd values under these lower limits
+   REAL, PARAMETER :: &
+      ridicule      = 1e-12,              & ! For mixing ratios
+      ridicule_rain = 1e-8,               & ! For rain fluxes (rain, zrfl...) in kg/s <-> 1e-3 mm/day
+      ridicule_evap = ridicule_rain*1e-2, & ! For evaporations                in kg/s <-> 1e-3 mm/day
+      ridicule_qsol = ridicule_rain,      & ! For qsol                        in kg <-> 1e-8 kg
+      ridicule_snow = ridicule_qsol         ! For snow                        in kg <-> 1e-8 kg
+   REAL, PARAMETER :: expb_max = 30.0
+
+   !--- Specific to HTO:
+   LOGICAL, SAVE :: ok_prod_nucl_tritium    !--- TRUE => HTO production by nuclear tests
 !$OMP THREADPRIVATE(ok_prod_nucl_tritium)
-        integer nessai
-        parameter (nessai=486)
-        integer, save :: day_nucl(nessai)
-!$OMP THREADPRIVATE(day_nucl)
-        integer, save :: month_nucl(nessai)
-!$OMP THREADPRIVATE(month_nucl)
-        integer, save :: year_nucl(nessai)
-!$OMP THREADPRIVATE(year_nucl)
-        real, save :: lat_nucl(nessai)
-!$OMP THREADPRIVATE(lat_nucl)
-        real, save :: lon_nucl(nessai)
-!$OMP THREADPRIVATE(lon_nucl)
-        real, save :: zmin_nucl(nessai)
-!$OMP THREADPRIVATE(zmin_nucl)
-        real, save :: zmax_nucl(nessai)
-!$OMP THREADPRIVATE(zmax_nucl)
-        real, save :: HTO_nucl(nessai)
-!$OMP THREADPRIVATE(HTO_nucl)
-
+   INTEGER, PARAMETER :: nessai = 486
+   INTEGER, DIMENSION(nessai), SAVE :: &
+                    day_nucl, month_nucl, year_nucl
+!$OMP THREADPRIVATE(day_nucl, month_nucl, year_nucl)
+   REAL,    DIMENSION(nessai), SAVE :: &
+                    lat_nucl, lon_nucl, zmin_nucl, zmax_nucl, HTO_nucl
+!$OMP THREADPRIVATE(lat_nucl, lon_nucl, zmin_nucl, zmax_nucl, HTO_nucl)
+ 
  
 CONTAINS
 
-  SUBROUTINE iso_init()
-      use ioipsl_getin_p_mod, ONLY : getin_p
-      implicit none
-
-! -- local variables:
-
-      integer ixt
-      ! référence O18
-      real fac_enrichoce18
-      real alpha_liq_sol_O18, &
-     &     talph1_O18,talph2_O18,talph3_O18, &
-     &     talps1_O18,talps2_O18, &
-     &     tkcin0_O18,tkcin1_O18,tkcin2_O18, &
-     &     tdifrel_O18  
+SUBROUTINE iso_init()
+   USE infotrac_phy,       ONLY: ntiso, niso, getKey
+    USE strings_mod,       ONLY: maxlen
+   IMPLICIT NONE
+
+   !=== Local variables:
+   INTEGER :: ixt
+
+   !--- H2[18]O reference
+   REAL :: fac_enrichoce18, alpha_liq_sol_O18, &
+           talph1_O18, talph2_O18, talph3_O18, talps1_O18, talps2_O18, &
+           tkcin0_O18, tkcin1_O18, tkcin2_O18, tdifrel_O18  
+
+   !--- For H2[17]O
+   REAL    :: fac_kcin, pente_MWL
       
-      ! cas de l'O17
-      real fac_kcin
-      real pente_MWL
-      integer ierr
-      
-      logical ok_nocinsat, ok_nocinsfc !sensi test
-      parameter (ok_nocinsfc=.FALSE.)  ! if T: no kinetic effect in sfc evap
-      parameter (ok_nocinsat=.FALSE.)  ! if T: no sursaturation effect for ice
-      logical Rdefault_smow
-      parameter (Rdefault_smow=.FALSE.) ! si T: Rdefault=smow; si F: nul
-      ! pour le tritium
-      integer iessai
-
-    write(*,*) 'iso_init 219: entree'
-
-! allocations mémoire
-allocate (tnat(niso))
-allocate (toce(niso))
-allocate (tcorr(niso))
-allocate (tdifrel(niso))
-allocate (talph1(niso))
-allocate (talph2(niso))
-allocate (talph3(niso))
-allocate (talps1(niso))
-allocate (talps2(niso))
-allocate (tkcin0(niso))
-allocate (tkcin1(niso))
-allocate (tkcin2(niso))
-allocate (alpha_liq_sol(niso))
-allocate (Rdefault(niso))
-allocate (Rmethox(niso))
-allocate (striso(niso))
-
-
-!--------------------------------------------------------------
-! General:
-!--------------------------------------------------------------
-
-! -- verif du nombre d'isotopes:
-      write(*,*) 'iso_init 64: niso=',niso
-
-! init de ntracisoOR: on écrasera en cas de nzone>0 si complications avec
-! ORCHIDEE
-      ntracisoOR=ntraciso  
-              
-! -- Type of water isotopes:
-
-        iso_eau=indnum_fn_num(1)
-        iso_HDO=indnum_fn_num(2)
-        iso_O18=indnum_fn_num(3)
-        iso_O17=indnum_fn_num(4)
-        iso_HTO=indnum_fn_num(5)
-        write(*,*) 'iso_init 59: iso_eau=',iso_eau
-        write(*,*) 'iso_HDO=',iso_HDO
-        write(*,*) 'iso_O18=',iso_O18
-        write(*,*) 'iso_O17=',iso_O17
-        write(*,*) 'iso_HTO=',iso_HTO
-        write(*,*) 'iso_init 251: use_iso=',use_iso
-
-      ! initialisation
-        lambda_sursat=0.004
-        thumxt1=0.75*1.2
-        ntot=20
-        h_land_ice=20. ! à comparer aux 3000mm de snow_max
-        P_veg=1.0
-        bidouille_anti_divergence=.false.
-        essai_convergence=.false.
-        initialisation_iso=0
-        modif_sst=0
-        modif_sic=0
-        deltaTtest=0.0
-        deltasic=0.1
-        deltaTtestpoles=0.0
-        sstlatcrit=30.0
-        deltaO18_oce=0.0
-        albedo_prescrit=0
-        lon_min_albedo=-200
-        lon_max_albedo=200
-        lat_min_albedo=-100
-        lat_max_albedo=100
-        deltaP_BL=10.0
-        ruissellement_pluie=0
-        alphak_stewart=1
-        tdifexp_sol=0.67
-        calendrier_guide=0
-        cste_surf_cond=0
-mixlen=35.0        
-evap_cont_cste=0.0
-deltaO18_evap_cont=0.0
-d_evap_cont=0.0
-nudge_qsol=0
-region_nudge_qsol=1
-nlevmaxO17=50
-no_pce=0
-A_satlim=1.0
-ok_restrict_A_satlim=0
-!        slope_limiterxy=2.0
-!        slope_limiterz=2.0
-modif_ratqs=0
-Pcrit_ratqs=500.0
-ratqsbasnew=0.05
-
-fac_modif_evaoce=1.0
-ok_bidouille_wake=0
-cond_temp_env=.false.
-! si oui, la temperature de cond est celle de l'environnement,
-! pour eviter bugs quand temperature dans ascendances convs est
-! mal calculee
-ok_prod_nucl_tritium=.false.
-
-! lecture des paramètres isotopiques:
-! pour que ça marche en openMP, il faut utiliser getin_p. Car le getin ne peut
-! être appelé que par un thread à la fois, et ça pose tout un tas de problème,
-! d'où tout un tas de magouilles comme dans conf_phys_m. A terme, tout le monde
-! lira par getin_p.
-call getin_p('lambda',lambda_sursat)
-call getin_p('thumxt1',thumxt1)
-call getin_p('ntot',ntot)
-call getin_p('h_land_ice',h_land_ice)
-call getin_p('P_veg',P_veg)
-call getin_p('bidouille_anti_divergence',bidouille_anti_divergence)
-call getin_p('essai_convergence',essai_convergence)
-call getin_p('initialisation_iso',initialisation_iso)
-!if (nzone>0) then      
-!if (initialisation_iso.eq.0) then
-!  call getin_p('initialisation_isotrac',initialisation_isotrac)
-!endif !if (initialisation_iso.eq.0) then
-!endif !if (nzone>0)
-call getin_p('modif_sst',modif_sst)
-if (modif_sst.ge.1) then
-call getin_p('deltaTtest',deltaTtest)
-if (modif_sst.ge.2) then
-  call getin_p('deltaTtestpoles',deltaTtestpoles)
-  call getin_p('sstlatcrit',sstlatcrit)
+   !--- Sensitivity tests
+   LOGICAL, PARAMETER ::   ok_nocinsfc = .FALSE. ! if T: no kinetic effect in sfc evap
+   LOGICAL, PARAMETER ::   ok_nocinsat = .FALSE. ! if T: no sursaturation effect for ice
+   LOGICAL, PARAMETER :: Rdefault_smow = .FALSE. ! if T: Rdefault=smow; if F: nul
+
+   !--- For [3]H
+   INTEGER :: iessai
+
+   CHARACTER(LEN=maxlen) :: modname, sxt
+   REAL, ALLOCATABLE :: tmp(:)
+
+   modname = 'iso_init'
+   CALL msg('219: entree', modname)
+
+   !--------------------------------------------------------------
+   ! General:
+   !--------------------------------------------------------------
+
+   !--- Check number of isotopes
+   CALL msg('64: niso = '//TRIM(int2str(niso)), modname)
+
+   !--- Init de ntracisoOR: on ecrasera en cas de traceurs de tagging isotopiques
+   !                     (nzone>0) si complications avec ORCHIDEE
+   ntracisoOR = ntiso  
+
+   !--- Type of water isotopes:
+   iso_eau = strIdx(isoName, 'H216O'); CALL msg('iso_eau='//int2str(iso_eau), modname)
+   iso_HDO = strIdx(isoName, 'HDO');   CALL msg('iso_HDO='//int2str(iso_HDO), modname)
+   iso_O18 = strIdx(isoName, 'H218O'); CALL msg('iso_O18='//int2str(iso_O18), modname)
+   iso_O17 = strIdx(isoName, 'H217O'); CALL msg('iso_O17='//int2str(iso_O17), modname)
+   iso_HTO = strIdx(isoName, 'HTO');   CALL msg('iso_HTO='//int2str(iso_HTO), modname)
+
+   !--- Initialiaation: reading the isotopic parameters.
+   CALL get_in('lambda',     lambda_sursat, 0.004)
+   CALL get_in('thumxt1',    thumxt1,       0.75*1.2)
+   CALL get_in('ntot',       ntot,          20,  .FALSE.)
+   CALL get_in('h_land_ice', h_land_ice,    20., .FALSE.)
+   CALL get_in('P_veg',      P_veg,         1.0, .FALSE.)
+   CALL get_in('bidouille_anti_divergence', bidouille_anti_divergence, .FALSE.)
+   CALL get_in('essai_convergence',         essai_convergence,         .FALSE.)
+   CALL get_in('initialisation_iso',        initialisation_iso,        0)
+
+!  IF(nzone>0 .AND. initialisation_iso==0) &
+!      CALL get_in('initialisation_isotrac',initialisation_isotrac)
+   CALL get_in('modif_sst',      modif_sst,         0)
+   CALL get_in('deltaTtest',     deltaTtest,      0.0)     !--- For modif_sst>=1
+   CALL get_in('deltaTtestpoles',deltaTtestpoles, 0.0)     !--- For modif_sst>=2
+   CALL get_in( 'sstlatcrit',    sstlatcrit,     30.0)     !--- For modif_sst>=3
+   CALL get_in('dsstlatcrit',   dsstlatcrit,      0.0)     !--- For modif_sst>=3
 #ifdef ISOVERIF
-      !call iso_verif_positif(sstlatcrit,'iso_init 107')
-      if (sstlatcrit.lt.0.0) then
-        write(*,*) 'iso_init 270: sstlatcrit=',sstlatcrit
-        stop
-      endif
+   CALL msg('iso_init 270:  sstlatcrit='//real2str( sstlatcrit), modname, sstlatcrit < 0.0) !--- For modif_sst>=2
+   CALL msg('iso_init 279: dsstlatcrit='//real2str(dsstlatcrit), modname, sstlatcrit < 0.0) !--- For modif_sst>=3
+   IF(modif_sst >= 2 .AND. sstlatcrit < 0.0) STOP
 #endif              
-  if (modif_sst.ge.3) then  
-      call getin_p('dsstlatcrit',dsstlatcrit)
+
+   CALL get_in('modif_sic', modif_sic,  0)
+   IF(modif_sic >= 1) &
+   CALL get_in('deltasic',  deltasic, 0.1)
+
+   CALL get_in('albedo_prescrit', albedo_prescrit, 0)
+   IF(albedo_prescrit == 1) THEN
+      CALL get_in('lon_min_albedo', lon_min_albedo, -200.)
+      CALL get_in('lon_max_albedo', lon_max_albedo,  200.)
+      CALL get_in('lat_min_albedo', lat_min_albedo, -100.)
+      CALL get_in('lat_max_albedo', lat_max_albedo,  100.)
+   END IF
+   deltaO18_oce=0.0
+   CALL get_in('deltaP_BL',           deltaP_BL,     10.0)
+   CALL get_in('ruissellement_pluie', ruissellement_pluie, 0)
+   CALL get_in('alphak_stewart',      alphak_stewart,      1)
+   CALL get_in('tdifexp_sol',         tdifexp_sol,      0.67)
+   CALL get_in('calendrier_guide',    calendrier_guide,    0)
+   CALL get_in('cste_surf_cond',      cste_surf_cond,      0)
+   CALL get_in('mixlen',              mixlen,           35.0)
+   CALL get_in('evap_cont_cste',      evap_cont_cste,      0)
+   CALL get_in('deltaO18_evap_cont',  deltaO18_evap_cont,0.0)
+   CALL get_in('d_evap_cont',         d_evap_cont,       0.0)
+   CALL get_in('nudge_qsol',          nudge_qsol,          0)
+   CALL get_in('region_nudge_qsol',   region_nudge_qsol,   1)
+   nlevmaxO17 = 50
+   CALL msg('nlevmaxO17='//TRIM(int2str(nlevmaxO17)))
+   CALL get_in('no_pce',   no_pce,     0)
+   CALL get_in('A_satlim', A_satlim, 1.0)
+   CALL get_in('ok_restrict_A_satlim', ok_restrict_A_satlim, 0)
 #ifdef ISOVERIF
-      !call iso_verif_positif(dsstlatcrit,'iso_init 110')
-      if (sstlatcrit.lt.0.0) then
-        write(*,*) 'iso_init 279: dsstlatcrit=',dsstlatcrit
-        stop
-      endif
-#endif              
-  endif !if (modif_sst.ge.3) then
-endif !if (modif_sst.ge.2) then
-endif !  if (modif_sst.ge.1) then   
-call getin_p('modif_sic',modif_sic)
-if (modif_sic.ge.1) then
-call getin_p('deltasic',deltasic)
-endif !if (modif_sic.ge.1) then
-
-call getin_p('albedo_prescrit',albedo_prescrit)
-call getin_p('lon_min_albedo',lon_min_albedo)
-call getin_p('lon_max_albedo',lon_max_albedo)
-call getin_p('lat_min_albedo',lat_min_albedo)
-call getin_p('lat_max_albedo',lat_max_albedo)
-call getin_p('deltaO18_oce',deltaO18_oce)
-call getin_p('deltaP_BL',deltaP_BL)
-call getin_p('ruissellement_pluie',ruissellement_pluie)
-call getin_p('alphak_stewart',alphak_stewart)
-call getin_p('tdifexp_sol',tdifexp_sol)
-call getin_p('calendrier_guide',calendrier_guide)
-call getin_p('cste_surf_cond',cste_surf_cond)
-call getin_p('mixlen',mixlen)
-call getin_p('evap_cont_cste',evap_cont_cste)
-call getin_p('deltaO18_evap_cont',deltaO18_evap_cont)
-call getin_p('d_evap_cont',d_evap_cont)  
-call getin_p('nudge_qsol',nudge_qsol)
-call getin_p('region_nudge_qsol',region_nudge_qsol)
-call getin_p('no_pce',no_pce)
-call getin_p('A_satlim',A_satlim)
-call getin_p('ok_restrict_A_satlim',ok_restrict_A_satlim)
-#ifdef ISOVERIF      
-!call iso_verif_positif(1.0-A_satlim,'iso_init 158')
-      if (A_satlim.gt.1.0) then
-        write(*,*) 'iso_init 315: A_satlim=',A_satlim
-        stop
-      endif
-#endif          
-!      call getin_p('slope_limiterxy',slope_limiterxy) 
-!      call getin_p('slope_limiterz',slope_limiterz) 
-call getin_p('modif_ratqs',modif_ratqs)
-call getin_p('Pcrit_ratqs',Pcrit_ratqs)
-call getin_p('ratqsbasnew',ratqsbasnew)
-call getin_p('fac_modif_evaoce',fac_modif_evaoce)
-call getin_p('ok_bidouille_wake',ok_bidouille_wake)
-call getin_p('cond_temp_env',cond_temp_env)
-if (use_iso(iso_HTO_possible)) then
-  ok_prod_nucl_tritium=.true.
-  call getin_p('ok_prod_nucl_tritium',ok_prod_nucl_tritium)
-endif
-
-write(*,*) 'lambda,thumxt1=',lambda_sursat,thumxt1
-write(*,*) 'bidouille_anti_divergence=',bidouille_anti_divergence
-write(*,*) 'essai_convergence=',essai_convergence
-write(*,*) 'initialisation_iso=',initialisation_iso
-write(*,*) 'modif_sst=',modif_sst
-if (modif_sst.ge.1) then
-write(*,*) 'deltaTtest=',deltaTtest
-if (modif_sst.ge.2) then  
-write(*,*) 'deltaTtestpoles,sstlatcrit=', &
-&           deltaTtestpoles,sstlatcrit
-if (modif_sst.ge.3) then   
- write(*,*) 'dsstlatcrit=',dsstlatcrit
-endif !if (modif_sst.ge.3) then
-endif !if (modif_sst.ge.2) then
-endif !if (modif_sst.ge.1) then
-write(*,*) 'modif_sic=',modif_sic
-if (modif_sic.ge.1) then  
-write(*,*) 'deltasic=',deltasic
-endif !if (modif_sic.ge.1) then
-write(*,*) 'deltaO18_oce=',deltaO18_oce
-write(*,*) 'albedo_prescrit=',albedo_prescrit
-if (albedo_prescrit.eq.1) then
- write(*,*) 'lon_min_albedo,lon_max_albedo=', &
-&           lon_min_albedo,lon_max_albedo
- write(*,*) 'lat_min_albedo,lat_max_albedo=', &
-&           lat_min_albedo,lat_max_albedo
-endif !if (albedo_prescrit.eq.1) then
-write(*,*) 'deltaP_BL,ruissellement_pluie,alphak_stewart=', &
-&       deltaP_BL,ruissellement_pluie,alphak_stewart
-write(*,*) 'cste_surf_cond=',cste_surf_cond
-write(*,*) 'mixlen=',mixlen
-write(*,*) 'tdifexp_sol=',tdifexp_sol
-write(*,*) 'calendrier_guide=',calendrier_guide
-write(*,*) 'evap_cont_cste=',evap_cont_cste
-write(*,*) 'deltaO18_evap_cont,d_evap_cont=', &
-&           deltaO18_evap_cont,d_evap_cont
-write(*,*) 'nudge_qsol,region_nudge_qsol=', &
-&  nudge_qsol,region_nudge_qsol  
-write(*,*) 'nlevmaxO17=',nlevmaxO17
-write(*,*) 'no_pce=',no_pce
-write(*,*) 'A_satlim=',A_satlim
-write(*,*) 'ok_restrict_A_satlim=',ok_restrict_A_satlim
-!      write(*,*) 'slope_limiterxy=',slope_limiterxy
-!      write(*,*) 'slope_limiterz=',slope_limiterz
-write(*,*) 'modif_ratqs=',modif_ratqs
-write(*,*) 'Pcrit_ratqs=',Pcrit_ratqs
-write(*,*) 'ratqsbasnew=',ratqsbasnew
-write(*,*) 'fac_modif_evaoce=',fac_modif_evaoce
-write(*,*) 'ok_bidouille_wake=',ok_bidouille_wake
-write(*,*) 'cond_temp_env=',cond_temp_env
-write(*,*) 'ok_prod_nucl_tritium=',ok_prod_nucl_tritium
-          
-
-!--------------------------------------------------------------
-! Parameters that do not depend on the nature of water isotopes:
-!--------------------------------------------------------------
-
-! -- temperature at which ice condensate starts to form (valeur ECHAM?):
-pxtmelt=273.15
-!      pxtmelt=273.15-10.0 ! test PHASE
-
-! -- temperature at which all condensate is ice:
-pxtice=273.15-10.0
-!      pxtice=273.15-30.0 ! test PHASE
-
-! -- minimum temperature to calculate fractionation coeff
-pxtmin=273.15-120.0 ! On ne calcule qu'au dessus de -120°C
-pxtmax=273.15+60.0 ! On ne calcule qu'au dessus de +60°C
-! remarque: les coeffs ont été mesurés seulement jusq'à -40!
-
-! -- a constant for alpha_eff for equilibrium below cloud base:
-tdifexp=0.58
-tv0cin=7.0
-
-! facteurs lambda et mu dans Si=musi-lambda*T
-musi=1.0
-if (ok_nocinsat) then
-lambda_sursat = 0.0 ! no sursaturation effect
-endif            
-
-
-! diffusion dans le sol
-Kd=2.5e-9 ! m2/s   
-
-! cas où cste_surf_cond: on met rhs ou/et Ts cste pour voir
-rh_cste_surf_cond=0.6
-T_cste_surf_cond=288.0
-
-!--------------------------------------------------------------
-! Parameters that depend on the nature of water isotopes:
-!--------------------------------------------------------------
-! ** constantes locales
-fac_enrichoce18=0.0005
-! on a alors tcor018=1+fac_enrichoce18
-! tcorD=1+fac_enrichoce18*8
-! tcorO17=1+fac_enrichoce18*0.528
-alpha_liq_sol_O18=1.00291 ! valeur de Lehmann & Siegenthaler, 1991, 
-  ! Journal of Glaciology, vol 37, p 23
-talph1_O18=1137.
-talph2_O18=-0.4156
-talph3_O18=-2.0667E-3
-talps1_O18=11.839
-talps2_O18=-0.028244
-tkcin0_O18 = 0.006
-tkcin1_O18 = 0.000285
-tkcin2_O18 = 0.00082
-tdifrel_O18= 1./0.9723
-
-! rapport des ln(alphaeq) entre O18 et O17
-fac_coeff_eq17_liq=0.529 ! donné par Amaelle
-!      fac_coeff_eq17_ice=0.528 ! slope MWL 
-fac_coeff_eq17_ice=0.529
-
-
-write(*,*) 'iso_O18,iso_HDO,iso_eau=',iso_O18,iso_HDO,iso_eau
-do 999 ixt = 1, niso
-write(*,*) 'iso_init 80: ixt=',ixt
-
-
-! -- kinetic factor for surface evaporation:
-! (cf: kcin = tkcin0                  if |V|<tv0cin
-!      kcin = tkcin1*|Vsurf| + tkcin2 if |V|>tv0cin )
-! (Rq: formula discontinuous for |V|=tv0cin... )        
-
-! -- main:
-if (ixt.eq.iso_HTO) then ! Tritium
-  tkcin0(ixt) = 0.01056
-  tkcin1(ixt) = 0.0005016
-  tkcin2(ixt) = 0.0014432
-  tnat(ixt)=0.
-  !toce(ixt)=2.2222E-8 ! corrigé par Alex Cauquoin
-  !toce(ixt)=1.0E-18 ! rapport 3H/1H ocean
-  toce(ixt)=4.0E-19 ! rapport T/H = 0.2 TU Dreisigacker and Roether 1978
-  tcorr(ixt)=1.
-  tdifrel(ixt)=1./0.968
-  talph1(ixt)=46480.
-  talph2(ixt)=-103.87
-  talph3(ixt)=0.
-  talps1(ixt)=46480.
-  talps2(ixt)=-103.87
-  alpha_liq_sol(ixt)=1. 
-  Rdefault(ixt)=0.0
-  Rmethox(ixt)=0.0
-  striso(ixt)='HTO'
-endif     
-if (ixt.eq.iso_O17) then ! Deuterium
-  pente_MWL=0.528
-!          tdifrel(ixt)=1./0.985452 ! donné par Amaelle 
-  tdifrel(ixt)=1./0.98555 ! valeur utilisée en 1D et dans modèle de LdG
-!          fac_kcin=0.5145 ! donné par Amaelle
-  fac_kcin= (tdifrel(ixt)-1.0)/(tdifrel_O18-1.0)
-  tkcin0(ixt) = tkcin0_O18*fac_kcin
-  tkcin1(ixt) = tkcin1_O18*fac_kcin
-  tkcin2(ixt) = tkcin2_O18*fac_kcin
-  tnat(ixt)=0.004/100. ! O17 représente 0.004% de l'oxygène
-  toce(ixt)=tnat(ixt)*(1.0+deltaO18_oce/1000.0)**pente_MWL
-  tcorr(ixt)=1.0+fac_enrichoce18*pente_MWL ! donné par Amaelle            
-  talph1(ixt)=talph1_O18
-  talph2(ixt)=talph2_O18
-  talph3(ixt)=talph3_O18
-  talps1(ixt)=talps1_O18
-  talps2(ixt)=talps2_O18     
-  alpha_liq_sol(ixt)=(alpha_liq_sol_O18)**fac_coeff_eq17_liq 
-  if (Rdefault_smow) then    
-        Rdefault(ixt)=tnat(ixt)*(-3.15/1000.0+1.0)
-  else
-        Rdefault(ixt)=0.0
-  endif
-  Rmethox(ixt)=(230./1000.+1.)*tnat(ixt) !Zahn et al 2006
-  striso(ixt)='O17'
-endif
-
-if (ixt.eq.iso_O18) then ! Oxygene18
-  tkcin0(ixt) = tkcin0_O18
-  tkcin1(ixt) = tkcin1_O18
-  tkcin2(ixt) = tkcin2_O18
-  tnat(ixt)=2005.2E-6
-  toce(ixt)=tnat(ixt)*(1.0+deltaO18_oce/1000.0)
-  tcorr(ixt)=1.0+fac_enrichoce18
-  tdifrel(ixt)=tdifrel_O18
-  talph1(ixt)=talph1_O18
-  talph2(ixt)=talph2_O18
-  talph3(ixt)=talph3_O18
-  talps1(ixt)=talps1_O18
-  talps2(ixt)=talps2_O18
-  alpha_liq_sol(ixt)=alpha_liq_sol_O18   
-  if (Rdefault_smow) then    
-        Rdefault(ixt)=tnat(ixt)*(-6.0/1000.0+1.0)
-  else
-        Rdefault(ixt)=0.0
-  endif
-  Rmethox(ixt)=(130./1000.+1.)*tnat(ixt) !Zahn et al 2006   
-!       write(*,*) 'iso_init 163: ZXalpha_liq_sol=',ZXalpha_liq_sol
-  striso(ixt)='O18'
-  write(*,*) 'isotopes_mod 519: ixt,striso(ixt)=',ixt,striso(ixt)
-endif
-
-if (ixt.eq.iso_HDO) then ! Deuterium
-  pente_MWL=8.0
-!          fac_kcin=0.88
-  tdifrel(ixt)=1./0.9755
-  fac_kcin= (tdifrel(ixt)-1)/(tdifrel_O18-1)
-  tkcin0(ixt) = tkcin0_O18*fac_kcin
-  tkcin1(ixt) = tkcin1_O18*fac_kcin
-  tkcin2(ixt) = tkcin2_O18*fac_kcin
-  tnat(ixt)=155.76E-6
-  toce(ixt)=tnat(ixt)*(1.0+pente_MWL*deltaO18_oce/1000.0)
-  tcorr(ixt)=1.0+fac_enrichoce18*pente_MWL          
-  talph1(ixt)=24844.
-  talph2(ixt)=-76.248
-  talph3(ixt)=52.612E-3
-  talps1(ixt)=16288.
-  talps2(ixt)=-0.0934
-  !ZXalpha_liq_sol=1.0192 ! Weston, Ralph, 1955
-  alpha_liq_sol(ixt)=1.0212 
-  ! valeur de Lehmann & Siegenthaler, 1991, Journal of
-  ! Glaciology, vol 37, p 23
-  if (Rdefault_smow) then    
-    Rdefault(ixt)=tnat(ixt)*((-6.0*pente_MWL+10.0)/1000.0+1.0)
-  else
-    Rdefault(ixt)=0.0
-  endif
-  Rmethox(ixt)=tnat(ixt)*(-25.0/1000.+1.) ! Zahn et al 2006
-  striso(ixt)='HDO'
-  write(*,*) 'isotopes_mod 548: ixt,striso(ixt)=',ixt,striso(ixt)
-endif
-
-!       write(*,*) 'iso_init 163: ZXalpha_liq_sol=',ZXalpha_liq_sol
-if (ixt.eq.iso_eau) then ! Oxygene16
-  tkcin0(ixt) = 0.0
-  tkcin1(ixt) = 0.0
-  tkcin2(ixt) = 0.0
-  tnat(ixt)=1.
-  toce(ixt)=tnat(ixt)
-  tcorr(ixt)=1.0
-  tdifrel(ixt)=1.
-  talph1(ixt)=0.
-  talph2(ixt)=0.
-  talph3(ixt)=0.
-  talps1(ixt)=0.
-  talph3(ixt)=0.
-  alpha_liq_sol(ixt)=1.
-  if (Rdefault_smow) then
-        Rdefault(ixt)=tnat(ixt)*1.0
-  else
-        Rdefault(ixt)=1.0
-  endif
-  Rmethox(ixt)=1.0
-  striso(ixt)='eau'
-endif
-
-999   continue
-
-! test de sensibilité: 
-if (ok_nocinsfc) then ! no kinetic effect in sfc evaporation
- do ixt=1,niso
-  tkcin0(ixt) = 0.0 
-  tkcin1(ixt) = 0.0 
-  tkcin2(ixt) = 0.0
- enddo 
-endif
-
-! nom des isotopes
-
-! verif
-write(*,*) 'iso_init 285: verif initialisation:'
-
-do ixt=1,niso
-  write(*,*) '* striso(',ixt,')=<'//striso(ixt)//'>'
-  write(*,*) 'tnat(',ixt,')=',tnat(ixt)
-!          write(*,*) 'alpha_liq_sol(',ixt,')=',alpha_liq_sol(ixt)
-!          write(*,*) 'tkcin0(',ixt,')=',tkcin0(ixt)
-!          write(*,*) 'tdifrel(',ixt,')=',tdifrel(ixt)
-enddo
-write(*,*) 'iso_init 69: lambda=',lambda_sursat
-write(*,*) 'iso_init 69: thumxt1=',thumxt1
-write(*,*) 'iso_init 69: h_land_ice=',h_land_ice
-write(*,*) 'iso_init 69: P_veg=',P_veg   
-
-    return
+   CALL msg(' 315: A_satlim='//real2str(A_satlim), modname, A_satlim > 1.0)
+   IF(A_satlim > 1.0) STOP
+#endif
+!  CALL get_in('slope_limiterxy',   slope_limiterxy,  2.0) 
+!  CALL get_in('slope_limiterz',    slope_limiterz,   2.0) 
+   CALL get_in('modif_ratqs',       modif_ratqs,        0)
+   CALL get_in('Pcrit_ratqs',       Pcrit_ratqs,    500.0)
+   CALL get_in('ratqsbasnew',       ratqsbasnew,     0.05)
+   CALL get_in('fac_modif_evaoce',  fac_modif_evaoce, 1.0)
+   CALL get_in('ok_bidouille_wake', ok_bidouille_wake,  0)
+   ! si oui, la temperature de cond est celle de l'environnement, pour eviter
+   ! bugs quand temperature dans ascendances convs est mal calculee
+   CALL get_in('cond_temp_env',        cond_temp_env,        .FALSE.)
+   IF(ANY(isoName == 'HTO')) &
+   CALL get_in('ok_prod_nucl_tritium', ok_prod_nucl_tritium, .FALSE., .FALSE.)
+
+   !--------------------------------------------------------------
+   ! Parameters that do not depend on the nature of water isotopes:
+   !--------------------------------------------------------------
+   ! -- temperature at which ice condensate starts to form (valeur ECHAM?):
+   pxtmelt = 273.15
+
+   ! -- temperature at which all condensate is ice:
+   pxtice  = 273.15-10.0
+
+   !- -- test PHASE
+!   pxtmelt = 273.15 - 10.0
+!   pxtice  = 273.15 - 30.0
+
+   ! -- minimum temperature to calculate fractionation coeff
+   pxtmin = 273.15 - 120.0   ! On ne calcule qu'au dessus de -120°C
+   pxtmax = 273.15 +  60.0   ! On ne calcule qu'au dessus de +60°C
+   !    Remarque: les coeffs ont ete mesures seulement jusq'à -40!
+
+   ! -- a constant for alpha_eff for equilibrium below cloud base:
+   tdifexp = 0.58
+   tv0cin  = 7.0
+
+   ! facteurs lambda et mu dans Si=musi-lambda*T
+   musi=1.0
+   if (ok_nocinsat) lambda_sursat = 0.0          ! no sursaturation effect
+
+   ! diffusion dans le sol
+   Kd=2.5e-9 ! m2/s   
+
+   ! cas où cste_surf_cond: on met rhs ou/et Ts cste pour voir
+   rh_cste_surf_cond = 0.6
+    T_cste_surf_cond = 288.0
+   
+   CALL msg('iso_O18, iso_HDO, iso_eau = '//TRIM(strStack(int2str([iso_O18, iso_HDO, iso_eau]))), modname)
+
+   !--------------------------------------------------------------
+   ! Parameters that depend on the nature of water isotopes:
+   !--------------------------------------------------------------
+   IF(getKey('tnat',    tnat,    isoName)) CALL abort_physic(modname, 'can''t get tnat',    1)
+   IF(getKey('toce',    toce,    isoName)) CALL abort_physic(modname, 'can''t get toce',    1)
+   IF(getKey('tcorr',   tcorr,   isoName)) CALL abort_physic(modname, 'can''t get tcorr',   1)
+   IF(getKey('talph1',  talph1,  isoName)) CALL abort_physic(modname, 'can''t get talph1',  1)
+   IF(getKey('talph2',  talph2,  isoName)) CALL abort_physic(modname, 'can''t get talph2',  1)
+   IF(getKey('talph3',  talph3,  isoName)) CALL abort_physic(modname, 'can''t get talph3',  1)
+   IF(getKey('talps1',  talps1,  isoName)) CALL abort_physic(modname, 'can''t get talps1',  1)
+   IF(getKey('talps2',  talps2,  isoName)) CALL abort_physic(modname, 'can''t get talps2',  1)
+   IF(getKey('tkcin0',  tkcin0,  isoName)) CALL abort_physic(modname, 'can''t get tkcin0',  1)
+   IF(getKey('tkcin1',  tkcin1,  isoName)) CALL abort_physic(modname, 'can''t get tkcin1',  1)
+   IF(getKey('tkcin2',  tkcin2,  isoName)) CALL abort_physic(modname, 'can''t get tkcin2',  1)
+   IF(getKey('tdifrel', tdifrel, isoName)) CALL abort_physic(modname, 'can''t get tdifrel', 1)
+   IF(getKey('alpha_liq_sol', alpha_liq_sol, isoName)) CALL abort_physic(modname, 'can''t get alpha_liq_sol',  1)
+   IF(getKey('Rdefault',Rdefault,isoName)) CALL abort_physic(modname, 'can''t get Rdefault',1)
+   IF(getKey('Rmethox', Rmethox, isoName)) CALL abort_physic(modname, 'can''t get Rmethox', 1)
+   IF(.NOT.Rdefault_smow) Rdefault(:) = 0.0
+
+   !--- Sensitivity test: no kinetic effect in sfc evaporation
+   IF(ok_nocinsfc) THEN
+      tkcin0(1:niso) = 0.0
+      tkcin1(1:niso) = 0.0
+      tkcin2(1:niso) = 0.0
+   END IF
+
+   CALL msg('285: verif initialisation:', modname)
+   DO ixt=1,niso
+      sxt=int2str(ixt)
+      CALL msg(' * isoName('//TRIM(sxt)//') = <'//TRIM(isoName(ixt))//'>',  modname)
+      CALL msg(  '    tnat('//TRIM(sxt)//') = '//TRIM(real2str(tnat(ixt))), modname)
+!     CALL msg('    alpha_liq_sol('//TRIM(sxt)//') = '//TRIM(real2str(alpha_liq_sol(ixt))), modname)
+!     CALL msg(        '   tkcin0('//TRIM(sxt)//') = '//TRIM(real2str(tkcin0(ixt))),        modname)
+!     CALL msg(       '   tdifrel('//TRIM(sxt)//') = '//TRIM(real2str(tdifrel(ixt))),       modname)
+   END DO
+   CALL msg('69:     lambda = '//TRIM(real2str(lambda_sursat)), modname)
+   CALL msg('69:    thumxt1 = '//TRIM(real2str(thumxt1)),       modname)
+   CALL msg('69: h_land_ice = '//TRIM(real2str(h_land_ice)),    modname)
+   CALL msg('69:      P_veg = '//TRIM(real2str(P_veg)),         modname)
+
 END SUBROUTINE iso_init
 
+
+SUBROUTINE getinp_s(nam, val, def, lDisp)
+   USE ioipsl_getincom, ONLY: getin
+   USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+   USE mod_phys_lmdz_omp_data, ONLY :  is_omp_root
+   USE mod_phys_lmdz_transfert_para, ONLY : bcast
+   CHARACTER(LEN=*),           INTENT(IN)    :: nam
+   CHARACTER(LEN=*),           INTENT(INOUT) :: val
+   CHARACTER(LEN=*), OPTIONAL, INTENT(IN)    :: def
+   LOGICAL,          OPTIONAL, INTENT(IN)    :: lDisp
+   LOGICAL :: lD
+!$OMP BARRIER
+   IF(is_mpi_root.AND.is_omp_root) THEN
+      IF(PRESENT(def)) val=def; CALL getin(nam,val)
+      lD=.TRUE.; IF(PRESENT(lDisp)) lD=lDisp
+      IF(lD) CALL msg(TRIM(nam)//' = '//TRIM(val))
+  END IF
+  CALL bcast(val)
+END SUBROUTINE getinp_s
+
+SUBROUTINE getinp_i(nam, val, def, lDisp)
+   USE ioipsl_getincom, ONLY: getin
+   USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+   USE mod_phys_lmdz_omp_data, ONLY :  is_omp_root
+   USE mod_phys_lmdz_transfert_para, ONLY : bcast
+   CHARACTER(LEN=*),  INTENT(IN)    :: nam
+   INTEGER,           INTENT(INOUT) :: val
+   INTEGER, OPTIONAL, INTENT(IN)    :: def
+   LOGICAL, OPTIONAL, INTENT(IN)    :: lDisp
+   LOGICAL :: lD
+!$OMP BARRIER
+   IF(is_mpi_root.AND.is_omp_root) THEN
+      IF(PRESENT(def)) val=def; CALL getin(nam,val)
+      lD=.TRUE.; IF(PRESENT(lDisp)) lD=lDisp
+      IF(lD) CALL msg(TRIM(nam)//' = '//TRIM(int2str(val)))
+  END IF
+  CALL bcast(val)
+END SUBROUTINE getinp_i
+
+SUBROUTINE getinp_r(nam, val, def, lDisp)
+   USE ioipsl_getincom, ONLY: getin
+   USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+   USE mod_phys_lmdz_omp_data, ONLY :  is_omp_root
+   USE mod_phys_lmdz_transfert_para, ONLY : bcast
+   CHARACTER(LEN=*),  INTENT(IN)    :: nam
+   REAL,              INTENT(INOUT) :: val
+   REAL,    OPTIONAL, INTENT(IN)    :: def
+   LOGICAL, OPTIONAL, INTENT(IN)    :: lDisp
+   LOGICAL :: lD
+!$OMP BARRIER
+   IF(is_mpi_root.AND.is_omp_root) THEN
+      IF(PRESENT(def)) val=def; CALL getin(nam,val)
+      lD=.TRUE.; IF(PRESENT(lDisp)) lD=lDisp
+      IF(lD) CALL msg(TRIM(nam)//' = '//TRIM(real2str(val)))
+  END IF
+  CALL bcast(val)
+END SUBROUTINE getinp_r
+
+SUBROUTINE getinp_l(nam, val, def, lDisp)
+   USE ioipsl_getincom, ONLY: getin
+   USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+   USE mod_phys_lmdz_omp_data, ONLY :  is_omp_root
+   USE mod_phys_lmdz_transfert_para, ONLY : bcast
+   CHARACTER(LEN=*),  INTENT(IN)    :: nam
+   LOGICAL,           INTENT(INOUT) :: val
+   LOGICAL, OPTIONAL, INTENT(IN)    :: def
+   LOGICAL, OPTIONAL, INTENT(IN)    :: lDisp
+   LOGICAL :: lD
+!$OMP BARRIER
+   IF(is_mpi_root.AND.is_omp_root) THEN
+      IF(PRESENT(def)) val=def; CALL getin(nam,val)
+      lD=.TRUE.; IF(PRESENT(lDisp)) lD=lDisp
+      IF(lD) CALL msg(TRIM(nam)//' = '//TRIM(bool2str(val)))
+  END IF
+  CALL bcast(val)
+END SUBROUTINE getinp_l
 
 END MODULE isotopes_mod
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/isotopes_routines_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/isotopes_routines_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/isotopes_routines_mod.F90	(revision 4446)
@@ -3,4 +3,5 @@
 
 MODULE isotopes_routines_mod
+  USE infotrac_phy, ONLY: niso, ntraciso=>ntiso, index_trac=>itZonIso, ntraceurs_zone=>nzone
 IMPLICIT NONE
 
@@ -13,6 +14,4 @@
 &            zqs,zq_ancien,zqev_diag,zq)
 
-USE infotrac_phy, ONLY: ntraciso,niso, &
-        ntraceurs_zone,index_trac
 USE isotopes_mod, ONLY: ridicule, ridicule_rain, thumxt1, no_pce,  &
 &       bidouille_anti_divergence, &
@@ -846,5 +845,4 @@
 &    L, xtnu,Pveg)
 
-USE infotrac_phy, ONLY: niso
 USE isotopes_mod, ONLY: ridicule_qsol, ridicule, &
 &       ridicule_evap,P_veg,iso_HDO,iso_eau,iso_O17,iso_O18
@@ -1301,5 +1299,4 @@
 
 subroutine calcul_kcin(Vsurf,KCIN)
-USE infotrac_phy, ONLY: niso 
 USE isotopes_mod, ONLY: tv0cin,tkcin0,tkcin1,tkcin2
 implicit none
@@ -1328,5 +1325,4 @@
 
      subroutine fractcalk(kt, ptin, pxtfra, pfraice)
-!USE infotrac_phy, ONLY: use_iso
 USE isotopes_mod, ONLY: talph1,talph2,talph3,pxtmin,iso_O17, &
 &       fac_coeff_eq17_liq, pxtmelt, &
@@ -1457,5 +1453,4 @@
       subroutine fractcalk_liq(kt, ptin, pxtfra)
 
-!      USE infotrac_phy, ONLY: use_iso
       USE isotopes_mod, ONLY: pxtmin,talph1,talph2,talph3, &
 &       fac_coeff_eq17_liq, pxtice, &
@@ -1522,5 +1517,4 @@
       subroutine fractcalk_glace(kt, ptin, pfraice)
 
-!      use infotrac_phy, ONLY: use_iso
       use isotopes_mod, ONLY: talps1,talps2, iso_O17,fac_coeff_eq17_ice, &
         & pxtmelt,musi, lambda_sursat, tdifrel, &
@@ -1631,5 +1625,4 @@
       subroutine fractcalk_vectall(ptin, pxtfra, pfraice,n)
 
-        USE infotrac_phy, ONLY: niso
         USE isotopes_mod, ONLY: talph1,talph2,talph3,tdifrel,pxtmin, &
 &      iso_O17, iso_HTO, iso_eau, iso_O18, iso_HDO, musi, lambda_sursat, &
@@ -1803,5 +1796,4 @@
       subroutine fractcalk_vectall_liq(ptin, pxtfra, n)
 
-      USE infotrac_phy, ONLY: niso
       USE isotopes_mod, ONLY: pxtmin,talph1,talph2,talph3, &
 &       iso_eau,iso_HDO, iso_O18, iso_O17,iso_HTO,fac_coeff_eq17_liq, &
@@ -1882,5 +1874,4 @@
       subroutine fractcalk_vectall_ice(ptin, pfraice,n)
 
-      use infotrac_phy, ONLY: niso
       use isotopes_mod, ONLY: talps1,talps2, fac_coeff_eq17_ice, &
         & pxtmelt,musi, lambda_sursat, tdifrel, &
@@ -2023,5 +2014,4 @@
 &            i,Rsol,klon)
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO,ridicule, &
 &        ridicule_qsol,iso_O17,iso_O18
@@ -2233,5 +2223,4 @@
 &          i,xtevap,klon)  
 
-  USE infotrac_phy, ONLY: ntraciso,niso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO,ridicule,ridicule_rain, &
         iso_O18,iso_O17
@@ -2444,5 +2433,4 @@
 &   )
 
-  USE infotrac_phy, ONLY: ntraciso,niso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO,expb_max,tdifrel,tdifexp, &
 &       ridicule,thumxt1,ridicule_rain,bidouille_anti_divergence, &
@@ -4500,5 +4488,4 @@
 &           Tevap) 
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO,bidouille_anti_divergence, &
 &       ridicule,ridicule_rain
@@ -4658,5 +4645,4 @@
 &           ,fac_ftmr)
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO,bidouille_anti_divergence, &
 &       Rdefault,ridicule,ridicule_rain
@@ -4904,5 +4890,4 @@
      &           Pqiinf_cas,Pqiinf)
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO
 
@@ -5066,5 +5051,4 @@
      &           xtnew_cas,xtnew,Pxtiinf_cas,Pxtiinf)
 
-  USE infotrac_phy, ONLY: niso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO
 #ifdef ISOVERIF
@@ -5111,5 +5095,4 @@
      &           ncum)
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO
 
@@ -5176,5 +5159,4 @@
      &    nloc,ncum,nd,i)
 
-  USE infotrac_phy, ONLY: niso, ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO
 
@@ -5252,5 +5234,4 @@
      &    nloc,ncum,nd,i)
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO
 
@@ -5326,5 +5307,4 @@
      &    nloc,ncum,nd,i)
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO
 
@@ -5396,5 +5376,4 @@
      &    nloc,ncum,nd,i)
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO,ridicule
 
@@ -5566,5 +5545,4 @@
      &    nloc,ncum,nd,i,frac_sublim)
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO,ridicule
 
@@ -5703,5 +5681,4 @@
      &       zxtrfln_cas,zxt_cas,zxtrfl,zxtrfln,zxt,klon)
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO
 
@@ -5739,5 +5716,4 @@
      &       delP,paprs,k,klon,klev)
 
-  USE infotrac_phy, ONLY: niso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO
          implicit none
@@ -5777,5 +5753,4 @@
      &       delP,paprs,k,klon,klev)
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO
          implicit none
@@ -5828,5 +5803,4 @@
      &       delP,paprs,k,klon,klev,frac_sublim)
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO
 #ifdef ISOVERIF
@@ -5905,5 +5879,4 @@
      &          qp0,A,m0,beta,gama,g0)  
 
-  USE infotrac_phy, ONLY: niso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO,ntot
 #ifdef ISOVERIF
@@ -6100,6 +6073,4 @@
  
 
-  USE infotrac_phy, ONLY: ntraciso,niso,ntraceurs_zone, &
-&       index_trac
   USE isotopes_mod, ONLY: iso_eau, iso_HDO,thumxt1, &
 &       bidouille_anti_divergence,ridicule
@@ -7680,5 +7651,4 @@
      &          )    
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO, Rdefault, ridicule
 #ifdef ISOVERIF
@@ -8048,5 +8018,4 @@
      &  ) 
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO, Rdefault,ridicule
 #ifdef ISOVERIF
@@ -8253,5 +8222,4 @@
      &          ) 
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO, Rdefault,ridicule
 #ifdef ISOVERIF
@@ -8390,5 +8358,4 @@
      &          ,xtp_cas,xtwater_cas,xtevap_cas) 
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO,no_pce, Rdefault,ridicule       
 #ifdef ISOVERIF
@@ -8927,5 +8894,4 @@
      &          ,xtp_cas,xtwater_cas,xtevap_cas) 
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO, Rdefault, ridicule
 #ifdef ISOVERIF
@@ -9317,6 +9283,4 @@
  
 
-  USE infotrac_phy, ONLY: niso,ntraciso, &
-&       ntraceurs_zone,index_trac
   USE isotopes_mod, ONLY: iso_eau, iso_HDO,bidouille_anti_divergence, &
 &       thumxt1, ridicule
@@ -11022,5 +10986,4 @@
      &          ) 
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO,Rdefault,ridicule
 #ifdef ISOVERIF
@@ -11172,5 +11135,4 @@
      &          ,xtp_cas,xtwater_cas,xtevap_cas) 
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO,Rdefault,no_pce,ridicule
 #ifdef ISOVERIF
@@ -11770,5 +11732,4 @@
      &          ,xtp_cas,xtwater_cas,xtevap_cas) 
 
-  USE infotrac_phy, ONLY: niso,ntraciso
   USE isotopes_mod, ONLY: iso_eau, iso_HDO, Rdefault, ridicule
 #ifdef ISOVERIF
@@ -12198,5 +12159,4 @@
      &          tcond,zfice,zxtice,zxtliq)
 
-    USE infotrac_phy, ONLY: ntraciso,niso
     USE isotopes_mod, ONLY: iso_eau,iso_HDO,essai_convergence, &
 &       bidouille_anti_divergence,ridicule
@@ -12432,5 +12392,4 @@
      &          tcond,zfice,zxtice,zxtliq,n)
 
-    USE infotrac_phy, ONLY: ntraciso,niso
     USE isotopes_mod, ONLY: iso_eau,iso_HDO,iso_O18,bidouille_anti_divergence, &
 &       ridicule
@@ -12890,5 +12849,4 @@
      &          tcond,zfice,zxtice,zxtliq)
 
-    USE infotrac_phy, ONLY: ntraciso
     USE isotopes_mod, ONLY: iso_eau,iso_HDO,bidouille_anti_divergence, &
 &       ridicule,iso_O18
@@ -13088,5 +13046,4 @@
      &           xt1lay,q1lay,tsurf,t_coup,nisurf,Rland_ice)
 
-    USE infotrac_phy, ONLY: ntraciso,niso
     USE isotopes_mod, ONLY: Rdefault,iso_eau,iso_HDO, &
 &       bidouille_anti_divergence, ridicule,ridicule_snow, &
@@ -13658,5 +13615,4 @@
      &   )
 
-    USE infotrac_phy, ONLY: ntraciso,niso
     USE isotopes_mod, ONLY: iso_eau,iso_HDO,cste_surf_cond, &
 &       rh_cste_surf_cond,Rdefault,T_cste_surf_cond,iso_O17,iso_O18, &
@@ -13982,5 +13938,4 @@
      &   )
 
-    USE infotrac_phy, ONLY: ntraciso,niso
     USE isotopes_mod, ONLY: tcorr, toce, alpha_liq_sol,ridicule_evap, &
         iso_eau,iso_HDO
@@ -14238,5 +14193,4 @@
      &   )
 
-    USE infotrac_phy, ONLY: ntraciso,niso
     USE isotopes_mod, ONLY: h_land_ice, ridicule,ridicule_snow,ridicule_evap, &
         iso_eau,iso_HDO,iso_O18
@@ -14573,5 +14527,4 @@
      &   )
 
-USE infotrac_phy, ONLY: niso,ntraciso
 USE isotopes_mod, ONLY: tdifrel,tdifexp_sol, iso_eau, iso_HDO, &
 &       bidouille_anti_divergence,ruissellement_pluie, Rdefault,Kd, &
@@ -16001,5 +15954,4 @@
       !USE write_field_phy
       USE indice_sol_mod, only: nbsrf  
-  USE infotrac_phy, ONLY: ntraciso,niso
   USE isotopes_mod, ONLY: initialisation_iso, iso_eau,iso_HDO, &
         ridicule_qsol,tnat, P_veg,iso_O18,ridicule, ridicule_snow,iso_O17, &
@@ -16187,5 +16139,4 @@
       !USE write_field_phy
       USE indice_sol_mod, only: nbsrf
-  USE infotrac_phy, ONLY: ntraciso,niso
   USE isotopes_mod, ONLY: tnat,iso_HDO,iso_O18,iso_HTO, iso_eau,toce, &
 &       Rdefault,iso_O17,ridicule,ridicule_qsol
@@ -16557,271 +16508,162 @@
       end subroutine phyiso_etat0_dur
 
-      subroutine phyiso_etat0_fichier( &
-     &           snow,run_off_lic_0, &
-     &           xtsnow,xtrun_off_lic_0, &
-     &           Rland_ice)
-      USE dimphy, only: klon,klev
-      !USE mod_grid_phy_lmdz
-      !USE mod_phys_lmdz_para
-      USE iophy
-      USE phys_state_var_mod, ONLY: q_ancien,xt_ancien,wake_deltaq,wake_deltaxt, &
-#ifdef ISOVERIF
-        rain_fall,snow_fall,fevap,qsol, &
-#endif
-        xtrain_fall,xtsnow_fall,ql_ancien,xtl_ancien,qs_ancien,xts_ancien, &
-        fxtevap,xtsol
-      !USE iostart
-      !USE write_field_phy
-      USE indice_sol_mod, only: nbsrf  
-  USE infotrac_phy, ONLY: ntraciso,niso
-  USE isotopes_mod, ONLY: striso,iso_HDO,iso_eau
-#ifdef ISOVERIF
-  USE isotopes_verif_mod
+SUBROUTINE phyiso_etat0_fichier(snow, run_off_lic_0, xtsnow, xtrun_off_lic_0, Rland_ice)
+   USE dimphy,             ONLY: klon,klev
+   USE iophy
+   USE phys_state_var_mod, ONLY: q_ancien, xt_ancien, wake_deltaq, wake_deltaxt, &
+#ifdef ISOVERIF
+     rain_fall, snow_fall, fevap,qsol, &
+#endif
+     xtrain_fall, xtsnow_fall, ql_ancien, xtl_ancien, qs_ancien, xts_ancien, fxtevap, xtsol
+   USE indice_sol_mod,    ONLY: nbsrf
+   USE isotopes_mod,      ONLY: isoName,iso_HDO,iso_eau
+   USE phyetat0_get_mod,  ONLY: phyetat0_get, phyetat0_srf
+   USE readTracFiles_mod, ONLY: new2oldH2O
+   USE strings_mod,       ONLY: strIdx, strTail, maxlen, msg, int2str
+#ifdef ISOVERIF
+   USE isotopes_verif_mod
 #endif
 #ifdef ISOTRAC
- USE isotrac_mod, ONLY: strtrac,initialisation_isotrac,index_iso, &
-&       index_zone,izone_init
-#endif
-        implicit none
+   USE isotrac_mod, ONLY: strtrac, initialisation_isotrac, index_iso, index_zone, izone_init
+#endif
+   IMPLICIT NONE
 
 #include "netcdf.inc"
 #include "dimsoil.h"
 #include "clesphys.h"
-! #include "thermcell.h"
 #include "compbl.h"    
 
-        ! inputs 
-        !REAL qsol(klon)
-        REAL snow(klon,nbsrf)
-        !REAL evap(klon,nbsrf)
-        REAL run_off_lic_0(klon)
-        ! outputs   
-        !REAL xtsol(niso,klon)
-        REAL xtsnow(niso,klon,nbsrf) 
-        !REAL xtevap(ntraciso,klon,nbsrf)     
-        REAL xtrun_off_lic_0(niso,klon)
-        REAL Rland_ice(niso,klon)
-
-        ! locals
-        real iso_tmp(klon)
-        real iso_tmp_lonlev(klon,klev)
-        real iso_tmp_lonsrf(klon,nbsrf)
-        INTEGER ierr
-        integer i,ixt,k,nsrf
-        INTEGER nid, nvarid
-        CHARACTER*2 str2
-        CHARACTER*5 str5
-        real xmin,xmax    
-        CHARACTER*50 striso_sortie  
-        integer lnblnk
-        LOGICAL :: found,phyetat0_get,phyetat0_srf
-
-!#ifdef ISOVERIF
-!      integer iso_verif_egalite_nostop
-!#endif
-!#ifdef ISOVERIF
-!        real deltaD
-!        integer iso_verif_noNaN_nostop
-!#endif
+   REAL, INTENT(IN) ::             snow     (klon,nbsrf)
+   REAL, INTENT(IN) ::    run_off_lic_0     (klon)
+   REAL, INTENT(OUT) ::          xtsnow(niso,klon,nbsrf) 
+   REAL, INTENT(OUT) :: xtrun_off_lic_0(niso,klon)
+   REAL, INTENT(OUT) ::       Rland_ice(niso,klon)
+
+   INTEGER :: ierr, i, ixt, k, nsrf, nid, nvarid, lnblnk
+   CHARACTER(LEN=2) :: str2
+   CHARACTER(LEN=5) :: str5
+   CHARACTER(LEN=maxlen) :: outiso, oldIso, modname, nam(2)
+   REAL :: xmin, xmax
+   LOGICAL :: found
 #ifdef ISOTRAC
-        integer iiso,izone
-#endif
-
-
-   write(*,*) 'phyiso_etat0_fichier 3'
-   write(*,*) 'niso=',niso
-   write(*,*) 'striso(1)=',striso(1)
-
-   do ixt=1,ntraciso
-
-     if (ixt.le.niso) then
-        striso_sortie=striso(ixt)
-     else
+   INTEGER :: iiso, izone
+#endif
+
+   modname = 'phyiso_etat0_fichier'
+   CALL msg('3', modname)
+   CALL msg('niso = '//TRIM(int2str(niso)), modname)
+   CALL msg('isoName(1) = '//TRIM(isoName(1)), modname)
+
+   DO ixt = 1, ntraciso
+
+      outiso = isoName(ixt)
+      oldIso = strTail(new2oldH2O(outiso), '_')            !--- Remove "H2O_" from "H2O_<iso>[_<tag>]"
+      ! on lit seulement si ixt<=niso ou si on initialise les traceurs d'après fichier:
 #ifdef ISOTRAC
-        iiso=index_iso(ixt)
-        izone=index_zone(ixt)       
-        striso_sortie=striso(iiso)//strtrac(izone)
-#else
-        write(*,*) 'phyredem 546: ixt,ntraciso=', ixt,ntraciso
-        stop
-#endif
-     endif !if (ixt.le.niso) then
-     write(*,*) 'phyiso_etat0_fichier 16621: ixt,striso_sortie=',ixt,striso_sortie(1:lnblnk(striso_sortie))
-
-           
-      ! on lit seulement si ixt<=niso ou si on initialise les traceurs d'après
-      ! fichier:
+      IF(ixt <= niso .OR. initialisation_isotrac == 0) THEN
+#endif
+      found = phyetat0iso_srf3(xtsnow,      "XTSNOW", "Surface snow", 0.)
+      if (.NOT.found) CALL abort_physic('isotopes_routines_mod', 'phyiso_etat0_fichier 16581: unfound isotopic variable',1)
+      found = phyetat0iso_srf3(fxtevap,     "XTEVAP", "evaporation",  0.)
+      found = phyetat0iso_get2(xtrain_fall, "xtrain_f", "xrain fall", 0.)
+      found = phyetat0iso_get2(xtsnow_fall, "xtsnow_f", "xsnow fall", 0.)
+      found = phyetat0iso_get3(xt_ancien,   "XTANCIEN",  "QANCIEN",   0.)
+      found = phyetat0iso_get3(xtl_ancien,  "XTLANCIEN", "QLANCIEN",  0.)
+      found = phyetat0iso_get3(xts_ancien,  "XTSANCIEN", "QSANCIEN",  0.)
+      found = phyetat0iso_get2(xtrun_off_lic_0, "XTRUNOFFLIC0", "RUNOFFLIC0", 0.)
+      found = phyetat0iso_get3(wake_deltaxt,  "WAKE_DELTAXT", "Delta hum. wake/env",  0.)
+#ifdef ISOVERIF
+      IF(ixt == iso_eau .AND. iso_eau > 0) THEN
+         DO i=1,klon
+            CALL iso_verif_egalite(xtrain_fall(iso_eau,i),rain_fall(i),TRIM(modname)//' 231a')
+            CALL iso_verif_egalite(xtsnow_fall(iso_eau,i),snow_fall(i),TRIM(modname)//' 231b')
+            DO nsrf = 1, nbsrf
+               CALL iso_verif_egalite(fxtevap(iso_eau,i,nsrf),fevap(i,nsrf),TRIM(modname)//' 231c')
+               CALL iso_verif_egalite( xtsnow(iso_eau,i,nsrf), snow(i,nsrf),TRIM(modname)//' 231d')
+            END DO
+         END DO
+      END IF
+      IF(ixt == iso_HDO .AND. iso_HDO > 0) THEN
+         DO k=1,klev
+            DO i=1,klon
+               IF(q_ancien(i,k) > 2e-3) &
+                  CALL iso_verif_aberrant(xt_ancien(iso_hdo,i,k)/q_ancien(i,k),TRIM(modname)//' 312')
+            END DO
+         END DO
+      END IF
+      IF(iso_eau > 0 .AND. ixt == iso_eau) THEN
+         DO i=1,klon
+            IF(iso_verif_egalite_nostop(run_off_lic_0(i),xtrun_off_lic_0(iso_eau,i),TRIM(modname)//' 326') == 1) THEN
+               WRITE(*,*) 'i=',i
+               STOP
+            END IF
+         END DO
+      END IF
+#endif
+      ! ces variables n'ont pas de traceurs:
+      IF(ixt <= niso) THEN
+         found = phyetat0iso_get2(xtsol, "XTSOL", "Surface humidity / bucket", 0.)
+         found = phyetat0iso_get2(Rland_ice, "Rland_ice", "SR land ice", 0.)
+#ifdef ISOVERIF
+
+         DO i=1,klon
+            IF(iso_verif_noNaN_nostop(xtsol(ixt,i),TRIM(modname)//' 95') == 1) THEN
+               WRITE(*,*) 'ixt,i=',ixt,i
+               STOP
+            END IF
+         END DO
+#endif
+      END IF
 #ifdef ISOTRAC
-      if ((ixt.le.niso).or.(initialisation_isotrac.eq.0)) then
-#endif
-
-      found=phyetat0_srf(1,iso_tmp_lonsrf,"XTSNOW"//striso_sortie(1:lnblnk(striso_sortie)), &
-     &     "Surface snow",0.)
-      if (.NOT.found) then
-        CALL abort_physic('isotopes_routines_mod', &
-                'phyiso_etat0_fichier 16581: variable isotopique not found',1)
-      endif
-      xtsnow(ixt,:,:)=iso_tmp_lonsrf(:,:)
-      
-      found=phyetat0_srf(1,iso_tmp_lonsrf,"XTEVAP"//striso_sortie &
-     &   (1:lnblnk(striso_sortie)),"evaporation",0.)
-      fxtevap(ixt,:,:)=iso_tmp_lonsrf(:,:)
-
-      found=phyetat0_get(1,iso_tmp,"xtrain_f"//striso_sortie &
-     &   (1:lnblnk(striso_sortie)),"xrain fall",0.)
-      xtrain_fall(ixt,:)=iso_tmp(:)
-
-      found=phyetat0_get(1,iso_tmp,"xtsnow_f"//striso_sortie &
-     &   (1:lnblnk(striso_sortie)),"snow fall",0.)
-      xtsnow_fall(ixt,:)=iso_tmp(:)
-
-      found=phyetat0_get(klev,iso_tmp_lonlev,"XTANCIEN"//striso_sortie &
-     &       (1:lnblnk(striso_sortie)),"QANCIEN",0.)
-      xt_ancien(ixt,:,:)=iso_tmp_lonlev(:,:)
-
-      found=phyetat0_get(klev,iso_tmp_lonlev,"XTLANCIEN"//striso_sortie &
-     &       (1:lnblnk(striso_sortie)),"QLANCIEN",0.)
-      xtl_ancien(ixt,:,:)=iso_tmp_lonlev(:,:)
-
-      found=phyetat0_get(klev,iso_tmp_lonlev,"XTSANCIEN"//striso_sortie &
-     &       (1:lnblnk(striso_sortie)),"QSANCIEN",0.)
-      xts_ancien(ixt,:,:)=iso_tmp_lonlev(:,:)
-
-
-      found=phyetat0_get(1,iso_tmp,"XTRUNOFFLIC0"//striso_sortie(1:lnblnk(striso_sortie)), &
-     &          "RUNOFFLIC0",0.)  
-      xtrun_off_lic_0(ixt,:)=iso_tmp(:)
-
-
-      found=phyetat0_get(klev,iso_tmp_lonlev,"WAKE_DELTAXT"//striso_sortie &
-     &   (1:lnblnk(striso_sortie)),"Delta hum. wake/env",0.)  
-      wake_deltaxt(ixt,:,:)=iso_tmp_lonlev(:,:)
-
-#ifdef ISOVERIF           
-      if ((ixt.eq.iso_eau).and.(iso_eau.gt.0)) then
-        do i=1,klon
-         call iso_verif_egalite(xtrain_fall(iso_eau,i),rain_fall(i), &
-     &           'phyisoetat0_fichier 231a')
-         call iso_verif_egalite(xtsnow_fall(iso_eau,i),snow_fall(i), &
-     &           'phyisoetat0_fichier 231b')
-         DO nsrf = 1, nbsrf
-         call iso_verif_egalite(fxtevap(iso_eau,i,nsrf),fevap(i,nsrf), &
-     &           'phyisoetat0_fichier 231c')
-         call iso_verif_egalite(xtsnow(iso_eau,i,nsrf),snow(i,nsrf), &
-     &           'phyisoetat0_fichier 231d')
-         enddo !DO nsrf = 1, nbsrf
-        enddo !do i=1,klon        
-      endif !if (iso_eau.gt.0) then  
-        if ((iso_HDO.gt.0).and.(ixt.eq.iso_HDO)) then
-              do k=1,klev
-               do i=1,klon
-                if (q_ancien(i,k).gt.2e-3) then
-                call iso_verif_aberrant(xt_ancien(iso_hdo,i,k) &
-     &           /q_ancien(i,k),'phyisoetat0_fichier 312')
-                endif !if (q_ancien(i,k).gt.2e-3) then
-               enddo !do i=1,klon
-              enddo !do k=1,klev
-      endif !if ((iso_HDO.gt.0).and.(ixt.eq.iso_HDO)) then 
-      if (iso_eau.gt.0) then   
-        do i=1,klon
-          if (iso_verif_egalite_nostop(run_off_lic_0(i), &
-     &           xtrun_off_lic_0(iso_eau,i), &
-     &          'phyiso_etat0_fichier 326').eq.1) then
-            write(*,*) 'i=',i
-            stop
-          endif !if (iso_verif_egalite_nostop(run_off_lic_0(i),
-        enddo !do i=1,klon
-      endif !if (iso_eau.gt.0) then 
-#endif
-
-       ! ces variables n'ont pas de traceurs:
-       if (ixt.le.niso) then
-        found=phyetat0_get(1,iso_tmp,"XTSOL"//striso_sortie(1:lnblnk(striso_sortie)), &
-     &     "Surface hmidity / bucket",0.)  
-        xtsol(ixt,:)=iso_tmp(:)
-
-        found=phyetat0_get(1,iso_tmp,"Rland_ice"//striso_sortie &
-     &     (1:lnblnk(striso_sortie)),"R land ice",0.)
-        Rland_ice(ixt,:)=iso_tmp(:)
-
-#ifdef ISOVERIF
-      do i=1,klon
-          if (iso_verif_noNaN_nostop(xtsol(ixt,i), &
-     &          'phyiso_etat0_fichier 95').eq.1) then
-            write(*,*) 'ixt,i=',ixt,i
-            stop
-          endif       
-      enddo !do i=1,klon
-#endif
-
-       endif
+      END IF ! IF(ixt > niso .OR. initialisation_isotrac == 0))
+#endif
+
+   END DO
 
 #ifdef ISOTRAC
-     endif !if ((ixt.le.niso).or.(initialisation_isotrac.eq.0)) then
-#endif
-
-  enddo !do ixt=1,ntraciso
-
-#ifdef ISOTRAC
-        if (initialisation_isotrac.ne.0) then
-        ! on n'initialise pas d'après le fichier
-        ! l'eau normale est mise dans la zone izone_init
-
-        do ixt=niso+1,ntraciso
-
-             iiso=index_iso(ixt)
-
-             if (index_zone(ixt).eq.izone_init) then
-                do i=1,klon
-                 do nsrf = 1, nbsrf
-                  fxtevap(ixt,i,nsrf)=fxtevap(iiso,i,nsrf)
-                 enddo !do nsrf = 1, nbsrf
-                 xtsnow_fall(ixt,i)=xtsnow_fall(iiso,i)
-                 xtrain_fall(ixt,i)=xtrain_fall(iiso,i)
-                 do k=1,klev
-                   xt_ancien(ixt,i,k)=xt_ancien(iiso,i,k)
-                   xtl_ancien(ixt,i,k)=xtl_ancien(iiso,i,k)
-                   xts_ancien(ixt,i,k)=xts_ancien(iiso,i,k)
-                   wake_deltaxt(ixt,i,k)= wake_deltaxt(iiso,i,k)    
-                 enddo
-                enddo !do i=1,klon
-             else !if (index_zone(ixt).eq.izone_init) then
-                do i=1,klon
-                 do nsrf = 1, nbsrf
-                  fxtevap(ixt,i,nsrf)=0.0
-                 enddo !do nsrf = 1, nbsrf
-                 xtsnow_fall(ixt,i)=0.0
-                 xtrain_fall(ixt,i)=0.0
-                 do k=1,klev
-                   xt_ancien(ixt,i,k)=0.0
-                   xtl_ancien(ixt,i,k)=0.0
-                   xts_ancien(ixt,i,k)=0.0
-                 enddo
-                enddo !do i=1,klon
-             endif !if (index_zone(ixt).eq.izone_init) then
-
-         enddo  !do ixt=1,niso
-      endif !if (initialisation_isotrac.eq.0) then
-
-
-#ifdef ISOVERIF
-        DO nsrf = 1, nbsrf
-         do i=1,klon
-               call iso_verif_traceur(fxtevap(1,i,nsrf), &
-     &                   'phyiso_etat0_fichier 426')
-         enddo !do i=1,klon 
-        enddo !DO nsrf = 1, nbsrf
-        do i=1,klon
-           call iso_verif_traceur(xtrain_fall(1,i), &
-     &                   'phyiso_etat0_fichier 466')
-           call iso_verif_traceur(xtsnow_fall(1,i), &
-     &                   'phyiso_etat0_fichier 468')
-        enddo !do i=1,klon 
-        do k=1,klev
-          do i=1,klon
-               call iso_verif_traceur(xt_ancien(1,i,k), &
-     &                   'phyiso_etat0_fichier 591')
-          enddo !do i=1,klon
-        enddo !do k=1,klev             
+   IF(initialisation_isotrac /= 0) THEN
+      ! On n'initialise pas d'apres le fichier. L'eau normale est mise dans la zone izone_init
+      DO ixt=niso+1,ntraciso
+         iiso=index_iso(ixt)
+         IF(index_zone(ixt) == izone_init) THEN
+            DO i = 1, klon
+               fxtevap(ixt,i,1:nbsrf) = fxtevap(iiso,i,1:nbsrf)
+               xtsnow_fall(ixt,i) = xtsnow_fall(iiso,i)
+               xtrain_fall(ixt,i) = xtrain_fall(iiso,i)
+               DO k = 1, klev
+                  xt_ancien   (ixt,i,k) = xt_ancien   (iiso,i,k)
+                  xtl_ancien  (ixt,i,k) = xtl_ancien  (iiso,i,k)
+                  xts_ancien  (ixt,i,k) = xts_ancien  (iiso,i,k)
+                  wake_deltaxt(ixt,i,k) = wake_deltaxt(iiso,i,k)    
+               END DO
+            END DO
+         ELSE
+            DO i = 1, klon
+               fxtevap(ixt,i,1:nbsrf)=0.0
+               xtsnow_fall(ixt,i)=0.0
+               xtrain_fall(ixt,i)=0.0
+               xt_ancien (ixt,i,1:klev) = 0.0
+               xtl_ancien(ixt,i,1:klev) = 0.0
+               xts_ancien(ixt,i,1:klev) = 0.0
+            END DO
+         END IF
+      END DO
+   END IF
+
+#ifdef ISOVERIF
+   DO nsrf = 1, nbsrf
+      DO i = 1, klon
+         CALL iso_verif_traceur(fxtevap(1,i,nsrf), 'phyiso_etat0_fichier 426')
+      END DO
+   END DO
+   DO i=1,klon
+      CALL iso_verif_traceur(xtrain_fall(1,i), 'phyiso_etat0_fichier 466')
+      CALL iso_verif_traceur(xtsnow_fall(1,i), 'phyiso_etat0_fichier 468')
+   END DO
+   DO k = 1, klev
+      DO i = 1, klon
+         CALL iso_verif_traceur(xt_ancien(1,i,k), 'phyiso_etat0_fichier 591')
+      END DO
+   END DO
 #endif 
         ! endif ISOVERIF       
@@ -16829,9 +16671,43 @@
         ! endif ISOTRAC      
 
-! on ferme le fichier
-!      CALL close_startphy
-! déjà fermé dans phyetat0
+CONTAINS
+
+LOGICAL FUNCTION phyetat0iso_get2(field, pref, descr, default) RESULT(lFound)
+  REAL,             INTENT(INOUT) :: field(:,:)
+  CHARACTER(LEN=*), INTENT(IN)    :: pref, descr
+  REAL,             INTENT(IN)    :: default
+  REAL :: iso_tmp(klon)
+  nam(1) = TRIM(pref)//TRIM(outiso)
+  nam(2) = TRIM(pref)//TRIM(oldIso)
+  lFound = phyetat0_get(iso_tmp, nam, descr, default)
+  field(ixt,:) = iso_tmp
+END FUNCTION phyetat0iso_get2
+
+
+LOGICAL FUNCTION phyetat0iso_get3(field, pref, descr, default) RESULT(lFound)
+  REAL,             INTENT(INOUT) :: field(:,:,:)
+  CHARACTER(LEN=*), INTENT(IN)    :: pref, descr
+  REAL,             INTENT(IN)    :: default
+  REAL :: iso_tmp_lonlev(klon,klev)
+  nam(1) = TRIM(pref)//TRIM(outiso)
+  nam(2) = TRIM(pref)//TRIM(oldIso)
+  lFound = phyetat0_get(iso_tmp_lonlev, nam, descr, default)
+  field(ixt,:,:) = iso_tmp_lonlev(:,:)
+END FUNCTION phyetat0iso_get3
+
+LOGICAL FUNCTION phyetat0iso_srf3(field, pref, descr, default) RESULT(lFound)
+  REAL,             INTENT(INOUT) :: field(:,:,:)
+  CHARACTER(LEN=*), INTENT(IN)    :: pref, descr
+  REAL,             INTENT(IN)    :: default
+  REAL :: iso_tmp_lonsrf(klon,nbsrf)
+  nam(1) = TRIM(pref)//TRIM(outiso)
+  nam(2) = TRIM(pref)//TRIM(oldIso)
+  lFound = phyetat0_srf(iso_tmp_lonsrf, nam, descr, default)
+  field(ixt,:,:) = iso_tmp_lonsrf
+END FUNCTION phyetat0iso_srf3
 
         end subroutine phyiso_etat0_fichier
+
+
 
 
@@ -16849,5 +16725,4 @@
      &           d_xt_decroiss, &
      &           xt_seri)
-        USE infotrac_phy, only: ntraciso
         USE isotopes_mod, only: iso_HTO,ok_prod_nucl_tritium
         USE dimphy, only: klon,klev
@@ -18371,5 +18246,4 @@
 !     &                         prod_nucl_HTO)
 
-        USE infotrac_phy, only: ntraciso
         use isotopes_mod, only: nessai, lat_nucl, lon_nucl, &
 &               zmin_nucl, zmax_nucl, HTO_nucl
@@ -18593,5 +18467,4 @@
      &                                paprs, &
      &                                prod_nucl)
-        USE infotrac_phy, only: ntraciso
         USE isotopes_mod, ONLY: iso_HTO
         use geometry_mod, only: cell_area
@@ -18739,5 +18612,4 @@
      &           tcond,zfice,zxtice,zxtliq)
 
-    USE infotrac_phy, ONLY: ntraciso,niso,index_trac,ntraceurs_zone
     USE isotopes_mod, ONLY: iso_eau,iso_HDO,essai_convergence, &
 &       bidouille_anti_divergence,ridicule
@@ -18869,5 +18741,4 @@
      &           tcond,zfice,zxtice,zxtliq,n)
 
-    USE infotrac_phy, ONLY: ntraciso,niso,index_trac,ntraceurs_zone
     USE isotopes_mod, ONLY: iso_eau,iso_HDO,iso_O18,bidouille_anti_divergence, &
 &       ridicule
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/isotopes_verif_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/isotopes_verif_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/isotopes_verif_mod.F90	(revision 4446)
@@ -6,6 +6,7 @@
 !use isotopes_mod, ONLY: 
 !#ifdef ISOTRAC
-!use isotrac_mod, ONLY: 
+!   USE isotrac_mod, ONLY: nzone
 !#endif
+USE infotrac_phy, ONLY: ntraciso=>ntiso, niso, itZonIso, nzone
 implicit none
 save
@@ -93,5 +94,4 @@
         SUBROUTINE iso_verif_init()
         use ioipsl_getin_p_mod, ONLY : getin_p
-        !USE infotrac_phy, ONLY: use_iso
         use isotopes_mod, ONLY: iso_O17, iso_O18, iso_HDO
         implicit none
@@ -196,5 +196,4 @@
 
         subroutine iso_verif_aberrant(R,err_msg)
-        !USE infotrac_phy, ONLY: use_iso
         use isotopes_mod, ONLY: ridicule, iso_HDO
         implicit none
@@ -227,5 +226,4 @@
 
         subroutine iso_verif_aberrant_encadre(R,err_msg)
-        !use infotrac_phy, ONLY: use_iso
         use isotopes_mod, ONLY: ridicule, iso_HDO
         implicit none
@@ -263,5 +261,4 @@
 
         subroutine iso_verif_aberrant_choix(xt,q,qmin,deltaDmax,err_msg)
-        !use infotrac_phy, ONLY: use_iso
         use isotopes_mod, ONLY: iso_HDO
         implicit none
@@ -298,5 +295,4 @@
 
         function iso_verif_aberrant_nostop(R,err_msg)
-        !use infotrac_phy, ONLY: use_iso
         use isotopes_mod, ONLY: ridicule,iso_HDO
         implicit none
@@ -330,5 +326,4 @@
 
         function iso_verif_aberrant_enc_nostop(R,err_msg)
-        !use infotrac_phy, ONLY: use_iso
         use isotopes_mod, ONLY: ridicule,iso_HDO
         implicit none
@@ -366,5 +361,4 @@
      &            qmin,deltaDmax,err_msg)
 
-        !use infotrac_phy, ONLY: use_iso
         use isotopes_mod, ONLY: iso_HDO
         implicit none
@@ -428,5 +422,4 @@
         function iso_verif_aberrant_enc_choix_nostop(xt,q,   &
      &            qmin,deltaDmax,err_msg)
-        !use infotrac_phy, ONLY: use_iso
         use isotopes_mod, ONLY: iso_HDO
         implicit none
@@ -1065,5 +1058,4 @@
         ! **********
         function deltaD(R)
-        !use infotrac_phy, ONLY: use_iso
         USE isotopes_mod, ONLY: tnat,iso_HDO
         implicit none
@@ -1082,5 +1074,4 @@
         ! **********
         function deltaO(R)
-        !use infotrac_phy, ONLY: use_iso
         USE isotopes_mod, ONLY: tnat,iso_O18
         implicit none
@@ -1098,5 +1089,4 @@
         ! **********
         function dexcess(RD,RO)
-        !use infotrac_phy, ONLY: use_iso
         USE isotopes_mod, ONLY: tnat,iso_O18,iso_HDO
         implicit none
@@ -1138,5 +1128,4 @@
          ! **********
         function o17excess(R17,R18)
-        !use infotrac_phy, ONLY: use_iso
         USE isotopes_mod, ONLY: tnat,iso_O18,iso_O17
         implicit none
@@ -1160,5 +1149,4 @@
      &           xt,q,err_msg,ni,n,m)
         
-        !use infotrac_phy, ONLY: use_iso
         USE isotopes_mod, ONLY: iso_eau
           implicit none
@@ -1212,5 +1200,4 @@
      &           xt,q,err_msg,ni,n)
 
-        !use infotrac_phy, ONLY: use_iso
         USE isotopes_mod, ONLY: iso_eau
         implicit none
@@ -1296,5 +1283,4 @@
         subroutine iso_verif_aberrant_vect2D( &
      &           xt,q,err_msg,ni,n,m)
-        !use infotrac_phy, ONLY: use_iso
         use isotopes_mod, ONLY: ridicule,tnat,iso_HDO
           implicit none
@@ -1345,5 +1331,4 @@
      &           xt,q,err_msg,ni,n,m)
 
-        !use infotrac_phy, ONLY: use_iso
         use isotopes_mod, ONLY: ridicule,tnat,iso_HDO
           implicit none
@@ -1399,5 +1384,4 @@
      &           xt,q,err_msg,ni,n,m)
 
-        !use infotrac_phy, ONLY: use_iso
         use isotopes_mod, ONLY: ridicule,tnat,iso_HDO
           implicit none
@@ -1450,5 +1434,4 @@
      &           xt,q,err_msg,ni,n,m,deltaDmax)
 
-        !use infotrac_phy, ONLY: use_iso
         use isotopes_mod, ONLY: ridicule,tnat,iso_HDO
           implicit none
@@ -1501,5 +1484,4 @@
      &           xt,q,err_msg,ni,n,m)
 
-        !use infotrac_phy, ONLY: use_iso
         use isotopes_mod, ONLY: ridicule,tnat,iso_HDO,iso_O18
           implicit none
@@ -1766,5 +1748,4 @@
      &           xt,q,err_msg,ni,n,m,ib,ie)
 
-        !use infotrac_phy, ONLY: use_iso
         use isotopes_mod, ONLY: ridicule,tnat,iso_HDO
           implicit none
@@ -1817,5 +1798,4 @@
      &           xt,q,err_msg,ni,n,m,ib,ie)
         
-        !use infotrac_phy, ONLY: use_iso
         USE isotopes_mod, ONLY: iso_eau
           implicit none
@@ -1863,5 +1843,4 @@
       function iso_verif_traceur_choix_nostop(x,err_msg, &
      &       errmax,errmaxrel,ridicule_trac,deltalimtrac)
-        USE infotrac_phy, ONLY: ntraciso
         use isotopes_mod, ONLY: iso_HDO
         implicit none
@@ -1915,5 +1894,4 @@
         function iso_verif_tracnps_choix_nostop(x,err_msg, &
      &       errmax,errmaxrel,ridicule_trac,deltalimtrac)
-        USE infotrac_phy, ONLY: ntraciso
         USE isotopes_mod, ONLY: iso_HDO
         implicit none
@@ -1961,7 +1939,5 @@
 
         function iso_verif_tracpos_choix_nostop(x,err_msg,seuil)
-        use infotrac_phy, ONLY: ntraciso,niso
-        use isotrac_mod, only: index_iso,strtrac,index_zone
-        use isotopes_mod, only: striso
+        use isotopes_mod, only: isoName
         implicit none
 
@@ -1982,8 +1958,6 @@
 
        do ixt=niso+1,ntraciso
-          iiso=index_iso(ixt)
           if (iso_verif_positif_choix_nostop(x(ixt),seuil,err_msg// &
-     &           ', verif positif, iso'//striso(iiso) &
-     &           //strtrac(index_zone(ixt))).eq.1) then
+     &           ', verif positif, iso'//TRIM(isoName(ixt))).eq.1) then
             iso_verif_tracpos_choix_nostop=1
           endif
@@ -1994,7 +1968,5 @@
 
         function iso_verif_traceur_noNaN_nostop(x,err_msg)
-        use infotrac_phy, ONLY: ntraciso,niso
-        use isotrac_mod, only: index_iso
-        use isotopes_mod, only: striso
+        use isotopes_mod, only: isoName
         implicit none
 
@@ -2015,8 +1987,7 @@
 
         do ixt=niso+1,ntraciso
-          iiso=index_iso(ixt)
 !          write(*,*) 'iso_verif_traceurs 154: iiso,ixt=',iiso,ixt
           if (iso_verif_noNaN_nostop(x(ixt),err_msg// &
-     &           ', verif trac no NaN, iso'//striso(iiso)) &
+     &           ', verif trac no NaN, iso'//TRIM(isoName(ixt))) &
      &           .eq.1) then
             iso_verif_traceur_noNaN_nostop=1
@@ -2029,7 +2000,5 @@
      &           errmaxin,errmaxrelin)
 
-        use infotrac_phy, ONLY: index_trac,ntraciso,niso
-        use isotopes_mod, ONLY: ridicule,striso
-        use isotrac_mod, only: ntraceurs_zone
+        use isotopes_mod, ONLY: ridicule,isoName
         ! on vérifie juste bilan de masse
         implicit none
@@ -2053,11 +2022,12 @@
 
           xtractot=0.0
-          do izone=1,ntraceurs_zone  
-            ixt=index_trac(izone,iiso) 
+          do izone=1,nzone  
+            ixt=itZonIso(izone,iiso) 
             xtractot=xtractot+x(ixt)
-          enddo !do izone=1,ntraceurs_zone
+          enddo
 
           if (iso_verif_egalite_choix_nostop(xtractot,x(iiso), &
-     &        err_msg//', verif trac egalite, iso '//striso(iiso), &
+     &        err_msg//', verif trac egalite, iso '// &
+     &        TRIM(isoName(iiso)), &
      &        errmaxin,errmaxrelin).eq.1) then
             write(*,*) 'iso_verif_traceur 202: x=',x
@@ -2070,5 +2040,5 @@
      &           (abs(x(iiso)).gt.ridicule)) then
             write(*,*) err_msg,', verif masse traceurs, iso ', &
-     &          striso(iiso)
+     &          TRIM(isoName(iiso))
             write(*,*) 'iso_verif_traceur 209: x=',x
 !            iso_verif_tracm_choix_nostop=1
@@ -2082,7 +2052,6 @@
      &           ridicule_trac,deltalimtrac)
 
-        use infotrac_phy, ONLY: index_trac,ntraciso
         USE isotopes_mod, ONLY: iso_eau, iso_HDO
-        use isotrac_mod, only: strtrac,ntraceurs_zone
+        use isotrac_mod, only: strtrac
         ! on vérifie juste deltaD
         implicit none
@@ -2103,7 +2072,7 @@
 
         if ((iso_eau.gt.0).and.(iso_HDO.gt.0)) then
-        do izone=1,ntraceurs_zone
-             ieau=index_trac(izone,iso_eau)
-             ixt=index_trac(izone,iso_HDO)
+        do izone=1,nzone
+             ieau=itZonIso(izone,iso_eau)
+             ixt=itZonIso(izone,iso_HDO)
 
              if (iso_verif_aberrant_choix_nostop(x(ixt),x(ieau), &
@@ -2118,5 +2087,5 @@
 !     :           //strtrac(izone))
 !             endif
-        enddo !do izone=1,ntraceurs_zone
+        enddo !do izone=1,nzone
        endif ! if ((iso_eau.gt.0).and.(iso_HDO.gt.0)) then
 
@@ -2124,5 +2093,4 @@
 
 INTEGER FUNCTION iso_verif_tag17_q_deltaD_chns(x,err_msg) RESULT(res)
-  USE infotrac_phy, ONLY: index_trac, ntraciso
   USE isotopes_mod, ONLY: iso_HDO, iso_eau, ridicule
   USE isotrac_mod,  ONLY: nzone_temp, option_traceurs
@@ -2135,6 +2103,6 @@
   !--- Check whether * deltaD(highest tagging layer) < 200 permil
   !                  * q <
-  ieau=index_trac(nzone_temp,iso_eau)
-  ixt=index_trac(nzone_temp,iso_HDO)
+  ieau=itZonIso(nzone_temp,iso_eau)
+  ixt=itZonIso(nzone_temp,iso_HDO)
   IF(x(ieau)>ridicule) THEN
     IF(iso_verif_positif_nostop(-200.0-deltaD(x(ixt)/x(ieau)), err_msg//': deltaDt05 trop fort')==1) THEN
@@ -2147,5 +2115,5 @@
   !--- Check whether q is small ; then, qt01 < 10%
   IF(x(iso_eau)<2.0e-3) THEN
-    ieau1= index_trac(1,iso_eau)
+    ieau1= itZonIso(1,iso_eau)
     IF(iso_verif_positif_nostop(0.1-(x(ieau1)/x(iso_eau)),err_msg//': qt01 trop abondant')==1) THEN
       res=1; write(*,*) 'x=',x
@@ -2156,5 +2124,4 @@
 SUBROUTINE iso_verif_trac17_q_deltaD(x,err_msg)
   USE isotrac_mod,  ONLY: nzone_temp, option_traceurs
-  USE infotrac_phy, ONLY: ntraciso
   IMPLICIT NONE
   REAL,             INTENT(IN) :: x(ntraciso)
@@ -2167,5 +2134,4 @@
 
       subroutine iso_verif_traceur(x,err_msg)
-        USE infotrac_phy, ONLY: ntraciso
         use isotrac_mod, only: ridicule_trac
         implicit none
@@ -2195,5 +2161,4 @@
       subroutine iso_verif_traceur_retourne3D(x,n1,n2,n3, &
      &           i1,i2,i3,err_msg)
-        USE infotrac_phy, ONLY: ntraciso
         use isotrac_mod, only: ridicule_trac
 
@@ -2228,5 +2193,4 @@
         subroutine iso_verif_traceur_retourne4D(x,n1,n2,n3,n4, &
      &           i1,i2,i3,i4,err_msg)
-        USE infotrac_phy, ONLY: ntraciso
         use isotrac_mod, only: ridicule_trac
 
@@ -2262,5 +2226,4 @@
       subroutine iso_verif_traceur_retourne2D(x,n1,n2, &
      &           i1,i2,err_msg)
-        USE infotrac_phy, ONLY: ntraciso
         use isotrac_mod, only: ridicule_trac
         implicit none
@@ -2293,5 +2256,4 @@
 
         subroutine iso_verif_traceur_vect(x,n,m,err_msg)
-        USE infotrac_phy, ONLY: ntraciso
         USE isotopes_mod, ONLY: iso_HDO
         implicit none
@@ -2329,5 +2291,4 @@
 
         subroutine iso_verif_tracnps_vect(x,n,m,err_msg)
-        USE infotrac_phy, ONLY: ntraciso
         USE isotopes_mod, ONLY: iso_HDO
         implicit none
@@ -2363,5 +2324,4 @@
 
         subroutine iso_verif_traceur_noNaN_vect(x,n,m,err_msg)
-        USE infotrac_phy, ONLY: ntraciso,niso
         implicit none
        
@@ -2407,7 +2367,5 @@
         subroutine iso_verif_trac_masse_vect(x,n,m,err_msg, &
      &            errmax,errmaxrel)
-        USE infotrac_phy, ONLY: index_trac,ntraciso,niso
-        use isotopes_mod, only: striso
-        use isotrac_mod, only: ntraceurs_zone
+        use isotopes_mod, only: isoName
         implicit none
        
@@ -2430,8 +2388,8 @@
           xtractot(i,j)=0.0
           xiiso(i,j)=x(iiso,i,j)
-          do izone=1,ntraceurs_zone  
-            ixt=index_trac(izone,iiso) 
+          do izone=1,nzone
+            ixt=itZonIso(izone,iiso) 
             xtractot(i,j)=xtractot(i,j)+x(ixt,i,j)            
-          enddo !do izone=1,ntraceurs_zone
+          enddo !do izone=1,nzone
          enddo !do i=1,n
         enddo !do j=1,m
@@ -2440,5 +2398,6 @@
         call iso_verif_egalite_std_vect( &
      &           xtractot,xiiso, &
-     &           err_msg//', verif trac egalite, iso '//striso(iiso), &
+     &           err_msg//', verif trac egalite, iso ' &
+     &           //TRIM(isoName(iiso)), &
      &           n,m,errmax,errmaxrel)
         enddo !do iiso=1,niso
@@ -2447,7 +2406,6 @@
 
         subroutine iso_verif_tracdd_vect(x,n,m,err_msg) 
-        use infotrac_phy, only: index_trac,ntraciso,niso
         use isotopes_mod, only: iso_HDO,iso_eau
-        use isotrac_mod, only: strtrac,ntraceurs_zone
+        use isotrac_mod, only: strtrac
         implicit none
        
@@ -2464,8 +2422,8 @@
 
        if (iso_HDO.gt.0) then
-        do izone=1,ntraceurs_zone
-          ieau=index_trac(izone,iso_eau)
+        do izone=1,nzone
+          ieau=itZonIso(izone,iso_eau)
           do iiso=1,niso
-           ixt=index_trac(izone,iiso)
+           ixt=itZonIso(izone,iiso)
            do j=1,m
             do i=1,n
@@ -2484,5 +2442,5 @@
      &           xiiso,xeau,err_msg//strtrac(izone),niso,n,m, &
      &           deltalimtrac)
-         enddo !do izone=1,ntraceurs_zone
+         enddo !do izone=1,nzone
         endif !if (iso_HDO.gt.0) then
 
@@ -2490,5 +2448,4 @@
 
         subroutine iso_verif_tracpos_vect(x,n,m,err_msg,seuil) 
-        USE infotrac_phy, ONLY: ntraciso,niso
         implicit none
 
@@ -2532,5 +2489,4 @@
 
         subroutine iso_verif_tracnps(x,err_msg)
-        USE infotrac_phy, ONLY: ntraciso
         use isotrac_mod, only: ridicule_trac
 
@@ -2559,5 +2515,4 @@
 
         subroutine iso_verif_tracpos_choix(x,err_msg,seuil)
-        USE infotrac_phy, ONLY: ntraciso
         implicit none
         ! vérifier des choses sur les traceurs
@@ -2585,5 +2540,4 @@
         subroutine iso_verif_traceur_choix(x,err_msg, &
      &       errmax,errmaxrel,ridicule_trac_loc,deltalimtrac)
-        USE infotrac_phy, ONLY: ntraciso
         implicit none
         ! vérifier des choses sur les traceurs
@@ -2608,5 +2562,4 @@
 
         function iso_verif_traceur_nostop(x,err_msg)
-        USE infotrac_phy, ONLY: ntraciso
         use isotrac_mod, only: ridicule_trac
         !use isotopes_verif, only: errmax,errmaxrel,deltalimtrac
@@ -2637,5 +2590,4 @@
 
       subroutine iso_verif_traceur_justmass(x,err_msg)
-        USE infotrac_phy, ONLY: ntraciso
         implicit none
         ! on vérifie que noNaN et masse
@@ -2666,5 +2618,4 @@
 
         function iso_verif_traceur_jm_nostop(x,err_msg)
-        USE infotrac_phy, ONLY: ntraciso
         implicit none
         ! on vérifie que noNaN et masse
@@ -2699,5 +2650,4 @@
 
         subroutine iso_verif_tag17_q_deltaD_vect(x,n,m,err_msg)
-        USE infotrac_phy, ONLY: index_trac,ntraciso
         USE isotopes_mod, ONLY: tnat,iso_eau, ridicule,iso_HDO
         use isotrac_mod, only: option_traceurs,nzone_temp
@@ -2719,7 +2669,7 @@
         ! verifier que deltaD du tag de la couche la plus haute <
         ! 200 permil, et vérifier que son q est inférieur à 
-        ieau=index_trac(nzone_temp,iso_eau)
-        ixt=index_trac(nzone_temp,iso_HDO)
-        ieau1=index_trac(1,iso_eau)
+        ieau=itZonIso(nzone_temp,iso_eau)
+        ixt=itZonIso(nzone_temp,iso_HDO)
+        ieau1=itZonIso(1,iso_eau)
         do i=1,n
          do k=1,m
@@ -2759,5 +2709,4 @@
 
         subroutine iso_verif_tag17_q_deltaD_vect_ret3D(x,n,m,nq,err_msg)
-        USE infotrac_phy, ONLY: index_trac,ntraciso
         USE isotopes_mod, ONLY: tnat,iso_eau,iso_HDO,ridicule
         use isotrac_mod, only: option_traceurs,nzone_temp
@@ -2779,7 +2728,7 @@
         ! verifier que deltaD du tag de la couche la plus haute <
         ! 200 permil, et vérifier que son q est inférieur à 
-        ieau=index_trac(nzone_temp,iso_eau)
-        ixt=index_trac(nzone_temp,iso_HDO)
-        ieau1=index_trac(1,iso_eau)
+        ieau=itZonIso(nzone_temp,iso_eau)
+        ixt=itZonIso(nzone_temp,iso_HDO)
+        ieau1=itZonIso(1,iso_eau)
         do iq=1,nq
         do i=1,n
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/isotrac_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/isotrac_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/isotrac_mod.F90	(revision 4446)
@@ -1,104 +1,27 @@
 #ifdef ISO
 #ifdef ISOTRAC
-! $Id: $
 
 MODULE isotrac_mod
-use infotrac_phy, ONLY: niso,ntraciso,ntraceurs_zone
-use isotopes_mod, only: ridicule
-
-IMPLICIT NONE
-SAVE
-
-! contient toutes les variables traceurs isotopiques + les routines specifiquement
-! traceurs isotopiques
-
-      real ridicule_trac
-      parameter (ridicule_trac=ridicule*1e4)
-
-integer, save ::  option_traceurs 
-integer, save ::  ntraceurs_zone_opt ! ntraceurs_zone propre à l'option
-! on vérifie que ça correspond bien à ntraceurs_zone d'infotrac
-integer, save ::  ntraceurs_zoneOR
-!$OMP THREADPRIVATE(option_traceurs,ntraceurs_zone_opt,ntraceurs_zoneOR)
-integer, save ::  initialisation_isotrac
-                ! 1 pour idéalisé
-                ! 0 pour lecture dans fichier
-!$OMP THREADPRIVATE(initialisation_isotrac)
-
-! variables spécifiques aux différentes options, mais necessaires au
-! calcul du nombre de zones de traceurs
-! si option=3
-integer, save :: use_bassin_atlantic
-!$OMP THREADPRIVATE(use_bassin_atlantic)
-integer, save :: use_bassin_medit
-!$OMP THREADPRIVATE(use_bassin_medit)
-integer, save :: use_bassin_indian
-!$OMP THREADPRIVATE(use_bassin_indian)
-integer, save :: use_bassin_austral
-!$OMP THREADPRIVATE(use_bassin_austral)
-integer, save :: use_bassin_pacific
-!$OMP THREADPRIVATE(use_bassin_pacific)
-integer, save :: use_bassin_merarabie
-!$OMP THREADPRIVATE(use_bassin_merarabie)
-integer, save :: use_bassin_golfebengale
-!$OMP THREADPRIVATE(use_bassin_golfebengale)
-integer, save :: use_bassin_indiansud
-!$OMP THREADPRIVATE(use_bassin_indiansud)
-integer, save :: use_bassin_tropics
-!$OMP THREADPRIVATE(use_bassin_tropics)
-integer, save :: use_bassin_midlats
-!$OMP THREADPRIVATE(use_bassin_midlats)
-integer, save :: use_bassin_hauteslats
-!$OMP THREADPRIVATE(use_bassin_hauteslats)
-integer, save :: bassin_atlantic
-!$OMP THREADPRIVATE(bassin_atlantic)
-integer, save :: bassin_medit
-!$OMP THREADPRIVATE(bassin_medit)
-integer, save :: bassin_indian
-!$OMP THREADPRIVATE(bassin_indian)
-integer, save :: bassin_austral
-!$OMP THREADPRIVATE(bassin_austral)
-integer, save :: bassin_pacific
-!$OMP THREADPRIVATE(bassin_pacific)
-integer, save :: bassin_merarabie
-!$OMP THREADPRIVATE(bassin_merarabie)
-integer, save :: bassin_golfebengale
-!$OMP THREADPRIVATE(bassin_golfebengale)
-integer, save :: bassin_indiansud
-!$OMP THREADPRIVATE(bassin_indiansud)
-integer, save :: bassin_tropics
-!$OMP THREADPRIVATE(bassin_tropics)
-integer, save :: bassin_midlats
-!$OMP THREADPRIVATE(bassin_midlats)
-integer, save :: bassin_hauteslats
-!$OMP THREADPRIVATE(bassin_hauteslats)
-! si option=4
-integer nzone_temp
-parameter (nzone_temp=1)
-real, save :: zone_temp1,zone_tempf,zone_tempa  
-!$OMP THREADPRIVATE(zone_temp1,zone_tempf,zone_tempa)
-! si option 14
-integer nzone_lat
-parameter (nzone_lat=4)
-integer nzone_pres
-parameter (nzone_pres=3)
-real, save :: zone_pres1,zone_presf,zone_presa 
-!$OMP THREADPRIVATE(zone_pres1,zone_presf,zone_presa) 
-real, save :: dlattag,lattag_min
-!$OMP THREADPRIVATE(dlattag,lattag_min)
-
-
-! option 1: on trace evap ocean et continent séparement  
+  USE infotrac_phy,      ONLY: niso, ntiso, nzone
+  USE readTracFiles_mod, ONLY: delPhase
+  USE isotopes_mod,      ONLY: ridicule, get_in
+
+  IMPLICIT NONE
+  SAVE
+
+!=== CONTENT: ALL THE ISOTOPIC TRACERS RELATED VARIABLES ===
+!
+! option 1: on trace evap ocean et continent separement  
 ! option 2: on trace evap ocean, continent et evap precip
-! option 3: on trace evap différents bassins océaniques 
-!       + continents + résidu
-!       attention, choisir dans ce cas les bassins océaniques
+! option 3: on trace evap differents bassins oceaniques 
+!       + continents + residu
+!       attention, choisir dans ce cas les bassins oceaniques
 !       dans iso_traceurs_opt3F90.h 
-! option 4: tracage par température minimale
-!       dans ce cas, on définit des bins dans iso_traceurs_opt4.h
-! option 5: pour AMMA: on taggue résidu/AEJ/flux mousson/Harmattan
+! option 4: tracage par temperature minimale
+!       dans ce cas, on definit des bins dans iso_traceurs_opt4.h
+! option 5: pour AMMA: on taggue residu/AEJ/flux mousson/Harmattan
 ! option 6: taggage des ddfts
-! option 7: pour Sandrine: taggage de la vapeur à 700hPa pour omega500<-20 TODO
-! option 8: pour Sandrine: taggage de la vapeur entre 950 et 800hPa, omega de 0 à 25 hPa et de l'évaoration en omega<-20. TODO
+! option 7: pour Sandrine: taggage de la vapeur a 700hPa pour omega500<-20 TODO
+! option 8: pour Sandrine: taggage de la vapeur entre 950 et 800hPa, omega de 0 a 25 hPa et de l'evaoration en omega<-20. TODO
 ! option 9: taggage du condensat et de la revap precip
 ! option 10: taggage evap oce, transpiration et evaporation
@@ -107,914 +30,645 @@
 ! option 12: taggage evap oce, sol nu, canop et reste evap cont. 
 ! A utiliser quand on couple avec ORCHIDEE
-! option 13: taggage température minimale + revap precip
-! option 14: taggage lat et altitude de dernière saturation (niveaux de pression) + evap surf
+! option 13: taggage temperature minimale + revap precip
+! option 14: taggage lat et altitude de derniere saturation (niveaux de pression) + evap surf
 ! otion 15: taggage irrigation
 ! option 16: taggage precip selon saisons et fonte neige: seulement pour ORCHIDEE
-! option 17: taggage température minimum de condensation directement dans la convection et la cond LS, + evap sfc, condensat et precipitation
+! option 17: taggage temperature minimum de condensation directement dans la convection et la cond LS, + evap sfc, condensat et precipitation
 ! option 18: idem 17 mais on tague qsmin au lieu de Tmin
 ! option 19: on tag vap residuelle, vap residuelle dans ddfts, sfc, cond, rev
 ! option 20: on taggue vapeur tropicale vs vapeur extratropicale
 ! option 21: taggage de 2 boites 3D: extratropiques (>35°) et UT tropicale (15-15°, > 500hPa)
-! option 22: tagage de la vapeur proccessée dans les zones très convectives
+! option 22: tagage de la vapeur proccessee dans les zones tres convectives
                 
-        ! ces variables sont initialisées dans traceurs_init
+   !--- nzone_opt (value of nzone for the selected option) must be equal to nzone as defined in onfotrac
+   REAL, PARAMETER :: ridicule_trac = ridicule * 1e4
+   INTEGER, SAVE :: option_traceurs, nzone_opt, nzoneOR
+!$OMP THREADPRIVATE(option_traceurs,nzone_opt,nzoneOR)
+   INTEGER, SAVE :: initialisation_isotrac
+!$OMP THREADPRIVATE(initialisation_isotrac)      
+                ! 1 pour idealise
+                ! 0 pour lecture dans fichier
+
+   !=== VARIABLES SPECIFIC TO THE SELECTED OPTION, BUT NEEDED FOR THE COMPUTATION OF THE NUMBER OF ZONES ; TO BE INITIALIZED IN traceurs_init
+
+   !--- option 3
+   LOGICAL, SAVE :: use_bassin_Austral, use_bassin_Atlantic, use_bassin_MidLats, use_bassin_SouthIndian, use_bassin_MerArabie
+!$OMP THREADPRIVATE(use_bassin_Austral, use_bassin_Atlantic, use_bassin_MidLats, use_bassin_SouthIndian, use_bassin_MerArabie)
+   INTEGER, SAVE ::     bassin_Austral,     bassin_Atlantic,     bassin_MidLats,     bassin_SouthIndian,     bassin_MerArabie
+!$OMP THREADPRIVATE(    bassin_Austral,     bassin_Atlantic,     bassin_MidLats,     bassin_SouthIndian,     bassin_MerArabie)
+   LOGICAL, SAVE :: use_bassin_Pacific, use_bassin_Indian,   use_bassin_Tropics, use_bassin_BengalGolf,  use_bassin_HighLats, use_bassin_Medit
+!$OMP THREADPRIVATE(use_bassin_Pacific, use_bassin_Indian,   use_bassin_Tropics, use_bassin_BengalGolf,  use_bassin_HighLats, use_bassin_Medit)
+   INTEGER, SAVE ::     bassin_Pacific,     bassin_Indian,       bassin_Tropics,     bassin_BengalGolf,      bassin_HighLats,     bassin_Medit
+!$OMP THREADPRIVATE(    bassin_Pacific,     bassin_Indian,       bassin_Tropics,     bassin_BengalGolf,      bassin_HighLats,     bassin_Medit)
+
+   !--- option 4
+   INTEGER, PARAMETER :: nzone_temp = 1
+   REAL,   SAVE ::  zone_temp1, zone_tempf, zone_tempa  
+!$OMP THREADPRIVATE(zone_temp1, zone_tempf, zone_tempa)
+   REAL,   SAVE ::  zone_temp(nzone_temp-1)
+!$OMP THREADPRIVATE(zone_temp)
+
+   !--- option 5
+   INTEGER, SAVE :: izone_aej, izone_harmattan, izone_mousson
+!$OMP THREADPRIVATE(izone_aej, izone_harmattan, izone_mousson)
+
+   !--- option 6
+   INTEGER, SAVE :: izone_ddft
+!$OMP THREADPRIVATE(izone_ddft)
+
+   !--- option 10
+   INTEGER, SAVE :: izone_contfrac
+!$OMP THREADPRIVATE(izone_contfrac)
+
+   !--- option 12	
+   INTEGER, SAVE :: izone_contcanop
+!$OMP THREADPRIVATE(izone_contcanop)
+
+   !--- option 13
+   INTEGER, PARAMETER :: nzone_pres = 3
+   REAL, SAVE ::  zone_pres(nzone_pres-1)
+!$OMP THREADPRIVATE(zone_pres)
+
+   !--- option 14
+   INTEGER, PARAMETER :: nzone_lat = 4
+   REAL,    SAVE :: zone_pres1, zone_presf, zone_presa 
+!$OMP THREADPRIVATE(zone_pres1, zone_presf, zone_presa) 
+   REAL,    SAVE :: dlattag, lattag_min, zone_lat(nzone_lat-1)
+!$OMP THREADPRIVATE(dlattag, lattag_min, zone_lat)
+
+   !--- option 15
+   INTEGER, SAVE :: izone_irrig
+!$OMP THREADPRIVATE(izone_irrig)
+
+   !--- option 17
+   REAL,    SAVE :: seuil_tag_tmin, seuil_tag_tmin_ls
+!$OMP THREADPRIVATE(seuil_tag_tmin, seuil_tag_tmin_ls)
+  INTEGER,  SAVE :: option_seuil_tag_tmin
+!$OMP THREADPRIVATE(option_seuil_tag_tmin)
+
+   !--- option 20
+   INTEGER, SAVE :: izone_trop, izone_extra
+!$OMP THREADPRIVATE(izone_trop, izone_extra)
+   REAL,    SAVE :: lim_tag20 
+!$OMP THREADPRIVATE(lim_tag20)
+
+   !--- option 21: on garde izone_trop, izone_extra  
+
+   !--- option 22
+   INTEGER, SAVE :: izone_conv_BT, izone_conv_UT
+!$OMP THREADPRIVATE(izone_conv_BT, izone_conv_UT)
+   REAL,    SAVE :: lim_precip_tag22 
+!$OMP THREADPRIVATE(lim_precip_tag22)
+
         
-!integer ntraciso
-!parameter (ntraciso=(ntraceurs_zone+1)*niso) 
-!integer ntracisoOR ! défini dans traceurs_init
-integer, ALLOCATABLE, DIMENSION(:), save :: index_iso
-!$OMP THREADPRIVATE(index_iso)
-integer, ALLOCATABLE, DIMENSION(:), save ::  index_zone
-!$OMP THREADPRIVATE(index_zone)
-integer, ALLOCATABLE, DIMENSION(:,:), save ::  index_trac_loc ! il y a déjà un index_trac dans infotrac: vérifier que c'est le même
-!$OMP THREADPRIVATE(index_trac_loc)
-character*3, ALLOCATABLE, DIMENSION(:), save :: strtrac
-!$OMP THREADPRIVATE(strtrac)
-! -> tout ça passe maintenant par infotrac
-
-integer, ALLOCATABLE, DIMENSION(:), save :: bassin_map
-integer, ALLOCATABLE, DIMENSION(:,:), save :: boite_map
-!$OMP THREADPRIVATE(bassin_map,boite_map)
-
-
-        ! traitement recyclage et evap
-integer, save :: izone_cont ! pour le recyclage continental
-!$OMP THREADPRIVATE(izone_cont)
-integer, save :: izone_oce ! pour l'océan
-!$OMP THREADPRIVATE(izone_oce)
-integer, save :: izone_poubelle ! pour les petits résidus numériques
+  INTEGER, ALLOCATABLE, SAVE :: index_iso(:), index_zone(:), itZonIso_loc(:,:)
+!$OMP THREADPRIVATE(            index_iso,    index_zone,    itZonIso_loc)
+  CHARACTER(LEN=3), ALLOCATABLE :: strtrac(:)
+!$OMP THREADPRIVATE(               strtrac)
+  INTEGER, ALLOCATABLE, SAVE :: bassin_map(:), boite_map(:,:)
+!$OMP THREADPRIVATE(            bassin_map,    boite_map)
+
+   !=== RECYCLING AND EVAPORATION TREATMENT
+   INTEGER, SAVE :: izone_cont, izone_oce        !--- For land and ocean recycling
+!$OMP THREADPRIVATE(izone_cont, izone_oce)
+   INTEGER, SAVE :: izone_poubelle               !--- For small numerical residues
 !$OMP THREADPRIVATE(izone_poubelle)
-integer, save :: izone_init ! pour l'initialisation par défaut
+   INTEGER, SAVE :: izone_init                   !--- For default initialization
 !$OMP THREADPRIVATE(izone_init)
-integer, save :: izone_revap ! pour l'évap des gouttes
+   INTEGER, SAVE :: izone_revap                  !--- For droplets evaporation
 !$OMP THREADPRIVATE(izone_revap)
-integer, save :: option_revap
-!$OMP THREADPRIVATE(option_revap)
-integer, save :: option_tmin
-!$OMP THREADPRIVATE(option_tmin)
-integer, save :: option_cond
-!$OMP THREADPRIVATE(option_cond)
-integer, save :: izone_cond
-!$OMP THREADPRIVATE(izone_cond)
-real evap_franche
-parameter (evap_franche=1e-6) ! en kg/m2/s
-
-! specifique à option 4:
-real, save ::  zone_temp(nzone_temp-1)
-!$OMP THREADPRIVATE(zone_temp)
-! si option 5
-integer, save :: izone_aej
-!$OMP THREADPRIVATE(izone_aej)
-integer, save :: izone_harmattan
-!$OMP THREADPRIVATE(izone_harmattan)
-integer, save :: izone_mousson
-!$OMP THREADPRIVATE(izone_mousson)
-! si option 6
-integer, save :: izone_ddft
-!$OMP THREADPRIVATE(izone_ddft)
-! si option 10
-integer, save :: izone_contfrac
-!$OMP THREADPRIVATE(izone_contfrac)
-! si option 12	
-integer, save :: izone_contcanop
-!$OMP THREADPRIVATE(izone_contcanop)
-! specifique à option 13:
-real, save ::  zone_pres(nzone_pres-1)
-!$OMP THREADPRIVATE(zone_pres)
-! si option 14
-real, save ::  zone_lat(nzone_lat-1)
-!$OMP THREADPRIVATE(zone_lat)
-! si option 15
-integer, save :: izone_irrig
-!$OMP THREADPRIVATE(izone_irrig)
-! si option 17
-real, save ::  seuil_tag_tmin
-!$OMP THREADPRIVATE(seuil_tag_tmin)
-real, save ::  seuil_tag_tmin_ls
-!$OMP THREADPRIVATE(seuil_tag_tmin_ls)
-integer, save :: option_seuil_tag_tmin
-!$OMP THREADPRIVATE(option_seuil_tag_tmin)
-! si option 20
-integer, save :: izone_trop,izone_extra
-real, save ::  lim_tag20 
-!$OMP THREADPRIVATE(izone_trop,izone_extra,lim_tag20)
-! si option 21: on garde izone_trop,izone_extra  
-! si opt 22
-integer, save :: izone_conv_BT,izone_conv_UT
-real, save ::  lim_precip_tag22 
-!$OMP THREADPRIVATE(izone_conv_BT,izone_conv_UT,lim_precip_tag22)
-
+   INTEGER, SAVE :: option_revap, option_tmin, option_cond, izone_cond
+!$OMP THREADPRIVATE(option_revap, option_tmin, option_cond, izone_cond)
+   REAL, PARAMETER :: evap_franche = 1e-6        !--- In kg/m2/s
 
 CONTAINS
 
-      subroutine iso_traceurs_init()
-
-      use IOIPSL ! getin
-      USE infotrac_phy, ONLY: ntraciso,niso,ntraceurs_zone,index_trac
-      USE isotopes_mod, ONLY: iso_eau,ntracisoOR,initialisation_iso, &
-&               iso_eau_possible
-      USE dimphy, only: klon,klev
-
-        implicit none
-
-
-        ! définition de quelles zones et quelles isotopes représentent
-        ! les traceurs
-
-        ! inputs, outputs
-        ! ! c'est les variables dans traceurs.h qui sont modifiées
-
-        ! locals
-        integer itrac,izone,ixt,k
-        integer izone_pres,izone_lat
-        character*2 strz,strz_preslat
-        character*1 strz_pres,strz_lat
-        integer ntraceurs_zone_opt
-
-        ! vérifier que on a bien l'eau comme traceurs
-        if (iso_eau.eq.0) then
-            write(*,*) 'traceurs_init 18: isotrac ne marche que si ', &
-     &            'on met l''eau comme isotope'
-            stop
-        endif
-
-        ! initialiser
-        option_traceurs=0
-        initialisation_isotrac=0
-
-        ! allouer
-        allocate (index_iso(ntraciso))
-        allocate (index_zone(ntraciso))
-        allocate (index_trac_loc(ntraceurs_zone,niso))
-        allocate (strtrac(ntraceurs_zone))
-        allocate (bassin_map(klon))
-        allocate (boite_map(klon,klev))
-
-        if (initialisation_iso.eq.0) then
-          call getin('initialisation_isotrac',initialisation_isotrac)
-          write(*,*) 'initialisation_isotrac=',initialisation_isotrac
-        endif !if (initialisation_iso.eq.0) then
-
-        ! lire l'option de traçage
-        call getin('option_traceurs',option_traceurs)
-        write(*,*) 'option_traceurs=',option_traceurs
-
-        ! cas général: pas de traceurs dans ORCHIDEE
-        ntracisoOR=niso
-
-        ! partie à éditer ! pour définir les différentes zones
-        if (option_traceurs.eq.1) then
-          ! on trace continents/ocean  
-
-          ntraceurs_zone_opt=2
-          izone_cont=1
-          izone_oce=2          
-          izone_poubelle=2 ! zone où on met les flux non physiques, de
-                ! réajustement
-          izone_init=2 ! zone d'initialisation par défaut          
-          option_revap=0
-          option_tmin=0
-          izone_revap=0
-          option_cond=0
-
-          strtrac(izone_cont)='con'
-          strtrac(izone_oce)='oce'
-
-        elseif (option_traceurs.eq.2) then
-          ! on trace continent/ ocean/reevap des gouttes
-
-          ntraceurs_zone_opt=3
-          izone_cont=1
-          izone_oce=2
-          izone_poubelle=2 ! zone où on met les flux non physiques, de
-                ! réajustement
-          izone_init=2 ! zone d'initialisation par défaut
-          option_revap=1
-          option_tmin=0
-          izone_revap=3
-          option_cond=0
-
-          strtrac(izone_cont)='con'
-          strtrac(izone_oce)='oce'
-          strtrac(izone_revap)='rev'
-          
-
-        else if (option_traceurs.eq.3) then
-            ! on trace des bassins océaniques + un résidu. On ne trace
-            ! pas l'évap des gouttes à part
-            ! le résidu est la dernère dimension
-            
-          ! lire les use_bassin
-          call getin('use_bassin_atlantic',use_bassin_atlantic)     
-          call getin('use_bassin_medit',use_bassin_medit)      
-          call getin('use_bassin_indian',use_bassin_indian)     
-          call getin('use_bassin_austral',use_bassin_austral)     
-          call getin('use_bassin_pacific',use_bassin_pacific)     
-          call getin('use_bassin_merarabie',use_bassin_merarabie)     
-          call getin('use_bassin_golfebengale',use_bassin_golfebengale)     
-          call getin('use_bassin_indiansud',use_bassin_indiansud)     
-          call getin('use_bassin_tropics',use_bassin_tropics)     
-          call getin('use_bassin_midlats',use_bassin_midlats)     
-          call getin('use_bassin_hauteslats',use_bassin_hauteslats)
-
-          write(*,*) 'use_bassin_atlantic=' ,use_bassin_atlantic  
-          write(*,*) 'use_bassin_medit=' ,use_bassin_medit
-          write(*,*) 'use_bassin_indian=' ,use_bassin_indian
-          write(*,*) 'use_bassin_austral=' ,use_bassin_austral
-          write(*,*) 'use_bassin_merarabie=' ,use_bassin_merarabie
-          write(*,*) 'use_bassin_golfebengale=' ,use_bassin_golfebengale
-          write(*,*) 'use_bassin_indiansud=' ,use_bassin_indiansud
-          write(*,*) 'use_bassin_tropics=' ,use_bassin_tropics
-          write(*,*) 'use_bassin_midlats=' ,use_bassin_midlats
-          write(*,*) 'use_bassin_hauteslats=' ,use_bassin_hauteslats
-
-        
-          ntraceurs_zone_opt=2 &
-     &                   +use_bassin_atlantic &
-     &                   +use_bassin_medit &
-     &                   +use_bassin_indian &
-     &                   +use_bassin_austral &
-     &                   +use_bassin_pacific &
-     &                   +use_bassin_merarabie &
-     &                   +use_bassin_golfebengale &
-     &                   +use_bassin_indiansud &
-     &                   +use_bassin_tropics &
-     &                   +use_bassin_midlats &
-     &                   +use_bassin_hauteslats
-
-          izone_cont=ntraceurs_zone
-          izone_oce=0 ! pas de sens car séparée en bassins          
-          izone_poubelle=ntraceurs_zone-1 ! zone où on met les flux non physiques, de
-                ! réajustement
-          izone_init=ntraceurs_zone-1 ! zone d'initialisation par défaut
-          option_revap=0 ! on ne trace pas les gouttes 
-          option_tmin=0
-          izone_revap=0 ! pas de sens car on taggue pas les gouttes séparemment  
-          option_cond=0
-
-          ! si on a use_bassin_indian, on n'a pas le découpage détaillé
-          ! de l'indian:
+   SUBROUTINE iso_traceurs_init()
+
+   USE infotrac_phy, ONLY: itZonIso, isoName, isoZone
+   USE isotopes_mod, ONLY: iso_eau, ntracisoOR, initialisation_iso
+   USE dimphy,       ONLY: klon, klev
+   USE  strings_mod, ONLY: int2str, strStack, strTail, strHead, strIdx, fmsg
+
+   IMPLICIT NONE
+   ! Define which zones and isotopes correspond to isotopic tagging tracers
+   ! Modify traceurs.h variables
+   INTEGER :: izone, ixt, k
+   INTEGER :: izone_pres, izone_lat
+   INTEGER :: nzone_opt
+
+   IF(fmsg("traceurs_init 18: isotrac ne marche que si on met l'eau comme isotope", 'iso_traceurs_init', iso_eau==0)) STOP
+
+   !--- Initialize
+   option_traceurs = 0
+   initialisation_isotrac = 0
+
+   !--- Allocate
+   ALLOCATE(index_iso (ntiso))
+   ALLOCATE(index_zone(ntiso))
+   ALLOCATE(itZonIso_loc(nzone,niso))
+   ALLOCATE(strtrac(nzone))
+   ALLOCATE(bassin_map(klon))
+   ALLOCATE( boite_map(klon,klev))
+
+   IF(initialisation_iso == 0) CALL get_in('initialisation_isotrac', initialisation_isotrac)
+
+   !--- Read tracing option
+   CALL get_in('option_traceurs', option_traceurs)
+
+   !--- Genral case: no traceurs in ORCHIDEE
+   ntracisoOR=niso
+
+   ! partie a editer ! pour definir les differentes zones
+   SELECT CASE(option_traceurs)
+      !========================================================================================================================
+      CASE(1)      !=== TRACING LAND/OCEAN
+      !========================================================================================================================
+         nzone_opt=2
+         izone_cont=1
+         izone_oce=2
+         izone_poubelle=2    ! zone ou on met les flux non physiques, de reajustement
+         izone_init=2        ! zone d'initialisation par defaut          
+         option_revap=0
+         option_tmin=0
+         izone_revap=0
+         option_cond=0
+         strtrac(izone_cont) = 'con'
+         strtrac(izone_oce)  = 'oce'
+      !========================================================================================================================
+      CASE(2)      !=== TRACING LAND/OCEAN/DROPLETS REEVAPORATION
+      !========================================================================================================================
+         nzone_opt=3
+         izone_cont=1
+         izone_oce=2
+         izone_poubelle=2    ! zone ou on met les flux non physiques, de reajustement
+         izone_init=2        ! zone d'initialisation par defaut          
+         option_revap=1
+         option_tmin=0
+         izone_revap=3
+         option_cond=0
+         strtrac(izone_cont) = 'con'
+         strtrac(izone_oce)  = 'oce'
+         strtrac(izone_revap)= 'rev'
+      !========================================================================================================================
+      CASE(3)      !=== TRACING OCEANS BASINS + RESIDUE (LAST DIMENSION). NO DROPLETS EVAPORATION TRACING.
+      !========================================================================================================================
+         ! lire les use_bassin
+         CALL get_in('use_bassin_Atlantic',   use_bassin_Atlantic)
+         CALL get_in('use_bassin_Medit',      use_bassin_Medit)
+         CALL get_in('use_bassin_Indian',     use_bassin_Indian)
+         CALL get_in('use_bassin_Austral',    use_bassin_Austral)
+         CALL get_in('use_bassin_Pacific',    use_bassin_Pacific)
+         CALL get_in('use_bassin_MerArabie',  use_bassin_MerArabie)
+         CALL get_in('use_bassin_BengalGolf', use_bassin_BengalGolf)
+         CALL get_in('use_bassin_SouthIndian',use_bassin_SouthIndian)
+         CALL get_in('use_bassin_Tropics',    use_bassin_Tropics)
+         CALL get_in('use_bassin_Midlats',    use_bassin_Midlats)
+         CALL get_in('use_bassin_HighLats',   use_bassin_HighLats)
+         nzone_opt  =  2  +  COUNT([use_bassin_Atlantic, use_bassin_Medit,     use_bassin_Indian,     &
+            use_bassin_Austral,     use_bassin_Pacific,  use_bassin_MerArabie, use_bassin_BengalGolf, &
+            use_bassin_SouthIndian, use_bassin_Tropics,  use_bassin_Midlats,   use_bassin_HighLats])
+         izone_cont=nzone
+         izone_oce=0             ! pas de sens car separee en bassins          
+         izone_poubelle=nzone-1  ! zone ou on met les flux non physiques, de reajustement
+         izone_init=nzone-1      ! zone d'initialisation par defaut
+         option_revap=0          ! on ne trace pas les gouttes 
+         option_tmin=0
+         izone_revap=0           ! pas de sens car on taggue pas les gouttes separemment  
+         option_cond=0
 #ifdef ISOVERIF
-          if (use_bassin_indian.eq.1) then
-!              call iso_verif_egalite(float(use_bassin_merarabie), &
-!     &            0.0,'iso_traceurs_init 73: revoir def des bassins')
-               if ((use_bassin_merarabie.ne.0).or. &
-      &            (use_bassin_indiansud.ne.0).or. &
-      &            (use_bassin_golfebengale.ne.0)) then
-                write(*,*) 'traceurs_init 73'
-                stop
-               endif 
-!              call iso_verif_egalite(float(use_bassin_golfebengale), &
-!     &            0.0,'iso_traceurs_init 73: revoir def des bassins')
-!              call iso_verif_egalite(float(use_bassin_indiansud), &
-!     &            0.0,'iso_traceurs_init 73: revoir def des bassins')
-          endif
+         IF(use_bassin_Indian) THEN   !=== NON COMPATIBLE WITH A DETAILED INDIAN CUTTING
+            IF(use_bassin_MerArabie .OR. use_bassin_SouthIndian .OR. use_bassin_BengalGolf) THEN
+               WRITE(*,*) 'traceurs_init 73'; STOP
+            END IF
+!           CALL iso_verif_egalite(float(use_bassin_MerArabie),   0.0, 'iso_traceurs_init 73: revoir def des bassins')
+!           CALL iso_verif_egalite(float(use_bassin_BengalGolf),  0.0, 'iso_traceurs_init 73: revoir def des bassins')
+!           CALL iso_verif_egalite(float(use_bassin_SouthIndian), 0.0, 'iso_traceurs_init 73: revoir def des bassins')
+         END IF
 #endif    
-          
-          bassin_atlantic= max(use_bassin_atlantic,1)
-          bassin_medit=max(use_bassin_atlantic &
-     &           +use_bassin_medit,1)
-          bassin_indian=max(use_bassin_atlantic &
-     &           +use_bassin_medit &
-     &           +use_bassin_indian,1)
-          bassin_austral=max(use_bassin_atlantic &
-     &           +use_bassin_medit &
-     &           +use_bassin_indian &
-     &           +use_bassin_austral,1)
-          bassin_pacific=max(use_bassin_atlantic &
-     &           +use_bassin_medit &
-     &           +use_bassin_indian &
-     &           +use_bassin_austral &
-     &           +use_bassin_pacific,1)
-          bassin_merarabie=max(use_bassin_atlantic &
-     &           +use_bassin_medit &
-     &           +use_bassin_indian &
-     &           +use_bassin_austral &
-     &           +use_bassin_pacific &
-     &           +use_bassin_merarabie,1)
-          bassin_golfebengale=max(use_bassin_atlantic& 
-     &           +use_bassin_medit &
-     &           +use_bassin_indian & 
-     &           +use_bassin_austral &
-     &           +use_bassin_pacific &
-     &           +use_bassin_merarabie &
-     &           +use_bassin_golfebengale,1)
-          bassin_indiansud=max(use_bassin_atlantic &
-     &           +use_bassin_medit &
-     &           +use_bassin_indian &
-     &           +use_bassin_austral &
-     &           +use_bassin_pacific &
-     &           +use_bassin_merarabie &
-     &           +use_bassin_golfebengale &
-     &           +use_bassin_indiansud,1) 
-          bassin_tropics=max(use_bassin_atlantic &
-     &                       +use_bassin_medit &
-     &                       +use_bassin_indian &
-     &                       +use_bassin_austral &
-     &                       +use_bassin_pacific &
-     &                       +use_bassin_merarabie &
-     &                       +use_bassin_golfebengale &
-     &                       +use_bassin_indiansud, &
-     &                       +use_bassin_tropics,1) 
-          bassin_midlats=max(use_bassin_atlantic &
-     &                       +use_bassin_medit &
-     &                       +use_bassin_indian &
-     &                       +use_bassin_austral &
-     &                       +use_bassin_pacific &
-     &                       +use_bassin_merarabie &
-     &                       +use_bassin_golfebengale &
-     &                       +use_bassin_indiansud &
-     &                       +use_bassin_tropics &
-     &                       +use_bassin_midlats,1) 
-          bassin_hauteslats=max(use_bassin_atlantic & 
-     &                       +use_bassin_medit &
-     &                       +use_bassin_indian &
-     &                       +use_bassin_austral &
-     &                       +use_bassin_pacific &
-     &                       +use_bassin_merarabie &
-     &                       +use_bassin_golfebengale &
-     &                       +use_bassin_indiansud &
-     &                       +use_bassin_tropics &
-     &                       +use_bassin_midlats &
-     &                       +use_bassin_hauteslats,1) 
-
-          write(*,*) 'bassin_atlantic=' ,bassin_atlantic  
-          write(*,*) 'bassin_medit=' ,bassin_medit
-          write(*,*) 'bassin_indian=' ,bassin_indian
-          write(*,*) 'bassin_austral=' ,bassin_austral
-          write(*,*) 'bassin_merarabie=' ,bassin_merarabie
-          write(*,*) 'bassin_golfebengale=' ,bassin_golfebengale
-          write(*,*) 'bassin_indiansud=' ,bassin_indiansud
-          write(*,*) 'bassin_tropics=' ,bassin_tropics
-          write(*,*) 'bassin_midlats=' ,bassin_midlats
-          write(*,*) 'bassin_hauteslats=' ,bassin_hauteslats
-
-          if (use_bassin_atlantic.eq.1) then
-            strtrac(bassin_atlantic)='atl'
-          endif
-          if (use_bassin_medit.eq.1) then
-            strtrac(bassin_medit)='med'
-          endif
-          if (use_bassin_indian.eq.1) then
-            strtrac(bassin_indian)='ind'
-          endif
-          if (use_bassin_austral.eq.1) then
-            strtrac(bassin_austral)='aus'
-          endif
-          if (use_bassin_pacific.eq.1) then
-            strtrac(bassin_pacific)='pac'
-          endif
-          if (use_bassin_merarabie.eq.1) then
-            strtrac(bassin_merarabie)='ara'
-          endif
-          if (use_bassin_golfebengale.eq.1) then
-            strtrac(bassin_golfebengale)='ben'
-          endif
-          if (use_bassin_indiansud.eq.1) then
-            strtrac(bassin_indiansud)='ins'
-          endif
-          if (use_bassin_tropics.eq.1) then
-            strtrac(bassin_tropics)='tro'
-          endif
-          if (use_bassin_midlats.eq.1) then
-            strtrac(bassin_midlats)='mid'
-          endif
-          if (use_bassin_hauteslats.eq.1) then
-            strtrac(bassin_hauteslats)='hau'
-          endif
-          strtrac(ntraceurs_zone-1)='res'
-          strtrac(ntraceurs_zone)='con'
-
-        else if (option_traceurs.eq.4) then
-          ! on trace les température minimales vécues
-          ! comme dans article sur LdG sauf pas de revap
-            
-          zone_temp1=293.0 ! en K
-!          zone_tempf=223.0 ! en K
-          zone_tempf=243.0 ! en K
- ! courbure de la relation entre l'indice et la température: 0 pour linéaire, <0 pour plus de détal en bas
-
+         bassin_Atlantic   = 1
+         bassin_Medit      = bassin_Atlantic    + COUNT([use_bassin_Medit]);       WRITE(*,*) 'bassin_Atlantic    =' ,bassin_Atlantic
+         bassin_Indian     = bassin_Medit       + COUNT([use_bassin_Indian]);      WRITE(*,*) 'bassin_Medit       =' ,bassin_Medit
+         bassin_Austral    = bassin_Indian      + COUNT([use_bassin_Austral]);     WRITE(*,*) 'bassin_Indian      =' ,bassin_Indian
+         bassin_Pacific    = bassin_Austral     + COUNT([use_bassin_Pacific]);     WRITE(*,*) 'bassin_Austral     =' ,bassin_Austral
+         bassin_MerArabie  = bassin_Pacific     + COUNT([use_bassin_MerArabie]);   WRITE(*,*) 'bassin_MerArabie   =' ,bassin_MerArabie
+         bassin_BengalGolf = bassin_MerArabie   + COUNT([use_bassin_BengalGolf]);  WRITE(*,*) 'bassin_BengalGolf  =' ,bassin_BengalGolf
+         bassin_SouthIndian= bassin_BengalGolf  + COUNT([use_bassin_SouthIndian]); WRITE(*,*) 'bassin_SouthIndian =' ,bassin_SouthIndian
+         bassin_Tropics    = bassin_SouthIndian + COUNT([use_bassin_Tropics]);     WRITE(*,*) 'bassin_Tropics     =' ,bassin_Tropics
+         bassin_MidLats    = bassin_Tropics     + COUNT([use_bassin_MidLats]);     WRITE(*,*) 'bassin_MidLats     =' ,bassin_MidLats
+         bassin_HighLats   = bassin_MidLats     + COUNT([use_bassin_HighLats]);    WRITE(*,*) 'bassin_HighLats    =' ,bassin_HighLats
+         IF(use_bassin_atlantic   ) strtrac(bassin_atlantic)   = 'atl'
+         IF(use_bassin_medit      ) strtrac(bassin_medit)      = 'med'
+         IF(use_bassin_indian     ) strtrac(bassin_indian)     = 'ind'
+         IF(use_bassin_austral    ) strtrac(bassin_austral)    = 'aus'
+         IF(use_bassin_pacific    ) strtrac(bassin_pacific)    = 'pac'
+         IF(use_bassin_merarabie  ) strtrac(bassin_merarabie)  = 'ara'
+         IF(use_bassin_BengalGolf ) strtrac(bassin_BengalGolf) = 'ben'
+         IF(use_bassin_SouthIndian) strtrac(bassin_SouthIndian)= 'ins'
+         IF(use_bassin_tropics    ) strtrac(bassin_tropics)    = 'tro'
+         IF(use_bassin_midlats    ) strtrac(bassin_midlats)    = 'mid'
+         IF(use_bassin_HighLats   ) strtrac(bassin_HighLats)   = 'hau'
+         strtrac(nzone-1)='res'
+         strtrac(nzone)='con'
+      !========================================================================================================================
+      CASE(4)      !=== TRACING MINIMAL EXPERIENCED TEMPERATURE AS IN THE ARTICLE ON LfG, EXCEPT NO REVAPORATION
+      !========================================================================================================================
+         zone_temp1 = 293.0  ! en K
+!        zone_tempf = 223.0  ! en K
+         zone_tempf = 243.0  ! en K
+        ! courbure de la relation entre l'indice et la temperature: 0 pour lineaire, <0 pour plus de detal en bas
         ! zone 1: >= zone_temp1
-        ! zone 2 à 4: intermédiaire, 
+        ! zone 2 a 4: intermediaire, 
         ! zone 5: <zone_tempf
-        
-          ntraceurs_zone_opt=nzone_temp+1
-
-          zone_tempa=-4.0 ! en K
-          izone_cont=ntraceurs_zone
-          izone_oce=ntraceurs_zone  
-          izone_poubelle=ntraceurs_zone
-          izone_init=ntraceurs_zone ! zone d'initialisation par défaut
-          option_revap=0 
-          option_tmin=0  
-          izone_revap=0
-          option_cond=0
-          do izone=1,nzone_temp
-            write(strz,'(i2.2)') izone
-            strtrac(izone)='t'//strz
-            write(*,*) 'izone,strz,strtrac=',izone,strz,strtrac(izone)
-          enddo
-          strtrac(izone_poubelle)='pou'
-
-          ! initialisation des zones de tempéarture
-          do izone=1,nzone_temp-1
-            zone_temp(izone)=zone_temp1+float(izone-1) &
-     &                      *(zone_tempa*float(izone-nzone_temp+1) &
-     &                      +(zone_tempf-zone_temp1)/float(nzone_temp-2))
-          enddo
-          write(*,*) 'iso_trac_init 183: zone_temp=',zone_temp          
-
-        elseif (option_traceurs.eq.5) then
-          ! on trace AEJ/flux de mousson/Harmattan
-!          write(*,*) 'iso_traceurs_init 129'
-
-          ntraceurs_zone_opt=4
-          izone_cont=1
-          izone_oce=1
-          izone_poubelle=1 ! zone où on met les flux non physiques, de
-                ! réajustement
-          izone_init=1 ! zone d'initialisation par défaut
-          option_revap=0
-          option_tmin=0
-          izone_revap=0
-          izone_aej=2
-          izone_mousson=3
-          izone_harmattan=4 
-          option_cond=0
-
-          strtrac(izone_poubelle)='res'
-          strtrac(izone_aej)='aej'
-          strtrac(izone_mousson)='mou'
-          strtrac(izone_harmattan)='sah'
-
-        elseif (option_traceurs.eq.6) then
-          ! on trace les ddfts
-
-          ntraceurs_zone_opt=2
-          izone_cont=1
-          izone_oce=1
-          izone_poubelle=1 ! zone où on met les flux non physiques, de
-                ! réajustement
-          izone_init=1 ! zone d'initialisation par défaut
-          option_revap=0
-          option_tmin=0
-          izone_revap=0
-          izone_ddft=2
-          option_cond=0
-
-          strtrac(izone_poubelle)='res'
-          strtrac(izone_ddft)='dft'
-
-        elseif (option_traceurs.eq.9) then
-          ! on trace le condensat
-
-          ntraceurs_zone_opt=3
-          izone_cont=1
-          izone_oce=1
-          izone_poubelle=1 ! zone où on met les flux non physiques, de
-                ! réajustement
-          izone_init=1 ! zone d'initialisation par défaut
-          option_revap=1
-          option_tmin=0
-          izone_revap=2
-          izone_cond=3
-          option_cond=1
-
-          ! 1 par défaut pour colorier à la fois condensat LS et
-          ! condensat convectif. Mais on peut mettre 2 si on ne veut que
-          ! collorier que le condensat convectif.
-          call getin('option_cond',option_cond)
-          write(*,*) 'option_cond=',option_cond
-
-          strtrac(izone_poubelle)='res'
-          strtrac(izone_cond)='con'
-          strtrac(izone_revap)='rev'
-
-        elseif (option_traceurs.eq.10) then
-          ! on trace l'évap venant de ocean/continent no frac/continent frac
-          !  utilse seulement si couplé avec ORCHIDEE
-#ifdef CPP_VEGET
-#else
-          write(*,*) 'iso_traceurs_init 219: option_traceurs=10 ', &
-     &                      'inutile si on ne couple pas avec ORCHIDEE'
-          stop
+         nzone_opt=nzone_temp+1
+         zone_tempa=-4.0     ! en K
+         izone_cont=nzone
+         izone_oce=nzone  
+         izone_poubelle=nzone
+         izone_init=nzone    ! zone d'initialisation par defaut
+         option_revap=0 
+         option_tmin=0  
+         izone_revap=0
+         option_cond=0
+         DO izone=1,nzone_temp
+            strtrac(izone) = 't'//TRIM(int2str(izone))
+            WRITE(*,*) 'izone, strtrac=', izone, strtrac(izone)
+         END DO
+         strtrac(izone_poubelle)='pou'
+         ! Initialization of temperatures zones
+         DO izone=1,nzone_temp-1
+            zone_temp(izone) = zone_temp1+float(izone-1)            &
+                            * (zone_tempa*float(izone-nzone_temp+1) &
+                            + (zone_tempf-zone_temp1)/float(nzone_temp-2))
+         END DO
+         WRITE(*,*) 'iso_trac_init 183: zone_temp=', zone_temp
+      !========================================================================================================================
+      CASE(5)      !=== TRACING AEJ/MOONSOON FLUX/Harmattan
+      !========================================================================================================================
+!        WRITE*,*) 'iso_traceurs_init 129'
+         nzone_opt=4
+         izone_cont=1
+         izone_oce=1
+         izone_poubelle=1    ! zone ou on met les flux non physiques, de reajustement
+         izone_init=1        ! zone d'initialisation par defaut          
+         option_revap=0
+         option_tmin=0
+         izone_revap=0
+         izone_aej=2
+         izone_mousson=3
+         izone_harmattan=4 
+         option_cond=0
+         strtrac(izone_poubelle) = 'res'
+         strtrac(izone_aej)      = 'aej'
+         strtrac(izone_mousson)  = 'mou'
+         strtrac(izone_harmattan)= 'sah'
+      !========================================================================================================================
+      CASE(6)      !=== TRACING DDFTS
+      !========================================================================================================================
+         nzone_opt=2
+         izone_cont=1
+         izone_oce=1
+         izone_poubelle=1    ! zone ou on met les flux non physiques, de reajustement
+         izone_init=1        ! zone d'initialisation par defaut          
+         option_revap=0
+         option_tmin=0
+         izone_revap=0
+         izone_ddft=2
+         option_cond=0
+         strtrac(izone_poubelle)='res'
+         strtrac(izone_ddft)='dft'
+      !========================================================================================================================
+      CASE(9)      !=== TRACING CONDENSATION
+      !========================================================================================================================
+         nzone_opt=3
+         izone_cont=1
+         izone_oce=1
+         izone_poubelle=1    ! zone ou on met les flux non physiques, de reajustement
+         izone_init=1        ! zone d'initialisation par defaut          
+         option_revap=1
+         option_tmin=0
+         izone_revap=2
+         izone_cond=3
+         option_cond=1
+         ! 1 par defaut pour colorier a la fois condensat LS et condensat convectif.
+         ! Mais on peut mettre 2 si on ne veut que colorier que le condensat convectif.
+         CALL get_in('option_cond',option_cond)
+         strtrac(izone_poubelle)='res'
+         strtrac(izone_cond)='con'
+         strtrac(izone_revap)='rev'
+      !========================================================================================================================
+      CASE(10)     !=== TRACING EVAPORATION FROM OCEAN/LAND, NON FRAC/LAND FRAC ; ONLY WHEN COUPLED WITH ORCHIDEE
+      !========================================================================================================================
+#ifndef CPP_VEGET
+         WRITE(*,*) 'iso_traceurs_init 219: option_traceurs=10 inutile si on ne couple pas avec ORCHIDEE'; STOP
 #endif          
-
-          ntraceurs_zone_opt=3
-          izone_cont=1 ! sous-entendu non fractionnant
-          izone_oce=2
-          izone_poubelle=2 ! zone où on met les flux non physiques, de
-                ! réajustement
-          izone_init=2 ! zone d'initialisation par défaut
-          option_revap=0
-          option_tmin=0
-          izone_revap=0
-          izone_contfrac=3
-          izone_contcanop=3
-          izone_irrig=0
-          option_cond=0
-
-          strtrac(izone_oce)='oce'
-          strtrac(izone_cont)='con'  
-          strtrac(izone_contfrac)='enu'  ! evap sol nu
-
-        elseif (option_traceurs.eq.11) then
-          ! on trace reevap des gouttes et le reste
-
-          ntraceurs_zone_opt=2
-          izone_cont=1
-          izone_oce=1
-          izone_poubelle=1 ! zone où on met les flux non physiques, de
-                ! réajustement
-          izone_init=1 ! zone d'initialisation par défaut
-          option_revap=1
-          option_tmin=0
-          izone_revap=2
-          izone_irrig=0
-          option_cond=0
-
-          strtrac(izone_poubelle)='res'
-          strtrac(izone_revap)='rev'
-
-        elseif (option_traceurs.eq.12) then
-          ! on trace evap du sol nu, evap de la canopée, reste de l'evap cont et
-          ! evap oce
-#ifdef CPP_VEGET
-#else
-          write(*,*) 'iso_traceurs_init 257: option_traceurs=10 ', &
-     &                      'inutile si on ne couple pas avec ORCHIDEE'
-          stop
+         nzone_opt=3
+         izone_cont=1        ! sous-entendu non fractionnant
+         izone_oce=2
+         izone_poubelle=2    ! zone ou on met les flux non physiques, de reajustement
+         izone_init=2        ! zone d'initialisation par defaut
+         option_revap=0
+         option_tmin=0
+         izone_revap=0
+         izone_contfrac=3
+         izone_contcanop=3
+         izone_irrig=0
+         option_cond=0
+         strtrac(izone_oce)='oce'
+         strtrac(izone_cont)='con'  
+         strtrac(izone_contfrac)='enu'  ! evap sol nu
+      !========================================================================================================================
+      CASE(11)     !=== TRACING DROPLETS REEVAPORATION + REST
+      !========================================================================================================================
+         nzone_opt=2
+         izone_cont=1
+         izone_oce=1
+         izone_poubelle=1    ! zone ou on met les flux non physiques, de reajustement
+         izone_init=1        ! zone d'initialisation par defaut
+         option_revap=1
+         option_tmin=0
+         izone_revap=2
+         izone_irrig=0
+         option_cond=0
+         strtrac(izone_poubelle)='res'
+         strtrac(izone_revap)='rev'
+      !========================================================================================================================
+      CASE(12)     !=== TRACING NAKED GROUND EVAPORATION, CANOPY EVAPORATION, REST OF LAND EVAPORATION AND OCEAN EVAPORATION
+      !========================================================================================================================
+#ifndef CPP_VEGET
+         WRITE(*,*) 'iso_traceurs_init 257: option_traceurs=10 inutile si on ne couple pas avec ORCHIDEE'; STOP
 #endif           
-
-          ntraceurs_zone_opt=2
-          izone_cont=1
-          izone_oce=2
-          izone_poubelle=2 ! zone où on met les flux non physiques, de
-                ! réajustement
-          izone_init=2 ! zone d'initialisation par défaut
-          option_revap=0
-          option_tmin=0
-          izone_revap=0
-          izone_contfrac=3
-          izone_contcanop=4
-          izone_irrig=0   
-          option_cond=0
-
-          strtrac(izone_oce)='oce'
-          strtrac(izone_cont)='con'
-          strtrac(izone_contfrac)='enu'  ! evap sol nu
-          strtrac(izone_contcanop)='eca'  ! evap canop
-
-       else if (option_traceurs.eq.13) then
-          ! on trace les température minimales vécues + la revap
-          ! comme dans article sur LdG
-            
-        zone_temp1=293.0         ! en K        
-!        parameter (zone_tempf=223.0) ! en K
-        zone_tempf=243.0 ! en K
-        zone_tempa=-4.0 ! courbure de la relation entre l'indice et la température: 0 pour linéaire, <0 pour plus de détal en bas
-
-        ! zone 1: >= zone_temp1
-        ! zone 2 à 4: intermédiaire, 
-        ! zone 5: <zone_tempf
-        
-          ntraceurs_zone_opt=nzone_temp+1
-          
-          izone_cont=1
-          izone_oce=1  
-          izone_poubelle=1
-          izone_init=1 ! zone d'initialisation par défaut
-          option_revap=1   
-          option_tmin=0
-          izone_revap=ntraceurs_zone
-          izone_irrig=0
-          option_cond=0
-          do izone=1,nzone_temp
-            write(strz,'(i2.2)') izone
-            strtrac(izone)='t'//strz
-            write(*,*) 'izone,strz,strtrac=',izone,strz,strtrac(izone)
-          enddo
-          strtrac(izone_revap)='rev'
-
-          ! initialisation des zones de tempéarture
-          do izone=1,nzone_temp-1
-            zone_temp(izone)=zone_temp1+float(izone-1) &
-     &                      *(zone_tempa*float(izone-nzone_temp+1) &
-     &                      +(zone_tempf-zone_temp1)/float(nzone_temp-2))
-          enddo
-          write(*,*) 'zone_temp=',zone_temp
-
-       else if (option_traceurs.eq.14) then
-          ! on trace les pres et lat de dernière saturation définies
-          ! comme rh>90%
-            
-        zone_pres1=600.0*100.0 ! en Pa       
-        zone_presf=300.0*100.0 ! en Pa
-        zone_presa=0.0 ! courbure de la relation entre l'indice et la température: 0 pour linéaire, <0 pour plus de détal en bas
-
-        lattag_min=10.0 ! en degrès
-        dlattag=15.0
-
-        ! zone 1: >= zone_pres1
-        ! zone 2 à 4: intermédiaire, 
-        ! zone 5: <zone_presf
-        
-         ntraceurs_zone_opt=nzone_pres*nzone_lat+1          
-          izone_cont=ntraceurs_zone
-          izone_oce=ntraceurs_zone
-          izone_poubelle=ntraceurs_zone
-          izone_init=ntraceurs_zone ! zone d'initialisation par défaut
-          option_revap=0  
-          option_tmin=0 
-          izone_revap=0
-          izone_irrig=0
-          option_cond=0
-          do izone_pres=1,nzone_pres
-           do izone_lat=1,nzone_lat
-            write(strz_pres,'(i1.1)') izone_pres
-            write(strz_lat,'(i1.1)') izone_lat
-            strz_preslat=strz_pres//strz_lat
-            izone=izone_lat+(izone_pres-1)*nzone_lat
-            strtrac(izone)='t'//strz_preslat
-            write(*,*) 'izone_pres,izone_lat,strtrac=', &
-     &                        izone_pres,izone_lat,izone,strtrac(izone)
-           enddo !do izone_lat=1,nzone_lat
-          enddo !do izone_pres=1,nzone_pres
-          strtrac(ntraceurs_zone)='sfc'
-
-          ! initialisation des zones de tempéarture
-          do izone=1,nzone_pres-1
-            zone_pres(izone)=zone_pres1+float(izone-1) &
-     &                      *(zone_presa*float(izone-nzone_pres+1) &
-     &                      +(zone_presf-zone_pres1)/float(nzone_pres-2))
-          enddo !do izone=1,nzone_pres-1
-          write(*,*) 'traceurs_init 332: zone_pres=',zone_pres
-!          stop
-!
-       elseif (option_traceurs.eq.15) then
-          ! on trace l'irrigation dans ORCHIDEE
-#ifdef CPP_VEGET
-#else
-          write(*,*) 'iso_traceurs_init 257: option_traceurs=15 ', &
-     &                      'inutile si on ne couple pas avec ORCHIDEE'
-          stop
+         nzone_opt=2
+         izone_cont=1
+         izone_oce=2
+         izone_poubelle=2    ! zone ou on met les flux non physiques, de reajustement
+         izone_init=2        ! zone d'initialisation par defaut
+         option_revap=0
+         option_tmin=0
+         izone_revap=0
+         izone_contfrac=3
+         izone_contcanop=4
+         izone_irrig=0   
+         option_cond=0
+         strtrac(izone_oce)='oce'
+         strtrac(izone_cont)='con'
+         strtrac(izone_contfrac)='enu' ! evap sol nu
+         strtrac(izone_contcanop)='eca'! evap canop
+      !========================================================================================================================
+      CASE(13)     !=== TRACING MINIMUM EXPERIENCED TEMPERATIRES + REEVAPORATION AS IN THE ARTICLE ON LdG
+      !========================================================================================================================
+         zone_temp1=293.0    ! en K        
+!        zone_tempf=223.0    ! en K
+         zone_tempf=243.0    ! en K
+         zone_tempa=-4.0     ! courbure de la relation entre l'indice et la temperature: 0 pour lineaire, <0 pour plus de detal en bas
+         ! zone 1: >= zone_temp1
+         ! zone 2 a 4: intermediaire, 
+         ! zone 5: <zone_tempf
+         nzone_opt=nzone_temp+1
+         izone_cont=1
+         izone_oce=1  
+         izone_poubelle=1
+         izone_init=1        ! zone d'initialisation par defaut
+         option_revap=1   
+         option_tmin=0
+         izone_revap=nzone
+         izone_irrig=0
+         option_cond=0
+         DO izone=1,nzone_temp
+            strtrac(izone) = 't'//TRIM(int2str(izone))
+            WRITE(*,*) 'izone, strtrac = ', izone, strtrac(izone)
+         END DO
+         strtrac(izone_revap)='rev'
+         ! initialisation des zones de tempearture
+         DO izone=1,nzone_temp-1
+            zone_temp(izone) = zone_temp1+float(izone-1) &
+                             *(zone_tempa*float(izone-nzone_temp+1) &
+                             +(zone_tempf-zone_temp1)/float(nzone_temp-2))
+         END DO
+         WRITE(*,*) 'zone_temp=',zone_temp
+      !========================================================================================================================
+      CASE(14)     !=== TRACING PRES AND LAT OF LAST SATURATION DEFINED AS rh>90%
+      !========================================================================================================================
+         zone_pres1=600.0*100.0   ! en Pa       
+         zone_presf=300.0*100.0   ! en Pa
+         zone_presa=0.0           ! courbure de la relation entre l'indice et la temperature: 0 pour lineaire
+         lattag_min=10.0          ! en degres
+         dlattag=15.0
+         ! zone 1: >= zone_pres1
+         ! zone 2 a 4: intermediaire, 
+         ! zone 5: <zone_presf
+         nzone_opt=nzone_pres*nzone_lat+1          
+         izone_cont=nzone
+         izone_oce=nzone
+         izone_poubelle=nzone
+         izone_init=nzone         ! zone d'initialisation par defaut
+         option_revap=0  
+         option_tmin=0 
+         izone_revap=0
+         izone_irrig=0
+         option_cond=0
+         DO izone_pres=1,nzone_pres
+            DO izone_lat=1,nzone_lat
+               izone=izone_lat+(izone_pres-1)*nzone_lat
+               strtrac(izone) = 't'//TRIM(int2str(izone_pres))//TRIM(int2str(izone_lat))
+               write(*,*) 'izone_pres, izone_lat, izone, strtrac = ',izone_pres, izone_lat, izone, strtrac(izone)
+            END DO
+         END DO
+         strtrac(nzone)='sfc'
+         ! initialisation des zones de temperature
+         DO izone=1,nzone_pres-1
+            zone_pres(izone) = zone_pres1+float(izone-1) &
+                             *(zone_presa*float(izone-nzone_pres+1) &
+                             +(zone_presf-zone_pres1)/float(nzone_pres-2))
+         END DO
+         WRITE(*,*) 'traceurs_init 332: zone_pres=',zone_pres
+      !========================================================================================================================
+      CASE(15)     !=== TRACING IRRIGATION IN ORCHIDEE
+      !========================================================================================================================
+#ifndef CPP_VEGET
+         WRITE(*,*) 'iso_traceurs_init 257: option_traceurs=15 inutile si on ne couple pas avec ORCHIDEE'; STOP
 #endif
-
-          ntraceurs_zone_opt=1
-          izone_cont=1
-          izone_oce=1
-          izone_poubelle=1 ! zone où on met les flux non physiques, de
-                ! réajustement
-          izone_init=1 ! zone d'initialisation par défaut
-          option_revap=0
-          option_tmin=0
-          izone_revap=0
-          izone_contfrac=0
-          izone_contcanop=0 
-          izone_irrig=2 
-          option_cond=0
-          
-          strtrac(izone_poubelle)='res'
-          strtrac(izone_irrig)='irrig'
-
-          ! dans ce cas particulier, il y a des traceurs dans ORCHIDEE
-          ntracisoOR=ntraciso
-
-        else if ((option_traceurs.eq.17).or. &
-     &           (option_traceurs.eq.18)) then
-          ! on trace les température minimales vécues
-          ! comme dans article sur LdG sauf pas de revap
-            
-        zone_temp1=12.0e-3 ! en kg/kg        
-        zone_tempf=0.2e-3 ! en kg/kg
-        zone_tempa=1.2e-3 ! courbure de la relation entre l'indice et la température: 0 pour linéaire, <0 pour plus de détail en bas
-
-!	parameter (zone_temp1=14.0e-3) ! en kg/kg        
-!   	parameter (zone_tempf=0.2e-3) ! en kg/kg
-!	parameter (zone_tempa=0.5e-3)       
-
-!        parameter (zone_temp1=10.0e-3) ! en kg/kg
-!   	parameter (zone_tempf=0.5e-3) ! en kg/kg
-!	parameter (zone_tempa=0.5e-3)
-
-        ! zone 1: >= zone_temp1
-        ! zone 2 à 4: intermédiaire, 
-        ! zone 5: <zone_tempf
-        
-        ntraceurs_zone_opt=nzone_temp+3
-        
-          izone_cont=nzone_temp+1
-          izone_oce=nzone_temp+1 
-          izone_poubelle=nzone_temp+1
-          izone_init=nzone_temp+1 ! zone d'initialisation par défaut
-          option_revap=1  
-          option_tmin=1 
-          option_cond=1
-
-          izone_revap=nzone_temp+3
-          izone_cond=nzone_temp+2
-          do izone=1,nzone_temp
-            write(strz,'(i2.2)') izone
-            strtrac(izone)='t'//strz
-            write(*,*) 'izone,strz,strtrac=',izone,strz,strtrac(izone)
-          enddo !do izone=1,nzone_temp
-          strtrac(izone_poubelle)='sfc'
-          strtrac(izone_cond)='con'
-          strtrac(izone_revap)='rev'
-
-          ! initialisation des zones de tempéarture
-          do izone=1,nzone_temp-1
-            zone_temp(izone)=zone_temp1+float(izone-1) &
-     &                      *(zone_tempa*float(izone-nzone_temp+1) &
-     &             +(zone_tempf-zone_temp1)/float(nzone_temp-2))
-          enddo
-         write(*,*) 'zone_temp1,zone_tempf,zone_tempa=', &
-     &              zone_temp1,zone_tempf,zone_tempa
-          write(*,*) 'zone_temp=',zone_temp
-!          stop          
-
-        else if (option_traceurs.eq.19) then
-
-        zone_temp1=12.0e-3 ! en kg/kg        
-        zone_tempf=0.2e-3 ! en kg/kg
-        zone_tempa=1.2e-3 ! courbure de la relation entre l'indice et la température: 0 pour linéaire, <0 pour plus de détail en bas
-
-!	parameter (zone_temp1=14.0e-3) ! en kg/kg        
-!   	parameter (zone_tempf=0.2e-3) ! en kg/kg
-!	parameter (zone_tempa=0.5e-3)       
-
-!        parameter (zone_temp1=10.0e-3) ! en kg/kg
-!   	parameter (zone_tempf=0.5e-3) ! en kg/kg
-!	parameter (zone_tempa=0.5e-3)
-
-        ! zone 1: >= zone_temp1
-        ! zone 2 à 4: intermédiaire, 
-        ! zone 5: <zone_tempf
-        
-        ntraceurs_zone_opt=nzone_temp+4
-        
-          izone_cont=nzone_temp+1
-          izone_oce=nzone_temp+1 
-          izone_poubelle=nzone_temp+1
-          if (option_seuil_tag_tmin.eq.1) then
-            izone_init=nzone_temp+1 ! zone d'initialisation par défaut
-          else
+         nzone_opt=1
+         izone_cont=1
+         izone_oce=1
+         izone_poubelle=1    ! zone ou on met les flux non physiques, de reajustement
+         izone_init=1        ! zone d'initialisation par defaut
+         option_revap=0
+         option_tmin=0
+         izone_revap=0
+         izone_contfrac=0
+         izone_contcanop=0 
+         izone_irrig=2 
+         option_cond=0
+         strtrac(izone_poubelle)='res'
+         strtrac(izone_irrig)='irrig'
+         ! dans ce cas particulier, il y a des traceurs dans ORCHIDEE
+         ntracisoOR=ntiso
+      !========================================================================================================================
+      CASE(17,18)  !=== TRACING MINIMAL EXPERIENCES TEMPERATURES AS IN THE ARTICLE ABOUT LdG, BUT NO EVAPORATION
+      !========================================================================================================================
+         zone_temp1=12.0e-3  ! en kg/kg        
+         zone_tempf=0.2e-3   ! en kg/kg
+         zone_tempa=1.2e-3   ! courbure de la relation entre l'indice et la temperature: 0 pour lineaire
+!	 zone_temp1=14.0e-3  ! en kg/kg        
+!   	 zone_tempf=0.2e-3   ! en kg/kg
+!	 zone_tempa=0.5e-3       
+!        zone_temp1=10.0e-3  ! en kg/kg
+!   	 zone_tempf=0.5e-3   ! en kg/kg
+!	 zone_tempa=0.5e-3
+         ! zone 1: >= zone_temp1
+         ! zone 2 a 4: intermediaire, 
+         ! zone 5: <zone_tempf
+         nzone_opt=nzone_temp+3
+         izone_cont=nzone_temp+1
+         izone_oce=nzone_temp+1 
+         izone_poubelle=nzone_temp+1
+         izone_init=nzone_temp+1 ! zone d'initialisation par defaut
+         option_revap=1  
+         option_tmin=1 
+         option_cond=1
+         izone_revap=nzone_temp+3
+         izone_cond=nzone_temp+2
+         DO izone=1,nzone_temp
+            strtrac(izone) = 't'//TRIM(int2str(izone))
+            WRITE(*,*) 'izone, strtrac = ', izone, strtrac(izone)
+         END DO !do izone=1,nzone_temp
+         strtrac(izone_poubelle)='sfc'
+         strtrac(izone_cond)='con'
+         strtrac(izone_revap)='rev'
+         ! initialisation des zones de tempearture
+         DO izone=1,nzone_temp-1
+            zone_temp(izone) = zone_temp1+float(izone-1) &
+                             *(zone_tempa*float(izone-nzone_temp+1) &
+                             +(zone_tempf-zone_temp1)/float(nzone_temp-2))
+         END DO
+         WRITE(*,*) 'zone_temp1,zone_tempf,zone_tempa=',zone_temp1,zone_tempf,zone_tempa
+         WRITE(*,*) 'zone_temp=',zone_temp
+!        STOP          
+      !========================================================================================================================
+      CASE(19)     !=== TRACING TROPICAL AND EXTRATROPICAL VAPOUR
+      !========================================================================================================================
+         zone_temp1=12.0e-3  ! en kg/kg        
+         zone_tempf=0.2e-3   ! en kg/kg
+         zone_tempa=1.2e-3   ! courbure de la relation entre l'indice et la temperature: 0 pour lineaire, <0 pour plus de detail en bas
+!        zone_temp1=14.0e-3  ! en kg/kg        
+!        zone_tempf=0.2e-3   ! en kg/kg
+!        zone_tempa=0.5e-3
+!        zone_temp1=10.0e-3  ! en kg/kg        
+!        zone_tempf=0.5e-3   ! en kg/kg
+!        zone_tempa=0.5e-3
+         ! zone 1: >= zone_temp1
+         ! zone 2 a 4: intermediaire, 
+         ! zone 5: <zone_tempf
+         nzone_opt=nzone_temp+4
+         izone_cont=nzone_temp+1
+         izone_oce=nzone_temp+1 
+         izone_poubelle=nzone_temp+1
+         IF(option_seuil_tag_tmin == 1) THEN
+            izone_init=nzone_temp+1 ! zone d'initialisation par defaut
+         ELSE
             izone_init=nzone_temp
-          endif
-          option_revap=1   
-          izone_revap=nzone_temp+3
-          izone_cond=nzone_temp+2
-          izone_ddft=nzone_temp+4
-          option_tmin=1          
-          option_cond=1
-          do izone=1,nzone_temp
-            write(strz,'(i2.2)') izone
-            strtrac(izone)='t'//strz
-            write(*,*) 'izone,strz,strtrac=',izone,strz,strtrac(izone)
-          enddo !do izone=1,nzone_temp
-          strtrac(izone_poubelle)='sfc'
-          strtrac(izone_cond)='con'
-          strtrac(izone_revap)='rev'
-          strtrac(izone_ddft)='dft'
-
-        elseif (option_traceurs.eq.20) then
-          ! on vapeur tropical/extractropicale/recyclage extractropical
-          ! pour comprendre controles humidité et isotopes subtropicaux.        
-          
-          lim_tag20=35.0
-          call getin('lim_tag20',lim_tag20)
-          write(*,*) 'lim_tag20=',lim_tag20
-
-          ntraceurs_zone_opt=3
-          izone_cont=1
-          izone_oce=1
-          izone_poubelle=2 ! zone où on met les flux non physiques, de
-                ! réajustement
-          izone_init=2 ! zone d'initialisation par défaut
-          option_revap=0
-          option_tmin=0
-          izone_revap=0
-          izone_trop=2
-          izone_extra=3
-
-          strtrac(izone_trop)='tro' ! vapeur tropicale
-          strtrac(izone_extra)='ext' ! vapeur extractropicale evaporée 
-                ! dans les tropiques
-          strtrac(izone_cont)='rec' ! recyclage
-
-        elseif (option_traceurs.eq.21) then
-          ! on trace 2 boites 3D: UT tropicale et extratropiques 
-          ! fonctionnement similaire à option 5 pour taggage des zones
-          ! AMMA
-!          write(*,*) 'iso_traceurs_init 129'
-
-          ntraceurs_zone_opt=3
-          izone_cont=1
-          izone_oce=1
-          izone_poubelle=1 ! zone où on met les flux non physiques, de
-                ! réajustement
-          izone_init=1 ! zone d'initialisation par défaut
-          option_revap=0
-          option_tmin=0
-          izone_revap=0
-          izone_trop=2
-          izone_extra=3
-          option_cond=0
-
-          strtrac(izone_poubelle)='res'
-          strtrac(izone_trop)='tro'
-          strtrac(izone_extra)='ext'
-
-        elseif (option_traceurs.eq.22) then
-          ! on trace la vapeur qui a été processée dans zones de
-          ! convections à 3 niveaux: BT, MT et UT
-
-          lim_precip_tag22=20.0
-          call getin('lim_precip_tag22',lim_precip_tag22)
-          write(*,*) 'lim_precip_tag22=',lim_precip_tag22
-
-          ntraceurs_zone_opt=3
-          izone_cont=1
-          izone_oce=1
-          izone_poubelle=1 ! zone où on met les flux non physiques, de
-                ! réajustement
-          izone_init=1 ! zone d'initialisation par défaut
-          option_revap=0
-          option_tmin=0
-          izone_revap=0
-          izone_conv_BT=2
-          izone_conv_UT=3
-          option_cond=0
-
-          strtrac(izone_poubelle)='res'
-          strtrac(izone_conv_BT)='cbt'
-          strtrac(izone_conv_UT)='cut'
-
-        else
-            write(*,*) 'traceurs_init 36: option pas encore prévue'
-            stop
-        endif
-
-        
-          if (ntraceurs_zone_opt.ne.ntraceurs_zone) then
-                write(*,*) 'ntraceurs_zone_opt,ntraceurs_zone=', &
-                        & ntraceurs_zone_opt,ntraceurs_zone
-                call abort_physic ('isotrac_mod','ntraceurs_zone incoherent',1)
-          endif
-
-       
-        ! seuil sur le taux de condensation
-        if (option_tmin.eq.1) then
-          seuil_tag_tmin=0.01
-          call getin('seuil_tag_tmin',seuil_tag_tmin)
-          write(*,*) 'seuil_tag_tmin=',seuil_tag_tmin
-
-          seuil_tag_tmin_ls=seuil_tag_tmin
-          call getin('seuil_tag_tmin_ls',seuil_tag_tmin_ls)
-          write(*,*) 'seuil_tag_tmin_ls=',seuil_tag_tmin_ls
-
-          option_seuil_tag_tmin=1
-          call getin('option_seuil_tag_tmin',option_seuil_tag_tmin)
-          write(*,*) 'option_seuil_tag_tmin=',option_seuil_tag_tmin
-        endif
-
-
-        do ixt=1,niso
-           index_zone(ixt)=0
-           index_iso(ixt)=ixt
-        enddo
-        itrac=niso        
-        do izone=1,ntraceurs_zone
-          do ixt=1,niso
-            itrac=itrac+1
-            index_zone(itrac)=izone
-            index_iso(itrac)=ixt
-            index_trac_loc(izone,ixt)=itrac
-            if (index_trac(izone,ixt).ne.index_trac_loc(izone,ixt)) then
-                write(*,*) 'isotrac 989: izone,ixt,itrac=',izone,ixt,itrac
-                CALL abort_physic ('isotrac','isotrac 989',1)
-            endif
-          enddo
-        enddo
+         END IF
+         option_revap=1   
+         izone_revap=nzone_temp+3
+         izone_cond=nzone_temp+2
+         izone_ddft=nzone_temp+4
+         option_tmin=1          
+         option_cond=1
+         DO izone=1,nzone_temp
+            strtrac(izone) = 't'//TRIM(int2str(izone))
+            WRITE(*,*) 'izone, strtrac = ', izone, strtrac(izone)
+         END DO
+         strtrac(izone_poubelle)='sfc'
+         strtrac(izone_cond)='con'
+         strtrac(izone_revap)='rev'
+         strtrac(izone_ddft)='dft'
+      !========================================================================================================================
+      CASE(20)     !=== TRACING TROPICAL/EXTRATROPICAL/EXTRATROPICAL RECYCLING TO STUDY HUMIDITY AND SUBTROPICAL ISOTOPES CONTROL
+      !========================================================================================================================
+         CALL get_in('lim_tag20', lim_tag20, 35.0)
+         nzone_opt=3
+         izone_cont=1
+         izone_oce=1
+         izone_poubelle=2    ! zone ou on met les flux non physiques, de reajustement
+         izone_init=2        ! zone d'initialisation par defaut
+         option_revap=0
+         option_tmin=0
+         izone_revap=0
+         izone_trop=2
+         izone_extra=3
+         strtrac(izone_trop)='tro'     ! tropical vapour
+         strtrac(izone_extra)='ext'    ! extratropical vapour evaporated in the tropics
+         strtrac(izone_cont)='rec'     ! recycling
+      !========================================================================================================================
+      CASE(21)     !=== TRACING TWO 3D BOXES: TROPICAL UT AND EXTRATROPICS ; SIMILAR TO 5 FOR AMMA ZONES TAGGING
+      !========================================================================================================================
+!        WRITE(*,*) 'iso_traceurs_init 129'
+         nzone_opt=3
+         izone_cont=1
+         izone_oce=1
+         izone_poubelle=1    ! zone ou on met les flux non physiques, de reajustement
+         izone_init=1        ! zone d'initialisation par defaut
+         option_revap=0
+         option_tmin=0
+         izone_revap=0
+         izone_trop=2
+         izone_extra=3
+         option_cond=0
+         strtrac(izone_poubelle)='res'
+         strtrac(izone_trop)='tro'
+         strtrac(izone_extra)='ext'
+      !========================================================================================================================
+      CASE(22)     !=== TRACING WATER VAPOUR PROCESSED IN THE 3-LEVELS SCONVECTION ZONES BT, MT AND UT
+      !========================================================================================================================
+         CALL get_in('lim_precip_tag22', lim_precip_tag22, 20.0)
+         nzone_opt=3
+         izone_cont=1
+         izone_oce=1
+         izone_poubelle=1    ! zone ou on met les flux non physiques, de reajustement
+         izone_init=1        ! zone d'initialisation par defaut
+         option_revap=0
+         option_tmin=0
+         izone_revap=0
+         izone_conv_BT=2
+         izone_conv_UT=3
+         option_cond=0
+         strtrac(izone_poubelle)='res'
+         strtrac(izone_conv_BT)='cbt'
+         strtrac(izone_conv_UT)='cut'
+      CASE DEFAULT
+         WRITE(*,*) 'traceurs_init 36: option pas encore prevue' ; STOP
+   END SELECT
+
+   IF(nzone_opt /= nzone) THEN
+      WRITE(*,*) 'nzone_opt, nzone=', nzone_opt, nzone
+      CALL abort_physic ('isotrac_mod','nzone incoherent',1)
+   END IF
+
+   !--- Condensation rate threshold
+   IF(option_tmin == 1) THEN
+      seuil_tag_tmin = 0.01
+      CALL get_in('seuil_tag_tmin',        seuil_tag_tmin,        0.01)
+      CALL get_in('seuil_tag_tmin_ls',     seuil_tag_tmin_ls,     seuil_tag_tmin)
+      CALL get_in('option_seuil_tag_tmin', option_seuil_tag_tmin, 1)
+   END IF
+
+   index_zone = [(strIdx(isoZone, strTail(isoName(ixt) ,'_',.TRUE.)), ixt=1, ntiso)]
+   index_iso  = [(strIdx(isoName, strHead(isoName(ixt) ,'_',.TRUE.)), ixt=1, ntiso)]
+   itZonIso_loc = itZonIso(:,:)
 #ifdef ISOVERIF
-!        call iso_verif_egalite(float(itrac),float(ntraciso), &
-!     &           'traceurs_init 50')
-        if (itrac.ne.ntraciso) then
-          write(*,*) 'traceurs_init 50'
-          stop
-        endif
-     
-        write(*,*) 'traceurs_init 65: bilan de l''init:'
-        write(*,*) 'index_zone=',index_zone(1:ntraciso)
-        write(*,*) 'index_iso=',index_iso(1:ntraciso)
-        write(*,*) 'index_trac=',index_trac(1:ntraceurs_zone,1:niso)
-        do izone=1,ntraceurs_zone
-          write(*,*) 'strtrac(',izone,')=',strtrac(izone)
-        enddo !do izone=1,ntraceurs_zone
-        write(*,*) 'ntracisoOR=',ntracisoOR
+   WRITE(*,*) 'traceurs_init 65: bilan de l''init:'
+   WRITE(*,*) 'index_zone = '//TRIM(strStack(int2str(index_zone(1:ntiso))))
+   WRITE(*,*) 'index_iso  = '//TRIM(strStack(int2str(index_iso (1:ntiso))))
+   DO izone=1,nzone
+      WRITE(*,*)'itZonIso('//TRIM(int2str(izone))//',:) = '//strStack(int2str(itZonIso(izone,:)))
+   END DO
+   DO izone=1,nzone
+      WRITE(*,*)'strtrac('//TRIM(int2str(izone))//',:) = '//TRIM(strtrac(izone))
+   END DO
+   WRITE(*,*) 'ntracisoOR=',ntracisoOR
 #endif  
 
-        end subroutine iso_traceurs_init
-
+END SUBROUTINE iso_traceurs_init
 
 END MODULE isotrac_mod
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/isotrac_routines_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/isotrac_routines_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/isotrac_routines_mod.F90	(revision 4446)
@@ -8,4 +8,5 @@
 ! isotopes_verif a besoin de isotopes et isotrac
 ! isotrac n'a besoin que de isotopes
+    USE infotrac_phy, ONLY: ntraciso=>ntiso, niso, index_trac=>itZonIso, ntraceurs_zone=>nzone
 IMPLICIT NONE
 
@@ -17,5 +18,4 @@
      &           ncum,izone)
 
-    USE infotrac_phy, ONLY: ntraciso,niso,index_trac
     USE isotopes_mod, ONLY: ridicule,iso_eau
 
@@ -63,5 +63,4 @@
      &          xtp_avantevap_cas,liq,hdiag)
 
-    USE infotrac_phy, ONLY: ntraciso,niso,index_trac
     USE isotopes_mod, ONLY: ridicule,iso_eau,iso_HDO,ridicule_evap
     USE isotrac_mod, only: option_revap,evap_franche,izone_revap, &
@@ -231,5 +230,4 @@
      &    nloc,ncum,nd,i,izone)
 
-    USE infotrac_phy, ONLY: ntraciso,niso,index_trac
     USE isotopes_mod, ONLY: iso_eau
 #ifdef ISOVERIF        
@@ -320,5 +318,4 @@
      &    nloc,ncum,nd,i,izone)
 
-    USE infotrac_phy, ONLY: ntraciso,niso,index_trac
     USE isotopes_mod, ONLY: iso_eau
 #ifdef ISOVERIF
@@ -408,5 +405,4 @@
      &    nloc,ncum,nd,i,izone)
 
-    USE infotrac_phy, ONLY: ntraciso,niso,index_trac
     USE isotopes_mod, ONLY: ridicule,iso_eau
 #ifdef ISOVERIF
@@ -476,5 +472,4 @@
      &    nloc,ncum,nd,izone)
 
-    USE infotrac_phy, ONLY: ntraciso,niso,index_trac
     USE isotopes_mod, ONLY: ridicule,iso_eau
 #ifdef ISOVERIF
@@ -643,5 +638,4 @@
      &    nloc,ncum,nd,i,frac_sublim,izone)
 
-    USE infotrac_phy, ONLY: ntraciso,niso,index_trac
     USE isotopes_mod, ONLY: ridicule,iso_eau
 #ifdef ISOVERIF
@@ -802,5 +796,4 @@
      &       xtrevap_tag,liq,hdiag)
 
-    USE infotrac_phy, ONLY: ntraciso,niso,index_trac
     USE isotopes_mod, ONLY: ridicule,iso_eau
     USE isotrac_mod, only: option_revap,evap_franche
@@ -899,5 +892,4 @@
      &       klon,izone,ptrac)
 
-    USE infotrac_phy, ONLY: ntraciso,niso,index_trac
     USE isotopes_mod, ONLY: ridicule,iso_eau
 #ifdef ISOVERIF
@@ -986,5 +978,4 @@
      &       klon,izone)
 
-    USE infotrac_phy, ONLY: ntraciso,niso,index_trac
     USE isotopes_mod, ONLY: ridicule,iso_eau
 #ifdef ISOVERIF
@@ -1052,6 +1043,4 @@
      &    klon,izone,zxt,xtrevap_tag)
 
-USE infotrac_phy, ONLY: ntraciso,niso, &
-        ntraceurs_zone,index_trac
 #ifdef ISOVERIF
 USE isotopes_verif_mod
@@ -1124,10 +1113,10 @@
       USE isotrac_mod, only: use_bassin_atlantic,use_bassin_medit, &
 &       use_bassin_indian,use_bassin_austral,use_bassin_pacific, &
-&       use_bassin_merarabie,use_bassin_golfebengale,use_bassin_indiansud, &
-&       use_bassin_tropics,use_bassin_midlats,use_bassin_hauteslats, &
+&       use_bassin_MerArabie,use_bassin_BengalGolf,use_bassin_SouthIndian, &
+&       use_bassin_tropics,use_bassin_midlats,use_bassin_HighLats, &
 &       bassin_atlantic,bassin_medit, &
 &       bassin_indian,bassin_austral,bassin_pacific, &
-&       bassin_merarabie,bassin_golfebengale,bassin_indiansud, &
-&       bassin_tropics,bassin_midlats,bassin_hauteslats
+&       bassin_MerArabie,bassin_BengalGolf,bassin_SouthIndian, &
+&       bassin_tropics,bassin_midlats,bassin_HighLats
       implicit none
       ! répond true si lat,lon se trouve dans le bassin numéroté bassin
@@ -1148,6 +1137,5 @@
       write(*,*) 'is_in_basin 84: entree,bassin=',bassin
 #endif
-      if ((use_bassin_atlantic.eq.1).and. &
-     &           (bassin.eq.bassin_atlantic)) then
+      if (use_bassin_atlantic .and. bassin==bassin_atlantic) then
 #ifdef ISOVERIF           
           write(*,*) 'bassin Atlantique?'
@@ -1180,6 +1168,5 @@
           endif
 
-      else if ((use_bassin_medit.eq.1).and. &
-     &           (bassin.eq.bassin_medit)) then
+      else if (use_bassin_medit .and. bassin==bassin_medit) then
 #ifdef ISOVERIF           
           write(*,*) 'bassin Medit?'
@@ -1194,6 +1181,5 @@
           endif
 
-      else if ((use_bassin_indian.eq.1).and. &
-     &           (bassin.eq.bassin_indian)) then
+      else if (use_bassin_indian .and. bassin==bassin_indian) then
 #ifdef ISOVERIF           
           write(*,*) 'bassin indian?'
@@ -1210,6 +1196,5 @@
           endif   
 
-      else if ((use_bassin_indiansud.eq.1).and. &
-     &           (bassin.eq.bassin_indiansud)) then
+      else if (use_bassin_SouthIndian .and. bassin==bassin_SouthIndian) then
 #ifdef ISOVERIF           
           write(*,*) 'bassin indian hemisphere Sud?'
@@ -1220,6 +1205,5 @@
           endif
           
-      else if ((use_bassin_merarabie.eq.1).and. &
-     &           (bassin.eq.bassin_merarabie)) then
+      else if (use_bassin_MerArabie .and. bassin==bassin_MerArabie) then
 #ifdef ISOVERIF           
           write(*,*) 'bassin Mer d''Arabie?'
@@ -1230,6 +1214,5 @@
           endif 
 
-      else if ((use_bassin_golfebengale.eq.1).and. &
-     &           (bassin.eq.bassin_golfebengale)) then
+      else if (use_bassin_BengalGolf .and. bassin==bassin_BengalGolf) then
 #ifdef ISOVERIF           
           write(*,*) 'bassin Golfe du Bengale?'
@@ -1240,6 +1223,5 @@
           endif         
 
-      else if ((use_bassin_pacific.eq.1).and. &
-     &           (bassin.eq.bassin_pacific)) then
+      else if (use_bassin_pacific .and. bassin==bassin_pacific) then
 #ifdef ISOVERIF           
           write(*,*) 'bassin Pacific?'
@@ -1278,6 +1260,5 @@
           endif
 
-      else if ((use_bassin_austral.eq.1).and. &
-     &           (bassin.eq.bassin_austral)) then  
+      else if (use_bassin_austral .and. bassin==bassin_austral) then  
 #ifdef ISOVERIF           
           write(*,*) 'bassin austral?'
@@ -1288,6 +1269,5 @@
           endif  
 
-      else if ((use_bassin_hauteslats.eq.1).and. &
-     &           (bassin.eq.bassin_hauteslats)) then  
+      else if (use_bassin_HighLats .and. bassin==bassin_HighLats) then  
 #ifdef ISOVERIF           
           write(*,*) 'bassin hautes lats?'
@@ -1298,6 +1278,5 @@
           endif
 
-      else if ((use_bassin_tropics.eq.1).and. &
-     &           (bassin.eq.bassin_tropics)) then  
+      else if (use_bassin_tropics .and. bassin==bassin_tropics) then  
 #ifdef ISOVERIF           
           write(*,*) 'bassin tropics?'
@@ -1308,6 +1287,5 @@
           endif
 
-       else if ((use_bassin_midlats.eq.1).and. &
-     &           (bassin.eq.bassin_midlats)) then  
+       else if (use_bassin_midlats .and. bassin==bassin_midlats) then  
 #ifdef ISOVERIF           
           write(*,*) 'bassin mid lats?'
@@ -1325,14 +1303,14 @@
           write(*,*) 'bassin_indian=' ,bassin_indian
           write(*,*) 'bassin_austral=' ,bassin_austral
-          write(*,*) 'bassin_merarabie=' ,bassin_merarabie
-          write(*,*) 'bassin_golfebengale=' ,bassin_golfebengale
-          write(*,*) 'bassin_indiansud=' ,bassin_indiansud
+          write(*,*) 'bassin_MerArabie=' ,bassin_MerArabie
+          write(*,*) 'bassin_BengalGolf=' ,bassin_BengalGolf
+          write(*,*) 'bassin_SouthIndian=' ,bassin_SouthIndian
           write(*,*) 'use_bassin_atlantic=' ,use_bassin_atlantic  
           write(*,*) 'use_bassin_medit=' ,use_bassin_medit
           write(*,*) 'use_bassin_indian=' ,use_bassin_indian
           write(*,*) 'use_bassin_austral=' ,use_bassin_austral
-          write(*,*) 'use_bassin_merarabie=' ,use_bassin_merarabie
-          write(*,*) 'use_bassin_golfebengale=' ,use_bassin_golfebengale
-          write(*,*) 'use_bassin_indiansud=' ,use_bassin_indiansud
+          write(*,*) 'use_bassin_MerArabie=' ,use_bassin_MerArabie
+          write(*,*) 'use_bassin_BengalGolf=' ,use_bassin_BengalGolf
+          write(*,*) 'use_bassin_SouthIndian=' ,use_bassin_SouthIndian
           stop
       endif
@@ -1342,5 +1320,5 @@
 
       subroutine find_bassin(lat,lon,bassin)
-      use isotrac_mod, only: izone_poubelle,ntraceurs_zone,option_traceurs, &
+      use isotrac_mod, only: izone_poubelle,ntraceurs_zone=>ntiso,option_traceurs, &
 &        bassin_map
 #ifdef ISOVERIF
@@ -1517,6 +1495,4 @@
         subroutine isotrac_recolorise_tmin(xt,t)
         USE dimphy, only: klon, klev
-        USE infotrac_phy, ONLY: ntraciso,niso, &
-        ntraceurs_zone,index_trac
         USE isotrac_mod, only: zone_temp,nzone_temp
 #ifdef ISOVERIF
@@ -1603,6 +1579,4 @@
         subroutine isotrac_recolorise_tmin_sfrev(xt,t)
         USE dimphy, only: klon,klev
-        USE infotrac_phy, ONLY: ntraciso,niso, &
-        ntraceurs_zone,index_trac
         USE isotrac_mod, only: nzone_temp,zone_temp
 #ifdef ISOVERIF
@@ -1661,6 +1635,4 @@
         subroutine isotrac_recolorise_saturation(xt,rh,lat,pres)
         USE dimphy, only: klon,klev
-        USE infotrac_phy, ONLY: ntraciso,niso, &
-        ntraceurs_zone,index_trac
 #ifdef ISOVERIF
         USE isotopes_verif_mod
@@ -1727,6 +1699,4 @@
         subroutine isotrac_recolorise_boite(xt,boite_map)
         USE dimphy, only: klon,klev
-        USE infotrac_phy, ONLY: ntraciso,niso, &
-        ntraceurs_zone,index_trac
 #ifdef ISOVERIF
         USE isotopes_verif_mod
@@ -1781,6 +1751,4 @@
         subroutine isotrac_recolorise_extra(xt,rlat)
         USE dimphy, only: klon,klev
-        USE infotrac_phy, ONLY: ntraciso,niso, &
-        ntraceurs_zone,index_trac
         usE isotrac_mod, only: lim_tag20,izone_trop,izone_extra
 #ifdef ISOVERIF
@@ -1830,6 +1798,4 @@
         subroutine isotrac_recolorise_conv(xt,rlat,presnivs,rain_con)
         USE dimphy, only: klon,klev
-        USE infotrac_phy, ONLY: ntraciso,niso, &
-        ntraceurs_zone,index_trac
         use isotrac_mod, only: lim_precip_tag22, &
 &       izone_conv_BT,izone_conv_UT
@@ -1902,6 +1868,4 @@
         subroutine boite_AMMA_init(lat,lon,presnivs,boite_map)
         USE dimphy, only: klon,klev
-        USE infotrac_phy, ONLY: ntraciso,niso, &
-        ntraceurs_zone,index_trac
 #ifdef ISOVERIF
         USE isotopes_verif_mod
@@ -1957,6 +1921,4 @@
         subroutine boite_UT_extra_init(lat,lon,presnivs,boite_map)
         USE dimphy, only: klon,klev
-        USE infotrac_phy, ONLY: ntraciso,niso, &
-        ntraceurs_zone,index_trac
         use isotrac_mod, only: izone_extra,izone_trop
 #ifdef ISOVERIF
@@ -2095,6 +2057,4 @@
      &           seuil_in)
         USE dimphy, only: klon,klev
-        USE infotrac_phy, ONLY: ntraciso,niso, &
-        ntraceurs_zone,index_trac
         USE isotopes_mod, only: bidouille_anti_divergence,iso_eau
         use isotrac_mod, only: option_seuil_tag_tmin,izone_cond, &
@@ -2304,6 +2264,4 @@
         subroutine bassin_map_init_opt20(lat,bassin_map)
         USE dimphy, only: klon
-        USE infotrac_phy, ONLY: ntraciso,niso, &
-        ntraceurs_zone,index_trac
         use isotrac_mod, only: izone_cont,izone_trop,lim_tag20
 #ifdef ISOVERIF
@@ -2334,5 +2292,4 @@
         USE geometry_mod, ONLY : latitude_deg
         USE dimphy, only: klon,klev
-        use infotrac_phy, only: ntraciso
         use isotrac_mod, only: option_traceurs,boite_map
         implicit none
@@ -2365,6 +2322,6 @@
         subroutine iso_verif_traceur_jbid_vect(x,n,m)
         USE isotopes_mod, ONLY: bidouille_anti_divergence,iso_eau,ridicule
-        USE infotrac_phy, ONLY: index_trac,niso,ntraciso
-        use isotrac_mod, only: ntraceurs_zone
+        !use isotrac_mod, only: ntraceurs_zone=>nzone
+        USE infotrac_phy, ONLY: ntraceurs_zone=>nzone
         implicit none
         
@@ -2430,5 +2387,4 @@
         subroutine iso_verif_traceur_jbidouille(x)
         USE isotopes_mod, ONLY: bidouille_anti_divergence,iso_eau,ridicule
-        USE infotrac_phy, ONLY: index_trac,niso,ntraciso,ntraceurs_zone
         implicit none
         
@@ -2470,5 +2426,4 @@
         subroutine iso_verif_traceur_jbid_pos(x)
         USE isotopes_mod, ONLY: bidouille_anti_divergence,iso_eau,ridicule
-        USE infotrac_phy, ONLY: index_trac,niso,ntraciso,ntraceurs_zone
 !#ifdef ISOVERIF
 !        use isotopes_verif_mod, only: iso_verif_traceur_pbidouille
@@ -2544,5 +2499,4 @@
         subroutine iso_verif_traceur_jbid_pos_vect(n,m,x)
         USE isotopes_mod, ONLY: bidouille_anti_divergence,iso_eau,ridicule
-        USE infotrac_phy, ONLY: index_trac,niso,ntraciso,ntraceurs_zone
 #ifdef ISOVERIF
         USE isotopes_verif_mod
@@ -2625,5 +2579,4 @@
         subroutine iso_verif_traceur_jbid_pos2(x,q)
         USE isotopes_mod, ONLY: bidouille_anti_divergence,iso_eau,ridicule
-        USE infotrac_phy, ONLY: index_trac,niso,ntraciso,ntraceurs_zone
 #ifdef ISOVERIF
         use isotopes_verif_mod
@@ -2696,5 +2649,4 @@
         subroutine iso_verif_traceur_jbid_vect1D(x,n)
         USE isotopes_mod, ONLY: bidouille_anti_divergence,iso_eau,ridicule
-        USE infotrac_phy, ONLY: index_trac,niso,ntraciso,ntraceurs_zone
         implicit none
         
@@ -2739,5 +2691,4 @@
 
         subroutine iso_verif_traceur_pbidouille(x,err_msg)
-        USE infotrac_phy, ONLY: ntraciso
         use isotopes_verif_mod
         implicit none
@@ -2765,5 +2716,4 @@
 
         function iso_verif_traceur_pbid_ns(x,err_msg)
-        USE infotrac_phy, ONLY: ntraciso
         use isotopes_mod, ONLY: iso_HDO,bidouille_anti_divergence
         use isotrac_mod, only: ridicule_trac
@@ -2828,5 +2778,4 @@
 
         subroutine iso_verif_traceur_pbid_vect(x,n,m,err_msg)
-        USE infotrac_phy, ONLY: ntraciso
         use isotopes_mod, ONLY: iso_HDO,bidouille_anti_divergence
         use isotopes_verif_mod
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/limit_read_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/limit_read_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/limit_read_mod.F90	(revision 4446)
@@ -281,5 +281,4 @@
     USE indice_sol_mod
 #ifdef ISO
-    !USE infotrac_phy, ONLY: use_iso
     USE isotopes_mod, ONLY : iso_HTO,ok_prod_nucl_tritium
 #ifdef ISOVERIF
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/ocean_forced_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/ocean_forced_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/ocean_forced_mod.F90	(revision 4446)
@@ -42,5 +42,5 @@
     use config_ocean_skin_m, only: activate_ocean_skin
 #ifdef ISO
-  USE infotrac_phy, ONLY: ntraciso,niso
+  USE infotrac_phy, ONLY: ntiso,niso
     USE isotopes_routines_mod, ONLY: calcul_iso_surf_oce_vectall, &
 &       calcul_iso_surf_sic_vectall    
@@ -73,6 +73,6 @@
 
 #ifdef ISO
-    REAL, DIMENSION(ntraciso,klon), INTENT(IN)    :: xtprecip_rain, xtprecip_snow
-    REAL, DIMENSION(ntraciso,klon), INTENT(IN)    :: xtspechum
+    REAL, DIMENSION(ntiso,klon), INTENT(IN)  :: xtprecip_rain, xtprecip_snow
+    REAL, DIMENSION(ntiso,klon), INTENT(IN)  :: xtspechum
     real, dimension(klon), intent(IN) :: rlat
 #endif
@@ -98,5 +98,5 @@
 
 #ifdef ISO     
-    REAL, DIMENSION(ntraciso,klon), INTENT(OUT)    :: xtevap ! isotopes in evaporation flux
+    REAL, DIMENSION(ntiso,klon), INTENT(OUT) :: xtevap ! isotopes in evaporation flux
     REAL, DIMENSION(klon), INTENT(out)    :: h1 ! just a diagnostic, not useful for the simulation
 #endif
@@ -271,5 +271,5 @@
     USE phys_output_var_mod, ONLY : sens_prec_liq_o, sens_prec_sol_o, lat_prec_liq_o, lat_prec_sol_o
 #ifdef ISO
-  USE infotrac_phy, ONLY: niso,ntraciso
+  USE infotrac_phy, ONLY: niso, ntiso
     USE isotopes_routines_mod, ONLY: calcul_iso_surf_oce_vectall, &
 &       calcul_iso_surf_sic_vectall 
@@ -303,8 +303,8 @@
     real, intent(in):: rhoa(:) ! (knon) density of moist air  (kg / m3)
 #ifdef ISO
-    REAL, DIMENSION(ntraciso,klon), INTENT(IN)    :: xtprecip_rain, xtprecip_snow
-    REAL, DIMENSION(ntraciso,klon), INTENT(IN)    :: xtspechum
-    REAL, DIMENSION(niso,klon), INTENT(IN)    :: Roce 
-    REAL, DIMENSION(niso,klon), INTENT(IN)        :: Rland_ice
+    REAL, DIMENSION(ntiso,klon), INTENT(IN)    :: xtprecip_rain, xtprecip_snow
+    REAL, DIMENSION(ntiso,klon), INTENT(IN)    :: xtspechum
+    REAL, DIMENSION(niso,klon),  INTENT(IN)    :: Roce 
+    REAL, DIMENSION(niso,klon),  INTENT(IN)    :: Rland_ice
 #endif
 
@@ -330,5 +330,5 @@
     REAL, DIMENSION(klon), INTENT(OUT)            :: dflux_s, dflux_l      
 #ifdef ISO     
-    REAL, DIMENSION(ntraciso,klon), INTENT(OUT)    :: xtevap
+    REAL, DIMENSION(ntiso,klon), INTENT(OUT)    :: xtevap
 #endif      
 
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/pbl_surface_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/pbl_surface_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/pbl_surface_mod.F90	(revision 4446)
@@ -14,5 +14,5 @@
   USE mod_grid_phy_lmdz,   ONLY : klon_glo
   USE ioipsl
-  USE surface_data,        ONLY : type_ocean, ok_veget
+  USE surface_data,        ONLY : type_ocean, ok_veget, landice_opt
   USE surf_land_mod,       ONLY : surf_land
   USE surf_landice_mod,    ONLY : surf_landice
@@ -31,4 +31,7 @@
                                   wx_pbl_check, wx_pbl_dts_check, wx_evappot
   use config_ocean_skin_m, only: activate_ocean_skin
+#ifdef ISO
+  USE infotrac_phy, ONLY: niso,ntraciso=>ntiso    
+#endif
 
   IMPLICIT NONE
@@ -193,5 +196,4 @@
     USE indice_sol_mod
     USE print_control_mod, ONLY: lunout
-  USE infotrac_phy, ONLY: niso,ntraciso ! ajout C Risi pour isos  
 #ifdef ISOVERIF
     USE isotopes_mod, ONLY: iso_eau,ridicule
@@ -395,5 +397,4 @@
     USE print_control_mod,  ONLY : prt_level,lunout
 #ifdef ISO
-  USE infotrac_phy, ONLY: ntraciso,niso ! ajout C Risi pour isos    
   USE isotopes_mod, ONLY: Rdefault,iso_eau
 #ifdef ISOVERIF
@@ -405,6 +406,7 @@
 #endif
     USE ioipsl_getin_p_mod, ONLY : getin_p
-    use phys_state_var_mod, only: ds_ns, dt_ns, delta_sst, delta_sal, zsig, zmea
-    use phys_output_var_mod, only: dter, dser, tkt, tks, taur, sss
+    use phys_state_var_mod, only: ds_ns, dt_ns, delta_sst, delta_sal, dter, &
+         dser, dt_ds, zsig, zmea
+    use phys_output_var_mod, only: tkt, tks, taur, sss
 #ifdef CPP_XIOS
     USE wxios, ONLY: missing_val
@@ -1028,8 +1030,8 @@
     ! Martin
 
-    REAL, DIMENSION(klon):: ydelta_sst, ydelta_sal, yds_ns, ydt_ns, ydter, ydser, &
-         ytkt, ytks, ytaur, ysss
-    ! compression of delta_sst, delta_sal, ds_ns, dt_ns, dter, dser, tkt, tks,
-    ! taur, sss on ocean points
+    REAL, DIMENSION(klon):: ydelta_sst, ydelta_sal, yds_ns, ydt_ns, ydter, &
+         ydser, ydt_ds, ytkt, ytks, ytaur, ysss
+    ! compression of delta_sst, delta_sal, ds_ns, dt_ns, dter, dser,
+    ! dt_ds, tkt, tks, taur, sss on ocean points
 
 #ifdef ISO
@@ -1812,4 +1814,7 @@
              ydelta_sal(:knon) = delta_sal(ni(:knon))
              ydelta_sst(:knon) = delta_sst(ni(:knon))
+             ydter(:knon) = dter(ni(:knon))
+             ydser(:knon) = dser(ni(:knon))
+             ydt_ds(:knon) = dt_ds(ni(:knon))
           end if
           
@@ -2381,67 +2386,70 @@
        CASE(is_lic)
           ! Martin
-          CALL surf_landice(itap, dtime, knon, ni, &
-               rlon, rlat, debut, lafin, &
-               yrmu0, ylwdown, yalb, zgeo1, &
-               ysolsw, ysollw, yts, ypplay(:,1), &
-!!jyg               ycdragh, ycdragm, yrain_f, ysnow_f, yt(:,1), yq(:,1),&
-               ycdragh, ycdragm, yrain_f, ysnow_f, yt1, yq1,&
-               AcoefH, AcoefQ, BcoefH, BcoefQ, &
-               AcoefU, AcoefV, BcoefU, BcoefV, &
-               ypsref, yu1, yv1, ygustiness, yrugoro, pctsrf, &
-               ysnow, yqsurf, yqsol, yagesno, &
-               ytsoil, yz0m, yz0h, SFRWL, yalb_dir_new, yalb_dif_new, yevap,yfluxsens,yfluxlat, &
-               ytsurf_new, y_dflux_t, y_dflux_q, &
-               yzmea, yzsig, ycldt, &
-               ysnowhgt, yqsnow, ytoice, ysissnow, &
-               yalb3_new, yrunoff, &
-               y_flux_u1, y_flux_v1 &
-#ifdef ISO
-           &    ,yxtrain_f, yxtsnow_f,yxt1,yRland_ice &
-           &    ,yxtsnow,yxtsol,yxtevap &
+          IF (landice_opt .LT. 2) THEN
+             ! Land ice is treated by LMDZ and not by ORCHIDEE
+             
+             CALL surf_landice(itap, dtime, knon, ni, &
+                  rlon, rlat, debut, lafin, &
+                  yrmu0, ylwdown, yalb, zgeo1, &
+                  ysolsw, ysollw, yts, ypplay(:,1), &
+                  !!jyg               ycdragh, ycdragm, yrain_f, ysnow_f, yt(:,1), yq(:,1),&
+                  ycdragh, ycdragm, yrain_f, ysnow_f, yt1, yq1,&
+                  AcoefH, AcoefQ, BcoefH, BcoefQ, &
+                  AcoefU, AcoefV, BcoefU, BcoefV, &
+                  ypsref, yu1, yv1, ygustiness, yrugoro, pctsrf, &
+                  ysnow, yqsurf, yqsol, yagesno, &
+                  ytsoil, yz0m, yz0h, SFRWL, yalb_dir_new, yalb_dif_new, yevap,yfluxsens,yfluxlat, &
+                  ytsurf_new, y_dflux_t, y_dflux_q, &
+                  yzmea, yzsig, ycldt, &
+                  ysnowhgt, yqsnow, ytoice, ysissnow, &
+                  yalb3_new, yrunoff, &
+                  y_flux_u1, y_flux_v1 &
+#ifdef ISO
+                  &    ,yxtrain_f, yxtsnow_f,yxt1,yRland_ice &
+                  &    ,yxtsnow,yxtsol,yxtevap &
 #endif              
-           &    )
-
-!jyg<
-!!          alb3_lic(:)=0.
-!>jyg
-          DO j = 1, knon
-             i = ni(j)
-             alb3_lic(i) = yalb3_new(j)
-             snowhgt(i)   = ysnowhgt(j)
-             qsnow(i)     = yqsnow(j)
-             to_ice(i)    = ytoice(j)
-             sissnow(i)   = ysissnow(j)
-             runoff(i)    = yrunoff(j)
-          ENDDO
-          ! Martin
-! Special DICE MPL 05082013 puis BOMEX MPL 20150410
-       IF (ok_prescr_ust) THEN
-          DO j=1,knon
-          y_flux_u1(j)=ycdragm(j)*(1.+sqrt(yu(j,1)*yu(j,1)+yv(j,1)*yv(j,1)))*yu(j,1)*ypplay(j,1)/RD/yt(j,1)
-          y_flux_v1(j)=ycdragm(j)*(1.+sqrt(yu(j,1)*yu(j,1)+yv(j,1)*yv(j,1)))*yv(j,1)*ypplay(j,1)/RD/yt(j,1)
-          ENDDO
-      ENDIF
-
+                  &    )
+             
+             !jyg<
+             !!          alb3_lic(:)=0.
+             !>jyg
+             DO j = 1, knon
+                i = ni(j)
+                alb3_lic(i) = yalb3_new(j)
+                snowhgt(i)   = ysnowhgt(j)
+                qsnow(i)     = yqsnow(j)
+                to_ice(i)    = ytoice(j)
+                sissnow(i)   = ysissnow(j)
+                runoff(i)    = yrunoff(j)
+             ENDDO
+             ! Martin
+             ! Special DICE MPL 05082013 puis BOMEX MPL 20150410
+             IF (ok_prescr_ust) THEN
+                DO j=1,knon
+                   y_flux_u1(j)=ycdragm(j)*(1.+sqrt(yu(j,1)*yu(j,1)+yv(j,1)*yv(j,1)))*yu(j,1)*ypplay(j,1)/RD/yt(j,1)
+                   y_flux_v1(j)=ycdragm(j)*(1.+sqrt(yu(j,1)*yu(j,1)+yv(j,1)*yv(j,1)))*yv(j,1)*ypplay(j,1)/RD/yt(j,1)
+                ENDDO
+             ENDIF
+             
 #ifdef ISOVERIF
-        do j=1,knon
-          do ixt=1,ntraciso
-            call iso_verif_noNaN(yxtevap(ixt,j), &
-         &      'pbl_surface 1095a: apres surf_landice')
-            call iso_verif_noNaN(yxtsol(ixt,j), &
-         &      'pbl_surface 1095b: apres surf_landice')
-          enddo
-        enddo
+             do j=1,knon
+                do ixt=1,ntraciso
+                   call iso_verif_noNaN(yxtevap(ixt,j), &
+                        &      'pbl_surface 1095a: apres surf_landice')
+                   call iso_verif_noNaN(yxtsol(ixt,j), &
+                        &      'pbl_surface 1095b: apres surf_landice')
+                enddo
+             enddo
 #endif
 #ifdef ISOVERIF
-        !write(*,*) 'pbl_surface_mod 1060: sortie surf_landice'
-        do j=1,knon
-          if (iso_eau.gt.0) then     
-                 call iso_verif_egalite(yxtsnow(iso_eau,j), &
-     &                  ysnow(j),'pbl_surf_mod 1064')
-           endif !if (iso_eau.gt.0) then
-        enddo !do i=1,klon
-#endif
-          
+             !write(*,*) 'pbl_surface_mod 1060: sortie surf_landice'
+             do j=1,knon
+                if (iso_eau.gt.0) then     
+                   call iso_verif_egalite(yxtsnow(iso_eau,j), &
+                        &                  ysnow(j),'pbl_surf_mod 1064')
+                endif !if (iso_eau.gt.0) then
+             enddo !do i=1,klon
+#endif
+          END IF
        CASE(is_oce)
            CALL surf_ocean(rlon, rlat, ysolsw, ysollw, yalb_vis, &
@@ -2458,5 +2466,5 @@
                y_flux_u1, y_flux_v1, ydelta_sst(:knon), ydelta_sal(:knon), &
                yds_ns(:knon), ydt_ns(:knon), ydter(:knon), ydser(:knon), &
-               ytkt(:knon), ytks(:knon), ytaur(:knon), ysss &
+               ydt_ds(:knon), ytkt(:knon), ytks(:knon), ytaur(:knon), ysss &
 #ifdef ISO
          &      ,yxtrain_f, yxtsnow_f,yxt1,Roce, &
@@ -3390,4 +3398,9 @@
           taur(ni(:knon)) = ytaur(:knon)
           sss(ni(:knon)) = ysss(:knon)
+
+          if (activate_ocean_skin == 2 .and. type_ocean == "couple") then
+             dt_ds = missing_val
+             dt_ds(ni(:knon)) = ydt_ds(:knon)
+          end if
        end if
 
@@ -4051,5 +4064,4 @@
     USE indice_sol_mod
 #ifdef ISO
-  USE infotrac_phy, ONLY: ntraciso,niso ! ajout C Risi pour isos  
 #ifdef ISOVERIF
     USE isotopes_mod, ONLY: iso_eau,ridicule
@@ -4128,9 +4140,7 @@
 
     USE indice_sol_mod
-    use phys_state_var_mod, only: delta_sal, ds_ns, dt_ns, delta_sst
+    use phys_state_var_mod, only: delta_sal, ds_ns, dt_ns, delta_sst, dter, &
+         dser, dt_ds
     use config_ocean_skin_m, only: activate_ocean_skin
-#ifdef ISO
-  USE infotrac_phy, ONLY: ntraciso    
-#endif
 
 
@@ -4237,4 +4247,7 @@
                          delta_sal(i) = 0.
                          delta_sst(i) = 0.
+                         dter(i) = 0.
+                         dser(i) = 0.
+                         dt_ds(i) = 0.
                       end if
                       
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/phyetat0.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/phyetat0.F90	(revision 4445)
+++ 	(revision )
@@ -1,708 +1,0 @@
-! $Id: phyetat0.F90 3890 2021-05-05 15:15:06Z jyg $
-
-SUBROUTINE phyetat0 (fichnom, clesphy0, tabcntr0)
-
-  USE dimphy, only: klon, zmasq, klev
-  USE iophy, ONLY : init_iophy_new
-  USE ocean_cpl_mod,    ONLY : ocean_cpl_init
-  USE fonte_neige_mod,  ONLY : fonte_neige_init
-  USE pbl_surface_mod,  ONLY : pbl_surface_init
-#ifdef ISO
-  USE fonte_neige_mod,  ONLY : fonte_neige_init_iso
-  USE pbl_surface_mod,  ONLY : pbl_surface_init_iso
-#endif
-  USE surface_data,     ONLY : type_ocean, version_ocean
-  USE phys_state_var_mod, ONLY : ancien_ok, clwcon, detr_therm, phys_tstep, &
-       qsol, fevap, z0m, z0h, agesno, &
-       du_gwd_rando, du_gwd_front, entr_therm, f0, fm_therm, &
-       falb_dir, falb_dif, prw_ancien, prlw_ancien, prsw_ancien, &
-       ftsol, pbl_tke, pctsrf, q_ancien, ql_ancien, qs_ancien, radpas, radsol, rain_fall, ratqs, &
-       rnebcon, rugoro, sig1, snow_fall, solaire_etat0, sollw, sollwdown, &
-       solsw, solswfdiff, t_ancien, u_ancien, v_ancien, w01, wake_cstar, wake_deltaq, &
-       wake_deltat, wake_delta_pbl_TKE, delta_tsurf, beta_aridity, wake_fip, wake_pe, &
-       wake_s, wake_dens, awake_dens, cv_gen, zgam, zmax0, zmea, zpic, zsig, &
-#ifdef ISO
-       fxtevap, xtsol, xt_ancien, xtl_ancien, xts_ancien, wake_deltaxt, &
-       xtrain_fall,xtsnow_fall, &
-#endif
-       zstd, zthe, zval, ale_bl, ale_bl_trig, alp_bl, u10m, v10m, treedrg, &
-       ale_wake, ale_bl_stat, ds_ns, dt_ns, delta_sst, delta_sal, ratqs_inter
-!FC
-  USE geometry_mod,     ONLY: longitude_deg, latitude_deg
-  USE iostart,          ONLY: close_startphy, get_field, get_var, open_startphy
-  USE infotrac_phy,     ONLY: nqtot, nbtr, type_trac, tracers
-  USE traclmdz_mod,     ONLY: traclmdz_from_restart
-  USE carbon_cycle_mod, ONLY: carbon_cycle_tr, carbon_cycle_cpl, co2_send
-  USE indice_sol_mod,   ONLY: nbsrf, is_ter, epsfra, is_lic, is_oce, is_sic
-  USE ocean_slab_mod,   ONLY: nslay, tslab, seaice, tice, ocean_slab_init
-  USE time_phylmdz_mod, ONLY: init_iteration, pdtphys, itau_phy
-#ifdef CPP_XIOS
-  USE wxios, ONLY: missing_val
-#else
-  use netcdf, only: missing_val => nf90_fill_real
-#endif
-  use config_ocean_skin_m, only: activate_ocean_skin
-#ifdef ISO
-  USE infotrac_phy, ONLY: niso
-  USE isotopes_routines_mod, ONLY: phyisoetat0
-  USE isotopes_mod, ONLY: iso_eau
-#ifdef ISOVERIF
-  USE isotopes_verif_mod, ONLY: iso_verif_egalite_vect2D,iso_verif_egalite
-#endif
-#endif
-
-  IMPLICIT none
-  !======================================================================
-  ! Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
-  ! Objet: Lecture de l'etat initial pour la physique
-  !======================================================================
-  include "dimsoil.h"
-  include "clesphys.h"
-  include "alpale.h"
-  include "compbl.h"
-  include "YOMCST.h"
-  !======================================================================
-  CHARACTER*(*) fichnom
-
-  ! les variables globales lues dans le fichier restart
-
-  REAL tsoil(klon, nsoilmx, nbsrf)
-  REAL qsurf(klon, nbsrf)
-  REAL snow(klon, nbsrf)
-  real fder(klon)
-  REAL run_off_lic_0(klon)
-  REAL fractint(klon)
-  REAL trs(klon, nbtr)
-  REAL zts(klon)
-  ! pour drag arbres FC
-  REAL drg_ter(klon,klev)
-
-  CHARACTER*6 ocean_in
-  LOGICAL ok_veget_in
-
-  INTEGER        longcles
-  PARAMETER    ( longcles = 20 )
-  REAL clesphy0( longcles )
-
-  REAL xmin, xmax
-
-  INTEGER nid, nvarid
-  INTEGER ierr, i, nsrf, isoil , k
-  INTEGER length
-  PARAMETER (length=100)
-  INTEGER it, iq, isw
-  REAL tab_cntrl(length), tabcntr0(length)
-  CHARACTER*7 str7
-  CHARACTER*2 str2
-  LOGICAL :: found,phyetat0_get,phyetat0_srf
-  REAL :: lon_startphy(klon), lat_startphy(klon)
-
-#ifdef ISO
-  REAL xtsnow(niso,klon, nbsrf)
-  REAL xtrun_off_lic_0(niso,klon)
-  REAL Rland_ice(niso,klon)
-#endif
-  ! FH1D
-  !     real iolat(jjm+1)
-  !real iolat(jjm+1-1/(iim*jjm))
-
-  ! Ouvrir le fichier contenant l'etat initial:
-
-  CALL open_startphy(fichnom)
-
-  ! Lecture des parametres de controle:
-
-  CALL get_var("controle", tab_cntrl)
-
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-  ! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
-  ! Les constantes de la physiques sont lues dans la physique seulement.
-  ! Les egalites du type
-  !             tab_cntrl( 5 )=clesphy0(1)
-  ! sont remplacees par
-  !             clesphy0(1)=tab_cntrl( 5 )
-  ! On inverse aussi la logique.
-  ! On remplit les tab_cntrl avec les parametres lus dans les .def
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-  DO i = 1, length
-     tabcntr0( i ) = tab_cntrl( i )
-  ENDDO
-
-  tab_cntrl(1)=pdtphys
-  tab_cntrl(2)=radpas
-
-  ! co2_ppm : value from the previous time step
-  IF (carbon_cycle_tr .OR. carbon_cycle_cpl) THEN
-     co2_ppm = tab_cntrl(3)
-     RCO2    = co2_ppm * 1.0e-06 * RMCO2 / RMD
-     ! ELSE : keep value from .def
-  ENDIF
-
-! co2_ppm0 : initial value of atmospheric CO2 (from create_etat0_limit.e .def)
-! co2_ppm0   = tab_cntrl(16)
-! initial value for interactive CO2 run when there is no tracer field for CO2 in restart
-  co2_ppm0=284.32
-
-  solaire_etat0      = tab_cntrl(4)
-  tab_cntrl(5)=iflag_con
-  tab_cntrl(6)=nbapp_rad
-
-  IF (iflag_cycle_diurne.GE.1) tab_cntrl( 7) = iflag_cycle_diurne
-  IF (soil_model) tab_cntrl( 8) =1.
-  IF (new_oliq) tab_cntrl( 9) =1.
-  IF (ok_orodr) tab_cntrl(10) =1.
-  IF (ok_orolf) tab_cntrl(11) =1.
-  IF (ok_limitvrai) tab_cntrl(12) =1.
-
-  itau_phy = tab_cntrl(15)
-
-  clesphy0(1)=tab_cntrl( 5 )
-  clesphy0(2)=tab_cntrl( 6 )
-  clesphy0(3)=tab_cntrl( 7 )
-  clesphy0(4)=tab_cntrl( 8 )
-  clesphy0(5)=tab_cntrl( 9 )
-  clesphy0(6)=tab_cntrl( 10 )
-  clesphy0(7)=tab_cntrl( 11 )
-  clesphy0(8)=tab_cntrl( 12 )
-
-  ! set time iteration
-   CALL init_iteration(itau_phy)
-
-  ! read latitudes and make a sanity check (because already known from dyn)
-  CALL get_field("latitude",lat_startphy)
-  DO i=1,klon
-    IF (ABS(lat_startphy(i)-latitude_deg(i))>=1) THEN
-      WRITE(*,*) "phyetat0: Error! Latitude discrepancy wrt startphy file:",&
-                 " i=",i," lat_startphy(i)=",lat_startphy(i),&
-                 " latitude_deg(i)=",latitude_deg(i)
-      ! This is presumably serious enough to abort run
-      CALL abort_physic("phyetat0","discrepancy in latitudes!",1)
-    ENDIF
-    IF (ABS(lat_startphy(i)-latitude_deg(i))>=0.0001) THEN
-      WRITE(*,*) "phyetat0: Warning! Latitude discrepancy wrt startphy file:",&
-                 " i=",i," lat_startphy(i)=",lat_startphy(i),&
-                 " latitude_deg(i)=",latitude_deg(i)
-    ENDIF
-  ENDDO
-
-  ! read longitudes and make a sanity check (because already known from dyn)
-  CALL get_field("longitude",lon_startphy)
-  DO i=1,klon
-    IF (ABS(lon_startphy(i)-longitude_deg(i))>=1) THEN
-      IF (ABS(360-ABS(lon_startphy(i)-longitude_deg(i)))>=1) THEN
-        WRITE(*,*) "phyetat0: Error! Longitude discrepancy wrt startphy file:",&
-                   " i=",i," lon_startphy(i)=",lon_startphy(i),&
-                   " longitude_deg(i)=",longitude_deg(i)
-        ! This is presumably serious enough to abort run
-        CALL abort_physic("phyetat0","discrepancy in longitudes!",1)
-      ENDIF
-    ENDIF
-    IF (ABS(lon_startphy(i)-longitude_deg(i))>=1) THEN
-      IF (ABS(360-ABS(lon_startphy(i)-longitude_deg(i))) > 0.0001) THEN
-        WRITE(*,*) "phyetat0: Warning! Longitude discrepancy wrt startphy file:",&
-                   " i=",i," lon_startphy(i)=",lon_startphy(i),&
-                   " longitude_deg(i)=",longitude_deg(i)
-      ENDIF 
-    ENDIF
-  ENDDO
-
-  ! Lecture du masque terre mer
-
-  CALL get_field("masque", zmasq, found)
-  IF (.NOT. found) THEN
-     PRINT*, 'phyetat0: Le champ <masque> est absent'
-     PRINT *, 'fichier startphy non compatible avec phyetat0'
-  ENDIF
-
-  ! Lecture des fractions pour chaque sous-surface
-
-  ! initialisation des sous-surfaces
-
-  pctsrf = 0.
-
-  ! fraction de terre
-
-  CALL get_field("FTER", pctsrf(:, is_ter), found)
-  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FTER> est absent'
-
-  ! fraction de glace de terre
-
-  CALL get_field("FLIC", pctsrf(:, is_lic), found)
-  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FLIC> est absent'
-
-  ! fraction d'ocean
-
-  CALL get_field("FOCE", pctsrf(:, is_oce), found)
-  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FOCE> est absent'
-
-  ! fraction glace de mer
-
-  CALL get_field("FSIC", pctsrf(:, is_sic), found)
-  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FSIC> est absent'
-
-  !  Verification de l'adequation entre le masque et les sous-surfaces
-
-  fractint( 1 : klon) = pctsrf(1 : klon, is_ter)  &
-       + pctsrf(1 : klon, is_lic)
-  DO i = 1 , klon
-     IF ( abs(fractint(i) - zmasq(i) ) .GT. EPSFRA ) THEN
-        WRITE(*, *) 'phyetat0: attention fraction terre pas ',  &
-             'coherente ', i, zmasq(i), pctsrf(i, is_ter) &
-             , pctsrf(i, is_lic)
-        WRITE(*, *) 'Je force la coherence zmasq=fractint'
-        zmasq(i) = fractint(i)
-     ENDIF
-  ENDDO
-  fractint (1 : klon) =  pctsrf(1 : klon, is_oce)  &
-       + pctsrf(1 : klon, is_sic)
-  DO i = 1 , klon
-     IF ( abs( fractint(i) - (1. - zmasq(i))) .GT. EPSFRA ) THEN
-        WRITE(*, *) 'phyetat0 attention fraction ocean pas ',  &
-             'coherente ', i, zmasq(i) , pctsrf(i, is_oce) &
-             , pctsrf(i, is_sic)
-        WRITE(*, *) 'Je force la coherence zmasq=1.-fractint'
-        zmasq(i) = 1. - fractint(i)
-     ENDIF
-  ENDDO
-
-!===================================================================
-! Lecture des temperatures du sol:
-!===================================================================
-
-  found=phyetat0_get(1,ftsol(:,1),"TS","Surface temperature",283.)
-  IF (found) THEN
-     DO nsrf=2,nbsrf
-        ftsol(:,nsrf)=ftsol(:,1)
-     ENDDO
-  ELSE
-     found=phyetat0_srf(1,ftsol,"TS","Surface temperature",283.)
-  ENDIF
-
-!===================================================================
-  ! Lecture des albedo difus et direct
-!===================================================================
-
-  DO nsrf = 1, nbsrf
-     DO isw=1, nsw
-        IF (isw.GT.99) THEN
-           PRINT*, "Trop de bandes SW"
-           call abort_physic("phyetat0", "", 1)
-        ENDIF
-        WRITE(str2, '(i2.2)') isw
-        found=phyetat0_srf(1,falb_dir(:, isw,:),"A_dir_SW"//str2//"srf","Direct Albedo",0.2)
-        found=phyetat0_srf(1,falb_dif(:, isw,:),"A_dif_SW"//str2//"srf","Direct Albedo",0.2)
-     ENDDO
-  ENDDO
-
-  found=phyetat0_srf(1,u10m,"U10M","u a 10m",0.)
-  found=phyetat0_srf(1,v10m,"V10M","v a 10m",0.)
-
-!===================================================================
-  ! Lecture des temperatures du sol profond:
-!===================================================================
-
-   DO isoil=1, nsoilmx
-        IF (isoil.GT.99) THEN
-           PRINT*, "Trop de couches "
-           call abort_physic("phyetat0", "", 1)
-        ENDIF
-        WRITE(str2,'(i2.2)') isoil
-        found=phyetat0_srf(1,tsoil(:, isoil,:),"Tsoil"//str2//"srf","Temp soil",0.)
-        IF (.NOT. found) THEN
-           PRINT*, "phyetat0: Le champ <Tsoil"//str7//"> est absent"
-           PRINT*, "          Il prend donc la valeur de surface"
-           tsoil(:, isoil, :)=ftsol(:, :)
-        ENDIF
-   ENDDO
-
-!=======================================================================
-! Lecture precipitation/evaporation
-!=======================================================================
-
-  found=phyetat0_srf(1,qsurf,"QS","Near surface hmidity",0.)
-  found=phyetat0_get(1,qsol,"QSOL","Surface hmidity / bucket",0.)
-  found=phyetat0_srf(1,snow,"SNOW","Surface snow",0.)
-  found=phyetat0_srf(1,fevap,"EVAP","evaporation",0.)
-  found=phyetat0_get(1,snow_fall,"snow_f","snow fall",0.)
-  found=phyetat0_get(1,rain_fall,"rain_f","rain fall",0.)
-
-!=======================================================================
-! Radiation
-!=======================================================================
-
-  found=phyetat0_get(1,solsw,"solsw","net SW radiation surf",0.)
-  found=phyetat0_get(1,solswfdiff,"solswfdiff","fraction of SW radiation surf that is diffuse",1.)
-  found=phyetat0_get(1,sollw,"sollw","net LW radiation surf",0.)
-  found=phyetat0_get(1,sollwdown,"sollwdown","down LW radiation surf",0.)
-  IF (.NOT. found) THEN
-     sollwdown(:) = 0. ;  zts(:)=0.
-     DO nsrf=1,nbsrf
-        zts(:)=zts(:)+ftsol(:,nsrf)*pctsrf(:,nsrf)
-     ENDDO
-     sollwdown(:)=sollw(:)+RSIGMA*zts(:)**4
-  ENDIF
-
-  found=phyetat0_get(1,radsol,"RADS","Solar radiation",0.)
-  found=phyetat0_get(1,fder,"fder","Flux derivative",0.) 
-
-
-  ! Lecture de la longueur de rugosite 
-  found=phyetat0_srf(1,z0m,"RUG","Z0m ancien",0.001)
-  IF (found) THEN
-     z0h(:,1:nbsrf)=z0m(:,1:nbsrf)
-  ELSE
-     found=phyetat0_srf(1,z0m,"Z0m","Roughness length, momentum ",0.001)
-     found=phyetat0_srf(1,z0h,"Z0h","Roughness length, enthalpy ",0.001)
-  ENDIF
-!FC
-  IF (ifl_pbltree>0) THEN
-!CALL get_field("FTER", pctsrf(:, is_ter), found)
-    treedrg(:,1:klev,1:nbsrf)= 0.0
-    CALL get_field("treedrg_ter", drg_ter(:,:), found)
-!  found=phyetat0_srf(1,treedrg,"treedrg","drag from vegetation" , 0.)
-    !lecture du profile de freinage des arbres
-    IF (.not. found ) THEN
-      treedrg(:,1:klev,1:nbsrf)= 0.0
-    ELSE
-      treedrg(:,1:klev,is_ter)= drg_ter(:,:)
-!     found=phyetat0_srf(klev,treedrg,"treedrg","freinage arbres",0.)
-    ENDIF
-  ELSE
-    ! initialize treedrg(), because it will be written in restartphy.nc
-    treedrg(:,:,:) = 0.0 
-  ENDIF
-
-  ! Lecture de l'age de la neige:
-  found=phyetat0_srf(1,agesno,"AGESNO","SNOW AGE",0.001)
-
-  ancien_ok=.true.
-  ancien_ok=ancien_ok.AND.phyetat0_get(klev,t_ancien,"TANCIEN","TANCIEN",0.)
-  ancien_ok=ancien_ok.AND.phyetat0_get(klev,q_ancien,"QANCIEN","QANCIEN",0.)
-  ancien_ok=ancien_ok.AND.phyetat0_get(klev,ql_ancien,"QLANCIEN","QLANCIEN",0.)
-  ancien_ok=ancien_ok.AND.phyetat0_get(klev,qs_ancien,"QSANCIEN","QSANCIEN",0.)
-  ancien_ok=ancien_ok.AND.phyetat0_get(klev,u_ancien,"UANCIEN","UANCIEN",0.)
-  ancien_ok=ancien_ok.AND.phyetat0_get(klev,v_ancien,"VANCIEN","VANCIEN",0.)
-  ancien_ok=ancien_ok.AND.phyetat0_get(1,prw_ancien,"PRWANCIEN","PRWANCIEN",0.)
-  ancien_ok=ancien_ok.AND.phyetat0_get(1,prlw_ancien,"PRLWANCIEN","PRLWANCIEN",0.)
-  ancien_ok=ancien_ok.AND.phyetat0_get(1,prsw_ancien,"PRSWANCIEN","PRSWANCIEN",0.)
-
-  ! Ehouarn: addtional tests to check if t_ancien, q_ancien contain
-  !          dummy values (as is the case when generated by ce0l,
-  !          or by iniaqua)
-  IF ( (maxval(q_ancien).EQ.minval(q_ancien))       .OR. &
-       (maxval(ql_ancien).EQ.minval(ql_ancien))     .OR. &
-       (maxval(qs_ancien).EQ.minval(qs_ancien))     .OR. &
-       (maxval(prw_ancien).EQ.minval(prw_ancien))   .OR. &
-       (maxval(prlw_ancien).EQ.minval(prlw_ancien)) .OR. &
-       (maxval(prsw_ancien).EQ.minval(prsw_ancien)) .OR. &
-       (maxval(t_ancien).EQ.minval(t_ancien)) ) THEN
-    ancien_ok=.false.
-  ENDIF
-
-  found=phyetat0_get(klev,clwcon,"CLWCON","CLWCON",0.)
-  found=phyetat0_get(klev,rnebcon,"RNEBCON","RNEBCON",0.)
-  found=phyetat0_get(klev,ratqs,"RATQS","RATQS",0.)
-
-  found=phyetat0_get(1,run_off_lic_0,"RUNOFFLIC0","RUNOFFLIC0",0.)
-
-!==================================
-!  TKE
-!==================================
-!
-  IF (iflag_pbl>1) then
-     found=phyetat0_srf(klev+1,pbl_tke,"TKE","Turb. Kinetic. Energ. ",1.e-8)
-  ENDIF
-
-  IF (iflag_pbl>1 .AND. iflag_wake>=1  .AND. iflag_pbl_split >=1 ) then
-    found=phyetat0_srf(klev+1,wake_delta_pbl_tke,"DELTATKE","Del TKE wk/env",0.)
-!!    found=phyetat0_srf(1,delta_tsurf,"DELTA_TSURF","Delta Ts wk/env ",0.)
-    found=phyetat0_srf(1,delta_tsurf,"DELTATS","Delta Ts wk/env ",0.)
-!!    found=phyetat0_srf(1,beta_aridity,"BETA_S","Aridity factor ",1.)
-    found=phyetat0_srf(1,beta_aridity,"BETAS","Aridity factor ",1.)
-  ENDIF   !(iflag_pbl>1 .AND. iflag_wake>=1 .AND. iflag_pbl_split >=1 )
-
-!==================================
-!  thermiques, poches, convection
-!==================================
-
-! Emanuel
-  found=phyetat0_get(klev,sig1,"sig1","sig1",0.)
-  found=phyetat0_get(klev,w01,"w01","w01",0.)
-
-! Wake
-  found=phyetat0_get(klev,wake_deltat,"WAKE_DELTAT","Delta T wake/env",0.)
-  found=phyetat0_get(klev,wake_deltaq,"WAKE_DELTAQ","Delta hum. wake/env",0.)
-  found=phyetat0_get(1,wake_s,"WAKE_S","Wake frac. area",0.)
-!jyg<
-!  Set wake_dens to -1000. when there is no restart so that the actual
-!  initialization is made in calwake.
-!!  found=phyetat0_get(1,wake_dens,"WAKE_DENS","Wake num. /unit area",0.)
-  found=phyetat0_get(1,wake_dens,"WAKE_DENS","Wake num. /unit area",-1000.)
-  found=phyetat0_get(1,awake_dens,"AWAKE_DENS","Active Wake num. /unit area",0.)
-  found=phyetat0_get(1,cv_gen,"CV_GEN","CB birth rate",0.)
-!>jyg
-  found=phyetat0_get(1,wake_cstar,"WAKE_CSTAR","WAKE_CSTAR",0.)
-  found=phyetat0_get(1,wake_pe,"WAKE_PE","WAKE_PE",0.)
-  found=phyetat0_get(1,wake_fip,"WAKE_FIP","WAKE_FIP",0.)
-
-! Thermiques
-  found=phyetat0_get(1,zmax0,"ZMAX0","ZMAX0",40.)
-  found=phyetat0_get(1,f0,"F0","F0",1.e-5)
-  found=phyetat0_get(klev+1,fm_therm,"FM_THERM","Thermals mass flux",0.)
-  found=phyetat0_get(klev,entr_therm,"ENTR_THERM","Thermals Entrain.",0.)
-  found=phyetat0_get(klev,detr_therm,"DETR_THERM","Thermals Detrain.",0.)
-
-! ALE/ALP
-  found=phyetat0_get(1,ale_bl,"ALE_BL","ALE BL",0.)
-  found=phyetat0_get(1,ale_bl_trig,"ALE_BL_TRIG","ALE BL_TRIG",0.)
-  found=phyetat0_get(1,alp_bl,"ALP_BL","ALP BL",0.)
-  found=phyetat0_get(1,ale_wake,"ALE_WAKE","ALE_WAKE",0.)
-  found=phyetat0_get(1,ale_bl_stat,"ALE_BL_STAT","ALE_BL_STAT",0.)
-
-! fisrtilp/Clouds 0.002 could be ratqsbas. But can stay like this as well
-  found=phyetat0_get(klev,ratqs_inter,"RATQS_INTER","Relative width of the lsc sugrid scale water",0.002)
-
-!===========================================
-  ! Read and send field trs to traclmdz
-!===========================================
-
-  IF (type_trac == 'lmdz') THEN
-     it = 0
-     DO iq = 1, nqtot
-        IF(.NOT.(tracers(iq)%isAdvected .AND. tracers(iq)%isInPhysics)) CYCLE
-        it = it+1
-        found=phyetat0_get(1,trs(:,it),"trs_"//TRIM(tracers(iq)%name), &
-                                  "Surf trac"//TRIM(tracers(iq)%name),0.)
-     END DO
-     CALL traclmdz_from_restart(trs)
-  ENDIF
-
-!--OB now this is for co2i - ThL: and therefore also for inco
-  IF (type_trac == 'co2i' .OR. type_trac == 'inco') THEN
-     IF (carbon_cycle_cpl) THEN
-        ALLOCATE(co2_send(klon), stat=ierr)
-        IF (ierr /= 0) CALL abort_physic('phyetat0', 'pb allocation co2_send', 1)
-        found=phyetat0_get(1,co2_send,"co2_send","co2 send",co2_ppm)
-     ENDIF
-  ENDIF
-
-#ifdef ISO
-        ! initialise les isotopes       
-        write(*,*) 'phyetat0 1069' 
-         CALL phyisoetat0 (snow,run_off_lic_0, &
-     &           xtsnow,xtrun_off_lic_0, &
-     &           Rland_ice)
-#ifdef ISOVERIF 
-      write(*,*) 'phyetat0 1074'
-      if (iso_eau.gt.0) then
-      call iso_verif_egalite_vect2D(  &
-     &           xtsnow,snow, &
-     &           'phyetat0 1101a',niso,klon,nbsrf)
-        do i=1,klon  
-              call iso_verif_egalite(Rland_ice(iso_eau,i),1.0, &
-     &         'phyetat0 1101b')
-         enddo
-      endif
-      write(*,*) 'phyetat0 1102'
-#endif
-#endif
-
-!===========================================
-!  ondes de gravite / relief
-!===========================================
-
-!  ondes de gravite non orographiques
-  IF (ok_gwd_rando) found = &
-       phyetat0_get(klev,du_gwd_rando,"du_gwd_rando","du_gwd_rando",0.)
-  IF (.NOT. ok_hines .AND. ok_gwd_rando) found &
-       = phyetat0_get(klev,du_gwd_front,"du_gwd_front","du_gwd_front",0.)
-
-!  prise en compte du relief sous-maille
-  found=phyetat0_get(1,zmea,"ZMEA","sub grid orography",0.)
-  found=phyetat0_get(1,zstd,"ZSTD","sub grid orography",0.)
-  found=phyetat0_get(1,zsig,"ZSIG","sub grid orography",0.)
-  found=phyetat0_get(1,zgam,"ZGAM","sub grid orography",0.)
-  found=phyetat0_get(1,zthe,"ZTHE","sub grid orography",0.)
-  found=phyetat0_get(1,zpic,"ZPIC","sub grid orography",0.)
-  found=phyetat0_get(1,zval,"ZVAL","sub grid orography",0.)
-  found=phyetat0_get(1,zmea,"ZMEA","sub grid orography",0.)
-  found=phyetat0_get(1,rugoro,"RUGSREL","sub grid orography",0.)
-
-!===========================================
-! Initialize ocean
-!===========================================
-
-  IF ( type_ocean == 'slab' ) THEN
-      CALL ocean_slab_init(phys_tstep, pctsrf)
-      IF (nslay.EQ.1) THEN
-        found=phyetat0_get(1,tslab,"tslab01","tslab",0.)
-        IF (.NOT. found) THEN
-            found=phyetat0_get(1,tslab,"tslab","tslab",0.)
-        ENDIF
-      ELSE
-          DO i=1,nslay
-            WRITE(str2,'(i2.2)') i
-            found=phyetat0_get(1,tslab(:,i),"tslab"//str2,"tslab",0.)  
-          ENDDO
-      ENDIF
-      IF (.NOT. found) THEN 
-          PRINT*, "phyetat0: Le champ <tslab> est absent"
-          PRINT*, "Initialisation a tsol_oce"
-          DO i=1,nslay
-              tslab(:,i)=MAX(ftsol(:,is_oce),271.35)
-          ENDDO
-      ENDIF 
-
-      ! Sea ice variables
-      IF (version_ocean == 'sicINT') THEN
-          found=phyetat0_get(1,tice,"slab_tice","slab_tice",0.)
-          IF (.NOT. found) THEN 
-              PRINT*, "phyetat0: Le champ <tice> est absent"
-              PRINT*, "Initialisation a tsol_sic"
-                  tice(:)=ftsol(:,is_sic)
-          ENDIF 
-          found=phyetat0_get(1,seaice,"seaice","seaice",0.)
-          IF (.NOT. found) THEN
-              PRINT*, "phyetat0: Le champ <seaice> est absent"
-              PRINT*, "Initialisation a 0/1m suivant fraction glace"
-              seaice(:)=0.
-              WHERE (pctsrf(:,is_sic).GT.EPSFRA)
-                  seaice=917.
-              ENDWHERE
-          ENDIF
-      ENDIF !sea ice INT
-  ENDIF ! Slab        
-
-  if (activate_ocean_skin >= 1) then
-     if (activate_ocean_skin == 2 .and. type_ocean == 'couple') then
-        found = phyetat0_get(1, delta_sal, "delta_sal", &
-             "ocean-air interface salinity minus bulk salinity", 0.)
-        found = phyetat0_get(1, delta_sst, "delta_SST", &
-             "ocean-air interface temperature minus bulk SST", 0.)
-     end if
-     
-     found = phyetat0_get(1, ds_ns, "dS_ns", "delta salinity near surface", 0.)
-     found = phyetat0_get(1, dt_ns, "dT_ns", "delta temperature near surface", &
-          0.)
-
-     where (pctsrf(:, is_oce) == 0.)
-        ds_ns = missing_val
-        dt_ns = missing_val
-        delta_sst = missing_val
-        delta_sal = missing_val
-     end where
-  end if
-
-  ! on ferme le fichier
-  CALL close_startphy
-
-  ! Initialize module pbl_surface_mod 
-
-#ifdef ISOVERIF
-        write(*,*) 'phyetat0 572: snow(994,:)=',snow(994,2)
-        write(*,*) 'xtsnow(:,994,2)=',xtsnow(:,994,2)
-#endif
-
-  CALL pbl_surface_init(fder, snow, qsurf, tsoil)
-#ifdef ISO
-  CALL pbl_surface_init_iso(xtsnow,Rland_ice)
-#endif
-
-  ! Initialize module ocean_cpl_mod for the case of coupled ocean
-  IF ( type_ocean == 'couple' ) THEN
-     CALL ocean_cpl_init(phys_tstep, longitude_deg, latitude_deg)
-  ENDIF
-
-!  CALL init_iophy_new(latitude_deg, longitude_deg)
-
-  ! Initilialize module fonte_neige_mod      
-  CALL fonte_neige_init(run_off_lic_0)
-#ifdef ISO
-   CALL fonte_neige_init_iso(xtrun_off_lic_0)
-#endif
-
-END SUBROUTINE phyetat0
-
-!===================================================================
-FUNCTION phyetat0_get(nlev,field,name,descr,default)
-!===================================================================
-! Lecture d'un champ avec contrôle
-! Function logique dont le resultat indique si la lecture
-! s'est bien passée
-! On donne une valeur par defaut dans le cas contraire
-!===================================================================
-
-USE iostart, ONLY : get_field
-USE dimphy, only: klon 
-USE print_control_mod, ONLY: lunout
-
-IMPLICIT NONE
-
-LOGICAL phyetat0_get
-
-! arguments
-INTEGER,INTENT(IN) :: nlev
-CHARACTER*(*),INTENT(IN) :: name,descr
-REAL,INTENT(IN) :: default
-REAL,DIMENSION(klon,nlev),INTENT(INOUT) :: field
-
-! Local variables
-LOGICAL found
-
-   CALL get_field(name, field, found)
-   IF (.NOT. found) THEN
-     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)
-   phyetat0_get=found
-
-RETURN
-END FUNCTION phyetat0_get
-
-!================================================================
-FUNCTION phyetat0_srf(nlev,field,name,descr,default)
-!===================================================================
-! Lecture d'un champ par sous-surface avec contrôle
-! Function logique dont le resultat indique si la lecture
-! s'est bien passée
-! On donne une valeur par defaut dans le cas contraire
-!===================================================================
-
-USE iostart, ONLY : get_field
-USE dimphy, only: klon 
-USE indice_sol_mod, only: nbsrf
-USE print_control_mod, ONLY: lunout
-
-IMPLICIT NONE
-
-LOGICAL phyetat0_srf
-! arguments
-INTEGER,INTENT(IN) :: nlev
-CHARACTER*(*),INTENT(IN) :: name,descr
-REAL,INTENT(IN) :: default
-REAL,DIMENSION(klon,nlev,nbsrf),INTENT(INOUT) :: field
-
-! Local variables
-LOGICAL found,phyetat0_get
-INTEGER nsrf
-CHARACTER*2 str2
-  
-     IF (nbsrf.GT.99) THEN
-        WRITE(lunout,*) "Trop de sous-mailles"
-        call abort_physic("phyetat0", "", 1)
-     ENDIF
-
-     DO nsrf = 1, nbsrf
-        WRITE(str2, '(i2.2)') nsrf
-        found= phyetat0_get(nlev,field(:,:, nsrf), &
-        name//str2,descr//" srf:"//str2,default)
-     ENDDO
-
-     phyetat0_srf=found
-
-RETURN
-END FUNCTION phyetat0_srf
-
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/phyetat0_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/phyetat0_mod.F90	(revision 4446)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/phyetat0_mod.F90	(revision 4446)
@@ -0,0 +1,661 @@
+! $Id: phyetat0.F90 3890 2021-05-05 15:15:06Z jyg $
+
+MODULE phyetat0_mod
+
+  PRIVATE
+  PUBLIC :: phyetat0
+
+CONTAINS
+
+SUBROUTINE phyetat0 (fichnom, clesphy0, tabcntr0)
+
+  USE dimphy, only: klon, zmasq, klev
+  USE iophy, ONLY : init_iophy_new
+  USE ocean_cpl_mod,    ONLY : ocean_cpl_init
+  USE fonte_neige_mod,  ONLY : fonte_neige_init
+  USE pbl_surface_mod,  ONLY : pbl_surface_init
+#ifdef ISO
+  USE fonte_neige_mod,  ONLY : fonte_neige_init_iso
+  USE pbl_surface_mod,  ONLY : pbl_surface_init_iso
+#endif
+  USE phyetat0_get_mod, ONLY : phyetat0_get, phyetat0_srf
+  USE surface_data,     ONLY : type_ocean, version_ocean
+  USE phys_state_var_mod, ONLY : ancien_ok, clwcon, detr_therm, phys_tstep, &
+       qsol, fevap, z0m, z0h, agesno, &
+       du_gwd_rando, du_gwd_front, entr_therm, f0, fm_therm, &
+       falb_dir, falb_dif, prw_ancien, prlw_ancien, prsw_ancien, &
+       ftsol, pbl_tke, pctsrf, q_ancien, ql_ancien, qs_ancien, rneb_ancien, radpas, radsol, rain_fall, ratqs, &
+       rnebcon, rugoro, sig1, snow_fall, solaire_etat0, sollw, sollwdown, &
+       solsw, solswfdiff, t_ancien, u_ancien, v_ancien, w01, wake_cstar, wake_deltaq, &
+       wake_deltat, wake_delta_pbl_TKE, delta_tsurf, beta_aridity, wake_fip, wake_pe, &
+       wake_s, wake_dens, awake_dens, cv_gen, zgam, zmax0, zmea, zpic, zsig, &
+#ifdef ISO
+       fxtevap, xtsol, xt_ancien, xtl_ancien, xts_ancien, wake_deltaxt, &
+       xtrain_fall,xtsnow_fall, &
+#endif
+       zstd, zthe, zval, ale_bl, ale_bl_trig, alp_bl, u10m, v10m, treedrg, &
+       ale_wake, ale_bl_stat, ds_ns, dt_ns, delta_sst, delta_sal, dter, dser, &
+       dt_ds, ratqs_inter
+!FC
+  USE geometry_mod,     ONLY: longitude_deg, latitude_deg
+  USE iostart,          ONLY: close_startphy, get_field, get_var, open_startphy
+  USE infotrac_phy,     ONLY: nqtot, nbtr, type_trac, tracers
+  USE readTracFiles_mod,ONLY: maxlen, new2oldH2O
+  USE traclmdz_mod,     ONLY: traclmdz_from_restart
+  USE carbon_cycle_mod, ONLY: carbon_cycle_init, carbon_cycle_cpl, carbon_cycle_tr, carbon_cycle_rad, co2_send, RCO2_glo
+  USE indice_sol_mod,   ONLY: nbsrf, is_ter, epsfra, is_lic, is_oce, is_sic
+  USE ocean_slab_mod,   ONLY: nslay, tslab, seaice, tice, ocean_slab_init
+  USE time_phylmdz_mod, ONLY: init_iteration, pdtphys, itau_phy
+#ifdef CPP_XIOS
+  USE wxios, ONLY: missing_val
+#else
+  use netcdf, only: missing_val => nf90_fill_real
+#endif
+  use config_ocean_skin_m, only: activate_ocean_skin
+#ifdef ISO
+  USE infotrac_phy, ONLY: niso
+  USE isotopes_routines_mod, ONLY: phyisoetat0
+  USE isotopes_mod, ONLY: iso_eau
+#ifdef ISOVERIF
+  USE isotopes_verif_mod, ONLY: iso_verif_egalite_vect2D,iso_verif_egalite
+#endif
+#endif
+
+  IMPLICIT none
+  !======================================================================
+  ! Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
+  ! Objet: Lecture de l'etat initial pour la physique
+  !======================================================================
+  include "dimsoil.h"
+  include "clesphys.h"
+  include "alpale.h"
+  include "compbl.h"
+  include "YOMCST.h"
+  !======================================================================
+  CHARACTER*(*) fichnom
+
+  ! les variables globales lues dans le fichier restart
+
+  REAL tsoil(klon, nsoilmx, nbsrf)
+  REAL qsurf(klon, nbsrf)
+  REAL snow(klon, nbsrf)
+  real fder(klon)
+  REAL run_off_lic_0(klon)
+  REAL fractint(klon)
+  REAL trs(klon, nbtr)
+  REAL zts(klon)
+  ! pour drag arbres FC
+  REAL drg_ter(klon,klev)
+
+  CHARACTER*6 ocean_in
+  LOGICAL ok_veget_in
+
+  INTEGER        longcles
+  PARAMETER    ( longcles = 20 )
+  REAL clesphy0( longcles )
+
+  REAL xmin, xmax
+
+  INTEGER nid, nvarid
+  INTEGER ierr, i, nsrf, isoil , k
+  INTEGER length
+  PARAMETER (length=100)
+  INTEGER it, iq, isw
+  REAL tab_cntrl(length), tabcntr0(length)
+  CHARACTER*7 str7
+  CHARACTER*2 str2
+  LOGICAL :: found
+  REAL :: lon_startphy(klon), lat_startphy(klon)
+  CHARACTER(LEN=maxlen) :: tname, t(2)
+
+#ifdef ISO
+  REAL xtsnow(niso,klon, nbsrf)
+  REAL xtrun_off_lic_0(niso,klon)
+  REAL Rland_ice(niso,klon)
+#endif
+  ! FH1D
+  !     real iolat(jjm+1)
+  !real iolat(jjm+1-1/(iim*jjm))
+
+  ! Ouvrir le fichier contenant l'etat initial:
+
+  CALL open_startphy(fichnom)
+
+  ! Lecture des parametres de controle:
+
+  CALL get_var("controle", tab_cntrl)
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  ! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
+  ! Les constantes de la physiques sont lues dans la physique seulement.
+  ! Les egalites du type
+  !             tab_cntrl( 5 )=clesphy0(1)
+  ! sont remplacees par
+  !             clesphy0(1)=tab_cntrl( 5 )
+  ! On inverse aussi la logique.
+  ! On remplit les tab_cntrl avec les parametres lus dans les .def
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  DO i = 1, length
+     tabcntr0( i ) = tab_cntrl( i )
+  ENDDO
+
+  tab_cntrl(1)=pdtphys
+  tab_cntrl(2)=radpas
+
+  ! co2_ppm : value from the previous time step
+
+  ! co2_ppm0 : initial value of atmospheric CO2 (from create_etat0_limit.e .def)
+  co2_ppm0 = 284.32
+  ! when no initial value is available e.g., from a restart 
+  ! this variable must be set  in a .def file which will then be 
+  ! used by the conf_phys_m.F90 routine.
+  ! co2_ppm0 = 284.32 (illustrative example on how to set the variable in .def
+  ! file, for a pre-industrial CO2 concentration value)
+
+  IF (carbon_cycle_tr .OR. carbon_cycle_cpl) THEN
+     co2_ppm = tab_cntrl(3)
+     RCO2    = co2_ppm * 1.0e-06 * RMCO2 / RMD
+     IF (tab_cntrl(17) > 0. .AND. carbon_cycle_rad) THEN
+           RCO2_glo = tab_cntrl(17)
+       ELSE
+           RCO2_glo    = co2_ppm0 * 1.0e-06 * RMCO2 / RMD
+     ENDIF
+     ! ELSE : keep value from .def
+  ENDIF
+
+  solaire_etat0      = tab_cntrl(4)
+  tab_cntrl(5)=iflag_con
+  tab_cntrl(6)=nbapp_rad
+
+  IF (iflag_cycle_diurne.GE.1) tab_cntrl( 7) = iflag_cycle_diurne
+  IF (soil_model) tab_cntrl( 8) =1.
+  IF (new_oliq) tab_cntrl( 9) =1.
+  IF (ok_orodr) tab_cntrl(10) =1.
+  IF (ok_orolf) tab_cntrl(11) =1.
+  IF (ok_limitvrai) tab_cntrl(12) =1.
+
+  itau_phy = tab_cntrl(15)
+
+  clesphy0(1)=tab_cntrl( 5 )
+  clesphy0(2)=tab_cntrl( 6 )
+  clesphy0(3)=tab_cntrl( 7 )
+  clesphy0(4)=tab_cntrl( 8 )
+  clesphy0(5)=tab_cntrl( 9 )
+  clesphy0(6)=tab_cntrl( 10 )
+  clesphy0(7)=tab_cntrl( 11 )
+  clesphy0(8)=tab_cntrl( 12 )
+  clesphy0(9)=tab_cntrl( 17 )
+
+  ! set time iteration
+   CALL init_iteration(itau_phy)
+
+  ! read latitudes and make a sanity check (because already known from dyn)
+  CALL get_field("latitude",lat_startphy)
+  DO i=1,klon
+    IF (ABS(lat_startphy(i)-latitude_deg(i))>=1) THEN
+      WRITE(*,*) "phyetat0: Error! Latitude discrepancy wrt startphy file:",&
+                 " i=",i," lat_startphy(i)=",lat_startphy(i),&
+                 " latitude_deg(i)=",latitude_deg(i)
+      ! This is presumably serious enough to abort run
+      CALL abort_physic("phyetat0","discrepancy in latitudes!",1)
+    ENDIF
+    IF (ABS(lat_startphy(i)-latitude_deg(i))>=0.0001) THEN
+      WRITE(*,*) "phyetat0: Warning! Latitude discrepancy wrt startphy file:",&
+                 " i=",i," lat_startphy(i)=",lat_startphy(i),&
+                 " latitude_deg(i)=",latitude_deg(i)
+    ENDIF
+  ENDDO
+
+  ! read longitudes and make a sanity check (because already known from dyn)
+  CALL get_field("longitude",lon_startphy)
+  DO i=1,klon
+    IF (ABS(lon_startphy(i)-longitude_deg(i))>=1) THEN
+      IF (ABS(360-ABS(lon_startphy(i)-longitude_deg(i)))>=1) THEN
+        WRITE(*,*) "phyetat0: Error! Longitude discrepancy wrt startphy file:",&
+                   " i=",i," lon_startphy(i)=",lon_startphy(i),&
+                   " longitude_deg(i)=",longitude_deg(i)
+        ! This is presumably serious enough to abort run
+        CALL abort_physic("phyetat0","discrepancy in longitudes!",1)
+      ENDIF
+    ENDIF
+    IF (ABS(lon_startphy(i)-longitude_deg(i))>=1) THEN
+      IF (ABS(360-ABS(lon_startphy(i)-longitude_deg(i))) > 0.0001) THEN
+        WRITE(*,*) "phyetat0: Warning! Longitude discrepancy wrt startphy file:",&
+                   " i=",i," lon_startphy(i)=",lon_startphy(i),&
+                   " longitude_deg(i)=",longitude_deg(i)
+      ENDIF 
+    ENDIF
+  ENDDO
+
+  ! Lecture du masque terre mer
+
+  CALL get_field("masque", zmasq, found)
+  IF (.NOT. found) THEN
+     PRINT*, 'phyetat0: Le champ <masque> est absent'
+     PRINT *, 'fichier startphy non compatible avec phyetat0'
+  ENDIF
+
+  ! Lecture des fractions pour chaque sous-surface
+
+  ! initialisation des sous-surfaces
+
+  pctsrf = 0.
+
+  ! fraction de terre
+
+  CALL get_field("FTER", pctsrf(:, is_ter), found)
+  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FTER> est absent'
+
+  ! fraction de glace de terre
+
+  CALL get_field("FLIC", pctsrf(:, is_lic), found)
+  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FLIC> est absent'
+
+  ! fraction d'ocean
+
+  CALL get_field("FOCE", pctsrf(:, is_oce), found)
+  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FOCE> est absent'
+
+  ! fraction glace de mer
+
+  CALL get_field("FSIC", pctsrf(:, is_sic), found)
+  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FSIC> est absent'
+
+  !  Verification de l'adequation entre le masque et les sous-surfaces
+
+  fractint( 1 : klon) = pctsrf(1 : klon, is_ter)  &
+       + pctsrf(1 : klon, is_lic)
+  DO i = 1 , klon
+     IF ( abs(fractint(i) - zmasq(i) ) .GT. EPSFRA ) THEN
+        WRITE(*, *) 'phyetat0: attention fraction terre pas ',  &
+             'coherente ', i, zmasq(i), pctsrf(i, is_ter) &
+             , pctsrf(i, is_lic)
+        WRITE(*, *) 'Je force la coherence zmasq=fractint'
+        zmasq(i) = fractint(i)
+     ENDIF
+  ENDDO
+  fractint (1 : klon) =  pctsrf(1 : klon, is_oce)  &
+       + pctsrf(1 : klon, is_sic)
+  DO i = 1 , klon
+     IF ( abs( fractint(i) - (1. - zmasq(i))) .GT. EPSFRA ) THEN
+        WRITE(*, *) 'phyetat0 attention fraction ocean pas ',  &
+             'coherente ', i, zmasq(i) , pctsrf(i, is_oce) &
+             , pctsrf(i, is_sic)
+        WRITE(*, *) 'Je force la coherence zmasq=1.-fractint'
+        zmasq(i) = 1. - fractint(i)
+     ENDIF
+  ENDDO
+
+!===================================================================
+! Lecture des temperatures du sol:
+!===================================================================
+
+  found=phyetat0_get(ftsol(:,1),"TS","Surface temperature",283.)
+  IF (found) THEN
+     DO nsrf=2,nbsrf
+        ftsol(:,nsrf)=ftsol(:,1)
+     ENDDO
+  ELSE
+     found=phyetat0_srf(ftsol,"TS","Surface temperature",283.)
+  ENDIF
+
+!===================================================================
+  ! Lecture des albedo difus et direct
+!===================================================================
+
+  DO nsrf = 1, nbsrf
+     DO isw=1, nsw
+        IF (isw.GT.99) THEN
+           PRINT*, "Trop de bandes SW"
+           call abort_physic("phyetat0", "", 1)
+        ENDIF
+        WRITE(str2, '(i2.2)') isw
+        found=phyetat0_srf(falb_dir(:, isw,:),"A_dir_SW"//str2//"srf","Direct Albedo",0.2)
+        found=phyetat0_srf(falb_dif(:, isw,:),"A_dif_SW"//str2//"srf","Direct Albedo",0.2)
+     ENDDO
+  ENDDO
+
+  found=phyetat0_srf(u10m,"U10M","u a 10m",0.)
+  found=phyetat0_srf(v10m,"V10M","v a 10m",0.)
+
+!===================================================================
+  ! Lecture des temperatures du sol profond:
+!===================================================================
+
+   DO isoil=1, nsoilmx
+        IF (isoil.GT.99) THEN
+           PRINT*, "Trop de couches "
+           call abort_physic("phyetat0", "", 1)
+        ENDIF
+        WRITE(str2,'(i2.2)') isoil
+        found=phyetat0_srf(tsoil(:, isoil,:),"Tsoil"//str2//"srf","Temp soil",0.)
+        IF (.NOT. found) THEN
+           PRINT*, "phyetat0: Le champ <Tsoil"//str7//"> est absent"
+           PRINT*, "          Il prend donc la valeur de surface"
+           tsoil(:, isoil, :)=ftsol(:, :)
+        ENDIF
+   ENDDO
+
+!=======================================================================
+! Lecture precipitation/evaporation
+!=======================================================================
+
+  found=phyetat0_srf(qsurf,"QS","Near surface hmidity",0.)
+  found=phyetat0_get(qsol,"QSOL","Surface hmidity / bucket",0.)
+  found=phyetat0_srf(snow,"SNOW","Surface snow",0.)
+  found=phyetat0_srf(fevap,"EVAP","evaporation",0.)
+  found=phyetat0_get(snow_fall,"snow_f","snow fall",0.)
+  found=phyetat0_get(rain_fall,"rain_f","rain fall",0.)
+
+!=======================================================================
+! Radiation
+!=======================================================================
+
+  found=phyetat0_get(solsw,"solsw","net SW radiation surf",0.)
+  found=phyetat0_get(solswfdiff,"solswfdiff","fraction of SW radiation surf that is diffuse",1.)
+  found=phyetat0_get(sollw,"sollw","net LW radiation surf",0.)
+  found=phyetat0_get(sollwdown,"sollwdown","down LW radiation surf",0.)
+  IF (.NOT. found) THEN
+     sollwdown(:) = 0. ;  zts(:)=0.
+     DO nsrf=1,nbsrf
+        zts(:)=zts(:)+ftsol(:,nsrf)*pctsrf(:,nsrf)
+     ENDDO
+     sollwdown(:)=sollw(:)+RSIGMA*zts(:)**4
+  ENDIF
+
+  found=phyetat0_get(radsol,"RADS","Solar radiation",0.)
+  found=phyetat0_get(fder,"fder","Flux derivative",0.) 
+
+
+  ! Lecture de la longueur de rugosite 
+  found=phyetat0_srf(z0m,"RUG","Z0m ancien",0.001)
+  IF (found) THEN
+     z0h(:,1:nbsrf)=z0m(:,1:nbsrf)
+  ELSE
+     found=phyetat0_srf(z0m,"Z0m","Roughness length, momentum ",0.001)
+     found=phyetat0_srf(z0h,"Z0h","Roughness length, enthalpy ",0.001)
+  ENDIF
+!FC
+  IF (ifl_pbltree>0) THEN
+!CALL get_field("FTER", pctsrf(:, is_ter), found)
+    treedrg(:,1:klev,1:nbsrf)= 0.0
+    CALL get_field("treedrg_ter", drg_ter(:,:), found)
+!  found=phyetat0_srf(treedrg,"treedrg","drag from vegetation" , 0.)
+    !lecture du profile de freinage des arbres
+    IF (.not. found ) THEN
+      treedrg(:,1:klev,1:nbsrf)= 0.0
+    ELSE
+      treedrg(:,1:klev,is_ter)= drg_ter(:,:)
+!     found=phyetat0_get(treedrg,"treedrg","freinage arbres",0.)
+    ENDIF
+  ELSE
+    ! initialize treedrg(), because it will be written in restartphy.nc
+    treedrg(:,:,:) = 0.0 
+  ENDIF
+
+  ! Lecture de l'age de la neige:
+  found=phyetat0_srf(agesno,"AGESNO","SNOW AGE",0.001)
+
+  ancien_ok=.true.
+  ancien_ok=ancien_ok.AND.phyetat0_get(t_ancien,"TANCIEN","TANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(q_ancien,"QANCIEN","QANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(ql_ancien,"QLANCIEN","QLANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(qs_ancien,"QSANCIEN","QSANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(rneb_ancien,"RNEBANCIEN","RNEBANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(u_ancien,"UANCIEN","UANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(v_ancien,"VANCIEN","VANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(prw_ancien,"PRWANCIEN","PRWANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(prlw_ancien,"PRLWANCIEN","PRLWANCIEN",0.)
+  ancien_ok=ancien_ok.AND.phyetat0_get(prsw_ancien,"PRSWANCIEN","PRSWANCIEN",0.)
+
+  ! Ehouarn: addtional tests to check if t_ancien, q_ancien contain
+  !          dummy values (as is the case when generated by ce0l,
+  !          or by iniaqua)
+  IF ( (maxval(q_ancien).EQ.minval(q_ancien))       .OR. &
+       (maxval(ql_ancien).EQ.minval(ql_ancien))     .OR. &
+       (maxval(qs_ancien).EQ.minval(qs_ancien))     .OR. &
+       (maxval(rneb_ancien).EQ.minval(rneb_ancien)) .OR. &
+       (maxval(prw_ancien).EQ.minval(prw_ancien))   .OR. &
+       (maxval(prlw_ancien).EQ.minval(prlw_ancien)) .OR. &
+       (maxval(prsw_ancien).EQ.minval(prsw_ancien)) .OR. &
+       (maxval(t_ancien).EQ.minval(t_ancien)) ) THEN
+    ancien_ok=.false.
+  ENDIF
+
+  found=phyetat0_get(clwcon,"CLWCON","CLWCON",0.)
+  found=phyetat0_get(rnebcon,"RNEBCON","RNEBCON",0.)
+  found=phyetat0_get(ratqs,"RATQS","RATQS",0.)
+
+  found=phyetat0_get(run_off_lic_0,"RUNOFFLIC0","RUNOFFLIC0",0.)
+
+!==================================
+!  TKE
+!==================================
+!
+  IF (iflag_pbl>1) then
+     found=phyetat0_srf(pbl_tke,"TKE","Turb. Kinetic. Energ. ",1.e-8)
+  ENDIF
+
+  IF (iflag_pbl>1 .AND. iflag_wake>=1  .AND. iflag_pbl_split >=1 ) then
+    found=phyetat0_srf(wake_delta_pbl_tke,"DELTATKE","Del TKE wk/env",0.)
+!!    found=phyetat0_srf(delta_tsurf,"DELTA_TSURF","Delta Ts wk/env ",0.)
+    found=phyetat0_srf(delta_tsurf,"DELTATS","Delta Ts wk/env ",0.)
+!!    found=phyetat0_srf(beta_aridity,"BETA_S","Aridity factor ",1.)
+    found=phyetat0_srf(beta_aridity,"BETAS","Aridity factor ",1.)
+  ENDIF   !(iflag_pbl>1 .AND. iflag_wake>=1 .AND. iflag_pbl_split >=1 )
+
+!==================================
+!  thermiques, poches, convection
+!==================================
+
+! Emanuel
+  found=phyetat0_get(sig1,"sig1","sig1",0.)
+  found=phyetat0_get(w01,"w01","w01",0.)
+
+! Wake
+  found=phyetat0_get(wake_deltat,"WAKE_DELTAT","Delta T wake/env",0.)
+  found=phyetat0_get(wake_deltaq,"WAKE_DELTAQ","Delta hum. wake/env",0.)
+  found=phyetat0_get(wake_s,"WAKE_S","Wake frac. area",0.)
+!jyg<
+!  Set wake_dens to -1000. when there is no restart so that the actual
+!  initialization is made in calwake.
+!!  found=phyetat0_get(1,wake_dens,"WAKE_DENS","Wake num. /unit area",0.)
+  found=phyetat0_get(wake_dens,"WAKE_DENS","Wake num. /unit area",-1000.)
+  found=phyetat0_get(awake_dens,"AWAKE_DENS","Active Wake num. /unit area",0.)
+  found=phyetat0_get(cv_gen,"CV_GEN","CB birth rate",0.)
+!>jyg
+  found=phyetat0_get(wake_cstar,"WAKE_CSTAR","WAKE_CSTAR",0.)
+  found=phyetat0_get(wake_pe,"WAKE_PE","WAKE_PE",0.)
+  found=phyetat0_get(wake_fip,"WAKE_FIP","WAKE_FIP",0.)
+
+! Thermiques
+  found=phyetat0_get(zmax0,"ZMAX0","ZMAX0",40.)
+  found=phyetat0_get(f0,"F0","F0",1.e-5)
+  found=phyetat0_get(fm_therm,"FM_THERM","Thermals mass flux",0.)
+  found=phyetat0_get(entr_therm,"ENTR_THERM","Thermals Entrain.",0.)
+  found=phyetat0_get(detr_therm,"DETR_THERM","Thermals Detrain.",0.)
+
+! ALE/ALP
+  found=phyetat0_get(ale_bl,"ALE_BL","ALE BL",0.)
+  found=phyetat0_get(ale_bl_trig,"ALE_BL_TRIG","ALE BL_TRIG",0.)
+  found=phyetat0_get(alp_bl,"ALP_BL","ALP BL",0.)
+  found=phyetat0_get(ale_wake,"ALE_WAKE","ALE_WAKE",0.)
+  found=phyetat0_get(ale_bl_stat,"ALE_BL_STAT","ALE_BL_STAT",0.)
+
+! fisrtilp/Clouds 0.002 could be ratqsbas. But can stay like this as well
+  found=phyetat0_get(ratqs_inter,"RATQS_INTER","Relative width of the lsc sugrid scale water",0.002)
+
+!===========================================
+  ! Read and send field trs to traclmdz
+!===========================================
+
+!--OB now this is for co2i - ThL: and therefore also for inco
+  IF (ANY(type_trac == ['co2i','inco'])) THEN
+     IF (carbon_cycle_cpl) THEN
+        ALLOCATE(co2_send(klon), stat=ierr)
+        IF (ierr /= 0) CALL abort_physic('phyetat0', 'pb allocation co2_send', 1)
+        found=phyetat0_get(co2_send,"co2_send","co2 send",co2_ppm0)
+     ENDIF
+  ELSE IF (type_trac == 'lmdz') THEN
+     it = 0
+     DO iq = 1, nqtot
+        IF(.NOT.(tracers(iq)%isAdvected .AND. tracers(iq)%isInPhysics)) CYCLE
+        it = it+1
+        tname = tracers(iq)%name
+        t(1) = 'trs_'//TRIM(tname); t(2) = 'trs_'//TRIM(new2oldH2O(tname))
+        found = phyetat0_get(trs(:,it), t(:), "Surf trac"//TRIM(tname), 0.)
+     END DO
+     CALL traclmdz_from_restart(trs)
+  ENDIF
+
+#ifdef ISO
+        ! initialise les isotopes       
+        write(*,*) 'phyetat0 1069' 
+         CALL phyisoetat0 (snow,run_off_lic_0, &
+     &           xtsnow,xtrun_off_lic_0, &
+     &           Rland_ice)
+#ifdef ISOVERIF 
+      write(*,*) 'phyetat0 1074'
+      if (iso_eau.gt.0) then
+      call iso_verif_egalite_vect2D(  &
+     &           xtsnow,snow, &
+     &           'phyetat0 1101a',niso,klon,nbsrf)
+        do i=1,klon  
+              call iso_verif_egalite(Rland_ice(iso_eau,i),1.0, &
+     &         'phyetat0 1101b')
+         enddo
+      endif
+      write(*,*) 'phyetat0 1102'
+#endif
+#endif
+
+!===========================================
+!  ondes de gravite / relief
+!===========================================
+
+!  ondes de gravite non orographiques
+  IF (ok_gwd_rando) found = &
+       phyetat0_get(du_gwd_rando,"du_gwd_rando","du_gwd_rando",0.)
+  IF (.NOT. ok_hines .AND. ok_gwd_rando) found &
+       = phyetat0_get(du_gwd_front,"du_gwd_front","du_gwd_front",0.)
+
+!  prise en compte du relief sous-maille
+  found=phyetat0_get(zmea,"ZMEA","sub grid orography",0.)
+  found=phyetat0_get(zstd,"ZSTD","sub grid orography",0.)
+  found=phyetat0_get(zsig,"ZSIG","sub grid orography",0.)
+  found=phyetat0_get(zgam,"ZGAM","sub grid orography",0.)
+  found=phyetat0_get(zthe,"ZTHE","sub grid orography",0.)
+  found=phyetat0_get(zpic,"ZPIC","sub grid orography",0.)
+  found=phyetat0_get(zval,"ZVAL","sub grid orography",0.)
+  found=phyetat0_get(zmea,"ZMEA","sub grid orography",0.)
+  found=phyetat0_get(rugoro,"RUGSREL","sub grid orography",0.)
+
+!===========================================
+! Initialize ocean
+!===========================================
+
+  IF ( type_ocean == 'slab' ) THEN
+      CALL ocean_slab_init(phys_tstep, pctsrf)
+      IF (nslay.EQ.1) THEN
+        found=phyetat0_get(tslab,["tslab01","tslab  "],"tslab",0.)
+      ELSE
+          DO i=1,nslay
+            WRITE(str2,'(i2.2)') i
+            found=phyetat0_get(tslab(:,i),"tslab"//str2,"tslab",0.)  
+          ENDDO
+      ENDIF
+      IF (.NOT. found) THEN 
+          PRINT*, "phyetat0: Le champ <tslab> est absent"
+          PRINT*, "Initialisation a tsol_oce"
+          DO i=1,nslay
+              tslab(:,i)=MAX(ftsol(:,is_oce),271.35)
+          ENDDO
+      ENDIF 
+
+      ! Sea ice variables
+      IF (version_ocean == 'sicINT') THEN
+          found=phyetat0_get(tice,"slab_tice","slab_tice",0.)
+          IF (.NOT. found) THEN 
+              PRINT*, "phyetat0: Le champ <tice> est absent"
+              PRINT*, "Initialisation a tsol_sic"
+                  tice(:)=ftsol(:,is_sic)
+          ENDIF 
+          found=phyetat0_get(seaice,"seaice","seaice",0.)
+          IF (.NOT. found) THEN
+              PRINT*, "phyetat0: Le champ <seaice> est absent"
+              PRINT*, "Initialisation a 0/1m suivant fraction glace"
+              seaice(:)=0.
+              WHERE (pctsrf(:,is_sic).GT.EPSFRA)
+                  seaice=917.
+              ENDWHERE
+          ENDIF
+      ENDIF !sea ice INT
+  ENDIF ! Slab        
+
+  if (activate_ocean_skin >= 1) then
+     if (activate_ocean_skin == 2 .and. type_ocean == 'couple') then
+        found = phyetat0_get(delta_sal, "delta_sal", &
+             "ocean-air interface salinity minus bulk salinity", 0.)
+        found = phyetat0_get(delta_sst, "delta_SST", &
+             "ocean-air interface temperature minus bulk SST", 0.)
+        found = phyetat0_get(dter, "dter", &
+             "ocean-air interface temperature minus subskin temperature", 0.)
+        found = phyetat0_get(dser, "dser", &
+             "ocean-air interface salinity minus subskin salinity", 0.)
+        found = phyetat0_get(dt_ds, "dt_ds", "(tks / tkt) * dTer", 0.)
+
+        where (pctsrf(:, is_oce) == 0.)
+           delta_sst = missing_val
+           delta_sal = missing_val
+           dter = missing_val
+           dser = missing_val
+           dt_ds = missing_val
+        end where
+     end if
+     
+     found = phyetat0_get(ds_ns, "dS_ns", "delta salinity near surface", 0.)
+     found = phyetat0_get(dt_ns, "dT_ns", "delta temperature near surface", &
+          0.)
+
+     where (pctsrf(:, is_oce) == 0.)
+        ds_ns = missing_val
+        dt_ns = missing_val
+        delta_sst = missing_val
+        delta_sal = missing_val
+     end where
+  end if
+
+  ! on ferme le fichier
+  CALL close_startphy
+
+  ! Initialize module pbl_surface_mod 
+
+! 994 est trop grand quand OpenMP est activé : on sort du tableau
+!#ifdef ISOVERIF
+!        write(*,*) 'phyetat0 572: snow(994,:)=',snow(994,2)
+!        write(*,*) 'xtsnow(:,994,2)=',xtsnow(:,994,2)
+!#endif
+
+  CALL pbl_surface_init(fder, snow, qsurf, tsoil)
+#ifdef ISO
+  CALL pbl_surface_init_iso(xtsnow,Rland_ice)
+#endif
+
+  ! Initialize module ocean_cpl_mod for the case of coupled ocean
+  IF ( type_ocean == 'couple' ) THEN
+     CALL ocean_cpl_init(phys_tstep, longitude_deg, latitude_deg)
+  ENDIF
+
+!  CALL init_iophy_new(latitude_deg, longitude_deg)
+
+  ! Initilialize module fonte_neige_mod      
+  CALL fonte_neige_init(run_off_lic_0)
+#ifdef ISO
+   CALL fonte_neige_init_iso(xtrun_off_lic_0)
+#endif
+
+END SUBROUTINE phyetat0
+
+END MODULE phyetat0_mod
+
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/phyredem.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/phyredem.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/phyredem.F90	(revision 4446)
@@ -30,5 +30,5 @@
                                 du_gwd_rando, du_gwd_front, u10m, v10m, &
                                 treedrg, solswfdiff, delta_sal, ds_ns, dt_ns, &
-                                delta_sst, ratqs_inter
+                                delta_sst, ratqs_inter, dter, dser, dt_ds
 #ifdef ISO
   USE phys_state_var_mod, ONLY: xtsol, fxtevap,xtrain_fall, xtsnow_fall,     &
@@ -39,5 +39,5 @@
   USE iostart, ONLY: open_restartphy, close_restartphy, enddef_restartphy, put_field, put_var
   USE traclmdz_mod, ONLY : traclmdz_to_restart
-  USE infotrac_phy, ONLY: type_trac, nqtot, tracers, nbtr, niso, ntraciso
+  USE infotrac_phy, ONLY: type_trac, nqtot, tracers, nbtr, niso
 #ifdef ISO
 #ifdef ISOVERIF
@@ -45,5 +45,5 @@
 #endif
 #endif
-  USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, co2_send
+  USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, co2_send, carbon_cycle_rad, RCO2_glo
   USE indice_sol_mod, ONLY: nbsrf, is_oce, is_sic, is_ter, is_lic, epsfra
   USE surface_data, ONLY: type_ocean, version_ocean
@@ -130,5 +130,10 @@
 
   ! co2_ppm0 : initial value of atmospheric CO2
-  tab_cntrl(16) = co2_ppm0
+  ! tab_cntrl(16) = co2_ppm0
+
+  !  PC -- initial value of RCO2 for the radiation scheme
+  !  tab_cntrl(17) = co2_ppm * 1.0e-06 * RMCO2 / RMD
+  IF (carbon_cycle_rad) tab_cntrl(17) = RCO2_glo
+  !PRINT*, "PC : phyredem RCO2_glo =",RCO2_glo
 
   DO pass=1,2   ! pass=1 netcdf definition ; pass=2 netcdf write
@@ -171,13 +176,7 @@
     CALL put_field(pass,"FSIC", "fraction glace mer", pctsrf(:, is_sic))
 
-    IF(nbsrf>99) THEN
-      PRINT*, "Trop de sous-mailles";  CALL abort_physic("phyredem", "", 1)
-    END IF
-    IF(nsoilmx>99) THEN
-      PRINT*, "Trop de sous-surfaces"; CALL abort_physic("phyredem", "", 1)
-    END IF
-    IF(nsw>99) THEN
-      PRINT*, "Trop de bandes"; CALL abort_physic("phyredem", "", 1)
-    END IF
+    IF(nbsrf  >99) CALL abort_physic("phyredem", "Trop de sous-mailles", 1)
+    IF(nsoilmx>99) CALL abort_physic("phyredem", "Trop de sous-mailles", 1)
+    IF(nsw    >99) CALL abort_physic("phyredem", "Trop de bandes", 1)
 
 !    Surface variables 
@@ -345,16 +344,5 @@
 
 
-    ! trs from traclmdz_mod
-    IF (type_trac == 'lmdz') THEN
-       CALL traclmdz_to_restart(trs)
-       it = 0
-       DO iq = 1, nqtot
-          IF(.NOT.(tracers(iq)%isAdvected .AND. tracers(iq)%isInPhysics)) CYCLE
-          it = it+1
-          CALL put_field(pass,"trs_"//tracers(iq)%name, "", trs(:, it))
-       END DO
-    END IF
-
-    IF (type_trac == 'co2i' .OR. type_trac == 'inco') THEN
+    IF (ANY(type_trac == ['co2i','inco'])) THEN
        IF (carbon_cycle_cpl) THEN
           IF (.NOT. ALLOCATED(co2_send)) THEN
@@ -365,4 +353,14 @@
           CALL put_field(pass,"co2_send", "co2_ppm for coupling", co2_send)
        END IF
+
+    ! trs from traclmdz_mod
+    ELSE IF (type_trac == 'lmdz') THEN
+       CALL traclmdz_to_restart(trs)
+       it = 0
+       DO iq = 1, nqtot
+          IF(.NOT.(tracers(iq)%isAdvected .AND. tracers(iq)%isInPhysics)) CYCLE
+          it = it+1
+          CALL put_field(pass,"trs_"//tracers(iq)%name, "", trs(:, it))
+       END DO
     END IF
 
@@ -395,4 +393,11 @@
           CALL put_field(pass, "delta_SST", &
                "ocean-air interface temperature minus bulk SST", delta_sst)
+          CALL put_field(pass, "dter", &
+               "ocean-air interface temperature minus subskin temperature", &
+               dter)
+          CALL put_field(pass, "dser", &
+               "ocean-air interface salinity minus subskin salinity", dser)
+          CALL put_field(pass, "dt_ds", &
+               "(tks / tkt) * dTer", dt_ds)
        end if
        
@@ -485,9 +490,9 @@
         xtrain_fall,xtsnow_fall, ql_ancien,xtl_ancien,qs_ancien,xts_ancien, &
         xtsol,fxtevap
-      USE infotrac_phy,ONLY: niso, ntraciso
+      USE infotrac_phy,ONLY: niso, ntiso
       !USE control_mod
       USE indice_sol_mod, ONLY: nbsrf
       USE iostart, ONLY: put_field
-      USE isotopes_mod, ONLY: striso,iso_eau
+      USE isotopes_mod, ONLY: isoName,iso_eau
 #ifdef ISOVERIF
       USE isotopes_verif_mod
@@ -509,5 +514,5 @@
       !REAL xtsol(niso,klon)
       REAL xtsnow(niso,klon,nbsrf) 
-      !REAL xtevap(ntraciso,klon,nbsrf)     
+      !REAL xtevap(ntiso,klon,nbsrf)     
       REAL xtrun_off_lic_0(niso,klon)
       REAL Rland_ice(niso,klon)
@@ -566,18 +571,9 @@
 #endif
 
-   do ixt=1,ntraciso
-
-     if (ixt.le.niso) then
-        outiso=striso(ixt)
-     else
-#ifdef ISOTRAC
-        iiso=index_iso(ixt)
-        izone=index_zone(ixt)       
-        outiso=striso(iiso)//strtrac(izone)
-#else
-        write(*,*) 'phyredem 546: ixt,ntraciso=', ixt,ntraciso
-        stop
-#endif
-     endif !if (ixt.le.niso) then
+   do ixt=1,ntiso
+
+      outiso = TRIM(isoName(ixt))
+      i = INDEX(outiso, '_', .TRUE.)
+      outiso = outiso(1:i-1)//outiso(i+1:LEN_TRIM(outiso))
       write(*,*) 'phyredem 550: ixt,outiso=',ixt,TRIM(outiso)
       
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/phys_local_var_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/phys_local_var_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/phys_local_var_mod.F90	(revision 4446)
@@ -726,5 +726,5 @@
 USE infotrac_phy, ONLY : nbtr
 #ifdef ISO
-USE infotrac_phy, ONLY : ntraciso,niso
+USE infotrac_phy, ONLY : ntraciso=>ntiso,niso
 #endif
 USE aero_mod
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/phys_output_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/phys_output_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/phys_output_mod.F90	(revision 4446)
@@ -35,5 +35,5 @@
     USE iophy 
     USE dimphy
-    USE infotrac_phy, ONLY: nqtot, tracers, type_trac, niso, ntraciso
+    USE infotrac_phy, ONLY: nqtot, tracers, niso, ntraciso=>ntiso
     USE strings_mod,  ONLY: maxlen
     USE ioipsl
@@ -52,5 +52,5 @@
 #endif
 #ifdef ISO
-    USE isotopes_mod, ONLY: striso,iso_HTO
+    USE isotopes_mod, ONLY: isoName,iso_HTO
 #ifdef ISOTRAC
     use isotrac_mod, only: index_zone,index_iso,strtrac
@@ -122,5 +122,5 @@
 
 #ifdef ISO
-    CHARACTER(LEN=LEN(striso)) :: outiso
+    CHARACTER(LEN=maxlen) :: outiso
     CHARACTER(LEN=20) :: unit
 #endif
@@ -546,16 +546,7 @@
     write(*,*) 'phys_output_mid 589'
     do ixt=1,ntraciso
-      if (ixt <= niso) then
-        outiso=striso(ixt)
-      else
-#ifdef ISOTRAC
-        iiso=index_iso(ixt)
-        izone=index_zone(ixt)       
-        outiso=striso(iiso)//strtrac(izone)
-#else
-        write(*,*) 'phys_output_mod 546: ixt,ntraciso=', ixt,ntraciso
-        stop
-#endif
-      endif
+      outiso = TRIM(isoName(ixt))
+      i = INDEX(outiso, '_', .TRUE.)
+      outiso = outiso(1:i-1)//outiso(i+1:LEN_TRIM(outiso))
 
       flag = [1,  1,  1, 10,  5, 10, 11, 11, 11, 11]; unit = 'kg/(s*m2)'
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/phys_output_var_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/phys_output_var_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/phys_output_var_mod.F90	(revision 4446)
@@ -135,25 +135,17 @@
   ! Ocean-atmosphere interface, subskin ocean and near-surface ocean:
   
-  REAL, ALLOCATABLE, SAVE:: dter(:)
-  ! Temperature variation in the diffusive microlayer, that is
-  ! ocean-air interface temperature minus subskin temperature. In K.
-      
-  REAL, SAVE, ALLOCATABLE:: dser(:)
-  ! Temperature variation in the diffusive microlayer, that is
-  ! subskin temperature minus ocean-air interface temperature. In K.
-
-  REAL, SAVE, ALLOCATABLE:: tkt(:)
+  REAL, SAVE, ALLOCATABLE:: tkt(:) ! (klon)
   ! épaisseur (m) de la couche de diffusion thermique (microlayer)
   ! cool skin thickness
 
-  REAL, SAVE, ALLOCATABLE:: tks(:)
+  REAL, SAVE, ALLOCATABLE:: tks(:) ! (klon)
   ! épaisseur (m) de la couche de diffusion de masse (microlayer)
   
-  REAL, SAVE, ALLOCATABLE:: taur(:) ! momentum flux due to rain, in Pa
-
-  REAL, SAVE, ALLOCATABLE:: sss(:)
+  REAL, SAVE, ALLOCATABLE:: taur(:) ! (klon) momentum flux due to rain, in Pa
+
+  REAL, SAVE, ALLOCATABLE:: sss(:) ! (klon)
   ! bulk salinity of the surface layer of the ocean, in ppt
   
-  !$OMP THREADPRIVATE(dter, dser, tkt, tks, taur, sss)
+  !$OMP THREADPRIVATE(tkt, tks, taur, sss)
 
 CONTAINS
@@ -216,6 +208,6 @@
     IF (ok_gwd_rando) allocate(zustr_gwd_rando(klon), zvstr_gwd_rando(klon))
 
-    if (activate_ocean_skin >= 1) allocate(dter(klon), dser(klon), tkt(klon), &
-         tks(klon), taur(klon), sss(klon))
+    if (activate_ocean_skin >= 1) allocate(tkt(klon), tks(klon), taur(klon), &
+         sss(klon))
 
   END SUBROUTINE phys_output_var_init
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/physiq_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/physiq_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/physiq_mod.F90	(revision 4446)
@@ -39,8 +39,7 @@
     USE ioipsl_getin_p_mod, ONLY : getin_p
     USE indice_sol_mod
-    USE infotrac, ONLY: iso_num, iso_indnum
-    USE infotrac_phy, ONLY: nqtot, nbtr, nqo, tracers, type_trac, nqCO2, indnum_fn_num
+    USE infotrac_phy, ONLY: nqtot, nbtr, nqo, tracers, type_trac
     USE readTracFiles_mod, ONLY: addPhase
-    USE strings_mod,  ONLY: strIdx, strStack, int2str
+    USE strings_mod,  ONLY: strIdx
     USE iophy
     USE limit_read_mod, ONLY : init_limit_read
@@ -54,7 +53,8 @@
     USE pbl_surface_mod, ONLY : pbl_surface
     USE phyaqua_mod, only: zenang_an
+    USE phyetat0_mod, only: phyetat0
     USE phystokenc_mod, ONLY: offline, phystokenc
     USE phys_cal_mod, only: year_len, mth_len, days_elapsed, jh_1jan, &
-         year_cur, mth_cur,jD_cur, jH_cur, jD_ref, day_cur, hour
+         year_cur, mth_cur,jD_cur, jH_cur, jD_ref, day_cur, hour, calend
 !!  USE phys_local_var_mod, ONLY : a long list of variables
 !!              ==> see below, after "CPP Keys" section
@@ -69,14 +69,17 @@
     USE regr_horiz_time_climoz_m, ONLY: regr_horiz_time_climoz
     USE regr_pr_time_av_m, only: regr_pr_time_av
-    USE surface_data,     ONLY : type_ocean, ok_veget, landice_opt
-    USE time_phylmdz_mod, only: annee_ref, current_time, day_ini, day_ref, &
-          day_step_phy, itau_phy, pdtphys, raz_date, start_time, update_time
+    USE surface_data,     ONLY : type_ocean, ok_veget
+    USE time_phylmdz_mod, only: current_time, itau_phy, pdtphys, raz_date, update_time
     USE tracinca_mod, ONLY: config_inca
     USE tropopause_m,     ONLY: dyn_tropopause
     USE ice_sursat_mod,  ONLY: flight_init, airplane
     USE vampir
-    USE VERTICAL_LAYERS_MOD, ONLY: aps,bps, ap, bp
     USE write_field_phy
+#ifdef CPP_XIOS
+    USE wxios, ONLY: g_ctx, wxios_set_context
+#endif
+    USE lscp_ini_mod, ONLY : lscp_ini
     USE lscp_mod, ONLY : lscp
+    USE wake_ini_mod, ONLY : wake_ini
     USE thermcell_ini_mod, ONLY : thermcell_ini
 
@@ -97,8 +100,16 @@
 
 
+#ifdef INCA
+    USE geometry_mod,      ONLY: longitude, latitude, boundslon, boundslat, ind_cell_glo
+    USE time_phylmdz_mod,  ONLY: ndays
+    USE infotrac_phy,      ONLY: nqCO2
+#endif
 #ifdef REPROBUS
-    USE CHEM_REP, ONLY : Init_chem_rep_xjour, &
-         d_q_rep,d_ql_rep,d_qi_rep,ptrop,ttrop, &
-         ztrop, gravit,itroprep, Z1,Z2,fac,B
+    USE chem_rep, ONLY: Init_chem_rep_xjour, d_q_rep, d_ql_rep, d_qi_rep, &
+                        ptrop, ttrop, ztrop, gravit, itroprep, Z1, Z2, fac, B
+#endif
+#if defined INCA || defined REPROBUS
+    USE time_phylmdz_mod,    ONLY: annee_ref, day_ini, day_ref, start_time
+    USE vertical_layers_mod, ONLY: aps, bps, ap, bp
 #endif
 
@@ -106,5 +117,5 @@
 #ifdef CPP_RRTM
     USE YOERAD, ONLY : NRADLP
-    USE YOESW, ONLY : RSUN
+!    USE YOESW, ONLY : RSUN
 #endif
 
@@ -116,6 +127,7 @@
 
 #ifdef CPP_XIOS
-    USE xios, ONLY: xios_update_calendar, xios_context_finalize, &
-            xios_get_field_attr, xios_field_is_active
+    USE xios, ONLY: xios_update_calendar, xios_context_finalize
+    USE xios, ONLY: xios_get_field_attr, xios_field_is_active, xios_context
+    USE xios, ONLY: xios_set_current_context
     USE wxios, ONLY: missing_val, missing_val_omp
 #endif
@@ -126,5 +138,5 @@
 
 #ifdef ISO
-    USE infotrac_phy, ONLY: iqiso,niso, ntraciso, nzone
+    USE infotrac_phy, ONLY: iqIsoPha,niso, ntraciso=>ntiso, nzone
     USE isotopes_mod, ONLY: iso_eau,iso_HDO,iso_O18,iso_O17,iso_HTO, &
         & bidouille_anti_divergence,ok_bidouille_wake, &
@@ -180,6 +192,6 @@
        d_t_ajsb,d_q_ajsb, &
        d_t_ajs,d_q_ajs,d_u_ajs,d_v_ajs, &
-       d_t_ajs_w,d_q_ajs_w, &
-       d_t_ajs_x,d_q_ajs_x, &
+!       d_t_ajs_w,d_q_ajs_w, &
+!       d_t_ajs_x,d_q_ajs_x, &
        !
        d_t_eva,d_q_eva,d_ql_eva,d_qi_eva, &
@@ -194,5 +206,5 @@
        d_ts, &
        !
-       d_t_oli,d_u_oli,d_v_oli, &
+!       d_t_oli,d_u_oli,d_v_oli, &
        d_t_oro,d_u_oro,d_v_oro, &
        d_t_oro_gw,d_u_oro_gw,d_v_oro_gw, &
@@ -313,4 +325,8 @@
        sij, &
        !
+       rneblsvol, &
+       zqsatl, zqsats, &
+       qclr, qcld, qss, qvc, rnebclr, rnebss, gamma_ss, &
+       Tcontr, qcontr, qcontr2, fcontrN, fcontrP, &
        cldemi,  &
        cldfra, cldtau, fiwc,  &
@@ -366,5 +382,4 @@
 #endif
        !
-
 
     IMPLICIT NONE
@@ -509,13 +524,7 @@
     !======================================================================
     !
-    INTEGER ivap          ! indice de traceurs pour vapeur d'eau
-    PARAMETER (ivap=1)
-    INTEGER iliq          ! indice de traceurs pour eau liquide
-    PARAMETER (iliq=2)
-    !CR: on ajoute la phase glace
-    INTEGER isol          ! indice de traceurs pour eau glace
-    PARAMETER (isol=3)
-    INTEGER irneb         ! indice de traceurs pour fraction nuageuse LS (optional)
-    PARAMETER (irneb=4)   
+    ! indices de traceurs eau vapeur, liquide, glace, fraction nuageuse LS (optional)
+    INTEGER,SAVE :: ivap, iliq, isol, irneb
+!$OMP THREADPRIVATE(ivap, iliq, isol, irneb)
     !
     !
@@ -585,5 +594,4 @@
     !
     !
-    INTEGER debug
     INTEGER n
     !ym      INTEGER npoints
@@ -642,5 +650,5 @@
     ! Upmost level reached by deep convection and related variable (jyg)
     !
-    INTEGER izero
+!    INTEGER izero
     INTEGER k_upper_cv
     !------------------------------------------------------------------
@@ -820,5 +828,4 @@
     REAL beta_prec_fisrt(klon,klev) ! taux de conv de l'eau cond (fisrt)
     ! RomP <<<
-    REAL          :: calday
 
     !IM cf FH pour Tiedtke 080604
@@ -876,5 +883,4 @@
     !C      EXTERNAL o3cm      ! initialiser l'ozone
     EXTERNAL orbite    ! calculer l'orbite terrestre
-    EXTERNAL phyetat0  ! lire l'etat initial de la physique
     EXTERNAL phyredem  ! ecrire l'etat de redemarrage de la physique
     EXTERNAL suphel    ! initialiser certaines constantes
@@ -941,5 +947,5 @@
     real zqsat(klon,klev)
     !
-    INTEGER i, k, iq, j, nsrf, ll, l, itr
+    INTEGER i, k, iq, nsrf, l, itr
 #ifdef ISO
     real zxt_apres(ntraciso,klon)
@@ -1063,4 +1069,5 @@
 
     REAL picefra(klon,klev)
+    REAL zrel_mount(klon)
     !IM cf. AM 081204 END
     !
@@ -1272,4 +1279,5 @@
 
 #ifdef INCA
+    REAL :: calday, zxsnow_dummy(klon)
     ! set de variables utilisees pour l'initialisation des valeurs provenant de INCA
     REAL, DIMENSION(klon,klev,naero_grp,nbands) :: init_tauinca
@@ -1320,5 +1328,9 @@
     phys_tstep=NINT(pdtphys)
 #ifdef CPP_XIOS
-    IF (.NOT. debut .AND. is_omp_master) CALL xios_update_calendar(itap+1)
+! switch to XIOS LMDZ physics context 
+    IF (.NOT. debut .AND. is_omp_master) THEN
+       CALL wxios_set_context()
+       CALL xios_update_calendar(itap+1)
+    ENDIF
 #endif
 
@@ -1354,4 +1366,8 @@
 
     IF (first) THEN 
+       ivap = strIdx(tracers(:)%name, addPhase('H2O', 'g'))
+       iliq = strIdx(tracers(:)%name, addPhase('H2O', 'l'))
+       isol = strIdx(tracers(:)%name, addPhase('H2O', 's'))
+       irneb= strIdx(tracers(:)%name, addPhase('H2O', 'r'))
        CALL init_etat0_limit_unstruct
        IF (.NOT. create_etat0_limit) CALL init_limit_read(days_elapsed)
@@ -1406,4 +1422,16 @@
           WRITE (lunout, *) ' ok_ice_sursat=y requires 4 H2O tracers ', &
                '(H2O_g, H2O_l, H2O_s, H2O_r) but nqo=', nqo, '. Might as well stop here.'
+          abort_message='see above'
+          CALL abort_physic(modname,abort_message,1)
+       ENDIF
+
+       IF (ok_plane_h2o.AND..NOT.ok_ice_sursat) THEN
+          WRITE (lunout, *) ' ok_plane_h2o=y requires ok_ice_sursat=y '
+          abort_message='see above'
+          CALL abort_physic(modname,abort_message,1)
+       ENDIF
+
+       IF (ok_plane_contrail.AND..NOT.ok_ice_sursat) THEN
+          WRITE (lunout, *) ' ok_plane_contrail=y requires ok_ice_sursat=y '
           abort_message='see above'
           CALL abort_physic(modname,abort_message,1)
@@ -1542,5 +1570,5 @@
        tau_overturning_th(:)=0.
 
-       IF (type_trac == 'inca' .OR. type_trac == 'inco') THEN
+       IF (ANY(type_trac == ['inca','inco'])) THEN
           ! jg : initialisation jusqu'au ces variables sont dans restart
           ccm(:,:,:) = 0.
@@ -1850,13 +1878,18 @@
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        ! Nouvelle initialisation pour le rayonnement RRTM
-       !
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
        CALL iniradia(klon,klev,paprs(1,1:klev+1))
 
-
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+       CALL wake_ini(rg,rd,rv,prt_level)
        CALL thermcell_ini(iflag_thermals,prt_level,tau_thermals,lunout, &
    &    RG,RD,RCPD,RKAPPA,RLVTT,RETV)
+       IF (ok_new_lscp) then
+           CALL lscp_ini(pdtphys,ok_ice_sursat)
+       endif
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
        !
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -2154,5 +2187,5 @@
        !c         ENDDO
        !
-       IF (type_trac == 'inca' .OR. type_trac == 'inco') THEN			! ModThL
+       IF (ANY(type_trac == ['inca','inco'])) THEN ! ModThL
 #ifdef INCA
           CALL VTe(VTphysiq)
@@ -2161,31 +2194,64 @@
           WRITE(lunout,*) 'initial time chemini', days_elapsed, calday
 
-          CALL chemini(  &
-               rg, &
-               ra, &
-               cell_area, &
-               latitude_deg, &
-               longitude_deg, &
-               presnivs, &
-               calday, &
-               klon, &
-               nqtot, &
-               nqo+nqCO2, &
-               pdtphys, &
-               annee_ref, &
-               year_cur, &
-               day_ref,  &
-               day_ini, &
-               start_time, &
-               itau_phy, &
-               date0, &
-               io_lon, &
-               io_lat, &
-               chemistry_couple, &
-               init_source, &
-               init_tauinca, &
-               init_pizinca, &
-               init_cginca, &
-               init_ccminca)
+          call init_const_lmdz( &
+          ndays, nbsrf, is_oce,is_sic, is_ter,is_lic, calend, &
+          config_inca)
+
+          CALL init_inca_geometry( & 
+               longitude, latitude, &
+               boundslon, boundslat, &
+               cell_area, ind_cell_glo) 
+
+          if (grid_type==unstructured) THEN 
+             CALL chemini(  pplay, &
+                  nbp_lon, nbp_lat, &
+                  latitude_deg, &
+                  longitude_deg, &
+                  presnivs, &
+                  calday, &
+                  klon, &
+                  nqtot, &
+                  nqo+nqCO2, &
+                  pdtphys, &
+                  annee_ref, &
+                  year_cur, &
+                  day_ref,  &
+                  day_ini, &
+                  start_time, &
+                  itau_phy, &
+                  date0, &
+                  chemistry_couple, &
+                  init_source, &
+                  init_tauinca, &
+                  init_pizinca, &
+                  init_cginca, &
+                  init_ccminca)
+          ELSE
+             CALL chemini(  pplay, &
+                  nbp_lon, nbp_lat, &
+                  latitude_deg, &
+                  longitude_deg, &
+                  presnivs, &
+                  calday, &
+                  klon, &
+                  nqtot, &
+                  nqo+nqCO2, &
+                  pdtphys, &
+                  annee_ref, &
+                  year_cur, &
+                  day_ref,  &
+                  day_ini, &
+                  start_time, &
+                  itau_phy, &
+                  date0, &
+                  chemistry_couple, &
+                  init_source, &
+                  init_tauinca, &
+                  init_pizinca, &
+                  init_cginca, &
+                  init_ccminca, &
+                  io_lon, &
+                  io_lat)
+          ENDIF
 
 
@@ -2289,4 +2355,5 @@
 
 
+
     ENDIF
     !
@@ -2393,9 +2460,11 @@
           ql_seri(i,k) = qx(i,k,iliq)
           !CR: ATTENTION, on rajoute la variable glace
-          IF (nqo.eq.2) THEN
+          IF (nqo.EQ.2) THEN             !--vapour and liquid only
              qs_seri(i,k) = 0.
-          ELSE IF (nqo.eq.3) THEN
+             rneb_seri(i,k) = 0.
+          ELSE IF (nqo.EQ.3) THEN        !--vapour, liquid and ice
              qs_seri(i,k) = qx(i,k,isol)
-          ELSE IF (nqo.eq.4) THEN
+             rneb_seri(i,k) = 0.
+          ELSE IF (nqo.EQ.4) THEN        !--vapour, liquid, ice and rneb
              qs_seri(i,k) = qx(i,k,isol)
              rneb_seri(i,k) = qx(i,k,irneb)
@@ -2412,19 +2481,19 @@
     do ixt=1,ntraciso
 #ifdef ISOVERIF
-      write(*,*) 'physiq tmp 1762a: ixt,iqiso_vap=',ixt,iqiso(ixt,ivap)
-      write(*,*) 'physiq tmp 1762b: ixt,iqiso_liq=',ixt,iqiso(ixt,iliq)
+      write(*,*) 'physiq tmp 1762a: ixt,iqiso_vap=',ixt,iqIsoPha(ixt,ivap)
+      write(*,*) 'physiq tmp 1762b: ixt,iqiso_liq=',ixt,iqIsoPha(ixt,iliq)
       if (nqo.eq.3) then  
-        write(*,*) 'physiq tmp 1762c: ixt,iqiso_liq=',ixt,iqiso(ixt,iliq)
+        write(*,*) 'physiq tmp 1762c: ixt,iqiso_liq=',ixt,iqIsoPha(ixt,iliq)
       endif !if (nqo.eq.3) then
 #endif
-      if (ixt.gt.niso) write(*,*) 'izone=',tracers(iqiso(ixt,ivap))%iso_iZone 
+      if (ixt.gt.niso) write(*,*) 'izone=',tracers(iqIsoPha(ixt,ivap))%iso_iZone 
       DO k = 1, klev
        DO i = 1, klon
-          xt_seri(ixt,i,k)  = qx(i,k,iqiso(ixt,ivap))
-          xtl_seri(ixt,i,k) = qx(i,k,iqiso(ixt,iliq))
+          xt_seri(ixt,i,k)  = qx(i,k,iqIsoPha(ixt,ivap))
+          xtl_seri(ixt,i,k) = qx(i,k,iqIsoPha(ixt,iliq))
           if (nqo.eq.2) then
              xts_seri(ixt,i,k) = 0.
           else if (nqo.eq.3) then
-             xts_seri(ixt,i,k) = qx(i,k,iqiso(ixt,isol))
+             xts_seri(ixt,i,k) = qx(i,k,iqIsoPha(ixt,isol))
           endif
        enddo !DO i = 1, klon
@@ -2661,6 +2730,6 @@
        ! !! RomP >>>   td dyn traceur
        IF (nqtot > nqo) d_tr_dyn(:,:,:)= 0.0
+       ! !! RomP <<<
        d_rneb_dyn(:,:)=0.0
-       ! !! RomP <<<
        ancien_ok = .TRUE.
     ENDIF
@@ -3032,5 +3101,4 @@
       ! verif iso_eau
       !write(*,*) 'physiq tmp 2748: iso_eau=',iso_eau
-      !write(*,*) 'use_iso=',use_iso
       !write(*,*) 'iso_eau.gt.0=',iso_eau.gt.0
       !write(*,*) 'd_xt_vdf(iso_eau,1,1),d_q_vdf(1,1)=',d_xt_vdf(iso_eau,1,1),d_q_vdf(1,1)
@@ -4612,15 +4680,22 @@
     IF (ok_new_lscp) THEN
 
-    CALL lscp(phys_tstep,missing_val,paprs,pplay, &
+    !--mise à jour de flight_m et flight_h2o dans leur module
+    IF (ok_plane_h2o .OR. ok_plane_contrail) THEN
+      CALL airplane(debut,pphis,pplay,paprs,t_seri)
+    ENDIF
+
+    CALL lscp(klon,klev,phys_tstep,missing_val,paprs,pplay, &
          t_seri, q_seri,ptconv,ratqs, &
-         d_t_lsc, d_q_lsc, d_ql_lsc, d_qi_lsc, rneb, rneb_seri, & 
+         d_t_lsc, d_q_lsc, d_ql_lsc, d_qi_lsc, rneb, rneblsvol, rneb_seri, &
          cldliq, picefra, rain_lsc, snow_lsc, &
-         pfrac_impa, pfrac_nucl, pfrac_1nucl, &
          frac_impa, frac_nucl, beta_prec_fisrt, &
          prfl, psfl, rhcl,  &
          zqasc, fraca,ztv,zpspsk,ztla,zthl,iflag_cld_th, &
-         iflag_ice_thermo, ok_ice_sursat)
+         iflag_ice_thermo, ok_ice_sursat, zqsatl, zqsats, &
+         qclr, qcld, qss, qvc, rnebclr, rnebss, gamma_ss, &
+         Tcontr, qcontr, qcontr2, fcontrN, fcontrP )
 
     ELSE
+
     CALL fisrtilp(phys_tstep,paprs,pplay, &
          t_seri, q_seri,ptconv,ratqs, &
@@ -4694,5 +4769,5 @@
        ENDDO
     ENDDO
-    IF (nqo==3) THEN
+    IF (nqo >= 3) THEN
     DO k = 1, klev
        DO i = 1, klon
@@ -5116,5 +5191,5 @@
     ENDDO
 
-    IF (type_trac == 'inca' .OR. type_trac == 'inco') THEN	! ModThL
+    IF (ANY(type_trac == ['inca','inco'])) THEN ! ModThL
 #ifdef INCA
        CALL VTe(VTphysiq)
@@ -5501,7 +5576,5 @@
           ! 
           !--interactive CO2 in ppm from carbon cycle
-          IF (carbon_cycle_rad.AND..NOT.debut) THEN
-            RCO2=RCO2_glo
-          ENDIF
+          IF (carbon_cycle_rad) RCO2=RCO2_glo
           !
           IF (prt_level .GE.10) THEN
@@ -5559,16 +5632,4 @@
  
 #ifndef CPP_XIOS
-          !--OB 30/05/2016 modified 21/10/2016
-          !--here we return swaero_diag and dryaod_diag to FALSE
-          !--and histdef will switch it back to TRUE if necessary
-          !--this is necessary to get the right swaero at first step
-          !--but only in the case of no XIOS as XIOS is covered elsewhere 
-          IF (debut) swaerofree_diag = .FALSE.
-          IF (debut) swaero_diag = .FALSE.
-          IF (debut) dryaod_diag = .FALSE.
-          !--IM 15/09/2017 here we return ok_4xCO2atm to FALSE
-          !--as for swaero_diag, see above
-          IF (debut) ok_4xCO2atm = .FALSE.
-
           !
           !IM 2eme calcul radiatif pour le cas perturbe ou au moins un
@@ -5738,6 +5799,9 @@
        DO i=1,klon
           itest(i)=0
-          !        IF ((zstd(i).gt.10.0)) THEN
-          IF (((zpic(i)-zmea(i)).GT.100.).AND.(zstd(i).GT.10.0)) THEN
+          zrel_mount(i)=zstd(i)/(max(zsig(i),1.E-8)*sqrt(cell_area(i)))
+          !zrel_mount: relative mountain height wrt relief explained by mean slope
+          ! -> condition on zrel_mount can deactivate the drag on tilted planar terrains
+          !    such as ice sheets (work by V. Wiener)
+          IF (((zpic(i)-zmea(i)).GT.100.).AND.(zstd(i).GT.10.0).AND.(zrel_mount(i).GE.zrel_mount_t)) THEN
              itest(i)=1
              igwd=igwd+1
@@ -5792,5 +5856,9 @@
        DO i=1,klon
           itest(i)=0
-          IF ((zpic(i)-zmea(i)).GT.100.) THEN
+          !zrel_mount: relative mountain height wrt relief explained by mean slope
+          ! -> condition on zrel_mount can deactivate the lifting on tilted planar terrains
+          !    such as ice sheets (work by V. Wiener)
+          zrel_mount(i)=zstd(i)/(max(zsig(i),1.E-8)*sqrt(cell_area(i)))
+          IF (((zpic(i)-zmea(i)).GT.100.).AND.(zrel_mount(i).GE.zrel_mount_t)) THEN
              itest(i)=1
              igwd=igwd+1
@@ -6279,5 +6347,5 @@
     ELSE
        sh_in(:,:) = qx(:,:,ivap)
-       IF (nqo .EQ. 3) THEN 
+       IF (nqo >= 3) THEN 
           ch_in(:,:) = qx(:,:,iliq) + qx(:,:,isol)
        ELSE 
@@ -6366,17 +6434,16 @@
     ! Calculer le transport de l'eau et de l'energie (diagnostique)
     !
-    CALL transp (paprs,zxtsol, &
-         t_seri, q_seri, ql_seri, qs_seri, u_seri, v_seri, zphi, &
-         ve, vq, ue, uq, vwat, uwat)
+    CALL transp (paprs,zxtsol, t_seri, q_seri, ql_seri, qs_seri, u_seri, v_seri, zphi, &
+                 ue, ve, uq, vq, uwat, vwat)
     !
     !IM global posePB BEG
     IF(1.EQ.0) THEN
        !
-       CALL transp_lay (paprs,zxtsol, &
-            t_seri, q_seri, u_seri, v_seri, zphi, &
+       CALL transp_lay (paprs,zxtsol, t_seri, q_seri, u_seri, v_seri, zphi, &
             ve_lay, vq_lay, ue_lay, uq_lay)
        !
     ENDIF !(1.EQ.0) THEN
     !IM global posePB END
+    !
     ! Accumuler les variables a stocker dans les fichiers histoire:
     !
@@ -6389,5 +6456,5 @@
     d_t_ec(:,:)=0.
     forall (k=1: nbp_lev) exner(:, k) = (pplay(:, k)/paprs(:,1))**RKAPPA
-    CALL ener_conserv(klon,klev,pdtphys,u,v,t,qx(:,:,ivap),qx(:,:,iliq),qx(:,:,isol), &
+    CALL ener_conserv(klon,klev,pdtphys,u,v,t,qx,ivap,iliq,isol, &
          u_seri,v_seri,t_seri,q_seri,ql_seri,qs_seri,pbl_tke(:,:,is_ave)-tke0(:,:), &
          zmasse,exner,d_t_ec)
@@ -6434,5 +6501,5 @@
 #endif
     !
-    IF (type_trac == 'inca' .OR. type_trac == 'inco') THEN
+    IF (ANY(type_trac == ['inca','inco'])) THEN
 #ifdef INCA
        CALL VTe(VTphysiq)
@@ -6451,5 +6518,5 @@
             pphis, &
             zx_rh, &
-            aps, bps, ap, bp)
+            aps, bps, ap, bp, lafin)
 
        CALL VTe(VTinca)
@@ -6458,4 +6525,9 @@
     ENDIF
 
+    IF (type_trac == 'repr') THEN
+#ifdef REPROBUS
+        CALL coord_hyb_rep(paprs, pplay, aps, bps, ap, bp, cell_area)
+#endif
+    ENDIF
 
     !
@@ -6481,9 +6553,9 @@
           d_qx(i,k,iliq) = ( ql_seri(i,k) - qx(i,k,iliq) ) / phys_tstep
           !CR: on ajoute le contenu en glace
-          IF (nqo.ge.3) THEN
+          IF (nqo >= 3) THEN
              d_qx(i,k,isol) = ( qs_seri(i,k) - qx(i,k,isol) ) / phys_tstep
           ENDIF
           !--ice_sursat: nqo=4, on ajoute rneb
-          IF (nqo.eq.4) THEN
+          IF (nqo == 4) THEN
              d_qx(i,k,irneb) = ( rneb_seri(i,k) - qx(i,k,irneb) ) / phys_tstep
           ENDIF
@@ -6496,10 +6568,10 @@
       DO k = 1, klev
        DO i = 1, klon
-          iq=iqiso(ixt,ivap)
+          iq=iqIsoPha(ixt,ivap)
           d_qx(i,k,iq) = ( xt_seri(ixt,i,k) - qx(i,k,iq) ) / phys_tstep
-          iq=iqiso(ixt,iliq)
+          iq=iqIsoPha(ixt,iliq)
           d_qx(i,k,iq) = ( xtl_seri(ixt,i,k) - qx(i,k,iq) ) / phys_tstep
           if (nqo.eq.3) then
-             iq=iqiso(ixt,isol)
+             iq=iqIsoPha(ixt,isol)
              d_qx(i,k,iq) = ( xts_seri(ixt,i,k) - qx(i,k,iq) ) / phys_tstep
           endif
@@ -6507,11 +6579,5 @@
       enddo ! DO k = 1, klev
     enddo !do ixt=1,ntraciso
-!#ifdef ISOVERIF
-!        write(*,*) 'physiq 6120: d_qx(1,1,:)=',d_qx(1,1,:)
-!        write(*,*) 'qx(1,1,:)=',qx(1,1,:)
-!        write(*,*) 'xt_seri(:,1,1)=',xt_seri(:,1,1)
-!#endif
-#endif
-! #ifdef ISO
+#endif
     ! DC: All iterations are cycled if nqtot==nqo, so no nqtot>nqo condition required
     itr = 0
@@ -6573,4 +6639,5 @@
     ql_ancien(:,:) = ql_seri(:,:)
     qs_ancien(:,:) = qs_seri(:,:)
+    rneb_ancien(:,:) = rneb_seri(:,:)
 #ifdef ISO
     xt_ancien(:,:,:)=xt_seri(:,:,:)
@@ -6832,4 +6899,13 @@
 #ifdef CPP_XIOS
        IF (is_omp_master) CALL xios_context_finalize
+
+#ifdef INCA
+       if (type_trac == 'inca') then 
+          IF (is_omp_master .and. grid_type==unstructured) THEN 
+             CALL finalize_inca
+          ENDIF
+       endif
+#endif
+
 #endif
        WRITE(lunout,*) ' physiq fin, nombre de steps ou cvpas = 1 : ', Ncvpaseq1
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/reevap.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/reevap.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/reevap.F90	(revision 4446)
@@ -9,5 +9,5 @@
     USE add_phys_tend_mod, only : fl_cor_ebil 
 #ifdef ISO
-    USE infotrac_phy, ONLY: ntraciso   
+    USE infotrac_phy, ONLY: ntiso   
 #ifdef ISOVERIF
     USE isotopes_verif_mod
@@ -30,6 +30,6 @@
 
 #ifdef ISO
-    REAL, DIMENSION(ntraciso,klon,klev), INTENT(in) :: xt_seri,xtl_seri,xts_seri
-    REAL, DIMENSION(ntraciso,klon,klev), INTENT(out) :: d_xt_eva,d_xtl_eva,d_xts_eva
+    REAL, DIMENSION(ntiso,klon,klev), INTENT(in) :: xt_seri,xtl_seri,xts_seri
+    REAL, DIMENSION(ntiso,klon,klev), INTENT(out) :: d_xt_eva,d_xtl_eva,d_xts_eva
     integer ixt
 #endif
@@ -76,12 +76,12 @@
 
 #ifdef ISO
-         do ixt=1,ntraciso
+         do ixt=1,ntiso
             zb = MAX(0.0,xtl_seri(ixt,i,k))
             d_xt_eva(ixt,i,k) = zb
             d_xtl_eva(ixt,i,k) = -xtl_seri(ixt,i,k)
             d_xts_eva(ixt,i,k) = 0.
-         enddo ! do ixt=1,ntraciso
+         enddo
 #ifdef ISOVERIF
-      do ixt=1,ntraciso
+      do ixt=1,ntiso
         call iso_verif_noNaN(xt_seri(ixt,i,k), &
      &     'physiq 2417: apres evap tot')
@@ -136,13 +136,13 @@
 
 #ifdef ISO
-         do ixt=1,ntraciso
+         do ixt=1,ntiso
             zb = MAX(0.0,xtl_seri(ixt,i,k)+xts_seri(ixt,i,k))
             d_xt_eva(ixt,i,k) = zb
             d_xtl_eva(ixt,i,k) = -xtl_seri(ixt,i,k)
             d_xts_eva(ixt,i,k) = -xts_seri(ixt,i,k)
-         enddo ! do ixt=1,ntraciso
+         enddo
 
 #ifdef ISOVERIF
-      do ixt=1,ntraciso
+      do ixt=1,ntiso
       call iso_verif_noNaN(xt_seri(ixt,i,k), &
      &     'physiq 2417: apres evap tot')
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/surf_land_bucket_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/surf_land_bucket_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/surf_land_bucket_mod.F90	(revision 4446)
@@ -35,5 +35,5 @@
     USE indice_sol_mod
 #ifdef ISO
-    use infotrac_phy, ONLY: ntraciso,niso
+    use infotrac_phy, ONLY: ntiso,niso
     USE isotopes_mod, ONLY: iso_eau, iso_HDO, iso_O18, iso_O17, &
         ridicule_qsol
@@ -69,6 +69,6 @@
     REAL, DIMENSION(klon), INTENT(IN)       :: swnet, lwnet
 #ifdef ISO
-    REAL, DIMENSION(ntraciso,klon), INTENT(IN)       :: xtprecip_rain, xtprecip_snow
-    REAL, DIMENSION(ntraciso,klon), INTENT(IN)       :: xtspechum    
+    REAL, DIMENSION(ntiso,klon), INTENT(IN) :: xtprecip_rain, xtprecip_snow
+    REAL, DIMENSION(ntiso,klon), INTENT(IN) :: xtspechum    
 #endif
 
@@ -91,9 +91,9 @@
     REAL, DIMENSION(klon), INTENT(OUT)       :: dflux_s, dflux_l         
 #ifdef ISO
-    REAL, DIMENSION(ntraciso,klon), INTENT(OUT)       :: xtevap
-    REAL, DIMENSION(klon), INTENT(OUT)       :: h1
-    REAL, DIMENSION(niso,klon), INTENT(OUT)       :: xtrunoff_diag
-    REAL, DIMENSION(klon), INTENT(OUT)       :: runoff_diag
-    REAL, DIMENSION(niso,klon), INTENT(IN)        :: Rland_ice
+    REAL, DIMENSION(ntiso,klon), INTENT(OUT) :: xtevap
+    REAL, DIMENSION(klon),       INTENT(OUT) :: h1
+    REAL, DIMENSION(niso,klon),  INTENT(OUT) :: xtrunoff_diag
+    REAL, DIMENSION(klon),       INTENT(OUT) :: runoff_diag
+    REAL, DIMENSION(niso,klon),  INTENT(IN)  :: Rland_ice
 #endif
 
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/surf_land_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/surf_land_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/surf_land_mod.F90	(revision 4446)
@@ -30,7 +30,5 @@
     USE dimphy
     USE surface_data, ONLY    : ok_veget
-! >> PC
     USE carbon_cycle_mod 
-! << PC
 
     ! See comments in each module surf_land_orchidee_xxx for compatiblity with ORCHIDEE
@@ -51,5 +49,11 @@
     USE surf_land_orchidee_nounstruct_mod
 #else
+#if ORCHIDEE_NOLIC
+    ! Compilation with cpp key ORCHIDEE_NOLIC
+    USE surf_land_orchidee_nolic_mod
+#else
+    ! Default version#else
     USE surf_land_orchidee_mod
+#endif
 #endif
 #endif
@@ -61,5 +65,5 @@
     USE indice_sol_mod
 #ifdef ISO
-    use infotrac_phy, ONLY: ntraciso,niso
+    use infotrac_phy, ONLY: ntiso,niso
     use isotopes_mod, ONLY: nudge_qsol, iso_eau
 #ifdef ISOVERIF
@@ -67,8 +71,6 @@
 #endif
 #endif
-
-! >> PC
+    
     USE print_control_mod, ONLY: lunout
-! << PC
 
     INCLUDE "dimsoil.h"
@@ -104,6 +106,6 @@
     REAL, DIMENSION(klon), INTENT(IN)       :: q2m, t2m
 #ifdef ISO
-    REAL, DIMENSION(ntraciso,klon), INTENT(IN)       :: xtprecip_rain, xtprecip_snow
-    REAL, DIMENSION(ntraciso,klon), INTENT(IN)       :: xtspechum
+    REAL, DIMENSION(ntiso,klon), INTENT(IN)       :: xtprecip_rain, xtprecip_snow
+    REAL, DIMENSION(ntiso,klon), INTENT(IN)       :: xtspechum
 #endif 
 
@@ -135,5 +137,5 @@
     REAL, DIMENSION(klon,nvm_lmdz), INTENT(OUT) :: height
 #ifdef ISO
-    REAL, DIMENSION(ntraciso,klon), INTENT(OUT)      :: xtevap
+    REAL, DIMENSION(ntiso,klon), INTENT(OUT)      :: xtevap
     REAL, DIMENSION(klon), INTENT(OUT)      :: h1
     REAL, DIMENSION(niso,klon), INTENT(OUT)      :: xtrunoff_diag
@@ -181,5 +183,5 @@
 !       write(*,*) 'surf_land 169: ok_veget=',ok_veget
         do i=1,knon
-         do ixt=1,ntraciso
+         do ixt=1,ntiso
            call iso_verif_noNaN(xtprecip_snow(ixt,i),'surf_land 146')
          enddo
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/surf_landice_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/surf_landice_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/surf_landice_mod.F90	(revision 4446)
@@ -37,5 +37,5 @@
 #ifdef ISO   
     USE fonte_neige_mod,  ONLY : xtrun_off_lic
-    USE infotrac_phy, ONLY : ntraciso,niso
+    USE infotrac_phy, ONLY : ntiso,niso
     USE isotopes_routines_mod, ONLY: calcul_iso_surf_lic_vectall
 #ifdef ISOVERIF
@@ -82,6 +82,6 @@
     REAL, DIMENSION(klon,nbsrf), INTENT(IN)       :: pctsrf
 #ifdef ISO
-    REAL, DIMENSION(ntraciso,klon), INTENT(IN)        :: xtprecip_rain, xtprecip_snow 
-    REAL, DIMENSION(ntraciso,klon), INTENT(IN)        :: xtspechum 
+    REAL, DIMENSION(ntiso,klon), INTENT(IN)       :: xtprecip_rain, xtprecip_snow 
+    REAL, DIMENSION(ntiso,klon), INTENT(IN)       :: xtspechum 
 #endif
 
@@ -129,5 +129,5 @@
     REAL, DIMENSION(klon), INTENT(OUT)           :: runoff  !Land ice runoff
 #ifdef ISO
-    REAL, DIMENSION(ntraciso,klon), INTENT(OUT)        :: xtevap     
+    REAL, DIMENSION(ntiso,klon), INTENT(OUT)     :: xtevap     
 !    real, DIMENSION(niso,klon) :: xtrun_off_lic_0_diag ! est une variable globale de
 !    fonte_neige
@@ -144,4 +144,5 @@
     INTEGER                  :: i,j,nt
     REAL, DIMENSION(klon)    :: fqfonte,ffonte
+    REAL, DIMENSION(klon)    :: run_off_lic_frac
 #ifdef ISO       
       real, parameter :: t_coup = 273.15
@@ -484,8 +485,15 @@
 ! Send run-off on land-ice to coupler if coupled ocean.
 ! run_off_lic has been calculated in fonte_neige or surf_inlandsis
-!
-!****************************************************************************************
-    IF (type_ocean=='couple') THEN
-       CALL cpl_send_landice_fields(itime, knon, knindex, run_off_lic)
+! If landice_opt>=2, corresponding call is done from surf_land_orchidee
+!****************************************************************************************
+    IF (type_ocean=='couple' .AND. landice_opt .LT. 2) THEN
+       ! Compress fraction where run_off_lic is active (here all pctsrf(is_lic))
+       run_off_lic_frac(:)=0.0
+       DO j = 1, knon
+          i = knindex(j)
+          run_off_lic_frac(j) = pctsrf(i,is_lic)
+       ENDDO
+       
+       CALL cpl_send_landice_fields(itime, knon, knindex, run_off_lic, run_off_lic_frac)
     ENDIF
 
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/surf_ocean_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/surf_ocean_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/surf_ocean_mod.F90	(revision 4446)
@@ -20,6 +20,6 @@
        z0m, z0h, SFRWL, alb_dir_new, alb_dif_new, evap, fluxsens, fluxlat, & 
        tsurf_new, dflux_s, dflux_l, lmt_bils, &
-       flux_u1, flux_v1, delta_sst, delta_sal, ds_ns, dt_ns, dter, dser, tkt, tks, &
-       taur, sss &
+       flux_u1, flux_v1, delta_sst, delta_sal, ds_ns, dt_ns, dter, dser, &
+       dt_ds, tkt, tks, taur, sss &
 #ifdef ISO
         &       ,xtprecip_rain, xtprecip_snow,xtspechum,Roce, &
@@ -37,5 +37,5 @@
     USE indice_sol_mod, ONLY : nbsrf, is_oce
 #ifdef ISO
-  USE infotrac_phy, ONLY : ntraciso,niso
+  USE infotrac_phy, ONLY : ntraciso=>ntiso,niso
 #ifdef ISOVERIF
     USE isotopes_mod, ONLY: iso_eau,ridicule
@@ -114,4 +114,16 @@
     ! minus foundation temperature. (Can be negative.) In K.
 
+    REAL, intent(inout):: dter(:) ! (knon)
+    ! Temperature variation in the diffusive microlayer, that is
+    ! ocean-air interface temperature minus subskin temperature. In
+    ! K.
+
+    REAL, intent(inout):: dser(:) ! (knon)
+    ! Salinity variation in the diffusive microlayer, that is
+    ! ocean-air interface salinity minus subskin salinity. In ppt.
+
+    real, intent(inout):: dt_ds(:) ! (knon)
+    ! (tks / tkt) * dTer, in K
+
     ! Output variables
     !**************************************************************************
@@ -129,13 +141,4 @@
     REAL, DIMENSION(klon), INTENT(OUT)       :: flux_u1, flux_v1
 
-    REAL, intent(out):: dter(:) ! (knon)
-    ! Temperature variation in the diffusive microlayer, that is
-    ! ocean-air interface temperature minus subskin temperature. In
-    ! K.
-
-    REAL, intent(out):: dser(:) ! (knon)
-    ! Salinity variation in the diffusive microlayer, that is
-    ! ocean-air interface salinity minus subskin salinity. In ppt.
-
     REAL, intent(out):: tkt(:) ! (knon)
     ! épaisseur (m) de la couche de diffusion thermique (microlayer)
@@ -152,4 +155,5 @@
     ! defined for subscripts 1:knon, but we have to declare it with
     ! size klon because of the coupling machinery.)
+
 #ifdef ISO
     REAL, DIMENSION(ntraciso,klon), INTENT(out)        :: xtevap ! isotopes in surface evaporation flux 
@@ -172,5 +176,5 @@
     real s_int(knon) ! ocean-air interface salinity, in ppt
 
-    !******************************************************************************
+    !**************************************************************************
 
 #ifdef ISO
@@ -213,7 +217,5 @@
     ENDIF
 
-
     rhoa = PS(:KNON) / (Rd * temp_air(:knon) * (1. + retv * spechum(:knon)))
-
     !******************************************************************************
     ! Switch according to type of ocean (couple, slab or forced)
@@ -232,5 +234,5 @@
             qsurf, evap, fluxsens, fluxlat, flux_u1, flux_v1, &
             tsurf_new, dflux_s, dflux_l, sens_prec_liq, sss, delta_sal, rhoa, &
-            delta_sst)
+            delta_sst, dTer, dSer, dt_ds)
 
     CASE('slab')
@@ -376,7 +378,11 @@
        delta_sst = t_int - tsurf_new(:knon)
        delta_sal = s_int - sss(:knon)
-       if (activate_ocean_skin >= 2) tsurf_new(:knon) = t_int
+
+       if (activate_ocean_skin == 2) then
+          tsurf_new(:knon) = t_int
+          if (type_ocean == 'couple') dt_ds = (tks / tkt) * dter
+       end if
     end if
-
+    
   END SUBROUTINE surf_ocean
   !****************************************************************************
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/surf_seaice_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/surf_seaice_mod.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/surf_seaice_mod.F90	(revision 4446)
@@ -35,5 +35,5 @@
   USE indice_sol_mod
 #ifdef ISO
-  USE infotrac_phy, ONLY : ntraciso,niso
+  USE infotrac_phy, ONLY : ntiso,niso
 #endif
 
@@ -71,5 +71,5 @@
     REAL, DIMENSION(klon,nbsrf), INTENT(IN)  :: pctsrf
 #ifdef ISO
-    REAL, DIMENSION(ntraciso,klon), INTENT(IN)        :: xtprecip_rain, xtprecip_snow 
+    REAL, DIMENSION(ntiso,klon), INTENT(IN)        :: xtprecip_rain, xtprecip_snow 
     REAL, DIMENSION(klon), INTENT(IN)        :: xtspechum
     REAL, DIMENSION(niso,klon), INTENT(IN)        :: Roce
@@ -101,5 +101,5 @@
     REAL, DIMENSION(klon), INTENT(OUT)       :: flux_u1, flux_v1
 #ifdef ISO
-    REAL, DIMENSION(ntraciso,klon), INTENT(OUT)        :: xtevap  
+    REAL, DIMENSION(ntiso,klon), INTENT(OUT)        :: xtevap  
 #endif
 
Index: LMDZ6/branches/Portage_acc/libf/phylmdiso/wake.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmdiso/wake.F90	(revision 4445)
+++ LMDZ6/branches/Portage_acc/libf/phylmdiso/wake.F90	(revision 4446)
@@ -34,5 +34,5 @@
   USE print_control_mod, ONLY: prt_level
 #ifdef ISO
-  USE infotrac_phy, ONLY : ntraciso
+  USE infotrac_phy, ONLY : ntraciso=>ntiso
 #ifdef ISOVERIF
   USE isotopes_verif_mod
@@ -2550,5 +2550,5 @@
     d_deltaqw, sigmaw, d_sigmaw, alpha)
   ! ------------------------------------------------------
-  ! Dtermination du coefficient alpha tel que les tendances
+  ! D\'etermination du coefficient alpha tel que les tendances
   ! corriges alpha*d_G, pour toutes les grandeurs G, correspondent
   ! a une humidite positive dans la zone (x) et dans la zone (w).
