Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OFF_SRC/domrea.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OFF_SRC/domrea.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OFF_SRC/domrea.F90	(revision 5779)
@@ -122,5 +122,5 @@
          &             nn_no   , cn_exp    , cn_ocerst_in, cn_ocerst_out, ln_rstart , nn_rstctl,   &
          &             nn_it000, nn_itend  , nn_date0    , nn_leapy     , nn_istate , nn_stock ,   &
-         &             nn_write, ln_dimgnnn, ln_mskland  , ln_cfmeta    , ln_clobber, nn_chunksz, nn_euler
+         &             nn_write, ln_iscpl, ln_dimgnnn, ln_mskland  , ln_cfmeta    , ln_clobber, nn_chunksz, nn_euler
       NAMELIST/namdom/ nn_bathy , rn_bathy, rn_e3zps_min, rn_e3zps_rat, nn_msh    , rn_hmin,   &
          &             nn_acc   , rn_atfp     , rn_rdt      , rn_rdtmin ,            &
@@ -839,15 +839,15 @@
       DO jj = 1, jpjm1
          DO ji = 1, fs_jpim1   ! vector loop
-            umask_i(ji,jj)  = ssmask(ji,jj) * ssmask(ji+1,jj  )  * MIN(1._wp,SUM(umask(ji,jj,:)))
-            vmask_i(ji,jj)  = ssmask(ji,jj) * ssmask(ji  ,jj+1)  * MIN(1._wp,SUM(vmask(ji,jj,:)))
+            ssumask(ji,jj)  = ssmask(ji,jj) * ssmask(ji+1,jj  )  * MIN(1._wp,SUM(umask(ji,jj,:)))
+            ssvmask(ji,jj)  = ssmask(ji,jj) * ssmask(ji  ,jj+1)  * MIN(1._wp,SUM(vmask(ji,jj,:)))
          END DO
          DO ji = 1, jpim1      ! NO vector opt.
-            fmask_i(ji,jj) =  ssmask(ji,jj  ) * ssmask(ji+1,jj  )   &
+            ssfmask(ji,jj) =  ssmask(ji,jj  ) * ssmask(ji+1,jj  )   &
                &            * ssmask(ji,jj+1) * ssmask(ji+1,jj+1) * MIN(1._wp,SUM(fmask(ji,jj,:)))
          END DO
       END DO
-      CALL lbc_lnk( umask_i, 'U', 1._wp )      ! Lateral boundary conditions
-      CALL lbc_lnk( vmask_i, 'V', 1._wp )
-      CALL lbc_lnk( fmask_i, 'F', 1._wp )
+      CALL lbc_lnk( ssumask, 'U', 1._wp )      ! Lateral boundary conditions
+      CALL lbc_lnk( ssvmask, 'V', 1._wp )
+      CALL lbc_lnk( ssfmask, 'F', 1._wp )
 
       ! 3. Ocean/land mask at wu-, wv- and w points 
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DIA/diafwb.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DIA/diafwb.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DIA/diafwb.F90	(revision 5779)
@@ -460,5 +460,5 @@
       ENDIF
 
-      IF( nn_timing == 1 )   CALL timing_start('dia_fwb')
+      IF( nn_timing == 1 )   CALL timing_stop('dia_fwb')
 
  9005 FORMAT(1X,A,ES24.16)
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DIA/diahsb.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DIA/diahsb.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DIA/diahsb.F90	(revision 5779)
@@ -201,7 +201,4 @@
 !!gm end
       
-      IF (lwp) PRINT *, 'ISCPL CONS HEAT ', kt, zdiff_hc / zvol_tot, zdiff_sc / zvol_tot
-      IF (lwp) PRINT *, 'ISCPL CONS VOL  ', kt, zdiff_v1 * 1.e-9, zdiff_v2 * 1.e-9
-
       IF( lk_vvl ) THEN
         CALL iom_put( 'bgtemper' , zdiff_hc / zvol_tot )              ! Temperature variation (C) 
@@ -218,6 +215,6 @@
         CALL iom_put( 'bgsaline' , zdiff_sc1 / zvol_tot)              ! Salt content variation (psu)
         CALL iom_put( 'bgheatco' , zdiff_hc1 * 1.e-20 * rau0 * rcp )  ! Heat content variation (1.e20 J) 
-        CALL iom_put( 'bgsaltco' , zdiff_sc1 * 1.e-9    )             ! Salt content variation (psu*km3)
-        CALL iom_put( 'bgvolssh' , (zdiff_v1+zdiff_v2) * 1.e-9    )   ! volume ssh variation (km3)  
+        CALL iom_put( 'bgsaltco' , zdiff_sc1 * 1.e-9   )              ! Salt content variation (psu*km3)
+        CALL iom_put( 'bgvolssh' , zdiff_v1  * 1.e-9   )              ! volume ssh variation (km3)  
         CALL iom_put( 'bgfrcvol' , frc_v    * 1.e-9    )              ! vol - surface forcing (km3) 
         CALL iom_put( 'bgfrctem' , frc_t / zvol_tot    )              ! hc  - surface forcing (C) 
@@ -279,4 +276,5 @@
           ssh_ini(:,:) = sshn(:,:)                                       ! initial ssh
           DO jk = 1, jpk
+             ! if ice sheet/oceqn coupling, need to mask ini variables here (mask could change at the next NEMO instance).
              e3t_ini   (:,:,jk) = fse3t_n(:,:,jk)    * tmask(:,:,jk)                    ! initial vertical scale factors
              hc_loc_ini(:,:,jk) = tsn(:,:,jk,jp_tem) * fse3t_n(:,:,jk) * tmask(:,:,jk)  ! initial heat content
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 5779)
@@ -115,5 +115,8 @@
 
                              CALL dom_stp      ! time step
-      IF( nmsh /= 0 .AND. .NOT. ln_iscpl )   CALL dom_wri      ! Create a domain file
+      !
+      IF( nmsh /= 0 .AND. .NOT. ln_iscpl )                         CALL dom_wri      ! Create a domain file
+      IF( nmsh /= 0 .AND.       ln_iscpl .AND. .NOT. ln_rstart )   CALL dom_wri      ! Create a domain file
+      !
       IF( .NOT.ln_rstart )   CALL dom_ctl      ! Domain control
       !
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/domngb.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/domngb.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/domngb.F90	(revision 5779)
@@ -40,5 +40,5 @@
       REAL(wp)        , INTENT(in   ) ::   plon, plat   ! longitude,latitude of the point
       INTEGER         , INTENT(  out) ::   kii, kjj     ! i-,j-index of the closes grid point
-      INTEGER         , INTENT(in   ), OPTIONAL :: kkk
+      INTEGER         , INTENT(in   ), OPTIONAL :: kkk  ! k-index of the mask level used
       CHARACTER(len=1), INTENT(in   ) ::   cdgrid       ! grid name 'T', 'U', 'V', 'W'
       !
@@ -72,5 +72,5 @@
          zglam(:,:) = zglam(:,:) - plon
       END IF
-!
+
       zgphi(:,:) = zgphi(:,:) - plat
       zdist(:,:) = zglam(:,:) * zglam(:,:) + zgphi(:,:) * zgphi(:,:)
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 5779)
@@ -28,5 +28,5 @@
    USE in_out_manager  ! I/O manager
    USE iom             ! I/O manager library
-   USE restart  , ONLY : rst_read_open    ! ocean restart
+   USE restart, ONLY : rst_read_open    ! ocean restart
    USE lib_mpp         ! distributed memory computing library
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 5779)
@@ -472,25 +472,4 @@
          risfdep(:,:)=0.e0
          misfdep(:,:)=1
-         !
-         ! (ISF) TODO build ice draft netcdf file for isomip and build the corresponding part of code
-         IF( cp_cfg == "isomip" .AND. ln_isfcav ) THEN 
-            risfdep(:,:)=200.e0 
-            misfdep(:,:)=1 
-            ij0 = 1 ; ij1 = 40 
-            DO jj = mj0(ij0), mj1(ij1) 
-               risfdep(:,jj)=700.0_wp-(gphit(:,jj)+80.0_wp)*125.0_wp 
-            END DO 
-            WHERE( bathy(:,:) <= 0._wp )  risfdep(:,:) = 0._wp 
-         ! 
-         ELSEIF ( cp_cfg == "isomip2" .AND. ln_isfcav ) THEN
-         ! 
-            risfdep(:,:)=0.e0
-            misfdep(:,:)=1
-            ij0 = 1 ; ij1 = 40
-            DO jj = mj0(ij0), mj1(ij1)
-               risfdep(:,jj)=700.0_wp-(gphit(:,jj)+80.0_wp)*125.0_wp
-            END DO
-            WHERE( bathy(:,:) <= 0._wp )  risfdep(:,:) = 0._wp
-         END IF
          !
          DEALLOCATE( idta, zdta )
@@ -549,10 +528,11 @@
                CALL iom_close( inum )
                WHERE( bathy(:,:) <= 0._wp )  risfdep(:,:) = 0._wp
+
+               ! set grounded point to 0 (treshold at 1cm, have to be update after first coupling experience)
+               WHERE (bathy(:,:) .LE. risfdep(:,:)+1e-2 )
+                  misfdep(:,:) = 0 ; risfdep(:,:) = 0._wp
+                  mbathy (:,:) = 0 ; bathy  (:,:) = 0._wp
+               END WHERE
             END IF
-            ! set grounded point to 0
-            WHERE (bathy(:,:) .LE. risfdep(:,:)+1e-2 )
-               misfdep(:,:) = 0 ; risfdep(:,:) = 0._wp
-               mbathy (:,:) = 0 ; bathy  (:,:) = 0._wp
-            END WHERE
             !       
             IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN    ! ORCA R2 configuration
@@ -1260,10 +1240,4 @@
       END WHERE  
 
-      ! set grounded point to 0
-      WHERE (bathy(:,:) .LE. risfdep(:,:)+1e-2 )
-         misfdep(:,:) = 0 ; risfdep(:,:) = 0._wp
-         mbathy (:,:) = 0 ; bathy  (:,:) = 0._wp
-      END WHERE
-
       ! Compute misfdep for ocean points (i.e. first wet level) 
       ! find the first ocean level such that the first level thickness 
@@ -1278,15 +1252,9 @@
       END WHERE
 
-      ! remove very shallow ice shelf (less than ~ 10m if 75L)
-      IF ( cp_cfg .NE. "isomip" ) THEN
-         WHERE (risfdep(:,:) < 100 )
-            misfdep = 1; risfdep = 0.0_wp;
-         END WHERE
-      END IF
- 
 ! basic check for the compatibility of bathy and risfdep. I think it should be offline because it is not perfect and cannot solved all the situation
       icompt = 0 
 ! run the bathy check 10 times to be sure all the modif in the bathy or iceshelf draft are compatible together
       DO jl = 1, 10     
+         ! check at each iteration if isf is grounded or not (1cm treshold have to be update after first coupling experiments)
          WHERE (bathy(:,:) .LE. risfdep(:,:)+1e-2 )
             misfdep(:,:) = 0 ; risfdep(:,:) = 0._wp
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/dtatsd.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/dtatsd.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/dtatsd.F90	(revision 5779)
@@ -34,5 +34,4 @@
 
    TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_tsd   ! structure of input SST (file informations, fields read)
-   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_tsddmp   ! structure of input SST (file informations, fields read)
 
    !! * Substitutions
@@ -61,8 +60,6 @@
       TYPE(FLD_N), DIMENSION( jpts) ::   slf_i           ! array of namelist informations on the fields to read
       TYPE(FLD_N)                   ::   sn_tem, sn_sal
-      TYPE(FLD_N)                   ::   sn_dmpt, sn_dmps
       !!
       NAMELIST/namtsd/   ln_tsd_init, ln_tsd_tradmp, cn_dir, sn_tem, sn_sal
-      NAMELIST/namtra_dmpfile/ sn_dmpt, sn_dmps
       INTEGER  ::   ios
       !!----------------------------------------------------------------------
@@ -81,12 +78,4 @@
 902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtsd in configuration namelist', lwp )
       IF(lwm) WRITE ( numond, namtsd )
-
-      REWIND( numnam_ref )              ! Namelist namtra_dmp in reference namelist : Temperature and salinity damping term
-      READ  ( numnam_ref, namtra_dmpfile, IOSTAT = ios, ERR = 903)
-903   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtra_dmp in reference namelist', lwp )
-
-      REWIND( numnam_cfg )              ! Namelist namtra_dmp in configuration namelist : Temperature and salinity damping term
-      READ  ( numnam_cfg, namtra_dmpfile, IOSTAT = ios, ERR = 904 )
-904   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtra_dmp in configuration namelist', lwp )
 
       IF( PRESENT( ld_tradmp ) )   ln_tsd_tradmp = .TRUE.     ! forces the initialization when tradmp is used
@@ -116,5 +105,4 @@
          !
          ALLOCATE( sf_tsd(jpts), STAT=ierr0 )
-         ALLOCATE( sf_tsddmp(jpts), STAT=ierr0 )
          IF( ierr0 > 0 ) THEN
             CALL ctl_stop( 'dta_tsd_init: unable to allocate sf_tsd structure' )   ;   RETURN
@@ -125,9 +113,4 @@
                                 ALLOCATE( sf_tsd(jp_sal)%fnow(jpi,jpj,jpk)   , STAT=ierr2 )
          IF( sn_sal%ln_tint )   ALLOCATE( sf_tsd(jp_sal)%fdta(jpi,jpj,jpk,2) , STAT=ierr3 )
-         ! dmp file
-                                 ALLOCATE( sf_tsddmp(jp_tem)%fnow(jpi,jpj,jpk)   , STAT=ierr0 )
-         IF( sn_dmpt%ln_tint )   ALLOCATE( sf_tsddmp(jp_tem)%fdta(jpi,jpj,jpk,2) , STAT=ierr1 )
-                                 ALLOCATE( sf_tsddmp(jp_sal)%fnow(jpi,jpj,jpk)   , STAT=ierr2 )
-         IF( sn_dmps%ln_tint )   ALLOCATE( sf_tsddmp(jp_sal)%fdta(jpi,jpj,jpk,2) , STAT=ierr3 )
          !
          IF( ierr0 + ierr1 + ierr2 + ierr3 > 0 ) THEN
@@ -137,6 +120,4 @@
          slf_i(jp_tem) = sn_tem   ;   slf_i(jp_sal) = sn_sal
          CALL fld_fill( sf_tsd, slf_i, cn_dir, 'dta_tsd', 'Temperature & Salinity data', 'namtsd' )
-         slf_i(jp_tem) = sn_dmpt   ;   slf_i(jp_sal) = sn_dmps
-         CALL fld_fill( sf_tsddmp, slf_i, cn_dir, 'dta_tsd', 'Temperature & Salinity data', 'namtsd' )
          !
       ENDIF
@@ -147,5 +128,5 @@
 
 
-   SUBROUTINE dta_tsd( kt, ptsd, ptsddmp )
+   SUBROUTINE dta_tsd( kt, ptsd )
       !!----------------------------------------------------------------------
       !!                   ***  ROUTINE dta_tsd  ***
@@ -164,5 +145,4 @@
       INTEGER                              , INTENT(in   ) ::   kt     ! ocean time-step
       REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(  out) ::   ptsd   ! T & S data
-      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), OPTIONAL, INTENT(  out) ::   ptsddmp   ! T & S data
       !
       INTEGER ::   ji, jj, jk, jl, jkk   ! dummy loop indicies
@@ -175,9 +155,4 @@
       !
       CALL fld_read( kt, 1, sf_tsd )      !==   read T & S data at kt time step   ==!
-      IF ( PRESENT(ptsddmp) ) THEN
-         CALL fld_read( kt, 1, sf_tsddmp )      !==   read T & S data at kt time step   ==!
-         ptsddmp(:,:,:,jp_tem) = sf_tsddmp(jp_tem)%fnow(:,:,:)    ! NO mask
-         ptsddmp(:,:,:,jp_sal) = sf_tsddmp(jp_sal)%fnow(:,:,:) 
-      END IF
       !
       !
@@ -329,10 +304,4 @@
          IF( sf_tsd(jp_sal)%ln_tint )   DEALLOCATE( sf_tsd(jp_sal)%fdta )
                                         DEALLOCATE( sf_tsd              )     ! the structure itself
-         IF(lwp) WRITE(numout,*) 'dta_tsd: deallocte T & S arrays as they are only use to initialize the run'
-                                        DEALLOCATE( sf_tsddmp(jp_tem)%fnow )     ! T arrays in the structure
-         IF( sf_tsddmp(jp_tem)%ln_tint )   DEALLOCATE( sf_tsddmp(jp_tem)%fdta )
-                                        DEALLOCATE( sf_tsddmp(jp_sal)%fnow )     ! S arrays in the structure
-         IF( sf_tsddmp(jp_sal)%ln_tint )   DEALLOCATE( sf_tsddmp(jp_sal)%fdta )
-                                        DEALLOCATE( sf_tsddmp              )     ! the structure itself
       ENDIF
       !
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/istate.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/istate.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/istate.F90	(revision 5779)
@@ -47,5 +47,5 @@
    USE wrk_nemo        ! Memory allocation
    USE timing          ! Timing
-   USE sbc_iscpl
+   USE iscplrst
 
    IMPLICIT NONE
@@ -91,7 +91,7 @@
       IF( ln_rstart ) THEN                    ! Restart from a file
          !                                    ! -------------------
-         CALL rst_read                           ! Read the restart file
-         IF (ln_iscpl) CALL rst_iscpl            ! extraloate restart to wet and dry
-         CALL day_init                           ! model calendar (using both namelist and restart infos)
+         CALL rst_read                        ! Read the restart file
+         IF (ln_iscpl)       CALL iscpl_stp   ! extraloate restart to wet and dry
+         CALL day_init                        ! model calendar (using both namelist and restart infos)
       ELSE
          !                                    ! Start from rest
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/phycst.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/phycst.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DOM/phycst.F90	(revision 5779)
@@ -73,5 +73,5 @@
    REAL(wp), PUBLIC ::   xlsn                        !: = lfus*rhosn (volumetric latent heat fusion of snow)  [J/m3]
 #else
-   REAL(wp), PUBLIC ::   rhoic    =  917._wp         !: volumic mass of sea ice                               [kg/m3]
+   REAL(wp), PUBLIC ::   rhoic    =  900._wp         !: volumic mass of sea ice                               [kg/m3]
    REAL(wp), PUBLIC ::   rcdic    =    2.034396_wp   !: conductivity of the ice                               [W/m/K]
    REAL(wp), PUBLIC ::   rcpic    =    1.8837e+6_wp  !: volumetric specific heat for ice                      [J/m3/K]
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DYN/divcur.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DYN/divcur.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/DYN/divcur.F90	(revision 5779)
@@ -29,5 +29,6 @@
    USE sbcrnf          ! river runoff 
    USE sbcisf          ! ice shelf 
-   USE sbc_iscpl        ! ice shelf 
+   USE iscplhsb       ! ice sheet / ocean coupling
+   USE iscplini        !
    USE cla             ! cross land advection             (cla_div routine)
    USE in_out_manager  ! I/O manager
@@ -330,5 +331,5 @@
       IF( ln_rnf      )   CALL sbc_rnf_div( hdivn )                            ! runoffs (update hdivn field)
       IF( ln_divisf .AND. (nn_isf .GT. 0) )   CALL sbc_isf_div  ( hdivn )      ! ice shelf (update hdivn field)
-      IF( ln_iscpl  .AND. ln_hfb )            CALL sbc_iscpl_div( hdivn )      ! ice shelf (update hdivn field)
+      IF( ln_iscpl  .AND. ln_hsb )            CALL iscpl_div( hdivn )      ! ice shelf (update hdivn field)
       IF( nn_cla == 1 )   CALL cla_div    ( kt )             ! Cross Land Advection (update hdivn field)
       !
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90	(revision 5779)
@@ -24,5 +24,4 @@
    USE trdmxl_oce      ! ocean active mixed layer tracers trends variables
    USE divcur          ! hor. divergence and curl      (div & cur routines)
-   USE wrk_nemo
 
    IMPLICIT NONE
@@ -147,6 +146,4 @@
 #endif
 
-
-
                   IF ( ln_iscpl ) THEN 
                      CALL iom_rstput( kt, nitrst, numrow, 'tmask'  , tmask     ) ! need to extrapolate T/S
@@ -154,8 +151,8 @@
                      CALL iom_rstput( kt, nitrst, numrow, 'vmask'  , vmask     ) ! need to correct barotropic velocity
                      CALL iom_rstput( kt, nitrst, numrow, 'smask'  , ssmask    ) ! need to correct barotropic velocity
-                     CALL iom_rstput( kt, nitrst, numrow, 'fse3t_n', fse3t_n(:,:,:) ) ! need to compute temperature correction
-                     CALL iom_rstput( kt, nitrst, numrow, 'fse3u_n', fse3u_n(:,:,:) ) ! need to compute volume      correction  ????
-                     CALL iom_rstput( kt, nitrst, numrow, 'fse3v_n', fse3v_n(:,:,:) ) ! need to compute volume      correction  ????
-                     CALL iom_rstput( kt, nitrst, numrow, 'fsdepw_n', fsdepw_n(:,:,:) ) ! need to compute volume      correction  ????
+                     CALL iom_rstput( kt, nitrst, numrow, 'fse3t_n', fse3t_n(:,:,:) )   ! need to compute temperature correction
+                     CALL iom_rstput( kt, nitrst, numrow, 'fse3u_n', fse3u_n(:,:,:) )   ! need to compute bt conservation
+                     CALL iom_rstput( kt, nitrst, numrow, 'fse3v_n', fse3v_n(:,:,:) )   ! need to compute bt conservation
+                     CALL iom_rstput( kt, nitrst, numrow, 'fsdepw_n', fsdepw_n(:,:,:) ) ! need to compute extrapolation if vvl
                   END IF
       IF( kt == nitrst ) THEN
@@ -221,5 +218,4 @@
       REAL(wp) ::   zrdt, zrdttra1
       INTEGER  ::   jk
-      LOGICAL  ::   llok
       !!----------------------------------------------------------------------
 
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/LBC/lbclnk.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/LBC/lbclnk.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/LBC/lbclnk.F90	(revision 5779)
@@ -32,5 +32,5 @@
 
    INTERFACE lbc_sum
-      MODULE PROCEDURE mpp_sum_3d, mpp_sum_2d
+      MODULE PROCEDURE mpp_lnk_sum_3d, mpp_lnk_sum_2d
    END INTERFACE
 
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 5779)
@@ -72,5 +72,5 @@
    PUBLIC   mpp_lnk_3d, mpp_lnk_3d_gather, mpp_lnk_2d, mpp_lnk_2d_e
    PUBLIC   mpp_lnk_2d_9 
-   PUBLIC   mpp_sum_3d, mpp_sum_2d
+   PUBLIC   mpp_lnk_sum_3d, mpp_lnk_sum_2d
    PUBLIC   mppscatter, mppgather
    PUBLIC   mpp_ini_ice, mpp_ini_znl
@@ -1395,9 +1395,9 @@
    END SUBROUTINE mpp_lnk_2d_e
 
-   SUBROUTINE mpp_sum_3d( ptab, cd_type, psgn, cd_mpp, pval )
-      !!----------------------------------------------------------------------
-      !!                  ***  routine mpp_sum_3d  ***
-      !!
-      !! ** Purpose :   Message passing manadgement
+   SUBROUTINE mpp_lnk_sum_3d( ptab, cd_type, psgn, cd_mpp, pval )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mpp_lnk_sum_3d  ***
+      !!
+      !! ** Purpose :   Message passing manadgement (sum in the overlap region)
       !!
       !! ** Method  :   Use mppsend and mpprecv function for passing mask
@@ -1445,42 +1445,9 @@
       ! 1. standard boundary treatment
       ! ------------------------------
-      IF( PRESENT( cd_mpp ) ) THEN      ! only fill added line/raw with existing values
-         !
-         ! WARNING ptab is defined only between nld and nle
-!         DO jk = 1, jpk
-!            DO jj = nlcj+1, jpj                 ! added line(s)   (inner only)
-!               ptab(nldi  :nlei  , jj          ,jk) = ptab(nldi:nlei,     nlej,jk)
-!               ptab(1     :nldi-1, jj          ,jk) = ptab(nldi     ,     nlej,jk)
-!               ptab(nlei+1:nlci  , jj          ,jk) = ptab(     nlei,     nlej,jk)
-!            END DO
-!            DO ji = nlci+1, jpi                 ! added column(s) (full)
-!               ptab(ji           ,nldj  :nlej  ,jk) = ptab(     nlei,nldj:nlej,jk)
-!               ptab(ji           ,1     :nldj-1,jk) = ptab(     nlei,nldj     ,jk)
-!               ptab(ji           ,nlej+1:jpj   ,jk) = ptab(     nlei,     nlej,jk)
-!            END DO
-!         END DO
-         !
-      ELSE                              ! standard close or cyclic treatment
-         !
-         !                                   ! East-West boundaries
-         !                                        !* Cyclic east-west
-         IF( nbondi == 2 .AND. (nperio == 1 .OR. nperio == 4 .OR. nperio == 6) ) THEN
-!            ptab( 1 ,:,:) = ptab(jpim1,:,:)
-!            ptab(jpi,:,:) = ptab(  2  ,:,:)
-         ELSE                                     !* closed
-!            IF( .NOT. cd_type == 'F' )   ptab(     1       :jpreci,:,:) = zland    ! south except F-point
-!                                         ptab(nlci-jpreci+1:jpi   ,:,:) = zland    ! north
-         ENDIF
-         !                                   ! North-South boundaries (always closed)
-!         IF( .NOT. cd_type == 'F' )   ptab(:,     1       :jprecj,:) = zland       ! south except F-point
-!                                      ptab(:,nlcj-jprecj+1:jpj   ,:) = zland       ! north
-         !
-      ENDIF
-
       ! 2. East and west directions exchange
       ! ------------------------------------
       ! we play with the neigbours AND the row number because of the periodicity
       !
-      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
+      SELECT CASE ( nbondi )      ! Read lateral conditions
       CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case)
       iihom = nlci-jpreci
@@ -1512,5 +1479,5 @@
       END SELECT
       !
-      !                           ! Write Dirichlet lateral conditions
+      !                           ! Write lateral conditions
       iihom = nlci-nreci
       !
@@ -1536,5 +1503,5 @@
       ! always closed : we play only with the neigbours
       !
-      IF( nbondj /= 2 ) THEN      ! Read Dirichlet lateral conditions
+      IF( nbondj /= 2 ) THEN      ! Read lateral conditions
          ijhom = nlcj-jprecj
          DO jl = 1, jprecj
@@ -1565,5 +1532,5 @@
       END SELECT
       !
-      !                           ! Write Dirichlet lateral conditions
+      !                           ! Write lateral conditions
       ijhom = nlcj-nrecj
       !
@@ -1599,11 +1566,11 @@
       DEALLOCATE( zt3ns, zt3sn, zt3ew, zt3we )
       !
-   END SUBROUTINE mpp_sum_3d
-
-   SUBROUTINE mpp_sum_2d( pt2d, cd_type, psgn, cd_mpp, pval )
-      !!----------------------------------------------------------------------
-      !!                  ***  routine mpp_sum_2d  ***
-      !!
-      !! ** Purpose :   Message passing manadgement for 2d array
+   END SUBROUTINE mpp_lnk_sum_3d
+
+   SUBROUTINE mpp_lnk_sum_2d( pt2d, cd_type, psgn, cd_mpp, pval )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mpp_lnk_sum_2d  ***
+      !!
+      !! ** Purpose :   Message passing manadgement for 2d array (sum in the overlap region)
       !!
       !! ** Method  :   Use mppsend and mpprecv function for passing mask
@@ -1649,41 +1616,9 @@
       ! 1. standard boundary treatment
       ! ------------------------------
-      !
-!      IF( PRESENT( cd_mpp ) ) THEN      ! only fill added line/raw with existing values
-!         !
-!         ! WARNING pt2d is defined only between nld and nle
-!         DO jj = nlcj+1, jpj                 ! added line(s)   (inner only)
-!            pt2d(nldi  :nlei  , jj          ) = pt2d(nldi:nlei,     nlej)
-!            pt2d(1     :nldi-1, jj          ) = pt2d(nldi     ,     nlej)
-!            pt2d(nlei+1:nlci  , jj          ) = pt2d(     nlei,     nlej)
-!         END DO
-!         DO ji = nlci+1, jpi                 ! added column(s) (full)
-!            pt2d(ji           ,nldj  :nlej  ) = pt2d(     nlei,nldj:nlej)
-!            pt2d(ji           ,1     :nldj-1) = pt2d(     nlei,nldj     )
-!            pt2d(ji           ,nlej+1:jpj   ) = pt2d(     nlei,     nlej)
-!         END DO
-!         !
-!      ELSE                              ! standard close or cyclic treatment
-!         !
-!         !                                   ! East-West boundaries
-!         IF( nbondi == 2 .AND.   &                ! Cyclic east-west
-!            &    (nperio == 1 .OR. nperio == 4 .OR. nperio == 6) ) THEN
-!            pt2d( 1 ,:) = pt2d(jpim1,:)                                    ! west
-!            pt2d(jpi,:) = pt2d(  2  ,:)                                    ! east
-!         ELSE                                     ! closed
-!            IF( .NOT. cd_type == 'F' )   pt2d(     1       :jpreci,:) = zland    ! south except F-point
-!                                         pt2d(nlci-jpreci+1:jpi   ,:) = zland    ! north
-!         ENDIF
-!         !                                   ! North-South boundaries (always closed)
-!            IF( .NOT. cd_type == 'F' )   pt2d(:,     1       :jprecj) = zland    !south except F-point
-!                                         pt2d(:,nlcj-jprecj+1:jpj   ) = zland    ! north
-!         !
-!      ENDIF
-
       ! 2. East and west directions exchange
       ! ------------------------------------
       ! we play with the neigbours AND the row number because of the periodicity
       !
-      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
+      SELECT CASE ( nbondi )      ! Read lateral conditions
       CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case)
          iihom = nlci - jpreci
@@ -1715,5 +1650,5 @@
       END SELECT
       !
-      !                           ! Write Dirichlet lateral conditions
+      !                           ! Write lateral conditions
       iihom = nlci-nreci
       !
@@ -1739,5 +1674,5 @@
       ! always closed : we play only with the neigbours
       !
-      IF( nbondj /= 2 ) THEN      ! Read Dirichlet lateral conditions
+      IF( nbondj /= 2 ) THEN      ! Read lateral conditions
          ijhom = nlcj - jprecj
          DO jl = 1, jprecj
@@ -1768,5 +1703,5 @@
       END SELECT
       !
-      !                           ! Write Dirichlet lateral conditions
+      !                           ! Write lateral conditions
       ijhom = nlcj-nrecj
       !
@@ -1802,5 +1737,5 @@
       DEALLOCATE( zt2ns, zt2sn, zt2ew, zt2we )
       !
-   END SUBROUTINE mpp_sum_2d
+   END SUBROUTINE mpp_lnk_sum_2d
 
    SUBROUTINE mppsend( ktyp, pmess, kbytes, kdest, md_req )
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/SBC/sbcfwb.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/SBC/sbcfwb.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/SBC/sbcfwb.F90	(revision 5779)
@@ -111,5 +111,4 @@
             zcoef = z_fwf * rcp
             emp(:,:) = emp(:,:) - z_fwf              * tmask(:,:,1)
-            sfx(:,:) = sfx(:,:) + z_fwf * sss_m      * tmask(:,:,1)
             qns(:,:) = qns(:,:) + zcoef * sst_m(:,:) * tmask(:,:,1) ! account for change to the heat budget due to fw correction
          ENDIF
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/SBC/sbcisf.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/SBC/sbcisf.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/SBC/sbcisf.F90	(revision 5779)
@@ -63,5 +63,5 @@
 
    REAL(wp), PUBLIC, SAVE ::   rcpi   = 2000.0_wp     ! phycst ?
-   REAL(wp), PUBLIC, SAVE ::   kappa  =    0.0_wp    ! phycst ?
+   REAL(wp), PUBLIC, SAVE ::   kappa  = 1.54e-6_wp    ! phycst ?
    REAL(wp), PUBLIC, SAVE ::   rhoisf = 920.0_wp      ! phycst ?
    REAL(wp), PUBLIC, SAVE ::   tsurf  = -20.0_wp      ! phycst ?
@@ -152,6 +152,7 @@
             !: read effective lenght (BG03)
             IF (nn_isf == 2) THEN
-               cvarLeff = 'soLeff' 
+               ! Read Data and save some integral values
                CALL iom_open( sn_Leff_isf%clname, inum )
+               cvarLeff  = 'soLeff'               !: variable name for Efficient Length scale
                CALL iom_get( inum, jpdom_data, cvarLeff, risfLeff , 1)
                CALL iom_close(inum)
@@ -297,6 +298,6 @@
          ! 
          ! output
-         IF( iom_use('qisf'  ) )   CALL iom_put('qisf'  , qisf)
-         IF( iom_use('fwfisf') )   CALL iom_put('fwfisf', fwfisf)
+         CALL iom_put('qisf'  , qisf)
+         IF( iom_use('fwfisf') )   CALL iom_put('fwfisf', fwfisf * stbl(:,:) / soce )
       END IF
   
@@ -528,5 +529,5 @@
 ! zwflx is upward water flux
 ! If non conservative we have zcfac=0.0 so what follows is then zfwflx*sss_m/zsfrz
-!!!!!!!!                     zfwflx = ( zgammas*rau0 - zcfac*zfwflx ) * (zsfrz - stbl(ji,jj)) / stbl(ji,jj)
+                     zfwflx = ( zgammas*rau0 - zcfac*zfwflx ) * (zsfrz - stbl(ji,jj)) / stbl(ji,jj)
 ! test convergence and compute gammat
                      IF (( zhtflx - zhtflx_b) .LE. 0.01 ) lit = .FALSE.
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2.F90	(revision 5779)
@@ -921,5 +921,5 @@
                pn2(ji,jj,jk) = grav * (  zaw * ( pts(ji,jj,jk-1,jp_tem) - pts(ji,jj,jk,jp_tem) )     &
                   &                    - zbw * ( pts(ji,jj,jk-1,jp_sal) - pts(ji,jj,jk,jp_sal) )  )  &
-                  &            / fse3w(ji,jj,jk) * wmask(ji,jj,jk)
+                  &            / fse3w(ji,jj,jk) * tmask(ji,jj,jk)
             END DO
          END DO
@@ -1242,5 +1242,5 @@
       !
       rau0        = 1026._wp                 !: volumic mass of reference     [kg/m3]
-      rcp         = 3974._wp      !: heat capacity     [J/K]
+      rcp         = 3991.86795711963_wp      !: heat capacity     [J/K]
       !
       IF(lwp) THEN                ! Control print
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/TRA/tradmp.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/TRA/tradmp.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/TRA/tradmp.F90	(revision 5779)
@@ -102,13 +102,11 @@
       REAL(wp) ::   zta, zsa             ! local scalars
       REAL(wp), POINTER, DIMENSION(:,:,:,:) ::  zts_dta 
-      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::  zts_dtadmp 
       !!----------------------------------------------------------------------
       !
       IF( nn_timing == 1 )  CALL timing_start( 'tra_dmp')
       !
-      CALL wrk_alloc( jpi, jpj, jpk, jpts,  zts_dta, zts_dtadmp )
+      CALL wrk_alloc( jpi, jpj, jpk, jpts,  zts_dta )
       !                           !==   input T-S data at kt   ==!
-      CALL dta_tsd( kt, zts_dta, zts_dtadmp )            ! read and interpolates T-S data at kt
-      zts_dta=zts_dtadmp
+      CALL dta_tsd( kt, zts_dta )            ! read and interpolates T-S data at kt
       !
       SELECT CASE ( nn_zdmp )     !==    type of damping   ==!
@@ -176,5 +174,5 @@
          &                       tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
       !
-      CALL wrk_dealloc( jpi, jpj, jpk, jpts,  zts_dta, zts_dtadmp )
+      CALL wrk_dealloc( jpi, jpj, jpk, jpts,  zts_dta )
       !
       IF( nn_timing == 1 )  CALL timing_stop( 'tra_dmp')
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/TRA/trasbc.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/TRA/trasbc.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/TRA/trasbc.F90	(revision 5779)
@@ -22,5 +22,5 @@
    USE sbcrnf          ! River runoff  
    USE sbcisf          ! Ice shelf   
-   USE sbc_iscpl       ! Ice sheet coupling
+   USE iscplini       ! Ice sheet coupling
    USE traqsr          ! solar radiation penetration
    USE trd_oce         ! trends: ocean variables
@@ -291,5 +291,5 @@
       !----------------------------------------
       !
-      IF( ln_iscpl .AND. ln_hfb) THEN         ! input of heat and salt due to river runoff 
+      IF( ln_iscpl .AND. ln_hsb) THEN         ! input of heat and salt due to river runoff 
          DO jk = 1,jpk
             DO jj = 2, jpj 
Index: /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/lib_fortran.F90
===================================================================
--- /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/lib_fortran.F90	(revision 5778)
+++ /branches/NERC/dev_r5589_is_oce_cpl/NEMOGCM/NEMO/OPA_SRC/lib_fortran.F90	(revision 5779)
@@ -163,10 +163,10 @@
    FUNCTION glob_sum_full_2d( ptab )
       !!----------------------------------------------------------------------
-      !!                  ***  FUNCTION  glob_sum_2d ***
-      !!
-      !! ** Purpose : perform a sum in calling DDPDD routine
+      !!                  ***  FUNCTION  glob_sum_full_2d ***
+      !!
+      !! ** Purpose : perform a sum in calling DDPDD routine (nomask)
       !!----------------------------------------------------------------------
       REAL(wp), INTENT(in), DIMENSION(:,:) ::   ptab
-      REAL(wp)                             ::   glob_sum_full_2d   ! global masked sum
+      REAL(wp)                             ::   glob_sum_full_2d   ! global sum
       !!
       !!-----------------------------------------------------------------------
@@ -179,10 +179,10 @@
    FUNCTION glob_sum_full_3d( ptab )
       !!----------------------------------------------------------------------
-      !!                  ***  FUNCTION  glob_sum_3d ***
-      !!
-      !! ** Purpose : perform a sum on a 3D array in calling DDPDD routine
+      !!                  ***  FUNCTION  glob_sum_full_3d ***
+      !!
+      !! ** Purpose : perform a sum on a 3D array in calling DDPDD routine (nomask)
       !!----------------------------------------------------------------------
       REAL(wp), INTENT(in), DIMENSION(:,:,:) ::   ptab
-      REAL(wp)                               ::   glob_sum_full_3d   ! global masked sum
+      REAL(wp)                               ::   glob_sum_full_3d   ! global sum
       !!
       INTEGER    ::   ji, jj, jk   ! dummy loop indices
@@ -192,7 +192,7 @@
       ijpk = SIZE(ptab,3)
       !
-      glob_sum_3d = 0.e0
+      glob_sum_full_3d = 0.e0
       DO jk = 1, ijpk
-         glob_sum_3d = glob_sum_3d + SUM( ptab(:,:,jk) )
+         glob_sum_full_3d = glob_sum_full_3d + SUM( ptab(:,:,jk) )
       END DO
       IF( lk_mpp )   CALL mpp_sum( glob_sum_full_3d )
