Index: /LMDZ6/trunk/libf/dyn3d/advtrac.F90
===================================================================
--- /LMDZ6/trunk/libf/dyn3d/advtrac.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/dyn3d/advtrac.F90	(revision 4056)
@@ -1,407 +1,358 @@
 ! $Id$
 
-SUBROUTINE advtrac(pbaru,pbarv , p,  masse,q,iapptrac,teta, flxw, pk)
-  !     Auteur :  F. Hourdin
-  !
-  !     Modif. P. Le Van     (20/12/97)
-  !            F. Codron     (10/99)
-  !            D. Le Croller (07/2001)
-  !            M.A Filiberti (04/2002)
-  !
-  USE infotrac, ONLY: nqtot, tracers, nqperes,ok_iso_verif
-  USE control_mod, ONLY: iapp_tracvl, day_step
-  USE comconst_mod, ONLY: dtvr
-
-  IMPLICIT NONE
-  !
-  include "dimensions.h"
-  include "paramet.h"
-  include "comdissip.h"
-  include "comgeom2.h"
-  include "description.h"
-  include "iniprint.h"
-
-  !-------------------------------------------------------------------
-  !     Arguments
-  !-------------------------------------------------------------------
-  INTEGER,INTENT(OUT) :: iapptrac
-  REAL,INTENT(IN) :: pbaru(ip1jmp1,llm)
-  REAL,INTENT(IN) :: pbarv(ip1jm,llm)
-  REAL,INTENT(INOUT) :: q(ip1jmp1,llm,nqtot)
-  REAL,INTENT(IN) :: masse(ip1jmp1,llm)
-  REAL,INTENT(IN) :: p( ip1jmp1,llmp1 )
-  REAL,INTENT(IN) :: teta(ip1jmp1,llm)
-  REAL,INTENT(IN) :: pk(ip1jmp1,llm)
-  REAL,INTENT(OUT) :: flxw(ip1jmp1,llm)
-  !-------------------------------------------------------------------
-  !     Ajout PPM
-  !--------------------------------------------------------
-  REAL massebx(ip1jmp1,llm),masseby(ip1jm,llm)
-  !-------------------------------------------------------------
-  !     Variables locales
-  !-------------------------------------------------------------
-
-  REAL pbaruc(ip1jmp1,llm),pbarvc(ip1jm,llm)
-  REAL massem(ip1jmp1,llm),zdp(ip1jmp1)
-  REAL pbarug(ip1jmp1,llm),pbarvg(ip1jm,llm),wg(ip1jmp1,llm) 
-  REAL (kind=kind(1.d0)) :: t_initial, t_final, tps_cpu
-  INTEGER iadvtr
-  INTEGER ij,l,iq,iiq
-  REAL zdpmin, zdpmax
-  EXTERNAL  minmax
-  SAVE iadvtr, massem, pbaruc, pbarvc
-  DATA iadvtr/0/
-  !----------------------------------------------------------
-  !     Rajouts pour PPM
-  !----------------------------------------------------------
-  INTEGER indice,n
-  REAL dtbon ! Pas de temps adaptatif pour que CFL<1
-  REAL CFLmaxz,aaa,bbb ! CFL maximum
-  REAL psppm(iim,jjp1) ! pression  au sol
-  REAL unatppm(iim,jjp1,llm),vnatppm(iim,jjp1,llm)
-  REAL qppm(iim*jjp1,llm,nqtot)
-  REAL fluxwppm(iim,jjp1,llm)
-  REAL apppm(llmp1), bpppm(llmp1)
-  LOGICAL dum,fill
-  DATA fill/.true./
-  DATA dum/.true./
-
-  integer,save :: countcfl=0
-  real cflx(ip1jmp1,llm)
-  real cfly(ip1jm,llm)
-  real cflz(ip1jmp1,llm)
-  real, save :: cflxmax(llm),cflymax(llm),cflzmax(llm)
-  INTEGER :: iadv
-
-  IF(iadvtr.EQ.0) THEN
-     pbaruc(:,:)=0
-     pbarvc(:,:)=0
-  ENDIF
-
-  !   accumulation des flux de masse horizontaux
-  DO l=1,llm
-     DO ij = 1,ip1jmp1
-        pbaruc(ij,l) = pbaruc(ij,l) + pbaru(ij,l)
-     ENDDO
-     DO ij = 1,ip1jm
-        pbarvc(ij,l) = pbarvc(ij,l) + pbarv(ij,l)
-     ENDDO
-  ENDDO
-
-  !   selection de la masse instantannee des mailles avant le transport.
-  IF(iadvtr.EQ.0) THEN
-
+#define DEBUG_IO
+#undef DEBUG_IO
+SUBROUTINE advtrac(pbaru, pbarv, p, masse,q,iapptrac,teta, flxw, pk)
+   !     Auteur :  F. Hourdin
+   !
+   !     Modif. P. Le Van     (20/12/97)
+   !            F. Codron     (10/99)
+   !            D. Le Croller (07/2001)
+   !            M.A Filiberti (04/2002)
+   !
+   USE infotrac,     ONLY: nqtot, tracers,ok_iso_verif
+   USE control_mod,  ONLY: iapp_tracvl, day_step
+   USE comconst_mod, ONLY: dtvr
+
+   IMPLICIT NONE
+   !
+   include "dimensions.h"
+   include "paramet.h"
+   include "comdissip.h"
+   include "comgeom2.h"
+   include "description.h"
+   include "iniprint.h"
+
+   !---------------------------------------------------------------------------
+   !     Arguments
+   !---------------------------------------------------------------------------
+   INTEGER, INTENT(OUT) :: iapptrac
+   REAL, INTENT(IN) :: pbaru(ip1jmp1,llm)
+   REAL, INTENT(IN) :: pbarv(ip1jm,  llm)
+   REAL, INTENT(INOUT) ::  q(ip1jmp1,llm,nqtot)
+   REAL, INTENT(IN) :: masse(ip1jmp1,llm)
+   REAL, INTENT(IN) ::     p(ip1jmp1,llmp1 )
+   REAL, INTENT(IN) ::  teta(ip1jmp1,llm)
+   REAL, INTENT(IN) ::    pk(ip1jmp1,llm)
+   REAL, INTENT(OUT) :: flxw(ip1jmp1,llm)
+   !---------------------------------------------------------------------------
+   !     Ajout PPM
+   !---------------------------------------------------------------------------
+   REAL :: massebx(ip1jmp1,llm), masseby(ip1jm,llm)
+   !---------------------------------------------------------------------------
+   !     Variables locales
+   !---------------------------------------------------------------------------
+   INTEGER :: ij, l, iq, iiq, iadv
+   REAL(KIND=KIND(1.d0)) :: t_initial, t_final, tps_cpu
+   REAL :: zdp(ip1jmp1), zdpmin, zdpmax
+   INTEGER, SAVE :: iadvtr=0
+   REAL, DIMENSION(ip1jmp1,llm) :: pbaruc, pbarug, massem, wg
+   REAL, DIMENSION(ip1jm,  llm) :: pbarvc, pbarvg
+   EXTERNAL  minmax
+   SAVE massem, pbaruc, pbarvc
+   !---------------------------------------------------------------------------
+   !     Rajouts pour PPM
+   !---------------------------------------------------------------------------
+   INTEGER indice, n
+   REAL :: dtbon                       ! Pas de temps adaptatif pour que CFL<1
+   REAL :: CFLmaxz, aaa, bbb           ! CFL maximum
+   REAL, DIMENSION(iim,jjp1,llm) :: unatppm, vnatppm, fluxwppm
+   REAL ::    qppm(iim*jjp1,llm,nqtot)
+   REAL ::   psppm(iim,jjp1)           ! pression  au sol
+   REAL, DIMENSION(llmp1) :: apppm, bpppm
+   LOGICAL, SAVE :: dum=.TRUE., fill=.TRUE.
+
+   INTEGER, SAVE :: countcfl=0
+   REAL, DIMENSION(ip1jmp1,llm) :: cflx, cflz
+   REAL, DIMENSION(ip1jm  ,llm) :: cfly
+   REAL, DIMENSION(llm), SAVE :: cflxmax, cflymax, cflzmax
+
+   IF(iadvtr == 0) THEN
+      pbaruc(:,:)=0
+      pbarvc(:,:)=0
+   END IF
+
+   !--- Accumulation des flux de masse horizontaux
+   DO l=1,llm
+      DO ij = 1,ip1jmp1
+         pbaruc(ij,l) = pbaruc(ij,l) + pbaru(ij,l)
+      END DO
+      DO ij = 1,ip1jm
+         pbarvc(ij,l) = pbarvc(ij,l) + pbarv(ij,l)
+      END DO
+   END DO
+
+   !--- Selection de la masse instantannee des mailles avant le transport.
+   IF(iadvtr == 0) THEN
      CALL SCOPY(ip1jmp1*llm,masse,1,massem,1)
-     !cc         CALL filtreg ( massem ,jjp1, llm,-2, 2, .TRUE., 1 )
-     !
-  ENDIF
-
-  iadvtr   = iadvtr+1
-  iapptrac = iadvtr
-
-
-  !   Test pour savoir si on advecte a ce pas de temps
-  IF ( iadvtr.EQ.iapp_tracvl ) THEN
-
-     !c   ..  Modif P.Le Van  ( 20/12/97 )  ....
-     !c
-
-     !   traitement des flux de masse avant advection.
-     !     1. calcul de w
-     !     2. groupement des mailles pres du pole.
-
-     CALL groupe( massem, pbaruc,pbarvc, pbarug,pbarvg,wg )
-
-     ! ... Flux de masse diaganostiques traceurs
-     flxw = wg / REAL(iapp_tracvl)
-
-     !  test sur l'eventuelle creation de valeurs negatives de la masse
-     DO l=1,llm-1
-        DO ij = iip2+1,ip1jm
-           zdp(ij) =    pbarug(ij-1,l)   - pbarug(ij,l) &
-                - pbarvg(ij-iip1,l) + pbarvg(ij,l) &
-                +       wg(ij,l+1)  - wg(ij,l)
-        ENDDO
-        CALL SCOPY( jjm -1 ,zdp(iip1+iip1),iip1,zdp(iip2),iip1 )
-        DO ij = iip2,ip1jm
-           zdp(ij)= zdp(ij)*dtvr/ massem(ij,l) 
-        ENDDO
-
-
-        CALL minmax ( ip1jm-iip1, zdp(iip2), zdpmin,zdpmax )
-
-        IF(MAX(ABS(zdpmin),ABS(zdpmax)).GT.0.5) THEN
-           PRINT*,'WARNING DP/P l=',l,'  MIN:',zdpmin, &
-                '   MAX:', zdpmax
-        ENDIF
-
-     ENDDO
-
-
-     !-------------------------------------------------------------------
-     ! Calcul des criteres CFL en X, Y et Z
-     !-------------------------------------------------------------------
-
-     if (countcfl == 0. ) then
-        cflxmax(:)=0.
-        cflymax(:)=0.
-        cflzmax(:)=0.
-     endif
-
-     countcfl=countcfl+iapp_tracvl
-     cflx(:,:)=0.
-     cfly(:,:)=0.
-     cflz(:,:)=0.
-     do l=1,llm
-        do ij=iip2,ip1jm-1
-           if (pbarug(ij,l)>=0.) then
-              cflx(ij,l)=pbarug(ij,l)*dtvr/masse(ij,l)
-           else
-              cflx(ij,l)=-pbarug(ij,l)*dtvr/masse(ij+1,l)
-           endif
-        enddo
-     enddo
-     do l=1,llm
-        do ij=iip2,ip1jm-1,iip1
-           cflx(ij+iip1,l)=cflx(ij,l)
-        enddo
-     enddo
-
-     do l=1,llm
-        do ij=1,ip1jm
-           if (pbarvg(ij,l)>=0.) then
-              cfly(ij,l)=pbarvg(ij,l)*dtvr/masse(ij,l)
-           else
-              cfly(ij,l)=-pbarvg(ij,l)*dtvr/masse(ij+iip1,l)
-           endif
-        enddo
-     enddo
-
-     do l=2,llm
-        do ij=1,ip1jm
-           if (wg(ij,l)>=0.) then
-              cflz(ij,l)=wg(ij,l)*dtvr/masse(ij,l)
-           else
-              cflz(ij,l)=-wg(ij,l)*dtvr/masse(ij,l-1)
-           endif
-        enddo
-     enddo
-
-     do l=1,llm
-        cflxmax(l)=max(cflxmax(l),maxval(cflx(:,l)))
-        cflymax(l)=max(cflymax(l),maxval(cfly(:,l)))
-        cflzmax(l)=max(cflzmax(l),maxval(cflz(:,l)))
-     enddo
-
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-     ! Par defaut, on sort le diagnostic des CFL tous les jours.
-     ! Si on veut le sortir a chaque pas d'advection en cas de plantage 
-     !     if (countcfl==iapp_tracvl) then
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-     if (countcfl==day_step) then
-        do l=1,llm
-           write(lunout,*) 'L, CFL[xyz]max:', l, cflxmax(l), cflymax(l), &
-                cflzmax(l)
-        enddo
-        countcfl=0
-     endif
-
-     !-------------------------------------------------------------------
-     !   Advection proprement dite (Modification Le Croller (07/2001)
-     !-------------------------------------------------------------------
-
-     !----------------------------------------------------
-     !        Calcul des moyennes basées sur la masse
-     !----------------------------------------------------
-     call massbar(massem,massebx,masseby)          
-
-     !-----------------------------------------------------------
-     !     Appel des sous programmes d'advection
-     !-----------------------------------------------------------
-
-     if (ok_iso_verif) then
-           write(*,*) 'advtrac 227'
-           call check_isotopes_seq(q,ip1jmp1,'advtrac 162')
-     endif !if (ok_iso_verif) then
-
-     do iq=1,nqperes
-        !        call clock(t_initial)
-       iadv = tracers(iq)%iadv
-       SELECT CASE(iadv)
+   ! CALL filtreg ( massem ,jjp1, llm,-2, 2, .TRUE., 1 )
+   END IF
+
+   iadvtr   = iadvtr+1
+   iapptrac = iadvtr
+
+   !--- Test pour savoir si on advecte a ce pas de temps
+   IF(iadvtr /= iapp_tracvl) RETURN
+
+   !   ..  Modif P.Le Van  ( 20/12/97 )  ....
+   !
+   !   traitement des flux de masse avant advection.
+   !       1. calcul de w
+   !       2. groupement des mailles pres du pole.
+
+   CALL groupe(massem, pbaruc, pbarvc, pbarug, pbarvg, wg)
+
+   !--- Flux de masse diaganostiques traceurs
+   flxw = wg / REAL(iapp_tracvl)
+
+   !--- Test sur l'eventuelle creation de valeurs negatives de la masse
+   DO l=1,llm-1
+      DO ij = iip2+1,ip1jm
+         zdp(ij) = pbarug(ij-1,l)    - pbarug(ij,l) &
+                 - pbarvg(ij-iip1,l) + pbarvg(ij,l) &
+                 +     wg(ij,l+1)    -     wg(ij,l)
+      END DO
+! ym  ---> pourquoi jjm-1 et non jjm ? a cause du pole ?
+      CALL SCOPY( jjm -1 ,zdp(iip1+iip1),iip1,zdp(iip2),iip1 )
+      DO ij = iip2,ip1jm
+         zdp(ij)= zdp(ij)*dtvr/ massem(ij,l)
+      END DO
+
+      CALL minmax ( ip1jm-iip1, zdp(iip2), zdpmin,zdpmax )
+
+      IF(MAX(ABS(zdpmin),ABS(zdpmax)) > 0.5) &
+         WRITE(*,*)'WARNING DP/P l=',l,'  MIN:',zdpmin,' MAX:', zdpmax
+
+   END DO
+
+   !-------------------------------------------------------------------------
+   ! Calcul des criteres CFL en X, Y et Z
+   !-------------------------------------------------------------------------
+   IF(countcfl == 0. ) then
+      cflxmax(:)=0.
+      cflymax(:)=0.
+      cflzmax(:)=0.
+   END IF
+
+   countcfl=countcfl+iapp_tracvl
+   cflx(:,:)=0.
+   cfly(:,:)=0.
+   cflz(:,:)=0.
+   DO l=1,llm
+      DO ij=iip2,ip1jm-1
+         IF(pbarug(ij,l)>=0.) then
+            cflx(ij,l)=pbarug(ij,l)*dtvr/masse(ij,l)
+         ELSE
+            cflx(ij,l)=-pbarug(ij,l)*dtvr/masse(ij+1,l)
+         END IF
+      END DO
+   END DO
+
+   DO l=1,llm
+      DO ij=iip2,ip1jm-1,iip1
+         cflx(ij+iip1,l)=cflx(ij,l)
+      END DO
+   END DO
+
+   DO l=1,llm
+      DO ij=1,ip1jm
+         IF(pbarvg(ij,l)>=0.) then
+            cfly(ij,l)=pbarvg(ij,l)*dtvr/masse(ij,l)
+         ELSE
+            cfly(ij,l)=-pbarvg(ij,l)*dtvr/masse(ij+iip1,l)
+         END IF
+      END DO
+   END DO
+
+   DO l=2,llm
+      DO ij=1,ip1jm
+         IF(wg(ij,l) >= 0.) THEN
+            cflz(ij,l)=wg(ij,l)*dtvr/masse(ij,l)
+         ELSE
+            cflz(ij,l)=-wg(ij,l)*dtvr/masse(ij,l-1)
+         END IF
+      END DO
+   END DO
+
+   DO l=1,llm
+      cflxmax(l)=max(cflxmax(l),maxval(cflx(:,l)))
+      cflymax(l)=max(cflymax(l),maxval(cfly(:,l)))
+      cflzmax(l)=max(cflzmax(l),maxval(cflz(:,l)))
+   END DO
+
+   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+   ! Par defaut, on sort le diagnostic des CFL tous les jours.
+   ! Si on veut le sortir a chaque pas d'advection en cas de plantage 
+   !       IF(countcfl==iapp_tracvl) then
+   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+   IF(countcfl==day_step) then
+      DO l=1,llm
+         WRITE(lunout,*) 'L, CFL[xyz]max:', l, cflxmax(l), cflymax(l), cflzmax(l)
+      END DO
+      countcfl=0
+   END IF
+
+   !---------------------------------------------------------------------------
+   !   Advection proprement dite (Modification Le Croller (07/2001)
+   !---------------------------------------------------------------------------
+
+   !---------------------------------------------------------------------------
+   !   Calcul des moyennes basees sur la masse
+   !---------------------------------------------------------------------------
+   CALL massbar(massem,massebx,masseby)
+
+#ifdef DEBUG_IO    
+   CALL WriteField_u('massem',massem)
+   CALL WriteField_u('wg',wg)
+   CALL WriteField_u('pbarug',pbarug)
+   CALL WriteField_v('pbarvg',pbarvg)
+   CALL WriteField_u('p_tmp',p)
+   CALL WriteField_u('pk_tmp',pk)
+   CALL WriteField_u('teta_tmp',teta)
+   DO iq=1,nqtot
+      CALL WriteField_u('q_adv'//trim(int2str(iq)),q(:,:,iq))
+   END DO
+#endif
+
+   IF(ok_iso_verif) THEN
+      WRITE(*,*) 'advtrac 227'
+      CALL check_isotopes_seq(q,ip1jmp1,'advtrac 162')
+   END IF
+
+   !-------------------------------------------------------------------------
+   !       Appel des sous programmes d'advection
+   !-------------------------------------------------------------------------
+   DO iq = 1, nqtot
+!     CALL clock(t_initial)
+      IF(tracers(iq)%parent /= 'air') CYCLE
+      iadv = tracers(iq)%iadv
+      !-----------------------------------------------------------------------
+      SELECT CASE(iadv)
+      !-----------------------------------------------------------------------
          CASE(0); CYCLE
-         CASE(10)
-        !   ----------------------------------------------------------------
-        !   Schema de Van Leer I MUSCL
-        !   ----------------------------------------------------------------
-           ! CRisi: on fait passer tout q pour avoir acces aux fils
-           
-           !write(*,*) 'advtrac 239: iq,q(1721,19,:)=',iq,q(1721,19,:)     
-           call vlsplt(q,2.,massem,wg,pbarug,pbarvg,dtvr,iq)
-           
-         CASE(14)
-           !   ----------------------------------------------------------------
-           !   Schema "pseudo amont" + test sur humidite specifique
-           !    pour la vapeur d'eau. F. Codron
-           !   ----------------------------------------------------------------
-           !
-           !write(*,*) 'advtrac 248: iq,q(1721,19,:)=',iq,q(1721,19,:)
-           CALL vlspltqs( q, 2., massem, wg , &
-                pbarug,pbarvg,dtvr,p,pk,teta,iq)
-           
-         CASE(12)
-           !   ----------------------------------------------------------------
-           !   Schema de Frederic Hourdin
-           !   ----------------------------------------------------------------
-           !            Pas de temps adaptatif
-           call adaptdt(iadv,dtbon,n,pbarug,massem)
-           if (n.GT.1) then
-              write(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=', &
-                   dtvr,'n=',n
-           endif
-           do indice=1,n
-              call advn(q(1,1,iq),massem,wg,pbarug,pbarvg,dtbon,1)
-           end do
-         CASE(13)
-           !            Pas de temps adaptatif
-           call adaptdt(iadv,dtbon,n,pbarug,massem)
-           if (n.GT.1) then
-              write(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=', &
-                   dtvr,'n=',n
-           endif
-           do indice=1,n
-              call advn(q(1,1,iq),massem,wg,pbarug,pbarvg,dtbon,2)
-           end do
-         CASE(20)
-           !   ----------------------------------------------------------------
-           !   Schema de pente SLOPES
-           !   ----------------------------------------------------------------
-           call pentes_ini (q(1,1,iq),wg,massem,pbarug,pbarvg,0)
-
-         CASE(30)
-           !   ----------------------------------------------------------------
-           !   Schema de Prather
-           !   ----------------------------------------------------------------
-           !            Pas de temps adaptatif
-           call adaptdt(iadv,dtbon,n,pbarug,massem)
-           if (n.GT.1) then
-              write(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=', &
-                   dtvr,'n=',n
-           endif
-           call  prather(q(1,1,iq),wg,massem,pbarug,pbarvg, &
-                n,dtbon)
-
-         CASE(11,16,17,18)
-           !   ----------------------------------------------------------------
-           !   Schemas PPM Lin et Rood
-           !   ----------------------------------------------------------------
-
-           !        Test sur le flux horizontal
-           !        Pas de temps adaptatif
-           call adaptdt(iadv,dtbon,n,pbarug,massem)
-           if (n.GT.1) then
-              write(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=', &
-                   dtvr,'n=',n
-           endif
-           !        Test sur le flux vertical
-           CFLmaxz=0.
-           do l=2,llm
-              do ij=iip2,ip1jm
-                 aaa=wg(ij,l)*dtvr/massem(ij,l)
-                 CFLmaxz=max(CFLmaxz,aaa)
-                 bbb=-wg(ij,l)*dtvr/massem(ij,l-1)
-                 CFLmaxz=max(CFLmaxz,bbb)
-              enddo
-           enddo
-           if (CFLmaxz.GE.1) then
-              write(*,*) 'WARNING vertical','CFLmaxz=', CFLmaxz
-           endif
-
-           !-----------------------------------------------------------
-           !        Ss-prg interface LMDZ.4->PPM3d (ss-prg de Lin)
-           !-----------------------------------------------------------
-
-           call interpre(q(1,1,iq),qppm(1,1,iq),wg,fluxwppm,massem, &
-                apppm,bpppm,massebx,masseby,pbarug,pbarvg, &
-                unatppm,vnatppm,psppm)
-
-           do indice=1,n
-              !----------------------------------------------------------------
-              !                         VL (version PPM) horiz. et PPM vert.
-              !----------------------------------------------------------------
-             SELECT CASE(iadv)
-               CASE(11)
-                 call ppm3d(1,qppm(1,1,iq), &
-                      psppm,psppm, &
-                      unatppm,vnatppm,fluxwppm,dtbon,2,2,2,1, &
-                      iim,jjp1,2,llm,apppm,bpppm,0.01,6400000, &
-                      fill,dum,220.)
-
-               CASE(16)
-                 !-------------------------------------------------------------
-                 !                           Monotonic PPM
-                 !-------------------------------------------------------------
-                 call ppm3d(1,qppm(1,1,iq), &
-                      psppm,psppm, &
-                      unatppm,vnatppm,fluxwppm,dtbon,3,3,3,1, &
-                      iim,jjp1,2,llm,apppm,bpppm,0.01,6400000, &
-                      fill,dum,220.)
-                 !-------------------------------------------------------------
-
-               CASE(17)
-                 !-------------------------------------------------------------
-                 !                           Semi Monotonic PPM
-                 !-------------------------------------------------------------
-                 call ppm3d(1,qppm(1,1,iq), &
-                      psppm,psppm, &
-                      unatppm,vnatppm,fluxwppm,dtbon,4,4,4,1, &
-                      iim,jjp1,2,llm,apppm,bpppm,0.01,6400000, &
-                      fill,dum,220.)
-                 !-------------------------------------------------------------
-
-               CASE(18)
-                 !-------------------------------------------------------------
-                 !                         Positive Definite PPM
-                 !-------------------------------------------------------------
-                 call ppm3d(1,qppm(1,1,iq), &
-                      psppm,psppm, &
-                      unatppm,vnatppm,fluxwppm,dtbon,5,5,5,1, &
-                      iim,jjp1,2,llm,apppm,bpppm,0.01,6400000, &
-                      fill,dum,220.)
-                 !-------------------------------------------------------------
-             END SELECT
-           enddo
-           !-----------------------------------------------------------------
-           !               Ss-prg interface PPM3d-LMDZ.4
-           !-----------------------------------------------------------------
-           call interpost(q(1,1,iq),qppm(1,1,iq))
-         END SELECT
-        !----------------------------------------------------------------------
-
-        !-----------------------------------------------------------------
-        ! On impose une seule valeur du traceur au pôle Sud j=jjm+1=jjp1
-        ! et Nord j=1
-        !-----------------------------------------------------------------
-
-        !                  call traceurpole(q(1,1,iq),massem)
-
-        ! calcul du temps cpu pour un schema donne
-
-        !                  call clock(t_final)
-        !ym                  tps_cpu=t_final-t_initial
-        !ym                  cpuadv(iq)=cpuadv(iq)+tps_cpu
-
-     end DO
-
-     if (ok_iso_verif) then
-           write(*,*) 'advtrac 402'
-           call check_isotopes_seq(q,ip1jmp1,'advtrac 397')
-     endif !if (ok_iso_verif) then
-
-     !------------------------------------------------------------------
-     !   on reinitialise a zero les flux de masse cumules
-     !---------------------------------------------------
-     iadvtr=0
-
-  ENDIF ! if iadvtr.EQ.iapp_tracvl
+         !--------------------------------------------------------------------
+         CASE(10)  !--- Schema de Van Leer I MUSCL
+         !--------------------------------------------------------------------
+!           WRITE(*,*) 'advtrac 239: iq,q(1721,19,:)=',iq,q(1721,19,:)     
+            CALL vlsplt(q,2.,massem,wg,pbarug,pbarvg,dtvr,iq)
+
+         !--------------------------------------------------------------------
+         CASE(14)  !--- Schema "pseuDO amont" + test sur humidite specifique
+                   !--- pour la vapeur d'eau. F. Codron
+         !--------------------------------------------------------------------
+!           WRITE(*,*) 'advtrac 248: iq,q(1721,19,:)=',iq,q(1721,19,:)
+            CALL vlspltqs(q,2.,massem,wg,pbarug,pbarvg,dtvr,p,pk,teta,iq)
+
+         !--------------------------------------------------------------------
+         CASE(12)  !--- Schema de Frederic Hourdin
+         !--------------------------------------------------------------------
+            CALL adaptdt(iadv,dtbon,n,pbarug,massem)   ! pas de temps adaptatif
+            IF(n > 1) WRITE(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=',dtvr,'n=',n
+            DO indice=1,n
+              CALL advn(q(1,1,iq),massem,wg,pbarug,pbarvg,dtbon,1)
+            END DO
+
+         !--------------------------------------------------------------------
+         CASE(13)  !--- Pas de temps adaptatif
+         !--------------------------------------------------------------------
+            CALL adaptdt(iadv,dtbon,n,pbarug,massem)
+            IF(n > 1) WRITE(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=',dtvr,'n=',n
+            DO indice=1,n
+               CALL advn(q(1,1,iq),massem,wg,pbarug,pbarvg,dtbon,2)
+            END DO
+
+         !--------------------------------------------------------------------
+         CASE(20)  !--- Schema de pente SLOPES
+         !--------------------------------------------------------------------
+            CALL pentes_ini (q(1,1,iq),wg,massem,pbarug,pbarvg,0)
+
+         !--------------------------------------------------------------------
+         CASE(30)  !--- Schema de Prather
+         !--------------------------------------------------------------------
+            ! Pas de temps adaptatif
+            CALL adaptdt(iadv,dtbon,n,pbarug,massem)
+            IF(n > 1) WRITE(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=',dtvr,'n=',n
+            CALL prather(q(1,1,iq),wg,massem,pbarug,pbarvg,n,dtbon)
+
+         !--------------------------------------------------------------------
+         CASE(11,16,17,18)   !--- Schemas PPM Lin et Rood
+         !--------------------------------------------------------------------
+            ! Test sur le flux horizontal
+            CALL adaptdt(iadv,dtbon,n,pbarug,massem)   ! pas de temps adaptatif
+            IF(n > 1) WRITE(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=',dtvr,'n=',n
+            ! Test sur le flux vertical
+            CFLmaxz=0.
+            DO l=2,llm
+               DO ij=iip2,ip1jm
+                  aaa=wg(ij,l)*dtvr/massem(ij,l)
+                  CFLmaxz=max(CFLmaxz,aaa)
+                  bbb=-wg(ij,l)*dtvr/massem(ij,l-1)
+                  CFLmaxz=max(CFLmaxz,bbb)
+               END DO
+            END DO
+            IF(CFLmaxz.GE.1) WRITE(*,*) 'WARNING vertical','CFLmaxz=', CFLmaxz
+            !----------------------------------------------------------------
+            !     Ss-prg interface LMDZ.4->PPM3d (ss-prg de Lin)
+            !----------------------------------------------------------------
+            CALL interpre(q(1,1,iq),qppm(1,1,iq),wg,fluxwppm,massem, &
+                 apppm,bpppm,massebx,masseby,pbarug,pbarvg, &
+                 unatppm,vnatppm,psppm)
+
+            !----------------------------------------------------------------
+            DO indice=1,n     !--- VL (version PPM) horiz. et PPM vert.
+            !----------------------------------------------------------------
+               SELECT CASE(iadv)
+                  !----------------------------------------------------------
+                  CASE(11)
+                  !----------------------------------------------------------
+                     CALL ppm3d(1,qppm(1,1,iq),psppm,psppm,unatppm,vnatppm,fluxwppm,dtbon, &
+                                2,2,2,1,iim,jjp1,2,llm,apppm,bpppm,0.01,6400000,fill,dum,220.)
+                  !----------------------------------------------------------
+                  CASE(16) !--- Monotonic PPM
+                  !----------------------------------------------------------
+                     CALL ppm3d(1,qppm(1,1,iq),psppm,psppm,unatppm,vnatppm,fluxwppm,dtbon, &
+                                3,3,3,1,iim,jjp1,2,llm,apppm,bpppm,0.01,6400000,fill,dum,220.)
+                  !----------------------------------------------------------
+                  CASE(17) !--- Semi monotonic PPM
+                  !----------------------------------------------------------
+                     CALL ppm3d(1,qppm(1,1,iq),psppm,psppm,unatppm,vnatppm,fluxwppm,dtbon, &
+                                4,4,4,1,iim,jjp1,2,llm,apppm,bpppm,0.01,6400000, fill,dum,220.)
+                  !----------------------------------------------------------
+                  CASE(18) !--- Positive Definite PPM
+                  !----------------------------------------------------------
+                     CALL ppm3d(1,qppm(1,1,iq),psppm,psppm,unatppm,vnatppm,fluxwppm,dtbon, &
+                                5,5,5,1,iim,jjp1,2,llm,apppm,bpppm,0.01,6400000,fill,dum,220.)
+               END SELECT
+            !----------------------------------------------------------------
+            END DO
+            !----------------------------------------------------------------
+            !     Ss-prg interface PPM3d-LMDZ.4
+            !----------------------------------------------------------------
+            CALL interpost(q(1,1,iq),qppm(1,1,iq))
+      !----------------------------------------------------------------------
+      END SELECT
+      !----------------------------------------------------------------------
+
+      !----------------------------------------------------------------------
+      ! On impose une seule valeur du traceur au pole Sud j=jjm+1=jjp1 et Nord j=1
+      !----------------------------------------------------------------------
+      !  CALL traceurpole(q(1,1,iq),massem)
+
+      !--- Calcul du temps cpu pour un schema donne
+      !  CALL clock(t_final)
+      !ym  tps_cpu=t_final-t_initial
+      !ym  cpuadv(iq)=cpuadv(iq)+tps_cpu
+
+   END DO
+
+   IF(ok_iso_verif) then
+      WRITE(*,*) 'advtrac 402'
+      CALL check_isotopes_seq(q,ip1jmp1,'advtrac 397')
+   END IF
+
+   !-------------------------------------------------------------------------
+   !   on reinitialise a zero les flux de masse cumules
+   !-------------------------------------------------------------------------
+   iadvtr=0
 
 END SUBROUTINE advtrac
Index: /LMDZ6/trunk/libf/dyn3d/iniacademic.F90
===================================================================
--- /LMDZ6/trunk/libf/dyn3d/iniacademic.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/dyn3d/iniacademic.F90	(revision 4056)
@@ -5,7 +5,9 @@
 
   USE filtreg_mod, ONLY: inifilr
-  USE infotrac,    ONLY: nqtot,niso_possibles,ok_isotopes,ok_iso_verif,tnat,alpha_ideal, &
-        & iqiso,iso_indnum, tracers
+  USE infotrac,    ONLY: nqtot, niso_possibles, ok_isotopes, ok_iso_verif, tnat, alpha_ideal, &
+                         iqiso, tracers, iso_indnum
   USE control_mod, ONLY: day_step,planet_type
+  use exner_hyb_m, only: exner_hyb
+  use exner_milieu_m, only: exner_milieu
 #ifdef CPP_IOIPSL
   USE IOIPSL, ONLY: getin
@@ -15,6 +17,4 @@
 #endif
   USE Write_Field
-  use exner_hyb_m, only: exner_hyb
-  use exner_milieu_m, only: exner_milieu
   USE comconst_mod, ONLY: cpp, kappa, g, daysec, dtvr, pi, im, jm
   USE logic_mod, ONLY: iflag_phys, read_start
@@ -62,5 +62,5 @@
   real tetastrat ! potential temperature in the stratosphere, in K
   real tetajl(jjp1,llm)
-  INTEGER i,j,l,lsup,ij, iq
+  INTEGER i,j,l,lsup,ij, iq, iName, iZone, iPhase, iqParent
 
   REAL teta0,ttp,delt_y,delt_z,eps ! Constantes pour profil de T
@@ -71,5 +71,5 @@
 
   real zz,ran1
-  integer idum, iqParent, iName, iZone, iPhase
+  integer idum
 
   REAL zdtvr
@@ -77,5 +77,4 @@
   character(len=*),parameter :: modname="iniacademic"
   character(len=80) :: abort_message
-
 
   ! Sanity check: verify that options selected by user are not incompatible
@@ -131,7 +130,9 @@
         ps(:)=preff
      endif
+
      ! ground geopotential
      phis(:)=0.
      CALL pression ( ip1jmp1, ap, bp, ps, p       )
+
      if (pressure_exner) then
        CALL exner_hyb( ip1jmp1, ps, p, pks, pk)
@@ -194,5 +195,4 @@
      CALL getin('tetanoise',tetanoise)
 
-
      ! 2. Initialize fields towards which to relax
      ! Friction
@@ -247,5 +247,4 @@
      IF (.NOT. read_start) THEN
         ! bulk initialization of temperature
-
         IF (iflag_phys>10000) THEN
         ! Particular case to impose a constant temperature T0=0.01*iflag_physx
@@ -254,5 +253,4 @@
            teta(:,:)=tetarappel(:,:)
         ENDIF
-
         ! geopotential
         CALL geopot(ip1jmp1,teta,pk,pks,phis,phi)
@@ -287,6 +285,6 @@
               iName = tracers(iq)%iso_iName
               if (.NOT.ok_isotopes .OR. iName <= 0) CYCLE
-              iZone = tracers(iq)%iso_iZone
-              iPhase= tracers(iq)%iso_iPhase
+              iZone    = tracers(iq)%iso_iZone
+              iPhase   = tracers(iq)%iso_iPhase
               iqParent = tracers(iq)%iqParent
               if (iZone == 0) q(:,:,iq) = q(:,:,iqParent)*tnat(iName) &
@@ -298,7 +296,5 @@
         endif ! of if (planet_type=="earth")
 
-        if (ok_iso_verif) then
-           call check_isotopes_seq(q,1,ip1jmp1,'iniacademic_loc')
-        endif !if (ok_iso_verif) then
+        if (ok_iso_verif) call check_isotopes_seq(q,1,ip1jmp1,'iniacademic_loc')
 
         ! add random perturbation to temperature
Index: /LMDZ6/trunk/libf/dyn3d_common/infotrac.F90
===================================================================
--- /LMDZ6/trunk/libf/dyn3d_common/infotrac.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/dyn3d_common/infotrac.F90	(revision 4056)
@@ -14,14 +14,6 @@
   INTEGER, SAVE :: nbtr
 
-! CRisi: on retranche les isotopes des traceurs habituels
-! On fait un tableaux d'indices des traceurs qui passeront dans phytrac
+! Nombre de traceurs passes a phytrac
   INTEGER, SAVE :: nqtottr
-  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE :: itr_indice
-
-! CRisi: nb traceurs peres= directement advectes par l'air
-  INTEGER, SAVE :: nqperes
-
-! ThL: nb traceurs INCA
-  INTEGER, SAVE :: nqINCA
 
 ! ThL: nb traceurs CO2
@@ -31,8 +23,4 @@
   TYPE(trac_type), TARGET,  SAVE, ALLOCATABLE ::  tracers(:)    !=== TRACERS DESCRIPTORS VECTOR
   TYPE(isot_type), TARGET,  SAVE, ALLOCATABLE :: isotopes(:)    !=== ISOTOPES PARAMETERS VECTOR
-
-! niadv : vector keeping the coorspondance between all tracers(nqtot) treated in the 
-!         dynamic part of the code and the tracers (nbtr+2) used in the physics part of the code. 
-  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE    :: niadv ! equivalent dyn / physique
 
   REAL :: qperemin,masseqmin,ratiomin ! MVals et CRisi
@@ -59,15 +47,4 @@
   INTEGER,SAVE :: niso,ntraceurs_zone,ntraciso
 
-#ifdef CPP_StratAer
-!--CK/OB for stratospheric aerosols
-  INTEGER, SAVE :: nbtr_bin
-  INTEGER, SAVE :: nbtr_sulgas
-  INTEGER, SAVE :: id_OCS_strat
-  INTEGER, SAVE :: id_SO2_strat
-  INTEGER, SAVE :: id_H2SO4_strat
-  INTEGER, SAVE :: id_BIN01_strat
-  INTEGER, SAVE :: id_TEST_strat
-#endif
- 
 CONTAINS
 
@@ -120,6 +97,7 @@
     LOGICAL :: continu,nouveau_traceurdef
     INTEGER :: IOstatus ! gestion de la retrocompatibilite de traceur.def
-    CHARACTER(len=maxlen) :: tchaine    
+    CHARACTER(len=maxlen) :: tchaine, msg1
     INTEGER, ALLOCATABLE  :: iqfils(:,:)
+    INTEGER :: nqINCA
 
     character(len=*),parameter :: modname="infotrac_init"
@@ -142,53 +120,40 @@
     descrq(30)='PRA'
     
-
-    ! Coherence test between parameter type_trac, config_inca and preprocessing keys
-    IF (type_trac=='inca') THEN
-       WRITE(lunout,*) 'You have chosen to couple with INCA chemistry model : type_trac=', &
-            type_trac,' config_inca=',config_inca
-       IF (config_inca/='aero' .AND. config_inca/='aeNP' .AND. config_inca/='chem') THEN
-          WRITE(lunout,*) 'Incoherence between type_trac and config_inca. Model stops. Modify run.def'
-          CALL abort_gcm('infotrac_init','Incoherence between type_trac and config_inca',1)
-       ENDIF
+    !--- MESSAGE ABOUT THE CHOSEN CONFIGURATION
+    WRITE(lunout,*)'type_trac='//TRIM(type_trac)
+    msg1 = 'For type_trac = "'//TRIM(type_trac)//'":'
+    SELECT CASE(type_trac)
+      CASE('inca'); WRITE(lunout,*)TRIM(msg1)//' coupling with INCA chemistry model, config_inca='//config_inca
+      CASE('inco'); WRITE(lunout,*)TRIM(msg1)//' coupling jointly with INCA and CO2 cycle'
+      CASE('repr'); WRITE(lunout,*)TRIM(msg1)//' coupling with REPROBUS chemistry model'
+      CASE('co2i'); WRITE(lunout,*)TRIM(msg1)//' you have chosen to run with CO2 cycle'
+      CASE('coag'); WRITE(lunout,*)TRIM(msg1)//' tracers are treated for COAGULATION tests'
+      CASE('lmdz'); WRITE(lunout,*)TRIM(msg1)//' tracers are treated in LMDZ only'
+      CASE DEFAULT
+        CALL abort_gcm(modname,'type_trac='//TRIM(type_trac)//' not possible yet.',1)
+    END SELECT
+
+    !--- COHERENCE TEST BETWEEN "type_trac", "config_inca" AND PREPROCESSING KEYS
+    SELECT CASE(type_trac)
+      CASE('inca','inco'); IF(ALL(['aero', 'aeNP', 'chem']/=config_inca)) &
+        CALL abort_gcm(modname, 'Incoherence between type_trac and config_inca. Please modify "run.def"',1)
 #ifndef INCA
-       WRITE(lunout,*) 'To run this option you must add cpp key INCA and compile with INCA code'
-       CALL abort_gcm('infotrac_init','You must compile with cpp key INCA',1)
+        CALL abort_gcm(modname, 'You must add cpp key INCA and compile with INCA code',1)
 #endif
-    ELSE IF (type_trac=='repr') THEN
-       WRITE(lunout,*) 'You have chosen to couple with REPROBUS chemestry model : type_trac=', type_trac
+      CASE('repr')
 #ifndef REPROBUS
-       WRITE(lunout,*) 'To run this option you must add cpp key REPROBUS and compile with REPRPBUS code'
-       CALL abort_gcm('infotrac_init','You must compile with cpp key REPROBUS',1)
+        CALL abort_gcm(modname, 'You must add cpp key REPROBUS and compile with REPROBUS code',1)
 #endif
-    ELSE IF (type_trac == 'co2i') THEN
-       WRITE(lunout,*) 'You have chosen to run with CO2 cycle: type_trac=', type_trac
-    ELSE IF (type_trac == 'coag') THEN
-       WRITE(lunout,*) 'Tracers are treated for COAGULATION tests : type_trac=', type_trac
+      CASE('coag')
 #ifndef CPP_StratAer
-       WRITE(lunout,*) 'To run this option you must add cpp key StratAer and compile with StratAer code'
-       CALL abort_gcm('infotrac_init','You must compile with cpp key StratAer',1)
+        CALL abort_gcm(modname, 'You must add cpp key StratAer and compile with StratAer code',1)
 #endif
-    ELSE IF (type_trac == 'lmdz') THEN
-       WRITE(lunout,*) 'Tracers are treated in LMDZ only : type_trac=', type_trac
-    ELSE IF (type_trac == 'inco') THEN ! ThL
-       WRITE(lunout,*) 'Using jointly INCA and CO2 cycle: type_trac =', type_trac
-       IF (config_inca/='aero' .AND. config_inca/='aeNP' .AND. config_inca/='chem') THEN
-          WRITE(lunout,*) 'Incoherence between type_trac and config_inca. Model stops. Modify run.def'
-          CALL abort_gcm('infotrac_init','Incoherence between type_trac and config_inca',1)
-       ENDIF
-#ifndef INCA
-       WRITE(lunout,*) 'To run this option you must add cpp key INCA and compilewith INCA code'
-       CALL abort_gcm('infotrac_init','You must compile with cpp key INCA',1)
-#endif    
-    ELSE
-       WRITE(lunout,*) 'type_trac=',type_trac,' not possible. Model stops'
-       CALL abort_gcm('infotrac_init','bad parameter',1)
-    ENDIF
-
-    ! Test if config_inca is other then none for run without INCA
-    IF (type_trac/='inca' .AND. type_trac/='inco' .AND. config_inca/='none') THEN
-       WRITE(lunout,*) 'config_inca will now be changed to none as you do not couple with INCA model'
-       config_inca='none'
-    ENDIF
+    END SELECT
+
+    !--- Disable "config_inca" option for a run without INCA if it differs from "none"
+    IF (ALL(['inca', 'inco', 'none'] /= config_inca)) THEN
+      WRITE(lunout,*)'setting config_inca="none" as you do not couple with INCA model'
+      config_inca = 'none'
+    END IF
 
 !-----------------------------------------------------------------------
@@ -198,71 +163,37 @@
 !
 !-----------------------------------------------------------------------
-    IF (type_trac == 'lmdz' .OR. type_trac == 'repr' .OR. type_trac == 'coag' .OR. type_trac == 'co2i') THEN
-       IF (type_trac=='co2i') THEN
-          nqCO2 = 1
-       ELSE
-          nqCO2 = 0
-       ENDIF
-       OPEN(90,file='traceur.def',form='formatted',status='old', iostat=ierr)
-       IF(ierr.EQ.0) THEN
-          WRITE(lunout,*) trim(modname),': Open traceur.def : ok'
-          READ(90,*) nqtrue
-          write(lunout,*) 'nqtrue=',nqtrue
-       ELSE 
-          WRITE(lunout,*) trim(modname),': Failed opening traceur.def'
-          CALL abort_gcm(modname,"file traceur.def not found!",1)
-       ENDIF
-!jyg<
-!!       if ( planet_type=='earth') then
-!!         ! For Earth, water vapour & liquid tracers are not in the physics
-!!         nbtr=nqtrue-2
-!!       else
-!!         ! Other planets (for now); we have the same number of tracers
-!!         ! in the dynamics than in the physics
-!!         nbtr=nqtrue
-!!       endif
-!>jyg
-    ELSE ! type_trac=inca or inco
-       IF (type_trac=='inco') THEN
-          nqCO2 = 1
-       ELSE
-          nqCO2 = 0
-       ENDIF
-!jyg<
-       ! The traceur.def file is used to define the number "nqo" of water phases 
-       ! present in the simulation. Default : nqo = 2.
-       OPEN(90,file='traceur.def',form='formatted',status='old', iostat=ierr)
-       IF(ierr.EQ.0) THEN
-          WRITE(lunout,*) trim(modname),': Open traceur.def : ok'
-          READ(90,*) nqo
-       ELSE 
-          WRITE(lunout,*) trim(modname),': Failed opening traceur.def'
-          CALL abort_gcm(modname,"file traceur.def not found!",1)
-       ENDIF
-       IF (nqo /= 2 .AND. nqo /= 3 ) THEN
-          IF (nqo == 4 .AND. type_trac=='inco') THEN ! ThL
-             WRITE(lunout,*) trim(modname),': you are coupling with INCA, and also using CO2i.'
-             nqo = 3    ! A ameliorier... je force 3 traceurs eau...  ThL
-             WRITE(lunout,*) trim(modname),': nqo = ',nqo
-          ELSE
-          WRITE(lunout,*) trim(modname),': nqo=',nqo, ' is not allowed. Only 2 or 3 water phases allowed'
-          CALL abort_gcm('infotrac_init','Bad number of water phases',1)
-          ENDIF
-       ENDIF
-       ! nbtr has been read from INCA by init_const_lmdz() in gcm.F 
+    OPEN(90,file='traceur.def',form='formatted',status='old', iostat=ierr)
+    IF(ierr.EQ.0) THEN
+       WRITE(lunout,*) trim(modname),': Open traceur.def : ok'
+    ELSE 
+       WRITE(lunout,*) trim(modname),': Failed opening traceur.def'
+       CALL abort_gcm(modname,"file traceur.def not found!",1)
+    ENDIF
+    nqCO2 = 0; IF(type_trac == 'inco') nqCO2 = 1
+    SELECT CASE(type_trac)
+       CASE('lmdz','repr','coag','co2i'); READ(90,*) nqtrue
+       CASE('inca','inco');               READ(90,*) nqo
+          ! The traceur.def file is used to define the number "nqo" of water phases 
+          ! present in the simulation. Default : nqo = 2.
+          IF (nqo == 4 .AND. type_trac=='inco') nqo = 3
+          IF(ALL([2,3] /= nqo)) THEN
+             WRITE(lunout,*) trim(modname),': nqo=',nqo, ' is not allowed. Only 2 or 3 water phases allowed'
+             CALL abort_gcm('infotrac_init','Bad number of water phases',1)
+          END IF
+          ! nbtr has been read from INCA by init_const_lmdz() in gcm.F 
 #ifdef INCA
-       CALL Init_chem_inca_trac(nqINCA)
+          CALL Init_chem_inca_trac(nqINCA)
 #else
-       nqINCA=0
+          nqINCA=0
 #endif
-       nbtr=nqINCA+nqCO2
-       nqtrue=nbtr+nqo
-       WRITE(lunout,*) trim(modname),': nqo = ',nqo
-       WRITE(lunout,*) trim(modname),': nbtr = ',nbtr
-       WRITE(lunout,*) trim(modname),': nqtrue = ',nqtrue
-       WRITE(lunout,*) trim(modname),': nqCO2 = ',nqCO2
-       WRITE(lunout,*) trim(modname),': nqINCA = ',nqINCA
-       ALLOCATE(hadv_inca(nqINCA), vadv_inca(nqINCA), conv_flg_inca(nqINCA), pbl_flg_inca(nqINCA), solsym_inca(nqINCA))
-    ENDIF   ! type_trac 'inca' ou 'inco'
+          nbtr=nqINCA+nqCO2
+          nqtrue=nbtr+nqo
+          WRITE(lunout,*) trim(modname),': nqo    = ',nqo
+          WRITE(lunout,*) trim(modname),': nbtr   = ',nbtr
+          WRITE(lunout,*) trim(modname),': nqtrue = ',nqtrue
+          WRITE(lunout,*) trim(modname),': nqCO2 = ',nqCO2
+          WRITE(lunout,*) trim(modname),': nqINCA = ',nqINCA
+          ALLOCATE(hadv_inca(nqINCA), vadv_inca(nqINCA), conv_flg_inca(nqINCA), pbl_flg_inca(nqINCA), solsym_inca(nqINCA))
+    END SELECT
 !>jyg
 
@@ -306,51 +237,35 @@
 !    Get choice of advection schema from file tracer.def or from INCA
 !---------------------------------------------------------------------
-    IF (type_trac == 'lmdz' .OR. type_trac == 'repr' .OR. type_trac == 'coag' .OR. type_trac == 'co2i') THEN
-
-          ! Continue to read tracer.def
-          DO iq=1,nqtrue
-
-             write(*,*) 'infotrac 237: iq=',iq
-             ! CRisi: ajout du nom du fluide transporteur
-             ! mais rester retro compatible
-             READ(90,'(I2,X,I2,X,A)',IOSTAT=IOstatus) hadv(iq),vadv(iq),tchaine
-             write(lunout,*) 'iq,hadv(iq),vadv(iq)=',iq,hadv(iq),vadv(iq)
-             write(lunout,*) 'tchaine=',trim(tchaine)
-             write(*,*) 'infotrac 238: IOstatus=',IOstatus
-             if (IOstatus.ne.0) then
-                CALL abort_gcm('infotrac_init','Pb dans la lecture de traceur.def',1)
-             endif
-             ! Y-a-t-il 1 ou 2 noms de traceurs? -> On regarde s'il y a un
-             ! espace ou pas au milieu de la chaine.
-             continu=.true.
-             nouveau_traceurdef=.false.
-             iiq=1
-             do while (continu)
-                if (tchaine(iiq:iiq).eq.' ') then
-                  nouveau_traceurdef=.true.
-                  continu=.false.
-                else if (iiq.lt.LEN_TRIM(tchaine)) then
-                  iiq=iiq+1
-                else
-                  continu=.false.
-                endif
-             enddo
-             write(*,*) 'iiq,nouveau_traceurdef=',iiq,nouveau_traceurdef
-             if (nouveau_traceurdef) then
-                write(lunout,*) 'C''est la nouvelle version de traceur.def'
-                tnom_0(iq)=TRIM(tchaine(1:iiq-1))
-                tnom_transp(iq)=TRIM(tchaine(iiq+1:))
-             else
-                write(lunout,*) 'C''est l''ancienne version de traceur.def'
-                write(lunout,*) 'On suppose que les traceurs sont tous d''air'
-                tnom_0(iq)=tchaine
-                tnom_transp(iq) = 'air'
-             endif
-             write(lunout,*) 'tnom_0(iq)=<',trim(tnom_0(iq)),'>'
-             write(lunout,*) 'tnom_transp(iq)=<',trim(tnom_transp(iq)),'>'
-
-          ENDDO!DO iq=1,nqtrue
-
-          CLOSE(90)  
+    IF (ANY(['lmdz', 'repr', 'coag', 'co2i'] == type_trac)) THEN
+
+       ! Continue to read tracer.def
+       DO iq=1,nqtrue
+
+          write(*,*) 'infotrac 237: iq=',iq
+          ! CRisi: ajout du nom du fluide transporteur
+          ! mais rester retro compatible
+          READ(90,'(I2,X,I2,X,A)',IOSTAT=IOstatus) hadv(iq),vadv(iq),tchaine
+          write(lunout,*) 'iq,hadv(iq),vadv(iq)=',iq,hadv(iq),vadv(iq)
+          write(lunout,*) 'tchaine=',trim(tchaine)
+          write(*,*) 'infotrac 238: IOstatus=',IOstatus
+          if (IOstatus.ne.0) CALL abort_gcm('infotrac_init','Pb dans la lecture de traceur.def',1)
+          ! Y-a-t-il 1 ou 2 noms de traceurs separes par un espace ?
+          iiq = INDEX(tchaine(1:LEN_TRIM(tchaine)),' ')
+          nouveau_traceurdef=iiq/=0
+          write(*,*) 'iiq,nouveau_traceurdef=',iiq,nouveau_traceurdef
+          if (nouveau_traceurdef) then
+             IF(iq==1) write(lunout,*) "Nouvelle version de traceur.def"
+             tnom_0     (iq) = tchaine(1:iiq-1)
+             tnom_transp(iq) = tchaine(iiq+1:)
+          else
+             IF(iq==1) write(lunout,*) "Nouvelle version de traceur.def: traceurs d'air uniquement"
+             tnom_0     (iq) = tchaine
+             tnom_transp(iq) = 'air'
+          endif
+          write(lunout,*) 'tnom_0(iq)=<',trim(tnom_0(iq)),'>'
+          write(lunout,*) 'tnom_transp(iq)=<',trim(tnom_transp(iq)),'>'
+       ENDDO!DO iq=1,nqtrue
+
+       CLOSE(90)  
 
        WRITE(lunout,*) trim(modname),': Valeur de traceur.def :'
@@ -362,9 +277,5 @@
        IF ( planet_type=='earth') THEN
          !CR: nombre de traceurs de l eau
-         IF (tnom_0(3) == 'H2Oi') THEN
-            nqo=3
-         ELSE
-            nqo=2
-         ENDIF
+         nqo=2; IF (tnom_0(3) == 'H2Oi') nqo=3
          ! For Earth, water vapour & liquid tracers are not in the physics
          nbtr=nqtrue-nqo
@@ -375,52 +286,12 @@
        ENDIF
 
-#ifdef CPP_StratAer
-       IF (type_trac == 'coag') THEN
-         nbtr_bin=0
-         nbtr_sulgas=0
-         DO iq=1,nqtrue
-           IF (tnom_0(iq)(1:3)=='BIN') THEN !check if tracer name contains 'BIN'
-             nbtr_bin=nbtr_bin+1
-           ENDIF
-           IF (tnom_0(iq)(1:3)=='GAS') THEN !check if tracer name contains 'GAS'
-             nbtr_sulgas=nbtr_sulgas+1
-           ENDIF
-         ENDDO
-         print*,'nbtr_bin=',nbtr_bin
-         print*,'nbtr_sulgas=',nbtr_sulgas
-         DO iq=1,nqtrue
-           IF (tnom_0(iq)=='GASOCS') THEN
-             id_OCS_strat=iq-nqo
-           ENDIF
-           IF (tnom_0(iq)=='GASSO2') THEN
-             id_SO2_strat=iq-nqo
-           ENDIF
-           IF (tnom_0(iq)=='GASH2SO4') THEN
-             id_H2SO4_strat=iq-nqo
-           ENDIF
-           IF (tnom_0(iq)=='BIN01') THEN
-             id_BIN01_strat=iq-nqo
-           ENDIF
-           IF (tnom_0(iq)=='GASTEST') THEN
-             id_TEST_strat=iq-nqo
-           ENDIF
-         ENDDO
-         print*,'id_OCS_strat  =',id_OCS_strat
-         print*,'id_SO2_strat  =',id_SO2_strat
-         print*,'id_H2SO4_strat=',id_H2SO4_strat
-         print*,'id_BIN01_strat=',id_BIN01_strat
-       ENDIF
+    ENDIF
+!jyg<
+!
+
+! Transfert number of tracers to Reprobus
+#ifdef REPROBUS
+    IF (type_trac == 'repr') CALL Init_chem_rep_trac(nbtr,nqo,tnom_0)
 #endif
-
-    ENDIF  ! (type_trac == 'lmdz' .OR. type_trac == 'repr' .OR. type_trac = 'coag' .OR. type_trac = 'co2i')
-!jyg<
-!
-
-! Transfert number of tracers to Reprobus
-    IF (type_trac == 'repr') THEN
-#ifdef REPROBUS
-       CALL Init_chem_rep_trac(nbtr,nqo,tnom_0)
-#endif
-    ENDIF
 !
 ! Allocate variables depending on nbtr
@@ -432,84 +303,49 @@
     IF (type_trac == 'inca' .OR. type_trac == 'inco') THEN   ! config_inca='aero' ou 'chem'
 !>jyg
-! le module de chimie fournit les noms des traceurs
-! et les schemas d'advection associes. excepte pour ceux lus 
-! dans traceur.def 
-
-          DO iq=1,nqo+nqCO2
-
-             write(*,*) 'infotrac 237: iq=',iq
-             ! CRisi: ajout du nom du fluide transporteur
-             ! mais rester retro compatible
-             READ(90,'(I2,X,I2,X,A)',IOSTAT=IOstatus) hadv(iq),vadv(iq),tchaine
-             write(lunout,*) 'iq,hadv(iq),vadv(iq)=',iq,hadv(iq),vadv(iq)
-             write(lunout,*) 'tchaine=',trim(tchaine)
-             write(*,*) 'infotrac 238: IOstatus=',IOstatus
-             if (IOstatus.ne.0) then
-                CALL abort_gcm('infotrac_init','Pb dans la lecture de traceur.def',1)
-             endif
-             ! Y-a-t-il 1 ou 2 noms de traceurs? -> On regarde s'il y a un
-             ! espace ou pas au milieu de la chaine.
-             continu=.true.
-             nouveau_traceurdef=.false.
-             iiq=1
-
-             do while (continu)
-                if (tchaine(iiq:iiq).eq.' ') then
-                  nouveau_traceurdef=.true.
-                  continu=.false.
-                else if (iiq.lt.LEN_TRIM(tchaine)) then
-                  iiq=iiq+1
-                else
-                  continu=.false.
-                endif
-             enddo
-
-             write(*,*) 'iiq,nouveau_traceurdef=',iiq,nouveau_traceurdef
-
-             if (nouveau_traceurdef) then
-                write(lunout,*) 'C''est la nouvelle version de traceur.def'
-                tnom_0(iq)=tchaine(1:iiq-1)
-                tnom_transp(iq)=tchaine(iiq+1:)
-             else
-                write(lunout,*) 'C''est l''ancienne version de traceur.def'
-                write(lunout,*) 'On suppose que les traceurs sont tous d''air'
-                tnom_0(iq)=tchaine
-                tnom_transp(iq) = 'air'
-             endif
-
-             write(lunout,*) 'tnom_0(iq)=<',trim(tnom_0(iq)),'>'
-             write(lunout,*) 'tnom_transp(iq)=<',trim(tnom_transp(iq)),'>'
-
-          ENDDO  !DO iq=1,nqo
-          CLOSE(90)  
-
- 
+! le module de chimie fournit les noms des traceurs et les schemas d'advection associes.
+! excepte pour ceux lus dans traceur.def 
+
 #ifdef INCA
-       CALL init_transport( &
-            hadv_inca, &
-            vadv_inca, &
-            conv_flg_inca, &
-            pbl_flg_inca,  &
-            solsym_inca)
-
-       conv_flg(1+nqCO2:nbtr) = conv_flg_inca
-       pbl_flg(1+nqCO2:nbtr) = pbl_flg_inca
-       solsym(1+nqCO2:nbtr) = solsym_inca
-
-       IF (type_trac == 'inco') THEN
-          conv_flg(1:nqCO2) = 1
-          pbl_flg(1:nqCO2) = 1
-          solsym(1:nqCO2) = 'CO2'
-       ENDIF
+       CALL init_transport(hadv_inca, vadv_inca, conv_flg_inca, pbl_flg_inca, solsym_inca)
+       ! DC passive CO2 tracer is at index 1: H2O was removed ; nqCO2/=0 in "inco" case only
+       conv_flg(1:nqCO2) = 1;   conv_flg(1+nqCO2:nbtr) = conv_flg_inca
+        pbl_flg(1:nqCO2) = 1;    pbl_flg(1+nqCO2:nbtr) =  pbl_flg_inca
+         solsym(1:nqCO2) = 'CO2'; solsym(1+nqCO2:nbtr) =   solsym_inca
 #endif
 
-!jyg<
-       DO iq = nqo+nqCO2+1, nqtrue
-          hadv(iq) = hadv_inca(iq-nqo-nqCO2)
-          vadv(iq) = vadv_inca(iq-nqo-nqCO2) 
-          tnom_0(iq)=solsym_inca(iq-nqo-nqCO2)
-          tnom_transp(iq) = 'air'
+       itr = 0
+       DO iq = 1, nqtot
+          IF(iq > nqo+nqCO2) THEN
+             itr = itr+1
+             hadv  (iq) = hadv_inca  (itr)
+             vadv  (iq) = vadv_inca  (itr) 
+             tnom_0(iq) = solsym_inca(itr)
+             tnom_transp(iq) = 'air'
+             CYCLE
+          END IF
+          write(*,*) 'infotrac 237: iq=',iq
+          ! CRisi: ajout du nom du fluide transporteur en restant retro-compatible
+          READ(90,'(I2,X,I2,X,A)',IOSTAT=IOstatus) hadv(iq),vadv(iq),tchaine
+          write(lunout,*) 'iq,hadv(iq),vadv(iq)=',iq,hadv(iq),vadv(iq)
+          write(lunout,*) 'tchaine=',trim(tchaine)
+          write(*,*) 'infotrac 238: IOstatus=',IOstatus
+          if (IOstatus.ne.0) CALL abort_gcm('infotrac_init','Pb dans la lecture de traceur.def',1)
+          ! Y-a-t-il 1 ou 2 noms de traceurs separes par un espace ?
+          iiq = INDEX(tchaine(1:LEN_TRIM(tchaine)),' ')
+          nouveau_traceurdef=iiq/=0
+          write(*,*) 'iiq,nouveau_traceurdef=',iiq,nouveau_traceurdef
+          if (nouveau_traceurdef) then
+             IF(iq==1) write(lunout,*) "Nouvelle version de traceur.def"
+             tnom_0     (iq) = tchaine(1:iiq-1)
+             tnom_transp(iq) = tchaine(iiq+1:)
+          else
+             IF(iq==1) write(lunout,*) "Nouvelle version de traceur.def: traceurs d'air uniquement"
+             tnom_0     (iq) = tchaine
+             tnom_transp(iq) = 'air'
+          endif
+          write(lunout,*) 'tnom_0(iq)=<',trim(tnom_0(iq)),'>'
+          write(lunout,*) 'tnom_transp(iq)=<',trim(tnom_transp(iq)),'>'
        END DO
-
+       CLOSE(90)  
     ENDIF ! (type_trac == 'inca' or 'inco')
 
@@ -554,5 +390,4 @@
 !
     ALLOCATE(tracers(nqtot))
-    ALLOCATE(niadv(nqtot))
 
 !-----------------------------------------------------------------------
@@ -604,23 +439,9 @@
     END DO
 
-!
-! Find vector keeping the correspodence between true and total tracers
-!
-    niadv(:)=0
-    iiq=0
+    WRITE(lunout,*) trim(modname),': Information stored in infotrac :'
+    WRITE(lunout,*) trim(modname),': iadv  name  long_name :'
+
     DO iq=1,nqtot
-       IF(tracers(iq)%iadv.GE.0) THEN
-          ! True tracer
-          iiq=iiq+1
-          niadv(iiq)=iq
-       ENDIF
-    END DO
-
-
-    WRITE(lunout,*) trim(modname),': Information stored in infotrac :'
-    WRITE(lunout,*) trim(modname),': iadv  niadv  name  long_name :'
-
-    DO iq=1,nqtot
-       WRITE(lunout,*) tracers(iq)%iadv,niadv(iq), ' ',trim(tracers(iq)%name),' ',trim(tracers(iq)%longName)
+       WRITE(lunout,*) tracers(iq)%iadv,' ',trim(tracers(iq)%name),' ',trim(tracers(iq)%longName)
     END DO
 
@@ -645,5 +466,4 @@
 ! + verifier que tous les peres sont ecrits en premieres positions
     ALLOCATE(iqfils(nqtot,nqtot))   
-    nqperes=0
     iqfils(:,:)=0
     tracers(:)%iqParent=0
@@ -652,5 +472,4 @@
         ! ceci est un traceur pere
         WRITE(lunout,*) 'Le traceur',iq,', appele ',trim(tnom_0(iq)),', est un pere'
-        nqperes=nqperes+1
         tracers(iq)%iqParent=0
       else !if (tnom_transp(iq) == 'air') then
@@ -682,5 +501,5 @@
       endif !if (tnom_transp(iq) == 'air') then
     enddo !DO iq=1,nqtot
-    WRITE(lunout,*) 'infotrac: nqperes=',nqperes    
+    WRITE(lunout,*) 'infotrac: nqGen0=',COUNT(tracers(:)%parent == 'air')
     WRITE(lunout,*) 'nqChilds=',tracers(:)%nqChilds
     WRITE(lunout,*) 'iqParent=',tracers(:)%iqParent
@@ -738,5 +557,4 @@
     tracers(:)%isH2Ofamily = [(tracers(iq)%gen0Name(1:3) == 'H2O', iq=1, nqtot)]
 
-
 ! detecter quels sont les traceurs isotopiques parmi des traceurs
     call infotrac_isoinit(tnom_0,nqtrue)
@@ -754,18 +572,6 @@
         write(lunout,*) 'infotrac 704: nqtottr,nqtot,nqo=',nqtottr,nqtot,nqo
         ! Rq: nqtottr n'est pas forcement egal a nbtr dans le cas ou new_iq /= nqtrue
-        ALLOCATE (itr_indice(nqtottr))  
-        itr_indice(:)=0  
-        itr=0
-        do iq=nqo+1, nqtot
-          if (tracers(iq)%iso_iName.eq.0) then
-            itr=itr+1
-            write(*,*) 'itr=',itr
-            itr_indice(itr)=iq
-          endif !if (tracers(iq)%iso_iName.eq.0) then
-        enddo
-        if (itr.ne.nqtottr) then
+        if (COUNT(tracers(:)%iso_iName == 0) /= nqtottr) &
             CALL abort_gcm('infotrac_init','pb dans le calcul de nqtottr',1)
-        endif
-        write(lunout,*) 'itr_indice=',itr_indice
 !    endif !if (ntraciso.gt.0) then
 
Index: DZ6/trunk/libf/dyn3dmem/advtrac_loc.F
===================================================================
--- /LMDZ6/trunk/libf/dyn3dmem/advtrac_loc.F	(revision 4055)
+++ 	(revision )
@@ -1,363 +1,0 @@
-!
-! $Id$
-!
-c
-c
-#define DEBUG_IO
-#undef DEBUG_IO
-      SUBROUTINE advtrac_loc(pbarug,pbarvg ,wg,
-     *                   p,  massem,q,teta,
-     *                   pk   )
-
-c     Auteur :  F. Hourdin
-c
-c     Modif. P. Le Van     (20/12/97)
-c            F. Codron     (10/99)
-c            D. Le Croller (07/2001)
-c            M.A Filiberti (04/2002)
-c
-      USE parallel_lmdz
-      USE Write_Field_loc
-      USE Write_Field
-      USE Bands
-      USE mod_hallo
-      USE Vampir
-      USE times
-      USE infotrac, ONLY: nqtot, tracers, ok_iso_verif
-      USE control_mod, ONLY: iapp_tracvl, day_step, planet_type
-      USE advtrac_mod, ONLY: finmasse
-      USE comconst_mod, ONLY: dtvr
-      IMPLICIT NONE
-c
-      include "dimensions.h"
-      include "paramet.h"
-      include "comdissip.h"
-      include "comgeom2.h"
-      include "description.h"
-
-c-------------------------------------------------------------------
-c     Arguments
-c-------------------------------------------------------------------
-c     Ajout PPM
-c--------------------------------------------------------
-      REAL massebx(ijb_u:ije_u,llm),masseby(ijb_v:ije_v,llm)
-c--------------------------------------------------------
-      INTEGER iapptrac
-      REAL pbarug(ijb_u:ije_u,llm),pbarvg(ijb_v:ije_v,llm)
-      REAL wg(ijb_u:ije_u,llm)
-      REAL q(ijb_u:ije_u,llm,nqtot),massem(ijb_u:ije_u,llm)
-      REAL p( ijb_u:ije_u,llmp1 ),teta(ijb_u:ije_u,llm)
-      REAL pk(ijb_u:ije_u,llm)
-
-c-------------------------------------------------------------
-c     Variables locales
-c-------------------------------------------------------------
-
-      REAL zdp(ijb_u:ije_u)
-      REAL (kind=kind(1.d0)) :: t_initial, t_final, tps_cpu
-      INTEGER,SAVE :: iadvtr=0
-c$OMP THREADPRIVATE(iadvtr)
-      INTEGER ij,l,iq,iiq
-      REAL zdpmin, zdpmax
-c----------------------------------------------------------
-c     Rajouts pour PPM
-c----------------------------------------------------------
-      INTEGER indice,n
-      REAL dtbon ! Pas de temps adaptatif pour que CFL<1
-      REAL CFLmaxz,aaa,bbb ! CFL maximum
-      REAL psppm(iim,jjb_u:jje_u) ! pression  au sol
-      REAL unatppm(iim,jjb_u:jje_u,llm),vnatppm(iim,jjb_u:jje_u,llm)
-      REAL qppm(iim*jjnb_u,llm,nqtot)
-      REAL fluxwppm(iim,jjb_u:jje_u,llm)
-      REAL apppm(llmp1), bpppm(llmp1)
-      LOGICAL dum,fill
-      DATA fill/.true./
-      DATA dum/.true./
-      integer ijb,ije,ijbu,ijbv,ijeu,ijev,j, iadv
-      type(Request),SAVE :: testRequest
-!$OMP THREADPRIVATE(testRequest)
-
-c  test sur l''eventuelle creation de valeurs negatives de la masse
-         ijb=ij_begin
-         ije=ij_end
-         if (pole_nord) ijb=ij_begin+iip1
-         if (pole_sud) ije=ij_end-iip1
-         
-c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)          
-         DO l=1,llm-1
-            DO ij = ijb+1,ije
-              zdp(ij) =    pbarug(ij-1,l)   - pbarug(ij,l)
-     s                  - pbarvg(ij-iip1,l) + pbarvg(ij,l)
-     s                  +       wg(ij,l+1)  - wg(ij,l)
-            ENDDO
-            
-c            CALL SCOPY( jjm -1 ,zdp(iip1+iip1),iip1,zdp(iip2),iip1 )
-c ym  ---> pourquoi jjm-1 et non jjm ? a cause du pole ?
-            
-            do ij=ijb,ije-iip1+1,iip1
-              zdp(ij)=zdp(ij+iip1-1)
-            enddo
-            
-            DO ij = ijb,ije
-               zdp(ij)= zdp(ij)*dtvr/ massem(ij,l) 
-            ENDDO 
-
-
-c            CALL minmax ( ip1jm-iip1, zdp(iip2), zdpmin,zdpmax )
-c  ym ---> eventuellement a revoir
-            CALL minmax ( ije-ijb+1, zdp(ijb), zdpmin,zdpmax )
-            
-            IF(MAX(ABS(zdpmin),ABS(zdpmax)).GT.0.5) THEN
-            PRINT*,'WARNING DP/P l=',l,'  MIN:',zdpmin,
-     s        '   MAX:', zdpmax
-            ENDIF
-
-         ENDDO
-c$OMP END DO NOWAIT
-
-c-------------------------------------------------------------------
-c   Advection proprement dite (Modification Le Croller (07/2001)
-c-------------------------------------------------------------------
-
-c----------------------------------------------------
-c        Calcul des moyennes basées sur la masse
-c----------------------------------------------------
-
-cym      ----> Normalement, inutile pour les schémas classiques
-cym      ----> Revérifier lors de la parallélisation des autres schemas
-   
-cym          call massbar_p(massem,massebx,masseby)          
-
-#ifdef DEBUG_IO    
-          CALL WriteField_u('massem',massem)
-          CALL WriteField_u('wg',wg)
-          CALL WriteField_u('pbarug',pbarug)
-          CALL WriteField_v('pbarvg',pbarvg)
-          CALL WriteField_u('p_tmp',p)
-          CALL WriteField_u('pk_tmp',pk)
-          CALL WriteField_u('teta_tmp',teta)
-          do j=1,nqtot
-            call WriteField_u('q_adv'//trim(int2str(j)),
-     .                q(:,:,j))
-          enddo
-#endif
-
-!          
-!       call Register_Hallo_v(pbarvg,llm,1,1,1,1,TestRequest)
-!
-!       call SendRequest(TestRequest)
-!c$OMP BARRIER
-!       call WaitRequest(TestRequest)
-c$OMP BARRIER
-                 
-          !write(*,*) 'advtrac 157: appel de vlspltgen_loc'
-          call vlspltgen_loc( q, 2., massem, wg,pbarug,pbarvg,dtvr,p,
-     *                        pk,teta )
-
-#ifdef DEBUG_IO     
-          do j=1,nqtot
-            call WriteField_u('q_adv'//trim(int2str(j)),
-     .                q(:,:,j))
-          enddo
-#endif
-         
-          GOTO 1234     
-c-----------------------------------------------------------
-c     Appel des sous programmes d'advection
-c-----------------------------------------------------------
-      do iq=1,nqtot
-c        call clock(t_initial)
-        iadv = tracers(iq)%iadv
-        SELECT CASE(iadv)
-          CASE(0); CYCLE
-          CASE(10)
-c   ----------------------------------------------------------------
-c   Schema de Van Leer I MUSCL
-c   ----------------------------------------------------------------
-     
-!LF            call vlsplt_p(q(1,1,iq),2.,massem,wg,pbarug,pbarvg,dtvr)
-
-          CASE(14)
-c   ----------------------------------------------------------------
-c   Schema "pseudo amont" + test sur humidite specifique
-C    pour la vapeur d'eau. F. Codron
-c   ----------------------------------------------------------------
-c
-cym           stop 'advtrac : appel à vlspltqs :schema non parallelise'
-!LF           CALL vlspltqs_p( q(1,1,1), 2., massem, wg ,
-!LF     *                 pbarug,pbarvg,dtvr,p,pk,teta )
-          CASE(12)
-c   ----------------------------------------------------------------
-c   Schema de Frederic Hourdin
-c   ----------------------------------------------------------------
-          stop 'advtrac : schema non parallelise'
-c            Pas de temps adaptatif
-           call adaptdt(iadv,dtbon,n,pbarug,massem)
-           if (n.GT.1) then
-           write(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=',
-     s             dtvr,'n=',n
-           endif
-           do indice=1,n
-            call advn(q(1,1,iq),massem,wg,pbarug,pbarvg,dtbon,1)
-           end do
-          CASE(13)
-          stop 'advtrac : schema non parallelise'
-c            Pas de temps adaptatif
-           call adaptdt(iadv,dtbon,n,pbarug,massem)
-           if (n.GT.1) then
-           write(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=',
-     s             dtvr,'n=',n
-           endif
-          do indice=1,n
-            call advn(q(1,1,iq),massem,wg,pbarug,pbarvg,dtbon,2)
-          end do
-          CASE(20)
-c   ----------------------------------------------------------------
-c   Schema de pente SLOPES
-c   ----------------------------------------------------------------
-          stop 'advtrac : schema non parallelise'
-
-            call pentes_ini (q(1,1,iq),wg,massem,pbarug,pbarvg,0)
-
-          CASE(30)
-c   ----------------------------------------------------------------
-c   Schema de Prather
-c   ----------------------------------------------------------------
-          stop 'advtrac : schema non parallelise'
-c            Pas de temps adaptatif
-           call adaptdt(iadv,dtbon,n,pbarug,massem)
-           if (n.GT.1) then
-           write(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=',
-     s             dtvr,'n=',n
-           endif
-           call  prather(q(1,1,iq),wg,massem,pbarug,pbarvg,
-     s                     n,dtbon)
-          CASE(11,16,17,18)
-c   ----------------------------------------------------------------
-c   Schemas PPM Lin et Rood
-c   ----------------------------------------------------------------
-
-           stop 'advtrac : schema non parallelise'
-
-c        Test sur le flux horizontal
-c        Pas de temps adaptatif
-         call adaptdt(iadv,dtbon,n,pbarug,massem)
-         if (n.GT.1) then
-           write(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=',
-     s             dtvr,'n=',n
-         endif
-c        Test sur le flux vertical
-         CFLmaxz=0.
-         do l=2,llm
-           do ij=iip2,ip1jm
-            aaa=wg(ij,l)*dtvr/massem(ij,l)
-            CFLmaxz=max(CFLmaxz,aaa)
-            bbb=-wg(ij,l)*dtvr/massem(ij,l-1)
-            CFLmaxz=max(CFLmaxz,bbb)
-           enddo
-         enddo
-         if (CFLmaxz.GE.1) then
-            write(*,*) 'WARNING vertical','CFLmaxz=', CFLmaxz
-         endif
-
-c-----------------------------------------------------------
-c        Ss-prg interface LMDZ.4->PPM3d
-c-----------------------------------------------------------
-
-          call interpre(q(1,1,iq),qppm(1,1,iq),wg,fluxwppm,massem,
-     s                 apppm,bpppm,massebx,masseby,pbarug,pbarvg,
-     s                 unatppm,vnatppm,psppm)
-
-          do indice=1,n
-c---------------------------------------------------------------------
-c                         VL (version PPM) horiz. et PPM vert.
-c---------------------------------------------------------------------
-            SELECT CASE(iadv)
-              CASE(11)
-c                  Ss-prg PPM3d de Lin
-                  call ppm3d(1,qppm(1,1,iq),
-     s                       psppm,psppm,
-     s                       unatppm,vnatppm,fluxwppm,dtbon,2,2,2,1,
-     s                       iim,jjp1,2,llm,apppm,bpppm,0.01,6400000,
-     s                       fill,dum,220.)
-
-              CASE(16)
-c----------------------------------------------------------------------
-c                           Monotonic PPM
-c----------------------------------------------------------------------
-c                  Ss-prg PPM3d de Lin
-                  call ppm3d(1,qppm(1,1,iq),
-     s                       psppm,psppm,
-     s                       unatppm,vnatppm,fluxwppm,dtbon,3,3,3,1,
-     s                       iim,jjp1,2,llm,apppm,bpppm,0.01,6400000,
-     s                       fill,dum,220.)
-c---------------------------------------------------------------------
-
-              CASE(17)
-c---------------------------------------------------------------------
-c                           Semi Monotonic PPM
-c---------------------------------------------------------------------
-c                  Ss-prg PPM3d de Lin
-                  call ppm3d(1,qppm(1,1,iq),
-     s                       psppm,psppm,
-     s                       unatppm,vnatppm,fluxwppm,dtbon,4,4,4,1,
-     s                       iim,jjp1,2,llm,apppm,bpppm,0.01,6400000,
-     s                       fill,dum,220.)
-c---------------------------------------------------------------------
-
-              CASE(18)
-c---------------------------------------------------------------------
-c                         Positive Definite PPM
-c---------------------------------------------------------------------
-c                  Ss-prg PPM3d de Lin
-                  call ppm3d(1,qppm(1,1,iq),
-     s                       psppm,psppm,
-     s                       unatppm,vnatppm,fluxwppm,dtbon,5,5,5,1,
-     s                       iim,jjp1,2,llm,apppm,bpppm,0.01,6400000,
-     s                       fill,dum,220.)
-c---------------------------------------------------------------------
-            END SELECT
-            enddo
-c-----------------------------------------------------------------
-c               Ss-prg interface PPM3d-LMDZ.4
-c-----------------------------------------------------------------
-                  call interpost(q(1,1,iq),qppm(1,1,iq))
-        END SELECT
-c----------------------------------------------------------------------
-
-c-----------------------------------------------------------------
-c On impose une seule valeur du traceur au pôle Sud j=jjm+1=jjp1
-c et Nord j=1
-c-----------------------------------------------------------------
-
-c                  call traceurpole(q(1,1,iq),massem)
-
-c calcul du temps cpu pour un schema donne
-
-
-       end DO
-
-1234  CONTINUE
-c$OMP BARRIER
-
-      if (planet_type=="earth") then
-
-      ijb=ij_begin
-      ije=ij_end
-
-c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)      
-       DO l = 1, llm
-         DO ij = ijb, ije
-           finmasse(ij,l) =  p(ij,l) - p(ij,l+1) 
-         ENDDO
-       ENDDO
-c$OMP END DO
-
-        ! CRisi: on passe nqtot et non nq
-       CALL qminimum_loc( q, nqtot, finmasse )
-
-      endif ! of if (planet_type=="earth")
-
-       RETURN
-       END
-
Index: /LMDZ6/trunk/libf/dyn3dmem/advtrac_loc.F90
===================================================================
--- /LMDZ6/trunk/libf/dyn3dmem/advtrac_loc.F90	(revision 4056)
+++ /LMDZ6/trunk/libf/dyn3dmem/advtrac_loc.F90	(revision 4056)
@@ -0,0 +1,290 @@
+
+#define DEBUG_IO
+#undef DEBUG_IO
+SUBROUTINE advtrac_loc(pbarug, pbarvg, wg, p, massem, q, teta, pk)
+   !     Auteur :  F. Hourdin
+   !
+   !     Modif. P. Le Van     (20/12/97)
+   !            F. Codron     (10/99)
+   !            D. Le Croller (07/2001)
+   !            M.A Filiberti (04/2002)
+   !
+   USE infotrac,     ONLY: nqtot, tracers,ok_iso_verif
+   USE control_mod,  ONLY: iapp_tracvl, day_step, planet_type
+   USE comconst_mod, ONLY: dtvr
+   USE parallel_lmdz
+   USE Write_Field_loc
+   USE Write_Field
+   USE Bands
+   USE mod_hallo
+   USE Vampir
+   USE times
+   USE advtrac_mod, ONLY: finmasse
+
+   IMPLICIT NONE
+   !
+   include "dimensions.h"
+   include "paramet.h"
+   include "comdissip.h"
+   include "comgeom2.h"
+   include "description.h"
+!   include "iniprint.h"
+
+   !---------------------------------------------------------------------------
+   !     Arguments
+   !---------------------------------------------------------------------------
+   REAL, INTENT(IN) ::  pbarug(ijb_u:ije_u,llm)
+   REAL, INTENT(IN) ::  pbarvg(ijb_v:ije_v,llm)
+   REAL, INTENT(IN) ::      wg(ijb_u:ije_u,llm)
+   REAL, INTENT(IN) ::       p(ijb_u:ije_u,llmp1)
+   REAL, INTENT(IN) ::  massem(ijb_u:ije_u,llm)
+   REAL, INTENT(INOUT) ::    q(ijb_u:ije_u,llm,nqtot)
+   REAL, INTENT(IN) ::    teta(ijb_u:ije_u,llm)
+   REAL, INTENT(IN) ::      pk(ijb_u:ije_u,llm)
+   !---------------------------------------------------------------------------
+   !     Ajout PPM
+   !---------------------------------------------------------------------------
+   REAL :: massebx(ijb_u:ije_u,llm), masseby(ijb_v:ije_v,llm)
+   !---------------------------------------------------------------------------
+   !     Variables locales
+   !---------------------------------------------------------------------------
+   INTEGER :: ij, l, iq, iiq, iadv
+   REAL(KIND=KIND(1.d0)) :: t_initial, t_final, tps_cpu
+   REAL :: zdp(ijb_u:ije_u), zdpmin, zdpmax
+   INTEGER, SAVE :: iadvtr=0
+!$OMP THREADPRIVATE(iadvtr)
+   EXTERNAL  minmax
+
+   !---------------------------------------------------------------------------
+   !     Rajouts pour PPM
+   !---------------------------------------------------------------------------
+   INTEGER :: indice, n
+   REAL :: dtbon                       ! Pas de temps adaptatif pour que CFL<1
+   REAL :: CFLmaxz, aaa, bbb           ! CFL maximum
+   REAL, DIMENSION(iim,jjb_u:jje_u,llm) :: unatppm, vnatppm, fluxwppm
+   REAL ::    qppm(iim*jjnb_u,llm,nqtot)
+   REAL ::   psppm(iim,jjb_u:jje_u)    ! pression  au sol
+   REAL, DIMENSION(llmp1) :: apppm, bpppm
+   LOGICAL, SAVE :: dum=.TRUE., fill=.TRUE.
+   INTEGER :: ijb, ije, ijbu, ijbv, ijeu, ijev, j
+   TYPE(Request),SAVE :: testRequest
+!$OMP THREADPRIVATE(testRequest)
+
+! Test sur l'eventuelle creation de valeurs negatives de la masse
+   ijb = ij_begin; IF(pole_nord) ijb = ij_begin+iip1
+   ije = ij_end;   IF(pole_sud)  ije = ij_end-iip1
+
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+   DO l=1,llm-1
+      DO ij = ijb+1,ije
+         zdp(ij) = pbarug(ij-1,l)    - pbarug(ij,l) &
+                 - pbarvg(ij-iip1,l) + pbarvg(ij,l) &
+                 +     wg(ij,l+1)    -     wg(ij,l)
+      END DO
+! ym  ---> pourquoi jjm-1 et non jjm ? a cause du pole ?
+!     CALL SCOPY( jjm -1 ,zdp(iip1+iip1),iip1,zdp(iip2),iip1 )
+      DO ij = ijb,ije-iip1+1,iip1
+         zdp(ij)=zdp(ij+iip1-1)
+      END DO
+      DO ij = ijb,ije
+         zdp(ij)= zdp(ij)*dtvr/ massem(ij,l) 
+      END DO 
+!     CALL minmax ( ip1jm-iip1, zdp(iip2), zdpmin,zdpmax )
+! ym ---> eventuellement a revoir
+      CALL minmax( ije-ijb+1, zdp(ijb), zdpmin,zdpmax )
+      IF(MAX(ABS(zdpmin),ABS(zdpmax)) >0.5) &
+         WRITE(*,*)'WARNING DP/P l=',l,'  MIN:',zdpmin,'   MAX:', zdpmax
+   END DO
+!$OMP END DO NOWAIT
+
+   !---------------------------------------------------------------------------
+   !   Advection proprement dite (Modification Le Croller (07/2001)
+   !---------------------------------------------------------------------------
+
+   !---------------------------------------------------------------------------
+   !   Calcul des moyennes basees sur la masse
+   !---------------------------------------------------------------------------
+!ym   CALL massbar_p(massem,massebx,masseby)
+!ym   ----> Normalement, inutile pour les schémas classiques
+!ym   ----> Revérifier lors de la parallélisation des autres schemas
+
+#ifdef DEBUG_IO    
+   CALL WriteField_u('massem',massem)
+   CALL WriteField_u('wg',wg)
+   CALL WriteField_u('pbarug',pbarug)
+   CALL WriteField_v('pbarvg',pbarvg)
+   CALL WriteField_u('p_tmp',p)
+   CALL WriteField_u('pk_tmp',pk)
+   CALL WriteField_u('teta_tmp',teta)
+   DO iq=1,nqtot
+      CALL WriteField_u('q_adv'//trim(int2str(iq)),q(:,:,iq))
+   END DO
+#endif
+
+!          
+!  CALL Register_Hallo_v(pbarvg,llm,1,1,1,1,TestRequest)
+!  CALL SendRequest(TestRequest)
+!!$OMP BARRIER
+!  CALL WaitRequest(TestRequest)
+!$OMP BARRIER
+                 
+!  WRITE(*,*) 'advtrac 157: appel de vlspltgen_loc'
+   CALL vlspltgen_loc(q, tracers(:)%iadv, 2., massem, wg, pbarug, pbarvg, dtvr, p, pk, teta )
+
+#ifdef DEBUG_IO     
+   DO iq = 1, nqtot
+      CALL WriteField_u('q_adv'//trim(int2str(iq)),q(:,:,iq))
+   END DO
+#endif
+         
+   GOTO 1234     
+   !-------------------------------------------------------------------------
+   !       Appel des sous programmes d'advection
+   !-------------------------------------------------------------------------
+   DO iq = 1, nqtot
+!     CALL clock(t_initial)
+      IF(tracers(iq)%parent /= 'air') CYCLE
+      iadv = tracers(iq)%iadv
+      !-----------------------------------------------------------------------
+      SELECT CASE(iadv)
+      !-----------------------------------------------------------------------
+         CASE(0); CYCLE
+         !--------------------------------------------------------------------
+         CASE(10)  !--- Schema de Van Leer I MUSCL
+         !--------------------------------------------------------------------
+!           WRITE(*,*) 'advtrac 239: iq,q(1721,19,:)=',iq,q(1721,19,:)     
+!LF         CALL vlsplt_p(q(1,1,iq),2.,massem,wg,pbarug,pbarvg,dtvr)
+
+         !--------------------------------------------------------------------
+         CASE(14)  !--- Schema "pseuDO amont" + test sur humidite specifique
+                   !--- pour la vapeur d'eau. F. Codron
+         !--------------------------------------------------------------------
+!           WRITE(*,*) 'advtrac 248: iq,q(1721,19,:)=',iq,q(1721,19,:)
+            STOP 'advtrac : appel a vlspltqs :schema non parallelise'
+!LF         CALL vlspltqs_p(q(1,1,1),2.,massem,wg,pbarug,pbarvg,dtvr,p,pk,teta )
+
+         !--------------------------------------------------------------------
+         CASE(12)  !--- Schema de Frederic Hourdin
+         !--------------------------------------------------------------------
+            CALL adaptdt(iadv,dtbon,n,pbarug,massem)   ! pas de temps adaptatif
+            IF(n > 1) WRITE(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=',dtvr,'n=',n
+            DO indice=1,n
+              CALL advn(q(1,1,iq),massem,wg,pbarug,pbarvg,dtbon,1)
+            END DO
+
+         !--------------------------------------------------------------------
+         CASE(13)  !--- Pas de temps adaptatif
+         !--------------------------------------------------------------------
+            STOP 'advtrac : schema non parallelise'
+            CALL adaptdt(iadv,dtbon,n,pbarug,massem)
+            IF(n > 1) WRITE(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=',dtvr,'n=',n
+            DO indice=1,n
+               CALL advn(q(1,1,iq),massem,wg,pbarug,pbarvg,dtbon,2)
+            END DO
+
+         !--------------------------------------------------------------------
+         CASE(20)  !--- Schema de pente SLOPES
+         !--------------------------------------------------------------------
+            STOP 'advtrac : schema non parallelise'
+            CALL pentes_ini (q(1,1,iq),wg,massem,pbarug,pbarvg,0)
+
+         !--------------------------------------------------------------------
+         CASE(30)  !--- Schema de Prather
+         !--------------------------------------------------------------------
+            STOP 'advtrac : schema non parallelise'
+            ! Pas de temps adaptatif
+            CALL adaptdt(iadv,dtbon,n,pbarug,massem)
+            IF(n > 1) WRITE(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=',dtvr,'n=',n
+            CALL prather(q(1,1,iq),wg,massem,pbarug,pbarvg,n,dtbon)
+
+         !--------------------------------------------------------------------
+         CASE(11,16,17,18)   !--- Schemas PPM Lin et Rood
+         !--------------------------------------------------------------------
+     	    STOP 'advtrac : schema non parallelise'
+            ! Test sur le flux horizontal
+            CALL adaptdt(iadv,dtbon,n,pbarug,massem)   ! pas de temps adaptatif
+            IF(n > 1) WRITE(*,*) 'WARNING horizontal dt=',dtbon,'dtvr=',dtvr,'n=',n
+            ! Test sur le flux vertical
+            CFLmaxz=0.
+            DO l=2,llm
+               DO ij=iip2,ip1jm
+                  aaa=wg(ij,l)*dtvr/massem(ij,l)
+                  CFLmaxz=max(CFLmaxz,aaa)
+                  bbb=-wg(ij,l)*dtvr/massem(ij,l-1)
+                  CFLmaxz=max(CFLmaxz,bbb)
+               END DO
+            END DO
+            IF(CFLmaxz.GE.1) WRITE(*,*) 'WARNING vertical','CFLmaxz=', CFLmaxz
+            !----------------------------------------------------------------
+            !     Ss-prg interface LMDZ.4->PPM3d (ss-prg de Lin)
+            !----------------------------------------------------------------
+            CALL interpre(q(1,1,iq),qppm(1,1,iq),wg,fluxwppm,massem, &
+                 apppm,bpppm,massebx,masseby,pbarug,pbarvg, &
+                 unatppm,vnatppm,psppm)
+
+            !----------------------------------------------------------------
+            DO indice=1,n     !--- VL (version PPM) horiz. et PPM vert.
+            !----------------------------------------------------------------
+               SELECT CASE(iadv)
+                  !----------------------------------------------------------
+                  CASE(11)
+                  !----------------------------------------------------------
+                     CALL ppm3d(1,qppm(1,1,iq),psppm,psppm,unatppm,vnatppm,fluxwppm,dtbon, &
+                                2,2,2,1,iim,jjp1,2,llm,apppm,bpppm,0.01,6400000,fill,dum,220.)
+                  !----------------------------------------------------------
+                  CASE(16) !--- Monotonic PPM
+                  !----------------------------------------------------------
+                     CALL ppm3d(1,qppm(1,1,iq),psppm,psppm,unatppm,vnatppm,fluxwppm,dtbon, &
+                                3,3,3,1,iim,jjp1,2,llm,apppm,bpppm,0.01,6400000,fill,dum,220.)
+                  !----------------------------------------------------------
+                  CASE(17) !--- Semi monotonic PPM
+                  !----------------------------------------------------------
+                     CALL ppm3d(1,qppm(1,1,iq),psppm,psppm,unatppm,vnatppm,fluxwppm,dtbon, &
+                                4,4,4,1,iim,jjp1,2,llm,apppm,bpppm,0.01,6400000, fill,dum,220.)
+                  !----------------------------------------------------------
+                  CASE(18) !--- Positive Definite PPM
+                  !----------------------------------------------------------
+                     CALL ppm3d(1,qppm(1,1,iq),psppm,psppm,unatppm,vnatppm,fluxwppm,dtbon, &
+                                5,5,5,1,iim,jjp1,2,llm,apppm,bpppm,0.01,6400000,fill,dum,220.)
+               END SELECT
+            !----------------------------------------------------------------
+            END DO
+            !----------------------------------------------------------------
+            !     Ss-prg interface PPM3d-LMDZ.4
+            !----------------------------------------------------------------
+            CALL interpost(q(1,1,iq),qppm(1,1,iq))
+      !----------------------------------------------------------------------
+      END SELECT
+      !----------------------------------------------------------------------
+
+      !----------------------------------------------------------------------
+      ! On impose une seule valeur du traceur au pôle Sud j=jjm+1=jjp1 et Nord j=1
+      !----------------------------------------------------------------------
+      !  CALL traceurpole(q(1,1,iq),massem)
+
+      !--- Calcul du temps cpu pour un schema donne
+      !  CALL clock(t_final)
+      !ym  tps_cpu=t_final-t_initial
+      !ym  cpuadv(iq)=cpuadv(iq)+tps_cpu
+
+   END DO
+
+1234 CONTINUE
+!$OMP BARRIER
+   IF(planet_type=="earth") THEN
+      ijb=ij_begin
+      ije=ij_end
+!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)      
+      DO l = 1, llm
+         DO ij = ijb, ije
+            finmasse(ij,l) =  p(ij,l) - p(ij,l+1) 
+         END DO
+      END DO
+!$OMP END DO
+
+      CALL qminimum_loc( q, nqtot, finmasse )
+
+   END IF ! of if (planet_type=="earth")
+
+END SUBROUTINE advtrac_loc
+
Index: /LMDZ6/trunk/libf/dyn3dmem/call_calfis_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/dyn3dmem/call_calfis_mod.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/dyn3dmem/call_calfis_mod.F90	(revision 4056)
@@ -113,5 +113,5 @@
     TYPE(Request),SAVE :: Request_physic
 !$OMP THREADPRIVATE(Request_physic )
-    INTEGER :: ijb,ije,l,j
+    INTEGER :: ijb,ije,l,iq
     
     
@@ -122,6 +122,6 @@
     CALL WriteField_u('pfi',p)
     CALL WriteField_u('pkfi',pk)
-    DO j=1,nqtot
-      CALL WriteField_u('qfi'//trim(int2str(j)),q(:,:,j))
+    DO iq=1,nqtot
+      CALL WriteField_u('qfi'//trim(int2str(iq)),q(:,:,iq))
     ENDDO
 #endif
@@ -223,6 +223,6 @@
     CALL WriteField_u('pfi',p)
     CALL WriteField_u('pkfi',pk)
-    DO j=1,nqtot
-      CALL WriteField_u('qfi'//trim(int2str(j)),q(:,:,j))
+    DO iq=1,nqtot
+      CALL WriteField_u('qfi'//trim(int2str(iq)),q(:,:,iq))
     ENDDO
 #endif
@@ -267,6 +267,6 @@
     CALL Register_Hallo_u(dpfi,1,1,0,0,1,Request_physic)
 
-    DO j=1,nqtot
-      CALL Register_Hallo_u(dqfi(:,:,j),llm,1,0,0,1,Request_physic)
+    DO iq=1,nqtot
+      CALL Register_Hallo_u(dqfi(:,:,iq),llm,1,0,0,1,Request_physic)
     ENDDO
         
@@ -305,6 +305,6 @@
     CALL WriteField_u('dtetafi',dtetafi)
     CALL WriteField_u('dpfi',dpfi)
-    DO j=1,nqtot
-      CALL WriteField_u('dqfi'//trim(int2str(j)),dqfi(:,:,j))
+    DO iq=1,nqtot
+      CALL WriteField_u('dqfi'//trim(int2str(iq)),dqfi(:,:,iq))
     ENDDO
 #endif
@@ -319,6 +319,6 @@
     CALL WriteField_u('tetafi',teta)
     CALL WriteField_u('psfi',ps)
-    DO j=1,nqtot
-      CALL WriteField_u('qfi'//trim(int2str(j)),q(:,:,j))
+    DO iq=1,nqtot
+      CALL WriteField_u('qfi'//trim(int2str(iq)),q(:,:,iq))
     ENDDO
 #endif
@@ -329,6 +329,6 @@
     CALL WriteField_u('tetafi',teta)
     CALL WriteField_u('psfi',ps)
-    DO j=1,nqtot
-      CALL WriteField_u('qfi'//trim(int2str(j)),q(:,:,j))
+    DO iq=1,nqtot
+      CALL WriteField_u('qfi'//trim(int2str(iq)),q(:,:,iq))
     ENDDO
 #endif
@@ -354,6 +354,6 @@
     CALL WriteField_u('tetafi',teta)
     CALL WriteField_u('psfi',ps)
-    DO j=1,nqtot
-      CALL WriteField_u('qfi'//trim(int2str(j)),q(:,:,j))
+    DO iq=1,nqtot
+      CALL WriteField_u('qfi'//trim(int2str(iq)),q(:,:,iq))
     ENDDO
 #endif
@@ -401,6 +401,6 @@
     CALL WriteField_u('tetafi',teta_dyn)
     CALL WriteField_u('psfi',ps_dyn)
-    DO j=1,nqtot
-      CALL WriteField_u('qfi'//trim(int2str(j)),q_dyn(:,:,j))
+    DO iq=1,nqtot
+      CALL WriteField_u('qfi'//trim(int2str(iq)),q_dyn(:,:,iq))
     ENDDO
 #endif
Index: /LMDZ6/trunk/libf/dyn3dmem/iniacademic_loc.F90
===================================================================
--- /LMDZ6/trunk/libf/dyn3dmem/iniacademic_loc.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/dyn3dmem/iniacademic_loc.F90	(revision 4056)
@@ -5,9 +5,9 @@
 
   USE filtreg_mod, ONLY: inifilr
+  USE infotrac,    ONLY: nqtot, niso_possibles, ok_isotopes, ok_iso_verif, tnat, alpha_ideal, &
+                         iqiso, tracers, iso_indnum
+  USE control_mod, ONLY: day_step,planet_type
   use exner_hyb_m, only: exner_hyb
   use exner_milieu_m, only: exner_milieu
-  USE infotrac, ONLY: nqtot, niso_possibles, ok_isotopes, ok_iso_verif, tnat, alpha_ideal, &
-                      iqiso, tracers, iso_indnum
-  USE control_mod, ONLY: day_step,planet_type
   USE parallel_lmdz, ONLY: ijb_u, ije_u, ijb_v, ije_v
 #ifdef CPP_IOIPSL
@@ -23,5 +23,4 @@
   USE temps_mod, ONLY: annee_ref, day_ini, day_ref
   USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
-
 
   !   Author:    Frederic Hourdin      original: 15/01/93
@@ -112,5 +111,5 @@
   ztot0      = 0.
   stot0      = 0.
-  ang0       = 0.      
+  ang0       = 0.
 
   if (llm == 1) then
@@ -143,8 +142,7 @@
         ps_glo(:)=preff
      endif
-     
+
      ! ground geopotential
      phis_glo(:)=0.
-
      CALL pression ( ip1jmp1, ap, bp, ps_glo, p       )
      if (pressure_exner) then
@@ -155,5 +153,4 @@
      CALL massdair(p,masse_glo)
   ENDIF
-
 
   if (llm == 1) then
@@ -281,11 +278,10 @@
         if (planet_type=="earth") then
            ! Earth: first two tracers will be water
-
            do iq=1,nqtot
               q(ijb_u:ije_u,:,iq)=0.
-!              IF(tracers(iq)%name == 'H2O'//Phases_sep//'g') q(ijb_u:ije_u,:,iq)=1.e-10
+!              IF(tracers(iq)%name == 'H2O'//phases_sep//'g') q(ijb_u:ije_u,:,iq)=1.e-10
 !              IF(tracers(iq)%name == 'H2O'//phases_sep//'l') q(ijb_u:ije_u,:,iq)=1.e-15
-              if (tracers(iq)%name == 'H2Ov') q(ijb_u:ije_u,:,iq)=1.e-10
-              if (tracers(iq)%name == 'H2Ol') q(ijb_u:ije_u,:,iq)=1.e-15
+              IF(tracers(iq)%name == 'H2Ov') q(ijb_u:ije_u,:,iq)=1.e-10
+              IF(tracers(iq)%name == 'H2Ol') q(ijb_u:ije_u,:,iq)=1.e-15
 
               ! CRisi: init des isotopes
@@ -293,6 +289,6 @@
               iName = tracers(iq)%iso_iName
               if (.NOT.ok_isotopes .OR. iName <= 0) CYCLE
-              iZone = tracers(iq)%iso_iZone
-              iPhase= tracers(iq)%iso_iPhase
+              iZone    = tracers(iq)%iso_iZone
+              iPhase   = tracers(iq)%iso_iPhase
               iqParent = tracers(iq)%iqParent
               if (iZone == 0) q(ijb_u:ije_u,:,iq) = q(ijb_u:ije_u,:,iqParent)*tnat(iName) &
@@ -304,7 +300,5 @@
         endif ! of if (planet_type=="earth")
 
-        if (ok_iso_verif) then
-           call check_isotopes(q,ijb_u,ije_u,'iniacademic_loc')
-        endif !if (ok_iso_verif) then
+        if (ok_iso_verif) call check_isotopes(q,ijb_u,ije_u,'iniacademic_loc')
 
         ! add random perturbation to temperature
Index: /LMDZ6/trunk/libf/dyn3dmem/leapfrog_loc.F
===================================================================
--- /LMDZ6/trunk/libf/dyn3dmem/leapfrog_loc.F	(revision 4055)
+++ /LMDZ6/trunk/libf/dyn3dmem/leapfrog_loc.F	(revision 4056)
@@ -664,7 +664,7 @@
         call WriteField_u('pkf',pkf)
         call WriteField_u('phis',phis)
-        do j=1,nqtot
-          call WriteField_u('q'//trim(int2str(j)),
-     .                q(:,:,j))
+        do iq=1,nqtot
+          call WriteField_u('q'//trim(int2str(iq)),
+     .                q(:,:,iq))
         enddo
       endif
Index: /LMDZ6/trunk/libf/dyn3dmem/vlspltgen_loc.F
===================================================================
--- /LMDZ6/trunk/libf/dyn3dmem/vlspltgen_loc.F	(revision 4055)
+++ /LMDZ6/trunk/libf/dyn3dmem/vlspltgen_loc.F	(revision 4056)
@@ -28,5 +28,5 @@
       USE VAMPIR
       ! CRisi: on rajoute variables utiles d'infotrac  
-      USE infotrac, ONLY : nqtot,nqperes, tracers,ok_iso_verif
+      USE infotrac, ONLY : nqtot, tracers,ok_iso_verif
       USE vlspltgen_mod
       USE comconst_mod, ONLY: cpp
@@ -196,10 +196,11 @@
 
 c$OMP BARRIER           
-!      DO iq=1,nqtot
-      DO iq=1,nqperes ! CRisi: on ne boucle que sur les pères= ceux qui sont transportés directement par l'air
-       !write(*,*) 'vlspltgen 192: iq,iadv=',iq,tracers(iq)%iadv
+      DO iq=1,nqtot
+        ! CRisi: on ne boucle que sur les pères= ceux qui sont transportés directement par l'air
+        IF(tracers(iq)%parent /= 'air') CYCLE
+        !write(*,*) 'vlspltgen 192: iq,iadv=',iq,tracers(iq)%iadv
 #ifdef DEBUG_IO    
-       CALL WriteField_u('zq',zq(:,:,iq))
-       CALL WriteField_u('zm',zm(:,:,iq)) 
+        CALL WriteField_u('zq',zq(:,:,iq))
+        CALL WriteField_u('zm',zm(:,:,iq)) 
 #endif
         SELECT CASE(tracers(iq)%iadv)
@@ -264,5 +265,5 @@
         END SELECT
       
-      enddo !DO iq=1,nqperes
+      enddo !DO iq=1,nqtot
       
       
@@ -288,5 +289,6 @@
       endif !if (ok_iso_verif) then
 
-      do iq=1,nqperes
+      do iq=1,nqtot
+        IF(tracers(iq)%parent /= 'air') CYCLE
         !write(*,*) 'vlspltgen 279: iq=',iq
 
@@ -328,6 +330,4 @@
       if (ok_iso_verif) then
            call check_isotopes(zq,ij_begin,ij_end,'vlspltgen_loc 326')
-      endif !if (ok_iso_verif) then        
-      if (ok_iso_verif) then
            ijb=ij_begin-2*iip1
            ije=ij_end+2*iip1
@@ -337,5 +337,6 @@
       endif !if (ok_iso_verif) then  
 
-      do iq=1,nqperes
+      do iq = 1, nqtot
+       IF(tracers(iq)%parent /= 'air') CYCLE
        !write(*,*) 'vlspltgen 321: iq=',iq
 #ifdef DEBUG_IO    
@@ -358,5 +359,6 @@
       endif !if (ok_iso_verif) then
 
-      do iq=1,nqperes
+      do iq = 1, nqtot
+       IF(tracers(iq)%parent /= 'air') CYCLE
       !write(*,*) 'vlspltgen 349: iq=',iq
 #ifdef DEBUG_IO    
@@ -419,5 +421,6 @@
 
 c$OMP BARRIER
-      do iq=1,nqperes
+      do iq=1,nqtot
+        IF(tracers(iq)%parent /= 'air') CYCLE
       !write(*,*) 'vlspltgen 409: iq=',iq
 
@@ -462,5 +465,6 @@
       endif !if (ok_iso_verif) then
 
-      do iq=1,nqperes
+      do iq=1,nqtot
+        IF(tracers(iq)%parent /= 'air') CYCLE
       !write(*,*) 'vlspltgen 449: iq=',iq
 #ifdef DEBUG_IO    
@@ -475,5 +479,5 @@
         END SELECT
        
-       enddo !do iq=1,nqperes
+       enddo !do iq=1,nqtot
 
       if (ok_iso_verif) then
@@ -481,5 +485,6 @@
       endif !if (ok_iso_verif) then
 
-      do iq=1,nqperes
+      do iq=1,nqtot
+        IF(tracers(iq)%parent /= 'air') CYCLE
       !write(*,*) 'vlspltgen 477: iq=',iq
 #ifdef DEBUG_IO    
@@ -496,5 +501,5 @@
         END SELECT
        
-       enddo !do iq=1,nqperes
+       enddo !do iq=1,nqtot
 
       !write(*,*) 'vlspltgen 550: apres derniere serie de call vlx'
Index: /LMDZ6/trunk/libf/dynphy_lonlat/calfis.F
===================================================================
--- /LMDZ6/trunk/libf/dynphy_lonlat/calfis.F	(revision 4055)
+++ /LMDZ6/trunk/libf/dynphy_lonlat/calfis.F	(revision 4056)
@@ -29,5 +29,5 @@
 c    Auteur :  P. Le Van, F. Hourdin 
 c   .........
-      USE infotrac, ONLY: nqtot, niadv, tracers
+      USE infotrac, ONLY: nqtot, tracers
       USE control_mod, ONLY: planet_type, nsplit_phys
 #ifdef CPP_PHYS
@@ -135,5 +135,5 @@
 c    -----------------
 
-      INTEGER i,j,l,ig0,ig,iq,iiq
+      INTEGER i,j,l,ig0,ig,iq,itr
       REAL zpsrf(ngridmx)
       REAL zplev(ngridmx,llm+1),zplay(ngridmx,llm)
@@ -281,16 +281,18 @@
 c   ---------------
 c
+      itr=0
       DO iq=1,nqtot
-          iiq=niadv(iq) 
+         IF(.NOT.tracers(iq)%isAdvected) CYCLE
+         itr = itr + 1
          DO l=1,llm
-            zqfi(1,l,iq) = pq(1,1,l,iiq)
-            ig0          = 2
+            zqfi(1,l,itr) = pq(1,1,l,iq)
+            ig0           = 2
             DO j=2,jjm
                DO i = 1, iim
-                  zqfi(ig0,l,iq)  = pq(i,j,l,iiq)
+                  zqfi(ig0,l,itr) = pq(i,j,l,iq)
                   ig0             = ig0 + 1
                ENDDO
             ENDDO
-            zqfi(ig0,l,iq) = pq(1,jjp1,l,iiq)
+            zqfi(ig0,l,itr) = pq(1,jjp1,l,iq)
          ENDDO
       ENDDO
@@ -481,4 +483,5 @@
          lafin_split=lafin.and.isplit==nsplit_phys
 
+!      if (planet_type=="earth") then
         CALL call_physiq(ngridmx,llm,nqtot,tracers(:)%name,
      &                   debut_split,lafin_split,
@@ -490,30 +493,4 @@
      &                   flxwfi,pducov,
      &                   zdufi,zdvfi,zdtfi,zdqfi,zdpsrf)
-                             
-!      if (planet_type=="earth") then
-!
-!         CALL physiq (ngridmx,
-!     .             llm,
-!     .             debut_split,
-!     .             lafin_split,
-!     .             jD_cur,
-!     .             jH_cur_split,
-!     .             zdt_split,
-!     .             zplev,
-!     .             zplay,
-!     .             zphi,
-!     .             zphis,
-!     .             presnivs,
-!     .             zufi,
-!     .             zvfi, zrfi,
-!     .             ztfi,
-!     .             zqfi,
-!     .             flxwfi,
-!     .             zdufi,
-!     .             zdvfi,
-!     .             zdtfi,
-!     .             zdqfi,
-!     .             zdpsrf,
-!     .             pducov)
 !
 !      else if ( planet_type=="generic" ) then
@@ -622,17 +599,19 @@
       pdqfi(:,:,:,:)=0.
 C
+      itr = 0
       DO iq=1,nqtot
-         iiq=niadv(iq)
+         IF(.NOT.tracers(iq)%isAdvected) CYCLE
+         itr = itr + 1
          DO l=1,llm
             DO i=1,iip1
-               pdqfi(i,1,l,iiq)    = zdqfi(1,l,iq)
-               pdqfi(i,jjp1,l,iiq) = zdqfi(ngridmx,l,iq)
+               pdqfi(i,1,l,iq)    = zdqfi(1,l,itr)
+               pdqfi(i,jjp1,l,iq) = zdqfi(ngridmx,l,itr)
             ENDDO
             DO j=2,jjm
                ig0=1+(j-2)*iim
                DO i=1,iim
-                  pdqfi(i,j,l,iiq) = zdqfi(ig0+i,l,iq)
+                  pdqfi(i,j,l,iq) = zdqfi(ig0+i,l,itr)
                ENDDO
-               pdqfi(iip1,j,l,iiq) = pdqfi(1,j,l,iq)
+               pdqfi(iip1,j,l,iq) = pdqfi(1,j,l,itr)
             ENDDO
          ENDDO
Index: /LMDZ6/trunk/libf/dynphy_lonlat/calfis_loc.F
===================================================================
--- /LMDZ6/trunk/libf/dynphy_lonlat/calfis_loc.F	(revision 4055)
+++ /LMDZ6/trunk/libf/dynphy_lonlat/calfis_loc.F	(revision 4056)
@@ -45,5 +45,5 @@
       USE Times
 #endif
-      USE infotrac, ONLY: nqtot, niadv, tracers
+      USE infotrac, ONLY: nqtot, tracers
       USE control_mod, ONLY: planet_type, nsplit_phys
 #ifdef CPP_PHYS
@@ -154,5 +154,5 @@
 c    -----------------
 
-      INTEGER i,j,l,ig0,ig,iq,iiq
+      INTEGER i,j,l,ig0,ig,iq,itr
       REAL,ALLOCATABLE,SAVE :: zpsrf(:)
       REAL,ALLOCATABLE,SAVE :: zplev(:,:),zplay(:,:)
@@ -366,6 +366,8 @@
 c
 
+      itr = 0
       DO iq=1,nqtot
-         iiq=niadv(iq)
+         IF(.NOT.tracers(iq)%isAdvected) CYCLE
+         itr = itr + 1
 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
          DO l=1,llm
@@ -375,5 +377,5 @@
              i=index_i(ig0)
              j=index_j(ig0)
-             zqfi(ig0,l,iq)  = pq(i,j,l,iiq)
+             zqfi(ig0,l,itr)  = pq(i,j,l,iq)
            enddo
          ENDDO
@@ -1069,6 +1071,8 @@
 C
 !cdir NODEP
+      itr = 0
       DO iq=1,nqtot
-         iiq=niadv(iq)
+         IF(.NOT.tracers(iq)%isAdvected) CYCLE
+         itr = itr + 1
 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
          DO l=1,llm
@@ -1079,11 +1083,11 @@
               i=index_i(ig0)
               j=index_j(ig0)
-              pdqfi(i,j,l,iiq) = zdqfi(ig0,l,iq)
-              if (i==1) pdqfi(iip1,j,l,iiq) = zdqfi(ig0,l,iq)
+              pdqfi(i,j,l,iq) = zdqfi(ig0,l,itr)
+              if (i==1) pdqfi(iip1,j,l,iq) = zdqfi(ig0,l,itr)
             ENDDO
             
             IF (is_north_pole_dyn) then
               DO i=1,iip1
-                pdqfi(i,1,l,iiq)    = zdqfi(1,l,iq)
+                pdqfi(i,1,l,iq)    = zdqfi(1,l,itr)
               ENDDO
             ENDIF
@@ -1091,5 +1095,5 @@
             IF (is_south_pole_dyn) then
               DO i=1,iip1
-                pdqfi(i,jjp1,l,iiq) = zdqfi(klon,l,iq)
+                pdqfi(i,jjp1,l,iq) = zdqfi(klon,l,itr)
               ENDDO
             ENDIF
Index: /LMDZ6/trunk/libf/dynphy_lonlat/phylmd/iniphysiq_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/dynphy_lonlat/phylmd/iniphysiq_mod.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/dynphy_lonlat/phylmd/iniphysiq_mod.F90	(revision 4056)
@@ -17,12 +17,12 @@
   USE vertical_layers_mod, ONLY : init_vertical_layers
   USE infotrac, ONLY: nqtot,nqo,nbtr,nqCO2,tracers,type_trac,&
-                      niadv,conv_flg,pbl_flg,solsym,&
+                      conv_flg,pbl_flg,solsym,&
                       ok_isotopes,ok_iso_verif,ok_isotrac,&
                       ok_init_iso,niso_possibles,tnat,&
                       alpha_ideal,use_iso,iqiso,iso_indnum,&
                       indnum_fn_num,index_trac,&
-                      niso,ntraceurs_zone,ntraciso,nqtottr,itr_indice
+                      niso,ntraceurs_zone,ntraciso,nqtottr
 #ifdef CPP_StratAer
-  USE infotrac, ONLY: nbtr_bin, nbtr_sulgas, id_OCS_strat, &
+  USE infotrac_phy, ONLY: nbtr_bin, nbtr_sulgas, id_OCS_strat, &
                       id_SO2_strat, id_H2SO4_strat, id_BIN01_strat
 
@@ -145,15 +145,10 @@
   ! Initialize tracer names, numbers, etc. for physics
   CALL init_infotrac_phy(nqtot,nqo,nbtr,nqtottr,nqCO2,tracers,type_trac,&
-                         niadv,conv_flg,pbl_flg,solsym,&
+                         conv_flg,pbl_flg,solsym,&
                          ok_isotopes,ok_iso_verif,ok_isotrac,&
                          ok_init_iso,niso_possibles,tnat,&
                          alpha_ideal,use_iso,iqiso,iso_indnum,&
                          indnum_fn_num,index_trac,&
-                         niso,ntraceurs_zone,ntraciso,itr_indice &
-#ifdef CPP_StratAer
-                         ,nbtr_bin,nbtr_sulgas&
-                         ,id_OCS_strat,id_SO2_strat,id_H2SO4_strat,id_BIN01_strat&
-#endif
-                         )
+                         niso,ntraceurs_zone,ntraciso)
 
   ! Initializations for Reprobus
Index: /LMDZ6/trunk/libf/phylmd/Dust/phys_output_write_spl_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/Dust/phys_output_write_spl_mod.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmd/Dust/phys_output_write_spl_mod.F90	(revision 4056)
@@ -381,5 +381,5 @@
     USE pbl_surface_mod, ONLY: snow
     USE indice_sol_mod, ONLY: nbsrf
-    USE infotrac, ONLY: nqtot, nqo, nbtr, type_trac
+    USE infotrac, ONLY: nqtot, nbtr, type_trac
     USE geometry_mod, ONLY: cell_area
     USE surface_data, ONLY: type_ocean, version_ocean, ok_veget, landice_opt
@@ -430,5 +430,5 @@
     INTEGER, PARAMETER :: jjmp1=jjm+1-1/jjm
     INTEGER :: itau_w
-    INTEGER :: i, iinit, iinitend=1, iff, iq, nsrf, k, ll, naero
+    INTEGER :: i, iinit, iinitend=1, iff, iq, itr, nsrf, k, ll, naero
     REAL, DIMENSION (klon) :: zx_tmp_fi2d
     REAL, DIMENSION (klon,klev) :: zx_tmp_fi3d, zpt_conv
@@ -1610,35 +1610,32 @@
 #endif
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-       IF (nqtot.GE.nqo+1) THEN
-         !AS: type_trac = 'lmdz' par defaut dans libf/dyn3d/conf_gcm.F90
-         !Changé par inca, repr(obus), coag(ulation), co2i(nteractif), PAS par SPLA
-         !Cet "if" est donc inutile : IF (type_trac == 'lmdz' .OR. type_trac == 'repr') THEN
-           DO iq=nqo+1,nqtot
-             CALL histwrite_phy(o_trac(iq-nqo), tr_seri(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_vdf(iq-nqo),d_tr_cl(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_the(iq-nqo),d_tr_th(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_con(iq-nqo),d_tr_cv(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_lessi_impa(iq-nqo),d_tr_lessi_impa(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_lessi_nucl(iq-nqo),d_tr_lessi_nucl(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_insc(iq-nqo),d_tr_insc(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_bcscav(iq-nqo),d_tr_bcscav(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_evapls(iq-nqo),d_tr_evapls(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_ls(iq-nqo),d_tr_ls(:,:,iq-nqo))
-!            CALL histwrite_phy(o_dtr_dyn(iq-nqo),d_tr_dyn(:,:,iq-nqo))
-!            CALL histwrite_phy(o_dtr_cl(iq-nqo),d_tr_cl(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_trsp(iq-nqo),d_tr_trsp(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_sscav(iq-nqo),d_tr_sscav(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_sat(iq-nqo),d_tr_sat(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_uscav(iq-nqo),d_tr_uscav(:,:,iq-nqo))
+           itr = 0
+           DO iq = 1, nqtot
+             IF(tracers(iq)%isH2Ofamily) CYCLE
+             itr = itr+1
+             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))
+             CALL histwrite_phy(o_dtr_lessi_impa(itr),d_tr_lessi_impa(:,:,itr))
+             CALL histwrite_phy(o_dtr_lessi_nucl(itr),d_tr_lessi_nucl(:,:,itr))
+             CALL histwrite_phy(o_dtr_insc(itr),d_tr_insc(:,:,itr))
+             CALL histwrite_phy(o_dtr_bcscav(itr),d_tr_bcscav(:,:,itr))
+             CALL histwrite_phy(o_dtr_evapls(itr),d_tr_evapls(:,:,itr))
+             CALL histwrite_phy(o_dtr_ls(itr),d_tr_ls(:,:,itr))
+!            CALL histwrite_phy(o_dtr_dyn(itr),d_tr_dyn(:,:,itr))
+!            CALL histwrite_phy(o_dtr_cl(itr),d_tr_cl(:,:,itr))
+             CALL histwrite_phy(o_dtr_trsp(itr),d_tr_trsp(:,:,itr))
+             CALL histwrite_phy(o_dtr_sscav(itr),d_tr_sscav(:,:,itr))
+             CALL histwrite_phy(o_dtr_sat(itr),d_tr_sat(:,:,itr))
+             CALL histwrite_phy(o_dtr_uscav(itr),d_tr_uscav(:,:,itr))
              zx_tmp_fi2d=0.
              IF (vars_defined) THEN
                 DO k=1,klev
-                   zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+zmasse(:,k)*tr_seri(:,k,iq-nqo)
+                   zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+zmasse(:,k)*tr_seri(:,k,itr)
                 ENDDO
              ENDIF
-             CALL histwrite_phy(o_trac_cum(iq-nqo), zx_tmp_fi2d)
+             CALL histwrite_phy(o_trac_cum(itr), zx_tmp_fi2d)
            ENDDO
-         !ENDIF
-       ENDIF
 
        IF (.NOT.vars_defined) THEN
Index: /LMDZ6/trunk/libf/phylmd/Dust/phytracr_spl_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/Dust/phytracr_spl_mod.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmd/Dust/phytracr_spl_mod.F90	(revision 4056)
@@ -1104,5 +1104,5 @@
       REAL, intent(in) ::  rlon(klon)       ! longitudes pour chaque point 
 !
-      INTEGER i, k, it, j, ig 
+      INTEGER i, k, iq, itr, j, ig 
 !
 ! DEFINITION OF DIAGNOSTIC VARIABLES
@@ -1260,7 +1260,10 @@
 
 #ifdef IOPHYS_DUST
-      do it=1,nbtr
-         write(str2,'(i2.2)') it
-         call iophys_ecrit('TRA'//str2,klev,'SOURCE','',tr_seri(:,:,it))
+      itr = 0
+      DO iq = 1, nqtot
+         IF(tracers(iq)%isH2Ofamily) CYCLE
+         itr = itr+1
+         write(str2,'(i2.2)') itr
+         call iophys_ecrit('TRA'//str2,klev,'SOURCE','',tr_seri(:,:,itr))
       enddo
 #endif
@@ -1414,21 +1417,23 @@
         id_codu=-1
         id_scdu=-1
-       !print *,nbtr
-       do it=1,nbtr
-        print *, it, tracers(it+nqo)%name
-        SELECT CASE(tracers(it+nqo)%name)
-          CASE('PREC'); id_prec=it
-          CASE('FINE'); id_fine=it
-          CASE('COSS'); id_coss=it
-          CASE('CODU'); id_codu=it
-          CASE('SCDU'); id_scdu=it
-        END SELECT
-       enddo
-       ! check consistency with dust emission scheme:
-       if (ok_chimeredust) then
+        itr = 0
+        do iq=1,nqtot
+          IF(tracers(iq)%isH2Ofamily) CYCLE
+          itr = itr+1
+          print *, itr, TRIM(tracers(iq)%name)
+          SELECT CASE(tracers(iq)%name)
+            CASE('PREC'); id_prec=itr
+            CASE('FINE'); id_fine=itr
+            CASE('COSS'); id_coss=itr
+            CASE('CODU'); id_codu=itr
+            CASE('SCDU'); id_scdu=itr
+          END SELECT
+        enddo
+        ! check consistency with dust emission scheme:
+        if (ok_chimeredust) then
           if (.not.( id_scdu>0 .and. id_codu>0 .and. id_fine>0)) then
              call abort_gcm('phytracr_mod', 'pb in ok_chimdust 0',1)
           endif
-       else 
+        else 
           if (id_scdu>0) then 
        call abort_gcm('phytracr_mod', 'pb in ok_chimdust 1 SCDU',1)
@@ -1560,9 +1565,9 @@
 ! JE before put in zero
       IF (lminmax) THEN
-        DO it=1,nbtr
-        CALL checknanqfi(tr_seri(:,:,it),qmin,qmax,'nan init phytracr')
-        ENDDO        
-        DO it=1,nbtr
-        CALL minmaxqfi2(tr_seri(:,:,it),qmin,qmax,'minmax init phytracr')
+        DO itr=1,nbtr
+        CALL checknanqfi(tr_seri(:,:,itr),qmin,qmax,'nan init phytracr')
+        ENDDO
+        DO itr=1,nbtr
+        CALL minmaxqfi2(tr_seri(:,:,itr),qmin,qmax,'minmax init phytracr')
         ENDDO
         CALL minmaxsource(source_tr,qmin,qmax,'maxsource init phytracr')
Index: /LMDZ6/trunk/libf/phylmd/Dust/splaeropt_5wv_rrtm.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/Dust/splaeropt_5wv_rrtm.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmd/Dust/splaeropt_5wv_rrtm.F90	(revision 4056)
@@ -9,5 +9,5 @@
   USE DIMPHY
   USE aero_mod
-  USE infotrac_phy
+  USE infotrac_phy, ONLY: nqtot, nbtr, tracers
   USE phys_local_var_mod, ONLY: od550aer,od865aer,ec550aer,od550lt1aer
   !
@@ -34,5 +34,5 @@
   LOGICAL :: soluble
   
-  INTEGER :: i, k, m, itr, irh, aerindex
+  INTEGER :: i, k, m, iq, itr, irh, aerindex
   INTEGER :: spsol, spinsol, la
   INTEGER :: RH_num(klon,klev)
@@ -112,6 +112,9 @@
   ENDDO
 
-  DO itr=1,nbtr    !--loop over tracers  
-    SELECT CASE(tracers(itr+nqo)%name)
+  itr = 0
+  DO iq = 1, nqtot
+    IF(tracers(iq)%isH2Ofamily) CYCLE
+    itr = itr+1
+    SELECT CASE(tracers(iq)%name)
       CASE('PREC'); CYCLE                                  !--precursor
       CASE('FINE'); soluble=.TRUE.;  spsol=1; aerindex=1   !--fine mode accumulation mode
@@ -119,5 +122,5 @@
       CASE('CODU'); soluble=.FALSE.; spsol=1; aerindex=3   !--coarse mode dust
       CASE('SCDU'); soluble=.FALSE.; spsol=2; aerindex=4   !--super coarse mode dust
-      CASE DEFAULT; CALL abort_physic(modname,'I cannot do aerosol optics for '//tracers(itr+nqo)%name,1)
+      CASE DEFAULT; CALL abort_physic(modname,'I cannot do aerosol optics for '//tracers(iq)%name,1)
     END SELECT
 
Index: /LMDZ6/trunk/libf/phylmd/Dust/splaeropt_6bands_rrtm.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/Dust/splaeropt_6bands_rrtm.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmd/Dust/splaeropt_6bands_rrtm.F90	(revision 4056)
@@ -8,5 +8,5 @@
   USE dimphy
   USE aero_mod
-  USE infotrac_phy
+  USE infotrac_phy, ONLY: nqtot, nbtr, tracers
   USE phys_local_var_mod, ONLY: abs550aer
 
@@ -35,5 +35,5 @@
   !
   LOGICAL :: soluble
-  INTEGER :: i, k, irh, itr, inu
+  INTEGER :: i, k, irh, iq, itr, inu
   INTEGER :: aerindex, spsol, spinsol
   INTEGER :: RH_num(klon,klev)
@@ -165,6 +165,9 @@
   cg_ae(:,:,:,:)=0.
     
-  DO itr=1,nbtr    !--loop over tracers  
-    SELECT CASE(tracers(itr+nqo)%name)
+  itr = 0
+  DO iq = 1, nqtot
+    IF(tracers(iq)%isH2Ofamily) CYCLE
+    itr = itr+1
+    SELECT CASE(tracers(iq)%name)
       CASE('PREC'); CYCLE                                  !--precursor
       CASE('FINE'); soluble=.TRUE.;  spsol=1; aerindex=1   !--fine mode accumulation mode
@@ -172,5 +175,5 @@
       CASE('CODU'); soluble=.FALSE.; spsol=1; aerindex=3   !--coarse mode dust
       CASE('SCDU'); soluble=.FALSE.; spsol=2; aerindex=4   !--super coarse mode dust
-      CASE DEFAULT; CALL abort_physic(modname,'I cannot do aerosol optics for '//tracers(itr+nqo)%name,1)
+      CASE DEFAULT; CALL abort_physic(modname,'I cannot do aerosol optics for '//tracers(iq)%name,1)
     END SELECT
 
Index: /LMDZ6/trunk/libf/phylmd/Dust/splaeropt_lw_rrtm.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/Dust/splaeropt_lw_rrtm.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmd/Dust/splaeropt_lw_rrtm.F90	(revision 4056)
@@ -10,5 +10,5 @@
   USE dimphy
   USE aero_mod
-  USE infotrac_phy
+  USE infotrac_phy, ONLY: nqtot, nbtr, tracers
   USE phys_state_var_mod, ONLY : tau_aero_lw_rrtm
   USE YOERAD, ONLY : NLW
@@ -30,5 +30,5 @@
   INTEGER, PARAMETER :: naero=naero_soluble+naero_insoluble
   !
-  INTEGER inu, itr, spinsol
+  INTEGER inu, itr, iq, spinsol
   CHARACTER*20 modname
   !
@@ -54,10 +54,14 @@
     tau_aero_lw_rrtm = 0.0
     !
-    DO itr=1,nbtr
-      SELECT CASE(tracers(itr+nqo)%name)
-        CASE('PREC','FINE''COSS'); CYCLE                   !--precursor or fine/coarde accumulation mode
+    
+    itr = 0
+    DO iq = 1, nqtot
+      IF(tracers(iq)%isH2Ofamily) CYCLE
+      itr = itr+1
+      SELECT CASE(tracers(iq)%name)
+        CASE('PREC','FINE','COSS'); CYCLE                  !--precursor or fine/coarde accumulation mode
         CASE('CODU'); spinsol=1                            !--coarse mode dust
         CASE('SCDU'); spinsol=2                            !--super coarse mode dust
-        CASE DEFAULT; CALL abort_physic(modname,'I cannot do aerosol optics for '//tracers(itr+nqo)%name,1)
+        CASE DEFAULT; CALL abort_physic(modname,'I cannot do aerosol optics for '//tracers(iq)%name,1)
       END SELECT
       !
Index: /LMDZ6/trunk/libf/phylmd/Dust/splaerosol_optic_rrtm.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/Dust/splaerosol_optic_rrtm.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmd/Dust/splaerosol_optic_rrtm.F90	(revision 4056)
@@ -13,5 +13,5 @@
   USE dimphy
   USE aero_mod
-  USE infotrac_phy
+  USE infotrac_phy, ONLY: nbtr, nqtot, tracers
   USE YOMCST, ONLY: RD, RG
 
@@ -40,5 +40,5 @@
   REAL, DIMENSION(klon,klev,nwave,naero_tot), INTENT(OUT)  :: tau3d_aero
 
-  INTEGER i, k, itr
+  INTEGER i, k, iq, itr
   REAL, DIMENSION(klon,klev) :: zdm, zdh
   REAL zrho, pdel
@@ -50,6 +50,9 @@
   mass_solu_aero_pi(:,:) = 0.0
   !
-  DO itr=1,nbtr
-    IF (tracers(itr+nqo)%name=='FINE') THEN
+  itr = 0
+  DO iq = 1, nqtot
+    IF(tracers(iq)%isH2Ofamily) CYCLE
+    itr = itr+1
+    IF(tracers(iq)%name/='FINE') THEN
       mass_solu_aero(:,:)    = tr_seri(:,:,itr)
       mass_solu_aero_pi(:,:) = tr_seri(:,:,itr)
Index: /LMDZ6/trunk/libf/phylmd/infotrac_phy.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/infotrac_phy.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmd/infotrac_phy.F90	(revision 4056)
@@ -26,29 +26,19 @@
 !$OMP THREADPRIVATE(nqtottr)
 
-! ThL : number of CO2 tracers			ModThL
+! ThL : number of CO2 tracers   ModThL
   INTEGER, SAVE :: nqCO2
 !$OMP THREADPRIVATE(nqCO2)
 
 #ifdef CPP_StratAer
-! nbtr_bin: number of aerosol bins for StratAer model
-! nbtr_sulgas: number of sulfur gases for StratAer model
-  INTEGER, SAVE :: nbtr_bin, nbtr_sulgas
-!$OMP THREADPRIVATE(nbtr_bin,nbtr_sulgas)
-  INTEGER, SAVE :: id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat
-!$OMP THREADPRIVATE(id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat)
+  !=== SPECIFIC TO STRATOSPHERIC AEROSOLS (CK/OB)
+  INTEGER, SAVE ::  nbtr_bin, nbtr_sulgas         !--- number of aerosols bins and sulfur gases for StratAer model
+!$OMP THREADPRIVATE(nbtr_bin, nbtr_sulgas)
+  INTEGER, SAVE ::  id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat, id_TEST_strat
+!$OMP THREADPRIVATE(id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat, id_TEST_strat)
 #endif
-
-! CRisi: nb traceurs pères= directement advectés par l'air
-  INTEGER, SAVE :: nqperes
-!$OMP THREADPRIVATE(nqperes)
 
 ! Tracers parameters
   TYPE(trac_type), TARGET, ALLOCATABLE, SAVE :: tracers(:)
 !$OMP THREADPRIVATE(tracers)
-
-! niadv : vector keeping the coorspondance between all tracers(nqtot) treated in the 
-!         dynamic part of the code and the tracers (nbtr+2) used in the physics part of the code. 
-  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE    :: niadv ! equivalent dyn / physique
-!$OMP THREADPRIVATE(niadv)
 
 ! conv_flg(it)=0 : convection desactivated for tracer number it 
@@ -85,21 +75,13 @@
 !$OMP THREADPRIVATE(niso,ntraceurs_zone,ntraciso)
 
-    INTEGER, ALLOCATABLE, DIMENSION(:), SAVE ::  itr_indice ! numéro iq entre 1 et nqtot qui correspond au traceur itr entre 1 et nqtottr
-!$OMP THREADPRIVATE(itr_indice)
- 
 CONTAINS
 
   SUBROUTINE init_infotrac_phy(nqtot_,nqo_,nbtr_,nqtottr_,nqCO2_,tracers_,type_trac_,&
-                               niadv_,conv_flg_,pbl_flg_,solsym_,&
+                               conv_flg_,pbl_flg_,solsym_,&
                                ok_isotopes_,ok_iso_verif_,ok_isotrac_,&
                                ok_init_iso_,niso_possibles_,tnat_,&
                                alpha_ideal_,use_iso_,iqiso_,iso_indnum_,&
                                indnum_fn_num_,index_trac_,&
-                               niso_,ntraceurs_zone_,ntraciso_,itr_indice_&
-#ifdef CPP_StratAer
-                               ,nbtr_bin_,nbtr_sulgas_&
-                               ,id_OCS_strat_,id_SO2_strat_,id_H2SO4_strat_,id_BIN01_strat_&
-#endif
-                               )
+                               niso_,ntraceurs_zone_,ntraciso_)
 
     ! transfer information on tracers from dynamics to physics
@@ -112,15 +94,6 @@
     INTEGER,INTENT(IN) :: nqtottr_
     INTEGER,INTENT(IN) :: nqCO2_
-#ifdef CPP_StratAer
-    INTEGER,INTENT(IN) :: nbtr_bin_
-    INTEGER,INTENT(IN) :: nbtr_sulgas_
-    INTEGER,INTENT(IN) :: id_OCS_strat_
-    INTEGER,INTENT(IN) :: id_SO2_strat_
-    INTEGER,INTENT(IN) :: id_H2SO4_strat_
-    INTEGER,INTENT(IN) :: id_BIN01_strat_
-#endif
     TYPE(trac_type), INTENT(IN) :: tracers_(nqtot_) ! tracers descriptors
     CHARACTER(len=*),INTENT(IN) :: type_trac_
-    INTEGER,INTENT(IN) :: niadv_ (nqtot_) ! equivalent dyn / physique
     INTEGER,INTENT(IN) :: conv_flg_(nbtr_)
     INTEGER,INTENT(IN) :: pbl_flg_(nbtr_)
@@ -142,7 +115,8 @@
     INTEGER,INTENT(IN) :: ntraceurs_zone_
     INTEGER,INTENT(IN) :: ntraciso_
-    INTEGER,INTENT(IN) :: itr_indice_(nqtottr_)
-
-    CHARACTER(LEN=30) :: modname="init_infotrac_phy"
+
+    INTEGER :: iq, itr
+    CHARACTER(LEN=maxlen), ALLOCATABLE :: tnames(:)
+    CHARACTER(LEN=maxlen) :: modname="init_infotrac_phy"
 
     nqtot=nqtot_
@@ -153,14 +127,23 @@
     ALLOCATE(tracers(nqtot)); tracers(:) = tracers_(:)
 #ifdef CPP_StratAer
-    nbtr_bin=nbtr_bin_
-    nbtr_sulgas=nbtr_sulgas_
-    id_OCS_strat=id_OCS_strat_
-    id_SO2_strat=id_SO2_strat_
-    id_H2SO4_strat=id_H2SO4_strat_
-    id_BIN01_strat=id_BIN01_strat_
+    IF (type_trac == 'coag') THEN
+      nbtr_bin    = COUNT([(tracers(iq)%name(1:3)=='BIN', iq=1, nqtot)])
+      nbtr_sulgas = COUNT([(tracers(iq)%name(1:3)=='GAS', iq=1, nqtot)])
+      tnames = PACK(tracers(:)%name, MASK=.NOT.tracers(:)%isH2Ofamily)
+      id_BIN01_strat = strIdx(tnames, 'BIN01'   )
+      id_OCS_strat   = strIdx(tnames, 'GASOSC'  )
+      id_SO2_strat   = strIdx(tnames, 'GASSO2'  )
+      id_H2SO4_strat = strIdx(tnames, 'GASH2SO4')
+      id_TEST_strat  = strIdx(tnames, 'GASTEST' )
+      WRITE(lunout,*)'nbtr_bin       =', nbtr_bin
+      WRITE(lunout,*)'nbtr_sulgas    =', nbtr_sulgas
+      WRITE(lunout,*)'id_BIN01_strat =', id_BIN01_strat
+      WRITE(lunout,*)'id_OCS_strat   =',   id_OCS_strat
+      WRITE(lunout,*)'id_SO2_strat   =',   id_SO2_strat
+      WRITE(lunout,*)'id_H2SO4_strat =', id_H2SO4_strat
+      WRITE(lunout,*)'id_TEST_strat  =',  id_TEST_strat
+    END IF
 #endif
     type_trac = type_trac_
-    ALLOCATE(niadv(nqtot))
-    niadv(:)=niadv_(:)
     ALLOCATE(conv_flg(nbtr))
     conv_flg(:)=conv_flg_(:)
@@ -207,7 +190,11 @@
     ENDIF ! of IF(ok_isotopes)
 
-    ALLOCATE(itr_indice(nqtottr))
-    itr_indice(:)=itr_indice_(:)
-  
+    WRITE(*,*) 'infotrac_phy 207: nqtottr=',nqtottr
+    WRITE(*,*) 'ntraciso,niso=',ntraciso,niso
+#ifdef ISOVERIF
+    ! DC: the "1" will be replaced by iH2O (H2O isotopes group index)
+    WRITE(*,*) 'iso_iName=',PACK(tracers(:)%iso_iName, MASK=tracers(:)%iso_iGroup==1)
+#endif
+
   END SUBROUTINE init_infotrac_phy
 
Index: /LMDZ6/trunk/libf/phylmd/init_be.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/init_be.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmd/init_be.F90	(revision 4056)
@@ -5,5 +5,4 @@
 
   USE dimphy
-  USE infotrac_phy, ONLY : nbtr
   USE indice_sol_mod
   USE geometry_mod, ONLY : longitude, latitude
Index: /LMDZ6/trunk/libf/phylmd/phyetat0.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/phyetat0.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmd/phyetat0.F90	(revision 4056)
@@ -21,11 +21,11 @@
        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: nbtr, nqo, type_trac, tracers, niadv
-  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 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
@@ -75,5 +75,5 @@
   INTEGER length
   PARAMETER (length=100)
-  INTEGER it, iiq, isw
+  INTEGER it, iq, isw
   REAL tab_cntrl(length), tabcntr0(length)
   CHARACTER*7 str7
@@ -448,13 +448,15 @@
 
   IF (type_trac == 'lmdz') THEN
-     DO it=1, nbtr                                                                  
-!!        iiq=niadv(it+2)                                                           ! jyg
-        iiq=niadv(it+nqo)                                                           ! jyg
-        found=phyetat0_get(1,trs(:,it),"trs_"//TRIM(tracers(iiq)%name), &
-                                  "Surf trac"//TRIM(tracers(iiq)%name),0.)
-     ENDDO
+     it = 0
+     DO iq = 1, nqtot
+        IF(.NOT.tracers(iq)%isAdvected .OR. tracers(iq)%isH2Ofamily) 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
@@ -598,5 +600,5 @@
    CALL get_field(name, field, found)
    IF (.NOT. found) THEN
-     WRITE(lunout,*) "phyetat0: Le champ <",name,"> est absent"
+     WRITE(lunout,*) "phyetat0: Le champ <",TRIM(name),"> est absent"
      WRITE(lunout,*) "Depart legerement fausse. Mais je continue"
      field(:,:)=default
Index: /LMDZ6/trunk/libf/phylmd/phyredem.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/phyredem.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmd/phyredem.F90	(revision 4056)
@@ -35,5 +35,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, niadv, tracers, nbtr, nqo
+  USE infotrac_phy, ONLY: type_trac, nqtot, tracers, nbtr
   USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, co2_send
   USE indice_sol_mod, ONLY: nbsrf, is_oce, is_sic, is_ter, is_lic, epsfra
@@ -70,5 +70,5 @@
   CHARACTER (len=2) :: str2
   CHARACTER (len=256) :: nam, lnam
-  INTEGER           :: it, iiq, pass
+  INTEGER           :: it, iq, pass
 
   !======================================================================
@@ -326,8 +326,9 @@
     IF (type_trac == 'lmdz') THEN
        CALL traclmdz_to_restart(trs)
-       DO it=1, nbtr
-!!        iiq=niadv(it+2)                                                           ! jyg
-          iiq=niadv(it+nqo)                                                           ! jyg
-          CALL put_field(pass,"trs_"//tracers(iiq)%name, "", trs(:, it))
+       it = 0
+       DO iq = 1, nqtot
+          IF(.NOT.tracers(iq)%isAdvected .OR. tracers(iq)%isH2Ofamily) CYCLE
+          it = it+1
+          CALL put_field(pass,"trs_"//tracers(iq)%name, "", trs(:, it))
        END DO
     END IF
@@ -391,5 +392,5 @@
 
   IMPLICIT NONE
-  INTEGER, INTENT(IN)            :: pass
+  INTEGER, INTENT(IN)           :: pass
   CHARACTER(LEN=*),  INTENT(IN) :: nam, lnam
   REAL,              INTENT(IN) :: field(:,:)
Index: /LMDZ6/trunk/libf/phylmd/phys_output_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/phys_output_mod.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmd/phys_output_mod.F90	(revision 4056)
@@ -35,6 +35,5 @@
     USE iophy 
     USE dimphy
-    USE infotrac_phy, ONLY: nqtot, nqo, niadv, tracers, type_trac
-    USE strings_mod,  ONLY: maxlen
+    USE infotrac_phy, ONLY: nqtot, tracers, type_trac, niso, ntraciso, maxlen
     USE ioipsl
     USE phys_cal_mod, only : hour, calend
@@ -96,5 +95,5 @@
     CHARACTER(LEN=4), DIMENSION(nlevSTD)  :: clevSTD
     REAL, DIMENSION(nlevSTD)              :: rlevSTD
-    INTEGER                               :: nsrf, k, iq, iiq, iff, i, j, ilev, jq
+    INTEGER                               :: nsrf, k, iq, iff, i, j, ilev, itr, ixt, iiso, izone
     INTEGER                               :: naero
     LOGICAL                               :: ok_veget
@@ -115,6 +114,4 @@
     LOGICAL, DIMENSION(nfiles)            :: phys_out_filestations
 
-    CHARACTER(LEN=50) :: outiso
-    CHARACTER(LEN=20) :: unit
     CHARACTER(LEN=maxlen) :: tnam, lnam, dn
     INTEGER :: flag(nfiles)
@@ -122,15 +119,11 @@
 !!!!!!!!!! stockage dans une region limitee pour chaque fichier !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     !                 entre [phys_out_lonmin,phys_out_lonmax] et [phys_out_latmin,phys_out_latmax]
-
-    LOGICAL, DIMENSION(nfiles), SAVE  :: phys_out_regfkey       = (/ .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., &
-                                                                     .FALSE., .FALSE., .FALSE., .FALSE., .FALSE. /)
-    REAL, DIMENSION(nfiles), SAVE     :: phys_out_lonmin        = (/ -180., -180., -180., -180., -180., &
-                                                                     -180., -180., -180., -180., -180. /)
-    REAL, DIMENSION(nfiles), SAVE     :: phys_out_lonmax        = (/  180.,  180.,  180.,  180.,  180., &
-                                                                      180.,  180.,  180.,  180.,  180. /)
-    REAL, DIMENSION(nfiles), SAVE     :: phys_out_latmin        = (/  -90.,  -90.,  -90.,  -90.,  -90., &
-                                                                      -90.,  -90.,  -90.,  -90.,  -90. /)
-    REAL, DIMENSION(nfiles), SAVE     :: phys_out_latmax        = (/   90.,   90.,   90.,   90.,   90., &
-                                                                       90.,   90.,   90.,   90.,   90. /)
+    LOGICAL, DIMENSION(nfiles), SAVE :: &
+      phys_out_regfkey = [.FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE.]
+    REAL,    DIMENSION(nfiles), SAVE :: &
+      phys_out_lonmin  = [  -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.], &
+      phys_out_lonmax  = [   180.,    180.,    180.,    180.,    180.,    180.,    180.,    180.,    180.,    180.], &
+      phys_out_latmin  = [   -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.], &
+      phys_out_latmax  = [    90.,     90.,     90.,     90.,     90.,     90.,     90.,     90.,     90.,     90.]
     REAL, DIMENSION(klev,2) :: Ahyb_bounds, Bhyb_bounds
     REAL, DIMENSION(klev+1)   :: lev_index
@@ -169,5 +162,5 @@
     ALLOCATE(o_dtr_dry(nqtot),o_dtr_vdf(nqtot))
 
-    levmax = (/ klev, klev, klev, klev, klev, klev, nlevSTD, nlevSTD, nlevSTD, klev /)
+    levmax = [klev, klev, klev, klev, klev, klev, nlevSTD, nlevSTD, nlevSTD, klev]
 
     phys_out_filenames(1) = 'histmth'
@@ -366,39 +359,16 @@
     CALL wxios_add_vaxis("bnds", 2, (/1.,2./))
 
-     CALL wxios_add_vaxis("Alt", &
+    CALL wxios_add_vaxis("Alt", &
             levmax(iff) - levmin(iff) + 1, pseudoalt)
 
-    IF (NSW.EQ.6) THEN
-!
-!wl1_sun: minimum bound of wavelength (in um)
-!
-      wl1_sun(1)=0.180
-      wl1_sun(2)=0.250
-      wl1_sun(3)=0.440
-      wl1_sun(4)=0.690
-      wl1_sun(5)=1.190
-      wl1_sun(6)=2.380
-!
-!wl2_sun: maximum bound of wavelength (in um)
-!
-      wl2_sun(1)=0.250
-      wl2_sun(2)=0.440
-      wl2_sun(3)=0.690
-      wl2_sun(4)=1.190
-      wl2_sun(5)=2.380
-      wl2_sun(6)=4.000
-!
-    ELSE IF(NSW.EQ.2) THEN
-!
-!wl1_sun: minimum bound of wavelength (in um)
-!
-      wl1_sun(1)=0.250
-      wl1_sun(2)=0.690
-!
-!wl2_sun: maximum bound of wavelength (in um)
-!
-      wl2_sun(1)=0.690
-      wl2_sun(2)=4.000
-    ENDIF
+    ! wl1_sun/wl2_sun: minimum/maximum bound of wavelength (in um)
+    SELECT CASE(NSW)
+      CASE(6)
+        wl1_sun(1:6) = [0.180, 0.250, 0.440, 0.690, 1.190, 2.380]
+        wl2_sun(1:6) = [0.250, 0.440, 0.690, 1.190, 2.380, 4.000]
+      CASE(2)
+        wl1_sun(1:2) = [0.250, 0.690]
+        wl2_sun(1:2) = [0.690, 4.000]
+    END SELECT
 
     DO ISW=1, NSW
@@ -498,41 +468,41 @@
      ENDIF ! clef_files
 
-       IF (nqtot>=nqo+1) THEN
-!
-          DO iq=nqo+1,nqtot 
-            iiq=niadv(iq); jq = iq-nqo
-            dn = 'd'//TRIM(tracers(iiq)%name)//'_'
+          itr = 0
+          DO iq = 1, nqtot 
+            IF(.NOT.tracers(iq)%isAdvected .OR. tracers(iq)%isH2Ofamily) CYCLE
+            itr = itr + 1
+            dn = 'd'//TRIM(tracers(iq)%name)//'_'
 
             flag = [1, 5, 5, 5, 10, 10, 11, 11, 11, 11]
-            lnam = 'Tracer '//TRIM(tracers(iiq)%longName)
-            tnam = TRIM(tracers(iiq)%name); o_trac          (jq) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+            lnam = 'Tracer '//TRIM(tracers(iq)%longName)
+            tnam = TRIM(tracers(iq)%name);  o_trac          (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+
             flag = [4, 7, 7, 7, 10, 10, 11, 11, 11, 11]
-            lnam = 'Tendance tracer '//TRIM(tracers(iiq)%longName)
-            tnam = TRIM(dn)//'vdf';         o_dtr_vdf       (jq) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+            lnam = 'Tendance tracer '//TRIM(tracers(iq)%longName)
+            tnam = TRIM(dn)//'vdf';         o_dtr_vdf       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
 
             flag = [5, 7, 7, 7, 10, 10, 11, 11, 11, 11]
-            tnam = TRIM(dn)//'the';         o_dtr_the       (jq) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
-            tnam = TRIM(dn)//'con';         o_dtr_con       (jq) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+            tnam = TRIM(dn)//'the';         o_dtr_the       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+            tnam = TRIM(dn)//'con';         o_dtr_con       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
 
             flag = [7, 7, 7, 7, 10, 10, 11, 11, 11, 11]
-            tnam = TRIM(dn)//'lessi_impa';  o_dtr_lessi_impa(jq) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
-            tnam = TRIM(dn)//'lessi_nucl';  o_dtr_lessi_nucl(jq) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
-            tnam = TRIM(dn)//'insc';        o_dtr_insc      (jq) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
-            tnam = TRIM(dn)//'bcscav';      o_dtr_bcscav    (jq) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
-            tnam = TRIM(dn)//'evapls';      o_dtr_evapls    (jq) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
-            tnam = TRIM(dn)//'ls';          o_dtr_ls        (jq) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
-            tnam = TRIM(dn)//'trsp';        o_dtr_trsp      (jq) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
-            tnam = TRIM(dn)//'sscav';       o_dtr_sscav     (jq) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
-            tnam = TRIM(dn)//'sat';         o_dtr_sat       (jq) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
-            tnam = TRIM(dn)//'uscav';       o_dtr_uscav     (jq) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
-
-            lnam = 'tracer tendency dry deposition'//TRIM(tracers(iiq)%longName)
-            tnam = 'cum'//TRIM(dn)//'dry';  o_dtr_dry       (jq) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+            tnam = TRIM(dn)//'lessi_impa';  o_dtr_lessi_impa(itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+            tnam = TRIM(dn)//'lessi_nucl';  o_dtr_lessi_nucl(itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+            tnam = TRIM(dn)//'insc';        o_dtr_insc      (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+            tnam = TRIM(dn)//'bcscav';      o_dtr_bcscav    (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+            tnam = TRIM(dn)//'evapls';      o_dtr_evapls    (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+            tnam = TRIM(dn)//'ls';          o_dtr_ls        (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+            tnam = TRIM(dn)//'trsp';        o_dtr_trsp      (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+            tnam = TRIM(dn)//'sscav';       o_dtr_sscav     (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+            tnam = TRIM(dn)//'sat';         o_dtr_sat       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+            tnam = TRIM(dn)//'uscav';       o_dtr_uscav     (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+
+            lnam = 'tracer tendency dry deposition'//TRIM(tracers(iq)%longName)
+            tnam = 'cum'//TRIM(dn)//'dry';  o_dtr_dry       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
 
             flag = [1, 4, 10, 10, 10, 10, 11, 11, 11, 11]
-            lnam = 'Cumulated tracer '//TRIM(tracers(iiq)%longName)
-            tnam = 'cum'//TRIM(tracers(iiq)%name); o_trac_cum(jq)= ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+            lnam = 'Cumulated tracer '//TRIM(tracers(iq)%longName)
+            tnam = 'cum'//TRIM(tracers(iq)%name); o_trac_cum(itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
           ENDDO
-       ENDIF
 
    ENDDO !  iff
@@ -555,10 +525,9 @@
     ENDIF
 
-!  DO iq=nqo+1,nqtot 
-!    iiq=niadv(iq)
-!    dn = 'd'//TRIM(tracers(iiq)%name)//'_'
-!    WRITE(*,'(a,i1,a,10i3)')'trac(',iiq,')%flag = ',o_trac(iiq)%flag
-!    WRITE(*,'(a,i1,a)')'trac(',iiq,')%tnam = '//TRIM(o_trac(iiq)%name)
-!    WRITE(*,'(a,i1,a)')'trac(',iiq,')%lnam = '//TRIM(o_trac(iiq)%description)
+!  DO iq=1,nqtot
+!    IF(.NOT.tracers(iq)%isAdvected .OR. tracers(iq)%isH2Ofamily) CYCLE
+!    WRITE(*,'(a,i1,a,10i3)')'trac(',iq,')%flag = ',o_trac(iq)%flag
+!    WRITE(*,'(a,i1,a)')'trac(',iq,')%name = '//TRIM(o_trac(iq)%name)
+!    WRITE(*,'(a,i1,a)')'trac(',iq,')%description = '//TRIM(o_trac(iq)%description)
 !  END DO
 
Index: /LMDZ6/trunk/libf/phylmd/phys_output_write_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/phys_output_write_mod.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmd/phys_output_write_mod.F90	(revision 4056)
@@ -25,5 +25,5 @@
 
     USE dimphy, ONLY: klon, klev, klevp1
-    USE infotrac_phy, ONLY: nbtr, nqtot, nqo, type_trac, tracers, niadv
+    USE infotrac_phy, ONLY: nbtr, nqtot, nqo, type_trac, tracers, niso, ntraciso, maxlen
     USE strings_mod,  ONLY: maxlen
     USE mod_phys_lmdz_para, ONLY: is_north_pole_phy,is_south_pole_phy
@@ -198,6 +198,13 @@
          o_map_emis_Anv, o_map_pcld_Anv, o_map_tcld_Anv, &
          o_map_ntot, o_map_hc,o_map_hist,o_map_Cb,o_map_ThCi,o_map_Anv, &
+#ifdef ISO
+! Isotopes
+         o_xtprecip,o_xtplul,o_xtpluc,o_xtovap,o_xtoliq,o_xtcond, &
+         o_xtevap,o_dxtdyn,o_dxtldyn,o_dxtcon,o_dxtlsc,o_dxteva, &
+         o_dxtajs,o_dxtvdf,o_dxtthe, o_dxtch4, &
+         o_dxtprod_nucl,o_dxtcosmo,o_dxtdecroiss, &
+#endif
+! Tropopause
          o_alt_tropo, & 
-! Tropopause
          o_p_tropopause, o_z_tropopause, o_t_tropopause,  &
          o_col_O3_strato, o_col_O3_tropo,                 & 
@@ -254,4 +261,7 @@
          rhlevSTD, O3STD, O3daySTD, uvSTD, vqSTD, vTSTD, wqSTD, vphiSTD, &
          wTSTD, u2STD, v2STD, T2STD, missing_val_nf90, delta_sal, ds_ns, &
+#ifdef ISO
+        xtrain_con, xtsnow_con, xtrain_fall, xtsnow_fall, &
+#endif
          dt_ns, delta_sst
 
@@ -320,4 +330,11 @@
          east_gwstress, west_gwstress, &
          d_q_ch4, pmfd, pmfu, ref_liq, ref_ice, rhwriteSTD, &
+#ifdef ISO
+        xtrain_lsc, xtsnow_lsc, xt_seri, xtl_seri,xts_seri,xtevap, &
+        d_xt_dyn,d_xtl_dyn,d_xt_con,d_xt_vdf,d_xt_ajsb, &
+        d_xt_lsc,d_xt_eva,d_xt_ch4, &
+        d_xt_ajs, d_xt_ajsb, &
+        d_xt_prod_nucl,d_xt_cosmo,d_xt_decroiss, &
+#endif
          ep, epmax_diag, &  ! epmax_cape
          p_tropopause, t_tropopause, z_tropopause
@@ -367,4 +384,7 @@
     USE pbl_surface_mod, ONLY: snow
     USE indice_sol_mod, ONLY: nbsrf
+#ifdef ISO
+    USE isotopes_mod, ONLY: iso_HTO
+#endif
     USE geometry_mod, ONLY: cell_area, latitude_deg, longitude_deg
     USE surface_data, ONLY: type_ocean, version_ocean, ok_veget, landice_opt
@@ -419,5 +439,5 @@
     ! Local
     INTEGER :: itau_w
-    INTEGER :: i, iinit, iinitend=1, iff, iq, iiq, nsrf, k, ll, naero
+    INTEGER :: i, iinit, iinitend=1, iff, iq, nsrf, k, ll, naero
     REAL, DIMENSION (klon) :: zx_tmp_fi2d, zpt_conv2d, wind100m
     REAL, DIMENSION (klon,klev) :: zx_tmp_fi3d, zpt_conv
@@ -439,5 +459,5 @@
 #endif
     REAL, PARAMETER :: un_jour=86400.
-    INTEGER ISW
+    INTEGER :: ISW, itr, ixt, it
     CHARACTER*1 ch1
     CHARACTER(LEN=maxlen) :: varname, dn
@@ -452,7 +472,4 @@
     REAL,DIMENSION(klon,klev) :: z, dz
     REAL,DIMENSION(klon)      :: zrho, zt
-
-    INTEGER :: nqup
-
 
     ! On calcul le nouveau tau:
@@ -511,11 +528,11 @@
           CALL xios_get_handle("fields_strataer_trac_3D", group_handle)
           ! On boucle sur les traceurs pour les ajouter au groupe puis fixer les attributs
-          DO iq=nqo+1, nqtot
-            iiq=niadv(iq)
-            dn = 'd'//TRIM(tracers(iiq)%name)//'_'
-            WRITE (lunout,*) 'XIOS var=', nqo, iq, nqtot, tracers(iiq)%name
+          DO iq = 1, nqtot
+            IF(.NOT.tracers(iq)%isAdvected .OR. tracers(iq)%isH2Ofamily) CYCLE
+            dn = 'd'//TRIM(tracers(iq)%name)//'_'
+            WRITE (lunout,*) 'XIOS var=', nqo, iq, nqtot, tracers(iq)%name
 
             unt = "kg kg-1"
-            varname=trim(tracers(iiq)%name)
+            varname=trim(tracers(iq)%name)
             CALL xios_add_child(group_handle, child, varname)
             CALL xios_set_attr(child, name=varname, unit=unt)
@@ -561,13 +578,13 @@
             CALL xios_add_child(group_handle, child, varname)
             CALL xios_set_attr(child, name=varname, unit=unt)
-          ENDDO
+          END DO
           !On ajoute les variables 2D traceurs par l interface fortran 
           CALL xios_get_handle("fields_strataer_trac_2D", group_handle)
           ! On boucle sur les traceurs pour les ajouter au groupe puis fixer les attributs
-          DO iq=nqo+1, nqtot
-            iiq=niadv(iq)
+          DO iq = 1, nqtot
+            IF(.NOT.tracers(iq)%isAdvected .OR. tracers(iq)%isH2Ofamily) CYCLE
 
             unt = "kg m-2"
-            varname='cum'//trim(tracers(iiq)%name)
+            varname='cum'//trim(tracers(iq)%name)
             WRITE (lunout,*) 'XIOS var=', iq, nqtot, varname
             CALL xios_add_child(group_handle, child, varname)
@@ -575,5 +592,5 @@
 
             unt = "kg m-2 s-1"
-            varname='cumd'//trim(tracers(iiq)%name)//'_dry'
+            varname='cumd'//trim(tracers(iq)%name)//'_dry'
             CALL xios_add_child(group_handle, child, varname)
             CALL xios_set_attr(child, name=varname, unit=unt)
@@ -611,4 +628,5 @@
        ENDIf
        CALL histwrite_phy(o_aire, zx_tmp_fi2d)
+
        IF (vars_defined) THEN
           DO i=1, klon
@@ -2408,39 +2426,47 @@
        IF (iflag_phytrac == 1 ) then
          IF (type_trac == 'lmdz' .OR. type_trac == 'coag') THEN
-           DO iq=nqo+1, nqtot
+           itr = 0
+           DO iq = 1, nqtot
+             IF(tracers(iq)%isH2Ofamily) CYCLE
+             itr = itr + 1
+!            write(*,*) 'phys_output_write_mod 2337: itr=',itr
              !--3D fields
-             CALL histwrite_phy(o_trac(iq-nqo), tr_seri(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_vdf(iq-nqo),d_tr_cl(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_the(iq-nqo),d_tr_th(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_con(iq-nqo),d_tr_cv(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_lessi_impa(iq-nqo),d_tr_lessi_impa(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_lessi_nucl(iq-nqo),d_tr_lessi_nucl(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_insc(iq-nqo),d_tr_insc(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_bcscav(iq-nqo),d_tr_bcscav(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_evapls(iq-nqo),d_tr_evapls(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_ls(iq-nqo),d_tr_ls(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_trsp(iq-nqo),d_tr_trsp(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_sscav(iq-nqo),d_tr_sscav(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_sat(iq-nqo),d_tr_sat(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_uscav(iq-nqo),d_tr_uscav(:,:,iq-nqo))
+             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))
+             CALL histwrite_phy(o_dtr_lessi_impa(itr),d_tr_lessi_impa(:,:,itr))
+             CALL histwrite_phy(o_dtr_lessi_nucl(itr),d_tr_lessi_nucl(:,:,itr))
+             CALL histwrite_phy(o_dtr_insc(itr),d_tr_insc(:,:,itr))
+             CALL histwrite_phy(o_dtr_bcscav(itr),d_tr_bcscav(:,:,itr))
+             CALL histwrite_phy(o_dtr_evapls(itr),d_tr_evapls(:,:,itr))
+             CALL histwrite_phy(o_dtr_ls(itr),d_tr_ls(:,:,itr))
+             CALL histwrite_phy(o_dtr_trsp(itr),d_tr_trsp(:,:,itr))
+             CALL histwrite_phy(o_dtr_sscav(itr),d_tr_sscav(:,:,itr))
+             CALL histwrite_phy(o_dtr_sat(itr),d_tr_sat(:,:,itr))
+             CALL histwrite_phy(o_dtr_uscav(itr),d_tr_uscav(:,:,itr))
             !--2D fields
-             CALL histwrite_phy(o_dtr_dry(iq-nqo), flux_tr_dry(:,iq-nqo))
+             CALL histwrite_phy(o_dtr_dry(itr), flux_tr_dry(:,itr))
              zx_tmp_fi2d=0.
              IF (vars_defined) THEN
                 DO k=1,klev
-                   zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+zmasse(:,k)*tr_seri(:,k,iq-nqo)
+                   zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+zmasse(:,k)*tr_seri(:,k,itr)
                 ENDDO
              ENDIF
-             CALL histwrite_phy(o_trac_cum(iq-nqo), zx_tmp_fi2d)
+             CALL histwrite_phy(o_trac_cum(itr), zx_tmp_fi2d)
            ENDDO !--iq
          ENDIF   !--type_trac
 !
          IF (type_trac == 'co2i') THEN
-           DO iq=nqo+1, nqtot
+           itr = 0
+           DO iq = 1, nqtot
+             IF(tracers(iq)%isH2Ofamily) CYCLE
+             itr = itr + 1
+!            write(*,*) 'phys_output_write_mod 2370: itr=',itr
              !--3D fields
-             CALL histwrite_phy(o_trac(iq-nqo), tr_seri(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_vdf(iq-nqo),d_tr_cl(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_the(iq-nqo),d_tr_th(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_con(iq-nqo),d_tr_cv(:,:,iq-nqo))
+             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
@@ -2448,8 +2474,8 @@
              IF (vars_defined) THEN
                 DO k=1,klev
-                   zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+zmasse(:,k)*tr_seri(:,k,iq-nqo)
+                   zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+zmasse(:,k)*tr_seri(:,k,itr)
                 ENDDO
              ENDIF
-             CALL histwrite_phy(o_trac_cum(iq-nqo), zx_tmp_fi2d)
+             CALL histwrite_phy(o_trac_cum(itr), zx_tmp_fi2d)
            ENDDO !--iq
            !--CO2 net fluxes
@@ -2463,11 +2489,13 @@
 
          IF (type_trac == 'inco') THEN
-           nqup = nqo+1
-           DO iq=nqo+1, nqup
+           DO iq = 1, nqtot
+             IF(tracers(iq)%isH2Ofamily .OR. .NOT.tracers(iq)%isAdvected) CYCLE
+             itr = itr+1
+             IF(tracers(iq)%component /= 'co2i') CYCLE
              !--3D fields
-             CALL histwrite_phy(o_trac(iq-nqo), tr_seri(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_vdf(iq-nqo),d_tr_cl(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_the(iq-nqo),d_tr_th(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_con(iq-nqo),d_tr_cv(:,:,iq-nqo))
+             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
@@ -2475,8 +2503,8 @@
              IF (vars_defined) THEN
                 DO k=1,klev
-                   zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+zmasse(:,k)*tr_seri(:,k,iq-nqo)
+                   zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+zmasse(:,k)*tr_seri(:,k,itr)
                 ENDDO
              ENDIF
-             CALL histwrite_phy(o_trac_cum(iq-nqo), zx_tmp_fi2d)
+             CALL histwrite_phy(o_trac_cum(itr), zx_tmp_fi2d)
            ENDDO !--iq
            !--CO2 net fluxes
@@ -2504,4 +2532,62 @@
        end if
 
+#ifdef ISO
+    do ixt=1,ntraciso
+!        write(*,*) 'ixt'
+        IF (vars_defined) zx_tmp_fi2d(:) = xtrain_fall(ixt,:) + xtsnow_fall(ixt,:)
+        CALL histwrite_phy(o_xtprecip(ixt), zx_tmp_fi2d)
+
+        IF (vars_defined) zx_tmp_fi2d(:) = xtrain_lsc(ixt,:) + xtsnow_lsc(ixt,:)
+        CALL histwrite_phy(o_xtplul(ixt), zx_tmp_fi2d)
+
+        IF (vars_defined) zx_tmp_fi2d(:) = xtrain_con(ixt,:) + xtsnow_con(ixt,:)
+        CALL histwrite_phy(o_xtpluc(ixt), zx_tmp_fi2d)
+        CALL histwrite_phy(o_xtevap(ixt),   xtevap(ixt,:))
+        CALL histwrite_phy(o_xtovap(ixt),  xt_seri(ixt,:,:))
+        CALL histwrite_phy(o_xtoliq(ixt), xtl_seri(ixt,:,:))
+
+        IF (vars_defined) zx_tmp_fi3d(:,:)=xtl_seri(ixt,:,:)+xts_seri(ixt,:,:)
+        CALL histwrite_phy(o_xtcond(ixt), zx_tmp_fi3d)
+        CALL histwrite_phy(o_dxtdyn(ixt),   d_xt_dyn(ixt,:,:))
+        CALL histwrite_phy(o_dxtldyn(ixt), d_xtl_dyn(ixt,:,:))
+
+        IF (vars_defined) zx_tmp_fi3d(:,:)=d_xt_con(ixt,:,:)/pdtphys
+        CALL histwrite_phy(o_dxtcon(ixt), zx_tmp_fi3d)
+
+        IF (vars_defined) zx_tmp_fi3d(:,:)=d_xt_lsc(ixt,:,:)/pdtphys
+        CALL histwrite_phy(o_dxtlsc(ixt), zx_tmp_fi3d)
+
+        IF (vars_defined) zx_tmp_fi3d(:,:)=d_xt_eva(ixt,:,:)/pdtphys
+        CALL histwrite_phy(o_dxteva(ixt), zx_tmp_fi3d)
+
+        IF (vars_defined) zx_tmp_fi3d(:,:)=d_xt_vdf(ixt,:,:)/pdtphys
+        CALL histwrite_phy(o_dxtvdf(ixt), zx_tmp_fi3d)
+
+        IF (vars_defined) zx_tmp_fi3d(:,:)=d_xt_ajsb(ixt,:,:)/pdtphys
+        CALL histwrite_phy(o_dxtajs(ixt), zx_tmp_fi3d)
+
+        IF (vars_defined) zx_tmp_fi3d(:,:)=(d_xt_ajs(ixt,:,:)-d_xt_ajsb(ixt,:,:))/pdtphys
+        CALL histwrite_phy(o_dxtthe(ixt), zx_tmp_fi3d)
+
+        IF (ok_qch4) THEN
+          IF (vars_defined) zx_tmp_fi3d(:,:)=d_xt_ch4(ixt,:,:)/pdtphys
+          CALL histwrite_phy(o_dxtch4(ixt), zx_tmp_fi3d)
+        END IF
+
+        IF (ixt == iso_HTO) THEN
+          IF (vars_defined) zx_tmp_fi3d(:,:)=d_xt_prod_nucl(ixt,:,:)/pdtphys
+          CALL histwrite_phy(o_dxtprod_nucl(ixt), zx_tmp_fi3d)
+
+          IF (vars_defined) zx_tmp_fi3d(:,:)=d_xt_cosmo(ixt,:,:)/pdtphys
+          CALL histwrite_phy(o_dxtcosmo(ixt), zx_tmp_fi3d)
+
+          IF (vars_defined) zx_tmp_fi3d(:,:)=d_xt_decroiss(ixt,:,:)/pdtphys
+          CALL histwrite_phy(o_dxtdecroiss(ixt), zx_tmp_fi3d)
+        END IF
+
+    !write(*,*) 'phys_output_write_mod 2531'
+    enddo !do ixt=1,ntraciso    
+#endif
+
        IF (.NOT.vars_defined) THEN
           !$OMP MASTER
Index: /LMDZ6/trunk/libf/phylmd/physiq_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/physiq_mod.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmd/physiq_mod.F90	(revision 4056)
@@ -39,5 +39,7 @@
     USE ioipsl_getin_p_mod, ONLY : getin_p
     USE indice_sol_mod
-    USE infotrac_phy, ONLY: nqtot, nbtr, nqo, type_trac, nqCO2
+    USE infotrac_phy, ONLY: nqtot, nbtr, nqo, tracers, type_trac, nqCO2
+    USE readTracFiles_mod, ONLY: phases_sep
+    USE strings_mod,  ONLY: strIdx
     USE iophy
     USE limit_read_mod, ONLY : init_limit_read
@@ -146,4 +148,6 @@
        !
        d_t_vdf,d_q_vdf,d_u_vdf,d_v_vdf,d_t_diss, &
+       d_t_vdf_x, d_t_vdf_w, &
+       d_q_vdf_x, d_q_vdf_w, &
        d_ts, &
        !
@@ -218,6 +222,4 @@
        zxfluxlat_x, zxfluxlat_w, &
        !
-       d_t_vdf_x, d_t_vdf_w, &
-       d_q_vdf_x, d_q_vdf_w, &
        pbl_tke_input, tke_dissip, l_mix, wprime,&
        t_therm, q_therm, u_therm, v_therm, &
@@ -356,5 +358,5 @@
     LOGICAL, SAVE :: ok_volcan ! pour activer les diagnostics volcaniques
     !$OMP THREADPRIVATE(ok_volcan)
-    INTEGER, SAVE :: flag_volc_surfstrat ! pour imposer le cool/heat rate à la surf ou dans la strato 
+    INTEGER, SAVE :: flag_volc_surfstrat ! pour imposer le cool/heat rate à la surf/strato
     !$OMP THREADPRIVATE(flag_volc_surfstrat)
     LOGICAL ok_cvl  ! pour activer le nouveau driver pour convection KE
@@ -854,5 +856,5 @@
     real zqsat(klon,klev)
     !
-    INTEGER i, k, iq, j, nsrf, ll, l
+    INTEGER i, k, iq, j, nsrf, ll, l, itr
     !
     REAL t_coup
@@ -1035,5 +1037,5 @@
 
     CHARACTER (LEN=20) :: modname='physiq_mod'
-    CHARACTER*80 message, abort_message
+    CHARACTER*80 abort_message
     LOGICAL, SAVE ::  ok_sync, ok_sync_omp
     !$OMP THREADPRIVATE(ok_sync)
@@ -1363,5 +1365,5 @@
          iflag_phytrac = 1
        ENDIF
-#endif	
+#endif
        nvm_lmdz = 13
        CALL getin_p('NVM',nvm_lmdz)
@@ -2230,22 +2232,20 @@
 
     tke0(:,:)=pbl_tke(:,:,is_ave)
-    !CR:Nombre de traceurs de l'eau: nqo
-    !  IF (nqtot.GE.3) THEN
-    IF (nqtot.GE.(nqo+1)) THEN
-       !     DO iq = 3, nqtot        
-       DO iq = nqo+1, nqtot  
+    IF (nqtot > nqo) THEN
+       ! water isotopes are not included in tr_seri
+       itr = 0
+       DO iq = 1, nqtot
+         IF(tracers(iq)%isH2Ofamily) CYCLE
+         itr = itr+1
           DO  k = 1, klev
              DO  i = 1, klon
-                !              tr_seri(i,k,iq-2) = qx(i,k,iq)
-                tr_seri(i,k,iq-nqo) = qx(i,k,iq)
+                tr_seri(i,k,itr) = qx(i,k,iq)
              ENDDO
           ENDDO
        ENDDO
     ELSE
-       DO k = 1, klev
-          DO i = 1, klon
-             tr_seri(i,k,1) = 0.0
-          ENDDO
-       ENDDO
+! DC: make sure the final "1" index was meant for 1st H2O phase (vapor) !!!
+!       tr_seri(:,:,strIdx(tracers(:)%name,'H2O'//phases_sep//'g')) = 0.0
+       tr_seri(:,:,strIdx(tracers(:)%name,'H2Ov')) = 0.0
     ENDIF
 !
@@ -2254,7 +2254,10 @@
     IF (debut) THEN
       WRITE(lunout,*)' WARNING: tr_ancien initialised to tr_seri'
-      DO iq = nqo+1, nqtot
-           tr_ancien(:,:,iq-nqo)=tr_seri(:,:,iq-nqo)
-      ENDDO
+       itr = 0
+       do iq = 1, nqtot
+         IF(tracers(iq)%isH2Ofamily) CYCLE
+         itr = itr+1
+         tr_ancien(:,:,itr)=tr_seri(:,:,itr)       
+       enddo
     ENDIF
     !
@@ -2287,9 +2290,5 @@
        d_qs_dyn2d(:)=(zx_tmp_fi2d(:)-prsw_ancien(:))/phys_tstep
        ! !! RomP >>>   td dyn traceur
-       IF (nqtot.GT.nqo) THEN     ! jyg
-          DO iq = nqo+1, nqtot      ! jyg
-              d_tr_dyn(:,:,iq-nqo)=(tr_seri(:,:,iq-nqo)-tr_ancien(:,:,iq-nqo))/phys_tstep ! jyg
-          ENDDO
-       ENDIF
+       IF (nqtot > nqo) d_tr_dyn(:,:,:)=(tr_seri(:,:,:)-tr_ancien(:,:,:))/phys_tstep
        ! !! RomP <<<
     ELSE
@@ -2304,9 +2303,5 @@
        d_qs_dyn2d(:) = 0.0
        ! !! RomP >>>   td dyn traceur
-       IF (nqtot.GT.nqo) THEN                                       ! jyg
-          DO iq = nqo+1, nqtot                                      ! jyg
-              d_tr_dyn(:,:,iq-nqo)= 0.0                             ! jyg
-          ENDDO
-       ENDIF
+       IF (nqtot > nqo) d_tr_dyn(:,:,:)= 0.0
        ! !! RomP <<<
        ancien_ok = .TRUE.
@@ -2589,5 +2584,5 @@
             debut,     lafin, &
             longitude_deg, latitude_deg, rugoro,  zrmu0,      &
-             sollwdown,    cldt,      &
+            sollwdown,    cldt,      &
             rain_fall, snow_fall, solsw,   solswfdiff, sollw,     &
             gustiness,                                &
@@ -2857,5 +2852,5 @@
          ENDDO
        ELSE
-               t_w(:,:) = t_seri(:,:)
+                t_w(:,:) = t_seri(:,:)
                 q_w(:,:) = q_seri(:,:)
                 t_x(:,:) = t_seri(:,:)
@@ -3073,5 +3068,12 @@
 
        DO i = 1, klon
-          ema_pcb(i)  = paprs(i,ibas_con(i))
+          ! C Risi modif: pour éviter pb de dépassement d'indice dans les cas
+          ! où i n'est pas un point convectif et donc ibas_con(i)=0
+          ! c'est un pb indépendant des isotopes
+          if (ibas_con(i) > 0) then
+             ema_pcb(i)  = paprs(i,ibas_con(i))
+          else
+             ema_pcb(i)  = 0.0
+          endif
        ENDDO
        DO i = 1, klon
@@ -3504,5 +3506,4 @@
     wprime_ave(:,:)=0.
 
-
     DO nsrf = 1, nbsrf
        DO i = 1, klon
@@ -3512,5 +3513,4 @@
        ENDDO
     ENDDO
-
 
     CALL  calcratqs(klon,klev,prt_level,lunout,        &
@@ -3530,4 +3530,5 @@
        print *,'itap, ->fisrtilp ',itap
     ENDIF
+    !
 
     picefra(:,:)=0.
@@ -3556,4 +3557,5 @@
          iflag_ice_thermo)
     ENDIF
+    !
     WHERE (rain_lsc < 0) rain_lsc = 0.
     WHERE (snow_lsc < 0) snow_lsc = 0.
@@ -4267,5 +4269,17 @@
  
 #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
           !IM des taux doit etre different du taux actuel
@@ -5052,13 +5066,12 @@
     ENDDO
     !
-    !CR: nb de traceurs eau: nqo
-    !  IF (nqtot.GE.3) THEN
-    IF (nqtot.GE.(nqo+1)) THEN
-       !     DO iq = 3, nqtot
-       DO iq = nqo+1, nqtot
+    IF (nqtot > nqo+1) THEN
+       itr = 0
+       DO iq = 1, nqtot
+          IF(tracers(iq)%isH2Ofamily) CYCLE
+          itr = itr+1
           DO  k = 1, klev
              DO  i = 1, klon
-                ! d_qx(i,k,iq) = ( tr_seri(i,k,iq-2) - qx(i,k,iq) ) / phys_tstep
-                d_qx(i,k,iq) = ( tr_seri(i,k,iq-nqo) - qx(i,k,iq) ) / phys_tstep
+                d_qx(i,k,iq) = ( tr_seri(i,k,itr) - qx(i,k,iq) ) / phys_tstep
              ENDDO
           ENDDO
@@ -5101,10 +5114,5 @@
     CALL water_int(klon,klev,qs_ancien,zmasse,prsw_ancien)
     ! !! RomP >>>
-    !CR: nb de traceurs eau: nqo
-    IF (nqtot.GT.nqo) THEN
-       DO iq = nqo+1, nqtot
-          tr_ancien(:,:,iq-nqo) = tr_seri(:,:,iq-nqo)
-       ENDDO
-    ENDIF
+    IF (nqtot > nqo) tr_ancien(:,:,:) = tr_seri(:,:,:)
     ! !! RomP <<<
     !==========================================================================
Index: /LMDZ6/trunk/libf/phylmd/phytrac_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/phytrac_mod.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmd/phytrac_mod.F90	(revision 4056)
@@ -56,5 +56,5 @@
   SUBROUTINE phytrac_init()
     USE dimphy
-    USE infotrac_phy, ONLY: nbtr, nqCO2, type_trac
+    USE infotrac_phy, ONLY: nbtr, type_trac
     USE tracco2i_mod, ONLY: tracco2i_init
     IMPLICIT NONE
@@ -145,5 +145,5 @@
     USE phys_local_var_mod, ONLY: budg_dep_dry_h2so4, budg_dep_wet_h2so4
     USE phys_local_var_mod, ONLY: budg_dep_dry_part,  budg_dep_wet_part
-    USE infotrac, ONLY: nbtr_sulgas, id_OCS_strat, id_SO2_strat, id_H2SO4_strat
+    USE infotrac_phy, ONLY: nbtr_sulgas, id_OCS_strat, id_SO2_strat, id_H2SO4_strat
     USE aerophys
 #endif
@@ -508,12 +508,12 @@
           iflag_con_trac= 1
        CASE('inco')
-          source(:,1:nqCO2) = 0.                          ! from CO2i	ModThL
-          source(:,nqCO2+1:nbtr)=init_source(:,:)         ! from INCA	ModThL
-          aerosol(1:nqCO2) = .FALSE.                      ! from CO2i	ModThL
-          CALL tracinca_init(aerosol(nqCO2+1:nbtr),lessivage)     ! from INCA	ModThL
-          pbl_flg(1:nqCO2) = 1              ! From CO2i		ModThL
-          iflag_the_trac= 1           ! From CO2i
-          iflag_vdf_trac= 1           ! From CO2i
-          iflag_con_trac= 1           ! From CO2i
+          source(:,1:nqCO2) = 0.                          ! from CO2i ModThL
+          source(:,nqCO2+1:nbtr)=init_source(:,:)         ! from INCA ModThL
+          aerosol(1:nqCO2) = .FALSE.                      ! from CO2i ModThL
+          CALL tracinca_init(aerosol(nqCO2+1:nbtr),lessivage)     ! from INCA ModThL
+          pbl_flg(1:nqCO2) = 1                            ! From CO2i ModThL
+          iflag_the_trac = 1                              ! From CO2i
+          iflag_vdf_trac = 1                              ! From CO2i
+          iflag_con_trac = 1                              ! From CO2i
 #ifdef CPP_StratAer
        CASE('coag')
Index: /LMDZ6/trunk/libf/phylmd/traclmdz_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/traclmdz_mod.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmd/traclmdz_mod.F90	(revision 4056)
@@ -67,5 +67,5 @@
     
     USE dimphy
-    USE infotrac_phy, ONLY: nbtr, tracers, niadv, solsym
+    USE infotrac_phy, ONLY: nbtr
     
     ! Input argument
@@ -89,5 +89,5 @@
     ! Initialization of the tracers should be done here only for those not found in the restart file.
     USE dimphy
-    USE infotrac_phy, ONLY: nbtr, nqo, tracers, pbl_flg, conv_flg, niadv
+    USE infotrac_phy, ONLY: nbtr, nqtot, tracers, pbl_flg, conv_flg
     USE regr_pr_comb_coefoz_m, ONLY: alloc_coefoz
     USE press_coefoz_m, ONLY: press_coefoz
@@ -114,5 +114,5 @@
         
 ! Local variables    
-    INTEGER :: ierr, it, iiq, i, k
+    INTEGER :: ierr, it, iq, i, k
     REAL, DIMENSION(klon_glo,klev) :: varglo ! variable temporaire sur la grille global    
     REAL, DIMENSION(klev)          :: mintmp, maxtmp
@@ -173,8 +173,9 @@
     id_rn=0; id_pb=0; id_aga=0; id_be=0; id_o3=0
     id_pcsat=0; id_pcocsat=0; id_pcq=0; id_pcs0=0; id_pcos0=0; id_pcq0=0
-    DO it=1,nbtr
-!!       iiq=niadv(it+2)                                                            ! jyg
-       iiq=niadv(it+nqo)                                                            ! jyg
-       SELECT CASE(strLower(tracers(iiq)%name))
+    it = 0
+    DO iq = 1, nqtot
+       IF(.NOT.tracers(iq)%isAdvected .OR. tracers(iq)%isH2Ofamily) CYCLE
+       it = it+1
+       SELECT CASE(strLower(tracers(iq)%name))
          CASE("rn");      id_rn     = it ! radon
          CASE("pb");      id_pb     = it ! plomb
@@ -189,8 +190,8 @@
          CASE("pcq0");    id_pcq0   = it
          CASE DEFAULT
-           WRITE(lunout,*) 'This is an unknown tracer in LMDZ : ', trim(tracers(iiq)%name)
+           WRITE(lunout,*) 'This is an unknown tracer in LMDZ : ', trim(tracers(iq)%name)
        END SELECT
 
-       SELECT CASE(strLower(tracers(iiq)%name))
+       SELECT CASE(strLower(tracers(iq)%name))
          CASE("pb")                        !--- RomP >>> profil initial de PB210 
            OPEN(ilesfil2,file='prof.pb210',status='old',iostat=irr2)
@@ -259,7 +260,8 @@
 ! Check if all tracers have restart values
 ! ----------------------------------------------
-    DO it=1,nbtr
-!!       iiq=niadv(it+2)                                                            ! jyg
-       iiq=niadv(it+nqo)                                                            ! jyg
+    it = 0
+    DO iq = 1, nqtot
+       IF(.NOT.tracers(iq)%isAdvected .OR. tracers(iq)%isH2Ofamily) CYCLE
+       it = it+1
        ! Test if tracer is zero everywhere. 
        ! Done by master process MPI and master thread OpenMP
@@ -282,5 +284,5 @@
        IF (zero) THEN
           ! The tracer was not found in restart file or it was equal zero everywhere.
-          WRITE(lunout,*) "The tracer ",trim(tracers(iiq)%name)," will be initialized"
+          WRITE(lunout,*) "The tracer ",trim(tracers(iq)%name)," will be initialized"
           IF (it==id_pcsat .OR. it==id_pcq .OR. &
                it==id_pcs0 .OR. it==id_pcq0) THEN
Index: /LMDZ6/trunk/libf/phylmdiso/infotrac_phy.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmdiso/infotrac_phy.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmdiso/infotrac_phy.F90	(revision 4056)
@@ -1,221 +1,1 @@
-
-! $Id: $
-
-MODULE infotrac_phy
-
-! Infotrac for physics; for now contains the same information as infotrac for
-! the dynamics (could be further cleaned) and is initialized using values
-! provided by the dynamics
-
-  USE readTracFiles_mod, ONLY: trac_type, maxlen, delPhase
-
-! nqtot : total number of tracers and higher order of moment, water vapor and liquid included
-  INTEGER, SAVE :: nqtot
-!$OMP THREADPRIVATE(nqtot)
-
-!CR: on ajoute le nombre de traceurs de l eau
-  INTEGER, SAVE :: nqo
-!$OMP THREADPRIVATE(nqo)
-
-! nbtr : number of tracers not including higher order of moment or water vapor or liquid
-!        number of tracers used in the physics
-  INTEGER, SAVE :: nbtr
-!$OMP THREADPRIVATE(nbtr)
-
-  INTEGER, SAVE :: nqtottr
-!$OMP THREADPRIVATE(nqtottr)
-
-! ThL : number of CO2 tracers			ModThL
-  INTEGER, SAVE :: nqCO2
-!$OMP THREADPRIVATE(nqCO2)
-
-#ifdef CPP_StratAer
-! nbtr_bin: number of aerosol bins for StratAer model
-! nbtr_sulgas: number of sulfur gases for StratAer model
-  INTEGER, SAVE :: nbtr_bin, nbtr_sulgas
-!$OMP THREADPRIVATE(nbtr_bin,nbtr_sulgas)
-  INTEGER, SAVE :: id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat
-!$OMP THREADPRIVATE(id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat)
-#endif
-
-! CRisi: nb traceurs pères= directement advectés par l'air
-  INTEGER, SAVE :: nqperes
-!$OMP THREADPRIVATE(nqperes)
-
-! Tracers parameters
-  TYPE(trac_type), TARGET, ALLOCATABLE, SAVE :: tracers(:)
-!$OMP THREADPRIVATE(tracers)
-
-! niadv : vector keeping the coorspondance between all tracers(nqtot) treated in the 
-!         dynamic part of the code and the tracers (nbtr+2) used in the physics part of the code. 
-  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE    :: niadv ! equivalent dyn / physique
-!$OMP THREADPRIVATE(niadv)
-
-! conv_flg(it)=0 : convection desactivated for tracer number it 
-  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE  :: conv_flg
-!$OMP THREADPRIVATE(conv_flg)
-
-! pbl_flg(it)=0  : boundary layer diffusion desactivaded for tracer number it 
-  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE  :: pbl_flg
-!$OMP THREADPRIVATE(pbl_flg)
-
-  CHARACTER(len=4),SAVE :: type_trac
-!$OMP THREADPRIVATE(type_trac)
-  CHARACTER(len=8),DIMENSION(:),ALLOCATABLE, SAVE :: solsym
-!$OMP THREADPRIVATE(solsym)
-   
-    ! CRisi: cas particulier des isotopes
-    LOGICAL,SAVE :: ok_isotopes,ok_iso_verif,ok_isotrac,ok_init_iso
-!$OMP THREADPRIVATE(ok_isotopes,ok_iso_verif,ok_isotrac,ok_init_iso)
-    INTEGER :: niso_possibles   
-    PARAMETER ( niso_possibles=5)
-    real, DIMENSION (niso_possibles),SAVE :: tnat,alpha_ideal
-!$OMP THREADPRIVATE(tnat,alpha_ideal)
-    LOGICAL, DIMENSION(niso_possibles),SAVE ::  use_iso
-!$OMP THREADPRIVATE(use_iso)
-    INTEGER, ALLOCATABLE, DIMENSION(:,:), SAVE ::  iqiso ! donne indice iq en fn de (ixt,phase) 
-!$OMP THREADPRIVATE(iqiso)
-    INTEGER, ALLOCATABLE, DIMENSION(:), SAVE ::  iso_indnum ! donne numéro iso entre 1 et niso effectif en fn de nqtot
-!$OMP THREADPRIVATE(iso_indnum)
-    INTEGER, DIMENSION(niso_possibles), SAVE :: indnum_fn_num ! donne indice entre entre 1 et niso en fonction du numéro d isotope entre 1 et niso_possibles
-!$OMP THREADPRIVATE(indnum_fn_num)
-    INTEGER, ALLOCATABLE, DIMENSION(:,:), SAVE ::  index_trac ! numéro ixt en fn izone, indnum entre 1 et niso
-!$OMP THREADPRIVATE(index_trac)
-    INTEGER,SAVE :: niso,ntraceurs_zone,ntraciso
-!$OMP THREADPRIVATE(niso,ntraceurs_zone,ntraciso)
-
-    INTEGER, ALLOCATABLE, DIMENSION(:), SAVE ::  itr_indice ! numéro iq entre 1 et nqtot qui correspond au traceur itr entre 1 et nqtottr
-!$OMP THREADPRIVATE(itr_indice)
- 
-CONTAINS
-
-  SUBROUTINE init_infotrac_phy(nqtot_,nqo_,nbtr_,nqtottr_,nqCO2_,tracers_,type_trac_,&
-                               niadv_,conv_flg_,pbl_flg_,solsym_,&
-                               ok_isotopes_,ok_iso_verif_,ok_isotrac_,&
-                               ok_init_iso_,niso_possibles_,tnat_,&
-                               alpha_ideal_,use_iso_,iqiso_,iso_indnum_,&
-                               indnum_fn_num_,index_trac_,&
-                               niso_,ntraceurs_zone_,ntraciso_,itr_indice_&
-#ifdef CPP_StratAer
-                               ,nbtr_bin_,nbtr_sulgas_&
-                               ,id_OCS_strat_,id_SO2_strat_,id_H2SO4_strat_,id_BIN01_strat_&
-#endif
-                               )
-
-    ! transfer information on tracers from dynamics to physics
-    USE print_control_mod, ONLY: prt_level, lunout
-    IMPLICIT NONE
-
-    INTEGER,INTENT(IN) :: nqtot_
-    INTEGER,INTENT(IN) :: nqo_
-    INTEGER,INTENT(IN) :: nbtr_
-    INTEGER,INTENT(IN) :: nqtottr_
-    INTEGER,INTENT(IN) :: nqCO2_
-#ifdef CPP_StratAer
-    INTEGER,INTENT(IN) :: nbtr_bin_
-    INTEGER,INTENT(IN) :: nbtr_sulgas_
-    INTEGER,INTENT(IN) :: id_OCS_strat_
-    INTEGER,INTENT(IN) :: id_SO2_strat_
-    INTEGER,INTENT(IN) :: id_H2SO4_strat_
-    INTEGER,INTENT(IN) :: id_BIN01_strat_
-#endif
-    TYPE(trac_type), INTENT(IN) :: tracers_(nqtot_) ! tracers descriptors
-    CHARACTER(len=*),INTENT(IN) :: type_trac_
-    INTEGER,INTENT(IN) :: niadv_ (nqtot_) ! equivalent dyn / physique
-    INTEGER,INTENT(IN) :: conv_flg_(nbtr_)
-    INTEGER,INTENT(IN) :: pbl_flg_(nbtr_)
-    CHARACTER(len=*),INTENT(IN) :: solsym_(nbtr_)
-    ! Isotopes:
-    LOGICAL,INTENT(IN) :: ok_isotopes_
-    LOGICAL,INTENT(IN) :: ok_iso_verif_
-    LOGICAL,INTENT(IN) :: ok_isotrac_
-    LOGICAL,INTENT(IN) :: ok_init_iso_
-    INTEGER,INTENT(IN) :: niso_possibles_
-    REAL,INTENT(IN) :: tnat_(niso_possibles_)
-    REAL,INTENT(IN) :: alpha_ideal_(niso_possibles_)
-    LOGICAL,INTENT(IN) :: use_iso_(niso_possibles_)
-    INTEGER,INTENT(IN) :: iqiso_(ntraciso_,nqo_)
-    INTEGER,INTENT(IN) :: iso_indnum_(nqtot_)
-    INTEGER,INTENT(IN) :: indnum_fn_num_(niso_possibles_)
-    INTEGER,INTENT(IN) :: index_trac_(ntraceurs_zone_,niso_)
-    INTEGER,INTENT(IN) :: niso_
-    INTEGER,INTENT(IN) :: ntraceurs_zone_
-    INTEGER,INTENT(IN) :: ntraciso_
-    INTEGER,INTENT(IN) :: itr_indice_(nqtottr_)
-
-    CHARACTER(LEN=30) :: modname="init_infotrac_phy"
-
-    nqtot=nqtot_
-    nqo=nqo_
-    nbtr=nbtr_
-    nqCO2=nqCO2_
-    nqtottr=nqtottr_
-    ALLOCATE(tracers(nqtot)); tracers(:) = tracers_(:)
-#ifdef CPP_StratAer
-    nbtr_bin=nbtr_bin_
-    nbtr_sulgas=nbtr_sulgas_
-    id_OCS_strat=id_OCS_strat_
-    id_SO2_strat=id_SO2_strat_
-    id_H2SO4_strat=id_H2SO4_strat_
-    id_BIN01_strat=id_BIN01_strat_
-#endif
-    type_trac = type_trac_
-    ALLOCATE(niadv(nqtot))
-    niadv(:)=niadv_(:)
-    ALLOCATE(conv_flg(nbtr))
-    conv_flg(:)=conv_flg_(:)
-    ALLOCATE(pbl_flg(nbtr))
-    pbl_flg(:)=pbl_flg_(:)
-    ALLOCATE(solsym(nbtr))
-    solsym(:)=solsym_(:)
-     
-    IF(prt_level.ge.1) THEN
-      write(lunout,*) TRIM(modname)//": nqtot,nqo,nbtr,nqCO2",nqtot,nqo,nbtr,nqCO2
-    ENDIF
-    
-    ! Isotopes:
-    
-    ! First check that the "niso_possibles" has the correct value
-    IF (niso_possibles.ne.niso_possibles_) THEN
-      CALL abort_physic(modname,&
-           "wrong value for parameter niso_possibles in infotrac_phy",1)
-    ENDIF
-    
-    ok_isotopes=ok_isotopes_
-    ok_iso_verif=ok_iso_verif_
-    ok_isotrac=ok_isotrac_
-    ok_init_iso=ok_init_iso_
-    
-    niso=niso_
-    ntraceurs_zone=ntraceurs_zone_
-    ntraciso=ntraciso_
-    
-    IF (ok_isotopes) THEN
-      tnat(:)=tnat_(:)
-      alpha_ideal(:)=alpha_ideal_(:)
-      use_iso(:)=use_iso_(:)
-    
-      ALLOCATE(iqiso(ntraciso,nqo))
-      iqiso(:,:)=iqiso_(:,:)
-      ALLOCATE(iso_indnum(nqtot))
-      iso_indnum(:)=iso_indnum_(:)
-      
-      indnum_fn_num(:)=indnum_fn_num_(:)
-      
-      ALLOCATE(index_trac(ntraceurs_zone,niso))
-      index_trac(:,:)=index_trac_(:,:)
-    ENDIF ! of IF(ok_isotopes)
-
-    ALLOCATE(itr_indice(nqtottr))
-    itr_indice(:)=itr_indice_(:)
-
-        write(*,*) 'infotrac_phy 207: nqtottr=',nqtottr
-        write(*,*) 'ntraciso,niso=',ntraciso,niso
-        write(*,*) 'itr_indice=',itr_indice
-#ifdef ISOVERIF
-        write(*,*) 'iso_iName=',tracers(:)%iso_iName
-#endif
-  
-  END SUBROUTINE init_infotrac_phy
-
-END MODULE infotrac_phy
+link ../phylmd/infotrac_phy.F90
Index: /LMDZ6/trunk/libf/phylmdiso/phyetat0.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmdiso/phyetat0.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmdiso/phyetat0.F90	(revision 4056)
@@ -29,12 +29,11 @@
        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: nbtr, nqo, type_trac, tracers, niadv, &
-        itr_indice ! C Risi
-  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 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
@@ -92,5 +91,5 @@
   INTEGER length
   PARAMETER (length=100)
-  INTEGER it, iiq, isw
+  INTEGER it, iq, isw
   REAL tab_cntrl(length), tabcntr0(length)
   CHARACTER*7 str7
@@ -104,5 +103,4 @@
   REAL Rland_ice(niso,klon)
 #endif
-  INTEGER iq
   ! FH1D
   !     real iolat(jjm+1)
@@ -471,12 +469,11 @@
 
   IF (type_trac == 'lmdz') THEN
-     DO it=1, nbtr                                                                 
-!!        iiq=niadv(it+2)                                                           ! jyg
-!        iiq=niadv(it+nqo)   C Risi: on efface pour remplacer         
-        iq=itr_indice(it)                                                    
-        iiq=niadv(iq)                                                        ! jyg
-        found=phyetat0_get(1,trs(:,it),"trs_"//TRIM(tracers(iiq)%name), &
-                                  "Surf trac"//TRIM(tracers(iiq)%name),0.)
-     ENDDO
+     it = 0
+     DO iq = 1, nqtot
+        IF(.NOT.tracers(iq)%isAdvected .OR. tracers(iq)%isH2Ofamily) 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
@@ -656,5 +653,5 @@
    CALL get_field(name, field, found)
    IF (.NOT. found) THEN
-     WRITE(lunout,*) "phyetat0: Le champ <",name,"> est absent"
+     WRITE(lunout,*) "phyetat0: Le champ <",TRIM(name),"> est absent"
      WRITE(lunout,*) "Depart legerement fausse. Mais je continue"
      field(:,:)=default
Index: /LMDZ6/trunk/libf/phylmdiso/phyredem.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmdiso/phyredem.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmdiso/phyredem.F90	(revision 4056)
@@ -23,4 +23,5 @@
                                 wake_delta_pbl_tke, zmax0, f0, sig1, w01,    &
                                 wake_deltat, wake_deltaq, wake_s, wake_dens, &
+                                awake_dens, cv_gen,                          &
                                 wake_cstar,                                  &
                                 wake_pe, wake_fip, fm_therm, entr_therm,     &
@@ -38,7 +39,6 @@
   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, niadv, tracers, nbtr, nqo,itr_indice
+  USE infotrac_phy, ONLY: type_trac, nqtot, tracers, nbtr, niso, ntraciso
 #ifdef ISO
-  USE infotrac_phy, ONLY: itr_indice,niso,ntraciso
 #ifdef ISOVERIF
   USE isotopes_verif_mod
@@ -74,5 +74,4 @@
   REAL Rland_ice(niso,klon)
 #endif
-  INTEGER iq ! C Risi
 
   INTEGER nid, nvarid, idim1, idim2, idim3
@@ -85,5 +84,5 @@
   CHARACTER (len=2) :: str2
   CHARACTER (len=256) :: nam, lnam
-  INTEGER           :: it, iiq, pass
+  INTEGER           :: it, iq, pass
 
   !======================================================================
@@ -185,9 +184,9 @@
     CALL put_field_srf1(pass,"TS","Temperature",ftsol(:,:))
 
-!!    CALL put_field_srf1(pass,"DELTA_TS","w-x surface temperature difference", delta_tsurf(:,:))
-    CALL put_field_srf1(pass,"DELTATS","w-x surface temperature difference", delta_tsurf(:,:))
-
-!    CALL put_field_srf1(pass,"BETA_S","Aridity factor", beta_aridity(:,:))
-    CALL put_field_srf1(pass,"BETAS","Aridity factor", beta_aridity(:,:))
+    IF (iflag_pbl>1 .AND. iflag_wake>=1  .AND. iflag_pbl_split >=1) then
+       CALL put_field_srf1(pass, "DELTATS", &
+                      "w-x surface temperature difference",  delta_tsurf(:,:))
+       CALL put_field_srf1(pass, "BETAS", "Aridity factor", beta_aridity(:,:))
+    end IF
 !    End surface variables
 
@@ -313,4 +312,8 @@
     CALL put_field(pass,"WAKE_DENS", "Wake num. /unit area", wake_dens)
 
+    CALL put_field(pass,"AWAKE_DENS", "Active Wake num. /unit area", awake_dens)
+
+    CALL put_field(pass,"CV_GEN", "CB birth rate", cv_gen)
+
     CALL put_field(pass,"WAKE_CSTAR", "WAKE_CSTAR", wake_cstar)
 
@@ -345,11 +348,13 @@
     IF (type_trac == 'lmdz') THEN
        CALL traclmdz_to_restart(trs)
-       DO it=1, nbtr
-!!        iiq=niadv(it+2)                                                           ! jyg
-          !iiq=niadv(it+nqo) ! C Risi: on efface pour remplacer:
-          iq=itr_indice(it)                                                           ! jyg
-          iiq=niadv(iq)                                                           ! jyg
-          CALL put_field(pass,"trs_"//tracers(iiq)%name, "", trs(:, it))
+       it = 0
+       DO iq = 1, nqtot
+          IF(.NOT.tracers(iq)%isAdvected .OR. tracers(iq)%isH2Ofamily) 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 (carbon_cycle_cpl) THEN
           IF (.NOT. ALLOCATED(co2_send)) THEN
@@ -417,5 +422,5 @@
 
   IMPLICIT NONE
-  INTEGER, INTENT(IN)            :: pass
+  INTEGER, INTENT(IN)           :: pass
   CHARACTER(LEN=*),  INTENT(IN) :: nam, lnam
   REAL,              INTENT(IN) :: field(:,:)
@@ -519,5 +524,5 @@
       CHARACTER*7 str7
       CHARACTER*2 str2
-      CHARACTER*50 striso_sortie
+      CHARACTER*50 outiso
       integer lnblnk
 #ifdef ISOTRAC
@@ -564,10 +569,10 @@
 
      if (ixt.le.niso) then
-        striso_sortie=striso(ixt)
+        outiso=striso(ixt)
      else
 #ifdef ISOTRAC
         iiso=index_iso(ixt)
         izone=index_zone(ixt)       
-        striso_sortie=striso(iiso)//strtrac(izone)
+        outiso=striso(iiso)//strtrac(izone)
 #else
         write(*,*) 'phyredem 546: ixt,ntraciso=', ixt,ntraciso
@@ -575,45 +580,35 @@
 #endif
      endif !if (ixt.le.niso) then
-      write(*,*) 'phyredem 550: ixt,striso_sortie=',ixt,striso_sortie(1:lnblnk(striso_sortie))
+      write(*,*) 'phyredem 550: ixt,outiso=',ixt,TRIM(outiso)
       
       iso_tmp_lonsrf(:,:)=fxtevap(ixt,:,:)
-      CALL put_field_srf1(pass,"XTEVAP"//striso_sortie(1:lnblnk(striso_sortie)), &
-     &           "Evaporation de surface",iso_tmp_lonsrf)
+      CALL put_field_srf1(pass, "XTEVAP"//TRIM(outiso), "Evaporation de surface",iso_tmp_lonsrf)
 
       iso_tmp_lonsrf(:,:)=xtsnow(ixt,:,:)
-      CALL put_field_srf1(pass,"XTSNOW"//striso_sortie(1:lnblnk(striso_sortie)), &
-     &           "NEIGE",iso_tmp_lonsrf)       
+      CALL put_field_srf1(pass, "XTSNOW"//TRIM(outiso), "NEIGE",       iso_tmp_lonsrf)       
 
       iso_tmp(:)=xtrain_fall(ixt,:)
-      CALL put_field(pass,"xtrain_f"//striso_sortie(1:lnblnk(striso_sortie)), &
-     &   "precipitation liquide",iso_tmp)
+      CALL put_field(pass,    "xtrain_f"//TRIM(outiso), "precipitation liquide",iso_tmp)
 
       iso_tmp(:)=xtsnow_fall(ixt,:)
-      CALL put_field(pass,"xtsnow_f"//striso_sortie(1:lnblnk(striso_sortie)), &
-     &    "precipitation solide",iso_tmp)
+      CALL put_field(pass,    "xtsnow_f"//TRIM(outiso), "precipitation solide",iso_tmp)
 
       iso_tmp_lonlev(:,:)=xt_ancien(ixt,:,:)
-      CALL put_field(pass,"XTANCIEN"//striso_sortie(1:lnblnk(striso_sortie)), &
-     &   "QANCIEN",iso_tmp_lonlev)
+      CALL put_field(pass,    "XTANCIEN"//TRIM(outiso), "QANCIEN",     iso_tmp_lonlev)
 
       iso_tmp_lonlev(:,:)=xtl_ancien(ixt,:,:)
-      CALL put_field(pass,"XTLANCIEN"//striso_sortie(1:lnblnk(striso_sortie)), &
-     &   "QLANCIEN",iso_tmp_lonlev)
+      CALL put_field(pass,   "XTLANCIEN"//TRIM(outiso), "QLANCIEN",    iso_tmp_lonlev)
 
       iso_tmp_lonlev(:,:)=xts_ancien(ixt,:,:)
-      CALL put_field(pass,"XTSANCIEN"//striso_sortie(1:lnblnk(striso_sortie)), &
-     &   "QSANCIEN",iso_tmp_lonlev)
+      CALL put_field(pass,   "XTSANCIEN"//TRIM(outiso), "QSANCIEN",    iso_tmp_lonlev)
 
       iso_tmp_lonlev(:,:)=wake_deltaxt(ixt,:,:)
-      CALL put_field(pass,"WAKE_DELTAXT"//striso_sortie(1:lnblnk(striso_sortie)), &
-     &   "WAKE_DELTAQ",iso_tmp_lonlev)
+      CALL put_field(pass,"WAKE_DELTAXT"//TRIM(outiso), "WAKE_DELTAQ", iso_tmp_lonlev)
 
       iso_tmp(:)=xtrun_off_lic_0(ixt,:)
-      CALL put_field(pass,"XTRUNOFFLIC0"//striso_sortie(1:lnblnk(striso_sortie)), &
-     &   "Runofflic0",iso_tmp)
+      CALL put_field(pass,"XTRUNOFFLIC0"//TRIM(outiso), "Runofflic0",  iso_tmp)
 
       iso_tmp_lonlev(:,:)=wake_deltaxt(ixt,:,:)
-      CALL put_field(pass,"WAKE_DELTAXT"//striso_sortie(1:lnblnk(striso_sortie)), &
-     &   "WAKE_DELTAXT",iso_tmp_lonlev)
+      CALL put_field(pass,"WAKE_DELTAXT"//TRIM(outiso), "WAKE_DELTAXT",iso_tmp_lonlev)
 
       ! variables seulement pour niso:
@@ -621,10 +616,8 @@
 
       iso_tmp(:)=xtsol(ixt,:)
-      CALL put_field(pass,"XTSOL"//striso_sortie(1:lnblnk(striso_sortie)), &
-     &   "Eau dans le sol (mm)",iso_tmp)
+      CALL put_field(pass,      "XTSOL"//TRIM(outiso), "Eau dans le sol (mm)",iso_tmp)
 
       iso_tmp(:)=Rland_ice(ixt,:)
-      CALL put_field(pass,"Rland_ice"//striso_sortie(1:lnblnk(striso_sortie)), &
-     &   "ratio land ice",iso_tmp)
+      CALL put_field(pass,  "Rland_ice"//TRIM(outiso), "ratio land ice",      iso_tmp)
 
       endif ! if (ixt.le.niso) then
Index: /LMDZ6/trunk/libf/phylmdiso/phys_output_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmdiso/phys_output_mod.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmdiso/phys_output_mod.F90	(revision 4056)
@@ -35,6 +35,5 @@
     USE iophy 
     USE dimphy
-    USE infotrac_phy, ONLY: nqtot, nqo, niadv, tracers, type_trac, maxlen, &
-        nqtottr,itr_indice ! C Risi
+    USE infotrac_phy, ONLY: nqtot, tracers, type_trac, niso, ntraciso, maxlen
     USE ioipsl
     USE phys_cal_mod, only : hour, calend
@@ -52,5 +51,4 @@
 #endif
 #ifdef ISO
-    USE infotrac_phy,ONLY: niso, ntraciso
     USE isotopes_mod, ONLY: striso,iso_HTO
 #ifdef ISOTRAC
@@ -103,6 +101,5 @@
     CHARACTER(LEN=4), DIMENSION(nlevSTD)  :: clevSTD
     REAL, DIMENSION(nlevSTD)              :: rlevSTD
-    INTEGER                               :: nsrf, k, iq, iiq, iff, i, j, ilev
-    INTEGER                               :: itr ! C Risi
+    INTEGER                               :: nsrf, k, iq, iff, i, j, ilev, itr, ixt, iiso, izone
     INTEGER                               :: naero
     LOGICAL                               :: ok_veget
@@ -124,5 +121,4 @@
 
 #ifdef ISO
-    INTEGER  :: ixt,iiso,izone
     CHARACTER(LEN=LEN(striso)) :: outiso
     CHARACTER(LEN=20) :: unit
@@ -133,15 +129,11 @@
 !!!!!!!!!! stockage dans une region limitee pour chaque fichier !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     !                 entre [phys_out_lonmin,phys_out_lonmax] et [phys_out_latmin,phys_out_latmax]
-
-    LOGICAL, DIMENSION(nfiles), SAVE  :: phys_out_regfkey       = (/ .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., &
-                                                                     .FALSE., .FALSE., .FALSE., .FALSE., .FALSE. /)
-    REAL, DIMENSION(nfiles), SAVE     :: phys_out_lonmin        = (/ -180., -180., -180., -180., -180., &
-                                                                     -180., -180., -180., -180., -180. /)
-    REAL, DIMENSION(nfiles), SAVE     :: phys_out_lonmax        = (/  180.,  180.,  180.,  180.,  180., &
-                                                                      180.,  180.,  180.,  180.,  180. /)
-    REAL, DIMENSION(nfiles), SAVE     :: phys_out_latmin        = (/  -90.,  -90.,  -90.,  -90.,  -90., &
-                                                                      -90.,  -90.,  -90.,  -90.,  -90. /)
-    REAL, DIMENSION(nfiles), SAVE     :: phys_out_latmax        = (/   90.,   90.,   90.,   90.,   90., &
-                                                                       90.,   90.,   90.,   90.,   90. /)
+    LOGICAL, DIMENSION(nfiles), SAVE :: &
+      phys_out_regfkey = [.FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE.]
+    REAL,    DIMENSION(nfiles), SAVE :: &
+      phys_out_lonmin  = [  -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.], &
+      phys_out_lonmax  = [   180.,    180.,    180.,    180.,    180.,    180.,    180.,    180.,    180.,    180.], &
+      phys_out_latmin  = [   -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.], &
+      phys_out_latmax  = [    90.,     90.,     90.,     90.,     90.,     90.,     90.,     90.,     90.,     90.]
     REAL, DIMENSION(klev,2) :: Ahyb_bounds, Bhyb_bounds
     REAL, DIMENSION(klev+1)   :: lev_index
@@ -401,39 +393,16 @@
     CALL wxios_add_vaxis("bnds", 2, (/1.,2./))
 
-     CALL wxios_add_vaxis("Alt", &
+    CALL wxios_add_vaxis("Alt", &
             levmax(iff) - levmin(iff) + 1, pseudoalt)
 
-    IF (NSW.EQ.6) THEN
-!
-!wl1_sun: minimum bound of wavelength (in um)
-!
-      wl1_sun(1)=0.180
-      wl1_sun(2)=0.250
-      wl1_sun(3)=0.440
-      wl1_sun(4)=0.690
-      wl1_sun(5)=1.190
-      wl1_sun(6)=2.380
-!
-!wl2_sun: maximum bound of wavelength (in um)
-!
-      wl2_sun(1)=0.250
-      wl2_sun(2)=0.440
-      wl2_sun(3)=0.690
-      wl2_sun(4)=1.190
-      wl2_sun(5)=2.380
-      wl2_sun(6)=4.000
-!
-    ELSE IF(NSW.EQ.2) THEN
-!
-!wl1_sun: minimum bound of wavelength (in um)
-!
-      wl1_sun(1)=0.250
-      wl1_sun(2)=0.690
-!
-!wl2_sun: maximum bound of wavelength (in um)
-!
-      wl2_sun(1)=0.690
-      wl2_sun(2)=4.000
-    ENDIF
+    ! wl1_sun/wl2_sun: minimum/maximum bound of wavelength (in um)
+    SELECT CASE(NSW)
+      CASE(6)
+        wl1_sun(1:6) = [0.180, 0.250, 0.440, 0.690, 1.190, 2.380]
+        wl2_sun(1:6) = [0.250, 0.440, 0.690, 1.190, 2.380, 4.000]
+      CASE(2)
+        wl1_sun(1:2) = [0.250, 0.690]
+        wl2_sun(1:2) = [0.690, 4.000]
+    END SELECT
 
     DO ISW=1, NSW
@@ -533,23 +502,16 @@
      ENDIF ! clef_files
 
-        write(lunout,*) 'phys_output_mid 496: nqtottr=',nqtottr
-        write(lunout,*) 'itr_indice=',itr_indice
-!       IF (nqtot>=nqo+1) THEN
-!
-            !DO iq=nqo+1,nqtot 
-            ! C Risi: on modifie la boucle
-          DO itr=1,nqtottr ! C Risi
-            iq=itr_indice(itr)  ! C Risi
-            write(*,*) 'phys_output_mid 503: itr=',itr
-  
-            iiq=niadv(iq)
-            dn = 'd'//TRIM(tracers(iiq)%name)//'_'
+          itr = 0
+          DO iq = 1, nqtot 
+            IF(.NOT.tracers(iq)%isAdvected .OR. tracers(iq)%isH2Ofamily) CYCLE
+            itr = itr + 1
+            dn = 'd'//TRIM(tracers(iq)%name)//'_'
 
             flag = [1, 5, 5, 5, 10, 10, 11, 11, 11, 11]
-            lnam = 'Tracer '//TRIM(tracers(iiq)%longName)
-            tnam = TRIM(tracers(iiq)%name); o_trac          (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+            lnam = 'Tracer '//TRIM(tracers(iq)%longName)
+            tnam = TRIM(tracers(iq)%name);  o_trac          (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
 
             flag = [4, 7, 7, 7, 10, 10, 11, 11, 11, 11]
-            lnam = 'Tendance tracer '//TRIM(tracers(iiq)%longName)
+            lnam = 'Tendance tracer '//TRIM(tracers(iq)%longName)
             tnam = TRIM(dn)//'vdf';         o_dtr_vdf       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
 
@@ -570,18 +532,18 @@
             tnam = TRIM(dn)//'uscav';       o_dtr_uscav     (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
 
-            lnam = 'tracer tendency dry deposition'//TRIM(tracers(iiq)%longName)
+            lnam = 'tracer tendency dry deposition'//TRIM(tracers(iq)%longName)
             tnam = 'cum'//TRIM(dn)//'dry';  o_dtr_dry       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
 
             flag = [1, 4, 10, 10, 10, 10, 11, 11, 11, 11]
-            lnam = 'Cumulated tracer '//TRIM(tracers(iiq)%longName)
-            tnam = 'cum'//TRIM(tracers(iiq)%name); o_trac_cum(itr)= ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
+            lnam = 'Cumulated tracer '//TRIM(tracers(iq)%longName)
+            tnam = 'cum'//TRIM(tracers(iq)%name); o_trac_cum(itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
           ENDDO
 
    ENDDO !  iff
 
-        write(*,*) 'phys_output_mid 589'
 #ifdef ISO
+    write(*,*) 'phys_output_mid 589'
     do ixt=1,ntraciso
-      if (ixt.le.niso) then
+      if (ixt <= niso) then
         outiso=striso(ixt)
       else
@@ -630,6 +592,6 @@
       END IF
     enddo !do ixt=1,niso
-#endif
-        write(*,*) 'phys_output_mid 596'
+    write(*,*) 'phys_output_mid 596'
+#endif
 
 
Index: /LMDZ6/trunk/libf/phylmdiso/phys_output_write_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmdiso/phys_output_write_mod.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmdiso/phys_output_write_mod.F90	(revision 4056)
@@ -1,2667 +1,1 @@
-!
-! $Id: phys_output_write_mod.F90 3900 2021-05-17 13:35:58Z evignon $
-!
-MODULE phys_output_write_mod
-
-  USE phytrac_mod, ONLY : d_tr_cl, d_tr_th, d_tr_cv, d_tr_lessi_impa, &
-       d_tr_lessi_nucl, d_tr_insc, d_tr_bcscav, d_tr_evapls, d_tr_ls,  &
-       d_tr_trsp, d_tr_sscav, d_tr_sat, d_tr_uscav, flux_tr_dry
-
-  ! Author: Abderrahmane IDELKADI (original include file)
-  ! Author: Laurent FAIRHEAD (transformation to module/subroutine)
-  ! Author: Ulysse GERARD (effective implementation)
-
-CONTAINS 
-
-  ! ug Routine pour définir (lors du premier passage) ET sortir les variables
-  SUBROUTINE phys_output_write(itap, pdtphys, paprs, pphis, &
-       pplay, lmax_th, aerosol_couple,         &
-       ok_ade, ok_aie, ok_volcan, ivap, iliq, isol, ok_sync, &
-       ptconv, read_climoz, clevSTD, ptconvth, &
-       d_u, d_t, qx, d_qx, zmasse, flag_aerosol, flag_aerosol_strat, ok_cdnc)
-
-    ! This subroutine does the actual writing of diagnostics that were
-    ! defined and initialised in phys_output_mod.F90
-
-    USE dimphy, ONLY: klon, klev, klevp1
-    USE infotrac_phy, ONLY: nbtr, nqtot, nqo, type_trac, tracers, niadv, &
-        nqtottr,itr_indice
-    USE strings_mod,  ONLY: maxlen
-    USE mod_phys_lmdz_para, ONLY: is_north_pole_phy,is_south_pole_phy
-    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
-    USE time_phylmdz_mod, ONLY: day_step_phy, start_time, itau_phy
-    USE vertical_layers_mod, ONLY : ap, bp, aps, bps
-    USE phys_output_ctrlout_mod, ONLY: o_phis, o_aire, is_ter, is_lic, is_oce, &
-         o_longitude, o_latitude, &
-         o_Ahyb, o_Bhyb,o_Ahyb_bounds, o_Bhyb_bounds, & 
-         o_Ahyb_mid, o_Bhyb_mid,o_Ahyb_mid_bounds, o_Bhyb_mid_bounds, & 
-         is_ave, is_sic, o_contfracATM, o_contfracOR, &
-         o_aireTER, o_flat, o_slp, o_ptstar, o_pt0, o_tsol, &
-         o_t2m, o_t2m_min, o_t2m_max, &
-         o_t2m_min_mon, o_t2m_max_mon, &
-         o_nt2mout, o_nt2moutfg, &
-         o_nq2mout, o_nq2moutfg, &
-         o_nu2mout, o_nu2moutfg, &
-         o_q2m, o_ustar, o_u10m, o_v10m, &
-         o_wind10m, o_wind10max, o_wind100m, o_gusts, o_sicf, &
-         o_loadfactor_wind_onshore, o_loadfactor_wind_offshore, &
-         o_psol, o_mass, o_qsurf, o_qsol, &
-         o_precip, o_rain_fall, o_rain_con, o_ndayrain, o_plul, o_pluc, o_plun, &
-         o_snow, o_msnow, o_fsnow, o_evap, o_ep,o_epmax_diag, & ! epmax_cape
-         o_tops, o_tops0, o_topl, o_topl0, &
-         o_SWupTOA, o_SWupTOAclr, o_SWupTOAcleanclr, o_SWdnTOA, o_fdiffSWdnSFC, &
-         o_SWdnTOAclr, o_nettop, o_SWup200, &
-         o_SWup200clr, o_SWdn200, o_SWdn200clr, &
-         o_LWup200, o_LWup200clr, o_LWdn200, &
-         o_LWdn200clr, o_sols, o_sols0, &
-         o_soll, o_radsol, o_soll0, o_SWupSFC, &
-         o_SWupSFCclr, o_SWupSFCcleanclr, o_SWdnSFC, o_SWdnSFCclr, o_SWdnSFCcleanclr, &
-         o_LWupSFC, o_LWdnSFC, o_LWupSFCclr, &
-         o_LWdnSFCclr, o_LWupTOAcleanclr, o_LWdnSFCcleanclr, o_bils, o_bils_diss, &
-         o_bils_ec,o_bils_ech, o_bils_tke, o_bils_kinetic, &
-         o_bils_latent, o_bils_enthalp, o_sens, &
-         o_fder, o_ffonte, o_fqcalving, o_fqfonte, o_mrroli, o_runofflic, &
-         o_taux, o_tauy, o_snowsrf, o_qsnow, &
-         o_snowhgt, o_toice, o_sissnow, o_runoff, &
-         o_albslw3, o_pourc_srf, o_fract_srf, &
-         o_taux_srf, o_tauy_srf, o_tsol_srf, &
-         o_evappot_srf, o_ustar_srf, o_u10m_srf, &
-         o_v10m_srf, o_t2m_srf, o_evap_srf, &
-         o_sens_srf, o_lat_srf, o_flw_srf, &
-         o_fsw_srf, o_wbils_srf, o_wbilo_srf, &
-         o_wevap_srf, o_wrain_srf, o_wsnow_srf, &
-         o_tke_srf, o_tke_max_srf,o_dltpbltke_srf, o_wstar, &
-         o_l_mixmin,o_l_mix, &
-         o_cdrm, o_cdrh, o_cldl, o_cldm, o_cldh, &
-         o_cldt, o_JrNt, o_cldljn, o_cldmjn, &
-         o_cldhjn, o_cldtjn, o_cldq, o_lwp, o_iwp, &
-         o_ue, o_ve, o_uq, o_vq, o_cape, o_pbase, &
-         o_uwat, o_vwat, &
-         o_ptop, o_fbase, o_plcl, o_plfc, &
-         o_wbeff, o_convoccur, o_cape_max, o_upwd, o_ep,o_epmax_diag, &
-         o_Mipsh, o_Ma, &
-         o_dnwd, o_dnwd0, o_ftime_deepcv, o_ftime_con, o_mc, &
-         o_prw, o_prlw, o_prsw, o_s_pblh, o_s_pblt, o_s_lcl, &
-         o_s_therm, o_uSTDlevs, o_vSTDlevs, &
-         o_wSTDlevs, o_zSTDlevs, o_qSTDlevs, &
-         o_tSTDlevs, epsfra, o_t_oce_sic, &
-         o_ale_bl, o_alp_bl, o_ale_wk, o_alp_wk, &
-         o_dtvdf_x    , o_dtvdf_w    , o_dqvdf_x    , o_dqvdf_w    , &
-         o_sens_x     , o_sens_w     , o_flat_x     , o_flat_w     , &
-         o_delta_tsurf, o_delta_tsurf_srf, &
-         o_cdragh_x   , o_cdragh_w   , o_cdragm_x   , o_cdragm_w   , &
-         o_kh         , o_kh_x       , o_kh_w       , &
-         o_ale, o_alp, o_cin, o_WAPE, o_wake_h, o_cv_gen, o_wake_dens, &
-         o_wake_s, o_wake_deltat, o_wake_deltaq, &
-         o_wake_omg, o_dtwak, o_dqwak, o_dqwak2d, o_Vprecip, &
-         o_qtaa, o_Clwaa, &
-         o_ftd, o_fqd, o_wdtrainA, o_wdtrainS, o_wdtrainM, &
-         o_n2, o_s2, o_proba_notrig, &
-         o_random_notrig, o_ale_bl_stat, &
-         o_ale_bl_trig, o_alp_bl_det, &
-         o_alp_bl_fluct_m, o_alp_bl_fluct_tke, &
-         o_alp_bl_conv, o_alp_bl_stat, &
-         o_slab_qflux, o_tslab, o_slab_bils, &
-         o_slab_bilg, o_slab_sic, o_slab_tice, &
-         o_slab_hdiff, o_slab_ekman, o_slab_gm,  &
-         o_weakinv, o_dthmin, o_cldtau, &
-         o_cldemi, o_pr_con_l, o_pr_con_i, &
-         o_pr_lsc_l, o_pr_lsc_i, o_re, o_fl, &
-         o_rh2m, &
-         o_qsat2m, o_tpot, o_tpote, o_SWnetOR, &
-         o_LWdownOR, o_snowl, &
-         o_solldown, o_dtsvdfo, o_dtsvdft, &
-         o_dtsvdfg, o_dtsvdfi, o_z0m, o_z0h,  o_od443aer, o_od550aer, &
-         o_dryod550aer, o_od865aer, o_abs550aer, o_od550lt1aer, &
-         o_sconcso4, o_sconcno3, o_sconcoa, o_sconcbc, &
-         o_sconcss, o_sconcdust, o_concso4, o_concno3, &
-         o_concoa, o_concbc, o_concss, o_concdust, &
-         o_loadso4, o_loadoa, o_loadbc, o_loadss, &
-         o_loaddust, o_loadno3, o_tausumaero, & 
-         o_drytausumaero, o_tausumaero_lw, &
-         o_topswad, o_topswad0, o_solswad, o_solswad0, &
-         o_toplwad, o_toplwad0, o_sollwad, o_sollwad0, &
-         o_swtoaas_nat, o_swsrfas_nat, &
-         o_swtoacs_nat, o_swtoaas_ant, &
-         o_swsrfas_ant, o_swtoacs_ant, &
-         o_swsrfcs_ant, o_swtoacf_nat, &
-         o_swsrfcf_nat, o_swtoacf_ant, &
-         o_swsrfcs_nat, o_swsrfcf_ant, &
-         o_swtoacf_zero, o_swsrfcf_zero, &
-         o_topswai, o_solswai, o_toplwai, o_sollwai, o_scdnc, &
-         o_cldncl, o_reffclws, o_reffclwc, o_solbnd, o_stratomask,&
-         o_cldnvi, o_lcc, o_lcc3d, o_lcc3dcon, &
-         o_lcc3dstra, o_icc3dcon, o_icc3dstra, &
-         o_cldicemxrat, o_cldwatmxrat, o_reffclwtop, o_ec550aer, &
-         o_lwcon, o_iwcon, o_temp, o_theta, &
-         o_ovapinit, o_ovap, o_oliq, o_ocond, o_geop, &
-         o_vitu, o_vitv, o_vitw, o_pres, o_paprs, &
-         o_zfull, o_zhalf, o_rneb, o_rnebjn, o_rnebcon, &
-         o_rnebls, o_rneblsvol, o_rhum, o_rhl, o_rhi, o_ozone, o_ozone_light, &
-         o_duphy, o_dtphy, o_dqphy, o_dqphy2d, o_dqlphy, o_dqlphy2d, &
-         o_dqsphy, o_dqsphy2d, o_albe_srf, o_z0m_srf, o_z0h_srf, &
-         o_ages_srf, o_snow_srf, o_alb1, o_alb2, o_tke, o_tke_dissip, &
-         o_tke_max, o_kz, o_kz_max, o_clwcon, &
-         o_dtdyn, o_dqdyn, o_dqdyn2d, o_dqldyn, o_dqldyn2d, & 
-         o_dqsdyn, o_dqsdyn2d, o_dudyn, o_dvdyn, &
-         o_dtcon, o_tntc, o_ducon, o_dvcon, &
-         o_dqcon, o_dqcon2d, o_tnhusc, o_tnhusc, o_dtlsc, &
-         o_dtlschr, o_dqlsc, o_dqlsc2d, o_beta_prec, &
-         o_dtlscth, o_dtlscst, o_dqlscth, o_dqlscth2d, &
-         o_dqlscst, o_dqlscst2d, o_plulth, o_plulst, &
-         o_ptconvth, o_lmaxth, o_dtvdf, &
-         o_dtdis, o_dqvdf, o_dqvdf2d, o_dteva, o_dqeva, o_dqeva2d, &
-         o_ptconv, o_ratqs, o_dtthe, & 
-         o_duthe, o_dvthe, o_ftime_th, &
-         o_f_th, o_e_th, o_w_th, o_q_th, &
-         o_a_th, o_cloudth_sth, o_cloudth_senv, &
-         o_cloudth_sigmath, o_cloudth_sigmaenv, &
-         o_d_th, o_f0_th, o_zmax_th, &
-         o_dqthe, o_dqthe2d, o_dtajs, o_dqajs, o_dqajs2d, o_dtswr, &
-         o_dtsw0, o_dtlwr, o_dtlw0, o_dtec, &
-         o_duvdf, o_dvvdf, o_duoro, o_dvoro, &
-         o_dtoro, o_dulif, o_dvlif, o_dtlif, &
-         o_du_gwd_hines, o_dv_gwd_hines, o_dthin, o_dqch4, o_rsu, &
-         o_du_gwd_front, o_dv_gwd_front, &
-         o_east_gwstress, o_west_gwstress, &
-         o_rsd, o_rlu, o_rld, o_rsucs, o_rsdcs, o_rsucsaf, o_rsdcsaf, &
-         o_rlucs, o_rldcs, o_tnt, o_tntr, &
-         o_tntscpbl, o_tnhus, o_tnhusscpbl, &
-         o_evu, o_h2o, o_mcd, o_dmc, o_ref_liq, &
-         o_ref_ice, o_rsut4co2, o_rlut4co2, &
-         o_rsutcs4co2, o_rlutcs4co2, o_rsu4co2, &
-         o_rlu4co2, o_rsucs4co2, o_rlucs4co2, &
-         o_rsd4co2, o_rld4co2, o_rsdcs4co2, &
-         o_rldcs4co2, o_tnondef, o_ta, o_zg, &
-         o_hus, o_hur, o_ua, o_va, o_wap, &
-         o_psbg, o_tro3, o_tro3_daylight, &
-         o_uxv, o_vxq, o_vxT, o_wxq, o_vxphi, &
-         o_wxT, o_uxu, o_vxv, o_TxT, o_trac, &
-         o_dtr_vdf, o_dtr_the, o_dtr_con, &
-         o_dtr_lessi_impa, o_dtr_lessi_nucl, &
-         o_dtr_insc, o_dtr_bcscav, o_dtr_evapls, &
-         o_dtr_ls, o_dtr_trsp, o_dtr_sscav, o_dtr_dry, &
-         o_dtr_sat, o_dtr_uscav, o_trac_cum, o_du_gwd_rando, o_dv_gwd_rando, &
-         o_ustr_gwd_hines,o_vstr_gwd_hines,o_ustr_gwd_rando,o_vstr_gwd_rando, &
-         o_ustr_gwd_front,o_vstr_gwd_front, &
-         o_sens_prec_liq_oce, o_sens_prec_liq_sic, &
-         o_sens_prec_sol_oce, o_sens_prec_sol_sic, &
-         o_lat_prec_liq_oce, o_lat_prec_liq_sic, &
-         o_lat_prec_sol_oce, o_lat_prec_sol_sic, &
-         o_sza, &
-! Marine
-         o_map_prop_hc, o_map_prop_hist, o_map_emis_hc, o_map_iwp_hc, &
-         o_map_deltaz_hc, o_map_pcld_hc, o_map_tcld_hc, &
-         o_map_emis_hist, o_map_iwp_hist, o_map_deltaz_hist, &
-         o_map_rad_hist, &
-         o_map_emis_Cb, o_map_pcld_Cb, o_map_tcld_Cb, &
-         o_map_emis_ThCi, o_map_pcld_ThCi, o_map_tcld_ThCi, &
-         o_map_emis_Anv, o_map_pcld_Anv, o_map_tcld_Anv, &
-         o_map_ntot, o_map_hc,o_map_hist,o_map_Cb,o_map_ThCi,o_map_Anv, &
-#ifdef ISO
-         o_xtprecip,o_xtplul,o_xtpluc,o_xtovap,o_xtoliq,o_xtcond, &
-         o_xtevap,o_dxtdyn,o_dxtldyn,o_dxtcon,o_dxtlsc,o_dxteva, &
-         o_dxtajs,o_dxtvdf,o_dxtthe, o_dxtch4, &
-         o_dxtprod_nucl,o_dxtcosmo,o_dxtdecroiss, &
-#endif
-
-         o_alt_tropo, & 
-! Tropopause
-         o_p_tropopause, o_z_tropopause, o_t_tropopause,  &
-         o_col_O3_strato, o_col_O3_tropo,                 & 
-!--interactive CO2
-         o_flx_co2_ocean, o_flx_co2_ocean_cor, &
-         o_flx_co2_land, o_flx_co2_land_cor, & 
-         o_flx_co2_ff, o_flx_co2_bb, & 
-         o_delta_sst, o_delta_sal, o_ds_ns, o_dt_ns, o_dter, o_dser, o_tkt, &
-         o_tks, o_taur, o_sss
-
-#ifdef CPP_StratAer
-    USE phys_output_ctrlout_mod, ONLY:  & 
-         o_budg_3D_nucl, o_budg_3D_cond_evap, o_budg_3D_ocs_to_so2, o_budg_3D_so2_to_h2so4, &
-         o_budg_sed_part, o_R2SO4, o_OCS_lifetime, o_SO2_lifetime, &
-         o_budg_3D_backgr_ocs, o_budg_3D_backgr_so2, & 
-         o_budg_dep_dry_ocs, o_budg_dep_wet_ocs, &
-         o_budg_dep_dry_so2, o_budg_dep_wet_so2, &
-         o_budg_dep_dry_h2so4, o_budg_dep_wet_h2so4, &
-         o_budg_dep_dry_part, o_budg_dep_wet_part, & 
-         o_budg_emi_ocs, o_budg_emi_so2, o_budg_emi_h2so4, o_budg_emi_part, & 
-         o_budg_ocs_to_so2, o_budg_so2_to_h2so4, o_budg_h2so4_to_part, &
-         o_surf_PM25_sulf, o_ext_strat_550, o_tau_strat_550, &
-         o_vsed_aer, o_tau_strat_1020, o_ext_strat_1020, o_f_r_wet
-#endif
-    
-    USE phys_output_ctrlout_mod, ONLY: o_heat_volc, o_cool_volc !NL
-    USE phys_state_var_mod, ONLY: heat_volc, cool_volc !NL
-
-    USE phys_state_var_mod, ONLY: pctsrf, rain_fall, snow_fall, &
-         qsol, z0m, z0h, fevap, agesno, &
-         nday_rain, rain_con, snow_con, &
-         topsw, toplw, toplw0, swup, swdn, solswfdiff, &
-         topsw0, swupc0, swdnc0, swup0, swdn0, SWup200, SWup200clr, &
-         SWdn200, SWdn200clr, LWup200, LWup200clr, &
-         LWdn200, LWdn200clr, solsw, solsw0, sollw, &
-         radsol, swradcorr, sollw0, sollwdown, sollw, gustiness, &
-         sollwdownclr, lwdnc0, lwdn0, ftsol, ustar, u10m, &
-         v10m, pbl_tke, wake_delta_pbl_TKE, &
-         delta_tsurf, &
-         wstar, cape, ema_pcb, ema_pct, &
-         ema_cbmf, Mipsh, Ma, fm_therm, ale_bl, alp_bl, ale, &
-         alp, cin, wake_pe, wake_dens, cv_gen, wake_s, wake_deltat, &
-         wake_deltaq, ftd, fqd, ale_bl_trig, albsol1, &
-         ale_wake, ale_bl_stat, &
-         rnebcon, wo, falb1, albsol2, coefh, clwcon0, &
-         ratqs, entr_therm, zqasc, detr_therm, f0, &
-         lwup, lwdn, lwupc0, lwup0, coefm, &
-         swupp, lwupp, swupc0p, swup0p, lwupc0p, lwup0p, swdnp, lwdnp, &
-         swdnc0p, swdn0p, lwdnc0p, lwdn0p, tnondef, O3sumSTD, uvsumSTD, &
-         vqsumSTD, vTsumSTD, O3daysumSTD, wqsumSTD, &
-         vphisumSTD, wTsumSTD, u2sumSTD, v2sumSTD, &
-         T2sumSTD, nlevSTD, du_gwd_rando, du_gwd_front, &
-         ulevSTD, vlevSTD, wlevSTD, philevSTD, qlevSTD, tlevSTD, &
-         rhlevSTD, O3STD, O3daySTD, uvSTD, vqSTD, vTSTD, wqSTD, vphiSTD, &
-         wTSTD, u2STD, v2STD, T2STD, missing_val_nf90, delta_sal, ds_ns, &
-#ifdef ISO
-        xtrain_con, xtsnow_con, xtrain_fall, xtsnow_fall, &
-#endif
-         dt_ns, delta_sst
-
-    USE phys_local_var_mod, ONLY: zxfluxlat, slp, ptstar, pt0, zxtsol, zt2m, &
-         zn2mout, t2m_min_mon, t2m_max_mon, evap, &
-         l_mixmin,l_mix, tke_dissip, &
-         zu10m, zv10m, zq2m, zustar, zxqsurf, &
-         rain_lsc, rain_num, snow_lsc, bils, sens, fder, &
-         zxffonte, zxfqcalving, zxfqfonte, zxrunofflic, fluxu, &
-         fluxv, zxsnow, qsnow, snowhgt, to_ice, &
-         sissnow, runoff, albsol3_lic, evap_pot, &
-         t2m, fluxt, fluxlat, fsollw, fsolsw, &
-         wfbils, wfbilo, wfevap, wfrain, wfsnow, &
-         cdragm, cdragh, cldl, cldm, &
-         cldh, cldt, JrNt,   & ! only output names: cldljn,cldmjn,cldhjn,cldtjn
-         cldq, flwp, fiwp, ue, ve, uq, vq, &
-         uwat, vwat, &
-         plcl, plfc, wbeff, convoccur, upwd, dnwd, dnwd0, prw, prlw, prsw, &
-         s_pblh, s_pblt, s_lcl, s_therm, uwriteSTD, &
-         vwriteSTD, wwriteSTD, phiwriteSTD, qwriteSTD, &
-         twriteSTD, alp_wake, &
-!!         dtvdf_x    ,dtvdf_w    ,dqvdf_x    ,dqvdf_w    , &
-         d_t_vdf_x    ,d_t_vdf_w    ,d_q_vdf_x    ,d_q_vdf_w    , &
-         sens_x     ,sens_w     ,zxfluxlat_x,zxfluxlat_w, &
-         cdragh_x   ,cdragh_w   ,cdragm_x   ,cdragm_w   , &
-         kh         ,kh_x       ,kh_w       , &
-         wake_h, &
-         wake_omg, d_t_wake, d_q_wake, Vprecip, qtaa, Clw, &
-         wdtrainA, wdtrainS, wdtrainM, n2, s2, proba_notrig, &
-         random_notrig, &
-         alp_bl_det, alp_bl_fluct_m, alp_bl_conv, &
-         alp_bl_stat, alp_bl_fluct_tke, slab_wfbils, &
-         weak_inversion, dthmin, cldtau, cldemi, &
-         pmflxr, pmflxs, prfl, psfl, re, fl, rh2m, &
-         qsat2m, tpote, tpot, d_ts, od443aer, od550aer, dryod550aer, &
-         od865aer, abs550aer, od550lt1aer, sconcso4, sconcno3, &
-         sconcoa, sconcbc, sconcss, sconcdust, concso4, concno3, &
-         concoa, concbc, concss, concdust, loadso4, &
-         loadoa, loadbc, loadss, loaddust, loadno3, tausum_aero, drytausum_aero, &
-         topswad_aero, topswad0_aero, solswad_aero, &
-         solswad0_aero, topsw_aero, solsw_aero, &
-         topsw0_aero, solsw0_aero, topswcf_aero, &
-         solswcf_aero, topswai_aero, solswai_aero, &
-         toplwad_aero, toplwad0_aero, sollwad_aero, &
-         sollwad0_aero, toplwai_aero, sollwai_aero, &
-         scdnc, cldncl, reffclws, reffclwc, cldnvi, stratomask,&
-         lcc, lcc3d, lcc3dcon, lcc3dstra, &
-         icc3dcon, icc3dstra, zfice, reffclwtop, &
-         ec550aer, flwc, fiwc, t_seri, theta, q_seri, &
-         ql_seri, qs_seri, tr_seri, &
-         zphi, u_seri, v_seri, omega, cldfra, &
-         rneb, rnebjn, rneblsvol, zx_rh, zx_rhl, zx_rhi, d_t_dyn,  & 
-         d_q_dyn,  d_ql_dyn, d_qs_dyn, &
-         d_q_dyn2d,  d_ql_dyn2d, d_qs_dyn2d, &
-         d_u_dyn, d_v_dyn, d_t_con, d_t_ajsb, d_t_ajs, &
-         d_u_ajs, d_v_ajs, &
-         d_u_con, d_v_con, d_q_con, d_q_ajs, d_t_lsc, &
-         d_t_lwr,d_t_lw0,d_t_swr,d_t_sw0, &
-         d_t_eva, d_q_lsc, beta_prec, d_t_lscth, &
-         d_t_lscst, d_q_lscth, d_q_lscst, plul_th, &
-         plul_st, d_t_vdf, d_t_diss, d_q_vdf, d_q_eva, &
-         zw2, fraca, zmax_th, d_q_ajsb, d_t_ec, d_u_vdf, &
-         d_v_vdf, d_u_oro, d_v_oro, d_t_oro, d_u_lif, &
-         d_v_lif, d_t_lif, du_gwd_hines, dv_gwd_hines, d_t_hin, &
-         dv_gwd_rando, dv_gwd_front, &
-         east_gwstress, west_gwstress, &
-         d_q_ch4, pmfd, pmfu, ref_liq, ref_ice, rhwriteSTD, &
-#ifdef ISO
-        xtrain_lsc, xtsnow_lsc, xt_seri, xtl_seri,xts_seri,xtevap, &
-        d_xt_dyn,d_xtl_dyn,d_xt_con,d_xt_vdf,d_xt_ajsb, &
-        d_xt_lsc,d_xt_eva,d_xt_ch4, &
-        d_xt_ajs, d_xt_ajsb, &
-        d_xt_prod_nucl,d_xt_cosmo,d_xt_decroiss, &
-#endif
-         ep, epmax_diag, &  ! epmax_cape
-         p_tropopause, t_tropopause, z_tropopause
-
-#ifdef CPP_StratAer 
-    USE phys_local_var_mod, ONLY:  &
-         budg_3D_nucl, budg_3D_cond_evap, budg_3D_ocs_to_so2, budg_3D_so2_to_h2so4, &
-         budg_sed_part, R2SO4, OCS_lifetime, SO2_lifetime, &
-         budg_3D_backgr_ocs, budg_3D_backgr_so2, & 
-         budg_dep_dry_ocs, budg_dep_wet_ocs, &
-         budg_dep_dry_so2, budg_dep_wet_so2, &
-         budg_dep_dry_h2so4, budg_dep_wet_h2so4, &
-         budg_dep_dry_part, budg_dep_wet_part, &
-         budg_emi_ocs, budg_emi_so2, budg_emi_h2so4, budg_emi_part, & 
-         budg_ocs_to_so2, budg_so2_to_h2so4, budg_h2so4_to_part, & 
-         surf_PM25_sulf, tau_strat_550, tausum_strat, &
-         vsed_aer, tau_strat_1020, f_r_wet
-#endif
-
-    USE carbon_cycle_mod, ONLY: fco2_ff, fco2_bb, fco2_land, fco2_ocean
-    USE carbon_cycle_mod, ONLY: fco2_ocean_cor, fco2_land_cor
-
-    USE phys_output_var_mod, ONLY: vars_defined, snow_o, zfra_o, bils_diss, &
-         bils_ec,bils_ech, bils_tke, bils_kinetic, bils_latent, bils_enthalp, &
-         itau_con, nfiles, clef_files, nid_files, dryaod_diag, &
-         zustr_gwd_hines, zvstr_gwd_hines,zustr_gwd_rando, zvstr_gwd_rando, &
-         zustr_gwd_front, zvstr_gwd_front, sza_o,    &
-         sens_prec_liq_o, sens_prec_sol_o, lat_prec_liq_o, lat_prec_sol_o, &
-         cloudth_sth,cloudth_senv,cloudth_sigmath,cloudth_sigmaenv, &
-! Marine
-         map_prop_hc, map_prop_hist, &
-         map_emis_hc,map_iwp_hc,map_deltaz_hc,&
-         map_pcld_hc,map_tcld_hc,&
-         map_emis_hist,map_iwp_hist,map_deltaz_hist,&
-         map_rad_hist,&
-         map_ntot,map_hc,map_hist,&
-         map_Cb,map_ThCi,map_Anv,&
-         map_emis_Cb,map_pcld_Cb,map_tcld_Cb,&
-         map_emis_ThCi,map_pcld_ThCi,map_tcld_ThCi,&
-         map_emis_Anv,map_pcld_Anv,map_tcld_Anv, &
-         alt_tropo, &
-!Ionela
-         ok_4xCO2atm, dter, dser, tkt, tks, taur, sss
-
-    USE ocean_slab_mod, ONLY: nslay, tslab, slab_bilg, tice, seaice, &
-        slab_ekman,slab_hdiff,slab_gm,dt_ekman, dt_hdiff, dt_gm, dt_qflux
-    USE pbl_surface_mod, ONLY: snow
-    USE indice_sol_mod, ONLY: nbsrf
-#ifdef ISO
-    USE infotrac_phy, only: ntraciso,niso,nqtottr
-    use isotopes_mod, only: iso_HTO
-#endif
-    USE geometry_mod, ONLY: cell_area, latitude_deg, longitude_deg
-    USE surface_data, ONLY: type_ocean, version_ocean, ok_veget, landice_opt
-    USE aero_mod, ONLY: naero_tot, id_STRAT_phy
-    USE ioipsl, ONLY: histend, histsync
-    USE iophy, ONLY: set_itau_iophy, histwrite_phy
-    USE netcdf, ONLY: nf90_fill_real
-    USE print_control_mod, ONLY: prt_level,lunout
-
-
-#ifdef CPP_XIOS
-    ! ug Pour les sorties XIOS
-    USE xios
-    USE wxios, ONLY: wxios_closedef, missing_val, wxios_set_context
-#endif
-    USE phys_cal_mod, ONLY : mth_len
-
-#ifdef CPP_RRTM
-    USE YOESW, ONLY : RSUN
-#endif
-    USE tracinca_mod, ONLY: config_inca
-    use config_ocean_skin_m, only: activate_ocean_skin
-
-    USE vertical_layers_mod, ONLY: presnivs
-
-    IMPLICIT NONE
-
-    INCLUDE "clesphys.h"
-    INCLUDE "thermcell.h"
-    INCLUDE "compbl.h"
-    INCLUDE "YOMCST.h"
-
-    ! Input
-    INTEGER :: itap, ivap, iliq, isol, read_climoz
-    INTEGER, DIMENSION(klon) :: lmax_th
-    LOGICAL :: aerosol_couple, ok_sync
-    LOGICAL :: ok_ade, ok_aie, ok_volcan
-    LOGICAL, DIMENSION(klon, klev) :: ptconv, ptconvth
-    REAL :: pdtphys
-    CHARACTER (LEN=4), DIMENSION(nlevSTD) :: clevSTD
-    REAL, DIMENSION(klon,nlevSTD) :: zx_tmp_fi3d_STD
-    REAL, DIMENSION(klon) :: pphis
-    REAL, DIMENSION(klon, klev) :: pplay, d_u, d_t
-    REAL, DIMENSION(klon, klev+1) :: paprs
-    REAL, DIMENSION(klon,klev,nqtot) :: qx, d_qx
-    REAL, DIMENSION(klon, klev) :: zmasse
-    INTEGER :: flag_aerosol_strat
-    INTEGER :: flag_aerosol 
-    LOGICAL :: ok_cdnc
-    REAL, DIMENSION(3) :: freq_moyNMC
-
-    ! Local
-    INTEGER :: itau_w
-    INTEGER :: i, iinit, iinitend=1, iff, iq, iiq, nsrf, k, ll, naero
-    REAL, DIMENSION (klon) :: zx_tmp_fi2d, zpt_conv2d, wind100m
-    REAL, DIMENSION (klon,klev) :: zx_tmp_fi3d, zpt_conv
-    REAL, DIMENSION (klon,klev+1) :: zx_tmp_fi3d1
-    REAL, DIMENSION (klon,NSW) :: zx_tmp_fi3dsp
-    CHARACTER (LEN=4)              :: bb2
-    INTEGER, DIMENSION(nbp_lon*nbp_lat)  :: ndex2d
-    INTEGER, DIMENSION(nbp_lon*nbp_lat*klev) :: ndex3d
-    REAL, PARAMETER :: dobson_u = 2.1415e-05 ! Dobson unit, in kg m-2
-!   REAL, PARAMETER :: missing_val=nf90_fill_real
-    REAL, DIMENSION(klev+1,2) :: Ahyb_bounds, Bhyb_bounds
-    REAL, DIMENSION(klev,2) :: Ahyb_mid_bounds, Bhyb_mid_bounds
-    INTEGER :: ilev
-    INTEGER, SAVE :: kmax_100m
-!$OMP THREADPRIVATE(kmax_100m)
-    REAL :: x
-#ifndef CPP_XIOS
-    REAL :: missing_val
-#endif
-    REAL, PARAMETER :: un_jour=86400.
-#ifdef ISO
-    INTEGER :: ixt
-#endif
-    INTEGER :: itr !  C Risi
-    INTEGER ISW
-    CHARACTER*1 ch1
-    CHARACTER(LEN=maxlen) :: varname, dn
-
-#ifdef CPP_XIOS
-    TYPE(xios_fieldgroup) :: group_handle
-    TYPE(xios_field) :: child
-#endif
-#ifdef CPP_StratAer 
-    LOGICAL, PARAMETER :: debug_strataer=.FALSE.
-#endif
-    REAL,DIMENSION(klon,klev) :: z, dz
-    REAL,DIMENSION(klon)      :: zrho, zt
-
-    INTEGER :: nqup
-
-    ! On calcul le nouveau tau:
-    itau_w = itau_phy + itap 
-    ! On le donne à iophy pour que les histwrite y aient accès:
-    CALL set_itau_iophy(itau_w)
-
- !   IF (.NOT.vars_defined) THEN
-       iinitend = 1
- !   ELSE
- !      iinitend = 1
- !   ENDIF
-
-#ifdef CPP_XIOS
-    CALL wxios_set_context
-#endif
-
-#ifndef CPP_XIOS
-    missing_val=missing_val_nf90
-#endif
-
-    IF (.NOT.vars_defined) THEN
-      kmax_100m=1
-      DO k=1, klev-1
-        IF (presnivs(k).GT.0.97*101325.) kmax_100m = k !--finding out max level for 100 m with a good margin
-      ENDDO
-    ENDIF
-
-    Ahyb_bounds(1,1) = 0.
-    Ahyb_bounds(1,2) = aps(1)
-    Bhyb_bounds(1,1) = 1.
-    Bhyb_bounds(1,2) = bps(1)    
-    DO ilev=2,klev
-      Ahyb_bounds(ilev,1) = aps(ilev-1)
-      Ahyb_bounds(ilev,2) = aps(ilev)
-      Bhyb_bounds(ilev,1) = bps(ilev-1)
-      Bhyb_bounds(ilev,2) = bps(ilev)
-    ENDDO
-     Ahyb_bounds(klev+1,1) = aps(klev)
-     Ahyb_bounds(klev+1,2) = 0.
-     Bhyb_bounds(klev+1,1) = bps(klev)
-     Bhyb_bounds(klev+1,2) = 0.
-
-    DO ilev=1, klev
-      Ahyb_mid_bounds(ilev,1) = ap(ilev)
-      Ahyb_mid_bounds(ilev,2) = ap(ilev+1)
-      Bhyb_mid_bounds(ilev,1) = bp(ilev)
-      Bhyb_mid_bounds(ilev,2) = bp(ilev+1)
-    END DO
-
-#ifdef CPP_XIOS
-#ifdef CPP_StratAer
-!$OMP MASTER
-   IF (.NOT.vars_defined) THEN
-          !On ajoute les variables 3D traceurs par l interface fortran 
-          CALL xios_get_handle("fields_strataer_trac_3D", group_handle)
-          ! On boucle sur les traceurs pour les ajouter au groupe puis fixer les attributs
-          DO iq=nqo+1, nqtot
-            iiq=niadv(iq)
-            dn = 'd'//TRIM(tracers(iiq)%name)//'_'
-            WRITE (lunout,*) 'XIOS var=', nqo, iq, nqtot, tracers(iiq)%name
-
-            unt = "kg kg-1"
-            varname=trim(tracers(iiq)%name)
-            CALL xios_add_child(group_handle, child, varname)
-            CALL xios_set_attr(child, name=varname, unit=unt)
-
-            unt = "kg kg-1 s-1"
-            varname=TRIM(dn)//'vdf'
-            CALL xios_add_child(group_handle, child, varname)
-            CALL xios_set_attr(child, name=varname, unit=unt)
-            varname=TRIM(dn)//'the'
-            CALL xios_add_child(group_handle, child, varname)
-            CALL xios_set_attr(child, name=varname, unit=unt)
-            varname=TRIM(dn)//'con'
-            CALL xios_add_child(group_handle, child, varname)
-            CALL xios_set_attr(child, name=varname, unit=unt)
-            varname=TRIM(dn)//'lessi_impa'
-            CALL xios_add_child(group_handle, child, varname)
-            CALL xios_set_attr(child, name=varname, unit=unt)
-            varname=TRIM(dn)//'lessi_nucl'
-            CALL xios_add_child(group_handle, child, varname)
-            CALL xios_set_attr(child, name=varname, unit=unt)
-            varname=TRIM(dn)//'insc'
-            CALL xios_add_child(group_handle, child, varname)
-            CALL xios_set_attr(child, name=varname, unit=unt)
-            varname=TRIM(dn)//'bcscav'
-            CALL xios_add_child(group_handle, child, varname)
-            CALL xios_set_attr(child, name=varname, unit=unt)
-            varname=TRIM(dn)//'evapls'
-            CALL xios_add_child(group_handle, child, varname)
-            CALL xios_set_attr(child, name=varname, unit=unt)
-            varname=TRIM(dn)//'ls'
-            CALL xios_add_child(group_handle, child, varname)
-            CALL xios_set_attr(child, name=varname, unit=unt)
-            varname=TRIM(dn)//'trsp'
-            CALL xios_add_child(group_handle, child, varname)
-            CALL xios_set_attr(child, name=varname, unit=unt)
-            varname=TRIM(dn)//'sscav'
-            CALL xios_add_child(group_handle, child, varname)
-            CALL xios_set_attr(child, name=varname, unit=unt)
-            varname=TRIM(dn)//'sat'
-            CALL xios_add_child(group_handle, child, varname)
-            CALL xios_set_attr(child, name=varname, unit=unt)
-            varname=TRIM(dn)//'uscav'
-            CALL xios_add_child(group_handle, child, varname)
-            CALL xios_set_attr(child, name=varname, unit=unt)
-          ENDDO
-          !On ajoute les variables 2D traceurs par l interface fortran 
-          CALL xios_get_handle("fields_strataer_trac_2D", group_handle)
-          ! On boucle sur les traceurs pour les ajouter au groupe puis fixer les attributs
-          DO iq=nqo+1, nqtot
-            iiq=niadv(iq)
-
-            unt = "kg m-2"
-            varname='cum'//trim(tracers(iiq)%name)
-            WRITE (lunout,*) 'XIOS var=', iq, nqtot, varname
-            CALL xios_add_child(group_handle, child, varname)
-            CALL xios_set_attr(child, name=varname, unit=unt)
-
-            unt = "kg m-2 s-1"
-            varname='cumd'//trim(tracers(iiq)%name)//'_dry'
-            CALL xios_add_child(group_handle, child, varname)
-            CALL xios_set_attr(child, name=varname, unit=unt)
-          ENDDO
-    ENDIF
-!$OMP END MASTER
-#endif
-#endif
-    ! ug la boucle qui suit ne sert qu'une fois, pour l'initialisation, sinon il n'y a toujours qu'un seul passage:
-    DO iinit=1, iinitend
-!      print *,'IFF iinit=', iinit, iinitend 
-#ifdef CPP_XIOS
-       !$OMP MASTER
-       IF (vars_defined) THEN
-          IF (prt_level >= 10) then
-             write(lunout,*)"phys_output_write: call xios_update_calendar, itau_w=",itau_w
-          ENDIF
-!          CALL xios_update_calendar(itau_w)
-          CALL xios_update_calendar(itap)
-       ENDIF
-       !$OMP END MASTER
-       !$OMP BARRIER
-#endif
-       ! On procède à l'écriture ou à la définition des nombreuses variables:
-!!! Champs 1D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-       CALL histwrite_phy(o_phis, pphis)
-
-       zx_tmp_fi2d = cell_area
-       IF (is_north_pole_phy) then
-         zx_tmp_fi2d(1) = cell_area(1)/nbp_lon
-       ENDIF
-       IF (is_south_pole_phy) then
-         zx_tmp_fi2d(klon) = cell_area(klon)/nbp_lon
-       ENDIf
-       CALL histwrite_phy(o_aire, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          DO i=1, klon
-             zx_tmp_fi2d(i)=pctsrf(i,is_ter)+pctsrf(i,is_lic)
-          ENDDO
-       ENDIF
-
-       CALL histwrite_phy(o_contfracATM, zx_tmp_fi2d)
-       CALL histwrite_phy(o_contfracOR, pctsrf(:,is_ter))
-!
-#ifdef CPP_XIOS
-       CALL histwrite_phy("R_ecc",R_ecc)
-       CALL histwrite_phy("R_peri",R_peri)
-       CALL histwrite_phy("R_incl",R_incl)
-       CALL histwrite_phy("solaire",solaire)
-       CALL histwrite_phy(o_Ahyb, ap)
-       CALL histwrite_phy(o_Bhyb, bp)
-       CALL histwrite_phy(o_Ahyb_bounds, Ahyb_bounds)
-       CALL histwrite_phy(o_Bhyb_bounds, Bhyb_bounds)
-       CALL histwrite_phy(o_Ahyb_mid, aps)
-       CALL histwrite_phy(o_Bhyb_mid, bps)
-       CALL histwrite_phy(o_Ahyb_mid_bounds, Ahyb_mid_bounds)
-       CALL histwrite_phy(o_Bhyb_mid_bounds, Bhyb_mid_bounds)
-       CALL histwrite_phy(o_longitude, longitude_deg)
-       CALL histwrite_phy(o_latitude, latitude_deg)
-!
-#ifdef CPP_RRTM
-      IF (iflag_rrtm.EQ.1) THEN
-        DO ISW=1, NSW
-          WRITE(ch1,'(i1)') ISW
-!         zx_tmp_0d=RSUN(ISW)
-!         CALL histwrite_phy("rsun"//ch1,zx_tmp_0d)
-          CALL histwrite_phy("rsun"//ch1,RSUN(ISW))
-        ENDDO
-      ENDIF
-#endif
-!
-       CALL histwrite_phy("co2_ppm",co2_ppm)
-       CALL histwrite_phy("CH4_ppb",CH4_ppb)
-       CALL histwrite_phy("N2O_ppb",N2O_ppb)
-       CALL histwrite_phy("CFC11_ppt",CFC11_ppt)
-       CALL histwrite_phy("CFC12_ppt",CFC12_ppt)
-!
-#endif
-
-!!! Champs 2D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! Simulateur AIRS
-     IF (ok_airs) then
-      CALL histwrite_phy(o_alt_tropo,alt_tropo)
- 
-      CALL histwrite_phy(o_map_prop_hc,map_prop_hc)
-      CALL histwrite_phy(o_map_prop_hist,map_prop_hist)
-
-      CALL histwrite_phy(o_map_emis_hc,map_emis_hc)
-      CALL histwrite_phy(o_map_iwp_hc,map_iwp_hc)
-      CALL histwrite_phy(o_map_deltaz_hc,map_deltaz_hc)
-      CALL histwrite_phy(o_map_pcld_hc,map_pcld_hc)
-      CALL histwrite_phy(o_map_tcld_hc,map_tcld_hc)
-
-      CALL histwrite_phy(o_map_emis_hist,map_emis_hist)
-      CALL histwrite_phy(o_map_iwp_hist,map_iwp_hist)
-      CALL histwrite_phy(o_map_deltaz_hist,map_deltaz_hist)
-
-      CALL histwrite_phy(o_map_ntot,map_ntot)
-      CALL histwrite_phy(o_map_hc,map_hc)
-      CALL histwrite_phy(o_map_hist,map_hist)
-
-      CALL histwrite_phy(o_map_Cb,map_Cb)
-      CALL histwrite_phy(o_map_ThCi,map_ThCi)
-      CALL histwrite_phy(o_map_Anv,map_Anv)
-
-      CALL histwrite_phy(o_map_emis_Cb,map_emis_Cb)
-      CALL histwrite_phy(o_map_pcld_Cb,map_pcld_Cb)
-      CALL histwrite_phy(o_map_tcld_Cb,map_tcld_Cb)
-
-      CALL histwrite_phy(o_map_emis_ThCi,map_emis_ThCi)
-      CALL histwrite_phy(o_map_pcld_ThCi,map_pcld_ThCi)
-      CALL histwrite_phy(o_map_tcld_ThCi,map_tcld_ThCi)
-
-      CALL histwrite_phy(o_map_emis_Anv,map_emis_Anv)
-      CALL histwrite_phy(o_map_pcld_Anv,map_pcld_Anv)
-      CALL histwrite_phy(o_map_tcld_Anv,map_tcld_Anv)
-     ENDIF
-
-       CALL histwrite_phy(o_sza, sza_o)
-       CALL histwrite_phy(o_flat, zxfluxlat)
-       CALL histwrite_phy(o_ptstar, ptstar)
-       CALL histwrite_phy(o_pt0, pt0)
-       CALL histwrite_phy(o_slp, slp)
-       CALL histwrite_phy(o_tsol, zxtsol)
-       CALL histwrite_phy(o_t2m, zt2m)
-       CALL histwrite_phy(o_t2m_min, zt2m)
-       CALL histwrite_phy(o_t2m_max, zt2m)
-       CALL histwrite_phy(o_t2m_max_mon, t2m_max_mon)
-       CALL histwrite_phy(o_t2m_min_mon, t2m_min_mon)
-
-       IF (vars_defined) THEN
-          DO i=1, klon
-             zx_tmp_fi2d(i)=real(zn2mout(i,1))
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_nt2mout, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          DO i=1, klon
-             zx_tmp_fi2d(i)=real(zn2mout(i,2))
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_nt2moutfg, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          DO i=1, klon
-             zx_tmp_fi2d(i)=real(zn2mout(i,3))
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_nq2mout, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          DO i=1, klon
-             zx_tmp_fi2d(i)=real(zn2mout(i,4))
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_nq2moutfg, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          DO i=1, klon
-             zx_tmp_fi2d(i)=real(zn2mout(i,5))
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_nu2mout, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          DO i=1, klon
-             zx_tmp_fi2d(i)=real(zn2mout(i,6))
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_nu2moutfg, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          DO i=1, klon
-             zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_wind10m, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          DO i=1, klon
-             zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_wind10max, zx_tmp_fi2d)
-
-       CALL histwrite_phy(o_gusts, gustiness)
-
-       IF (vars_defined) THEN
-          DO k = 1, kmax_100m                                      !--we could stop much lower
-            zrho(:) = pplay(:,k)/t_seri(:,k)/RD                    ! air density in kg/m3
-            dz(:,k) = (paprs(:,k)-paprs(:,k+1))/zrho(:)/RG         ! layer thickness in m
-            IF (k==1) THEN
-              z(:,1) = (paprs(:,1)-pplay(:,1))/zrho(:)/RG          ! altitude middle of first layer in m
-              zt(:)  = dz(:,1)                                     ! altitude top of first layer in m
-            ELSE
-              z(:,k) = zt(:) + (paprs(:,k)-pplay(:,k))/zrho(:)/RG  ! altitude middle of layer k in m
-              zt(:)  = zt(:) + dz(:,k)                             ! altitude top of layer k in m
-            ENDIF
-          ENDDO
-          wind100m(:)=missing_val
-          DO k=1, kmax_100m-1                                      !--we could stop much lower
-            DO i=1,klon
-              IF (z(i,k).LT.100..AND.z(i,k+1).GE.100.) THEN
-                wind100m(i)=SQRT( (u_seri(i,k)+(100.-z(i,k))/(z(i,k+1)-z(i,k))*(u_seri(i,k+1)-u_seri(i,k)))**2.0 + &
-                                  (v_seri(i,k)+(100.-z(i,k))/(z(i,k+1)-z(i,k))*(v_seri(i,k+1)-v_seri(i,k)))**2.0 )
-              ENDIF
-            ENDDO
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_wind100m, wind100m)
-
-       IF (vars_defined) THEN
-         !--polynomial fit for 14,Vestas,1074,V136/3450 kW windmill - Olivier
-         DO i=1,klon
-           IF (pctsrf(i,is_ter).GT.0.05 .AND. wind100m(i).NE.missing_val) THEN
-             x=wind100m(i)
-             IF (x.LE.3.0 .OR. x.GE.22.5) THEN
-               zx_tmp_fi2d(i)=0.0
-             ELSE IF (x.GE.10.0) THEN
-               zx_tmp_fi2d(i)=1.0
-             ELSE
-               zx_tmp_fi2d(i)= 10.73 + x*(-14.69 + x*(8.339 + x*(-2.59 + x*(0.4893 + x*(-0.05898 + x*(0.004627 + & 
-                               x*(-0.0002352 + x*(7.478e-06 + x*(-1.351e-07 + x*(1.059e-09))))))))))
-               zx_tmp_fi2d(i)=MIN(MAX(zx_tmp_fi2d(i),0.0),1.0)
-             ENDIF
-           ELSE
-             zx_tmp_fi2d(i)=missing_val
-           ENDIF
-         ENDDO
-       ENDIF
-       CALL histwrite_phy(o_loadfactor_wind_onshore, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-         !--polynomial fit for 14,Vestas,867,V164/8000 kW - Olivier
-         DO i=1,klon
-           IF (pctsrf(i,is_oce).GT.0.05 .AND. wind100m(i).NE.missing_val) THEN
-             x=wind100m(i)
-             IF (x.LE.3.0 .OR. x.GE.25.5) THEN
-               zx_tmp_fi2d(i)=0.0
-             ELSE IF (x.GE.12.5) THEN
-               zx_tmp_fi2d(i)=1.0
-             ELSE
-               zx_tmp_fi2d(i)= 20.59 + x*(-22.39 + x*(10.25 + x*(-2.601 + x*(0.4065 + x*(-0.04099 + x*(0.002716 + & 
-                               x*(-0.0001175 + x*(3.195e-06 + x*(-4.959e-08 + x*(3.352e-10))))))))))
-               zx_tmp_fi2d(i)=MIN(MAX(zx_tmp_fi2d(i),0.0),1.0)
-             ENDIF
-           ELSE
-             zx_tmp_fi2d(i)=missing_val
-           ENDIF
-         ENDDO
-       ENDIF
-       CALL histwrite_phy(o_loadfactor_wind_offshore, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          DO i = 1, klon
-             zx_tmp_fi2d(i) = pctsrf(i,is_sic)
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_sicf, zx_tmp_fi2d)
-       CALL histwrite_phy(o_q2m, zq2m)
-       IF (vars_defined) zx_tmp_fi2d = zustar
-       CALL histwrite_phy(o_ustar, zx_tmp_fi2d)
-       CALL histwrite_phy(o_u10m, zu10m)
-       CALL histwrite_phy(o_v10m, zv10m)
-
-       IF (vars_defined) THEN
-          DO i = 1, klon
-             zx_tmp_fi2d(i) = paprs(i,1)
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_psol, zx_tmp_fi2d)
-       CALL histwrite_phy(o_mass, zmasse)
-       CALL histwrite_phy(o_qsurf, zxqsurf)
-
-       IF (.NOT. ok_veget) THEN
-          CALL histwrite_phy(o_qsol, qsol)
-       ENDIF
-
-       IF (vars_defined) THEN
-          DO i = 1, klon
-             zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
-          ENDDO
-       ENDIF
-
-       CALL histwrite_phy(o_precip, zx_tmp_fi2d)
-       CALL histwrite_phy(o_rain_fall, rain_fall)
-       CALL histwrite_phy(o_ndayrain, nday_rain)
-
-       ! epmax_cape:
-!       CALL histwrite_phy(o_epmax_diag, epmax_diag)
-       CALL histwrite_phy(o_ep, ep)
-
-       IF (vars_defined) THEN
-          DO i = 1, klon
-             zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_plul, zx_tmp_fi2d)
-       CALL histwrite_phy(o_plun, rain_num)
-
-       IF (vars_defined) THEN
-          DO i = 1, klon
-             zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_pluc, zx_tmp_fi2d)
-       CALL histwrite_phy(o_rain_con, rain_con)
-       CALL histwrite_phy(o_snow, snow_fall)
-       CALL histwrite_phy(o_msnow, zxsnow)
-       CALL histwrite_phy(o_fsnow, zfra_o)
-       CALL histwrite_phy(o_evap, evap)
-
-       IF (vars_defined) THEN
-         zx_tmp_fi2d = topsw*swradcorr
-       ENDIF
-       CALL histwrite_phy(o_tops, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-         zx_tmp_fi2d = topsw0*swradcorr
-       ENDIF
-       CALL histwrite_phy(o_tops0, zx_tmp_fi2d)
-
-       CALL histwrite_phy(o_topl, toplw)
-       CALL histwrite_phy(o_topl0, toplw0)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(:) = swup(:,klevp1)*swradcorr(:)
-       ENDIF
-       CALL histwrite_phy(o_SWupTOA, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(:) = swup0(:,klevp1)*swradcorr(:)
-       ENDIF
-       CALL histwrite_phy(o_SWupTOAclr, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(:) = swupc0(:,klevp1)*swradcorr(:)
-       ENDIF
-       CALL histwrite_phy(o_SWupTOAcleanclr, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(:) = swdn(:,klevp1)*swradcorr(:)
-       ENDIF
-       CALL histwrite_phy(o_SWdnTOA, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(:) = swdn0(:,klevp1)*swradcorr(:)
-       ENDIF
-       CALL histwrite_phy(o_SWdnTOAclr, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(:) = topsw(:)*swradcorr(:)-toplw(:)
-       ENDIF
-       CALL histwrite_phy(o_nettop, zx_tmp_fi2d)
-       
-       IF (vars_defined) THEN
-          zx_tmp_fi2d = SWup200*swradcorr
-       ENDIF
-       CALL histwrite_phy(o_SWup200, zx_tmp_fi2d)
-       
-       IF (vars_defined) THEN
-          zx_tmp_fi2d = SWup200clr*swradcorr
-       ENDIF
-       CALL histwrite_phy(o_SWup200clr, zx_tmp_fi2d)
-       
-       IF (vars_defined) THEN
-          zx_tmp_fi2d = SWdn200*swradcorr
-       ENDIF
-       CALL histwrite_phy(o_SWdn200, zx_tmp_fi2d)
-       
-       
-       IF (vars_defined) THEN
-          zx_tmp_fi2d = SWdn200clr*swradcorr
-       ENDIF
-       CALL histwrite_phy(o_SWdn200clr, zx_tmp_fi2d)
-       
-       CALL histwrite_phy(o_LWup200, LWup200)
-       CALL histwrite_phy(o_LWup200clr, LWup200clr)
-       CALL histwrite_phy(o_LWdn200, LWdn200)
-       CALL histwrite_phy(o_LWdn200clr, LWdn200clr)
-       
-       IF (vars_defined) THEN
-          zx_tmp_fi2d = solsw*swradcorr
-       ENDIF
-       CALL histwrite_phy(o_sols, zx_tmp_fi2d)
-       
-       
-       IF (vars_defined) THEN
-          zx_tmp_fi2d = solsw0*swradcorr
-       ENDIF
-       CALL histwrite_phy(o_sols0, zx_tmp_fi2d)
-       CALL histwrite_phy(o_soll, sollw)
-       CALL histwrite_phy(o_soll0, sollw0)
-       CALL histwrite_phy(o_radsol, radsol)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(:) = swup(:,1)*swradcorr(:)
-       ENDIF
-       CALL histwrite_phy(o_SWupSFC, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(:) = swup0(:,1)*swradcorr(:)
-       ENDIF
-       CALL histwrite_phy(o_SWupSFCclr, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(:) = swupc0(:,1)*swradcorr(:)
-       ENDIF
-       CALL histwrite_phy(o_SWupSFCcleanclr, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(:) = swdn(:,1)*swradcorr(:)
-       ENDIF
-       CALL histwrite_phy(o_SWdnSFC, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(:) = swdn0(:,1)*swradcorr(:)
-       ENDIF
-       CALL histwrite_phy(o_SWdnSFCclr, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(:) = swdnc0(:,1)*swradcorr(:)
-       ENDIF
-       CALL histwrite_phy(o_SWdnSFCcleanclr, zx_tmp_fi2d)
-
-       CALL histwrite_phy(o_fdiffSWdnSFC, solswfdiff)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(:)=sollwdown(:)-sollw(:)
-       ENDIF
-       CALL histwrite_phy(o_LWupSFC, zx_tmp_fi2d)
-       CALL histwrite_phy(o_LWdnSFC, sollwdown)
-
-       IF (vars_defined) THEN
-          sollwdownclr(1:klon) = -1.*lwdn0(1:klon,1)
-          zx_tmp_fi2d(1:klon)=sollwdownclr(1:klon)-sollw0(1:klon)
-       ENDIF
-       CALL histwrite_phy(o_LWupSFCclr, zx_tmp_fi2d)
-       CALL histwrite_phy(o_LWdnSFCclr, sollwdownclr)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(:) = lwupc0(:,klevp1)
-       ENDIF
-       CALL histwrite_phy(o_LWupTOAcleanclr, zx_tmp_fi2d)
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(:) = -1.*lwdnc0(:,1)
-       ENDIF
-       CALL histwrite_phy(o_LWdnSFCcleanclr, zx_tmp_fi2d)
-
-       CALL histwrite_phy(o_bils, bils)
-       CALL histwrite_phy(o_bils_diss, bils_diss)
-       CALL histwrite_phy(o_bils_ec, bils_ec)
-       CALL histwrite_phy(o_bils_ech, bils_ech)
-       CALL histwrite_phy(o_bils_tke, bils_tke)
-       CALL histwrite_phy(o_bils_kinetic, bils_kinetic)
-       CALL histwrite_phy(o_bils_latent, bils_latent)
-       CALL histwrite_phy(o_bils_enthalp, bils_enthalp)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(1:klon)=-1*sens(1:klon)
-       ENDIF
-       CALL histwrite_phy(o_sens, zx_tmp_fi2d)
-       CALL histwrite_phy(o_fder, fder)
-       CALL histwrite_phy(o_ffonte, zxffonte)
-       CALL histwrite_phy(o_fqcalving, zxfqcalving)
-       CALL histwrite_phy(o_fqfonte, zxfqfonte)
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(1:klon)=(zxfqfonte(1:klon)+rain_fall(1:klon))*pctsrf(1:klon,is_lic)
-       ENDIF
-       CALL histwrite_phy(o_mrroli, zx_tmp_fi2d)
-       CALL histwrite_phy(o_runofflic, zxrunofflic)
-       IF (vars_defined) THEN
-          zx_tmp_fi2d=0.
-          DO nsrf=1,nbsrf
-             zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+pctsrf(:,nsrf)*fluxu(:,1,nsrf)
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_taux, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d=0.
-          DO nsrf=1,nbsrf
-             zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+pctsrf(:,nsrf)*fluxv(:,1,nsrf)
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_tauy, zx_tmp_fi2d)
-
-       ! Etienne: test sorties pour compil sur JZ
-!       IF (landice_opt .GE. 1) THEN
-!          CALL histwrite_phy(o_snowsrf, snow_o)
-!          CALL histwrite_phy(o_qsnow, qsnow)
-!          CALL histwrite_phy(o_snowhgt,snowhgt)
-!          CALL histwrite_phy(o_toice,to_ice)
-!          CALL histwrite_phy(o_sissnow,sissnow)
-!          CALL histwrite_phy(o_runoff,runoff)
-!          CALL histwrite_phy(o_albslw3,albsol3_lic)
-!       ENDIF
-
-       DO nsrf = 1, nbsrf
-
-          IF (vars_defined)             zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)*100.
-          CALL histwrite_phy(o_pourc_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)           zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)
-          CALL histwrite_phy(o_fract_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fluxu( 1 : klon, 1, nsrf)
-          CALL histwrite_phy(o_taux_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fluxv( 1 : klon, 1, nsrf)
-          CALL histwrite_phy(o_tauy_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = ftsol( 1 : klon, nsrf)
-          CALL histwrite_phy(o_tsol_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = evap_pot( 1 : klon, nsrf)
-          CALL histwrite_phy(o_evappot_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = ustar(1 : klon, nsrf)
-          CALL histwrite_phy(o_ustar_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = u10m(1 : klon, nsrf)
-          CALL histwrite_phy(o_u10m_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = v10m(1 : klon, nsrf)
-          CALL histwrite_phy(o_v10m_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = t2m(1 : klon, nsrf)
-          CALL histwrite_phy(o_t2m_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = fevap(1 : klon, nsrf)
-          CALL histwrite_phy(o_evap_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)        zx_tmp_fi2d(1 : klon) = fluxt( 1 : klon, 1, nsrf)
-          CALL histwrite_phy(o_sens_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fluxlat( 1 : klon, nsrf)
-          CALL histwrite_phy(o_lat_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fsollw( 1 : klon, nsrf)
-          CALL histwrite_phy(o_flw_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, nsrf)
-          CALL histwrite_phy(o_fsw_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = wfbils( 1 : klon, nsrf)
-          CALL histwrite_phy(o_wbils_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = wfbilo( 1 : klon, nsrf)
-          CALL histwrite_phy(o_wbilo_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = wfevap( 1 : klon, nsrf)
-          CALL histwrite_phy(o_wevap_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = wfrain( 1 : klon, nsrf)
-          CALL histwrite_phy(o_wrain_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = wfsnow( 1 : klon, nsrf)
-          CALL histwrite_phy(o_wsnow_srf(nsrf), zx_tmp_fi2d)
-
-          IF (iflag_pbl > 1) THEN
-             CALL histwrite_phy(o_tke_srf(nsrf),  pbl_tke(:,1:klev,nsrf))
-             !CALL histwrite_phy(o_l_mix(nsrf),  l_mix(:,1:klev,nsrf))
-             CALL histwrite_phy(o_l_mixmin(nsrf),  l_mixmin(:,1:klev,nsrf))
-             CALL histwrite_phy(o_tke_max_srf(nsrf),  pbl_tke(:,1:klev,nsrf))
-
-                         
-          ENDIF
-!jyg<
-          IF (iflag_pbl > 1 .AND. iflag_wake>=1  .AND. iflag_pbl_split >=1) THEN
-             CALL histwrite_phy(o_dltpbltke_srf(nsrf), wake_delta_pbl_TKE(:,1:klev,nsrf))
-          ENDIF
-!>jyg
-!          IF (iflag_pbl > 1 .AND. ifl_pbltree  >=1 ) THEN
-!       CALL histwrite_phy(o_treedrg_srf(nsrf), treedrg(:,1:klev,nsrf))
-!            ENDIF
-
-       ENDDO
-       
-                
-        IF (iflag_pbl > 1) THEN
-          zx_tmp_fi3d=0.
-          IF (vars_defined) THEN
-             DO nsrf=1,nbsrf
-                DO k=1,klev
-                   zx_tmp_fi3d(:,k)=zx_tmp_fi3d(:,k) &
-                        +pctsrf(:,nsrf)*tke_dissip(:,k,nsrf)
-                ENDDO
-             ENDDO
-          ENDIF
-          
-          CALL histwrite_phy(o_tke_dissip, zx_tmp_fi3d)    
-       ENDIF
-
-       IF (vars_defined) zx_tmp_fi2d(1 : klon) = sens_prec_liq_o(1 : klon, 1)
-       CALL histwrite_phy(o_sens_prec_liq_oce, zx_tmp_fi2d)       
-       IF (vars_defined) zx_tmp_fi2d(1 : klon) = sens_prec_liq_o(1 : klon, 2)
-       CALL histwrite_phy(o_sens_prec_liq_sic, zx_tmp_fi2d)       
-       IF (vars_defined) zx_tmp_fi2d(1 : klon) = sens_prec_sol_o(1 : klon, 1)
-       CALL histwrite_phy(o_sens_prec_sol_oce, zx_tmp_fi2d)       
-       IF (vars_defined) zx_tmp_fi2d(1 : klon) = sens_prec_sol_o(1 : klon, 2)
-       CALL histwrite_phy(o_sens_prec_sol_sic, zx_tmp_fi2d)       
-
-       IF (vars_defined) zx_tmp_fi2d(1 : klon) = lat_prec_liq_o(1 : klon, 1)
-       CALL histwrite_phy(o_lat_prec_liq_oce, zx_tmp_fi2d)       
-       IF (vars_defined) zx_tmp_fi2d(1 : klon) = lat_prec_liq_o(1 : klon, 2)
-       CALL histwrite_phy(o_lat_prec_liq_sic, zx_tmp_fi2d)       
-       IF (vars_defined) zx_tmp_fi2d(1 : klon) = lat_prec_sol_o(1 : klon, 1)
-       CALL histwrite_phy(o_lat_prec_sol_oce, zx_tmp_fi2d)       
-       IF (vars_defined) zx_tmp_fi2d(1 : klon) = lat_prec_sol_o(1 : klon, 2)
-       CALL histwrite_phy(o_lat_prec_sol_sic, zx_tmp_fi2d)       
-
-       DO nsrf=1,nbsrf+1
-          CALL histwrite_phy(o_wstar(nsrf), wstar(1 : klon, nsrf))
-       ENDDO
-
-       CALL histwrite_phy(o_cdrm, cdragm)
-       CALL histwrite_phy(o_cdrh, cdragh)
-       CALL histwrite_phy(o_cldl, cldl)
-       CALL histwrite_phy(o_cldm, cldm)
-       CALL histwrite_phy(o_cldh, cldh)
-       CALL histwrite_phy(o_cldt, cldt)
-       CALL histwrite_phy(o_JrNt, JrNt)
-       
-       IF (vars_defined)  zx_tmp_fi2d=cldl*JrNt      
-       CALL histwrite_phy(o_cldljn, zx_tmp_fi2d)
-       
-       IF (vars_defined)  zx_tmp_fi2d=cldm*JrNt      
-       CALL histwrite_phy(o_cldmjn, zx_tmp_fi2d)
-       
-       IF (vars_defined)  zx_tmp_fi2d=cldh*JrNt
-       CALL histwrite_phy(o_cldhjn, zx_tmp_fi2d)
-       
-       IF (vars_defined)  zx_tmp_fi2d=cldt*JrNt
-       CALL histwrite_phy(o_cldtjn, zx_tmp_fi2d)
-       
-       CALL histwrite_phy(o_cldq, cldq)
-       IF (vars_defined)       zx_tmp_fi2d(1:klon) = flwp(1:klon)
-       CALL histwrite_phy(o_lwp, zx_tmp_fi2d)
-       IF (vars_defined)       zx_tmp_fi2d(1:klon) = fiwp(1:klon)
-       CALL histwrite_phy(o_iwp, zx_tmp_fi2d)
-       CALL histwrite_phy(o_ue, ue)
-       CALL histwrite_phy(o_ve, ve)
-       CALL histwrite_phy(o_uq, uq)
-       CALL histwrite_phy(o_vq, vq)
-       CALL histwrite_phy(o_uwat, uwat)
-       CALL histwrite_phy(o_vwat, vwat)
-       IF (iflag_con.GE.3) THEN ! sb
-          CALL histwrite_phy(o_cape, cape)
-          CALL histwrite_phy(o_pbase, ema_pcb)
-          CALL histwrite_phy(o_ptop, ema_pct)
-          CALL histwrite_phy(o_fbase, ema_cbmf)
-          IF (iflag_con /= 30) THEN
-             CALL histwrite_phy(o_plcl, plcl)
-             CALL histwrite_phy(o_plfc, plfc)
-             CALL histwrite_phy(o_wbeff, wbeff)
-             CALL histwrite_phy(o_convoccur, convoccur)
-          ENDIF
-
-          CALL histwrite_phy(o_cape_max, cape)
-
-          CALL histwrite_phy(o_upwd, upwd)
-          CALL histwrite_phy(o_Ma, Ma)
-          CALL histwrite_phy(o_dnwd, dnwd)
-          CALL histwrite_phy(o_dnwd0, dnwd0)
-          !! The part relative to the frequency of occurence of convection
-          !! is now grouped with the part relative to thermals and shallow
-          !! convection (output of the 3 fields: ftime_deepcv, ftime_th and
-          !!  ftime_con).
-          IF (vars_defined) THEN
-             IF (iflag_thermals>=1)THEN
-                zx_tmp_fi3d=-dnwd+dnwd0+upwd+fm_therm(:,1:klev)
-             ELSE
-                zx_tmp_fi3d=-dnwd+dnwd0+upwd
-             ENDIF
-          ENDIF
-          CALL histwrite_phy(o_mc, zx_tmp_fi3d)
-       ENDIF !iflag_con .GE. 3
-       CALL histwrite_phy(o_prw, prw)
-       CALL histwrite_phy(o_prlw, prlw)
-       CALL histwrite_phy(o_prsw, prsw)
-       CALL histwrite_phy(o_s_pblh, s_pblh)
-       CALL histwrite_phy(o_s_pblt, s_pblt)
-       CALL histwrite_phy(o_s_lcl, s_lcl)
-       CALL histwrite_phy(o_s_therm, s_therm)
-       !IM : Les champs suivants (s_capCL, s_oliqCL, s_cteiCL, s_trmb1, s_trmb2, s_trmb3) ne sont pas definis dans HBTM.F
-       !       IF (o_s_capCL%flag(iff)<=lev_files(iff)) THEN
-       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
-       !    $o_s_capCL%name,itau_w,s_capCL)
-       !       ENDIF
-       !       IF (o_s_oliqCL%flag(iff)<=lev_files(iff)) THEN
-       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
-       !    $o_s_oliqCL%name,itau_w,s_oliqCL)
-       !       ENDIF
-       !       IF (o_s_cteiCL%flag(iff)<=lev_files(iff)) THEN
-       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
-       !    $o_s_cteiCL%name,itau_w,s_cteiCL)
-       !       ENDIF
-       !       IF (o_s_trmb1%flag(iff)<=lev_files(iff)) THEN
-       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
-       !    $o_s_trmb1%name,itau_w,s_trmb1)
-       !       ENDIF
-       !       IF (o_s_trmb2%flag(iff)<=lev_files(iff)) THEN
-       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
-       !    $o_s_trmb2%name,itau_w,s_trmb2)
-       !       ENDIF
-       !       IF (o_s_trmb3%flag(iff)<=lev_files(iff)) THEN
-       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
-       !    $o_s_trmb3%name,itau_w,s_trmb3)
-       !       ENDIF
-
-#ifdef CPP_IOIPSL
-#ifndef CPP_XIOS
-  IF (.NOT.ok_all_xml) THEN
-       ! ATTENTION, LES ANCIENS HISTWRITE ONT ETES CONSERVES EN ATTENDANT MIEUX:
-       ! Champs interpolles sur des niveaux de pression
-       DO iff=1, nfiles
-          ll=0
-          DO k=1, nlevSTD
-             bb2=clevSTD(k) 
-             IF (bb2.EQ."850".OR.bb2.EQ."700".OR. &
-                  bb2.EQ."500".OR.bb2.EQ."200".OR. &
-                  bb2.EQ."100".OR. &
-                  bb2.EQ."50".OR.bb2.EQ."10") THEN
-
-                ! a refaire correctement !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-                ll=ll+1
-                CALL histwrite_phy(o_uSTDlevs(ll),uwriteSTD(:,k,iff), iff)
-                CALL histwrite_phy(o_vSTDlevs(ll),vwriteSTD(:,k,iff), iff)
-                CALL histwrite_phy(o_wSTDlevs(ll),wwriteSTD(:,k,iff), iff)
-                CALL histwrite_phy(o_zSTDlevs(ll),phiwriteSTD(:,k,iff), iff)
-                CALL histwrite_phy(o_qSTDlevs(ll),qwriteSTD(:,k,iff), iff)
-                CALL histwrite_phy(o_tSTDlevs(ll),twriteSTD(:,k,iff), iff)
-
-             ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
-          ENDDO
-       ENDDO
-  ENDIF
-#endif
-#endif
-#ifdef CPP_XIOS
-  IF (ok_all_xml) THEN
-!XIOS  CALL xios_get_field_attr("u850",default_value=missing_val)
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-          ll=0
-          DO k=1, nlevSTD
-             bb2=clevSTD(k) 
-             IF (bb2.EQ."850".OR.bb2.EQ."700".OR. &
-                bb2.EQ."500".OR.bb2.EQ."200".OR. &
-                bb2.EQ."100".OR. &
-                bb2.EQ."50".OR.bb2.EQ."10") THEN
-                ll=ll+1
-                CALL histwrite_phy(o_uSTDlevs(ll),ulevSTD(:,k))
-                CALL histwrite_phy(o_vSTDlevs(ll),vlevSTD(:,k))
-                CALL histwrite_phy(o_wSTDlevs(ll),wlevSTD(:,k))
-                CALL histwrite_phy(o_zSTDlevs(ll),philevSTD(:,k))
-                CALL histwrite_phy(o_qSTDlevs(ll),qlevSTD(:,k))
-                CALL histwrite_phy(o_tSTDlevs(ll),tlevSTD(:,k))
-             ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
-          ENDDO
-  ENDIF
-#endif
-       IF (vars_defined) THEN
-          DO i=1, klon
-             IF (pctsrf(i,is_oce).GT.epsfra.OR. &
-                  pctsrf(i,is_sic).GT.epsfra) THEN
-                zx_tmp_fi2d(i) = (ftsol(i, is_oce) * pctsrf(i,is_oce)+ &
-                     ftsol(i, is_sic) * pctsrf(i,is_sic))/ &
-                     (pctsrf(i,is_oce)+pctsrf(i,is_sic))
-             ELSE
-                zx_tmp_fi2d(i) = 273.15
-             ENDIF
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_t_oce_sic, zx_tmp_fi2d)
-
-       ! Couplage convection-couche limite
-       IF (iflag_con.GE.3) THEN
-          IF (iflag_coupl>=1) THEN
-             CALL histwrite_phy(o_ale_bl, ale_bl)
-             CALL histwrite_phy(o_alp_bl, alp_bl)
-          ENDIF !iflag_coupl>=1
-       ENDIF !(iflag_con.GE.3)
-       ! Wakes
-       IF (iflag_con.EQ.3) THEN
-          CALL histwrite_phy(o_Mipsh, Mipsh)
-          IF (iflag_wake>=1) THEN
-             CALL histwrite_phy(o_ale_wk, ale_wake)
-             CALL histwrite_phy(o_alp_wk, alp_wake)
-             IF (iflag_pbl_split>=1) THEN
-!!               IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=dtvdf_x(1:klon,1:klev)/pdtphys
-!!               CALL histwrite_phy(o_dtvdf_x    ,zx_tmp_fi3d) 
-!!               IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=dtvdf_w(1:klon,1:klev)/pdtphys
-!!               CALL histwrite_phy(o_dtvdf_w    ,zx_tmp_fi3d) 
-!!               IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=dqvdf_x(1:klon,1:klev)/pdtphys
-!!               CALL histwrite_phy(o_dqvdf_x    ,zx_tmp_fi3d) 
-!!               IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=dqvdf_w(1:klon,1:klev)/pdtphys
-!
-               IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_vdf_x(1:klon,1:klev)/pdtphys
-               CALL histwrite_phy(o_dtvdf_x    ,zx_tmp_fi3d) 
-               IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_vdf_w(1:klon,1:klev)/pdtphys
-               CALL histwrite_phy(o_dtvdf_w    ,zx_tmp_fi3d) 
-               IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_vdf_x(1:klon,1:klev)/pdtphys
-               CALL histwrite_phy(o_dqvdf_x    ,zx_tmp_fi3d) 
-               IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_vdf_w(1:klon,1:klev)/pdtphys
-!
-               CALL histwrite_phy(o_dqvdf_w    ,zx_tmp_fi3d) 
-       IF (vars_defined)  zx_tmp_fi2d(1:klon)=-1*sens_x(1:klon)
-               CALL histwrite_phy(o_sens_x     ,zx_tmp_fi2d) 
-       IF (vars_defined)  zx_tmp_fi2d(1:klon)=-1*sens_w(1:klon)
-               CALL histwrite_phy(o_sens_w     ,zx_tmp_fi2d) 
-               CALL histwrite_phy(o_flat_x     ,zxfluxlat_x) 
-               CALL histwrite_phy(o_flat_w     ,zxfluxlat_w) 
-          zx_tmp_fi2d=0.
-          IF (vars_defined) THEN
-             DO nsrf=1,nbsrf
-                   zx_tmp_fi2d(:)=zx_tmp_fi2d(:) &
-                        +pctsrf(:,nsrf)*delta_tsurf(:,nsrf)
-             ENDDO
-          ENDIF
-               CALL histwrite_phy(o_delta_tsurf,zx_tmp_fi2d) 
-               CALL histwrite_phy(o_cdragh_x   ,cdragh_x   ) 
-               CALL histwrite_phy(o_cdragh_w   ,cdragh_w   ) 
-               CALL histwrite_phy(o_cdragm_x   ,cdragm_x   ) 
-               CALL histwrite_phy(o_cdragm_w   ,cdragm_w   ) 
-               CALL histwrite_phy(o_kh         ,kh         ) 
-               CALL histwrite_phy(o_kh_x       ,kh_x       ) 
-               CALL histwrite_phy(o_kh_w       ,kh_w       ) 
-             ENDIF   ! (iflag_pbl_split>=1)
-             CALL histwrite_phy(o_ale, ale)
-             CALL histwrite_phy(o_alp, alp)
-             CALL histwrite_phy(o_cin, cin)
-             CALL histwrite_phy(o_WAPE, wake_pe)
-             CALL histwrite_phy(o_cv_gen, cv_gen)
-             CALL histwrite_phy(o_wake_h, wake_h)
-             CALL histwrite_phy(o_wake_dens, wake_dens)
-             CALL histwrite_phy(o_wake_s, wake_s)
-             CALL histwrite_phy(o_wake_deltat, wake_deltat)
-             CALL histwrite_phy(o_wake_deltaq, wake_deltaq)
-             CALL histwrite_phy(o_wake_omg, wake_omg)
-             IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_wake(1:klon,1:klev) &
-                  /pdtphys
-             CALL histwrite_phy(o_dtwak, zx_tmp_fi3d)
-             IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_wake(1:klon,1:klev)/pdtphys
-             CALL histwrite_phy(o_dqwak, zx_tmp_fi3d)
-             IF (vars_defined) CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
-             CALL histwrite_phy(o_dqwak2d, zx_tmp_fi2d)
-          ENDIF ! iflag_wake>=1
-          CALL histwrite_phy(o_ftd, ftd)
-          CALL histwrite_phy(o_fqd, fqd)
-       ENDIF !(iflag_con.EQ.3)
-       IF (iflag_con.EQ.3.OR.iflag_con.EQ.30) THEN
-          ! sortie RomP convection descente insaturee iflag_con=30
-          ! etendue a iflag_con=3 (jyg)
-          CALL histwrite_phy(o_Vprecip, Vprecip)
-          CALL histwrite_phy(o_qtaa, qtaa)
-          CALL histwrite_phy(o_clwaa, clw)
-          CALL histwrite_phy(o_wdtrainA, wdtrainA)
-          CALL histwrite_phy(o_wdtrainS, wdtrainS)
-          CALL histwrite_phy(o_wdtrainM, wdtrainM)
-       ENDIF !(iflag_con.EQ.3.or.iflag_con.EQ.30)
-!!! nrlmd le 10/04/2012
-       IF (iflag_trig_bl>=1) THEN
-          CALL histwrite_phy(o_n2, n2)
-          CALL histwrite_phy(o_s2, s2)
-          CALL histwrite_phy(o_proba_notrig, proba_notrig)
-          CALL histwrite_phy(o_random_notrig, random_notrig)
-          CALL histwrite_phy(o_ale_bl_stat, ale_bl_stat)
-          CALL histwrite_phy(o_ale_bl_trig, ale_bl_trig)
-       ENDIF  !(iflag_trig_bl>=1)
-       IF (iflag_clos_bl>=1) THEN
-          CALL histwrite_phy(o_alp_bl_det, alp_bl_det)
-          CALL histwrite_phy(o_alp_bl_fluct_m, alp_bl_fluct_m)
-          CALL histwrite_phy(o_alp_bl_fluct_tke,  &
-               alp_bl_fluct_tke)
-          CALL histwrite_phy(o_alp_bl_conv, alp_bl_conv)
-          CALL histwrite_phy(o_alp_bl_stat, alp_bl_stat)
-       ENDIF  !(iflag_clos_bl>=1)
-!!! fin nrlmd le 10/04/2012
-       ! Output of slab ocean variables
-       IF (type_ocean=='slab ') THEN
-          CALL histwrite_phy(o_slab_bils, slab_wfbils)
-          IF (nslay.EQ.1) THEN
-              IF (vars_defined) zx_tmp_fi2d(:)=tslab(:,1)
-              CALL histwrite_phy(o_tslab, zx_tmp_fi2d)
-              IF (vars_defined) zx_tmp_fi2d(:)=dt_qflux(:,1)
-              CALL histwrite_phy(o_slab_qflux, zx_tmp_fi2d)
-          ELSE
-              CALL histwrite_phy(o_tslab, tslab(:,1:nslay))
-              CALL histwrite_phy(o_slab_qflux, dt_qflux(:,1:nslay))
-          ENDIF
-          IF (version_ocean=='sicINT') THEN
-              CALL histwrite_phy(o_slab_bilg, slab_bilg)
-              CALL histwrite_phy(o_slab_tice, tice)
-              CALL histwrite_phy(o_slab_sic, seaice)
-          ENDIF
-          IF (slab_gm) THEN
-             CALL histwrite_phy(o_slab_gm, dt_gm(:,1:nslay))
-          ENDIF
-          IF (slab_hdiff) THEN
-            IF (nslay.EQ.1) THEN
-                IF (vars_defined) zx_tmp_fi2d(:)=dt_hdiff(:,1)
-                CALL histwrite_phy(o_slab_hdiff, zx_tmp_fi2d)
-            ELSE
-                CALL histwrite_phy(o_slab_hdiff, dt_hdiff(:,1:nslay))
-            ENDIF
-          ENDIF
-          IF (slab_ekman.GT.0) THEN
-            IF (nslay.EQ.1) THEN
-                IF (vars_defined) zx_tmp_fi2d(:)=dt_ekman(:,1)
-                CALL histwrite_phy(o_slab_ekman, zx_tmp_fi2d)
-            ELSE
-                CALL histwrite_phy(o_slab_ekman, dt_ekman(:,1:nslay))
-            ENDIF
-          ENDIF
-       ENDIF !type_ocean == force/slab
-       CALL histwrite_phy(o_weakinv, weak_inversion)
-       CALL histwrite_phy(o_dthmin, dthmin)
-       CALL histwrite_phy(o_cldtau, cldtau)
-       CALL histwrite_phy(o_cldemi, cldemi)
-       CALL histwrite_phy(o_pr_con_l, pmflxr(:,1:klev))
-       CALL histwrite_phy(o_pr_con_i, pmflxs(:,1:klev))
-       CALL histwrite_phy(o_pr_lsc_l, prfl(:,1:klev))
-       CALL histwrite_phy(o_pr_lsc_i, psfl(:,1:klev))
-       CALL histwrite_phy(o_re, re)
-       CALL histwrite_phy(o_fl, fl)
-       IF (vars_defined) THEN
-          DO i=1, klon
-             IF (zt2m(i).LE.273.15) then
-                zx_tmp_fi2d(i)=MAX(0.,rh2m(i)*100.)
-             ELSE
-                zx_tmp_fi2d(i)=MAX(0.,MIN(100.,rh2m(i)*100.))
-             ENDIF
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_rh2m, zx_tmp_fi2d)
-
-!       IF (vars_defined) THEN
-!          DO i=1, klon
-!             zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
-!          ENDDO
-!       ENDIF
-!       CALL histwrite_phy(o_rh2m_min, zx_tmp_fi2d)
-
-!       IF (vars_defined) THEN
-!          DO i=1, klon
-!             zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
-!          ENDDO
-!       ENDIF
-!       CALL histwrite_phy(o_rh2m_max, zx_tmp_fi2d)
-
-       CALL histwrite_phy(o_qsat2m, qsat2m)
-       CALL histwrite_phy(o_tpot, tpot)
-       CALL histwrite_phy(o_tpote, tpote)
-       IF (vars_defined) zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, is_ter)
-       CALL histwrite_phy(o_SWnetOR,  zx_tmp_fi2d)
-       CALL histwrite_phy(o_LWdownOR, sollwdown)
-       CALL histwrite_phy(o_snowl, snow_lsc)
-       CALL histwrite_phy(o_solldown, sollwdown)
-       CALL histwrite_phy(o_dtsvdfo, d_ts(:,is_oce))
-       CALL histwrite_phy(o_dtsvdft, d_ts(:,is_ter))
-       CALL histwrite_phy(o_dtsvdfg,  d_ts(:,is_lic))
-       CALL histwrite_phy(o_dtsvdfi, d_ts(:,is_sic))
-       CALL histwrite_phy(o_z0m, z0m(:,nbsrf+1))
-       CALL histwrite_phy(o_z0h, z0h(:,nbsrf+1))
-
-       ! od550 per species
-!--OLIVIER
-!This is warranted by treating INCA aerosols as offline aerosols
-       IF (flag_aerosol.GT.0) THEN
-          CALL histwrite_phy(o_od443aer, od443aer)
-          CALL histwrite_phy(o_od550aer, od550aer)
-          CALL histwrite_phy(o_od865aer, od865aer)
-          CALL histwrite_phy(o_abs550aer, abs550aer)
-          CALL histwrite_phy(o_od550lt1aer, od550lt1aer)
-          CALL histwrite_phy(o_sconcso4, sconcso4)
-          CALL histwrite_phy(o_sconcno3, sconcno3)
-          CALL histwrite_phy(o_sconcoa, sconcoa)
-          CALL histwrite_phy(o_sconcbc, sconcbc)
-          CALL histwrite_phy(o_sconcss, sconcss)
-          CALL histwrite_phy(o_sconcdust, sconcdust)
-          CALL histwrite_phy(o_concso4, concso4)
-          CALL histwrite_phy(o_concno3, concno3)
-          CALL histwrite_phy(o_concoa, concoa)
-          CALL histwrite_phy(o_concbc, concbc)
-          CALL histwrite_phy(o_concss, concss)
-          CALL histwrite_phy(o_concdust, concdust)
-          CALL histwrite_phy(o_loadso4, loadso4)
-          CALL histwrite_phy(o_loadoa, loadoa)
-          CALL histwrite_phy(o_loadbc, loadbc)
-          CALL histwrite_phy(o_loadss, loadss)
-          CALL histwrite_phy(o_loaddust, loaddust)
-          CALL histwrite_phy(o_loadno3, loadno3)
-          CALL histwrite_phy(o_dryod550aer, dryod550aer)
-          DO naero = 1, naero_tot-1
-             CALL histwrite_phy(o_drytausumaero(naero),drytausum_aero(:,naero))
-          END DO
-       ENDIF
-       !--STRAT AER
-       IF (flag_aerosol.GT.0.OR.flag_aerosol_strat.GT.0) THEN
-          DO naero = 1, naero_tot
-             CALL histwrite_phy(o_tausumaero(naero),tausum_aero(:,2,naero))
-          END DO
-       ENDIF
-       IF (flag_aerosol_strat.GT.0) THEN
-          CALL histwrite_phy(o_tausumaero_lw,tausum_aero(:,6,id_STRAT_phy))
-       ENDIF
-
-       CALL histwrite_phy(o_p_tropopause, p_tropopause)
-       CALL histwrite_phy(o_t_tropopause, t_tropopause)
-       CALL histwrite_phy(o_z_tropopause, z_tropopause)
-
-! ThL -- In the following, we assume read_climoz == 1
-       IF (vars_defined) THEN
-         zx_tmp_fi2d = 0.0    ! Computation for strato, added ThL
-         DO k=1, klev
-            zx_tmp_fi2d(:) = zx_tmp_fi2d(:) + wo(:,k,1) * stratomask(:,k) * 1.e3
-         END DO
-       ENDIF
-       CALL histwrite_phy(o_col_O3_strato, zx_tmp_fi2d) ! Added ThL
-
-       IF (vars_defined) THEN
-         zx_tmp_fi2d = 0.0    ! Computation for tropo, added ThL
-         DO k=1, klev
-            zx_tmp_fi2d(:) = zx_tmp_fi2d(:) + wo(:,k,1) * (1.0-stratomask(:,k)) * 1.e3
-         END DO
-       ENDIF
-       CALL histwrite_phy(o_col_O3_tropo, zx_tmp_fi2d)   ! Added ThL
-! end add ThL
-
-#ifdef CPP_StratAer
-       IF (type_trac=='coag') THEN
-          CALL histwrite_phy(o_R2SO4, R2SO4)
-          CALL histwrite_phy(o_OCS_lifetime, OCS_lifetime)
-          CALL histwrite_phy(o_SO2_lifetime, SO2_lifetime)
-          CALL histwrite_phy(o_budg_3D_backgr_ocs,   budg_3D_backgr_ocs)
-          CALL histwrite_phy(o_budg_3D_backgr_so2,   budg_3D_backgr_so2)
-          CALL histwrite_phy(o_budg_3D_ocs_to_so2,   budg_3D_ocs_to_so2)
-          CALL histwrite_phy(o_budg_3D_so2_to_h2so4, budg_3D_so2_to_h2so4)
-          CALL histwrite_phy(o_budg_3D_nucl,         budg_3D_nucl)
-          CALL histwrite_phy(o_budg_3D_cond_evap,    budg_3D_cond_evap)
-          CALL histwrite_phy(o_budg_dep_dry_ocs,     budg_dep_dry_ocs)
-          CALL histwrite_phy(o_budg_dep_wet_ocs,     budg_dep_wet_ocs)
-          CALL histwrite_phy(o_budg_dep_dry_so2,     budg_dep_dry_so2)
-          CALL histwrite_phy(o_budg_dep_wet_so2,     budg_dep_wet_so2)
-          CALL histwrite_phy(o_budg_dep_dry_h2so4,   budg_dep_dry_h2so4)
-          CALL histwrite_phy(o_budg_dep_wet_h2so4,   budg_dep_wet_h2so4)
-          CALL histwrite_phy(o_budg_dep_dry_part,    budg_dep_dry_part)
-          CALL histwrite_phy(o_budg_dep_wet_part,    budg_dep_wet_part)
-          CALL histwrite_phy(o_budg_emi_ocs,         budg_emi_ocs)
-          CALL histwrite_phy(o_budg_emi_so2,         budg_emi_so2)
-          CALL histwrite_phy(o_budg_emi_h2so4,       budg_emi_h2so4)
-          CALL histwrite_phy(o_budg_emi_part,        budg_emi_part)
-          CALL histwrite_phy(o_budg_ocs_to_so2,      budg_ocs_to_so2)
-          CALL histwrite_phy(o_budg_so2_to_h2so4,    budg_so2_to_h2so4)
-          CALL histwrite_phy(o_budg_h2so4_to_part,   budg_h2so4_to_part)
-          CALL histwrite_phy(o_budg_sed_part,        budg_sed_part)
-          CALL histwrite_phy(o_surf_PM25_sulf, surf_PM25_sulf)
-          CALL histwrite_phy(o_vsed_aer, vsed_aer)
-          CALL histwrite_phy(o_f_r_wet, f_r_wet)
-          CALL histwrite_phy(o_ext_strat_550, tau_strat_550)
-          CALL histwrite_phy(o_ext_strat_1020, tau_strat_1020)
-          CALL histwrite_phy(o_tau_strat_550, tausum_strat(:,1))
-          CALL histwrite_phy(o_tau_strat_1020, tausum_strat(:,2))
-       ENDIF
-#endif
-       !NL
-       IF (ok_volcan .AND. ok_ade) THEN
-          DO k=1, klev
-             IF (vars_defined) zx_tmp_fi3d(:,k)=heat_volc(:,k)*swradcorr(:)
-          ENDDO
-          CALL histwrite_phy(o_heat_volc, zx_tmp_fi3d)
-          DO k=1, klev
-             IF (vars_defined) zx_tmp_fi3d(:,k)=cool_volc(:,k)
-          ENDDO
-          CALL histwrite_phy(o_cool_volc, zx_tmp_fi3d)
-       ENDIF
-       IF (ok_ade) THEN
-          IF (vars_defined) zx_tmp_fi2d(:)=topswad_aero*swradcorr
-          CALL histwrite_phy(o_topswad, zx_tmp_fi2d)
-          
-          IF (vars_defined) zx_tmp_fi2d(:)=topswad0_aero*swradcorr
-          CALL histwrite_phy(o_topswad0, zx_tmp_fi2d)
-                    
-          IF (vars_defined) zx_tmp_fi2d(:)=solswad_aero*swradcorr
-          CALL histwrite_phy(o_solswad, zx_tmp_fi2d)
-                    
-          IF (vars_defined) zx_tmp_fi2d(:)=solswad0_aero*swradcorr
-          CALL histwrite_phy(o_solswad0, zx_tmp_fi2d)
-          
-          CALL histwrite_phy(o_toplwad, toplwad_aero)
-          CALL histwrite_phy(o_toplwad0, toplwad0_aero)
-          CALL histwrite_phy(o_sollwad, sollwad_aero)
-          CALL histwrite_phy(o_sollwad0, sollwad0_aero)
-          !====MS forcing diagnostics
-          !ym warning : topsw_aero, solsw_aero, topsw0_aero, solsw0_aero are not defined by model
-          !ym => init to 0 in radlwsw_m.F90 ztopsw_aero, zsolsw_aero, ztopsw0_aero, zsolsw0_aero
-
-          IF (vars_defined) zx_tmp_fi2d(:)=topsw_aero(:,1)*swradcorr(:)
-          CALL histwrite_phy(o_swtoaas_nat,zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(:)=solsw_aero(:,1)*swradcorr(:)
-          CALL histwrite_phy(o_swsrfas_nat,zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(:)=topsw0_aero(:,1)*swradcorr(:)
-          CALL histwrite_phy(o_swtoacs_nat,zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(:)=solsw0_aero(:,1)*swradcorr(:)
-          CALL histwrite_phy(o_swsrfcs_nat,zx_tmp_fi2d)
-          !ant
-          IF (vars_defined) zx_tmp_fi2d(:)=topsw_aero(:,2)*swradcorr(:)
-          CALL histwrite_phy(o_swtoaas_ant,zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(:)=solsw_aero(:,2)*swradcorr(:)
-          CALL histwrite_phy(o_swsrfas_ant,zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(:)=topsw0_aero(:,2)*swradcorr(:)
-          CALL histwrite_phy(o_swtoacs_ant,zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(:)=solsw0_aero(:,2)*swradcorr(:)
-          CALL histwrite_phy(o_swsrfcs_ant,zx_tmp_fi2d)
-          !cf
-          IF (.not. aerosol_couple) THEN
-             IF (vars_defined) zx_tmp_fi2d(:)=topswcf_aero(:,1)*swradcorr(:)
-             CALL histwrite_phy(o_swtoacf_nat,zx_tmp_fi2d)
-             IF (vars_defined) zx_tmp_fi2d(:)=solswcf_aero(:,1)*swradcorr(:)
-             CALL histwrite_phy(o_swsrfcf_nat,zx_tmp_fi2d)
-             IF (vars_defined) zx_tmp_fi2d(:)=topswcf_aero(:,2)*swradcorr(:)
-             CALL histwrite_phy(o_swtoacf_ant,zx_tmp_fi2d)
-             IF (vars_defined) zx_tmp_fi2d(:)=solswcf_aero(:,2)*swradcorr(:)
-             CALL histwrite_phy(o_swsrfcf_ant,zx_tmp_fi2d)
-             IF (vars_defined) zx_tmp_fi2d(:)=topswcf_aero(:,3)*swradcorr(:)
-             CALL histwrite_phy(o_swtoacf_zero,zx_tmp_fi2d)
-             IF (vars_defined) zx_tmp_fi2d(:)=solswcf_aero(:,3)*swradcorr(:)
-             CALL histwrite_phy(o_swsrfcf_zero,zx_tmp_fi2d)
-          ENDIF
-          !====MS forcing diagnostics
-       ENDIF
-       IF (ok_aie) THEN
-          IF (vars_defined) zx_tmp_fi2d(:)= topswai_aero*swradcorr
-          CALL histwrite_phy(o_topswai, zx_tmp_fi2d)
-          
-          IF (vars_defined) zx_tmp_fi2d(:)=toplwai_aero*swradcorr
-          CALL histwrite_phy(o_toplwai, zx_tmp_fi2d)
-          
-          IF (vars_defined) zx_tmp_fi2d(:)=solswai_aero*swradcorr
-          CALL histwrite_phy(o_solswai, zx_tmp_fi2d)
-          
-          IF (vars_defined) zx_tmp_fi2d(:)=sollwai_aero*swradcorr
-          CALL histwrite_phy(o_sollwai, zx_tmp_fi2d)
-       ENDIF
-       IF (flag_aerosol.GT.0.AND.ok_cdnc) THEN
-          CALL histwrite_phy(o_scdnc, scdnc)
-          CALL histwrite_phy(o_cldncl, cldncl)
-          CALL histwrite_phy(o_reffclws, reffclws)
-          CALL histwrite_phy(o_reffclwc, reffclwc)
-          CALL histwrite_phy(o_cldnvi, cldnvi)
-          CALL histwrite_phy(o_lcc, lcc)
-          CALL histwrite_phy(o_lcc3d, lcc3d)
-          CALL histwrite_phy(o_lcc3dcon, lcc3dcon)
-          CALL histwrite_phy(o_lcc3dstra, lcc3dstra)
-          CALL histwrite_phy(o_icc3dcon, icc3dcon)
-          CALL histwrite_phy(o_icc3dstra, icc3dstra)
-          CALL histwrite_phy(o_cldicemxrat, zfice)
-          IF (vars_defined) zx_tmp_fi3d(:,:)=1-zfice(:,:)
-          CALL histwrite_phy(o_cldwatmxrat, zx_tmp_fi3d)
-          CALL histwrite_phy(o_reffclwtop, reffclwtop)
-       ENDIF
-       ! Champs 3D:
-       IF (ok_ade .OR. ok_aie) then
-          CALL histwrite_phy(o_ec550aer, ec550aer)
-       ENDIF
-       CALL histwrite_phy(o_lwcon, flwc)
-       CALL histwrite_phy(o_iwcon, fiwc)
-       CALL histwrite_phy(o_temp, t_seri)
-       CALL histwrite_phy(o_theta, theta)
-       CALL histwrite_phy(o_ovapinit, qx(:,:,ivap))
-       CALL histwrite_phy(o_ovap, q_seri)
-       CALL histwrite_phy(o_oliq, ql_seri)
-
-       IF (vars_defined) zx_tmp_fi3d = ql_seri+qs_seri
-       CALL histwrite_phy(o_ocond, zx_tmp_fi3d)
-
-       CALL histwrite_phy(o_geop, zphi)
-       CALL histwrite_phy(o_vitu, u_seri)
-       CALL histwrite_phy(o_vitv, v_seri)
-       CALL histwrite_phy(o_vitw, omega)
-       CALL histwrite_phy(o_pres, pplay)
-       CALL histwrite_phy(o_paprs, paprs(:,1:klev))
-       
-       IF (vars_defined) zx_tmp_fi3d = zphi/RG
-       CALL histwrite_phy(o_zfull,zx_tmp_fi3d)
-
-#ifdef CPP_XIOS
-!solbnd begin
-#ifdef CPP_RRTM
-      IF (iflag_rrtm.EQ.1) THEN
-       IF (vars_defined) THEN
-        DO ISW=1, NSW
-          zx_tmp_fi3dsp(:,ISW) = swdn(:,klevp1)*swradcorr(:)*RSUN(ISW)
-        ENDDO
-        CALL histwrite_phy(o_solbnd, zx_tmp_fi3dsp)
-       ENDIF
-      ENDIF
-#endif
-!solbnd end
-#endif
-
-       IF (flag_aerosol_strat.EQ.2) THEN
-         CALL histwrite_phy(o_stratomask, stratomask)
-       ENDIF
-      
-       IF (vars_defined)  THEN
-        zx_tmp_fi3d(:,1)= pphis(:)/RG
-        DO k = 2, klev
-         DO i = 1, klon
-            zx_tmp_fi3d(i,k) = zphi(i,k-1)/RG + &
-                          (zphi(i,k)-zphi(i,k-1))/RG * &
-                          (paprs(i,k)-pplay(i,k-1))/(pplay(i,k)-pplay(i,k-1))
-         ENDDO
-        ENDDO
-       ENDIF
-       CALL histwrite_phy(o_zhalf, zx_tmp_fi3d)
-       CALL histwrite_phy(o_rneb, cldfra)
-       CALL histwrite_phy(o_rnebcon, rnebcon)
-       CALL histwrite_phy(o_rnebls, rneb)
-       CALL histwrite_phy(o_rneblsvol, rneblsvol)
-       IF (vars_defined)  THEN
-          DO k=1, klev
-             DO i=1, klon
-                zx_tmp_fi3d(i,k)=cldfra(i,k)*JrNt(i)
-             ENDDO
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_rnebjn, zx_tmp_fi3d)
-       CALL histwrite_phy(o_rhum, zx_rh)
-       IF (iflag_ice_thermo .GT. 0) THEN
-          IF (vars_defined) zx_tmp_fi3d = zx_rhl * 100.
-          CALL histwrite_phy(o_rhl, zx_tmp_fi3d)
-          IF (vars_defined) zx_tmp_fi3d = zx_rhi * 100.
-          CALL histwrite_phy(o_rhi, zx_tmp_fi3d)
-       ENDIF
-
-       
-       IF (vars_defined) zx_tmp_fi3d = wo(:, :, 1) * dobson_u * 1e3 / zmasse / rmo3 * rmd
-       CALL histwrite_phy(o_ozone, zx_tmp_fi3d)
-
-       IF (read_climoz == 2) THEN
-         IF (vars_defined) zx_tmp_fi3d = wo(:, :, 2) * dobson_u * 1e3 / zmasse / rmo3 * rmd 
-         CALL histwrite_phy(o_ozone_light, zx_tmp_fi3d)
-       ENDIF
-
-       CALL histwrite_phy(o_duphy, d_u)
-
-       CALL histwrite_phy(o_dtphy, d_t)
-
-       CALL histwrite_phy(o_dqphy,  d_qx(:,:,ivap))
-       IF (vars_defined) CALL water_int(klon,klev,d_qx(:,:,ivap),zmasse,zx_tmp_fi2d)
-       CALL histwrite_phy(o_dqphy2d,  zx_tmp_fi2d)
-
-       CALL histwrite_phy(o_dqlphy,  d_qx(:,:,iliq))
-       IF (vars_defined) CALL water_int(klon,klev,d_qx(:,:,iliq),zmasse,zx_tmp_fi2d)
-       CALL histwrite_phy(o_dqlphy2d,  zx_tmp_fi2d)
-
-       IF (nqo.EQ.3) THEN
-       CALL histwrite_phy(o_dqsphy,  d_qx(:,:,isol))
-       IF (vars_defined) CALL water_int(klon,klev,d_qx(:,:,isol),zmasse,zx_tmp_fi2d)
-       CALL histwrite_phy(o_dqsphy2d,  zx_tmp_fi2d)
-       ELSE 
-       zx_tmp_fi3d=0.0
-       CALL histwrite_phy(o_dqsphy,  zx_tmp_fi3d)
-       zx_tmp_fi2d=0.0
-       CALL histwrite_phy(o_dqsphy2d,  zx_tmp_fi2d)
-       ENDIF
-
-       DO nsrf=1, nbsrf
-          IF (vars_defined) zx_tmp_fi2d(1 : klon) = falb1( 1 : klon, nsrf)
-          CALL histwrite_phy(o_albe_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(1 : klon) = z0m( 1 : klon, nsrf)
-          CALL histwrite_phy(o_z0m_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(1 : klon) = z0h( 1 : klon, nsrf)
-          CALL histwrite_phy(o_z0h_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(1 : klon) = agesno( 1 : klon, nsrf)
-          CALL histwrite_phy(o_ages_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(1 : klon) = snow( 1 : klon, nsrf)
-          CALL histwrite_phy(o_snow_srf(nsrf), zx_tmp_fi2d)
-       ENDDO !nsrf=1, nbsrf
-       CALL histwrite_phy(o_alb1, albsol1)
-       CALL histwrite_phy(o_alb2, albsol2)
-       !FH Sorties pour la couche limite
-       IF (iflag_pbl>1) THEN
-          zx_tmp_fi3d=0.
-          IF (vars_defined) THEN
-             DO nsrf=1,nbsrf
-                DO k=1,klev
-                   zx_tmp_fi3d(:,k)=zx_tmp_fi3d(:,k) &
-                        +pctsrf(:,nsrf)*pbl_tke(:,k,nsrf)
-                ENDDO
-             ENDDO
-          ENDIF
-          CALL histwrite_phy(o_tke, zx_tmp_fi3d)
-          CALL histwrite_phy(o_tke_max, zx_tmp_fi3d)  
-
-       ENDIF
-
-       CALL histwrite_phy(o_kz, coefh(:,:,is_ave))
-
-       CALL histwrite_phy(o_kz_max, coefh(:,:,is_ave))
-
-       CALL histwrite_phy(o_clwcon, clwcon0)
-       CALL histwrite_phy(o_dtdyn, d_t_dyn)
-
-       CALL histwrite_phy(o_dqdyn, d_q_dyn)
-
-       CALL histwrite_phy(o_dqdyn2d,d_q_dyn2d)
-
-       CALL histwrite_phy(o_dqldyn, d_ql_dyn)
-
-       CALL histwrite_phy(o_dqldyn2d, d_ql_dyn2d)
-
-       CALL histwrite_phy(o_dqsdyn, d_qs_dyn)
-
-       CALL histwrite_phy(o_dqsdyn2d, d_qs_dyn2d)
-
-       CALL histwrite_phy(o_dudyn, d_u_dyn)
-       CALL histwrite_phy(o_dvdyn, d_v_dyn)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys
-       ENDIF
-       CALL histwrite_phy(o_dtcon, zx_tmp_fi3d)
-       IF (iflag_thermals.EQ.0) THEN
-          IF (vars_defined) THEN
-             zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys + &
-                  d_t_ajsb(1:klon,1:klev)/pdtphys
-          ENDIF
-          CALL histwrite_phy(o_tntc, zx_tmp_fi3d)
-       ELSE IF(iflag_thermals.GE.1.AND.iflag_wake.EQ.1) THEN
-          IF (vars_defined) THEN
-             zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys + &
-                  d_t_ajs(1:klon,1:klev)/pdtphys + &
-                  d_t_wake(1:klon,1:klev)/pdtphys
-          ENDIF
-          CALL histwrite_phy(o_tntc, zx_tmp_fi3d)
-       ENDIF
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_con(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_ducon, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_con(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dvcon, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dqcon, zx_tmp_fi3d)
-       IF (vars_defined) CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
-       CALL histwrite_phy(o_dqcon2d, zx_tmp_fi2d)
-
-       IF (iflag_thermals.EQ.0) THEN
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_tnhusc, zx_tmp_fi3d)
-       ELSE IF (iflag_thermals.GE.1.AND.iflag_wake.EQ.1) THEN
-          IF (vars_defined) THEN
-             zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys + &
-                  d_q_ajs(1:klon,1:klev)/pdtphys + &
-                  d_q_wake(1:klon,1:klev)/pdtphys
-          ENDIF
-          CALL histwrite_phy(o_tnhusc, zx_tmp_fi3d)
-       ENDIF
-
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lsc(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dtlsc, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev)=(d_t_lsc(1:klon,1:klev)+ &
-            d_t_eva(1:klon,1:klev))/pdtphys
-       CALL histwrite_phy(o_dtlschr, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dqlsc, zx_tmp_fi3d)
-       IF (vars_defined) CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
-       CALL histwrite_phy(o_dqlsc2d, zx_tmp_fi2d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=beta_prec(1:klon,1:klev)
-       CALL histwrite_phy(o_beta_prec, zx_tmp_fi3d)
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-       ! Sorties specifiques a la separation thermiques/non thermiques
-       IF (iflag_thermals>=1) THEN
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lscth(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dtlscth, zx_tmp_fi3d)
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lscst(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dtlscst, zx_tmp_fi3d)
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_lscth(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dqlscth, zx_tmp_fi3d)
-          IF (vars_defined) CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
-          CALL histwrite_phy(o_dqlscth2d, zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_lscst(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dqlscst, zx_tmp_fi3d)
-          IF (vars_defined) CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
-          CALL histwrite_phy(o_dqlscst2d, zx_tmp_fi2d)
-          CALL histwrite_phy(o_plulth, plul_th)
-          CALL histwrite_phy(o_plulst, plul_st)
-          IF (vars_defined) THEN
-             DO i=1,klon
-                zx_tmp_fi2d(1:klon)=lmax_th(:)
-             ENDDO
-          ENDIF
-          CALL histwrite_phy(o_lmaxth, zx_tmp_fi2d)
-          IF (vars_defined) THEN
-             DO k=1,klev
-                DO i=1,klon
-                   IF (ptconvth(i,k)) THEN
-                      zx_tmp_fi3d(i,k)=1.
-                   ELSE
-                      zx_tmp_fi3d(i,k)=0.
-                   ENDIF
-                ENDDO
-             ENDDO
-          ENDIF
-          CALL histwrite_phy(o_ptconvth, zx_tmp_fi3d)
-       ENDIF ! iflag_thermals>=1
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-       zpt_conv = 0.
-       WHERE (ptconv) zpt_conv = 1.
-       CALL histwrite_phy(o_ptconv, zpt_conv)
-!!       IF (vars_defined)         zx_tmp_fi2d=float(itau_con)/float(itap)
-!!       CALL histwrite_phy(o_ftime_con, zx_tmp_fi2d)
-       IF (vars_defined) THEN
-          zpt_conv2d(:) = 0.
-          DO k=1,klev
-            WHERE (ptconv(:,k)) zpt_conv2d(:) = 1.
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_ftime_deepcv, zpt_conv2d)
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(:) = 0.
-          DO k=1,klev
-            WHERE (ptconvth(:,k)) zx_tmp_fi2d(:) = 1.
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_ftime_th, zx_tmp_fi2d)
-       IF (vars_defined) THEN
-           zx_tmp_fi2d(:) = max(zx_tmp_fi2d(:),zpt_conv2d(:))
-       ENDIF
-       CALL histwrite_phy(o_ftime_con, zx_tmp_fi2d)
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_vdf(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dtvdf, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_diss(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dtdis, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_vdf(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dqvdf, zx_tmp_fi3d)
-       IF (vars_defined) CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
-       CALL histwrite_phy(o_dqvdf2d, zx_tmp_fi2d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_eva(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dteva, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_eva(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dqeva, zx_tmp_fi3d)
-       IF (vars_defined) CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
-       CALL histwrite_phy(o_dqeva2d, zx_tmp_fi2d)
-       CALL histwrite_phy(o_ratqs, ratqs)
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)=d_t_ajs(1:klon,1:klev)/pdtphys - &
-               d_t_ajsb(1:klon,1:klev)/pdtphys
-       ENDIF
-       CALL histwrite_phy(o_dtthe, zx_tmp_fi3d)
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)=d_u_ajs(1:klon,1:klev)/pdtphys
-       ENDIF
-       CALL histwrite_phy(o_duthe, zx_tmp_fi3d) 
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)=d_v_ajs(1:klon,1:klev)/pdtphys
-       ENDIF
-       CALL histwrite_phy(o_dvthe, zx_tmp_fi3d)
-
-       IF (iflag_thermals>=1) THEN
-          ! Pour l instant 0 a y reflichir pour les thermiques
-          ! regroupe avec ftime_deepcv et ftime_con
-          !!zx_tmp_fi2d=0. 
-          !!CALL histwrite_phy(o_ftime_th, zx_tmp_fi2d)
-          CALL histwrite_phy(o_f_th, fm_therm)
-          CALL histwrite_phy(o_e_th, entr_therm)
-          CALL histwrite_phy(o_w_th, zw2)
-          CALL histwrite_phy(o_q_th, zqasc)
-          CALL histwrite_phy(o_a_th, fraca)
-          CALL histwrite_phy(o_cloudth_sth, cloudth_sth)
-          CALL histwrite_phy(o_cloudth_senv, cloudth_senv)
-          CALL histwrite_phy(o_cloudth_sigmath, cloudth_sigmath)
-          CALL histwrite_phy(o_cloudth_sigmaenv, cloudth_sigmaenv)
-          CALL histwrite_phy(o_d_th, detr_therm)
-          CALL histwrite_phy(o_f0_th, f0)
-          CALL histwrite_phy(o_zmax_th, zmax_th)
-          IF (vars_defined) THEN
-             zx_tmp_fi3d(1:klon,1:klev)=d_q_ajs(1:klon,1:klev)/pdtphys - &
-                  d_q_ajsb(1:klon,1:klev)/pdtphys
-          ENDIF
-          CALL histwrite_phy(o_dqthe, zx_tmp_fi3d)
-          IF (vars_defined) CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
-          CALL histwrite_phy(o_dqthe2d, zx_tmp_fi2d)
-       ENDIF !iflag_thermals
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_ajsb(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dtajs, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_ajsb(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dqajs, zx_tmp_fi3d)
-       IF (vars_defined) CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
-       CALL histwrite_phy(o_dqajs2d, zx_tmp_fi2d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_swr(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dtswr, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_sw0(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dtsw0, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lwr(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dtlwr, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lw0(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dtlw0, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_ec(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dtec, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_vdf(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_duvdf, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_vdf(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dvvdf, zx_tmp_fi3d)
-       IF (ok_orodr) THEN
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_oro(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_duoro, zx_tmp_fi3d)
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_oro(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dvoro, zx_tmp_fi3d)
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_oro(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dtoro, zx_tmp_fi3d)
-       ENDIF
-       IF (ok_orolf) THEN
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_lif(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dulif, zx_tmp_fi3d)
-
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_lif(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dvlif, zx_tmp_fi3d)
-
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lif(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dtlif, zx_tmp_fi3d)
-       ENDIF
-
-       IF (ok_hines) THEN
-          IF (vars_defined) zx_tmp_fi3d=du_gwd_hines/pdtphys
-          CALL histwrite_phy(o_du_gwd_hines, zx_tmp_fi3d)
-
-          IF (vars_defined) zx_tmp_fi3d= dv_gwd_hines/pdtphys          
-          CALL histwrite_phy(o_dv_gwd_hines, zx_tmp_fi3d)
-          
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_hin(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dthin, zx_tmp_fi3d)
-          CALL histwrite_phy(o_ustr_gwd_hines, zustr_gwd_hines)
-          CALL histwrite_phy(o_vstr_gwd_hines, zvstr_gwd_hines)
-       ENDIF
-
-       IF (.not. ok_hines .and. ok_gwd_rando) THEN
-          IF (vars_defined)  zx_tmp_fi3d=du_gwd_front / pdtphys
-          CALL histwrite_phy(o_du_gwd_front, zx_tmp_fi3d)
-          
-          IF (vars_defined)  zx_tmp_fi3d=dv_gwd_front / pdtphys
-          CALL histwrite_phy(o_dv_gwd_front, zx_tmp_fi3d)
-          
-          CALL histwrite_phy(o_ustr_gwd_front, zustr_gwd_front)
-          CALL histwrite_phy(o_vstr_gwd_front, zvstr_gwd_front)
-       ENDIF
-
-       IF (ok_gwd_rando) THEN
-          IF (vars_defined)  zx_tmp_fi3d=du_gwd_rando / pdtphys
-          CALL histwrite_phy(o_du_gwd_rando, zx_tmp_fi3d)
-          
-          IF (vars_defined)  zx_tmp_fi3d=dv_gwd_rando / pdtphys
-          CALL histwrite_phy(o_dv_gwd_rando, zx_tmp_fi3d)
-          CALL histwrite_phy(o_ustr_gwd_rando, zustr_gwd_rando)
-          CALL histwrite_phy(o_vstr_gwd_rando, zvstr_gwd_rando)
-          CALL histwrite_phy(o_east_gwstress, east_gwstress )
-          CALL histwrite_phy(o_west_gwstress, west_gwstress )
-       ENDIF
-
-       IF (ok_qch4) THEN
-          IF (vars_defined) zx_tmp_fi3d=d_q_ch4 / pdtphys
-          CALL histwrite_phy(o_dqch4, zx_tmp_fi3d)
-       ENDIF
-       
-       IF (vars_defined) THEN
-         DO k=1, klevp1
-           zx_tmp_fi3d1(:,k)=swup(:,k)*swradcorr(:)
-         ENDDO
-       ENDIF
-       
-       CALL histwrite_phy(o_rsu, zx_tmp_fi3d1)
-
-
-       IF (vars_defined) THEN
-         DO k=1, klevp1
-           zx_tmp_fi3d1(:,k)=swdn(:,k)*swradcorr(:)
-         ENDDO
-       ENDIF
-       
-       CALL histwrite_phy(o_rsd, zx_tmp_fi3d1)
-
-       IF (vars_defined) THEN
-         DO k=1, klevp1
-           zx_tmp_fi3d1(:,k)=swup0(:,k)*swradcorr(:)
-         ENDDO
-       ENDIF
-       
-       CALL histwrite_phy(o_rsucs, zx_tmp_fi3d1)
-
-       IF (vars_defined) THEN
-         DO k=1, klevp1
-           zx_tmp_fi3d1(:,k)=swupc0(:,k)*swradcorr(:)
-         ENDDO
-       ENDIF
-       CALL histwrite_phy(o_rsucsaf, zx_tmp_fi3d1)
-
-       IF (vars_defined) THEN
-         DO k=1, klevp1
-           zx_tmp_fi3d1(:,k)=swdn0(:,k)*swradcorr(:)
-         ENDDO
-       ENDIF
-       CALL histwrite_phy(o_rsdcs, zx_tmp_fi3d1)
-
-
-       IF (vars_defined) THEN
-         DO k=1, klevp1
-           zx_tmp_fi3d1(:,k)=swdnc0(:,k)*swradcorr(:)
-         ENDDO
-       ENDIF
-       CALL histwrite_phy(o_rsdcsaf, zx_tmp_fi3d1)
-
-       CALL histwrite_phy(o_rlu, lwup)
-       CALL histwrite_phy(o_rld, lwdn)
-       CALL histwrite_phy(o_rlucs, lwup0)
-       CALL histwrite_phy(o_rldcs, lwdn0)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)=d_t(1:klon,1:klev)+ &
-               d_t_dyn(1:klon,1:klev)
-       ENDIF
-       CALL histwrite_phy(o_tnt, zx_tmp_fi3d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)=d_t_swr(1:klon,1:klev)/pdtphys + &
-               d_t_lwr(1:klon,1:klev)/pdtphys
-       ENDIF
-       CALL histwrite_phy(o_tntr, zx_tmp_fi3d)
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)= (d_t_lsc(1:klon,1:klev)+ &
-               d_t_eva(1:klon,1:klev)+ &
-               d_t_vdf(1:klon,1:klev))/pdtphys
-       ENDIF
-       CALL histwrite_phy(o_tntscpbl, zx_tmp_fi3d)
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)=d_qx(1:klon,1:klev,ivap)+ &
-               d_q_dyn(1:klon,1:klev)
-       ENDIF
-       CALL histwrite_phy(o_tnhus, zx_tmp_fi3d)
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys+ &
-               d_q_eva(1:klon,1:klev)/pdtphys
-       ENDIF
-       CALL histwrite_phy(o_tnhusscpbl, zx_tmp_fi3d)
-       CALL histwrite_phy(o_evu, coefm(:,:,is_ave))
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)=q_seri(1:klon,1:klev)+ &
-               ql_seri(1:klon,1:klev) 
-       ENDIF
-       CALL histwrite_phy(o_h2o, zx_tmp_fi3d)
-       IF (iflag_con >= 3) THEN
-          IF (vars_defined) THEN
-             zx_tmp_fi3d(1:klon,1:klev)=-1 * (dnwd(1:klon,1:klev)+ &
-                  dnwd0(1:klon,1:klev)) 
-          ENDIF
-          CALL histwrite_phy(o_mcd, zx_tmp_fi3d)
-          IF (vars_defined) THEN
-             zx_tmp_fi3d(1:klon,1:klev)=upwd(1:klon,1:klev) + &
-                  dnwd(1:klon,1:klev)+ dnwd0(1:klon,1:klev) 
-          ENDIF
-          CALL histwrite_phy(o_dmc, zx_tmp_fi3d)
-       ELSE IF (iflag_con == 2) THEN
-          CALL histwrite_phy(o_mcd,  pmfd)
-          IF (vars_defined) zx_tmp_fi3d = pmfu + pmfd
-          CALL histwrite_phy(o_dmc,  zx_tmp_fi3d)
-       ENDIF
-       CALL histwrite_phy(o_ref_liq, ref_liq)
-       CALL histwrite_phy(o_ref_ice, ref_ice)
-!
-       IF (ok_4xCO2atm) THEN
-          IF (vars_defined) zx_tmp_fi2d(:) = swupp(:,klevp1)*swradcorr(:)
-          CALL histwrite_phy(o_rsut4co2, zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(:) = lwupp(:,klevp1)
-          CALL histwrite_phy(o_rlut4co2, zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(:) = swup0p(:,klevp1)*swradcorr(:)
-          CALL histwrite_phy(o_rsutcs4co2, zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(:) = lwup0p(:,klevp1)
-          CALL histwrite_phy(o_rlutcs4co2, zx_tmp_fi2d)
-          IF (vars_defined) THEN
-            DO k=1, klevp1
-              zx_tmp_fi3d1(:,k)=swupp(:,k)*swradcorr(:)
-            ENDDO
-          ENDIF
-          CALL histwrite_phy(o_rsu4co2, zx_tmp_fi3d1)
-          IF (vars_defined) THEN
-            DO k=1, klevp1
-              zx_tmp_fi3d1(:,k)=swup0p(:,k)*swradcorr(:)
-            ENDDO
-          ENDIF
-          CALL histwrite_phy(o_rsucs4co2, zx_tmp_fi3d1)
-          IF (vars_defined) THEN
-            DO k=1, klevp1
-              zx_tmp_fi3d1(:,k)=swdnp(:,k)*swradcorr(:)
-            ENDDO
-          ENDIF
-          CALL histwrite_phy(o_rsd4co2, zx_tmp_fi3d1)
-          IF (vars_defined) THEN
-            DO k=1, klevp1
-              zx_tmp_fi3d1(:,k)=swdn0p(:,k)*swradcorr(:)
-            ENDDO
-          ENDIF
-          CALL histwrite_phy(o_rsdcs4co2, zx_tmp_fi3d1)
-          CALL histwrite_phy(o_rlu4co2, lwupp)
-          CALL histwrite_phy(o_rlucs4co2, lwup0p)
-          CALL histwrite_phy(o_rld4co2, lwdnp)
-          CALL histwrite_phy(o_rldcs4co2, lwdn0p)
-       ENDIF !ok_4xCO2atm
-!!!!!!!!!!!! Sorties niveaux de pression NMC !!!!!!!!!!!!!!!!!!!!
-#ifdef CPP_IOIPSL
-#ifndef CPP_XIOS
-  IF (.NOT.ok_all_xml) THEN 
-       ! ATTENTION, LES ANCIENS HISTWRITE ONT ETES CONSERVES EN ATTENDANT MIEUX:
-       ! Champs interpolles sur des niveaux de pression
-       DO iff=7, nfiles-1 !--OB: here we deal with files 7,8,9
-
-          CALL histwrite_phy(o_tnondef,tnondef(:,:,iff-6),iff)
-          CALL histwrite_phy(o_ta,twriteSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_zg,phiwriteSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_hus,qwriteSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_hur,rhwriteSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_ua,uwriteSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_va,vwriteSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_wap,wwriteSTD(:,:,iff-6),iff)
-          IF (vars_defined) THEN
-             DO k=1, nlevSTD
-                DO i=1, klon
-                   IF (tnondef(i,k,iff-6).NE.missing_val) THEN
-                      IF (freq_outNMC(iff-6).LT.0) THEN
-                         freq_moyNMC(iff-6)=(mth_len*un_jour)/freq_calNMC(iff-6)
-                      ELSE
-                         freq_moyNMC(iff-6)=freq_outNMC(iff-6)/freq_calNMC(iff-6)
-                      ENDIF
-                      zx_tmp_fi3d_STD(i,k) = (100.*tnondef(i,k,iff-6))/freq_moyNMC(iff-6)
-                   ELSE
-                      zx_tmp_fi3d_STD(i,k) = missing_val
-                   ENDIF
-                ENDDO
-             ENDDO
-          ENDIF
-          CALL histwrite_phy(o_psbg,zx_tmp_fi3d_STD,iff)
-          IF (vars_defined) THEN
-             DO k=1, nlevSTD
-                DO i=1, klon
-                   IF (O3sumSTD(i,k,iff-6).NE.missing_val) THEN
-                      zx_tmp_fi3d_STD(i,k) = O3sumSTD(i,k,iff-6) * 1.e+9
-                   ELSE
-                      zx_tmp_fi3d_STD(i,k) = missing_val
-                   ENDIF
-                ENDDO
-             ENDDO !k=1, nlevSTD
-          ENDIF
-          CALL histwrite_phy(o_tro3,zx_tmp_fi3d_STD,iff)
-          IF (read_climoz == 2) THEN
-             IF (vars_defined) THEN
-                DO k=1, nlevSTD
-                   DO i=1, klon
-                      IF (O3daysumSTD(i,k,iff-6).NE.missing_val) THEN
-                         zx_tmp_fi3d_STD(i,k) = O3daysumSTD(i,k,iff-6) * 1.e+9
-                      ELSE
-                         zx_tmp_fi3d_STD(i,k) = missing_val
-                      ENDIF
-                   ENDDO
-                ENDDO !k=1, nlevSTD
-             ENDIF
-             CALL histwrite_phy(o_tro3_daylight,zx_tmp_fi3d_STD,iff)
-          endif
-          CALL histwrite_phy(o_uxv,uvsumSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_vxq,vqsumSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_vxT,vTsumSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_wxq,wqsumSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_vxphi,vphisumSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_wxT,wTsumSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_uxu,u2sumSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_vxv,v2sumSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_TxT,T2sumSTD(:,:,iff-6),iff)
-       ENDDO !nfiles
-  ENDIF
-#endif
-#endif
-#ifdef CPP_XIOS
-  IF (ok_all_xml) THEN 
-!      DO iff=7, nfiles
-
-!         CALL histwrite_phy(o_tnondef,tnondef(:,:,3))
-          CALL histwrite_phy(o_ta,tlevSTD(:,:))
-          CALL histwrite_phy(o_zg,philevSTD(:,:))
-          CALL histwrite_phy(o_hus,qlevSTD(:,:))
-          CALL histwrite_phy(o_hur,rhlevSTD(:,:))
-          CALL histwrite_phy(o_ua,ulevSTD(:,:))
-          CALL histwrite_phy(o_va,vlevSTD(:,:))
-          CALL histwrite_phy(o_wap,wlevSTD(:,:))
-!         IF (vars_defined) THEN
-!            DO k=1, nlevSTD
-!               DO i=1, klon
-!                  IF (tnondef(i,k,3).NE.missing_val) THEN
-!                     IF (freq_outNMC(iff-6).LT.0) THEN
-!                        freq_moyNMC(iff-6)=(mth_len*un_jour)/freq_calNMC(iff-6)
-!                     ELSE
-!                        freq_moyNMC(iff-6)=freq_outNMC(iff-6)/freq_calNMC(iff-6)
-!                     ENDIF
-!                     zx_tmp_fi3d_STD(i,k) = (100.*tnondef(i,k,3))/freq_moyNMC(iff-6)
-!                  ELSE
-!                     zx_tmp_fi3d_STD(i,k) = missing_val
-!                  ENDIF
-!               ENDDO
-!            ENDDO
-!         ENDIF
-!         CALL histwrite_phy(o_psbg,zx_tmp_fi3d_STD)
-          IF (vars_defined) THEN
-             DO k=1, nlevSTD
-                DO i=1, klon
-                   IF (O3STD(i,k).NE.missing_val) THEN
-                      zx_tmp_fi3d_STD(i,k) = O3STD(i,k) * 1.e+9
-                   ELSE
-                      zx_tmp_fi3d_STD(i,k) = missing_val
-                   ENDIF
-                ENDDO
-             ENDDO !k=1, nlevSTD
-          ENDIF
-          CALL histwrite_phy(o_tro3,zx_tmp_fi3d_STD)
-          IF (read_climoz == 2) THEN
-             IF (vars_defined) THEN
-                DO k=1, nlevSTD
-                   DO i=1, klon
-                      IF (O3daySTD(i,k).NE.missing_val) THEN
-                         zx_tmp_fi3d_STD(i,k) = O3daySTD(i,k) * 1.e+9
-                      ELSE
-                         zx_tmp_fi3d_STD(i,k) = missing_val
-                      ENDIF
-                   ENDDO
-                ENDDO !k=1, nlevSTD
-             ENDIF
-             CALL histwrite_phy(o_tro3_daylight,zx_tmp_fi3d_STD)
-          ENDIF
-          CALL histwrite_phy(o_uxv,uvSTD(:,:))
-          CALL histwrite_phy(o_vxq,vqSTD(:,:))
-          CALL histwrite_phy(o_vxT,vTSTD(:,:))
-          CALL histwrite_phy(o_wxq,wqSTD(:,:))
-          CALL histwrite_phy(o_vxphi,vphiSTD(:,:))
-          CALL histwrite_phy(o_wxT,wTSTD(:,:))
-          CALL histwrite_phy(o_uxu,u2STD(:,:))
-          CALL histwrite_phy(o_vxv,v2STD(:,:))
-          CALL histwrite_phy(o_TxT,T2STD(:,:))
-!      ENDDO !nfiles
-  ENDIF
-#endif
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-       IF (iflag_phytrac == 1 ) then
-         IF (type_trac == 'lmdz' .OR. type_trac == 'coag') THEN
-!           DO iq=nqo+1, nqtot
-        ! C Risi: modif boucle
-            DO itr=1,nqtottr 
-                write(*,*) 'phys_output_write_mod 2337: itr=',itr
-                iq=itr_indice(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))
-             CALL histwrite_phy(o_dtr_lessi_impa(itr),d_tr_lessi_impa(:,:,itr))
-             CALL histwrite_phy(o_dtr_lessi_nucl(itr),d_tr_lessi_nucl(:,:,itr))
-             CALL histwrite_phy(o_dtr_insc(itr),d_tr_insc(:,:,itr))
-             CALL histwrite_phy(o_dtr_bcscav(itr),d_tr_bcscav(:,:,itr))
-             CALL histwrite_phy(o_dtr_evapls(itr),d_tr_evapls(:,:,itr))
-             CALL histwrite_phy(o_dtr_ls(itr),d_tr_ls(:,:,itr))
-             CALL histwrite_phy(o_dtr_trsp(itr),d_tr_trsp(:,:,itr))
-             CALL histwrite_phy(o_dtr_sscav(itr),d_tr_sscav(:,:,itr))
-             CALL histwrite_phy(o_dtr_sat(itr),d_tr_sat(:,:,itr))
-             CALL histwrite_phy(o_dtr_uscav(itr),d_tr_uscav(:,:,itr))
-            !--2D fields
-             CALL histwrite_phy(o_dtr_dry(itr), flux_tr_dry(:,itr))
-             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
-         ENDIF   !--type_trac
-!
-         IF (type_trac == 'co2i') THEN
-           !DO iq=nqo+1, nqtot
-        ! C Risi: modif boucle
-            DO itr=1,nqtottr 
-             write(*,*) 'phys_output_write_mod 2370: itr=',itr
-             iq=itr_indice(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
-           nqup = nqo+1
-           DO iq=nqo+1, nqup
-             !--3D fields
-             CALL histwrite_phy(o_trac(iq-nqo), tr_seri(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_vdf(iq-nqo),d_tr_cl(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_the(iq-nqo),d_tr_th(:,:,iq-nqo))
-             CALL histwrite_phy(o_dtr_con(iq-nqo),d_tr_cv(:,:,iq-nqo))
-             !--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,iq-nqo)
-                ENDDO
-             ENDIF
-             CALL histwrite_phy(o_trac_cum(iq-nqo), 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)
-
-       if (activate_ocean_skin >= 1) then
-          CALL histwrite_phy(o_delta_sst, delta_sst)
-          CALL histwrite_phy(o_delta_sal, delta_sal)
-          CALL histwrite_phy(o_ds_ns, ds_ns)
-          CALL histwrite_phy(o_dt_ns, dt_ns)
-          CALL histwrite_phy(o_dter, dter)
-          CALL histwrite_phy(o_dser, dser)
-          CALL histwrite_phy(o_tkt, tkt)
-          CALL histwrite_phy(o_tks, tks)
-          CALL histwrite_phy(o_taur, taur)
-          CALL histwrite_phy(o_sss, sss)
-       end if
-
-#ifdef ISO
-    do ixt=1,ntraciso
-        write(*,*) 'ixt'
-        IF (vars_defined) THEN
-             zx_tmp_fi2d(:) = xtrain_fall(ixt,:) + xtsnow_fall(ixt,:)
-        ENDIF
-        CALL histwrite_phy(o_xtprecip(ixt), zx_tmp_fi2d)
-
-        IF (vars_defined) THEN
-             zx_tmp_fi2d(:) = xtrain_lsc(ixt,:) + xtsnow_lsc(ixt,:)
-       ENDIF
-       CALL histwrite_phy(o_xtplul(ixt), zx_tmp_fi2d)
-
-        IF (vars_defined) THEN
-             zx_tmp_fi2d(:) = xtrain_con(ixt,:) + xtsnow_con(ixt,:)
-        ENDIF
-       CALL histwrite_phy(o_xtpluc(ixt), zx_tmp_fi2d)
-
-       CALL histwrite_phy(o_xtevap(ixt), xtevap(ixt,:))
-       CALL histwrite_phy(o_xtovap(ixt), xt_seri(ixt,:,:))
-       CALL histwrite_phy(o_xtoliq(ixt), xtl_seri(ixt,:,:))
-
-        IF (vars_defined) THEN
-             zx_tmp_fi3d(:,:)=xtl_seri(ixt,:,:)+xts_seri(ixt,:,:)
-        ENDIF
-        CALL histwrite_phy(o_xtcond(ixt), zx_tmp_fi3d)
-
-        CALL histwrite_phy(o_dxtdyn(ixt), d_xt_dyn(ixt,:,:))
-        CALL histwrite_phy(o_dxtldyn(ixt), d_xtl_dyn(ixt,:,:))
-
-        IF (vars_defined) THEN
-             zx_tmp_fi3d(:,:)=d_xt_con(ixt,:,:)/pdtphys
-        ENDIF
-        CALL histwrite_phy(o_dxtcon(ixt), zx_tmp_fi3d)
-
-        IF (vars_defined) THEN
-             zx_tmp_fi3d(:,:)=d_xt_lsc(ixt,:,:)/pdtphys
-        ENDIF
-        CALL histwrite_phy(o_dxtlsc(ixt), zx_tmp_fi3d)
-
-        IF (vars_defined) THEN
-             zx_tmp_fi3d(:,:)=d_xt_eva(ixt,:,:)/pdtphys
-        ENDIF
-        CALL histwrite_phy(o_dxteva(ixt), zx_tmp_fi3d)
-
-        IF (vars_defined) THEN
-             zx_tmp_fi3d(:,:)=d_xt_vdf(ixt,:,:)/pdtphys
-        ENDIF
-        CALL histwrite_phy(o_dxtvdf(ixt), zx_tmp_fi3d)
-
-        IF (vars_defined) THEN
-             zx_tmp_fi3d(:,:)=d_xt_ajsb(ixt,:,:)/pdtphys
-        ENDIF
-        CALL histwrite_phy(o_dxtajs(ixt), zx_tmp_fi3d)
-
-        IF (vars_defined) THEN
-             zx_tmp_fi3d(:,:)=d_xt_ajs(ixt,:,:)/pdtphys - &
-                  d_xt_ajsb(ixt,:,:)/pdtphys
-        ENDIF
-        CALL histwrite_phy(o_dxtthe(ixt), zx_tmp_fi3d)
-
-        IF (ok_qch4) then
-        IF (vars_defined) THEN
-             zx_tmp_fi3d(:,:)=d_xt_ch4(ixt,:,:)/pdtphys
-        ENDIF
-        CALL histwrite_phy(o_dxtch4(ixt), zx_tmp_fi3d)
-        ENDIF !IF (ok_qch4) then
-
-        IF (ixt.eq.iso_HTO) then
-        IF (vars_defined) THEN
-             zx_tmp_fi3d(:,:)=d_xt_prod_nucl(ixt,:,:)/pdtphys
-        ENDIF
-        CALL histwrite_phy(o_dxtprod_nucl(ixt), zx_tmp_fi3d)
-
-        IF (vars_defined) THEN
-             zx_tmp_fi3d(:,:)=d_xt_cosmo(ixt,:,:)/pdtphys
-        ENDIF
-        CALL histwrite_phy(o_dxtcosmo(ixt), zx_tmp_fi3d)
-
-        IF (vars_defined) THEN
-             zx_tmp_fi3d(:,:)=d_xt_decroiss(ixt,:,:)/pdtphys
-        ENDIF
-        CALL histwrite_phy(o_dxtdecroiss(ixt), zx_tmp_fi3d)
-        ENDIF !IF (iso_HTO.gt.0) then
-
-    !write(*,*) 'phys_output_write_mod 2531'
-    enddo !do ixt=1,ntraciso    
-    !write(*,*) 'phys_output_write_mod 1777'    
-#endif
-
-       IF (.NOT.vars_defined) THEN
-          !$OMP MASTER
-#ifndef CPP_IOIPSL_NO_OUTPUT 
-          DO iff=1,nfiles
-             IF (clef_files(iff)) THEN
-                CALL histend(nid_files(iff))
-                ndex2d = 0
-                ndex3d = 0
-             ENDIF ! clef_files
-          ENDDO !  iff
-#endif
-#ifdef CPP_XIOS
-          !On finalise l'initialisation:
-          CALL wxios_closedef()
-#endif
-          !$OMP END MASTER
-          !$OMP BARRIER
-          vars_defined = .TRUE.
-
-       ENDIF !--.NOT.vars_defined
-
-    ENDDO
-
-    IF (vars_defined) THEN
-       ! On synchronise les fichiers pour IOIPSL
-#ifndef CPP_IOIPSL_NO_OUTPUT 
-       !$OMP MASTER
-       DO iff=1,nfiles
-          IF (ok_sync .AND. clef_files(iff)) THEN
-             CALL histsync(nid_files(iff))
-          ENDIF
-       END DO
-       !$OMP END MASTER
-#endif
-    ENDIF
-
-  END SUBROUTINE phys_output_write
-
-END MODULE phys_output_write_mod
+link ../phylmd/phys_output_write_mod.F90
Index: /LMDZ6/trunk/libf/phylmdiso/physiq_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmdiso/physiq_mod.F90	(revision 4055)
+++ /LMDZ6/trunk/libf/phylmdiso/physiq_mod.F90	(revision 4056)
@@ -39,7 +39,7 @@
     USE ioipsl_getin_p_mod, ONLY : getin_p
     USE indice_sol_mod
-    USE infotrac_phy, ONLY: nqtot, nbtr, nqo, type_trac,ok_isotopes, &
-        nqtottr,itr_indice ! C Risi
-
+    USE infotrac_phy, ONLY: nqtot, nbtr, nqo, tracers, type_trac, nqCO2, ok_isotopes
+    USE readTracFiles_mod, ONLY: phases_sep
+    USE strings_mod,  ONLY: strIdx
     USE iophy
     USE limit_read_mod, ONLY : init_limit_read
@@ -61,5 +61,6 @@
     USE phys_output_mod
     USE phys_output_ctrlout_mod
-    USE print_control_mod, ONLY: mydebug=>debug , lunout, prt_level
+    USE print_control_mod, ONLY: mydebug=>debug , lunout, prt_level, &
+         alert_first_call, call_alert, prt_alerte
     USE readaerosol_mod, ONLY : init_aero_fromfile
     USE readaerosolstrato_m, ONLY : init_readaerosolstrato
@@ -123,6 +124,5 @@
 #ifdef ISO
     USE infotrac_phy, ONLY:  &
-        iqiso,iso_indnum,tracers,ok_isotrac, &
-        niso,ntraciso,nqtottr,itr_indice ! ajout C Risi pour isos
+        iqiso,iso_indnum,ok_isotrac,niso, ntraciso
      USE isotopes_mod, ONLY: iso_eau,iso_HDO,iso_O18,iso_O17,iso_HTO, &
         & bidouille_anti_divergence,ok_bidouille_wake, &
@@ -188,6 +188,6 @@
        !
        d_t_vdf,d_q_vdf,d_u_vdf,d_v_vdf,d_t_diss, &
-       d_t_vdf_w,d_q_vdf_w, &
-       d_t_vdf_x,d_q_vdf_x, &
+       d_t_vdf_x, d_t_vdf_w, &
+       d_q_vdf_x, d_q_vdf_w, &
        d_ts, &
        !
@@ -262,6 +262,4 @@
        zxfluxlat_x, zxfluxlat_w, &
        !
-       d_t_vdf_x, d_t_vdf_w, &
-       d_q_vdf_x, d_q_vdf_w, &
        pbl_tke_input, tke_dissip, l_mix, wprime,&
        t_therm, q_therm, u_therm, v_therm, &
@@ -939,6 +937,5 @@
     real zqsat(klon,klev)
     !
-    INTEGER i, k, iq, j, nsrf, ll, l
-    INTEGER itr ! C Risi
+    INTEGER i, k, iq, j, nsrf, ll, l, itr
 #ifdef ISO
     real zxt_apres(ntraciso,klon)
@@ -1133,5 +1130,5 @@
 !JLD    REAL zstophy, zout
 
-    CHARACTER*20 modname
+    CHARACTER (LEN=20) :: modname='physiq_mod'
     CHARACTER*80 abort_message
     LOGICAL, SAVE ::  ok_sync, ok_sync_omp
@@ -1306,4 +1303,7 @@
     pi = 4. * ATAN(1.)
 
+    ! set-up call to alerte function
+    call_alert = (alert_first_call .AND. is_master)
+    
     ! Ehouarn: set value of jjmp1 since it is no longer a "fixed parameter"
     jjmp1=nbp_lat
@@ -1424,5 +1424,4 @@
     forall (k=1: nbp_lev) zmasse(:, k) = (paprs(:, k)-paprs(:, k+1)) / rg
 
-    modname = 'physiq'
 
     IF (debut) THEN
@@ -1853,6 +1852,10 @@
 
        CALL iniradia(klon,klev,paprs(1,1:klev+1))
-
-       ! Initialisation des champs dans phytrac* qui sont utilisés par phys_output_write*
+       !
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+       ! Initialisation des champs dans phytrac* qui sont utilises par phys_output_write*
+       !
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
 #ifdef CPP_Dust
        ! Quand on utilise SPLA, on force iflag_phytrac=1
@@ -1899,5 +1902,5 @@
             ENDDO
           ENDDO
-        ELSE
+       ELSE
           pbl_tke(:,:,is_ave) = 0. !ym missing init : maybe must be initialized in the same way that for klon_glo==1 ??
 !>jyg
@@ -1949,7 +1952,12 @@
           CALL abort_physic(modname,abort_message,1)
        ENDIF
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+       ! Initialisation pour la convection de K.E. et pour les poches froides
+       !
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
        WRITE(lunout,*)"Clef pour la convection, iflag_con=", iflag_con
-       WRITE(lunout,*)"Clef pour le driver de la convection, ok_cvl=", &
-            ok_cvl
+       WRITE(lunout,*)"Clef pour le driver de la convection, ok_cvl=", ok_cvl
        !
        !KE43
@@ -2004,5 +2012,5 @@
              d_deltaxt_ajs_cv(:,:,:) = 0.
 #endif
-          ENDIF
+          ENDIF  !  (iflag_wake>=1)
 
           !        do i = 1,klon
@@ -2015,6 +2023,6 @@
        !   ALLOCATE(lonGCM(0), latGCM(0))
        !   ALLOCATE(iGCM(0), jGCM(0))
-       ENDIF
-
+       ENDIF  !  (iflag_con.GE.3)
+       !
        DO i=1,klon
           rugoro(i) = f_rugoro * MAX(1.0e-05, zstd(i)*zsig(i)/2.0)
@@ -2085,14 +2093,51 @@
        !$OMP BARRIER
        missing_val=missing_val_omp
+       ! 
+       ! Now we activate some double radiation call flags only if some
+       ! diagnostics are requested, otherwise there is no point in doing this
+       IF (is_master) THEN
+         !--setting up swaero_diag to TRUE in XIOS case 
+         IF (xios_field_is_active("topswad").OR.xios_field_is_active("topswad0").OR. & 
+            xios_field_is_active("solswad").OR.xios_field_is_active("solswad0").OR. & 
+            xios_field_is_active("topswai").OR.xios_field_is_active("solswai").OR.  & 
+              (iflag_rrtm==1.AND.(xios_field_is_active("toplwad").OR.xios_field_is_active("toplwad0").OR. & 
+                                  xios_field_is_active("sollwad").OR.xios_field_is_active("sollwad0"))))  & 
+            !!!--for now these fields are not in the XML files so they are omitted 
+            !!!  xios_field_is_active("toplwai").OR.xios_field_is_active("sollwai") !))) & 
+            swaero_diag=.TRUE. 
+ 
+         !--setting up swaerofree_diag to TRUE in XIOS case 
+         IF (xios_field_is_active("SWdnSFCcleanclr").OR.xios_field_is_active("SWupSFCcleanclr").OR. &
+            xios_field_is_active("SWupTOAcleanclr").OR.xios_field_is_active("rsucsaf").OR.   &
+            xios_field_is_active("rsdcsaf") .OR. xios_field_is_active("LWdnSFCcleanclr").OR. &
+            xios_field_is_active("LWupTOAcleanclr")) &
+            swaerofree_diag=.TRUE. 
+ 
+         !--setting up dryaod_diag to TRUE in XIOS case 
+         DO naero = 1, naero_tot-1
+          IF (xios_field_is_active("dryod550_"//name_aero_tau(naero))) dryaod_diag=.TRUE. 
+         ENDDO
+         !
+         !--setting up ok_4xCO2atm to TRUE in XIOS case 
+         IF (xios_field_is_active("rsut4co2").OR.xios_field_is_active("rlut4co2").OR. & 
+            xios_field_is_active("rsutcs4co2").OR.xios_field_is_active("rlutcs4co2").OR. &
+            xios_field_is_active("rsu4co2").OR.xios_field_is_active("rsucs4co2").OR. &
+            xios_field_is_active("rsd4co2").OR.xios_field_is_active("rsdcs4co2").OR. &
+            xios_field_is_active("rlu4co2").OR.xios_field_is_active("rlucs4co2").OR. &
+            xios_field_is_active("rld4co2").OR.xios_field_is_active("rldcs4co2")) &
+            ok_4xCO2atm=.TRUE. 
+       ENDIF
+       !$OMP BARRIER
+       CALL bcast(swaero_diag)
+       CALL bcast(swaerofree_diag)
+       CALL bcast(dryaod_diag)
+       CALL bcast(ok_4xCO2atm)
 #endif 
-
-
+       !
        CALL printflag( tabcntr0,radpas,ok_journe, &
             ok_instan, ok_region )
        !
        !
-       !
        ! Prescrire l'ozone dans l'atmosphere
-       !
        !
        !c         DO i = 1, klon
@@ -2150,4 +2195,5 @@
 #endif
        ENDIF
+       !
        IF (type_trac == 'repr') THEN
 #ifdef REPROBUS
@@ -2198,6 +2244,4 @@
           SFRWL(6)=3.02191470E-02
        END SELECT
-
-
        !albedo SB <<<
 
@@ -2331,5 +2375,4 @@
       ! RomP <<<
     ENDIF
-
     !
     ! Ne pas affecter les valeurs entrees de u, v, h, et q
@@ -2408,17 +2451,10 @@
 
     tke0(:,:)=pbl_tke(:,:,is_ave)
-    !C Risi:Nombre de traceurs de l'eau: nqo
-    !  IF (nqtot.GE.3) THEN
-    IF (nqtot.GE.(nqo+1)) THEN
-       !     DO iq = 3, nqtot        
-!       DO iq = nqo+1, nqtot  
-       ! CR: on modifie directement le code ici.
-       ! les isotopes ne sont pas dispatchés dans tr_seri, il faut les enlever.
-       ! on a prévu pour ça un tableau d'indice dans infotrac
-#ifdef ISOVERIF
-       write(*,*) 'physiq 1971: nqtottr=',nqtottr
-#endif
-       do itr=1,nqtottr
-         iq=itr_indice(itr)
+    IF (nqtot > nqo) THEN
+       ! water isotopes are not included in tr_seri
+       itr = 0
+       DO iq = 1, nqtot
+         IF(tracers(iq)%isH2Ofamily) CYCLE
+         itr = itr+1
 !#ifdef ISOVERIF
 !         write(*,*) 'physiq 1973: itr,iq=',itr,iq
@@ -2427,17 +2463,13 @@
          DO  k = 1, klev
              DO  i = 1, klon
-                tr_seri(i,k,itr) = qx(i,k,iq) ! modif C Risi
+                tr_seri(i,k,itr) = qx(i,k,iq)
              ENDDO
-          ENDDO !DO  k = 1, klev
-          !write(*,*) 'physiq 1980'
-       enddo !do itr=1,nqtottr
-
-    ELSE !IF (nqtot.GE.(nqo+1)) THEN
-       DO k = 1, klev
-          DO i = 1, klon
-             tr_seri(i,k,1) = 0.0
           ENDDO
        ENDDO
-    ENDIF !IF (nqtot.GE.(nqo+1)) THEN
+    ELSE
+! DC: make sure the final "1" index was meant for 1st H2O phase (vapor) !!!
+!       tr_seri(:,:,strIdx(tracers(:)%name,'H2O'//phases_sep//'g')) = 0.0
+       tr_seri(:,:,strIdx(tracers(:)%name,'H2Ov')) = 0.0
+    ENDIF
 !
 ! Temporary solutions adressing ticket #104 and the non initialisation of tr_ancien
@@ -2445,9 +2477,8 @@
     IF (debut) THEN
       WRITE(lunout,*)' WARNING: tr_ancien initialised to tr_seri'
-!      DO iq = nqo+1, nqtot
-!           tr_ancien(:,:,iq-nqo)=tr_seri(:,:,iq-nqo)
-!      ENDDO
-       ! modif CRisi:
-       do itr=1,nqtottr
+       itr = 0
+       do iq = 1, nqtot
+         IF(tracers(iq)%isH2Ofamily) CYCLE
+         itr = itr+1
          tr_ancien(:,:,itr)=tr_seri(:,:,itr)       
        enddo
@@ -2519,10 +2550,5 @@
        d_qs_dyn2d(:)=(zx_tmp_fi2d(:)-prsw_ancien(:))/phys_tstep
        ! !! RomP >>>   td dyn traceur
-       IF (nqtot.GT.nqo) THEN     ! jyg
-!          DO iq = nqo+1, nqtot      ! jyg
-          DO itr=1,nqtottr      ! C Risi modif directe
-              d_tr_dyn(:,:,itr)=(tr_seri(:,:,itr)-tr_ancien(:,:,itr))/phys_tstep ! jyg
-          ENDDO
-       ENDIF
+       IF (nqtot > nqo) d_tr_dyn(:,:,:)=(tr_seri(:,:,:)-tr_ancien(:,:,:))/phys_tstep
        ! !! RomP <<<
 
@@ -2627,12 +2653,5 @@
 
        ! !! RomP >>>   td dyn traceur
-       IF (nqtot.GT.nqo) THEN                                       ! jyg
-!          DO iq = nqo+1, nqtot                                      ! jyg
-!              d_tr_dyn(:,:,iq-nqo)= 0.0                             ! jyg
-! Modif C Risi:
-          DO itr=1,nqtottr
-                d_tr_dyn(:,:,itr)= 0.0
-          ENDDO
-       ENDIF
+       IF (nqtot > nqo) d_tr_dyn(:,:,:)= 0.0
        ! !! RomP <<<
        ancien_ok = .TRUE.
@@ -3363,5 +3382,5 @@
             ENDDO
          ENDDO
-       ELSE !IF (iflag_wake>=1) THEN
+       ELSE
                 t_w(:,:) = t_seri(:,:)
                 q_w(:,:) = q_seri(:,:)
@@ -3752,10 +3771,9 @@
           ! où i n'est pas un point convectif et donc ibas_con(i)=0
           ! c'est un pb indépendant des isotopes
-          if (ibas_con(i).gt.0) then
-            ema_pcb(i)  = paprs(i,ibas_con(i))
-          else ! if (ibas_con(i).gt.0) then
-              ema_pcb(i)  = 0.0
-          endif ! if (ibas_con(i).gt.0) then
-
+          if (ibas_con(i) > 0) then
+             ema_pcb(i)  = paprs(i,ibas_con(i))
+          else
+             ema_pcb(i)  = 0.0
+          endif
        ENDDO
        DO i = 1, klon
@@ -4484,5 +4502,5 @@
     ENDDO
 
-   CALL  calcratqs(klon,klev,prt_level,lunout,        &
+    CALL  calcratqs(klon,klev,prt_level,lunout,        &
          iflag_ratqs,iflag_con,iflag_cld_th,pdtphys,  &
          ratqsbas,ratqshaut,ratqsp0, ratqsdp, &
@@ -4492,5 +4510,4 @@
          pbl_tke(:,:,is_ave),tke_dissip_ave,l_mix_ave,wprime_ave,t2m,q2m,fm_therm, &
          ratqs,ratqsc,ratqs_inter)
-
 
     !
@@ -5608,5 +5625,5 @@
                      ZLWFT0_i, ZFLDN0, ZFLUP0, &
                      ZSWFT0_i, ZFSDN0, ZFSUP0)
-          endif !ok_4xCO2atm
+          ENDIF !ok_4xCO2atm
        ENDIF ! aerosol_couple
        itaprad = 0
@@ -6485,20 +6502,15 @@
 #endif
 ! #ifdef ISO
-    !
-    !CR: nb de traceurs eau: nqo
-    !  IF (nqtot.GE.3) THEN
-    IF (nqtot.GE.(nqo+1)) THEN
-       !     DO iq = 3, nqtot
-!       DO iq = nqo+1, nqtot ! modif C Risi
-        do itr=1,nqtottr
-         iq=itr_indice(itr)
-          DO  k = 1, klev
-             DO  i = 1, klon
-                ! d_qx(i,k,iq) = ( tr_seri(i,k,iq-2) - qx(i,k,iq) ) / phys_tstep
-                d_qx(i,k,iq) = ( tr_seri(i,k,iq-nqo) - 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(tracers(iq)%isH2Ofamily) 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 ! !do itr=1,nqtottr
-    ENDIF
+       ENDDO
+    ENDDO
     !
     !IM rajout diagnostiques bilan KP pour analyse MJO par Jun-Ichi Yano
@@ -6558,11 +6570,5 @@
     CALL water_int(klon,klev,qs_ancien,zmasse,prsw_ancien)
     ! !! RomP >>>
-    !CR: nb de traceurs eau: nqo
-    IF (nqtot.GT.nqo) THEN
-       ! DO iq = nqo+1, nqtot ! modif C Risi
-       do itr=1,nqtottr
-          tr_ancien(:,:,itr) = tr_seri(:,:,itr)
-       ENDDO
-    ENDIF
+    IF (nqtot > nqo) tr_ancien(:,:,:) = tr_seri(:,:,:)
     ! !! RomP <<<
     !==========================================================================
@@ -6795,4 +6801,7 @@
 ! ISO
 
+    ! Disabling calls to the prt_alerte function
+    alert_first_call = .FALSE.
+    
     IF (lafin) THEN
        itau_phy = itau_phy + itap
