Index: /LMDZ6/trunk/libf/phylmd/phys_local_var_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/phys_local_var_mod.F90	(revision 5055)
+++ /LMDZ6/trunk/libf/phylmd/phys_local_var_mod.F90	(revision 5056)
@@ -14,4 +14,8 @@
       REAL, SAVE, ALLOCATABLE :: ql_seri(:,:),qs_seri(:,:)
       !$OMP THREADPRIVATE(ql_seri,qs_seri)
+! SN 15/07/2024 ISO 4D
+      REAL, SAVE, ALLOCATABLE :: qx_seri(:,:,:)
+      !$OMP THREADPRIVATE(qx_seri)
+! SN
       REAL, SAVE, ALLOCATABLE :: qbs_seri(:,:)
       !$OMP THREADPRIVATE(qbs_seri)
@@ -66,4 +70,8 @@
       REAL, SAVE, ALLOCATABLE :: d_t_eva(:,:),d_q_eva(:,:),d_ql_eva(:,:),d_qi_eva(:,:)
       !$OMP THREADPRIVATE(d_t_eva,d_q_eva,d_ql_eva,d_qi_eva)
+! SN 15/07/2024 ISO 4D
+      REAL, SAVE, ALLOCATABLE :: d_qx_eva(:,:,:)
+      !$OMP THREADPRIVATE(d_qx_eva)
+! SN
       REAL, SAVE, ALLOCATABLE :: d_t_lscst(:,:),d_q_lscst(:,:)
       !$OMP THREADPRIVATE(d_t_lscst,d_q_lscst)
@@ -119,4 +127,48 @@
       REAL, SAVE, ALLOCATABLE :: d_q_ch4(:,:)
       !$OMP THREADPRIVATE(d_q_ch4)
+#ifdef ISO
+      REAL, SAVE, ALLOCATABLE :: xt_seri(:,:,:)
+      !$OMP THREADPRIVATE( xt_seri)
+      REAL, SAVE, ALLOCATABLE :: xtl_seri(:,:,:)
+      !$OMP THREADPRIVATE( xtl_seri)
+      REAL, SAVE, ALLOCATABLE :: xts_seri(:,:,:)
+      !$OMP THREADPRIVATE( xts_seri)
+      REAL, SAVE, ALLOCATABLE :: xtbs_seri(:,:,:)
+      !$OMP THREADPRIVATE( xtbs_seri)
+      REAL, SAVE, ALLOCATABLE :: d_xt_eva(:,:,:)
+      !$OMP THREADPRIVATE( d_xt_eva)
+      REAL, SAVE, ALLOCATABLE :: d_xtl_eva(:,:,:)
+      !$OMP THREADPRIVATE( d_xtl_eva)
+      REAL, SAVE, ALLOCATABLE :: d_xti_eva(:,:,:)
+      !$OMP THREADPRIVATE( d_xti_eva)
+      REAL, SAVE, ALLOCATABLE :: d_xt_vdf(:,:,:)
+      !$OMP THREADPRIVATE( d_xt_vdf)
+      REAL, SAVE, ALLOCATABLE :: d_xt_dyn(:,:,:)
+      !$OMP THREADPRIVATE( d_xt_dyn)
+      REAL, SAVE, ALLOCATABLE :: d_xtl_dyn(:,:,:), d_xts_dyn(:,:,:), d_xtbs_dyn(:,:,:)
+      !$OMP THREADPRIVATE(d_xtl_dyn, d_xts_dyn, d_xtbs_dyn)
+      REAL, SAVE, ALLOCATABLE :: d_xt_con(:,:,:)
+      !$OMP THREADPRIVATE( d_xt_con)
+      REAL, SAVE, ALLOCATABLE :: d_xt_wake(:,:,:)
+      !$OMP THREADPRIVATE( d_xt_wake)
+      REAL, SAVE, ALLOCATABLE :: d_xt_lsc(:,:,:),d_xtl_lsc(:,:,:),d_xti_lsc(:,:,:)
+      !$OMP THREADPRIVATE( d_xt_lsc,d_xtl_lsc,d_xti_lsc)
+      REAL, SAVE, ALLOCATABLE :: d_xt_ajsb(:,:,:)
+      !$OMP THREADPRIVATE( d_xt_ajsb)
+      REAL, SAVE, ALLOCATABLE :: d_xt_ajs(:,:,:)
+      !$OMP THREADPRIVATE( d_xt_ajs)
+      REAL, SAVE, ALLOCATABLE :: d_xt_ajs_w(:,:,:), d_xt_ajs_x(:,:,:)
+      !$OMP THREADPRIVATE(d_xt_ajs_w, d_xt_ajs_x)
+      REAL, SAVE, ALLOCATABLE :: d_xt_vdf_w(:,:,:), d_xt_vdf_x(:,:,:)
+      !$OMP THREADPRIVATE(d_xt_vdf_w, d_xt_vdf_x)
+      REAL, SAVE, ALLOCATABLE :: d_xt_ch4(:,:,:)
+      !$OMP THREADPRIVATE( d_xt_ch4)
+      REAL, SAVE, ALLOCATABLE :: d_xt_prod_nucl(:,:,:)
+      !$OMP THREADPRIVATE( d_xt_prod_nucl)
+      REAL, SAVE, ALLOCATABLE :: d_xt_cosmo(:,:,:)
+      !$OMP THREADPRIVATE( d_xt_cosmo)
+      REAL, SAVE, ALLOCATABLE :: d_xt_decroiss(:,:,:)
+      !$OMP THREADPRIVATE( d_xt_decroiss)
+#endif
 
 ! tendance du a la conersion Ec -> E thermique
@@ -306,5 +358,17 @@
 !!!OMP THREADPRIVATE(d_s_the, d_dens_the)
       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:)           :: d_deltat_ajs_cv, d_deltaq_ajs_cv
-!$OMP THREADPRIVATE(d_deltat_ajs_cv, d_deltaq_ajs_cv)                       
+!$OMP THREADPRIVATE(d_deltat_ajs_cv, d_deltaq_ajs_cv)
+#ifdef ISO
+    REAL, SAVE, ALLOCATABLE,DIMENSION(:,:,:)          :: d_deltaxt_wk
+!$OMP THREADPRIVATE(d_deltaxt_wk)
+    REAL, SAVE, ALLOCATABLE,DIMENSION(:,:,:)          :: d_deltaxt_wk_gw
+!$OMP THREADPRIVATE(d_deltaxt_wk_gw)
+    REAL, SAVE, ALLOCATABLE,DIMENSION(:,:,:)          ::  d_deltaxt_the
+!$OMP THREADPRIVATE(d_deltaxt_the)
+    REAL, SAVE, ALLOCATABLE,DIMENSION(:,:,:)          ::  d_deltaxt_vdf
+!$OMP THREADPRIVATE(d_deltaxt_vdf)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:)           ::  d_deltaxt_ajs_cv
+!$OMP THREADPRIVATE(d_deltaxt_ajs_cv)
+#endif                       
 !!         End of Wake variables
 !!
@@ -346,4 +410,19 @@
       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zxqsurf, rain_lsc, rain_num
 !$OMP THREADPRIVATE(zxqsurf, rain_lsc, rain_num)
+#ifdef ISO
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: xtevap,xtprw
+!$OMP THREADPRIVATE(xtevap,xtprw)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: h1_diag,runoff_diag
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: xtrunoff_diag
+!$OMP THREADPRIVATE(h1_diag,runoff_diag,xtrunoff_diag)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: zxfxtcalving
+!$OMP THREADPRIVATE(zxfxtcalving)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: xtsnow_lsc, zxfxtfonte
+!$OMP THREADPRIVATE(xtsnow_lsc, zxfxtfonte)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: zxxtrunofflic
+!$OMP THREADPRIVATE(zxxtrunofflic)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: xtrain_lsc
+!$OMP THREADPRIVATE(xtrain_lsc)
+#endif
 !
 !jyg+nrlmd<
@@ -383,4 +462,10 @@
       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: kh, kh_x, kh_w
 !$OMP THREADPRIVATE(kh, kh_x, kh_w)
+#ifdef ISO
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: dxtvdf_x, dxtvdf_w
+!$OMP THREADPRIVATE(dxtvdf_x, dxtvdf_w)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: xt_therm
+!$OMP THREADPRIVATE(xt_therm)
+#endif
 !!!
 !!!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
@@ -445,4 +530,50 @@
       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:):: sij
 !$OMP THREADPRIVATE(sij)
+#ifdef ISO
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:)  :: xtwdtrainA
+!$OMP THREADPRIVATE(xtwdtrainA)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:)  :: xtev
+!$OMP THREADPRIVATE(xtev)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:)  :: xttaa
+!$OMP THREADPRIVATE(xttaa)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:)  :: xtclw
+!$OMP THREADPRIVATE(xtclw)
+#ifdef DIAGISO
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:)  :: qlp
+!$OMP THREADPRIVATE(qlp)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:)  :: qvp
+!$OMP THREADPRIVATE(qvp)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:)  :: fq_detrainement
+!$OMP THREADPRIVATE(fq_detrainement)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:)  :: fq_ddft
+!$OMP THREADPRIVATE(fq_ddft)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:)  :: fq_fluxmasse
+!$OMP THREADPRIVATE(fq_fluxmasse)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:)  :: fq_evapprecip
+!$OMP THREADPRIVATE(fq_evapprecip)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:)  :: f_detrainement
+!$OMP THREADPRIVATE(f_detrainement)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:)  :: q_detrainement
+!$OMP THREADPRIVATE(q_detrainement)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:)  :: xt_detrainement
+!$OMP THREADPRIVATE(xt_detrainement)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:)  :: xtlp
+!$OMP THREADPRIVATE(xtlp)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:)  :: xtvp
+!$OMP THREADPRIVATE(xtvp)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:)  :: q_the
+!$OMP THREADPRIVATE(q_the)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:)  :: xt_the
+!$OMP THREADPRIVATE(xt_the)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:)  :: fxt_detrainement
+!$OMP THREADPRIVATE(fxt_detrainement)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:)  :: fxt_ddft
+!$OMP THREADPRIVATE(fxt_ddft)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:)  :: fxt_fluxmasse
+!$OMP THREADPRIVATE(fxt_fluxmasse)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:)  :: fxt_evapprecip
+!$OMP THREADPRIVATE(fxt_evapprecip)
+#endif
+#endif
 !
 !      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: coefh, coefm, lambda_th
@@ -492,4 +623,12 @@
 !$OMP THREADPRIVATE(zxsnow,snowhgt,qsnow,to_ice)
 !$OMP THREADPRIVATE(sissnow,runoff,albsol3_lic)
+#ifdef ISO
+      REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: zxxtsnow
+!$OMP THREADPRIVATE(zxxtsnow)     
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: xtVprecip,xtVprecipi
+!$OMP THREADPRIVATE(xtVprecip,xtVprecipi) 
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: pxtrfl, pxtsfl
+!$OMP THREADPRIVATE(pxtrfl, pxtsfl) 
+#endif
 
       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: p_tropopause, z_tropopause, t_tropopause
@@ -682,5 +821,8 @@
 SUBROUTINE phys_local_var_init
 USE dimphy
-USE infotrac_phy, ONLY : nbtr
+USE infotrac_phy, ONLY : nbtr,nqtot
+#ifdef ISO
+USE infotrac_phy, ONLY : ntraciso=>ntiso,niso
+#endif
 USE aero_mod
 USE indice_sol_mod
@@ -693,4 +835,7 @@
 IMPLICIT NONE
       ALLOCATE(t_seri(klon,klev),q_seri(klon,klev),ql_seri(klon,klev),qs_seri(klon,klev), qbs_seri(klon,klev))
+! SN 4D ISO
+      ALLOCATE(qx_seri(klon,klev,nqtot))
+! SN
       ALLOCATE(u_seri(klon,klev),v_seri(klon,klev))
       ALLOCATE(l_mixmin(klon,klev+1,nbsrf),l_mix(klon,klev+1,nbsrf),wprime(klon,klev+1,nbsrf))
@@ -722,4 +867,7 @@
       ALLOCATE(d_u_ajs(klon,klev),d_v_ajs(klon,klev))
       ALLOCATE(d_t_eva(klon,klev),d_q_eva(klon,klev))
+! SN 4D ISO
+      ALLOCATE(d_qx_eva(klon,klev,nqtot))
+! SN 
       ALLOCATE(d_ql_eva(klon,klev),d_qi_eva(klon,klev))
       ALLOCATE(d_t_lscst(klon,klev),d_q_lscst(klon,klev))
@@ -731,4 +879,33 @@
       ALLOCATE(d_t_vdf_w(klon,klev),d_q_vdf_w(klon,klev))
       ALLOCATE(d_t_vdf_x(klon,klev),d_q_vdf_x(klon,klev))
+#ifdef ISO
+      allocate(xt_seri(ntraciso,klon,klev))
+      allocate(xtl_seri(ntraciso,klon,klev))
+      allocate(xts_seri(ntraciso,klon,klev))
+      allocate(xtbs_seri(ntraciso,klon,klev))
+      allocate(d_xt_dyn(ntraciso,klon,klev))
+      allocate(d_xtl_dyn(ntraciso,klon,klev))
+      allocate(d_xts_dyn(ntraciso,klon,klev))
+      allocate(d_xtbs_dyn(ntraciso,klon,klev))
+      allocate(d_xt_con(ntraciso,klon,klev))
+      allocate(d_xt_wake(ntraciso,klon,klev))
+      allocate(d_xt_lsc(ntraciso,klon,klev))
+      allocate(d_xtl_lsc(ntraciso,klon,klev))
+      allocate(d_xti_lsc(ntraciso,klon,klev))
+      allocate(d_xt_ajsb(ntraciso,klon,klev))
+      allocate(d_xt_ajs(ntraciso,klon,klev))
+      allocate(d_xt_ajs_w(ntraciso,klon,klev))
+      allocate(d_xt_ajs_x(ntraciso,klon,klev))
+      allocate(d_xt_eva(ntraciso,klon,klev))
+      allocate(d_xtl_eva(ntraciso,klon,klev))
+      allocate(d_xti_eva(ntraciso,klon,klev))
+      allocate(d_xt_vdf(ntraciso,klon,klev))  
+      allocate(d_xt_vdf_w(ntraciso,klon,klev))
+      allocate(d_xt_vdf_x(ntraciso,klon,klev))
+      allocate(d_xt_ch4(ntraciso,klon,klev))
+      allocate(d_xt_prod_nucl(ntraciso,klon,klev))
+      allocate(d_xt_cosmo(ntraciso,klon,klev))
+      allocate(d_xt_decroiss(ntraciso,klon,klev))
+#endif
 
       ALLOCATE(d_u_vdf(klon,klev),d_v_vdf(klon,klev))
@@ -849,4 +1026,11 @@
 !!      ALLOCATE( d_s_the(klon), d_dens_the(klon))
       ALLOCATE(d_deltat_ajs_cv(klon, klev), d_deltaq_ajs_cv(klon, klev))
+#ifdef ISO
+      ALLOCATE(d_deltaxt_wk(ntraciso,klon, klev))
+      ALLOCATE(d_deltaxt_wk_gw(ntraciso,klon, klev))
+      ALLOCATE(d_deltaxt_the(ntraciso,klon, klev))
+      ALLOCATE(d_deltaxt_vdf(ntraciso,klon, klev))
+      ALLOCATE(d_deltaxt_ajs_cv(ntraciso,klon, klev))
+#endif
 !!         End of wake variables
 !!
@@ -877,4 +1061,17 @@
       ALLOCATE(qlth(klon,klev), qith(klon,klev), qsith(klon,klev), wiceth(klon,klev))
       !
+#ifdef ISO
+      ALLOCATE(xtevap(ntraciso,klon))
+      ALLOCATE(xtprw(ntraciso,klon))
+      ALLOCATE(zxfxtcalving(niso,klon))
+      ALLOCATE(xtsnow_lsc(ntraciso,klon), zxfxtfonte(niso,klon)) 
+      ALLOCATE(zxxtrunofflic(niso,klon)) 
+      ALLOCATE(xtrain_lsc(ntraciso,klon))
+      ALLOCATE(xtrunoff_diag(niso,klon))
+      ALLOCATE(h1_diag(klon),runoff_diag(klon))
+!SN
+      runoff_diag(:)=0. ; xtrunoff_diag(:,:)=0. ! because variables are only given values on knon grid points
+#endif
+!
       ALLOCATE(sens_x(klon), sens_w(klon))
       ALLOCATE(zxfluxlat_x(klon), zxfluxlat_w(klon))
@@ -893,4 +1090,8 @@
       ALLOCATE(cdragm_x(klon), cdragm_w(klon))
       ALLOCATE(kh(klon), kh_x(klon), kh_w(klon))
+#ifdef ISO
+      ALLOCATE(dxtvdf_x(ntraciso,klon,klev), dxtvdf_w(ntraciso,klon,klev))
+      ALLOCATE(xt_therm(ntraciso,klon,klev))
+#endif
 !
       ALLOCATE(ptconv(klon,klev))
@@ -948,4 +1149,27 @@
       ALLOCATE(epmlmMm(klon,klev,klev), eplaMm(klon,klev))
       ALLOCATE(sij(klon,klev,klev))
+#ifdef ISO
+      ALLOCATE(xtwdtrainA(ntraciso,klon,klev))
+      ALLOCATE(xtev(ntraciso,klon,klev) )
+      ALLOCATE(xttaa(ntraciso,klon,klev) )
+      ALLOCATE(xtclw(ntraciso,klon,klev) )
+#ifdef DIAGISO
+      ALLOCATE(qlp(klon,klev))
+      ALLOCATE(qvp(klon,klev))
+      ALLOCATE(fq_detrainement(klon,klev))
+      ALLOCATE(fq_ddft(klon,klev))
+      ALLOCATE(fq_fluxmasse(klon,klev))
+      ALLOCATE(fq_evapprecip(klon,klev))
+      ALLOCATE(f_detrainement(klon,klev), q_detrainement(klon,klev))
+      ALLOCATE(xtlp(ntraciso,klon,klev))
+      ALLOCATE(xtvp(ntraciso,klon,klev))
+      ALLOCATE(q_the(klon,klev), xt_the(ntraciso,klon,klev))
+      ALLOCATE(fxt_detrainement(ntraciso,klon,klev))
+      ALLOCATE(fxt_ddft(ntraciso,klon,klev))
+      ALLOCATE(fxt_fluxmasse(ntraciso,klon,klev))
+      ALLOCATE(fxt_evapprecip(ntraciso,klon,klev))
+      ALLOCATE(xt_detrainement(ntraciso,klon,klev))
+#endif
+#endif
 
       ALLOCATE(prfl(klon, klev+1))
@@ -976,4 +1200,9 @@
       ALLOCATE (zxsnow(klon),snowhgt(klon),qsnow(klon),to_ice(klon))
       ALLOCATE (sissnow(klon),runoff(klon),albsol3_lic(klon))
+#ifdef ISO
+      ALLOCATE (zxxtsnow(niso,klon))
+      ALLOCATE(xtVprecip(ntraciso,klon, klev+1),xtVprecipi(ntraciso,klon, klev+1))
+      ALLOCATE(pxtsfl(ntraciso,klon, klev+1),pxtrfl(ntraciso,klon, klev+1))
+#endif
 
       ALLOCATE (p_tropopause(klon))
@@ -1057,4 +1286,7 @@
 IMPLICIT NONE
       DEALLOCATE(t_seri,q_seri,ql_seri,qs_seri, qbs_seri)
+! SN 4D ISO
+      DEALLOCATE(qx_seri)
+! SN
       DEALLOCATE(u_seri,v_seri)
       DEALLOCATE(l_mixmin,l_mix,wprime)
@@ -1083,4 +1315,7 @@
       DEALLOCATE(d_u_ajs,d_v_ajs)
       DEALLOCATE(d_t_eva,d_q_eva)
+! SN 4D ISO
+      DEALLOCATE(d_qx_eva)
+! SN
       DEALLOCATE(d_ql_eva,d_qi_eva)
       DEALLOCATE(d_t_lscst,d_q_lscst)
@@ -1090,4 +1325,26 @@
       DEALLOCATE(d_qbs_vdf)
       DEALLOCATE(d_t_bsss,d_q_bsss,d_qbs_bsss)
+#ifdef ISO
+      deallocate(xt_seri,xtl_seri,xts_seri,xtbs_seri)
+      DEALLOCATE(d_xtl_eva,d_xti_eva)
+      deallocate(d_xt_dyn,d_xtl_dyn,d_xts_dyn,d_xtbs_dyn)
+      deallocate(d_xt_con)
+      deallocate(d_xt_wake)
+      deallocate(d_xt_lsc)
+      deallocate(d_xtl_lsc,d_xti_lsc)
+      deallocate(d_xt_ajsb)
+      deallocate(d_xt_ajs)
+      deallocate(d_xt_ajs_w,d_xt_ajs_x)
+      deallocate(d_xt_eva)
+      deallocate(d_xtl_eva)
+      deallocate(d_xti_eva)
+      deallocate(d_xt_vdf)
+      deallocate(d_xt_vdf_w,d_xt_vdf_x)
+      deallocate(d_xt_ch4)
+      deallocate(d_xt_prod_nucl)
+      deallocate(d_xt_cosmo)
+      deallocate(d_xt_decroiss)
+#endif
+
       DEALLOCATE(d_u_vdf,d_v_vdf)
       DEALLOCATE(d_t_oli,d_t_oro)
@@ -1193,4 +1450,10 @@
 !!      DEALLOCATE( d_s_the, d_dens_the)
       DEALLOCATE(d_deltat_ajs_cv, d_deltaq_ajs_cv)
+#ifdef ISO
+      DEALLOCATE(d_deltaxt_wk)
+      DEALLOCATE(d_deltaxt_wk_gw)
+      DEALLOCATE(d_deltaxt_ajs_cv)
+      DEALLOCATE(d_deltaxt_vdf)
+#endif
 !
       DEALLOCATE(bils)
@@ -1232,4 +1495,14 @@
       DEALLOCATE(cdragm_x, cdragm_w)
       DEALLOCATE(kh, kh_x, kh_w)
+#ifdef ISO
+      DEALLOCATE(xtevap,xtprw)
+      DEALLOCATE(zxfxtcalving)
+      DEALLOCATE(zxxtrunofflic)
+      DEALLOCATE(xtsnow_lsc, zxfxtfonte)
+      DEALLOCATE(xtrain_lsc)
+      DEALLOCATE(dxtvdf_x, dxtvdf_w)
+      DEALLOCATE(xt_therm)
+      DEALLOCATE(h1_diag,runoff_diag,xtrunoff_diag)
+#endif
 !
       DEALLOCATE(ptconv)
@@ -1281,4 +1554,27 @@
       DEALLOCATE(epmlmMm, eplaMm)
       DEALLOCATE(sij)
+#ifdef ISO
+      DEALLOCATE(xtwdtrainA)
+      DEALLOCATE(xttaa )
+      DEALLOCATE(xtclw )
+      DEALLOCATE(xtev )
+#ifdef DIAGISO
+      DEALLOCATE(qlp)
+      DEALLOCATE(qvp)
+      DEALLOCATE(fq_detrainement)
+      DEALLOCATE(fq_ddft)
+      DEALLOCATE(fq_fluxmasse)
+      DEALLOCATE(fq_evapprecip)
+      DEALLOCATE(f_detrainement,q_detrainement)
+      DEALLOCATE(xtlp)
+      DEALLOCATE(xtvp)
+      DEALLOCATE(q_the,xt_the)
+      DEALLOCATE(fxt_detrainement)
+      DEALLOCATE(fxt_ddft)
+      DEALLOCATE(fxt_fluxmasse)
+      DEALLOCATE(fxt_evapprecip)
+      DEALLOCATE(xt_detrainement)
+#endif
+#endif
 
 
@@ -1303,4 +1599,8 @@
       DEALLOCATE(distcltop)
       DEALLOCATE(temp_cltop)
+#ifdef ISO
+      DEALLOCATE (zxxtsnow,xtVprecip,xtVprecipi,pxtrfl,pxtsfl)
+#endif
+
       DEALLOCATE (p_tropopause)
       DEALLOCATE (z_tropopause)
Index: /LMDZ6/trunk/libf/phylmd/phys_output_ctrlout_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 5055)
+++ /LMDZ6/trunk/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 5056)
@@ -2003,4 +2003,28 @@
   TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_dry(:)
 
+#ifdef ISO
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_xtprecip(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_xtevap(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_xtevap_srf(:,:) ! ajout Camille 8 mai 2023
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_xtplul(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_xtpluc(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_xtovap(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_xtoliq(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_xtcond(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_xtrunoff_diag(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dxtdyn(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dxtldyn(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dxtvdf(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dxtcon(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dxtlsc(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dxteva(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dxtajs(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dxtthe(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dxtch4(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dxtprod_nucl(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dxtcosmo(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dxtdecroiss(:)
+#endif
+
   TYPE(ctrl_out), SAVE :: o_rsu = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11, 11/), &
     'rsu', 'SW upward radiation', 'W m-2', (/ ('', i=1, 10) /))
@@ -2086,4 +2110,8 @@
   TYPE(ctrl_out), SAVE :: o_runoff = ctrl_out((/ 1, 1, 10, 1, 10, 10, 11, 11, 11, 11/), &
     'runoff', 'Run-off rate land ice', 'kg/m2/s', (/ ('', i=1, 10) /))
+#ifdef ISO
+  TYPE(ctrl_out), SAVE :: o_runoff_diag = ctrl_out((/ 1, 1, 10, 1, 10, 10, 11, 11, 11, 11/), &
+    'runoffland', 'Run-off rate land for bucket', 'kg/m2/s', (/ ('', i=1, 10) /))
+#endif
   TYPE(ctrl_out), SAVE :: o_albslw3 = ctrl_out((/ 1, 1, 1, 1, 10, 10, 11, 11, 11, 11/), &
     'albslw3', 'Surface albedo LW3', '-', (/ ('', i=1, 10) /))
Index: /LMDZ6/trunk/libf/phylmd/phys_output_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/phys_output_mod.F90	(revision 5055)
+++ /LMDZ6/trunk/libf/phylmd/phys_output_mod.F90	(revision 5056)
@@ -35,5 +35,5 @@
     USE iophy 
     USE dimphy
-    USE infotrac_phy, ONLY: nqtot, tracers, niso
+    USE infotrac_phy, ONLY: nqtot, tracers, niso, ntraciso=>ntiso
     USE strings_mod,  ONLY: maxlen
     USE ioipsl
@@ -52,5 +52,11 @@
    USE infotrac_phy, ONLY: nbtr_bin
 #endif
-   
+#ifdef ISO
+    USE isotopes_mod, ONLY: isoName,iso_HTO
+#ifdef ISOTRAC
+    use isotrac_mod, only: index_zone,index_iso,strtrac
+#endif
+#endif
+
     IMPLICIT NONE
     include "clesphys.h"
@@ -115,4 +121,8 @@
     LOGICAL, DIMENSION(nfiles)            :: phys_out_filestations
 
+#ifdef ISO
+    CHARACTER(LEN=maxlen) :: outiso
+    CHARACTER(LEN=20) :: unit
+#endif
     CHARACTER(LEN=maxlen) :: tnam, lnam, dn
     INTEGER :: flag(nfiles)
@@ -164,5 +174,30 @@
     ALLOCATE(o_nd_mode(nbtr_bin),o_sulfmmr_mode(nbtr_bin))
 #endif
-    
+#ifdef ISO
+    ALLOCATE(o_xtprecip(ntraciso))
+    ALLOCATE(o_xtplul(ntraciso))
+    ALLOCATE(o_xtpluc(ntraciso))
+    ALLOCATE(o_xtevap(ntraciso))
+    ALLOCATE(o_xtevap_srf(ntraciso,4))
+    ALLOCATE(o_xtovap(ntraciso))
+    ALLOCATE(o_xtoliq(ntraciso))
+    ALLOCATE(o_xtcond(ntraciso))
+    ALLOCATE(o_xtrunoff_diag(ntraciso))
+    ALLOCATE(o_dxtdyn(ntraciso))
+    ALLOCATE(o_dxtldyn(ntraciso))
+    ALLOCATE(o_dxtcon(ntraciso))
+    ALLOCATE(o_dxtlsc(ntraciso))
+    ALLOCATE(o_dxteva(ntraciso))
+    ALLOCATE(o_dxtajs(ntraciso))
+    ALLOCATE(o_dxtvdf(ntraciso))
+    ALLOCATE(o_dxtthe(ntraciso))
+    ALLOCATE(o_dxtch4(ntraciso))
+    if (iso_HTO.gt.0) then
+      ALLOCATE(o_dxtprod_nucl(ntraciso))
+      ALLOCATE(o_dxtcosmo(ntraciso))
+      ALLOCATE(o_dxtdecroiss(ntraciso))
+    endif
+#endif
+
     levmax = [klev, klev, klev, klev, klev, klev, nlevSTD, nlevSTD, nlevSTD, klev]
 
@@ -524,5 +559,59 @@
    ENDDO !  iff
 
-    ! Updated write frequencies due to phys_out_filetimesteps. 
+#ifdef ISO
+    write(*,*) 'phys_output_mid 589'
+    do ixt=1,ntraciso
+      outiso = TRIM(isoName(ixt))
+      i = INDEX(outiso, '_', .TRUE.)
+      outiso = outiso(1:i-1)//outiso(i+1:LEN_TRIM(outiso))
+
+      flag = [1,  1,  1, 10,  5, 10, 11, 11, 11, 11]; unit = 'kg/(s*m2)'
+      o_xtprecip(ixt)=ctrl_out(flag, 'precip'//TRIM(outiso), 'Precip Totale liq+sol', unit, [('',i=1,nfiles)])
+      o_xtpluc  (ixt)=ctrl_out(flag,   'pluc'//TRIM(outiso),    'Convective Precip.', unit, [('',i=1,nfiles)])
+
+      flag = [1,  1,  1, 10, 10, 10, 11, 11, 11, 11]
+      o_xtplul  (ixt)=ctrl_out(flag,   'plul'//TRIM(outiso),   'Large-scale Precip.', unit, [('',i=1,nfiles)])
+      o_xtevap  (ixt)=ctrl_out(flag,   'evap'//TRIM(outiso),             'Evaporat.', unit, [('',i=1,nfiles)])
+
+      ! ajout Camille 8 mai 2023
+      flag = [1, 6, 10, 10, 10, 10, 11, 11, 11, 11]
+      o_xtevap_srf (ixt,1)=ctrl_out(flag,   'evap_ter'//TRIM(outiso), 'Evap sfc'//clnsurf(1), unit, [('',i=1,nfiles)])
+      o_xtevap_srf (ixt,2)=ctrl_out(flag,   'evap_lic'//TRIM(outiso), 'Evap sfc'//clnsurf(2), unit, [('',i=1,nfiles)])
+      o_xtevap_srf (ixt,3)=ctrl_out(flag,   'evap_oce'//TRIM(outiso), 'Evap sfc'//clnsurf(3), unit, [('',i=1,nfiles)])
+      o_xtevap_srf (ixt,4)=ctrl_out(flag,   'evap_sic'//TRIM(outiso), 'Evap sfc'//clnsurf(4), unit, [('',i=1,nfiles)])
+
+      flag = [2,  3,  4, 10, 10, 10, 11, 11, 11, 11]; unit = 'kg/kg'
+      o_xtovap  (ixt)=ctrl_out(flag,   'ovap'//TRIM(outiso),     'Specific humidity', unit, [('',i=1,nfiles)])
+      o_xtoliq  (ixt)=ctrl_out(flag,   'oliq'//TRIM(outiso),          'Liquid water', unit, [('',i=1,nfiles)])
+      o_xtcond  (ixt)=ctrl_out(flag,  'ocond'//TRIM(outiso),       'Condensed water', unit, [('',i=1,nfiles)])
+
+      flag = [1,  1,  1, 10, 5, 10, 11, 11, 11, 11]; unit = 'kg/m2/s'
+      o_xtrunoff_diag  (ixt)=ctrl_out(flag, 'runoffland'//TRIM(outiso), 'Run-off rate land for bucket', unit, [('',i=1,nfiles)])
+
+      flag = [4, 10, 10, 10, 10, 10, 11, 11, 11, 11]; unit = '(kg/kg)/s'
+      o_dxtdyn  (ixt)=ctrl_out(flag,  'dqdyn'//TRIM(outiso),           'Dynamics dQ', unit, [('',i=1,nfiles)])
+      o_dxtldyn (ixt)=ctrl_out(flag, 'dqldyn'//TRIM(outiso),          'Dynamics dQL', unit, [('',i=1,nfiles)])
+      o_dxtcon  (ixt)=ctrl_out(flag,  'dqcon'//TRIM(outiso),         'Convection dQ', unit, [('',i=1,nfiles)])
+      o_dxteva  (ixt)=ctrl_out(flag,  'dqeva'//TRIM(outiso),      'Reevaporation dQ', unit, [('',i=1,nfiles)])
+      o_dxtlsc  (ixt)=ctrl_out(flag,  'dqlsc'//TRIM(outiso),       'Condensation dQ', unit, [('',i=1,nfiles)])
+      o_dxtajs  (ixt)=ctrl_out(flag,  'dqajs'//TRIM(outiso),        'Dry adjust. dQ', unit, [('',i=1,nfiles)])
+      o_dxtvdf  (ixt)=ctrl_out(flag,  'dqvdf'//TRIM(outiso),     'Boundary-layer dQ', unit, [('',i=1,nfiles)])
+      o_dxtthe  (ixt)=ctrl_out(flag,  'dqthe'//TRIM(outiso),            'Thermal dQ', unit, [('',i=1,nfiles)])
+
+      IF(ok_qch4) o_dxtch4(ixt)=ctrl_out(flag, 'dqch4'//TRIM(outiso), 'H2O due to CH4 oxidation & photolysis', &
+                                                                                      unit, [('',i=1,nfiles)])
+      IF(ixt == iso_HTO) THEN
+      o_dxtprod_nucl(ixt)=ctrl_out(flag, 'dqprodnucl'//TRIM(outiso), 'dHTO/dt due to nuclear production',      &
+                                                                                      unit, [('',i=1,nfiles)])
+      o_dxtcosmo    (ixt)=ctrl_out(flag,    'dqcosmo'//TRIM(outiso), 'dHTO/dt due to cosmogenic production',   &
+                                                                                      unit, [('',i=1,nfiles)])
+      o_dxtdecroiss (ixt)=ctrl_out(flag, 'dqdecroiss'//TRIM(outiso), 'dHTO/dt due to radiative destruction',   &
+                                                                                      unit, [('',i=1,nfiles)])
+      END IF
+    enddo !do ixt=1,niso
+    write(*,*) 'phys_output_mid 596'
+#endif
+
+   ! Updated write frequencies due to phys_out_filetimesteps. 
     ! Write frequencies are now in seconds.  
     ecrit_mth = ecrit_files(1)
