Index: LMDZ5/trunk/libf/dynphy_lonlat/phylmd/limit_netcdf.F90
===================================================================
--- LMDZ5/trunk/libf/dynphy_lonlat/phylmd/limit_netcdf.F90	(revision 2888)
+++ LMDZ5/trunk/libf/dynphy_lonlat/phylmd/limit_netcdf.F90	(revision 2889)
@@ -28,12 +28,12 @@
 
   CHARACTER(LEN=20), PARAMETER :: &
-  fsst(4)=['amipbc_sst_1x1.nc   ','cpl_atm_sst.nc      ','histmth_sst.nc      '&
-          ,'sstk.nc             ']
+  fsst(5)=['amipbc_sst_1x1.nc   ','amip_sst_1x1.nc     ','cpl_atm_sst.nc      '&
+          ,'histmth_sst.nc      ','sstk.nc             ']
   CHARACTER(LEN=20), PARAMETER :: &
-  fsic(4)=['amipbc_sic_1x1.nc   ','cpl_atm_sic.nc      ','histmth_sic.nc      '&
-          ,'ci.nc               ']
+  fsic(5)=['amipbc_sic_1x1.nc   ','amip_sic_1x1.nc     ','cpl_atm_sic.nc      '&
+          ,'histmth_sic.nc      ','ci.nc               ']
   CHARACTER(LEN=10), PARAMETER :: &
-  vsst(4)=['tosbcs    ','SISUTESW  ','tsol_oce  ','sstk      '], &
-  vsic(4)=['sicbcs    ','SIICECOV  ','pourc_sic ','ci        ']
+  vsst(5)=['tosbcs    ','tos       ','SISUTESW  ','tsol_oce  ','sstk      '],  &
+  vsic(5)=['sicbcs    ','sic       ','SIICECOV  ','pourc_sic ','ci        ']
   CHARACTER(LEN=10), PARAMETER :: &
   frugo='Rugos.nc  ', falbe='Albedo.nc ', frelf='Relief.nc ',    &
@@ -61,4 +61,5 @@
 !  *    12/2009: D. Cugnet   (f77->f90, calendars, files from coupled runs)
 !  *    04/2016: D. Cugnet   (12/14 recs SST/SIC files: cyclic/interannual runs)
+!  *    05/2017: D. Cugnet   (linear time interpolation for BCS files)
 !-------------------------------------------------------------------------------
 #ifndef CPP_1D
@@ -102,4 +103,5 @@
   INTEGER :: NF90_FORMAT
   INTEGER :: ndays                   !--- Depending on the output calendar
+  CHARACTER(LEN=256) :: str
 
 !--- INITIALIZATIONS -----------------------------------------------------------
@@ -158,7 +160,7 @@
      pctsrf_t(:,is_lic,k)=pctsrf(:,is_lic)       ! land ice
      SELECT CASE(ix_sic)
-        CASE(2)                                   ! SIC=pICE*(1-LIC-TER) (CPL)
+        CASE(3)                                   ! SIC=pICE*(1-LIC-TER) (CPL)
         pctsrf_t(:,is_sic,k)=fi_ice(:)*(1.-pctsrf(:,is_lic)-pctsrf(:,is_ter))
-        CASE(3)                                   ! SIC=pICE            (HIST)
+        CASE(4)                                   ! SIC=pICE            (HIST)
         pctsrf_t(:,is_sic,k)=fi_ice(:)
         CASE DEFAULT                              ! SIC=pICE-LIC   (AMIP,ERAI)
@@ -223,4 +225,22 @@
   CALL ncerr(NF90_CREATE(fnam,NF90_CLOBBER,nid),fnam)
   CALL ncerr(NF90_PUT_ATT(nid,NF90_GLOBAL,"title","Fichier conditions aux limites"),fnam)
+  str='File produced using ce0l executable.'
+  str=TRIM(str)//NEW_LINE(' ')//'Sea Ice Concentration built from'
+  SELECT CASE(ix_sic)
+    CASE(1); str=TRIM(str)//' Amip mid-month boundary condition (BCS).'
+    CASE(2); str=TRIM(str)//' Amip monthly mean observations.'
+    CASE(3); str=TRIM(str)//' IPSL coupled model outputs.'
+    CASE(4); str=TRIM(str)//' LMDZ model outputs.'
+    CASE(5); str=TRIM(str)//' ci.nc file.'
+  END SELECT
+  str=TRIM(str)//NEW_LINE(' ')//'Sea Surface Temperature built from'
+  SELECT CASE(ix_sst)
+    CASE(1); str=TRIM(str)//' Amip mid-month boundary condition (BCS).'
+    CASE(2); str=TRIM(str)//' Amip monthly mean observations.'
+    CASE(3); str=TRIM(str)//' IPSL coupled model outputs.'
+    CASE(4); str=TRIM(str)//' LMDZ model outputs.'
+    CASE(5); str=TRIM(str)//' sstk.nc file.'
+  END SELECT
+  CALL ncerr(NF90_PUT_ATT(nid,NF90_GLOBAL,"history",TRIM(str)),fnam)
 
   !--- Dimensions creation
@@ -348,6 +368,7 @@
   REAL, ALLOCATABLE :: work(:,:)          ! used for extrapolation
   CHARACTER(LEN=128):: title, mess        ! for messages
+  LOGICAL           :: is_bcs             ! flag for BCS data
   LOGICAL           :: extrp              ! flag for extrapolation
-  REAL              :: chmin, chmax
+  REAL              :: chmin, chmax, timeday, al
   INTEGER ierr, idx
   integer n_extrap ! number of extrapolated points
@@ -365,4 +386,5 @@
   END SELECT
   extrp=.FALSE.; IF(PRESENT(flag).AND.mode=='SST') extrp=flag
+  is_bcs=(mode=='SIC'.AND.ix_sic==1).OR.(mode=='SST'.AND.ix_sst==1)
   idx=INDEX(fnam,'.nc')-1
 
@@ -442,11 +464,12 @@
     CALL ncerr(NF90_GET_VAR(ncid,varid,champ,[1,1,l],[imdep,jmdep,1]),fnam)
     !--- Check whether values are acceptable for SIC, depending on unit.
-    IF(mode=='SIC') THEN
+    !--- Dropped for mid-month boundary conditions datasets (BCS, ix_sic==1)
+    IF(mode=='SIC'.AND.ix_sic/=1) THEN
       IF(TRIM(unit_sic)=="1".OR.TRIM(unit_sic)=="1.0") THEN
         IF(ANY(champ>1.0+EPSFRA)) &
           CALL abort_physic('SIC','Found sea-ice fractions greater than 1.')
       ELSE IF(TRIM(unit_sic)=="X".OR.TRIM(unit_sic)=="%") THEN
-!        IF(ANY(champ>100.0+EPSFRA)) &
-!          CALL abort_physic('SIC','Found sea-ice percentages greater than 100.')
+        IF(ANY(champ>100.0+EPSFRA)) &
+          CALL abort_physic('SIC','Found sea-ice percentages greater than 100.')
         IF(MAXVAL(champ)< 1.01) &
           CALL abort_physic('SIC','All sea-ice percentages lower than 1.')
@@ -529,15 +552,30 @@
         WRITE(lunout, *)' Daily input file.'
      ELSE
-        WRITE(lunout, *)'TIME INTERPOLATION.'
+        IF(     is_bcs) WRITE(lunout, *)'LINEAR TIME INTERPOLATION.'
+        IF(.NOT.is_bcs) WRITE(lunout, *)'SPLINES TIME INTERPOLATION.'
         WRITE(lunout, *)' Input time vector: ', timeyear
         WRITE(lunout, *)' Output time vector from 0 to ', ndays-1
      END IF
   END IF
-  ALLOCATE(yder(lmdep+2), champan(iip1, jjp1, ndays))
-  IF(lmdep==ndays_in) THEN
+  ALLOCATE(champan(iip1, jjp1, ndays))
+
+  IF(lmdep==ndays_in) THEN  !--- DAILY DATA: NO     TIME INTERPOLATION
      champan(1:iim,:,:)=champtime
-  ELSE
+  ELSE IF(is_bcs) THEN      !--- BCS   DATA: LINEAR TIME INTERPOLATION
+    l=1
+    DO k=1, ndays
+      timeday = REAL((k-1)*ndays_in)/ndays
+      IF(timeyear(l+1)<timeday) l=l+1
+      al=(timeday-timeyear(l))/(timeyear(l+1)-timeyear(l))
+      DO j=1, jjp1
+        DO i=1, iim
+          champan(i,j,k) = champtime(i,j,l)+al*(champtime(i,j,l+1)-champtime(i,j,l))
+        END DO
+      END DO
+    END DO
+  ELSE                      !--- AVE   DATA: SPLINE TIME INTERPOLATION
      skip = .false.
      n_extrap = 0
+     ALLOCATE(yder(lmdep+2))
      DO j=1, jjp1
        DO i=1, iim
@@ -551,7 +589,8 @@
      END DO
      IF(n_extrap /= 0) WRITE(lunout,*) "get_2Dfield pchfe_95: n_extrap = ", n_extrap
+     DEALLOCATE(yder)
   END IF
   champan(iip1, :, :)=champan(1, :, :)
-  DEALLOCATE(yder, champtime, timeyear)
+  DEALLOCATE(champtime, timeyear)
 
 !--- Checking the result
