Index: LMDZ.3.3/branches/rel-LF/libf/dyn3d/create_etat0_limit.F
===================================================================
--- LMDZ.3.3/branches/rel-LF/libf/dyn3d/create_etat0_limit.F	(revision 324)
+++ LMDZ.3.3/branches/rel-LF/libf/dyn3d/create_etat0_limit.F	(revision 325)
@@ -21,7 +21,10 @@
 #include "dimensions.h"
 #include "paramet.h"
+#include "indicesol.h"
+#include "dimphy.h"
       REAL :: masque(iip1,jjp1)
+      REAL :: pctsrf(klon, nbsrf)
 
-      CALL etat0_netcdf ( interbar, masque )
+      CALL etat0_netcdf ( interbar, masque, pctsrf )
 c
       WRITE(6,1)
@@ -31,5 +34,5 @@
       WRITE(6,1)
 c
-      CALL  limit_netcdf ( interbar, extrap , oldice, masque )
+      CALL  limit_netcdf ( interbar, extrap , oldice, masque, pctsrf )
 
 1     FORMAT(//)
Index: LMDZ.3.3/branches/rel-LF/libf/dyn3d/etat0_netcdf.F
===================================================================
--- LMDZ.3.3/branches/rel-LF/libf/dyn3d/etat0_netcdf.F	(revision 324)
+++ LMDZ.3.3/branches/rel-LF/libf/dyn3d/etat0_netcdf.F	(revision 325)
@@ -2,5 +2,5 @@
 c $Header$
 c
-      SUBROUTINE etat0_netcdf (interbar, masque)
+      SUBROUTINE etat0_netcdf (interbar, masque, pctsrf)
     
       USE startvar
@@ -165,5 +165,5 @@
       !
       WRITE(*,*) 'OUT OF GET VARIABLE : Relief'
-      WRITE(*,'(49I1)') INT(orog(:,:))
+!      WRITE(*,'(49I1)') INT(orog(:,:))
       !
       varname = 'rugosite'
@@ -174,5 +174,5 @@
       !
       WRITE(*,*) 'OUT OF GET VARIABLE : Rugosite' 
-      WRITE(*,'(49I1)') INT(rugo(:,:)*10)
+!      WRITE(*,'(49I1)') INT(rugo(:,:)*10)
       !
       varname = 'masque'
@@ -183,5 +183,5 @@
       !
       WRITE(*,*) 'MASQUE construit : Masque'
-      WRITE(*,'(49I1)') INT(masque(:,:))
+!      WRITE(*,'(49I1)') INT(masque(:,:))
       !
       !
@@ -203,5 +203,4 @@
           zmasq(1 : klon) = 1.
       END WHERE 
-      WRITE(*,*)zmasq
 
 
@@ -216,15 +215,15 @@
       !  anyway.
       !
-      WRITE(*,*) 'PSOL :', psol(10,20)
-      WRITE(*,*) ap(:), bp(:)
+!      WRITE(*,*) 'PSOL :', psol(10,20)
+!      WRITE(*,*) ap(:), bp(:)
       CALL pression(ip1jmp1, ap, bp, psol, p3d)
-      WRITE(*,*) 'P3D :', p3d(10,20,:)
+!      WRITE(*,*) 'P3D :', p3d(10,20,:)
       CALL exner_hyb(ip1jmp1, psol, p3d, alpha, beta, pks, pk, workvar)
-      WRITE(*,*) 'PK:', pk(10,20,:)
+!      WRITE(*,*) 'PK:', pk(10,20,:)
       !
       !
       !
       prefkap =  preff  ** kappa
-      WRITE(*,*) 'unskap, cpp,  preff :', unskap, cpp,  preff
+!      WRITE(*,*) 'unskap, cpp,  preff :', unskap, cpp,  preff
       DO l = 1, llm
         DO j=1,jjp1
@@ -235,5 +234,5 @@
       ENDDO
       !
-      WRITE(*,*) 'PLS :', pls(10,20,:)
+!      WRITE(*,*) 'PLS :', pls(10,20,:)
       !
       varname = 'surfgeo'
@@ -297,5 +296,5 @@
       !
       WRITE(*,*) 'TSOL construit :'
-      WRITE(*,'(48I3)') INT(TSOL(2:klon)-273)
+!      WRITE(*,'(48I3)') INT(TSOL(2:klon)-273)
       !
       varname = 'qsol'
Index: LMDZ.3.3/branches/rel-LF/libf/dyn3d/grid_noro.F
===================================================================
--- LMDZ.3.3/branches/rel-LF/libf/dyn3d/grid_noro.F	(revision 324)
+++ LMDZ.3.3/branches/rel-LF/libf/dyn3d/grid_noro.F	(revision 325)
@@ -450,7 +450,7 @@
       ENDDO
       
-      WRITE(*,*) 'MVA9 ', IMAR, JMAR
-      WRITE(*,*) 'MVA9 ', WEIGHTpb
-      WRITE(*,*) 'MVA9 SUM ', SUM
+c     WRITE(*,*) 'MVA9 ', IMAR, JMAR
+c     WRITE(*,*) 'MVA9 ', WEIGHTpb
+c     WRITE(*,*) 'MVA9 SUM ', SUM
       DO IS=-1,1
         DO JS=-1,1
Index: LMDZ.3.3/branches/rel-LF/libf/dyn3d/inter_barxy.F
===================================================================
--- LMDZ.3.3/branches/rel-LF/libf/dyn3d/inter_barxy.F	(revision 324)
+++ LMDZ.3.3/branches/rel-LF/libf/dyn3d/inter_barxy.F	(revision 325)
@@ -18,5 +18,4 @@
 c
 
-         print *,' NEEEEE BY ** '
        DO j = 1, jnterfd + 1
         CALL inter_barx( interfd, dlonid, champ( 1,j ),
Index: LMDZ.3.3/branches/rel-LF/libf/dyn3d/limit_netcdf.F
===================================================================
--- LMDZ.3.3/branches/rel-LF/libf/dyn3d/limit_netcdf.F	(revision 324)
+++ LMDZ.3.3/branches/rel-LF/libf/dyn3d/limit_netcdf.F	(revision 325)
@@ -2,5 +2,5 @@
 C $Header$
 C
-      SUBROUTINE limit_netcdf ( interbar, extrap, oldice, masque )
+      SUBROUTINE limit_netcdf(interbar, extrap, oldice, masque, pctsrf)
 c
       IMPLICIT none
@@ -29,10 +29,9 @@
 #include "comconst.h"
 #include "dimphy.h"
+#include "indicesol.h"
 c
 c-----------------------------------------------------------------------
       LOGICAL interbar, extrap, oldice
 
-      INTEGER KIDIA, KFDIA, KLON, KLEV
-c-----------------------------------------------------------------------
       REAL phy_nat(klon,360), phy_nat0(klon)
       REAL phy_alb(klon,360)
@@ -42,6 +41,16 @@
       REAL phy_ice(klon,360)
 c
+      real pctsrf_t(klon,nbsrf,360)
+      real pctsrf(klon,nbsrf)
+      REAL verif
+
       REAL masque(iip1,jjp1)
       REAL mask(iim,jjp1)
+CPB
+C newlmt indique l'utilisation de la sous-maille fractionnelle
+C tandis que l'ancien codage utilise l'indicateur du sol (0,1,2,3)
+      LOGICAL newlmt, fracterre
+      PARAMETER(newlmt=.TRUE.)
+      PARAMETER(fracterre = .TRUE.) 
 
 C Declarations pour le champ de depart
@@ -83,8 +92,27 @@
       INTEGER id_tim
       INTEGER id_NAT, id_SST, id_BILS, id_RUG, id_ALB
-
-      INTEGER i, j, k, l
+CPB
+      INTEGER id_FOCE, id_FSIC, id_FTER, id_FLIC
+
+      INTEGER i, j, k, l, ji
+c declarations pour lecture glace de mer
+      INTEGER :: iml_lic, jml_lic, llm_tmp, ttm_tmp, iret
+      INTEGER :: itaul(1), fid
+      REAL :: lev(1), date, dt
+      REAL, ALLOCATABLE, DIMENSION(:,:) :: lon_lic, lat_lic
+      REAL, ALLOCATABLE, DIMENSION(:)  :: dlon_lic, dlat_lic
+      REAL, ALLOCATABLE, DIMENSION (:,:) :: fraclic
+      REAL :: flic_tmp(iip1, jjp1)
+
 c Diverses variables locales
       REAL time
+! pour la lecture du fichier masque ocean
+      integer :: nid_o2a
+      logical :: couple = .false.
+      INTEGER :: iml_omask, jml_omask
+      REAL, ALLOCATABLE, DIMENSION(:,:) :: lon_omask, lat_omask
+      REAL, ALLOCATABLE, DIMENSION(:)  :: dlon_omask, dlat_omask
+      REAL, ALLOCATABLE, DIMENSION (:,:) :: ocemask, ocetmp
+      real, dimension(klon) :: ocemask_fi
 
       INTEGER          longcles
@@ -94,4 +122,9 @@
       INTEGER ncid,varid,ndimid(4),dimid
       character*30 namedim
+      CHARACTER*80 :: varname
+
+c initialisations:
+      CALL conf_gcm( 99, .TRUE. , clesphy0 )
+
 
       pi     = 4. * ATAN(1.)
@@ -103,4 +136,5 @@
       cpp    = 1004.70885
       dtvr    = daysec/FLOAT(day_step)
+      CALL inigeom
 c
 C Traitement du relief au sol
@@ -589,18 +623,100 @@
          CALL gr_dyn_fi(1, iip1, jjp1, klon,
      .                  champan(1,1,k), phy_ice(1,k))
-         DO i = 1, klon
-            phy_nat(i,k) = zmasq(i)
-            IF ( (phy_ice(i,k) - 0.5).GE.1.e-5 ) THEN
-               IF (NINT(zmasq(i)).EQ.0) THEN
-                  phy_nat(i,k) = 3.0
-               ELSE
-                  phy_nat(i,k) = 2.0
-               ENDIF
+        IF ( newlmt) THEN
+
+CPB  en attendant de mettre fraction de terre
+c
+          WHERE(phy_ice(1:klon) .GE. 1.) phy_ice(1 : klon) = 1.
+          WHERE(phy_ice(1:klon) .LT. EPSFRA) phy_ice(1 : klon) = 0.
+c 
+          IF (fracterre ) THEN
+c            WRITE(*,*) 'passe dans cas fracterre' 
+            pctsrf_t(:,is_ter,k) = pctsrf(:,is_ter)
+            pctsrf_t(:,is_lic,k) = pctsrf(:,is_lic)
+            pctsrf_t(1:klon,is_sic,k) =   phy_ice(1:klon) 
+     $            - pctsrf_t(1:klon,is_lic,k)
+c Il y a des cas ou il y a de la glace dans landiceref et pas dans AMIP
+            WHERE (pctsrf_t(1:klon,is_sic,k) .LE. 0)
+              pctsrf_t(1:klon,is_sic,k) = 0.
+            END WHERE 
+            WHERE( 1. - zmasq(1:klon) .LT. EPSFRA)
+              pctsrf_t(1:klon,is_sic,k) = 0.
+              pctsrf_t(1:klon,is_oce,k) = 0.
+            END WHERE
+            DO i = 1, klon
+              IF ( 1. - zmasq(i) .GT. EPSFRA) THEN 
+                IF ( pctsrf_t(i,is_sic,k) .GE. 1 - zmasq(i)) THEN
+                  pctsrf_t(i,is_sic,k) = 1 - zmasq(i)
+                  pctsrf_t(i,is_oce,k) = 0.
+                ELSE 
+                  pctsrf_t(i,is_oce,k) = 1 - zmasq(i) 
+     $                    - pctsrf_t(i,is_sic,k)
+                  IF (pctsrf_t(i,is_oce,k) .LT. EPSFRA) THEN
+                    pctsrf_t(i,is_oce,k) = 0.
+                    pctsrf_t(i,is_sic,k) = 1 - zmasq(i)
+                  ENDIF 
+                ENDIF
+              ENDIF  
+              if (pctsrf_t(i,is_oce,k) .lt. 0.) then
+                WRITE(*,*) 'pb sous maille au point : i,k '
+     $              , i,k,pctsrf_t(:,is_oce,k)
+              ENDIF
+              IF ( abs( pctsrf_t(i, is_ter,k) + pctsrf_t(i, is_lic,k) + 
+     $          pctsrf_t(i, is_oce,k) + pctsrf_t(i, is_sic,k)  - 1.) 
+     $            .GT. EPSFRA) THEN 
+                  WRITE(*,*) 'physiq : pb sous surface au point ', i, 
+     $                pctsrf_t(i, 1 : nbsrf,k), phy_ice(i)
+              ENDIF 
+            END DO
+          ELSE 
+            DO i = 1, klon
+              pctsrf_t(i,is_ter,k) = pctsrf(i,is_ter)
+              IF (NINT(pctsrf(i,is_ter)).EQ.1 ) THEN
+                pctsrf_t(i,is_sic,k) = 0.
+                pctsrf_t(i,is_oce,k) = 0.                  
+                IF(phy_ice(i) .GE. 1.e-5) THEN
+                  pctsrf_t(i,is_lic,k) = phy_ice(i)
+                  pctsrf_t(i,is_ter,k) = pctsrf_t(i,is_ter,k) 
+     .                                   - pctsrf_t(i,is_lic,k)
+                ELSE
+                  pctsrf_t(i,is_lic,k) = 0.
+                ENDIF 
+              ELSE
+                pctsrf_t(i,is_lic,k) = 0. 
+                IF(phy_ice(i) .GE. 1.e-5) THEN 
+                  pctsrf_t(i,is_ter,k) = 0.
+                  pctsrf_t(i,is_sic,k) = phy_ice(i)
+                  pctsrf_t(i,is_oce,k) = 1. - pctsrf_t(i,is_sic,k)
+                ELSE
+                  pctsrf_t(i,is_sic,k) = 0.
+                  pctsrf_t(i,is_oce,k) = 1.                      
+                ENDIF 
+              ENDIF
+              verif = pctsrf_t(i,is_ter,k) +
+     .                pctsrf_t(i,is_oce,k) + 
+     .                pctsrf_t(i,is_sic,k) +
+     .                pctsrf_t(i,is_lic,k)
+              IF ( verif .LT. 1. - 1.e-5 .OR. 
+     $             verif .GT. 1 + 1.e-5) THEN  
+                WRITE(*,*) 'pb sous maille au point : i,k,verif '
+     $                    , i,k,verif
+              ENDIF 
+            END DO
+          ENDIF 
+        ELSE  
+          DO i = 1, klon
+            phy_nat(i,k) = phy_nat0(i)
+            IF ( (phy_ice(i) - 0.5).GE.1.e-5 ) THEN
+              IF (NINT(phy_nat0(i)).EQ.0) THEN
+                phy_nat(i,k) = 3.0
+              ELSE
+                phy_nat(i,k) = 2.0
+              ENDIF
             ENDIF
             IF( NINT(phy_nat(i,k)).EQ.0 ) THEN
               IF ( phy_rug(i,k).NE.0.001 ) phy_rug(i,k) = 0.001
             ENDIF
-         ENDDO
-
+          END DO
+        ENDIF
       ENDDO
 c
@@ -1004,25 +1120,39 @@
       dims(2) = ntim
 c
-ccc      ierr = NF_DEF_VAR (nid, "TEMPS", NF_DOUBLE, 1,ntim, id_tim)
       ierr = NF_DEF_VAR (nid, "TEMPS", NF_FLOAT, 1,ntim, id_tim)
       ierr = NF_PUT_ATT_TEXT (nid, id_tim, "title", 17,
      .                        "Jour dans l annee")
-ccc      ierr = NF_DEF_VAR (nid, "NAT", NF_DOUBLE, 2,dims, id_NAT)
-      ierr = NF_DEF_VAR (nid, "NAT", NF_FLOAT, 2,dims, id_NAT)
-      ierr = NF_PUT_ATT_TEXT (nid, id_NAT, "title", 23,
-     .                        "Nature du sol (0,1,2,3)")
-ccc      ierr = NF_DEF_VAR (nid, "SST", NF_DOUBLE, 2,dims, id_SST)
+      IF (newlmt) THEN
+c
+        ierr = NF_DEF_VAR (nid, "FOCE", NF_FLOAT, 2,dims, id_FOCE)
+        ierr = NF_PUT_ATT_TEXT (nid, id_FOCE, "title", 14,
+     .                      "Fraction ocean")
+c
+        ierr = NF_DEF_VAR (nid, "FSIC", NF_FLOAT, 2,dims, id_FSIC)
+        ierr = NF_PUT_ATT_TEXT (nid, id_FSIC, "title", 21,
+     .                      "Fraction glace de mer")
+c
+        ierr = NF_DEF_VAR (nid, "FTER", NF_FLOAT, 2,dims, id_FTER)
+        ierr = NF_PUT_ATT_TEXT (nid, id_FTER, "title", 14,
+     .                      "Fraction terre")
+c
+        ierr = NF_DEF_VAR (nid, "FLIC", NF_FLOAT, 2,dims, id_FLIC)
+        ierr = NF_PUT_ATT_TEXT (nid, id_FLIC, "title", 17,
+     .                      "Fraction land ice")
+c
+      ELSE 
+        ierr = NF_DEF_VAR (nid, "NAT", NF_FLOAT, 2,dims, id_NAT)
+        ierr = NF_PUT_ATT_TEXT (nid, id_NAT, "title", 23,
+     .                      "Nature du sol (0,1,2,3)")
+      ENDIF 
       ierr = NF_DEF_VAR (nid, "SST", NF_FLOAT, 2,dims, id_SST)
       ierr = NF_PUT_ATT_TEXT (nid, id_SST, "title", 35,
-     .                        "Temperature superficielle de la mer")
-ccc      ierr = NF_DEF_VAR (nid, "BILS", NF_DOUBLE, 2,dims, id_BILS)
+     .                      "Temperature superficielle de la mer")
       ierr = NF_DEF_VAR (nid, "BILS", NF_FLOAT, 2,dims, id_BILS)
       ierr = NF_PUT_ATT_TEXT (nid, id_BILS, "title", 32,
      .                        "Reference flux de chaleur au sol")
-ccc      ierr = NF_DEF_VAR (nid, "ALB", NF_DOUBLE, 2,dims, id_ALB)
       ierr = NF_DEF_VAR (nid, "ALB", NF_FLOAT, 2,dims, id_ALB)
       ierr = NF_PUT_ATT_TEXT (nid, id_ALB, "title", 19,
      .                        "Albedo a la surface")
-ccc      ierr = NF_DEF_VAR (nid, "RUG", NF_DOUBLE, 2,dims, id_RUG)
       ierr = NF_DEF_VAR (nid, "RUG", NF_FLOAT, 2,dims, id_RUG)
       ierr = NF_PUT_ATT_TEXT (nid, id_RUG, "title", 8,
@@ -1040,5 +1170,19 @@
 #ifdef NC_DOUBLE
       ierr = NF_PUT_VAR1_DOUBLE (nid,id_tim,k,DBLE(k))
-      ierr = NF_PUT_VARA_DOUBLE (nid,id_NAT,debut,epais,phy_nat(1,k))
+c
+      IF (newlmt ) THEN
+          ierr = NF_PUT_VARA_DOUBLE (nid,id_FOCE,debut,epais
+     $        ,pctsrf_t(1,is_oce,k))
+          ierr = NF_PUT_VARA_DOUBLE (nid,id_FSIC,debut,epais
+     $        ,pctsrf_t(1,is_sic,k))
+          ierr = NF_PUT_VARA_DOUBLE (nid,id_FTER,debut,epais
+     $        ,pctsrf_t(1,is_ter,k))
+          ierr = NF_PUT_VARA_DOUBLE (nid,id_FLIC,debut,epais
+     $        ,pctsrf_t(1,is_lic,k))
+      ELSE 
+          ierr = NF_PUT_VARA_DOUBLE (nid,id_NAT,debut,epais
+     $        ,phy_nat(1,k))
+      ENDIF 
+c
       ierr = NF_PUT_VARA_DOUBLE (nid,id_SST,debut,epais,phy_sst(1,k))
       ierr = NF_PUT_VARA_DOUBLE (nid,id_BILS,debut,epais,phy_bil(1,k))
@@ -1047,5 +1191,17 @@
 #else
       ierr = NF_PUT_VAR1_REAL (nid,id_tim,k,FLOAT(k))
-      ierr = NF_PUT_VARA_REAL (nid,id_NAT,debut,epais,phy_nat(1,k))
+      IF (newlmt ) THEN
+          ierr = NF_PUT_VARA_REAL (nid,id_FOCE,debut,epais
+     $        ,pctsrf_t(1,is_oce,k))
+          ierr = NF_PUT_VARA_REAL (nid,id_FSIC,debut,epais
+     $        ,pctsrf_t(1,is_sic,k))
+          ierr = NF_PUT_VARA_REAL (nid,id_FTER,debut,epais
+     $        ,pctsrf_t(1,is_ter,k))
+          ierr = NF_PUT_VARA_REAL (nid,id_FLIC,debut,epais
+     $        ,pctsrf_t(1,is_lic,k))
+      ELSE 
+          ierr = NF_PUT_VARA_REAL (nid,id_NAT,debut,epais
+     $        ,phy_nat(1,k))
+      ENDIF 
       ierr = NF_PUT_VARA_REAL (nid,id_SST,debut,epais,phy_sst(1,k))
       ierr = NF_PUT_VARA_REAL (nid,id_BILS,debut,epais,phy_bil(1,k))
