Index: LMDZ6/trunk/libf/phylmd/surf_land_mod.F90
===================================================================
--- LMDZ6/trunk/libf/phylmd/surf_land_mod.F90	(revision 4526)
+++ LMDZ6/trunk/libf/phylmd/surf_land_mod.F90	(revision 5022)
@@ -20,5 +20,11 @@
        qsurf, tsurf_new, dflux_s, dflux_l, &
        flux_u1, flux_v1 , & 
-       veget,lai,height)
+       veget,lai,height &
+#ifdef ISO
+       ,xtprecip_rain, xtprecip_snow,xtspechum, &
+       xtsnow, xtsol,xtevap,h1, &
+       runoff_diag,xtrunoff_diag,Rland_ice &
+#endif               
+               )
 
     USE dimphy
@@ -59,4 +65,12 @@
     USE calcul_fluxs_mod
     USE indice_sol_mod
+#ifdef ISO
+    use infotrac_phy, ONLY: ntiso,niso
+    use isotopes_mod, ONLY: nudge_qsol, iso_eau
+#ifdef ISOVERIF
+    use isotopes_verif_mod
+#endif
+#endif
+
     USE print_control_mod, ONLY: lunout
 
@@ -92,5 +106,8 @@
                                                          ! corresponds to previous sollwdown
     REAL, DIMENSION(klon), INTENT(IN)       :: q2m, t2m
-
+#ifdef ISO
+    REAL, DIMENSION(ntiso,klon), INTENT(IN)       :: xtprecip_rain, xtprecip_snow
+    REAL, DIMENSION(ntiso,klon), INTENT(IN)       :: xtspechum
+#endif 
 ! In/Output variables
 !****************************************************************************************
@@ -98,4 +115,7 @@
     REAL, DIMENSION(klon), INTENT(INOUT)          :: agesno
     REAL, DIMENSION(klon, nsoilmx), INTENT(INOUT) :: tsoil
+#ifdef ISO
+    REAL, DIMENSION(niso,klon), INTENT(INOUT)    :: xtsnow, xtsol
+#endif
 
 ! Output variables
@@ -116,4 +136,11 @@
     REAL, DIMENSION(klon,nvm_lmdz), INTENT(OUT) :: veget,lai
     REAL, DIMENSION(klon,nvm_lmdz), INTENT(OUT) :: height
+#ifdef ISO
+    REAL, DIMENSION(ntiso,klon), INTENT(OUT)      :: xtevap
+    REAL, DIMENSION(klon), INTENT(OUT)      :: h1
+    REAL, DIMENSION(niso,klon), INTENT(OUT)      :: xtrunoff_diag
+    REAL, DIMENSION(klon), INTENT(OUT)      :: runoff_diag
+    REAL, DIMENSION(niso,klon), INTENT(IN)        :: Rland_ice
+#endif
 
 ! Local variables
@@ -132,5 +159,11 @@
 !albedo SB <<<
 
-
+#ifdef ISO       
+      real, parameter :: t_coup = 273.15
+      real, dimension(klon) :: fqfonte_diag
+      real, dimension(klon) :: snow_evap_diag 
+      real, dimension(klon) :: fqcalving_diag 
+      integer :: ixt
+#endif 
 !****************************************************************************************
 !Total solid precip
@@ -142,4 +175,27 @@
 ENDIF
 !****************************************************************************************
+#ifdef ISO
+#ifdef ISOVERIF
+!        write(*,*) 'surf_land_mod 162'
+        do i=1,knon
+          if (iso_eau.gt.0) then
+            call iso_verif_egalite_choix(precip_snow(i), &
+     &          xtprecip_snow(iso_eau,i),'surf_land_mod 129', &
+     &          errmax,errmaxrel)
+            call iso_verif_egalite_choix(qsol(i), &
+     &          xtsol(iso_eau,i),'surf_land_mod 139', &
+     &          errmax,errmaxrel)
+          endif  
+        enddo
+#endif 
+#ifdef ISOVERIF
+!       write(*,*) 'surf_land 169: ok_veget=',ok_veget
+        do i=1,knon
+         do ixt=1,ntiso
+           call iso_verif_noNaN(xtprecip_snow(ixt,i),'surf_land 146')
+         enddo
+        enddo
+#endif
+#endif
 
 
@@ -172,4 +228,7 @@
        END DO
 
+#ifdef ISO
+      CALL abort_gcm('surf_land_mod 220','isos pas prevus dans orchidee',1)
+#endif
        ! temporary for keeping same results using lwdown_m instead of lwdown
        CALL surf_land_orchidee(itime, dtime, date0, knon, &
@@ -183,5 +242,21 @@
             tsol_rad, tsurf_new, alb1_new, alb2_new, &
             emis_new, z0m, z0h, qsurf, &
-            veget, lai, height)       
+            veget, lai, height &
+!#ifdef ISO
+!            , xtprecip_rain, xtprecip_snow, xtspechum, xtevap &
+!#endif
+            )                  
+
+#ifdef ISO
+#ifdef ISOVERIF
+     write(*,*) 'surf_land 193: apres surf_land_orchidee'   
+     do i=1,knon
+        if (iso_eau.gt.0) then
+             call iso_verif_egalite_choix(xtevap(iso_eau,i),evap(i), &
+    &            'surf_land 197',errmax,errmaxrel)
+        endif !if (iso_eau.gt.0) then      
+      enddo !do i=1,knon  
+#endif
+#endif
 !  
 !* Add contribution of relief to surface roughness
@@ -196,4 +271,18 @@
 !
 !****************************************************************************************
+#ifdef ISO
+#ifdef ISOVERIF
+!       write(*,*) 'surf_land 247'
+        call iso_verif_egalite_vect1D( &
+     &           xtsnow,snow,'surf_land_mod 207',niso,klon)
+#endif
+#endif
+
+#ifdef ISO
+        if (nudge_qsol.eq.1) then
+          call surf_land_nudge_qsol(knon,rlat,rlon,qsol,xtsol,knindex)
+        endif
+        !write(*,*) 'surf_land 258'
+#endif
        CALL surf_land_bucket(itime, jour, knon, knindex, debut, dtime,&
             tsurf, p1lay, cdragh, precip_rain, precip_totsnow, temp_air, &
@@ -202,5 +291,11 @@
             snow, qsol, agesno, tsoil, &
             qsurf, z0m, alb1_new, alb2_new, evap, &
-            fluxsens, fluxlat, tsurf_new, dflux_s, dflux_l)
+            fluxsens, fluxlat, tsurf_new, dflux_s, dflux_l &
+#ifdef ISO
+            ,xtprecip_rain, xtprecip_snow,xtspechum, &
+            xtsnow, xtsol,xtevap,h1, &
+     &      runoff_diag, xtrunoff_diag,Rland_ice &
+#endif           
+     &       )
         z0h(1:knon)=z0m(1:knon) ! En attendant mieux
 
@@ -224,4 +319,16 @@
          p1lay, temp_air, &
          flux_u1, flux_v1)
+
+#ifdef ISO
+#ifdef ISOVERIF
+!     write(*,*) 'surf_land 237: sortie'   
+      DO i=1,knon
+        IF (iso_eau >= 0) THEN
+             call iso_verif_egalite_choix(xtsnow(iso_eau,i),snow(i), &
+    &            'surf_land 241',errmax,errmaxrel)
+        ENDIF !if (iso_eau.gt.0) then      
+      ENDDO !do i=1,knon  
+#endif
+#endif
 
 !albedo SB >>>
@@ -248,4 +355,79 @@
     
   END SUBROUTINE surf_land
+
+
+#ifdef ISO
+  SUBROUTINE surf_land_nudge_qsol(knon,rlat,rlon,qsol,xtsol,knindex)
+
+    USE dimphy   
+    USE infotrac_phy, ONLY: niso
+    USE isotopes_mod, ONLY: region_nudge_qsol    
+    INTEGER, INTENT(IN)                       :: knon         
+    REAL, DIMENSION(klon), INTENT(IN)         :: rlon, rlat
+    REAL, DIMENSION(klon), INTENT(INOUT)      :: qsol
+    INTEGER, DIMENSION(klon), INTENT(IN)      :: knindex    
+    REAL, DIMENSION(niso,klon), INTENT(INOUT) :: xtsol 
+    REAL :: lat_min_nudge_qsol,lat_max_nudge_qsol
+    REAL :: lon_min_nudge_qsol,lon_max_nudge_qsol
+    INTEGER :: i,ixt
+    REAL :: qsol_new
+
+    IF (region_nudge_qsol == 1) THEN
+        ! Aamzonie du Sud
+        lat_min_nudge_qsol=-15.0
+        lat_max_nudge_qsol=-5.0
+        lon_min_nudge_qsol=-70.0
+        lon_max_nudge_qsol=-50.0
+    ELSE IF (region_nudge_qsol == 2) THEN
+        ! Aamzonie du Nord
+        lat_min_nudge_qsol=-5.0
+        lat_max_nudge_qsol=5.0
+        lon_min_nudge_qsol=-70.0
+        lon_max_nudge_qsol=-50.0
+    ELSE
+        WRITE(*,*) 'surf_land 298: cas pas prevu'
+        WRITE(*,*) 'region_nudge_qsol=',region_nudge_qsol
+        stop
+    ENDIF
+
+!    write(*,*) 'surf_land 314: knon=',knon
+!    write(*,*) 'rlat=',rlat
+!    write(*,*) 'rlon=',rlon
+!    write(*,*) 'region_nudge_qsol=',region_nudge_qsol
+
+    DO i=1,knon
+      IF ((rlat(knindex(i)) >= lat_min_nudge_qsol).and. &
+  &       (rlat(knindex(i)) <= lat_max_nudge_qsol).and. &
+  &       (rlon(knindex(i)) >= lon_min_nudge_qsol).and. &
+  &       (rlon(knindex(i)) <= lon_max_nudge_qsol)) THEN
+!        write(*,*) 'surf_land 324: bon domaine: rlat,rlon,qsol=', &
+!  &             rlat(knindex(i)),rlon(knindex(i)),qsol(knindex(i))
+        qsol_new=qsol(i)
+        IF (region_nudge_qsol == 1) THEN   
+           qsol_new=max(qsol(i),50.0)   
+        ELSE IF (region_nudge_qsol == 2) THEN      
+           qsol_new=max(qsol(i),120.0)
+        ELSE !if (region_nudge_qsol.eq.1) then
+           WRITE(*,*) 'surf_land 317: cas pas prevu'
+           WRITE(*,*) 'region_nudge_qsol=',region_nudge_qsol
+           STOP
+        ENDIF !if (region_nudge_qsol.eq.1) then
+        IF (qsol(i) > 0.0) THEN
+           DO ixt=1,niso
+              xtsol(ixt,i)=xtsol(ixt,i)*qsol_new/qsol(i)
+           ENDDO
+        ELSE !IF (qsol(i) > 0.0) THEN
+           DO ixt=1,niso
+             xtsol(ixt,i)=0.0
+           ENDDO
+        ENDIF !IF (qsol(i) > 0.0) THEN
+        qsol(i)=qsol_new
+        WRITE(*,*) 'surf_land 346: qsol_new=',qsol(i)      
+     ENDIF ! if ((rlat(i).ge.lat_min_nudge_qsol).and.
+  ENDDO !DO i=1,knon
+
+  END SUBROUTINE surf_land_nudge_qsol
+#endif
+
 !
 !****************************************************************************************
