Index: LMDZ6/branches/Amaury_dev/libf/phylmd/phys_local_var_mod.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/phys_local_var_mod.F90	(revision 5128)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/phys_local_var_mod.F90	(revision 5132)
@@ -407,6 +407,7 @@
   REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxfluxlat, zxtsol, snow_lsc, zxfqfonte
   !$OMP THREADPRIVATE(zxfluxlat, zxtsol, snow_lsc, zxfqfonte)
-  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxrunofflic
-  !$OMP THREADPRIVATE(zxrunofflic)
+!SN runoffdiag
+  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxrunofflic, runoff_diag
+  !$OMP THREADPRIVATE(zxrunofflic, runoff_diag)
   REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxqsurf, rain_lsc, rain_num
   !$OMP THREADPRIVATE(zxqsurf, rain_lsc, rain_num)
@@ -414,7 +415,7 @@
       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: xtevap,xtprw
 !$OMP THREADPRIVATE(xtevap,xtprw)
-      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: h1_diag,runoff_diag
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: h1_diag
       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: xtrunoff_diag
-!$OMP THREADPRIVATE(h1_diag,runoff_diag,xtrunoff_diag)
+!$OMP THREADPRIVATE(h1_diagv,xtrunoff_diag)
       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: zxfxtcalving
 !$OMP THREADPRIVATE(zxfxtcalving)
@@ -1046,5 +1047,7 @@
     ALLOCATE(zxfqcalving(klon), zxfluxlat(klon))
     ALLOCATE(zxtsol(klon), snow_lsc(klon), zxfqfonte(klon), zxqsurf(klon))
-    ALLOCATE(zxrunofflic(klon))
+! SN add runoff_diag
+      ALLOCATE(zxrunofflic(klon), runoff_diag(klon))
+      runoff_diag(:)=0.
     ALLOCATE(zxustartlic(klon), zxrhoslic(klon), zxqsaltlic(klon))
     zxustartlic(:) = 0. ; zxrhoslic(:) = 0. ; zxqsaltlic(:) = 0.
@@ -1052,5 +1055,4 @@
     ALLOCATE(rain_num(klon))
     ALLOCATE(qlth(klon, klev), qith(klon, klev), qsith(klon, klev), wiceth(klon, klev))
-
 #ifdef ISO
       ALLOCATE(xtevap(ntraciso,klon))
@@ -1061,7 +1063,7 @@
       ALLOCATE(xtrain_lsc(ntraciso,klon))
       ALLOCATE(xtrunoff_diag(niso,klon))
-      ALLOCATE(h1_diag(klon),runoff_diag(klon))
+      ALLOCATE(h1_diag(klon))
 !SN
-      runoff_diag(:)=0. ; xtrunoff_diag(:,:)=0. ! because variables are only given values on knon grid points
+      xtrunoff_diag(:,:)=0. ! because variables are only given values on knon grid points
 #endif
 
@@ -1467,5 +1469,6 @@
     DEALLOCATE(uwat, vwat)
     DEALLOCATE(zxfqcalving, zxfluxlat)
-    DEALLOCATE(zxrunofflic)
+! SN runoff_diag
+      DEALLOCATE(zxrunofflic, runoff_diag)
     DEALLOCATE(zxustartlic, zxrhoslic, zxqsaltlic)
     DEALLOCATE(zxtsol, snow_lsc, zxfqfonte, zxqsurf)
@@ -1496,5 +1499,5 @@
       DEALLOCATE(dxtvdf_x, dxtvdf_w)
       DEALLOCATE(xt_therm)
-      DEALLOCATE(h1_diag,runoff_diag,xtrunoff_diag)
+      DEALLOCATE(h1_diag,xtrunoff_diag)
 #endif
 
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/phys_output_ctrlout_mod.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 5128)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 5132)
@@ -2108,8 +2108,9 @@
   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
+! SN add runoff_diag
+!#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
+!#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/branches/Amaury_dev/libf/phylmd/phys_output_write_mod.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/phys_output_write_mod.F90	(revision 5128)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/phys_output_write_mod.F90	(revision 5132)
@@ -64,5 +64,6 @@
          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, &
+! SN runoff_diag
+         o_snowhgt, o_toice, o_sissnow, o_runoff, o_runoff_diag, &
          o_albslw3, o_pourc_srf, o_fract_srf, &
          o_taux_srf, o_tauy_srf, o_tsol_srf, &
@@ -207,5 +208,5 @@
 ! Isotopes
          o_xtprecip,o_xtplul,o_xtpluc,o_xtovap,o_xtoliq,o_xtcond, &
-         o_runoff_diag, o_xtrunoff_diag, &
+         o_xtrunoff_diag, &
          o_xtevap,o_dxtdyn,o_dxtldyn,o_dxtcon,o_dxtlsc,o_dxteva, &
          o_dxtajs,o_dxtvdf,o_dxtthe, o_dxtch4, &
@@ -317,5 +318,6 @@
          zxffonte, zxfqcalving, zxfqfonte, zxrunofflic, fluxu, &
          fluxv, zxsnow, qsnow, snowhgt, to_ice, &
-         sissnow, runoff, albsol3_lic, evap_pot, &
+! SN runoff_diag
+         sissnow, runoff, runoff_diag, albsol3_lic, evap_pot, &
          t2m, fluxt, fluxlat, fsollw, fsolsw, &
          wfbils, wfevap, &
@@ -391,5 +393,5 @@
         d_xt_ajs, d_xt_ajsb, &
         d_xt_prod_nucl,d_xt_cosmo,d_xt_decroiss, &
-        runoff_diag, xtrunoff_diag, &
+        xtrunoff_diag, &
 #endif
          ep, epmax_diag, &  ! epmax_cape
@@ -446,5 +448,5 @@
     USE indice_sol_mod, ONLY: nbsrf
 #ifdef ISO
-    USE isotopes_mod, ONLY: iso_HTO
+    USE isotopes_mod, ONLY: iso_HTO, isoName
 #endif
     USE lmdz_geometry, ONLY: cell_area, latitude_deg, longitude_deg
@@ -525,4 +527,9 @@
     LOGICAL, PARAMETER :: debug_strataer=.FALSE.
     CHARACTER(LEN=maxlen) :: unt
+
+#ifdef ISO
+    CHARACTER(LEN=maxlen) :: outiso
+#endif
+
     REAL,DIMENSION(klon,klev) :: z, dz
     REAL,DIMENSION(klon)      :: zrho, zt
@@ -2827,10 +2834,11 @@
        end if
 
+    !! runoff land bucket - ajout S. Nguyen 23 07 2024
+    CALL histwrite_phy(o_runoff_diag, runoff_diag)
+
 #ifdef ISO
     !WRITE(*,*) 'tmp phys_output_write: ntiso=',ntiso
-    !! runoff land bucket - ajout S. Nguyen 25 avril 2024
-    CALL histwrite_phy(o_runoff_diag, runoff_diag)
-
-    do ixt=1,ntiso
+
+    DO ixt = 1, ntiso
         !WRITE(*,*) 'ixt,o_xtovap(ixt)=',ixt,o_xtovap(ixt)
         IF (vars_defined) zx_tmp_fi2d(:) = xtrain_fall(ixt,:) + xtsnow_fall(ixt,:)
@@ -2909,4 +2917,20 @@
           ENDDO !  iff
 #endif
+
+!SN activate water isotopes present in tracer.def
+#ifdef ISO
+          DO ixt = 1, ntiso
+            outiso = TRIM(isoName(ixt))
+            i = INDEX(outiso, '_', .TRUE.)
+            outiso = outiso(1:i-1)//outiso(i+1:LEN_TRIM(outiso))
+            ! dayly
+            CALL xios_set_fieldgroup_attr("dd_2D_"//TRIM(outiso), enabled=.TRUE.)
+            CALL xios_set_fieldgroup_attr("dd_3D_"//TRIM(outiso), enabled=.TRUE.)
+            ! monthly
+            CALL xios_set_fieldgroup_attr("mm_2D_"//TRIM(outiso), enabled=.TRUE.)
+            CALL xios_set_fieldgroup_attr("mm_3D_"//TRIM(outiso), enabled=.TRUE.)
+
+          ENDDO
+#endif
           !On finalise l'initialisation:
           IF (using_xios) CALL wxios_closedef()
