Index: LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/ce0l.F90
===================================================================
--- LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/ce0l.F90	(revision 2669)
+++ LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/ce0l.F90	(revision 2720)
@@ -12,4 +12,5 @@
 !     * "masque" can be:
 !       - read from file "o2a.nc"          (for coupled runs).
+!       - read from file "startphy0.nc"    (from a previous run).
 !       - created in etat0phys or etat0dyn (for forced  runs).
 !     It is then passed to limit_netcdf to ensure consistancy.
@@ -20,5 +21,6 @@
   USE etat0phys,      ONLY: etat0phys_netcdf
   USE limit,          ONLY: limit_netcdf
-  USE netcdf,         ONLY: NF90_OPEN, NF90_NOWRITE, NF90_CLOSE, NF90_NOERR
+  USE netcdf,         ONLY: NF90_OPEN, NF90_NOWRITE, NF90_CLOSE, NF90_NOERR,    &
+         NF90_INQUIRE_DIMENSION, NF90_INQ_DIMID, NF90_INQ_VARID, NF90_GET_VAR
   USE infotrac,       ONLY: type_trac, infotrac_init
   USE dimphy,         ONLY: klon
@@ -60,4 +62,9 @@
   REAL, ALLOCATABLE  :: lat_omask(:,:), dlat_omask(:), ocetmp (:,:)
   REAL               :: date, lev(1)
+
+!--- Local variables for land mask from startphy0 file reading
+  INTEGER            :: nid_sta, nid_nph, nid_msk, nphys
+  REAL, ALLOCATABLE  :: masktmp(:)
+
 #ifndef CPP_PARA
 ! for iniphysiq in serial mode
@@ -133,15 +140,12 @@
   ENDIF
 
-!--- LAND MASK. TWO CASES:
+!--- LAND MASK. THREE CASES:
 !   1) read from ocean model    file "o2a.nc"    (coupled runs)
-!   2) computed from topography file "Relief.nc" (masque(:,:)=-99999.)
-! Coupled simulations (case 1) use the ocean model mask to compute the
+!   2) read from previous run   file="startphy0.nc"
+!   3) computed from topography file "Relief.nc" (masque(:,:)=-99999.)
+! In the first case, the mask from the ocean model is used compute the
 ! weights to ensure ocean fractions are the same for atmosphere and ocean.
 !*******************************************************************************
-  IF(NF90_OPEN("o2a.nc", NF90_NOWRITE, nid_o2a)/=NF90_NOERR) THEN
-    WRITE(lunout,*)'BEWARE !! No ocean mask "o2a.nc" file found'
-    WRITE(lunout,*)'Forced run.'
-    masque(:,:)=-99999.
-  ELSE
+  IF(NF90_OPEN("o2a.nc", NF90_NOWRITE, nid_o2a)==NF90_NOERR) THEN
     iret=NF90_CLOSE(nid_o2a)
     WRITE(lunout,*)'BEWARE !! Ocean mask "o2a.nc" file found'
@@ -175,4 +179,30 @@
     masque(iip1 ,:)=masque(1,:)
     DEALLOCATE(ocemask)
+  ELSE IF(NF90_OPEN("startphy0.nc", NF90_NOWRITE, nid_sta)==NF90_NOERR) THEN
+    WRITE(lunout,*)'BEWARE !! File "startphy0.nc" found.'
+    WRITE(lunout,*)'Getting the land mask from a previous run.'
+    iret=NF90_INQ_DIMID(nid_sta,'points_physiques',nid_nph)
+    iret=NF90_INQUIRE_DIMENSION(nid_sta,nid_nph,len=nphys)
+    IF(nphys/=klon) THEN
+      WRITE(lunout,*)'Mismatching dimensions for land mask'
+      WRITE(lunout,*)'nphys  = ',nphys ,' klon = ',klon
+      iret=NF90_CLOSE(nid_sta)
+      CALL abort_gcm(modname,'',1)
+    END IF
+    ALLOCATE(masktmp(klon))
+    iret=NF90_INQ_VARID(nid_sta,'masque',nid_msk)
+    iret=NF90_GET_VAR(nid_sta,nid_msk,masktmp)
+    iret=NF90_CLOSE(nid_sta)
+    CALL gr_fi_dyn(1,klon,iip1,jjp1,masktmp,masque)
+    IF(prt_level>=1) THEN
+      WRITE(fmt,"(i4,'i1)')")iip1 ; fmt='('//ADJUSTL(fmt)
+      WRITE(lunout,*)'LAND MASK :'
+      WRITE(lunout,fmt) NINT(masque)
+    END IF
+    DEALLOCATE(masktmp)
+  ELSE
+    WRITE(lunout,*)'BEWARE !! No ocean mask "o2a.nc" file or "startphy0.nc" file found'
+    WRITE(lunout,*)'Land mask will be built from the topography file.'
+    masque(:,:)=-99999.
   END IF
   phis(:,:)=-99999.
Index: LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/etat0dyn_netcdf.F90
===================================================================
--- LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/etat0dyn_netcdf.F90	(revision 2669)
+++ LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/etat0dyn_netcdf.F90	(revision 2720)
@@ -38,5 +38,5 @@
   USE comconst_mod, ONLY: pi, cpp, kappa
   USE comvert_mod, ONLY: ap, bp, preff, pressure_exner
-  USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn, itau_phy
+  USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn, itau_phy, start_time
   
   IMPLICIT NONE
@@ -172,5 +172,6 @@
   CALL caldyn0( itau, uvent, vvent, tpot, psol, masse, pk, phis,               &
                 phi,  w, pbaru, pbarv, time+iday-dayref)
-  WRITE(lunout,*)'sortie caldyn0'     
+  WRITE(lunout,*)'sortie caldyn0'
+  start_time = 0.
 #ifdef CPP_PARA
   CALL dynredem0_loc( "start.nc", dayref, phis)
Index: LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/etat0phys_netcdf.F90
===================================================================
--- LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/etat0phys_netcdf.F90	(revision 2669)
+++ LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/etat0phys_netcdf.F90	(revision 2720)
@@ -59,4 +59,5 @@
   INTEGER,            SAVE      :: iml_phys, jml_phys, llm_phys, ttm_phys, fid_phys
   REAL, ALLOCATABLE,  SAVE      :: lon_phys(:,:), lat_phys(:,:), levphys_ini(:)
+  CHARACTER(LEN=256), PARAMETER :: oroparam="oro_params.nc"
   CHARACTER(LEN=256), PARAMETER :: orofname="Relief.nc", orogvar="RELIEF"
   CHARACTER(LEN=256), PARAMETER :: phyfname="ECPHY.nc",  psrfvar="SP"
@@ -255,6 +256,9 @@
 !   This routine launch grid_noro, which computes parameters for SSO scheme as
 !   described in LOTT & MILLER (1997) and LOTT(1999).
+!   In case the file oroparam is present and the key read_orop is activated,
+!   grid_noro is bypassed and sub-cell parameters are read from the file.
 !===============================================================================
-  USE grid_noro_m, ONLY: grid_noro
+  USE grid_noro_m, ONLY: grid_noro, read_noro
+  USE logic_mod,   ONLY: read_orop
   IMPLICIT NONE
 !-------------------------------------------------------------------------------
@@ -266,4 +270,5 @@
   CHARACTER(LEN=256) :: modname
   INTEGER            :: fid, llm_tmp,ttm_tmp, iml,jml, iml_rel,jml_rel, itau(1)
+  INTEGER            :: ierr
   REAL               :: lev(1), date, dt
   REAL, ALLOCATABLE  :: lon_rad(:), lon_ini(:), lon_rel(:,:), relief_hi(:,:)
@@ -306,7 +311,15 @@
   ALLOCATE(zpic0(iml,jml),zval0(iml,jml)) !--- Peaks and valley heights
 
+!--- READ SUB-CELL SCALES PARAMETERS FROM A FILE (AT RIGHT RESOLUTION)
+  OPEN(UNIT=66,FILE=oroparam,STATUS='OLD',IOSTAT=ierr)
+  IF(ierr==0.AND.read_orop) THEN
+    CLOSE(UNIT=66)
+    CALL read_noro(lon_in,lat_in,oroparam,                                     &
+                   phis,zmea0,zstd0,zsig0,zgam0,zthe0,zpic0,zval0,masque)
+  ELSE
 !--- CALL OROGRAPHY MODULE TO COMPUTE FIELDS
-  CALL grid_noro(lon_rad,lat_rad,relief_hi,lon_in,lat_in,phis,zmea0,zstd0,     &
-                                      zsig0,zgam0,zthe0,zpic0,zval0,masque)
+    CALL grid_noro(lon_rad,lat_rad,relief_hi,lon_in,lat_in,                    &
+                   phis,zmea0,zstd0,zsig0,zgam0,zthe0,zpic0,zval0,masque)
+  END IF
   phis = phis * 9.81
   phis(iml,:) = phis(1,:)
Index: LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/limit_netcdf.F90
===================================================================
--- LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/limit_netcdf.F90	(revision 2669)
+++ LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/limit_netcdf.F90	(revision 2720)
@@ -71,4 +71,5 @@
   USE netcdf95,           ONLY: nf95_def_var, nf95_put_att, nf95_put_var
   USE comconst_mod, ONLY: pi
+  USE phys_cal_mod, ONLY: calend
   IMPLICIT NONE
 !-------------------------------------------------------------------------------
@@ -244,4 +245,5 @@
   !--- Attributes creation
   CALL ncerr(NF90_PUT_ATT(nid,id_tim, "title","Jour dans l annee"),fnam)
+  CALL ncerr(NF90_PUT_ATT(nid,id_tim, "calendar",calend),fnam)
   CALL ncerr(NF90_PUT_ATT(nid,id_FOCE,"title","Fraction ocean"),fnam)
   CALL ncerr(NF90_PUT_ATT(nid,id_FSIC,"title","Fraction glace de mer"),fnam)
@@ -405,7 +407,8 @@
       CASE('SIC', 'SST'); cal_in='gregorian'
     END SELECT
-  CALL msg(5,'WARNING: missing "calendar" attribute for "time" in '&
+    CALL msg(5,'WARNING: missing "calendar" attribute for "time" in '&
      &//TRIM(fnam)//'. Choosing default value.')
   END IF
+  CALL strclean(cal_in)                     !--- REMOVE (WEIRD) NULL CHARACTERS
   CALL msg(5,'var, calendar, dim: '//TRIM(dnam)//' '//TRIM(cal_in), lmdep)
   
@@ -477,5 +480,5 @@
   fnam_p=fnam(1:idx)//'_p.nc'
   IF(NF90_OPEN(fnam_p,NF90_NOWRITE,ncid)==NF90_NOERR) THEN
-    CALL msg(0,'Reading previous year file ("'//TRIM(fnam_p)//'") first record for '//TRIM(title))
+    CALL msg(0,'Reading next year file ("'//TRIM(fnam_p)//'") first record for '//TRIM(title))
     CALL ncerr(NF90_INQ_VARID(ncid, varname, varid),fnam_p)
     CALL ncerr(NF90_GET_VAR(ncid,varid,champ,[1,1,1],[imdep,jmdep,1]),fnam_p)
@@ -767,4 +770,26 @@
 !-------------------------------------------------------------------------------
 
+
+!-------------------------------------------------------------------------------
+!
+SUBROUTINE strclean(s)
+!
+!-------------------------------------------------------------------------------
+  IMPLICIT NONE
+!-------------------------------------------------------------------------------
+! Purpose: Remove tail null characters from the input string.
+!-------------------------------------------------------------------------------
+! Parameters:
+  CHARACTER(LEN=*), INTENT(INOUT) :: s
+!-------------------------------------------------------------------------------
+! Local variable:
+  INTEGER :: k
+!-------------------------------------------------------------------------------
+  k=LEN_TRIM(s); DO WHILE(ICHAR(s(k:k))==0); s(k:k)=' '; k=LEN_TRIM(s); END DO
+
+END SUBROUTINE strclean
+!
+!-------------------------------------------------------------------------------
+
 #endif
 ! of #ifndef CPP_1D
