Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ASM/README.rst
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ASM/README.rst	(revision 10288)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ASM/README.rst	(revision 10288)
@@ -0,0 +1,1 @@
+link ../../../doc/rst/source/data_assimilation.rst
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ASM/asmbkg.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ASM/asmbkg.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ASM/asmbkg.F90	(revision 10288)
@@ -48,5 +48,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ASM/asminc.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ASM/asminc.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ASM/asminc.F90	(revision 10288)
@@ -98,5 +98,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ASM/asmpar.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ASM/asmpar.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ASM/asmpar.F90	(revision 10288)
@@ -25,5 +25,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!======================================================================
 END MODULE asmpar
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdy_oce.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdy_oce.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdy_oce.F90	(revision 10288)
@@ -142,5 +142,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdydta.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdydta.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdydta.F90	(revision 10288)
@@ -60,5 +60,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -351,12 +351,13 @@
                ENDIF
 #if defined key_si3
+               ! convert N-cat fields (input) into jpl-cat (output)
                IF( cn_ice(jbdy) /= 'none' .AND. nn_ice_dta(jbdy) == 1 ) THEN
                   jfld_hti = jfld_htit(jbdy)
                   jfld_hts = jfld_htst(jbdy)
                   jfld_ai  = jfld_ait(jbdy)
-                  IF( nice_cat == 1 ) THEN ! case input cat = 1
+                  IF    ( jpl /= 1 .AND. nice_cat == 1 ) THEN                       ! case input cat = 1
                      CALL ice_var_itd ( bf(jfld_hti)%fnow(:,1,1), bf(jfld_hts)%fnow(:,1,1), bf(jfld_ai)%fnow(:,1,1), &
                         &               dta_bdy(jbdy)%h_i     , dta_bdy(jbdy)%h_s     , dta_bdy(jbdy)%a_i    )
-                  ELSEIF( nice_cat /= 1 .AND. nice_cat /= jpl ) THEN ! case input cat /=1 and /=jpl
+                  ELSEIF( jpl /= 1 .AND. nice_cat /= 1 .AND. nice_cat /= jpl ) THEN ! case input cat /=1 and /=jpl
                      CALL ice_var_itd2( bf(jfld_hti)%fnow(:,1,:), bf(jfld_hts)%fnow(:,1,:), bf(jfld_ai)%fnow(:,1,:), &
                         &               dta_bdy(jbdy)%h_i     , dta_bdy(jbdy)%h_s     , dta_bdy(jbdy)%a_i    )
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdydyn.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdydyn.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdydyn.F90	(revision 10288)
@@ -33,5 +33,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdydyn2d.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdydyn2d.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdydyn2d.F90	(revision 10288)
@@ -32,5 +32,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdydyn3d.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdydyn3d.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdydyn3d.F90	(revision 10288)
@@ -28,5 +28,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdyice.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdyice.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdyice.F90	(revision 10288)
@@ -18,5 +18,5 @@
    USE ice             ! sea-ice: variables
    USE icevar          ! sea-ice: operations
-   USE iceitd          ! sea-ice: rebining
+   USE icecor          ! sea-ice: corrections
    USE icectl          ! sea-ice: control prints
    USE phycst          ! physical constant
@@ -41,6 +41,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: bdyice.F90 8306 2017-07-10 10:18:03Z clem $
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -50,21 +50,21 @@
       !!                  ***  SUBROUTINE bdy_ice  ***
       !!
-      !! ** Purpose : - Apply open boundary conditions for ice (SI3)
+      !! ** Purpose : Apply open boundary conditions for sea ice
       !!
       !!----------------------------------------------------------------------
       INTEGER, INTENT(in) ::   kt   ! Main time step counter
       !
-      INTEGER ::   ib_bdy   ! Loop index
+      INTEGER ::   jbdy   ! BDY set index
       !!----------------------------------------------------------------------
       !
-      IF( ln_timing )   CALL timing_start('bdy_ice')
+      IF( ln_timing )   CALL timing_start('bdy_ice_thd')
       !
       CALL ice_var_glo2eqv
       !
-      DO ib_bdy = 1, nb_bdy
-         !
-         SELECT CASE( cn_ice(ib_bdy) )
+      DO jbdy = 1, nb_bdy
+         !
+         SELECT CASE( cn_ice(jbdy) )
          CASE('none')   ;   CYCLE
-         CASE('frs' )   ;   CALL bdy_ice_frs( idx_bdy(ib_bdy), dta_bdy(ib_bdy), kt, ib_bdy )
+         CASE('frs' )   ;   CALL bdy_ice_frs( idx_bdy(jbdy), dta_bdy(jbdy), kt, jbdy )
          CASE DEFAULT
             CALL ctl_stop( 'bdy_ice : unrecognised option for open boundaries for ice fields' )
@@ -73,19 +73,20 @@
       END DO
       !
-      CALL ice_var_zapsmall
+      CALL ice_cor( kt , 0 )      ! -- In case categories are out of bounds, do a remapping
+      !                           !    i.e. inputs have not the same ice thickness distribution (set by rn_himean)
+      !                           !         than the regional simulation
       CALL ice_var_agg(1)
       !
       IF( ln_icectl )   CALL ice_prt( kt, iiceprt, jiceprt, 1, ' - ice thermo bdy - ' )
-      IF( ln_timing )   CALL timing_stop('bdy_ice')
+      IF( ln_timing )   CALL timing_stop('bdy_ice_thd')
       !
    END SUBROUTINE bdy_ice
 
 
-   SUBROUTINE bdy_ice_frs( idx, dta, kt, ib_bdy )
+   SUBROUTINE bdy_ice_frs( idx, dta, kt, jbdy )
       !!------------------------------------------------------------------------------
       !!                 ***  SUBROUTINE bdy_ice_frs  ***
       !!                    
-      !! ** Purpose : Apply the Flow Relaxation Scheme for sea-ice fields in the case 
-      !!              of unstructured open boundaries.
+      !! ** Purpose : Apply the Flow Relaxation Scheme for sea-ice fields
       !! 
       !! Reference : Engedahl H., 1995: Use of the flow relaxation scheme in a three-
@@ -95,10 +96,10 @@
       TYPE(OBC_DATA),  INTENT(in) ::   dta     ! OBC external data
       INTEGER,         INTENT(in) ::   kt      ! main time-step counter
-      INTEGER,         INTENT(in) ::   ib_bdy  ! BDY set index
+      INTEGER,         INTENT(in) ::   jbdy    ! BDY set index
       !
       INTEGER  ::   jpbound            ! 0 = incoming ice
       !                                ! 1 = outgoing ice
-      INTEGER  ::   jb, jk, jgrd, jl   ! dummy loop indices
-      INTEGER  ::   ji, jj, ii, ij     ! local scalar
+      INTEGER  ::   i_bdy, jgrd        ! dummy loop indices
+      INTEGER  ::   ji, jj, jk, jl, ib, jb
       REAL(wp) ::   zwgt, zwgt1        ! local scalar
       REAL(wp) ::   ztmelts, zdh
@@ -108,12 +109,12 @@
       !
       DO jl = 1, jpl
-         DO jb = 1, idx%nblenrim(jgrd)
-            ji    = idx%nbi(jb,jgrd)
-            jj    = idx%nbj(jb,jgrd)
-            zwgt  = idx%nbw(jb,jgrd)
-            zwgt1 = 1.e0 - idx%nbw(jb,jgrd)
-            a_i(ji,jj,jl) = ( a_i(ji,jj,jl) * zwgt1 + dta%a_i(jb,jl) * zwgt ) * tmask(ji,jj,1)  ! Leads fraction 
-            h_i(ji,jj,jl) = ( h_i(ji,jj,jl) * zwgt1 + dta%h_i(jb,jl) * zwgt ) * tmask(ji,jj,1)  ! Ice depth 
-            h_s(ji,jj,jl) = ( h_s(ji,jj,jl) * zwgt1 + dta%h_s(jb,jl) * zwgt ) * tmask(ji,jj,1)  ! Snow depth
+         DO i_bdy = 1, idx%nblenrim(jgrd)
+            ji    = idx%nbi(i_bdy,jgrd)
+            jj    = idx%nbj(i_bdy,jgrd)
+            zwgt  = idx%nbw(i_bdy,jgrd)
+            zwgt1 = 1.e0 - idx%nbw(i_bdy,jgrd)
+            a_i(ji,jj,jl) = ( a_i(ji,jj,jl) * zwgt1 + dta%a_i(i_bdy,jl) * zwgt ) * tmask(ji,jj,1)  ! Leads fraction 
+            h_i(ji,jj,jl) = ( h_i(ji,jj,jl) * zwgt1 + dta%h_i(i_bdy,jl) * zwgt ) * tmask(ji,jj,1)  ! Ice depth 
+            h_s(ji,jj,jl) = ( h_s(ji,jj,jl) * zwgt1 + dta%h_s(i_bdy,jl) * zwgt ) * tmask(ji,jj,1)  ! Snow depth
 
             ! -----------------
@@ -124,134 +125,138 @@
 
             ! Then, a) transfer the snow excess into the ice (different from icethd_dh)
-            zdh = MAX( 0._wp, ( rhosn * h_s(ji,jj,jl) + ( rhoic - rau0 ) * h_i(ji,jj,jl) ) * r1_rau0 )
+            zdh = MAX( 0._wp, ( rhos * h_s(ji,jj,jl) + ( rhoi - rau0 ) * h_i(ji,jj,jl) ) * r1_rau0 )
             ! Or, b) transfer all the snow into ice (if incoming ice is likely to melt as it comes into a warmer environment)
-            !zdh = MAX( 0._wp, h_s(ji,jj,jl) * rhosn / rhoic )
+            !zdh = MAX( 0._wp, h_s(ji,jj,jl) * rhos / rhoi )
 
             ! recompute h_i, h_s
             h_i(ji,jj,jl) = MIN( hi_max(jl), h_i(ji,jj,jl) + zdh )
-            h_s(ji,jj,jl) = MAX( 0._wp, h_s(ji,jj,jl) - zdh * rhoic / rhosn ) 
+            h_s(ji,jj,jl) = MAX( 0._wp, h_s(ji,jj,jl) - zdh * rhoi / rhos ) 
 
          ENDDO
-         CALL lbc_bdy_lnk( a_i(:,:,jl), 'T', 1., ib_bdy )
-         CALL lbc_bdy_lnk( h_i(:,:,jl), 'T', 1., ib_bdy )
-         CALL lbc_bdy_lnk( h_s(:,:,jl), 'T', 1., ib_bdy )
       ENDDO
-      ! retrieve at_i
-      at_i(:,:) = 0._wp
+      CALL lbc_bdy_lnk( a_i(:,:,:), 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( h_i(:,:,:), 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( h_s(:,:,:), 'T', 1., jbdy )
+
       DO jl = 1, jpl
-         at_i(:,:) = a_i(:,:,jl) + at_i(:,:)
-      END DO
-
-      DO jl = 1, jpl
-         DO jb = 1, idx%nblenrim(jgrd)
-            ji    = idx%nbi(jb,jgrd)
-            jj    = idx%nbj(jb,jgrd)
+         DO i_bdy = 1, idx%nblenrim(jgrd)
+            ji = idx%nbi(i_bdy,jgrd)
+            jj = idx%nbj(i_bdy,jgrd)
 
             ! condition on ice thickness depends on the ice velocity
             ! if velocity is outward (strictly), then ice thickness, volume... must be equal to adjacent values
-            jpbound = 0   ;   ii = ji   ;   ij = jj
-            !
-            IF( u_ice(ji+1,jj  ) < 0. .AND. umask(ji-1,jj  ,1) == 0. ) jpbound = 1; ii = ji+1; ij = jj
-            IF( u_ice(ji-1,jj  ) > 0. .AND. umask(ji+1,jj  ,1) == 0. ) jpbound = 1; ii = ji-1; ij = jj
-            IF( v_ice(ji  ,jj+1) < 0. .AND. vmask(ji  ,jj-1,1) == 0. ) jpbound = 1; ii = ji  ; ij = jj+1
-            IF( v_ice(ji  ,jj-1) > 0. .AND. vmask(ji  ,jj+1,1) == 0. ) jpbound = 1; ii = ji  ; ij = jj-1
-            !
-            IF( nn_ice_dta(ib_bdy) == 0 ) jpbound = 0; ii = ji; ij = jj   ! case ice boundaries = initial conditions
-            !                                                             !      do not make state variables dependent on velocity
-            !
-            rswitch = MAX( 0.0_wp , SIGN ( 1.0_wp , at_i(ii,ij) - 0.01 ) ) ! 0 if no ice
-            !
-            ! concentration and thickness
-            a_i(ji,jj,jl) = a_i(ii,ij,jl) * rswitch
-            h_i(ji,jj,jl) = h_i(ii,ij,jl) * rswitch
-            h_s(ji,jj,jl) = h_s(ii,ij,jl) * rswitch
-            !
-            ! Ice and snow volumes
-            v_i(ji,jj,jl) = h_i(ji,jj,jl) * a_i(ji,jj,jl)
-            v_s(ji,jj,jl) = h_s(ji,jj,jl) * a_i(ji,jj,jl)
-            !
-            SELECT CASE( jpbound )
-            !
-            CASE( 0 )   ! velocity is inward
-               !
-               ! Ice salinity, age, temperature
-               s_i (ji,jj,jl)   = rswitch * rn_ice_sal(ib_bdy)  + ( 1.0 - rswitch ) * rn_simin
-               oa_i(ji,jj,jl)   = rswitch * rn_ice_age(ib_bdy) * a_i(ji,jj,jl)
-               t_su(ji,jj,jl)   = rswitch * rn_ice_tem(ib_bdy)  + ( 1.0 - rswitch ) * rn_ice_tem(ib_bdy)
+            jpbound = 0   ;   ib = ji   ;   jb = jj
+            !
+            IF( u_ice(ji+1,jj  ) < 0. .AND. umask(ji-1,jj  ,1) == 0. )   jpbound = 1 ; ib = ji+1 ; jb = jj
+            IF( u_ice(ji-1,jj  ) > 0. .AND. umask(ji+1,jj  ,1) == 0. )   jpbound = 1 ; ib = ji-1 ; jb = jj
+            IF( v_ice(ji  ,jj+1) < 0. .AND. vmask(ji  ,jj-1,1) == 0. )   jpbound = 1 ; ib = ji   ; jb = jj+1
+            IF( v_ice(ji  ,jj-1) > 0. .AND. vmask(ji  ,jj+1,1) == 0. )   jpbound = 1 ; ib = ji   ; jb = jj-1
+            !
+            IF( nn_ice_dta(jbdy) == 0 )   jpbound = 0 ; ib = ji ; jb = jj   ! case ice boundaries = initial conditions
+            !                                                               !      do not make state variables dependent on velocity
+            !
+            IF( a_i(ib,jb,jl) > 0._wp ) THEN   ! there is ice at the boundary
+               !
+               a_i(ji,jj,jl) = a_i(ib,jb,jl) ! concentration
+               h_i(ji,jj,jl) = h_i(ib,jb,jl) ! thickness ice
+               h_s(ji,jj,jl) = h_s(ib,jb,jl) ! thickness snw
+               !
+               SELECT CASE( jpbound )
+                  !
+               CASE( 0 )   ! velocity is inward
+                  !
+                  oa_i(ji,jj,  jl) = rn_ice_age(jbdy) * a_i(ji,jj,jl) ! age
+                  a_ip(ji,jj,  jl) = 0._wp                            ! pond concentration
+                  v_ip(ji,jj,  jl) = 0._wp                            ! pond volume
+                  t_su(ji,jj,  jl) = rn_ice_tem(jbdy)                 ! temperature surface
+                  t_s (ji,jj,:,jl) = rn_ice_tem(jbdy)                 ! temperature snw
+                  t_i (ji,jj,:,jl) = rn_ice_tem(jbdy)                 ! temperature ice
+                  s_i (ji,jj,  jl) = rn_ice_sal(jbdy)                 ! salinity
+                  sz_i(ji,jj,:,jl) = rn_ice_sal(jbdy)                 ! salinity profile
+                  !
+               CASE( 1 )   ! velocity is outward
+                  !
+                  oa_i(ji,jj,  jl) = oa_i(ib,jb,  jl) ! age
+                  a_ip(ji,jj,  jl) = a_ip(ib,jb,  jl) ! pond concentration
+                  v_ip(ji,jj,  jl) = v_ip(ib,jb,  jl) ! pond volume
+                  t_su(ji,jj,  jl) = t_su(ib,jb,  jl) ! temperature surface
+                  t_s (ji,jj,:,jl) = t_s (ib,jb,:,jl) ! temperature snw
+                  t_i (ji,jj,:,jl) = t_i (ib,jb,:,jl) ! temperature ice
+                  s_i (ji,jj,  jl) = s_i (ib,jb,  jl) ! salinity
+                  sz_i(ji,jj,:,jl) = sz_i(ib,jb,:,jl) ! salinity profile
+                  !
+               END SELECT
+               !
+               IF( nn_icesal == 1 ) THEN     ! if constant salinity
+                  s_i (ji,jj  ,jl) = rn_icesal
+                  sz_i(ji,jj,:,jl) = rn_icesal
+               ENDIF
+               !
+               ! global fields
+               v_i (ji,jj,jl) = h_i(ji,jj,jl) * a_i(ji,jj,jl)                       ! volume ice
+               v_s (ji,jj,jl) = h_s(ji,jj,jl) * a_i(ji,jj,jl)                       ! volume snw
+               sv_i(ji,jj,jl) = MIN( s_i(ji,jj,jl) , sss_m(ji,jj) ) * v_i(ji,jj,jl) ! salt content
                DO jk = 1, nlay_s
-                  t_s(ji,jj,jk,jl) = rswitch * rn_ice_tem(ib_bdy) + ( 1.0 - rswitch ) * rt0
+                  e_s(ji,jj,jk,jl) = rhos * ( rcpi * ( rt0 - t_s(ji,jj,jk,jl) ) + rLfus )   ! enthalpy in J/m3
+                  e_s(ji,jj,jk,jl) = e_s(ji,jj,jk,jl) * v_s(ji,jj,jl) * r1_nlay_s           ! enthalpy in J/m2
+               END DO               
+               DO jk = 1, nlay_i
+                  ztmelts          = - rTmlt  * sz_i(ji,jj,jk,jl)             ! Melting temperature in C
+                  t_i(ji,jj,jk,jl) = MIN( t_i(ji,jj,jk,jl), ztmelts + rt0 )   ! Force t_i to be lower than melting point => likely conservation issue
+                  !
+                  e_i(ji,jj,jk,jl) = rhoi * ( rcpi  * ( ztmelts - ( t_i(ji,jj,jk,jl) - rt0 ) )           &   ! enthalpy in J/m3
+                     &                      + rLfus * ( 1._wp - ztmelts / ( t_i(ji,jj,jk,jl) - rt0 ) )   &
+                     &                      - rcp   *   ztmelts )                  
+                  e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) * v_i(ji,jj,jl) * r1_nlay_i                            ! enthalpy in J/m2
                END DO
-               DO jk = 1, nlay_i
-                  t_i (ji,jj,jk,jl) = rswitch * rn_ice_tem(ib_bdy) + ( 1.0 - rswitch ) * rt0 
-                  sz_i(ji,jj,jk,jl) = rswitch * rn_ice_sal(ib_bdy) + ( 1.0 - rswitch ) * rn_simin
-               END DO
-               !
-            CASE( 1 )   ! velocity is outward
-               !
-               ! Ice salinity, age, temperature
-               s_i (ji,jj,jl)   = rswitch * s_i (ii,ij,jl)  + ( 1.0 - rswitch ) * rn_simin
-               oa_i(ji,jj,jl)   = rswitch * oa_i(ii,ij,jl)
-               t_su(ji,jj,jl)   = rswitch * t_su(ii,ij,jl)  + ( 1.0 - rswitch ) * rt0
-               DO jk = 1, nlay_s
-                  t_s(ji,jj,jk,jl) = rswitch * t_s(ii,ij,jk,jl) + ( 1.0 - rswitch ) * rt0
-               END DO
-               DO jk = 1, nlay_i
-                  t_i (ji,jj,jk,jl) = rswitch * t_i (ii,ij,jk,jl) + ( 1.0 - rswitch ) * rt0
-                  sz_i(ji,jj,jk,jl) = rswitch * sz_i(ii,ij,jk,jl) + ( 1.0 - rswitch ) * rn_simin
-               END DO
-               !
-            END SELECT
-            !
-            IF( nn_icesal == 1 ) THEN     ! constant salinity : overwrite rn_icesal
-               s_i (ji,jj  ,jl) = rn_icesal
-               sz_i(ji,jj,:,jl) = rn_icesal
+               !
+            ELSE   ! no ice at the boundary
+               !
+               a_i (ji,jj,  jl) = 0._wp
+               h_i (ji,jj,  jl) = 0._wp
+               h_s (ji,jj,  jl) = 0._wp
+               oa_i(ji,jj,  jl) = 0._wp
+               a_ip(ji,jj,  jl) = 0._wp
+               v_ip(ji,jj,  jl) = 0._wp
+               t_su(ji,jj,  jl) = rt0
+               t_s (ji,jj,:,jl) = rt0
+               t_i (ji,jj,:,jl) = rt0 
+               
+               IF( nn_icesal == 1 ) THEN     ! if constant salinity
+                  s_i (ji,jj  ,jl) = rn_icesal
+                  sz_i(ji,jj,:,jl) = rn_icesal
+               ELSE                          ! if variable salinity
+                  s_i (ji,jj,jl)   = rn_simin
+                  sz_i(ji,jj,:,jl) = rn_simin
+               ENDIF
+               !
+               ! global fields
+               v_i (ji,jj,  jl) = 0._wp
+               v_s (ji,jj,  jl) = 0._wp
+               sv_i(ji,jj,  jl) = 0._wp
+               e_s (ji,jj,:,jl) = 0._wp
+               e_i (ji,jj,:,jl) = 0._wp
+
             ENDIF
-            !
-            ! contents
-            sv_i(ji,jj,jl)  = MIN( s_i(ji,jj,jl) , sss_m(ji,jj) ) * v_i(ji,jj,jl)
-            DO jk = 1, nlay_s
-               ! Snow energy of melting
-               e_s(ji,jj,jk,jl) = rswitch * rhosn * ( cpic * ( rt0 - t_s(ji,jj,jk,jl) ) + lfus )
-               ! Multiply by volume, so that heat content in J/m2
-               e_s(ji,jj,jk,jl) = e_s(ji,jj,jk,jl) * v_s(ji,jj,jl) * r1_nlay_s
-            END DO
-            DO jk = 1, nlay_i
-               ztmelts          = - tmut * sz_i(ji,jj,jk,jl) + rt0 !Melting temperature in K                  
-               ! heat content per unit volume
-               e_i(ji,jj,jk,jl) = rswitch * rhoic * &
-                  (   cpic    * ( ztmelts - t_i(ji,jj,jk,jl) ) &
-                  +   lfus    * ( 1.0 - (ztmelts-rt0) / MIN((t_i(ji,jj,jk,jl)-rt0),-epsi20) ) &
-                  - rcp      * ( ztmelts - rt0 ) )
-               ! Mutliply by ice volume, and divide by number of layers to get heat content in J/m2
-               e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) * a_i(ji,jj,jl) * h_i(ji,jj,jl) * r1_nlay_i
-            END DO
-            !
+                        
          END DO
          !
-         CALL lbc_bdy_lnk( a_i(:,:,jl), 'T', 1., ib_bdy )
-         CALL lbc_bdy_lnk( h_i(:,:,jl), 'T', 1., ib_bdy )
-         CALL lbc_bdy_lnk( h_s(:,:,jl), 'T', 1., ib_bdy )
-         CALL lbc_bdy_lnk( v_i(:,:,jl), 'T', 1., ib_bdy )
-         CALL lbc_bdy_lnk( v_s(:,:,jl), 'T', 1., ib_bdy )
-         !
-         CALL lbc_bdy_lnk( sv_i(:,:,jl), 'T', 1., ib_bdy )
-         CALL lbc_bdy_lnk(  s_i(:,:,jl), 'T', 1., ib_bdy )
-         CALL lbc_bdy_lnk( oa_i(:,:,jl), 'T', 1., ib_bdy )
-         CALL lbc_bdy_lnk( t_su(:,:,jl), 'T', 1., ib_bdy )
-         DO jk = 1, nlay_s
-            CALL lbc_bdy_lnk(t_s(:,:,jk,jl), 'T', 1., ib_bdy )
-            CALL lbc_bdy_lnk(e_s(:,:,jk,jl), 'T', 1., ib_bdy )
-         END DO
-         DO jk = 1, nlay_i
-            CALL lbc_bdy_lnk(t_i(:,:,jk,jl), 'T', 1., ib_bdy )
-            CALL lbc_bdy_lnk(e_i(:,:,jk,jl), 'T', 1., ib_bdy )
-         END DO
-         !
-      END DO !jl
-      !
-      ! --- In case categories are out of bounds, do a remapping --- !
-      !     i.e. inputs have not the same ice thickness distribution 
-      !          (set by rn_himean) than the regional simulation
-      IF( jpl > 1 )   CALL ice_itd_reb( kt )
+      END DO ! jl
+
+      CALL lbc_bdy_lnk( a_i (:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( h_i (:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( h_s (:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( oa_i(:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( a_ip(:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( v_ip(:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( s_i (:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( t_su(:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( v_i (:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( v_s (:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( sv_i(:,:,:)  , 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( t_s (:,:,:,:), 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( e_s (:,:,:,:), 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( t_i (:,:,:,:), 'T', 1., jbdy )
+      CALL lbc_bdy_lnk( e_i (:,:,:,:), 'T', 1., jbdy )
       !      
    END SUBROUTINE bdy_ice_frs
@@ -262,21 +267,23 @@
       !!                 ***  SUBROUTINE bdy_ice_dyn  ***
       !!                    
-      !! ** Purpose : Apply dynamics boundary conditions for sea-ice in the cas of unstructured open boundaries.
-      !!              u_ice and v_ice are equal to the value of the adjacent grid point if this latter is not ice free
-      !!              if adjacent grid point is ice free, then u_ice and v_ice are equal to ocean velocities
+      !! ** Purpose : Apply dynamics boundary conditions for sea-ice.
       !!
-      !! 2013-06 : C. Rousset
+      !! ** Method :  if this adjacent grid point is not ice free, then u_ice and v_ice take its value
+      !!              if                          is     ice free, then u_ice and v_ice are unchanged by BDY
+      !!                                                           they keep values calculated in rheology
+      !!
       !!------------------------------------------------------------------------------
       CHARACTER(len=1), INTENT(in)  ::   cd_type   ! nature of velocity grid-points
       !
-      INTEGER  ::   jb, jgrd           ! dummy loop indices
-      INTEGER  ::   ji, jj             ! local scalar
-      INTEGER  ::   ib_bdy             ! Loop index
+      INTEGER  ::   i_bdy, jgrd      ! dummy loop indices
+      INTEGER  ::   ji, jj           ! local scalar
+      INTEGER  ::   jbdy             ! BDY set index
       REAL(wp) ::   zmsk1, zmsk2, zflag
       !!------------------------------------------------------------------------------
-      !
-      DO ib_bdy=1, nb_bdy
-         !
-         SELECT CASE( cn_ice(ib_bdy) )
+      IF( ln_timing )   CALL timing_start('bdy_ice_dyn')
+      !
+      DO jbdy=1, nb_bdy
+         !
+         SELECT CASE( cn_ice(jbdy) )
          !
          CASE('none')
@@ -285,14 +292,14 @@
          CASE('frs')
             !
-            IF( nn_ice_dta(ib_bdy) == 0 ) CYCLE            ! case ice boundaries = initial conditions 
-            !                                              !      do not change ice velocity (it is only computed by rheology)
+            IF( nn_ice_dta(jbdy) == 0 ) CYCLE            ! case ice boundaries = initial conditions 
+            !                                            !      do not change ice velocity (it is only computed by rheology)
             SELECT CASE ( cd_type )
             !     
             CASE ( 'U' )  
                jgrd = 2      ! u velocity
-               DO jb = 1, idx_bdy(ib_bdy)%nblenrim(jgrd)
-                  ji    = idx_bdy(ib_bdy)%nbi(jb,jgrd)
-                  jj    = idx_bdy(ib_bdy)%nbj(jb,jgrd)
-                  zflag = idx_bdy(ib_bdy)%flagu(jb,jgrd)
+               DO i_bdy = 1, idx_bdy(jbdy)%nblenrim(jgrd)
+                  ji    = idx_bdy(jbdy)%nbi(i_bdy,jgrd)
+                  jj    = idx_bdy(jbdy)%nbj(i_bdy,jgrd)
+                  zflag = idx_bdy(jbdy)%flagu(i_bdy,jgrd)
                   !
                   IF ( ABS( zflag ) == 1. ) THEN  ! eastern and western boundaries
@@ -301,25 +308,21 @@
                      zmsk2 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji-1,jj) ) ) ! 0 if no ice
                      !  
-                     ! u_ice = u_ice of the adjacent grid point except if this grid point is ice-free (then u_ice = u_oce)
+                     ! u_ice = u_ice of the adjacent grid point except if this grid point is ice-free (then do not change u_ice)
                      u_ice (ji,jj) = u_ice(ji+1,jj) * 0.5_wp * ABS( zflag + 1._wp ) * zmsk1 + &
                         &            u_ice(ji-1,jj) * 0.5_wp * ABS( zflag - 1._wp ) * zmsk2 + &
-                        &            u_oce(ji  ,jj) * ( 1._wp - MIN( 1._wp, zmsk1 + zmsk2 ) )
+                        &            u_ice(ji  ,jj) * ( 1._wp - MIN( 1._wp, zmsk1 + zmsk2 ) )
                   ELSE                             ! everywhere else
-                     !u_ice(ji,jj) = u_oce(ji,jj)
                      u_ice(ji,jj) = 0._wp
                   ENDIF
-                  ! mask ice velocities
-                  rswitch = MAX( 0.0_wp , SIGN ( 1.0_wp , at_i(ji,jj) - 0.01_wp ) ) ! 0 if no ice
-                  u_ice(ji,jj) = rswitch * u_ice(ji,jj)
                   !
                END DO
-               CALL lbc_bdy_lnk( u_ice(:,:), 'U', -1., ib_bdy )
+               CALL lbc_bdy_lnk( u_ice(:,:), 'U', -1., jbdy )
                !
             CASE ( 'V' )
                jgrd = 3      ! v velocity
-               DO jb = 1, idx_bdy(ib_bdy)%nblenrim(jgrd)
-                  ji    = idx_bdy(ib_bdy)%nbi(jb,jgrd)
-                  jj    = idx_bdy(ib_bdy)%nbj(jb,jgrd)
-                  zflag = idx_bdy(ib_bdy)%flagv(jb,jgrd)
+               DO i_bdy = 1, idx_bdy(jbdy)%nblenrim(jgrd)
+                  ji    = idx_bdy(jbdy)%nbi(i_bdy,jgrd)
+                  jj    = idx_bdy(jbdy)%nbj(i_bdy,jgrd)
+                  zflag = idx_bdy(jbdy)%flagv(i_bdy,jgrd)
                   !
                   IF ( ABS( zflag ) == 1. ) THEN  ! northern and southern boundaries
@@ -328,18 +331,14 @@
                      zmsk2 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji,jj-1) ) ) ! 0 if no ice
                      !  
-                     ! u_ice = u_ice of the adjacent grid point except if this grid point is ice-free (then u_ice = u_oce)
+                     ! v_ice = v_ice of the adjacent grid point except if this grid point is ice-free (then do not change v_ice)
                      v_ice (ji,jj) = v_ice(ji,jj+1) * 0.5_wp * ABS( zflag + 1._wp ) * zmsk1 + &
                         &            v_ice(ji,jj-1) * 0.5_wp * ABS( zflag - 1._wp ) * zmsk2 + &
-                        &            v_oce(ji,jj  ) * ( 1._wp - MIN( 1._wp, zmsk1 + zmsk2 ) )
+                        &            v_ice(ji,jj  ) * ( 1._wp - MIN( 1._wp, zmsk1 + zmsk2 ) )
                   ELSE                             ! everywhere else
-                     !v_ice(ji,jj) = v_oce(ji,jj)
                      v_ice(ji,jj) = 0._wp
                   ENDIF
-                  ! mask ice velocities
-                  rswitch = MAX( 0.0_wp , SIGN ( 1.0_wp , at_i(ji,jj) - 0.01 ) ) ! 0 if no ice
-                  v_ice(ji,jj) = rswitch * v_ice(ji,jj)
                   !
                END DO
-               CALL lbc_bdy_lnk( v_ice(:,:), 'V', -1., ib_bdy )
+               CALL lbc_bdy_lnk( v_ice(:,:), 'V', -1., jbdy )
                !
             END SELECT
@@ -350,4 +349,6 @@
          !
       END DO
+      !
+      IF( ln_timing )   CALL timing_stop('bdy_ice_dyn')
       !
     END SUBROUTINE bdy_ice_dyn
@@ -359,4 +360,6 @@
 CONTAINS
    SUBROUTINE bdy_ice( kt )      ! Empty routine
+      IMPLICIT NONE
+      INTEGER, INTENT( in ) :: kt
       WRITE(*,*) 'bdy_ice: You should not have seen this print! error?', kt
    END SUBROUTINE bdy_ice
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdyini.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdyini.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdyini.F90	(revision 10288)
@@ -47,5 +47,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdylib.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdylib.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdylib.F90	(revision 10288)
@@ -29,5 +29,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdytides.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdytides.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdytides.F90	(revision 10288)
@@ -48,5 +48,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdytra.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdytra.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdytra.F90	(revision 10288)
@@ -35,5 +35,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdyvol.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdyvol.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/BDY/bdyvol.F90	(revision 10288)
@@ -29,5 +29,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/C1D/c1d.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/C1D/c1d.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/C1D/c1d.F90	(revision 10288)
@@ -31,7 +31,7 @@
 
    !!----------------------------------------------------------------------
-   !! NEMO/C1D 3.7 , NEMO Consortium (2018)
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!======================================================================
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/C1D/dtauvd.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/C1D/dtauvd.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/C1D/dtauvd.F90	(revision 10288)
@@ -34,5 +34,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/C1D/dyncor_c1d.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/C1D/dyncor_c1d.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/C1D/dyncor_c1d.F90	(revision 10288)
@@ -33,7 +33,7 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/C1D 3.7 , NEMO Consortium (2018)
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -106,6 +106,9 @@
 CONTAINS
    SUBROUTINE cor_c1d              ! Empty routine
+       IMPLICIT NONE
    END SUBROUTINE cor_c1d   
    SUBROUTINE dyn_cor_c1d ( kt )      ! Empty routine
+      IMPLICIT NONE
+      INTEGER, INTENT( in ) :: kt
       WRITE(*,*) 'dyn_cor_c1d: You should not have seen this print! error?', kt
    END SUBROUTINE dyn_cor_c1d
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/C1D/dyndmp.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/C1D/dyndmp.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/C1D/dyndmp.F90	(revision 10288)
@@ -47,5 +47,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/C1D/step_c1d.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/C1D/step_c1d.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/C1D/step_c1d.F90	(revision 10288)
@@ -28,7 +28,7 @@
 
    !!----------------------------------------------------------------------
-   !! NEMO/C1D 3.7 , NEMO Consortium (2018)
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -147,4 +147,6 @@
 CONTAINS
    SUBROUTINE stp_c1d ( kt )      ! dummy routine
+      IMPLICIT NONE
+      INTEGER, INTENT( in ) :: kt
       WRITE(*,*) 'stp_c1d: You should not have seen this print! error?', kt
    END SUBROUTINE stp_c1d
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/README.rst
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/README.rst	(revision 10288)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/README.rst	(revision 10288)
@@ -0,0 +1,149 @@
+**********************************
+On line biogeochemistry coarsening
+**********************************
+
+.. contents::
+   :local:
+
+Presentation
+============
+
+A capacity of coarsening physics to force a BGC model coupled to NEMO has been developed.
+This capacity allow to run 'online' a BGC model coupled to OCE-SI3 with a lower resolution,
+to reduce the CPU cost of the BGC model, while preserving the effective resolution of the dynamics.
+
+A presentation is available [attachment:crs_wiki_1.1.pdf​ here], where the methodology is presented.
+
+What is available and working for now in this version
+=====================================================
+
+[To be completed]
+
+Description of the successful validation tests
+==============================================
+
+[To be completed]
+
+What is not working yet with on line coarsening of biogeochemistry
+==================================================================
+
+[To be completed]
+
+''should include precise explanation on MPI decomposition problems too''
+
+How to set up and use on line biogeochemistry
+=============================================
+
+Extract the on line biogeochemistry branch
+------------------------------------------
+
+To get the appropriate source code with the on line coarsening of biogeochemistry feature:
+
+.. code-block:: console
+
+	$ svn co https://forge.ipsl.jussieu.fr/nemo/browser/NEMO/branches/2018/dev_r5003_MERCATOR6_CRS
+
+
+How to activate coarsening?
+---------------------------
+
+To activate the coarsening, ``key_crs`` should be added to list of CPP keys.
+This key will only activate the coarsening of dynamics.
+
+Some parameters are available in the namelist_cfg:
+
+.. code-block:: fortran
+
+	               !   passive tracer coarsened online simulations
+	!-----------------------------------------------------------------------
+	   nn_factx    = 3         !  Reduction factor of x-direction
+	   nn_facty    = 3         !  Reduction factor of y-direction
+	   nn_msh_crs  = 0         !  create (=1) a mesh file or not (=0)
+	   nn_crs_kz   = 3         ! 0, volume-weighted MEAN of KZ
+	                           ! 1, MAX of KZ
+	                           ! 2, MIN of KZ
+	                           ! 3, 10^(MEAN(LOG(KZ)) 
+	                           ! 4, MEDIANE of KZ 
+	   ln_crs_wn   = .false.   ! wn coarsened (T) or computed using horizontal divergence ( F )
+	                           !                           !
+	   ln_crs_top = .true.     !coarsening online for the bio
+	/
+
+- Only ``nn_factx = 3`` is available and the coarsening only works for grids with a T-pivot point for
+  the north-fold lateral boundary condition (ORCA025, ORCA12, ORCA36, ...).
+- ``nn_msh_crs = 1`` will activate the generation of the coarsened grid meshmask.
+- ``nn_crs_kz`` is the operator to coarsen the vertical mixing coefficient. 
+- ``ln_crs_wn``
+
+  - when ``key_vvl`` is activated, this logical has no effect;
+    the coarsened vertical velocities are computed using horizontal divergence.
+  - when ``key_vvl`` is not activated,
+
+    - coarsened vertical velocities are computed using horizontal divergence (``ln_crs_wn = .false.``) 
+    - or coarsened vertical velocities are computed with an average operator (``ln_crs_wn = .true.``)
+- ``ln_crs_top = .true.``: should be activated to run BCG model in coarsened space;
+  so only works when ``key_top`` is in the cpp list and eventually ``key_pisces`` or ``key_my_trc``.
+
+Choice of operator to coarsene KZ
+---------------------------------
+
+A sensiblity test has been done with an Age tracer to compare the different operators.
+The 3 and 4 options seems to provide the best results.
+
+Some results can be found [xxx here]
+
+Example of xml files to output coarsened variables with XIOS
+------------------------------------------------------------
+
+In the [attachment:iodef.xml iodef.xml]  file, a "nemo" context is defined and
+some variable defined in [attachment:file_def.xml file_def.xml] are writted on the ocean-dynamic grid.  
+To write variables on the coarsened grid, and in particular the passive tracers,
+a "nemo_crs" context should be defined in [attachment:iodef.xml iodef.xml] and
+the associated variable are listed in [attachment:file_crs_def.xml file_crs_def.xml ].
+
+Passive tracers tracers initial conditions
+------------------------------------------
+
+When initial conditions are provided in NetCDF files, the field might be:
+
+- on the coarsened grid
+- or they can be on another grid and
+  interpolated `on-the-fly <http://forge.ipsl.jussieu.fr/nemo/wiki/Users/SetupNewConfiguration/Weight-creator>`_.
+  Example of namelist for PISCES :
+  
+	.. code-block:: fortran
+
+		!-----------------------------------------------------------------------
+		&namtrc_dta      !    Initialisation from data input file
+		!-----------------------------------------------------------------------
+		!
+		   sn_trcdta(1)  = 'DIC_REG1'        ,        -12        ,  'DIC'     ,    .false.   , .true. , 'yearly'  , 'reshape_REG1toeORCA075_bilin.nc'       , ''   , ''
+		   sn_trcdta(2)  = 'ALK_REG1'        ,        -12        ,  'ALK'     ,    .false.   , .true. , 'yearly'  , 'reshape_REG1toeORCA075_bilin.nc'       , ''   , ''
+		   sn_trcdta(3)  = 'O2_REG1'         ,        -1         ,  'O2'      ,    .true.    , .true. , 'yearly'  , 'reshape_REG1toeORCA075_bilin.nc'       , ''   , ''
+		   sn_trcdta(5)  = 'PO4_REG1'        ,        -1         ,  'PO4'     ,    .true.    , .true. , 'yearly'  , 'reshape_REG1toeORCA075_bilin.nc'       , ''   , ''
+		   sn_trcdta(7)  = 'Si_REG1'         ,        -1         ,  'Si'      ,    .true.    , .true. , 'yearly'  , 'reshape_REG1toeORCA075_bilin.nc'       , ''   , ''
+	   	sn_trcdta(10) = 'DOC_REG1'        ,        -12        ,  'DOC'     ,    .false.   , .true. , 'yearly'  , 'reshape_REG1toeORCA075_bilin.nc'       , ''   , ''
+		   sn_trcdta(14) = 'Fe_REG1'         ,        -12        ,  'Fe'      ,    .false.   , .true. , 'yearly'  , 'reshape_REG1toeORCA075_bilin.nc'       , ''   , ''
+		   sn_trcdta(23) = 'NO3_REG1'        ,        -1         ,  'NO3'     ,    .true.    , .true. , 'yearly'  , 'reshape_REG1toeORCA075_bilin.nc'       , ''   , ''
+	   	rn_trfac(1)   =   1.0e-06  !  multiplicative factor
+		   rn_trfac(2)   =   1.0e-06  !  -      -      -     -
+		   rn_trfac(3)   =  44.6e-06  !  -      -      -     -
+	   	rn_trfac(5)   = 122.0e-06  !  -      -      -     -
+		   rn_trfac(7)   =   1.0e-06  !  -      -      -     -
+		   rn_trfac(10)  =   1.0e-06  !  -      -      -     -
+	   	rn_trfac(14)  =   1.0e-06  !  -      -      -     -
+		   rn_trfac(23)  =   7.6e-06  !  -      -      -     -
+		
+	   	cn_dir        =  './'      !  root directory for the location of the data files
+
+PISCES forcing files
+--------------------
+
+They might be on the coarsened grid.
+
+Perspectives
+============
+
+For the future, a few options are on the table to implement coarsening for biogeochemistry in 4.0 and
+future releases.
+Those will be discussed in Autumn 2018
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/crs.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/crs.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/crs.F90	(revision 10288)
@@ -156,5 +156,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/crsdom.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/crsdom.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/crsdom.F90	(revision 10288)
@@ -55,5 +55,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -2246,5 +2246,5 @@
      
       zmbk(:,:) = 0.0
-      zmbk(:,:) = REAL( mbathy_crs(:,:), wp ) ;   CALL crs_lbc_lnk(zmbk,'T',1.0)   ;   mbathy_crs(:,:) = INT( zmbk(:,:) )
+      zmbk(:,:) = REAL( mbathy_crs(:,:), wp ) ;   CALL crs_lbc_lnk(zmbk,'T',1.0)   ;   mbathy_crs(:,:) = NINT( zmbk(:,:) )
 
 
@@ -2266,6 +2266,6 @@
       ! convert into REAL to use lbc_lnk ; impose a min value of 1 as a zero can be set in lbclnk
       zmbk(:,:) = 1.e0;    
-      zmbk(:,:) = REAL( mbku_crs(:,:), wp )   ;   CALL crs_lbc_lnk(zmbk,'U',1.0) ; mbku_crs  (:,:) = MAX( INT( zmbk(:,:) ), 1 ) 
-      zmbk(:,:) = REAL( mbkv_crs(:,:), wp )   ;   CALL crs_lbc_lnk(zmbk,'V',1.0) ; mbkv_crs  (:,:) = MAX( INT( zmbk(:,:) ), 1 ) 
+      zmbk(:,:) = REAL( mbku_crs(:,:), wp )   ;   CALL crs_lbc_lnk(zmbk,'U',1.0) ; mbku_crs  (:,:) = MAX( NINT( zmbk(:,:) ), 1 ) 
+      zmbk(:,:) = REAL( mbkv_crs(:,:), wp )   ;   CALL crs_lbc_lnk(zmbk,'V',1.0) ; mbkv_crs  (:,:) = MAX( NINT( zmbk(:,:) ), 1 ) 
       !
    END SUBROUTINE crs_dom_bat
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/crsdomwri.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/crsdomwri.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/crsdomwri.F90	(revision 10288)
@@ -28,5 +28,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/crsfld.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/crsfld.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/crsfld.F90	(revision 10288)
@@ -36,5 +36,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/crsini.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/crsini.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/crsini.F90	(revision 10288)
@@ -31,5 +31,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/crslbclnk.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/crslbclnk.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/CRS/crslbclnk.F90	(revision 10288)
@@ -23,5 +23,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/dia25h.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/dia25h.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/dia25h.F90	(revision 10288)
@@ -33,6 +33,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id:$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -139,6 +139,6 @@
       ! -----------------
       ! Define frequency of summing to create 25 h mean
-      IF( MOD( 3600,INT(rdt) ) == 0 ) THEN
-         i_steps = 3600/INT(rdt)
+      IF( MOD( 3600,NINT(rdt) ) == 0 ) THEN
+         i_steps = 3600/NINT(rdt)
       ELSE
          CALL ctl_stop('STOP', 'dia_wri_tide: timestep must give MOD(3600,rdt) = 0 otherwise no hourly values are possible')
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diaar5.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diaar5.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diaar5.F90	(revision 10288)
@@ -43,5 +43,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diacfl.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diacfl.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diacfl.F90	(revision 10288)
@@ -39,7 +39,7 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diadct.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diadct.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diadct.F90	(revision 10288)
@@ -100,5 +100,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -1249,8 +1249,10 @@
 
    SUBROUTINE dia_dct_init          ! Dummy routine
-      WRITE(*,*) 'dia_dct_init: You should not have seen this print! error?', kt
+      IMPLICIT NONE
+      WRITE(*,*) 'dia_dct_init: You should not have seen this print! error?'
    END SUBROUTINE dia_dct_init
 
    SUBROUTINE dia_dct( kt )         ! Dummy routine
+      IMPLICIT NONE
       INTEGER, INTENT( in ) :: kt   ! ocean time-step index
       WRITE(*,*) 'dia_dct: You should not have seen this print! error?', kt
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diaharm.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diaharm.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diaharm.F90	(revision 10288)
@@ -57,5 +57,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diahsb.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diahsb.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diahsb.F90	(revision 10288)
@@ -54,5 +54,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diahth.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diahth.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diahth.F90	(revision 10288)
@@ -43,5 +43,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -343,4 +343,6 @@
 CONTAINS
    SUBROUTINE dia_hth( kt )         ! Empty routine
+      IMPLICIT NONE
+      INTEGER, INTENT( in ) :: kt
       WRITE(*,*) 'dia_hth: You should not have seen this print! error?', kt
    END SUBROUTINE dia_hth
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/dianam.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/dianam.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/dianam.F90	(revision 10288)
@@ -25,5 +25,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diaptr.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diaptr.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diaptr.F90	(revision 10288)
@@ -67,5 +67,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diatmb.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diatmb.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diatmb.F90	(revision 10288)
@@ -22,6 +22,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id:$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diawri.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diawri.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIA/diawri.F90	(revision 10288)
@@ -81,5 +81,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -125,6 +125,6 @@
       ! Output of initial vertical scale factor
       CALL iom_put("e3t_0", e3t_0(:,:,:) )
-      CALL iom_put("e3u_0", e3t_0(:,:,:) )
-      CALL iom_put("e3v_0", e3t_0(:,:,:) )
+      CALL iom_put("e3u_0", e3u_0(:,:,:) )
+      CALL iom_put("e3v_0", e3v_0(:,:,:) )
       !
       CALL iom_put( "e3t" , e3t_n(:,:,:) )
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIU/cool_skin.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIU/cool_skin.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIU/cool_skin.F90	(revision 10288)
@@ -44,7 +44,7 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
-   !! $Id:  $
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------   
    CONTAINS 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIU/step_diu.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIU/step_diu.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DIU/step_diu.F90	(revision 10288)
@@ -24,6 +24,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id:$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/closea.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/closea.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/closea.F90	(revision 10288)
@@ -65,6 +65,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: usrdef_closea.F90 9124 2017-12-19 08:26:25Z gm $
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/daymod.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/daymod.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/daymod.F90	(revision 10288)
@@ -46,5 +46,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/depth_e3.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/depth_e3.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/depth_e3.F90	(revision 10288)
@@ -41,5 +41,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS             
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/dom_oce.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/dom_oce.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/dom_oce.F90	(revision 10288)
@@ -216,5 +216,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/domain.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/domain.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/domain.F90	(revision 10288)
@@ -54,5 +54,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence        (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!-------------------------------------------------------------------------
 CONTAINS
@@ -542,5 +542,5 @@
          !
          cd_cfg = 'ORCA'
-         CALL iom_get( inum, 'ORCA_index', zorca_res )   ;   kk_cfg = INT( zorca_res )
+         CALL iom_get( inum, 'ORCA_index', zorca_res )   ;   kk_cfg = NINT( zorca_res )
          !
          WRITE(ldtxt(ii),*) '   .'                                                     ;   ii = ii+1
@@ -562,8 +562,8 @@
       ENDIF
       !
-      CALL iom_get( inum, 'jpiglo', ziglo  )   ;   kpi = INT( ziglo )
-      CALL iom_get( inum, 'jpjglo', zjglo  )   ;   kpj = INT( zjglo )
-      CALL iom_get( inum, 'jpkglo', zkglo  )   ;   kpk = INT( zkglo )
-      CALL iom_get( inum, 'jperio', zperio )   ;   kperio = INT( zperio )
+      CALL iom_get( inum, 'jpiglo', ziglo  )   ;   kpi = NINT( ziglo )
+      CALL iom_get( inum, 'jpjglo', zjglo  )   ;   kpj = NINT( zjglo )
+      CALL iom_get( inum, 'jpkglo', zkglo  )   ;   kpk = NINT( zkglo )
+      CALL iom_get( inum, 'jperio', zperio )   ;   kperio = NINT( zperio )
       CALL iom_close( inum )
       !
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/domhgr.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/domhgr.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/domhgr.F90	(revision 10288)
@@ -41,5 +41,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/dommsk.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/dommsk.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/dommsk.F90	(revision 10288)
@@ -48,5 +48,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/domngb.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/domngb.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/domngb.F90	(revision 10288)
@@ -23,5 +23,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/domvvl.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/domvvl.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/domvvl.F90	(revision 10288)
@@ -64,7 +64,7 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -234,9 +234,11 @@
                END DO
             END DO
-            IF( cn_cfg == "orca" .AND. nn_cfg == 3 ) THEN   ! ORCA2: Suppress ztilde in the Foxe Basin for ORCA2
-               ii0 = 103   ;   ii1 = 111       
-               ij0 = 128   ;   ij1 = 135   ;   
-               frq_rst_e3t( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  0.0_wp
-               frq_rst_hdv( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  1.e0_wp / rdt
+            IF( cn_cfg == "orca" .OR. cn_cfg == "ORCA" ) THEN
+               IF( nn_cfg == 3 ) THEN   ! ORCA2: Suppress ztilde in the Foxe Basin for ORCA2
+                  ii0 = 103   ;   ii1 = 111       
+                  ij0 = 128   ;   ij1 = 135   ;   
+                  frq_rst_e3t( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  0.0_wp
+                  frq_rst_hdv( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  1.e0_wp / rdt
+               ENDIF
             ENDIF
          ENDIF
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/domwri.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/domwri.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/domwri.F90	(revision 10288)
@@ -36,5 +36,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/domzgr.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/domzgr.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/domzgr.F90	(revision 10288)
@@ -48,5 +48,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS       
@@ -253,7 +253,7 @@
       !                          !* ocean top and bottom level
       CALL iom_get( inum, jpdom_data, 'top_level'    , z2d  , lrowattr=ln_use_jattr )   ! 1st wet T-points (ISF)
-      k_top(:,:) = INT( z2d(:,:) )
+      k_top(:,:) = NINT( z2d(:,:) )
       CALL iom_get( inum, jpdom_data, 'bottom_level' , z2d  , lrowattr=ln_use_jattr )   ! last wet T-points
-      k_bot(:,:) = INT( z2d(:,:) )
+      k_bot(:,:) = NINT( z2d(:,:) )
       !
       ! reference depth for negative bathy (wetting and drying only)
@@ -307,10 +307,10 @@
       END DO
       ! converte into REAL to use lbc_lnk ; impose a min value of 1 as a zero can be set in lbclnk 
-      zk(:,:) = REAL( miku(:,:), wp )   ;   CALL lbc_lnk( zk, 'U', 1. )   ;   miku(:,:) = MAX( INT( zk(:,:) ), 1 )
-      zk(:,:) = REAL( mikv(:,:), wp )   ;   CALL lbc_lnk( zk, 'V', 1. )   ;   mikv(:,:) = MAX( INT( zk(:,:) ), 1 )
-      zk(:,:) = REAL( mikf(:,:), wp )   ;   CALL lbc_lnk( zk, 'F', 1. )   ;   mikf(:,:) = MAX( INT( zk(:,:) ), 1 )
-      !
-      zk(:,:) = REAL( mbku(:,:), wp )   ;   CALL lbc_lnk( zk, 'U', 1. )   ;   mbku(:,:) = MAX( INT( zk(:,:) ), 1 )
-      zk(:,:) = REAL( mbkv(:,:), wp )   ;   CALL lbc_lnk( zk, 'V', 1. )   ;   mbkv(:,:) = MAX( INT( zk(:,:) ), 1 )
+      zk(:,:) = REAL( miku(:,:), wp )   ;   CALL lbc_lnk( zk, 'U', 1. )   ;   miku(:,:) = MAX( NINT( zk(:,:) ), 1 )
+      zk(:,:) = REAL( mikv(:,:), wp )   ;   CALL lbc_lnk( zk, 'V', 1. )   ;   mikv(:,:) = MAX( NINT( zk(:,:) ), 1 )
+      zk(:,:) = REAL( mikf(:,:), wp )   ;   CALL lbc_lnk( zk, 'F', 1. )   ;   mikf(:,:) = MAX( NINT( zk(:,:) ), 1 )
+      !
+      zk(:,:) = REAL( mbku(:,:), wp )   ;   CALL lbc_lnk( zk, 'U', 1. )   ;   mbku(:,:) = MAX( NINT( zk(:,:) ), 1 )
+      zk(:,:) = REAL( mbkv(:,:), wp )   ;   CALL lbc_lnk( zk, 'V', 1. )   ;   mbkv(:,:) = MAX( NINT( zk(:,:) ), 1 )
       !
    END SUBROUTINE zgr_top_bot
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/dtatsd.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/dtatsd.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/dtatsd.F90	(revision 10288)
@@ -38,5 +38,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -150,25 +150,27 @@
       !
       !                                   !==   ORCA_R2 configuration and T & S damping   ==! 
-      IF( cn_cfg == "orca" .AND. nn_cfg == 2 .AND. ln_tsd_dmp ) THEN    ! some hand made alterations
-         !
-         ij0 = 101   ;   ij1 = 109                       ! Reduced T & S in the Alboran Sea
-         ii0 = 141   ;   ii1 = 155
-         DO jj = mj0(ij0), mj1(ij1)
-            DO ji = mi0(ii0), mi1(ii1)
-               sf_tsd(jp_tem)%fnow(ji,jj,13:13) = sf_tsd(jp_tem)%fnow(ji,jj,13:13) - 0.20_wp
-               sf_tsd(jp_tem)%fnow(ji,jj,14:15) = sf_tsd(jp_tem)%fnow(ji,jj,14:15) - 0.35_wp
-               sf_tsd(jp_tem)%fnow(ji,jj,16:25) = sf_tsd(jp_tem)%fnow(ji,jj,16:25) - 0.40_wp
-               !
-               sf_tsd(jp_sal)%fnow(ji,jj,13:13) = sf_tsd(jp_sal)%fnow(ji,jj,13:13) - 0.15_wp
-               sf_tsd(jp_sal)%fnow(ji,jj,14:15) = sf_tsd(jp_sal)%fnow(ji,jj,14:15) - 0.25_wp
-               sf_tsd(jp_sal)%fnow(ji,jj,16:17) = sf_tsd(jp_sal)%fnow(ji,jj,16:17) - 0.30_wp
-               sf_tsd(jp_sal)%fnow(ji,jj,18:25) = sf_tsd(jp_sal)%fnow(ji,jj,18:25) - 0.35_wp
+      IF( cn_cfg == "orca" .OR. cn_cfg == "ORCA" ) THEN
+         IF( nn_cfg == 2 .AND. ln_tsd_dmp ) THEN    ! some hand made alterations
+            !
+            ij0 = 101   ;   ij1 = 109                       ! Reduced T & S in the Alboran Sea
+            ii0 = 141   ;   ii1 = 155
+            DO jj = mj0(ij0), mj1(ij1)
+               DO ji = mi0(ii0), mi1(ii1)
+                  sf_tsd(jp_tem)%fnow(ji,jj,13:13) = sf_tsd(jp_tem)%fnow(ji,jj,13:13) - 0.20_wp
+                  sf_tsd(jp_tem)%fnow(ji,jj,14:15) = sf_tsd(jp_tem)%fnow(ji,jj,14:15) - 0.35_wp
+                  sf_tsd(jp_tem)%fnow(ji,jj,16:25) = sf_tsd(jp_tem)%fnow(ji,jj,16:25) - 0.40_wp
+                  !
+                  sf_tsd(jp_sal)%fnow(ji,jj,13:13) = sf_tsd(jp_sal)%fnow(ji,jj,13:13) - 0.15_wp
+                  sf_tsd(jp_sal)%fnow(ji,jj,14:15) = sf_tsd(jp_sal)%fnow(ji,jj,14:15) - 0.25_wp
+                  sf_tsd(jp_sal)%fnow(ji,jj,16:17) = sf_tsd(jp_sal)%fnow(ji,jj,16:17) - 0.30_wp
+                  sf_tsd(jp_sal)%fnow(ji,jj,18:25) = sf_tsd(jp_sal)%fnow(ji,jj,18:25) - 0.35_wp
+               END DO
             END DO
-         END DO
-         ij0 =  87   ;   ij1 =  96                          ! Reduced temperature in Red Sea
-         ii0 = 148   ;   ii1 = 160
-         sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ,  4:10 ) = 7.0_wp
-         sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 11:13 ) = 6.5_wp
-         sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 14:20 ) = 6.0_wp
+            ij0 =  87   ;   ij1 =  96                          ! Reduced temperature in Red Sea
+            ii0 = 148   ;   ii1 = 160
+            sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ,  4:10 ) = 7.0_wp
+            sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 11:13 ) = 6.5_wp
+            sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 14:20 ) = 6.0_wp
+         ENDIF
       ENDIF
 !!gm end
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/iscplhsb.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/iscplhsb.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/iscplhsb.F90	(revision 10288)
@@ -35,6 +35,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: sbcrnf.F90 4666 2014-06-11 12:52:23Z mathiot $
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/iscplini.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/iscplini.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/iscplini.F90	(revision 10288)
@@ -37,6 +37,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id:$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/iscplrst.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/iscplrst.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/iscplrst.F90	(revision 10288)
@@ -35,6 +35,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: sbcrnf.F90 4666 2014-06-11 12:52:23Z mathiot $
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/istate.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/istate.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/istate.F90	(revision 10288)
@@ -47,5 +47,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/phycst.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/phycst.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DOM/phycst.F90	(revision 10288)
@@ -23,27 +23,20 @@
    PUBLIC   phy_cst     ! routine called by inipar.F90
 
-   REAL(wp), PUBLIC ::   rpi = 3.141592653589793_wp             !: pi
-   REAL(wp), PUBLIC ::   rad = 3.141592653589793_wp / 180._wp   !: conversion from degre into radian
-   REAL(wp), PUBLIC ::   rsmall = 0.5 * EPSILON( 1.e0 )         !: smallest real computer value
+   REAL(wp), PUBLIC ::   rpi      = 3.141592653589793_wp             !: pi
+   REAL(wp), PUBLIC ::   rad      = 3.141592653589793_wp / 180._wp   !: conversion from degre into radian
+   REAL(wp), PUBLIC ::   rsmall   = 0.5 * EPSILON( 1.e0 )            !: smallest real computer value
    
-   REAL(wp), PUBLIC ::   rday = 24.*60.*60.     !: day                                [s]
-   REAL(wp), PUBLIC ::   rsiyea                 !: sideral year                       [s]
-   REAL(wp), PUBLIC ::   rsiday                 !: sideral day                        [s]
-   REAL(wp), PUBLIC ::   raamo =  12._wp        !: number of months in one year
-   REAL(wp), PUBLIC ::   rjjhh =  24._wp        !: number of hours in one day
-   REAL(wp), PUBLIC ::   rhhmm =  60._wp        !: number of minutes in one hour
-   REAL(wp), PUBLIC ::   rmmss =  60._wp        !: number of seconds in one minute
-   REAL(wp), PUBLIC ::   omega                  !: earth rotation parameter           [s-1]
-   REAL(wp), PUBLIC ::   ra    = 6371229._wp    !: earth radius                       [m]
-   REAL(wp), PUBLIC ::   grav  = 9.80665_wp     !: gravity                            [m/s2]
-   
-   REAL(wp), PUBLIC ::   rtt      = 273.16_wp        !: triple point of temperature   [Kelvin]
+   REAL(wp), PUBLIC ::   rday     = 24.*60.*60.      !: day                                [s]
+   REAL(wp), PUBLIC ::   rsiyea                      !: sideral year                       [s]
+   REAL(wp), PUBLIC ::   rsiday                      !: sideral day                        [s]
+   REAL(wp), PUBLIC ::   raamo    =  12._wp          !: number of months in one year
+   REAL(wp), PUBLIC ::   rjjhh    =  24._wp          !: number of hours in one day
+   REAL(wp), PUBLIC ::   rhhmm    =  60._wp          !: number of minutes in one hour
+   REAL(wp), PUBLIC ::   rmmss    =  60._wp          !: number of seconds in one minute
+   REAL(wp), PUBLIC ::   omega                       !: earth rotation parameter           [s-1]
+   REAL(wp), PUBLIC ::   ra       = 6371229._wp      !: earth radius                       [m]
+   REAL(wp), PUBLIC ::   grav     = 9.80665_wp       !: gravity                            [m/s2]   
    REAL(wp), PUBLIC ::   rt0      = 273.15_wp        !: freezing point of fresh water [Kelvin]
-   REAL(wp), PUBLIC ::   rt0_snow = 273.15_wp        !: melting point of snow         [Kelvin]
-#if defined key_si3
-   REAL(wp), PUBLIC ::   rt0_ice  = 273.15_wp        !: melting point of ice          [Kelvin]
-#else
-   REAL(wp), PUBLIC ::   rt0_ice  = 273.05_wp        !: melting point of ice          [Kelvin]
-#endif
+
    REAL(wp), PUBLIC ::   rau0                        !: volumic mass of reference     [kg/m3]
    REAL(wp), PUBLIC ::   r1_rau0                     !: = 1. / rau0                   [m3/kg]
@@ -53,46 +46,28 @@
    REAL(wp), PUBLIC ::   r1_rau0_rcp                 !: = 1. / ( rau0 * rcp )
 
-   REAL(wp), PUBLIC ::   rhosn    =  330._wp         !: volumic mass of snow          [kg/m3]
-   REAL(wp), PUBLIC ::   rhofw    = 1000._wp         !: volumic mass of freshwater in melt ponds [kg/m3]
-   REAL(wp), PUBLIC ::   emic     =    0.97_wp       !: emissivity of snow or ice
-   REAL(wp), PUBLIC ::   sice     =    6.0_wp        !: salinity of ice               [psu]
-   REAL(wp), PUBLIC ::   soce     =   34.7_wp        !: salinity of sea               [psu]
-   REAL(wp), PUBLIC ::   cevap    =    2.5e+6_wp     !: latent heat of evaporation (water)
-   REAL(wp), PUBLIC ::   srgamma  =    0.9_wp        !: correction factor for solar radiation (Oberhuber, 1974)
+   REAL(wp), PUBLIC ::   emic     =    0.97_wp       !: emissivity of snow or ice (not used?)
+
+   REAL(wp), PUBLIC ::   sice     =    6.0_wp        !: salinity of ice (for pisces)          [psu]
+   REAL(wp), PUBLIC ::   soce     =   34.7_wp        !: salinity of sea (for pisces and isf)  [psu]
+   REAL(wp), PUBLIC ::   rLevap   =    2.5e+6_wp     !: latent heat of evaporation (water)
    REAL(wp), PUBLIC ::   vkarmn   =    0.4_wp        !: von Karman constant
    REAL(wp), PUBLIC ::   stefan   =    5.67e-8_wp    !: Stefan-Boltzmann constant 
 
-#if defined key_si3 || defined key_cice
-   REAL(wp), PUBLIC ::   rhoic    =  917._wp         !: volumic mass of sea ice                               [kg/m3]
-   REAL(wp), PUBLIC ::   rcdic    =    2.034396_wp   !: thermal conductivity of fresh ice                     [W/m/K]
-   REAL(wp), PUBLIC ::   cpic     = 2067.0_wp        !: specific heat of fresh ice                            [J/kg/K]
-   REAL(wp), PUBLIC ::   lsub     =    2.834e+6_wp   !: pure ice latent heat of sublimation                   [J/kg]
-   REAL(wp), PUBLIC ::   lfus     =    0.334e+6_wp   !: latent heat of fusion of fresh ice                    [J/kg]
-   REAL(wp), PUBLIC ::   tmut     =    0.054_wp      !: decrease of seawater meltpoint with salinity
-   REAL(wp), PUBLIC ::   xlsn                        !: = lfus*rhosn (volumetric latent heat fusion of snow)  [J/m3]
-#else
-   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]
-   REAL(wp), PUBLIC ::   cpic                        !: = rcpic / rhoic  (specific heat for ice)              [J/Kg/K]
-   REAL(wp), PUBLIC ::   rcdsn    =    0.22_wp       !: conductivity of the snow                              [W/m/K]
-   REAL(wp), PUBLIC ::   rcpsn    =    6.9069e+5_wp  !: volumetric specific heat for snow                     [J/m3/K]
-   REAL(wp), PUBLIC ::   xlsn     =  110.121e+6_wp   !: volumetric latent heat fusion of snow                 [J/m3]
-   REAL(wp), PUBLIC ::   lfus                        !: = xlsn / rhosn   (latent heat of fusion of fresh ice) [J/Kg]
-   REAL(wp), PUBLIC ::   xlic     =  300.33e+6_wp    !: volumetric latent heat fusion of ice                  [J/m3]
-   REAL(wp), PUBLIC ::   xsn      =    2.8e+6_wp     !: volumetric latent heat of sublimation of snow         [J/m3]
-#endif
-#if defined key_cice
-   REAL(wp), PUBLIC ::   rcdsn    =    0.31_wp       !: thermal conductivity of snow                          [W/m/K]
-#endif
-#if defined key_si3
-   REAL(wp), PUBLIC ::   r1_rhoic                    !: 1 / rhoic
-   REAL(wp), PUBLIC ::   r1_rhosn                    !: 1 / rhosn
-   REAL(wp), PUBLIC ::   r1_cpic                     !: 1 / cpic
-#endif
+   REAL(wp), PUBLIC ::   rhos     =  330._wp         !: volumic mass of snow                                  [kg/m3]
+   REAL(wp), PUBLIC ::   rhoi     =  917._wp         !: volumic mass of sea ice                               [kg/m3]
+   REAL(wp), PUBLIC ::   rhow     = 1000._wp         !: volumic mass of freshwater in melt ponds              [kg/m3]
+   REAL(wp), PUBLIC ::   rcnd_i   =    2.034396_wp   !: thermal conductivity of fresh ice                     [W/m/K]
+   REAL(wp), PUBLIC ::   rcpi     = 2067.0_wp        !: specific heat of fresh ice                            [J/kg/K]
+   REAL(wp), PUBLIC ::   rLsub    =    2.834e+6_wp   !: pure ice latent heat of sublimation                   [J/kg]
+   REAL(wp), PUBLIC ::   rLfus    =    0.334e+6_wp   !: latent heat of fusion of fresh ice                    [J/kg]
+   REAL(wp), PUBLIC ::   rTmlt    =    0.054_wp      !: decrease of seawater meltpoint with salinity
+
+   REAL(wp), PUBLIC ::   r1_rhoi                     !: 1 / rhoi
+   REAL(wp), PUBLIC ::   r1_rhos                     !: 1 / rhos
+   REAL(wp), PUBLIC ::   r1_rcpi                     !: 1 / rcpi
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
    
@@ -106,16 +81,4 @@
       !!----------------------------------------------------------------------
 
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'phy_cst : initialization of ocean parameters and constants'
-      IF(lwp) WRITE(numout,*) '~~~~~~~'
-
-      ! Define & print constants
-      ! ------------------------
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) '   Constants'
-
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) '      mathematical constant                 rpi = ', rpi
-
       rsiyea = 365.25_wp * rday * 2._wp * rpi / 6.283076_wp
       rsiday = rday / ( 1._wp + rday / rsiyea )
@@ -125,61 +88,42 @@
       omega  = 2._wp * rpi / rsiday 
 #endif
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) '      day                                rday   = ', rday,   ' s'
-      IF(lwp) WRITE(numout,*) '      sideral year                       rsiyea = ', rsiyea, ' s'
-      IF(lwp) WRITE(numout,*) '      sideral day                        rsiday = ', rsiday, ' s'
-      IF(lwp) WRITE(numout,*) '      omega                              omega  = ', omega,  ' s^-1'
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) '      nb of months per year               raamo = ', raamo, ' months'
-      IF(lwp) WRITE(numout,*) '      nb of hours per day                 rjjhh = ', rjjhh, ' hours'
-      IF(lwp) WRITE(numout,*) '      nb of minutes per hour              rhhmm = ', rhhmm, ' mn'
-      IF(lwp) WRITE(numout,*) '      nb of seconds per minute            rmmss = ', rmmss, ' s'
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) '      earth radius                         ra   = ', ra, ' m'
-      IF(lwp) WRITE(numout,*) '      gravity                              grav = ', grav , ' m/s^2'
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) '      triple point of temperature      rtt      = ', rtt     , ' K'
-      IF(lwp) WRITE(numout,*) '      freezing point of water          rt0      = ', rt0     , ' K'
-      IF(lwp) WRITE(numout,*) '      melting point of snow            rt0_snow = ', rt0_snow, ' K'
-      IF(lwp) WRITE(numout,*) '      melting point of ice             rt0_ice  = ', rt0_ice , ' K'
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) '   reference density and heat capacity now defined in eosbn2.f90'
-              
-#if defined key_si3 || defined key_cice
-      xlsn = lfus * rhosn        ! volumetric latent heat fusion of snow [J/m3]
-#else
-      cpic = rcpic / rhoic       ! specific heat for ice   [J/Kg/K]
-      lfus = xlsn / rhosn        ! latent heat of fusion of fresh ice
-#endif
-#if defined key_si3
-      r1_rhoic = 1._wp / rhoic
-      r1_rhosn = 1._wp / rhosn
-      r1_cpic  = 1._wp / cpic
-#endif
+
+      r1_rhoi = 1._wp / rhoi
+      r1_rhos = 1._wp / rhos
+      r1_rcpi = 1._wp / rcpi
+
       IF(lwp) THEN
          WRITE(numout,*)
-#if defined key_cice
-         WRITE(numout,*) '      thermal conductivity of the snow          = ', rcdsn   , ' J/s/m/K'
-#endif
-         WRITE(numout,*) '      thermal conductivity of pure ice          = ', rcdic   , ' J/s/m/K'
-         WRITE(numout,*) '      fresh ice specific heat                   = ', cpic    , ' J/kg/K'
-         WRITE(numout,*) '      latent heat of fusion of fresh ice / snow = ', lfus    , ' J/kg'
-#if defined key_si3 || defined key_cice
-         WRITE(numout,*) '      latent heat of subl.  of fresh ice / snow = ', lsub    , ' J/kg'
-#else
-         WRITE(numout,*) '      density times specific heat for snow      = ', rcpsn   , ' J/m^3/K' 
-         WRITE(numout,*) '      density times specific heat for ice       = ', rcpic   , ' J/m^3/K'
-         WRITE(numout,*) '      volumetric latent heat fusion of sea ice  = ', xlic    , ' J/m' 
-         WRITE(numout,*) '      latent heat of sublimation of snow        = ', xsn     , ' J/kg' 
-#endif
-         WRITE(numout,*) '      volumetric latent heat fusion of snow     = ', xlsn    , ' J/m^3' 
-         WRITE(numout,*) '      density of sea ice                        = ', rhoic   , ' kg/m^3'
-         WRITE(numout,*) '      density of snow                           = ', rhosn   , ' kg/m^3'
-         WRITE(numout,*) '      density of freshwater (in melt ponds)     = ', rhofw   , ' kg/m^3'
-         WRITE(numout,*) '      emissivity of snow or ice                 = ', emic  
-         WRITE(numout,*) '      salinity of ice                           = ', sice    , ' psu'
-         WRITE(numout,*) '      salinity of sea                           = ', soce    , ' psu'
-         WRITE(numout,*) '      latent heat of evaporation (water)        = ', cevap   , ' J/m^3' 
-         WRITE(numout,*) '      correction factor for solar radiation     = ', srgamma 
+         WRITE(numout,*) 'phy_cst : initialization of ocean parameters and constants'
+         WRITE(numout,*) '~~~~~~~'
+         WRITE(numout,*) '      mathematical constant                 rpi = ', rpi
+         WRITE(numout,*) '      day                                rday   = ', rday,   ' s'
+         WRITE(numout,*) '      sideral year                       rsiyea = ', rsiyea, ' s'
+         WRITE(numout,*) '      sideral day                        rsiday = ', rsiday, ' s'
+         WRITE(numout,*) '      omega                              omega  = ', omega,  ' s^-1'
+         WRITE(numout,*)
+         WRITE(numout,*) '      nb of months per year               raamo = ', raamo, ' months'
+         WRITE(numout,*) '      nb of hours per day                 rjjhh = ', rjjhh, ' hours'
+         WRITE(numout,*) '      nb of minutes per hour              rhhmm = ', rhhmm, ' mn'
+         WRITE(numout,*) '      nb of seconds per minute            rmmss = ', rmmss, ' s'
+         WRITE(numout,*)
+         WRITE(numout,*) '      earth radius                         ra   = ', ra   , ' m'
+         WRITE(numout,*) '      gravity                              grav = ', grav , ' m/s^2'
+         WRITE(numout,*)
+         WRITE(numout,*) '      freezing point of water              rt0  = ', rt0  , ' K'
+         WRITE(numout,*)
+         WRITE(numout,*) '   reference density and heat capacity now defined in eosbn2.f90'
+         WRITE(numout,*)
+         WRITE(numout,*) '      thermal conductivity of pure ice          = ', rcnd_i  , ' J/s/m/K'
+         WRITE(numout,*) '      thermal conductivity of snow is defined in a namelist '
+         WRITE(numout,*) '      fresh ice specific heat                   = ', rcpi    , ' J/kg/K'
+         WRITE(numout,*) '      latent heat of fusion of fresh ice / snow = ', rLfus   , ' J/kg'
+         WRITE(numout,*) '      latent heat of subl.  of fresh ice / snow = ', rLsub   , ' J/kg'
+         WRITE(numout,*) '      density of sea ice                        = ', rhoi    , ' kg/m^3'
+         WRITE(numout,*) '      density of snow                           = ', rhos    , ' kg/m^3'
+         WRITE(numout,*) '      density of freshwater (in melt ponds)     = ', rhow    , ' kg/m^3'
+         WRITE(numout,*) '      salinity of ice (for pisces)              = ', sice    , ' psu'
+         WRITE(numout,*) '      salinity of sea (for pisces and isf)      = ', soce    , ' psu'
+         WRITE(numout,*) '      latent heat of evaporation (water)        = ', rLevap  , ' J/m^3' 
          WRITE(numout,*) '      von Karman constant                       = ', vkarmn 
          WRITE(numout,*) '      Stefan-Boltzmann constant                 = ', stefan  , ' J/s/m^2/K^4'
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/divhor.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/divhor.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/divhor.F90	(revision 10288)
@@ -44,5 +44,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynadv.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynadv.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynadv.F90	(revision 10288)
@@ -49,5 +49,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynadv_cen2.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynadv_cen2.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynadv_cen2.F90	(revision 10288)
@@ -31,5 +31,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynadv_ubs.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynadv_ubs.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynadv_ubs.F90	(revision 10288)
@@ -37,5 +37,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynhpg.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynhpg.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynhpg.F90	(revision 10288)
@@ -77,5 +77,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynkeg.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynkeg.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynkeg.F90	(revision 10288)
@@ -40,5 +40,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynldf.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynldf.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynldf.F90	(revision 10288)
@@ -39,5 +39,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynldf_iso.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynldf_iso.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynldf_iso.F90	(revision 10288)
@@ -45,5 +45,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynldf_lap_blp.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynldf_lap_blp.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynldf_lap_blp.F90	(revision 10288)
@@ -31,5 +31,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynnxt.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynnxt.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynnxt.F90	(revision 10288)
@@ -60,5 +60,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynspg.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynspg.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynspg.F90	(revision 10288)
@@ -49,5 +49,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynspg_exp.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynspg_exp.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynspg_exp.F90	(revision 10288)
@@ -34,5 +34,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynspg_ts.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynspg_ts.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynspg_ts.F90	(revision 10288)
@@ -90,5 +90,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -1114,10 +1114,4 @@
                             &   ) * ssvmask(ji,jj)
  
-!jth implicit bottom friction:
-                  IF ( ll_wd ) THEN ! revert to explicit for bit comparison tests in non wad runs
-                     ua_e(ji,jj) =  ua_e(ji,jj) /(1.0 -   rdtbt * zCdU_u(ji,jj) * hur_e(ji,jj))
-                     va_e(ji,jj) =  va_e(ji,jj) /(1.0 -   rdtbt * zCdU_v(ji,jj) * hvr_e(ji,jj))
-                  ENDIF
-
                END DO
             END DO
@@ -1144,4 +1138,13 @@
                             &               +    hv_n(ji,jj)  * zv_frc(ji,jj) ) &
                             &   ) * zhvra
+               END DO
+            END DO
+         ENDIF
+!jth implicit bottom friction:
+         IF ( ll_wd ) THEN ! revert to explicit for bit comparison tests in non wad runs
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                     ua_e(ji,jj) =  ua_e(ji,jj) /(1.0 -   rdtbt * zCdU_u(ji,jj) * hur_e(ji,jj))
+                     va_e(ji,jj) =  va_e(ji,jj) /(1.0 -   rdtbt * zCdU_v(ji,jj) * hvr_e(ji,jj))
                END DO
             END DO
@@ -1393,5 +1396,5 @@
       IF( TRIM(cdrw) == 'READ' ) THEN        ! Read/initialise 
          !                                   ! ---------------
-         IF( ln_rstart .AND. ln_bt_fw ) THEN    !* Read the restart file
+         IF( ln_rstart .AND. ln_bt_fw .AND. (neuler/=0) ) THEN    !* Read the restart file
             CALL iom_get( numror, jpdom_autoglo, 'ub2_b'  , ub2_b  (:,:), ldxios = lrxios )   
             CALL iom_get( numror, jpdom_autoglo, 'vb2_b'  , vb2_b  (:,:), ldxios = lrxios ) 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynvor.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynvor.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynvor.F90	(revision 10288)
@@ -92,5 +92,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynzad.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynzad.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynzad.F90	(revision 10288)
@@ -32,5 +32,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -89,24 +89,13 @@
       !
       ! Surface and bottom advective fluxes set to zero
-      IF( ln_isfcav ) THEN
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1           ! vector opt.
-               zwuw(ji,jj, 1:miku(ji,jj) ) = 0._wp
-               zwvw(ji,jj, 1:mikv(ji,jj) ) = 0._wp
-               zwuw(ji,jj,jpk) = 0._wp
-               zwvw(ji,jj,jpk) = 0._wp
-            END DO
-         END DO
-      ELSE
-         DO jj = 2, jpjm1        
-            DO ji = fs_2, fs_jpim1           ! vector opt.
-               zwuw(ji,jj, 1 ) = 0._wp
-               zwvw(ji,jj, 1 ) = 0._wp
-               zwuw(ji,jj,jpk) = 0._wp
-               zwvw(ji,jj,jpk) = 0._wp
-            END DO  
-         END DO
-      END IF
-
+      DO jj = 2, jpjm1        
+         DO ji = fs_2, fs_jpim1           ! vector opt.
+            zwuw(ji,jj, 1 ) = 0._wp
+            zwvw(ji,jj, 1 ) = 0._wp
+            zwuw(ji,jj,jpk) = 0._wp
+            zwvw(ji,jj,jpk) = 0._wp
+         END DO  
+      END DO
+      !
       DO jk = 1, jpkm1              ! Vertical momentum advection at u- and v-points
          DO jj = 2, jpjm1
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynzdf.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynzdf.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/dynzdf.F90	(revision 10288)
@@ -41,5 +41,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/sshwzv.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/sshwzv.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/DYN/sshwzv.F90	(revision 10288)
@@ -48,5 +48,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/flo4rk.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/flo4rk.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/flo4rk.F90	(revision 10288)
@@ -31,5 +31,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/flo_oce.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/flo_oce.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/flo_oce.F90	(revision 10288)
@@ -52,5 +52,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/floats.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/floats.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/floats.F90	(revision 10288)
@@ -35,5 +35,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -142,7 +142,10 @@
 CONTAINS
    SUBROUTINE flo_stp( kt )          ! Empty routine
+      IMPLICIT NONE
+      INTEGER, INTENT( in ) :: kt
       WRITE(*,*) 'flo_stp: You should not have seen this print! error?', kt
    END SUBROUTINE flo_stp
    SUBROUTINE flo_init          ! Empty routine
+      IMPLICIT NONE
    END SUBROUTINE flo_init
 #endif
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/floblk.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/floblk.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/floblk.F90	(revision 10288)
@@ -25,5 +25,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/flodom.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/flodom.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/flodom.F90	(revision 10288)
@@ -40,5 +40,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/florst.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/florst.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/florst.F90	(revision 10288)
@@ -29,5 +29,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/flowri.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/flowri.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/FLO/flowri.F90	(revision 10288)
@@ -40,5 +40,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icb_oce.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icb_oce.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icb_oce.F90	(revision 10288)
@@ -111,4 +111,6 @@
    INTEGER , PUBLIC ::   nn_test_icebergs                !: Create icebergs in absence of a restart file from the supplied class nb
    REAL(wp), PUBLIC, DIMENSION(4) ::   rn_test_box       !: lon1,lon2,lat1,lat2 box to create them in
+   LOGICAL , PUBLIC ::   ln_use_calving                  !: Force use of calving data even with nn_test_icebergs > 0 
+                                                         !  (default is not to use calving data with test bergs)
    INTEGER , PUBLIC ::   nn_sample_rate                  !: Timesteps between sampling of position for trajectory storage
    INTEGER , PUBLIC ::   nn_verbose_write                !: timesteps between verbose messages
@@ -146,5 +148,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbclv.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbclv.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbclv.F90	(revision 10288)
@@ -34,5 +34,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -63,5 +63,5 @@
       berg_grid%calving_hflx(:,:) = src_calving_hflx(:,:) * tmask_i(:,:)
 
-      IF( ll_first_call .AND. .NOT. l_restarted_bergs) THEN      ! This is a hack to simplify initialization
+      IF( ll_first_call .AND. .NOT. l_restarted_bergs ) THEN      ! This is a hack to simplify initialization
          ll_first_call = .FALSE.
          !do jn=1, nclasses
@@ -100,5 +100,5 @@
 
 
-   SUBROUTINE icb_clv()
+   SUBROUTINE icb_clv( kt )
       !!----------------------------------------------------------------------
       !!                 ***  ROUTINE icb_clv  ***
@@ -114,4 +114,5 @@
       !!                is considered
       !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt
       INTEGER       ::   ji, jj, jn   ! dummy loop indices
       INTEGER       ::   icnt, icntmax
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbdia.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbdia.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbdia.F90	(revision 10288)
@@ -51,4 +51,6 @@
 
    REAL(wp), DIMENSION(:,:)  , ALLOCATABLE, PUBLIC  ::   berg_melt       ! Melting+erosion rate of icebergs     [kg/s/m2]
+   REAL(wp), DIMENSION(:,:)  , ALLOCATABLE, PUBLIC  ::   berg_melt_hcflx ! Heat flux to ocean due to heat content of melting icebergs [J/s/m2]
+   REAL(wp), DIMENSION(:,:)  , ALLOCATABLE, PUBLIC  ::   berg_melt_qlat  ! Heat flux to ocean due to latent heat of melting icebergs [J/s/m2]
    REAL(wp), DIMENSION(:,:)  , ALLOCATABLE, PUBLIC  ::   buoy_melt       ! Buoyancy component of melting rate   [kg/s/m2]
    REAL(wp), DIMENSION(:,:)  , ALLOCATABLE, PUBLIC  ::   eros_melt       ! Erosion component of melting rate    [kg/s/m2]
@@ -90,5 +92,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -101,4 +103,6 @@
 
       ALLOCATE( berg_melt    (jpi,jpj)   )           ;   berg_melt   (:,:)   = 0._wp
+      ALLOCATE( berg_melt_hcflx(jpi,jpj) )           ;   berg_melt_hcflx(:,:)   = 0._wp
+      ALLOCATE( berg_melt_qlat(jpi,jpj)  )           ;   berg_melt_qlat(:,:)   = 0._wp
       ALLOCATE( buoy_melt    (jpi,jpj)   )           ;   buoy_melt   (:,:)   = 0._wp
       ALLOCATE( eros_melt    (jpi,jpj)   )           ;   eros_melt   (:,:)   = 0._wp
@@ -364,4 +368,6 @@
       IF( .NOT.ln_bergdia )   RETURN
       berg_melt   (:,:)   = 0._wp
+      berg_melt_hcflx(:,:)   = 0._wp
+      berg_melt_qlat(:,:)   = 0._wp
       buoy_melt   (:,:)   = 0._wp
       eros_melt   (:,:)   = 0._wp
@@ -384,4 +390,7 @@
       !
       CALL iom_put( "berg_melt"        , berg_melt   (:,:)   )   ! Melt rate of icebergs                     [kg/m2/s]
+      !! NB. The berg_melt_hcflx field is currently always zero - see comment in icbthm.F90
+      CALL iom_put( "berg_melt_hcflx"  , berg_melt_hcflx(:,:))   ! Heat flux to ocean due to heat content of melting icebergs [J/m2/s]
+      CALL iom_put( "berg_melt_qlat"   , berg_melt_qlat(:,:) )   ! Heat flux to ocean due to latent heat of melting icebergs [J/m2/s]
       CALL iom_put( "berg_buoy_melt"   , buoy_melt   (:,:)   )   ! Buoyancy component of iceberg melt rate   [kg/m2/s]
       CALL iom_put( "berg_eros_melt"   , eros_melt   (:,:)   )   ! Erosion component of iceberg melt rate    [kg/m2/s]
@@ -471,5 +480,5 @@
 
 
-   SUBROUTINE icb_dia_melt(ki, kj, pmnew, pheat, pmass_scale,     &
+   SUBROUTINE icb_dia_melt(ki, kj, pmnew, pheat_hcflux, pheat_latent, pmass_scale,     &
       &                    pdM, pdMbitsE, pdMbitsM, pdMb, pdMe,   &
       &                    pdMv, pz1_dt_e1e2 )
@@ -477,5 +486,5 @@
       !!----------------------------------------------------------------------
       INTEGER , INTENT(in) ::   ki, kj
-      REAL(wp), INTENT(in) ::   pmnew, pheat, pmass_scale
+      REAL(wp), INTENT(in) ::   pmnew, pheat_hcflux, pheat_latent, pmass_scale
       REAL(wp), INTENT(in) ::   pdM, pdMbitsE, pdMbitsM, pdMb, pdMe, pdMv, pz1_dt_e1e2
       !!----------------------------------------------------------------------
@@ -484,4 +493,6 @@
       !
       berg_melt (ki,kj) = berg_melt (ki,kj) + pdM      * pz1_dt_e1e2   ! kg/m2/s
+      berg_melt_hcflx (ki,kj) = berg_melt_hcflx (ki,kj) + pheat_hcflux * pz1_dt_e1e2   ! J/m2/s
+      berg_melt_qlat (ki,kj) = berg_melt_qlat (ki,kj) + pheat_latent * pz1_dt_e1e2   ! J/m2/s
       bits_src  (ki,kj) = bits_src  (ki,kj) + pdMbitsE * pz1_dt_e1e2   ! mass flux into bergy bitskg/m2/s
       bits_melt (ki,kj) = bits_melt (ki,kj) + pdMbitsM * pz1_dt_e1e2   ! melt rate of bergy bits kg/m2/s
@@ -489,5 +500,5 @@
       eros_melt (ki,kj) = eros_melt (ki,kj) + pdMe     * pz1_dt_e1e2   ! erosion rate kg/m2/s
       conv_melt (ki,kj) = conv_melt (ki,kj) + pdMv     * pz1_dt_e1e2   ! kg/m2/s
-      heat_to_ocean_net = heat_to_ocean_net + pheat * pmass_scale * berg_dt         ! J
+      heat_to_ocean_net = heat_to_ocean_net + (pheat_hcflux + pheat_latent) * pmass_scale * berg_dt         ! J
       IF( pmnew <= 0._wp ) nbergs_melted = nbergs_melted + 1                        ! Delete the berg if completely melted
       !
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbdyn.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbdyn.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbdyn.F90	(revision 10288)
@@ -27,5 +27,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbini.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbini.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbini.F90	(revision 10288)
@@ -42,5 +42,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -228,5 +228,5 @@
 
       ! when not generating test icebergs we need to setup calving file
-      IF( nn_test_icebergs < 0 ) THEN
+      IF( nn_test_icebergs < 0 .OR. ln_use_calving ) THEN
          !
          ! maximum distribution class array does not change in time so read it once
@@ -358,5 +358,5 @@
          &              rn_bits_erosion_fraction        , rn_sicn_shift       , ln_passive_mode      ,   &
          &              ln_time_average_weight          , nn_test_icebergs    , rn_test_box          ,   &
-         &              rn_speed_limit , cn_dir, sn_icb
+         &              ln_use_calving , rn_speed_limit , cn_dir, sn_icb
       !!----------------------------------------------------------------------
 
@@ -399,4 +399,10 @@
          IF(lwp) WRITE(numout,*) '   ==>>>   Resetting of nn_test_icebergs to ', nclasses
          nn_test_icebergs = nclasses
+      ENDIF
+      !
+      IF( nn_test_icebergs < 0 .AND. .NOT. ln_use_calving ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '   ==>>>   Resetting ln_use_calving to .true. since we are not using test icebergs'
+         ln_use_calving = .true.
       ENDIF
       !
@@ -440,4 +446,5 @@
          WRITE(numout,*) '   Create icebergs in absence of a restart file   nn_test_icebergs  = ', nn_test_icebergs
          WRITE(numout,*) '                   in lon/lat box                                   = ', rn_test_box
+         WRITE(numout,*) '   Use calving data even if nn_test_icebergs > 0    ln_use_calving  = ', ln_use_calving
          WRITE(numout,*) '   CFL speed limit for a berg            speed_limit                = ', rn_speed_limit
          WRITE(numout,*) '   Writing Iceberg status information to icebergs.stat file        '
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icblbc.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icblbc.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icblbc.F90	(revision 10288)
@@ -66,5 +66,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbrst.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbrst.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbrst.F90	(revision 10288)
@@ -46,5 +46,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -60,5 +60,5 @@
       INTEGER                      ::   idim, ivar, iatt
       INTEGER                      ::   jn, iunlim_dim, ibergs_in_file
-      INTEGER                      ::   ii,ij,iclass
+      INTEGER                      ::   ii, ij, iclass, ibase_err, imax_icb
       REAL(wp), DIMENSION(nkounts) ::   zdata      
       LOGICAL                      ::   ll_found_restart
@@ -77,4 +77,5 @@
       CALL iom_open( TRIM(cl_path)//cl_filename, ncid )
 
+      imax_icb = 0
       IF( iom_file(ncid)%iduld .GE. 0) THEN
 
@@ -96,4 +97,5 @@
                CALL iom_get( ncid, jpdom_unknown, 'number'       , zdata(:) , ktime=jn, kstart=(/1/), kcount=(/nkounts/) )
                localberg%number(:) = INT(zdata(:))
+               imax_icb = MAX( imax_icb, INT(zdata(1)) )
                CALL iom_get( ncid, 'mass_scaling' , localberg%mass_scaling, ktime=jn )
                CALL iom_get( ncid, 'lon'          , localpt%lon           , ktime=jn )
@@ -117,4 +119,6 @@
          END DO
          !
+      ELSE
+         ibergs_in_file = 0
       ENDIF 
 
@@ -127,8 +131,11 @@
       CALL iom_get( ncid, jpdom_unknown, 'kount' , zdata(:) )
       num_bergs(:) = INT(zdata(:))
-
-      ! Sanity check
+      ! Close file
+      CALL iom_close( ncid )
+      !
+
+      ! Sanity checks
       jn = icb_utl_count()
-      IF (nn_verbose_level >= 0)   &
+      IF ( lwp .AND. nn_verbose_level >= 0 )   &
          WRITE(numout,'(2(a,i5))') 'icebergs, read_restart_bergs: # bergs =',jn,' on PE',narea-1
       IF( lk_mpp ) THEN
@@ -137,11 +144,37 @@
          CALL mpp_sum(jn)
       ENDIF
-      IF(lwp)   WRITE(numout,'(a,i5,a,i5,a)') 'icebergs, read_restart_bergs: there were',ibergs_in_file,   &
+      IF( lwp )   WRITE(numout,'(a,i5,a,i5,a)') 'icebergs, icb_rst_read: there were',ibergs_in_file,   &
          &                                    ' bergs in the restart file and', jn,' bergs have been read'
       !
-      ! Finish up
-      CALL iom_close( ncid )
-      !
-      IF( lwp .AND. nn_verbose_level >= 0)  WRITE(numout,'(a)') 'icebergs, read_restart_bergs: completed'
+      ! Confirm that all areas have a suitable base for assigning new iceberg
+      ! numbers. This will not be the case if restarting from a collated dataset
+      ! (even if using the same processor decomposition)
+      !
+      ibase_err = 0
+      IF( num_bergs(1) < 0 .AND. num_bergs(1) /= narea - jpnij ) THEN
+         ! If this area has never calved a new berg then the base should be
+         ! set to narea - jpnij. If it is negative but something else then
+         ! a new base will be needed to guarantee unique, future iceberg numbers
+         ibase_err = 1
+      ELSEIF( MOD( num_bergs(1) - narea , jpnij ) /= 0 ) THEN
+         ! If this area has a base which is not in the set {narea + N*jpnij}
+         ! for positive integers N then a new base will be needed to guarantee 
+         ! unique, future iceberg numbers
+         ibase_err = 1
+      ENDIF
+      IF( lk_mpp ) THEN
+         CALL mpp_sum(ibase_err)
+      ENDIF
+      IF( ibase_err > 0 ) THEN
+         ! 
+         ! A new base is needed. The only secure solution is to set bases such that
+         ! all future icebergs numbers will be greater than the current global maximum
+         IF( lk_mpp ) THEN
+            CALL mpp_max(imax_icb)
+         ENDIF
+         num_bergs(1) = imax_icb - jpnij + narea
+      ENDIF
+      !
+      IF( lwp .AND. nn_verbose_level >= 0 )  WRITE(numout,'(a)') 'icebergs, icb_rst_read: completed'
       !
    END SUBROUTINE icb_rst_read
@@ -163,199 +196,220 @@
       !!----------------------------------------------------------------------
 
-      ! Assume we write iceberg restarts to same directory as ocean restarts.
-      cl_path = TRIM(cn_ocerst_outdir)
-      IF( cl_path(LEN_TRIM(cl_path):) /= '/' ) cl_path = TRIM(cl_path) // '/'
-      IF( lk_mpp ) THEN
-         WRITE(cl_filename,'(A,"_icebergs_",I8.8,"_restart_",I4.4,".nc")') TRIM(cexper), kt, narea-1
-      ELSE
-         WRITE(cl_filename,'(A,"_icebergs_",I8.8,"_restart.nc")') TRIM(cexper), kt
+      ! Following the normal restart procedure, this routine will be called
+      ! the timestep before a restart stage as well as the restart timestep.
+      ! This is a performance step enabling the file to be opened and contents
+      ! defined in advance of the write. This is not possible with icebergs
+      ! since the number of bergs to be written could change between timesteps
+      IF( kt == nitrst ) THEN
+         ! Only operate on the restart timestep itself.
+         ! Assume we write iceberg restarts to same directory as ocean restarts.
+         cl_path = TRIM(cn_ocerst_outdir)
+         IF( cl_path(LEN_TRIM(cl_path):) /= '/' ) cl_path = TRIM(cl_path) // '/'
+         IF( lk_mpp ) THEN
+            WRITE(cl_filename,'(A,"_icebergs_",I8.8,"_restart_",I4.4,".nc")') TRIM(cexper), kt, narea-1
+         ELSE
+            WRITE(cl_filename,'(A,"_icebergs_",I8.8,"_restart.nc")') TRIM(cexper), kt
+         ENDIF
+         IF ( lwp .AND. nn_verbose_level >= 0) WRITE(numout,'(2a)') 'icebergs, write_restart: creating ',  &
+           &                                                         TRIM(cl_path)//TRIM(cl_filename)
+   
+         nret = NF90_CREATE(TRIM(cl_path)//TRIM(cl_filename), NF90_CLOBBER, ncid)
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_create failed')
+   
+         ! Dimensions
+         nret = NF90_DEF_DIM(ncid, 'x', jpi, ix_dim)
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim x failed')
+   
+         nret = NF90_DEF_DIM(ncid, 'y', jpj, iy_dim)
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim y failed')
+   
+         nret = NF90_DEF_DIM(ncid, 'c', nclasses, nc_dim)
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim c failed')
+   
+         nret = NF90_DEF_DIM(ncid, 'k', nkounts, ik_dim)
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim k failed')
+   
+         ! global attributes
+         IF( lk_mpp ) THEN
+            ! Set domain parameters (assume jpdom_local_full)
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_number_total'   , jpnij              )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_number'         , narea-1            )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_dimensions_ids' , (/1     , 2     /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_size_global'    , (/jpiglo, jpjglo/) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_size_local'     , (/jpi   , jpj   /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_position_first' , (/nimpp , njmpp /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_position_last'  , (/nimpp + jpi - 1 , njmpp + jpj - 1  /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_halo_size_start', (/nldi - 1        , nldj - 1         /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_halo_size_end'  , (/jpi - nlei      , jpj - nlej       /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_type'           , 'BOX'              )
+         ENDIF
+         
+         IF (associated(first_berg)) then
+            nret = NF90_DEF_DIM(ncid, 'n', NF90_UNLIMITED, in_dim)
+            IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim n failed')
+         ENDIF
+   
+         ! Variables
+         nret = NF90_DEF_VAR(ncid, 'kount'       , NF90_INT   , (/ ik_dim /), nkountid)
+         nret = NF90_DEF_VAR(ncid, 'calving'     , NF90_DOUBLE, (/ ix_dim, iy_dim /), ncalvid)
+         nret = NF90_DEF_VAR(ncid, 'calving_hflx', NF90_DOUBLE, (/ ix_dim, iy_dim /), ncalvhid)
+         nret = NF90_DEF_VAR(ncid, 'stored_ice'  , NF90_DOUBLE, (/ ix_dim, iy_dim, nc_dim /), nsiceid)
+         nret = NF90_DEF_VAR(ncid, 'stored_heat' , NF90_DOUBLE, (/ ix_dim, iy_dim /), nsheatid)
+   
+         ! Attributes
+         nret = NF90_PUT_ATT(ncid, ncalvid , 'long_name', 'iceberg calving')
+         nret = NF90_PUT_ATT(ncid, ncalvid , 'units', 'some')
+         nret = NF90_PUT_ATT(ncid, ncalvhid, 'long_name', 'heat flux associated with iceberg calving')
+         nret = NF90_PUT_ATT(ncid, ncalvhid, 'units', 'some')
+         nret = NF90_PUT_ATT(ncid, nsiceid , 'long_name', 'stored ice used to calve icebergs')
+         nret = NF90_PUT_ATT(ncid, nsiceid , 'units', 'kg/s')
+         nret = NF90_PUT_ATT(ncid, nsheatid, 'long_name', 'heat in stored ice used to calve icebergs')
+         nret = NF90_PUT_ATT(ncid, nsheatid, 'units', 'J/kg/s')
+   
+         IF ( ASSOCIATED(first_berg) ) THEN
+   
+            ! Only add berg variables for this PE if we have anything to say
+   
+            ! Variables
+            nret = NF90_DEF_VAR(ncid, 'lon', NF90_DOUBLE, in_dim, nlonid)
+            nret = NF90_DEF_VAR(ncid, 'lat', NF90_DOUBLE, in_dim, nlatid)
+            nret = NF90_DEF_VAR(ncid, 'xi', NF90_DOUBLE, in_dim, nxid)
+            nret = NF90_DEF_VAR(ncid, 'yj', NF90_DOUBLE, in_dim, nyid)
+            nret = NF90_DEF_VAR(ncid, 'uvel', NF90_DOUBLE, in_dim, nuvelid)
+            nret = NF90_DEF_VAR(ncid, 'vvel', NF90_DOUBLE, in_dim, nvvelid)
+            nret = NF90_DEF_VAR(ncid, 'mass', NF90_DOUBLE, in_dim, nmassid)
+            nret = NF90_DEF_VAR(ncid, 'thickness', NF90_DOUBLE, in_dim, nthicknessid)
+            nret = NF90_DEF_VAR(ncid, 'width', NF90_DOUBLE, in_dim, nwidthid)
+            nret = NF90_DEF_VAR(ncid, 'length', NF90_DOUBLE, in_dim, nlengthid)
+            nret = NF90_DEF_VAR(ncid, 'number', NF90_INT, (/ik_dim,in_dim/), numberid)
+            nret = NF90_DEF_VAR(ncid, 'year', NF90_INT, in_dim, nyearid)
+            nret = NF90_DEF_VAR(ncid, 'day', NF90_DOUBLE, in_dim, ndayid)
+            nret = NF90_DEF_VAR(ncid, 'mass_scaling', NF90_DOUBLE, in_dim, nscaling_id)
+            nret = NF90_DEF_VAR(ncid, 'mass_of_bits', NF90_DOUBLE, in_dim, nmass_of_bits_id)
+            nret = NF90_DEF_VAR(ncid, 'heat_density', NF90_DOUBLE, in_dim, nheat_density_id)
+   
+            ! Attributes
+            nret = NF90_PUT_ATT(ncid, nlonid, 'long_name', 'longitude')
+            nret = NF90_PUT_ATT(ncid, nlonid, 'units', 'degrees_E')
+            nret = NF90_PUT_ATT(ncid, nlatid, 'long_name', 'latitude')
+            nret = NF90_PUT_ATT(ncid, nlatid, 'units', 'degrees_N')
+            nret = NF90_PUT_ATT(ncid, nxid, 'long_name', 'x grid box position')
+            nret = NF90_PUT_ATT(ncid, nxid, 'units', 'fractional')
+            nret = NF90_PUT_ATT(ncid, nyid, 'long_name', 'y grid box position')
+            nret = NF90_PUT_ATT(ncid, nyid, 'units', 'fractional')
+            nret = NF90_PUT_ATT(ncid, nuvelid, 'long_name', 'zonal velocity')
+            nret = NF90_PUT_ATT(ncid, nuvelid, 'units', 'm/s')
+            nret = NF90_PUT_ATT(ncid, nvvelid, 'long_name', 'meridional velocity')
+            nret = NF90_PUT_ATT(ncid, nvvelid, 'units', 'm/s')
+            nret = NF90_PUT_ATT(ncid, nmassid, 'long_name', 'mass')
+            nret = NF90_PUT_ATT(ncid, nmassid, 'units', 'kg')
+            nret = NF90_PUT_ATT(ncid, nthicknessid, 'long_name', 'thickness')
+            nret = NF90_PUT_ATT(ncid, nthicknessid, 'units', 'm')
+            nret = NF90_PUT_ATT(ncid, nwidthid, 'long_name', 'width')
+            nret = NF90_PUT_ATT(ncid, nwidthid, 'units', 'm')
+            nret = NF90_PUT_ATT(ncid, nlengthid, 'long_name', 'length')
+            nret = NF90_PUT_ATT(ncid, nlengthid, 'units', 'm')
+            nret = NF90_PUT_ATT(ncid, numberid, 'long_name', 'iceberg number on this processor')
+            nret = NF90_PUT_ATT(ncid, numberid, 'units', 'count')
+            nret = NF90_PUT_ATT(ncid, nyearid, 'long_name', 'calendar year of calving event')
+            nret = NF90_PUT_ATT(ncid, nyearid, 'units', 'years')
+            nret = NF90_PUT_ATT(ncid, ndayid, 'long_name', 'year day of calving event')
+            nret = NF90_PUT_ATT(ncid, ndayid, 'units', 'days')
+            nret = NF90_PUT_ATT(ncid, nscaling_id, 'long_name', 'scaling factor for mass of calving berg')
+            nret = NF90_PUT_ATT(ncid, nscaling_id, 'units', 'none')
+            nret = NF90_PUT_ATT(ncid, nmass_of_bits_id, 'long_name', 'mass of bergy bits')
+            nret = NF90_PUT_ATT(ncid, nmass_of_bits_id, 'units', 'kg')
+            nret = NF90_PUT_ATT(ncid, nheat_density_id, 'long_name', 'heat density')
+            nret = NF90_PUT_ATT(ncid, nheat_density_id, 'units', 'J/kg')
+   
+         ENDIF ! associated(first_berg)
+   
+         ! End define mode
+         nret = NF90_ENDDEF(ncid)
+   
+         ! --------------------------------
+         ! now write some data
+   
+         nstrt3(1) = 1
+         nstrt3(2) = 1
+         nlngth3(1) = jpi
+         nlngth3(2) = jpj
+         nlngth3(3) = 1
+   
+         DO jn=1,nclasses
+            griddata(:,:,1) = berg_grid%stored_ice(:,:,jn)
+            nstrt3(3) = jn
+            nret = NF90_PUT_VAR( ncid, nsiceid, griddata, nstrt3, nlngth3 )
+            IF (nret .ne. NF90_NOERR) THEN
+               IF( lwp ) WRITE(numout,*) TRIM(NF90_STRERROR( nret ))
+               CALL ctl_stop('icebergs, write_restart: nf_put_var stored_ice failed')
+            ENDIF
+         ENDDO
+         IF( lwp ) WRITE(numout,*) 'file: ',TRIM(cl_path)//TRIM(cl_filename),' var: stored_ice  written'
+   
+         nret = NF90_PUT_VAR( ncid, nkountid, num_bergs(:) )
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var kount failed')
+   
+         nret = NF90_PUT_VAR( ncid, nsheatid, berg_grid%stored_heat(:,:) )
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var stored_heat failed')
+         IF( lwp ) WRITE(numout,*) 'file: ',TRIM(cl_path)//TRIM(cl_filename),' var: stored_heat written'
+   
+         nret = NF90_PUT_VAR( ncid, ncalvid , src_calving(:,:) )
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var calving failed')
+         nret = NF90_PUT_VAR( ncid, ncalvhid, src_calving_hflx(:,:) )
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var calving_hflx failed')
+         IF( lwp ) WRITE(numout,*) 'file: ',TRIM(cl_path)//TRIM(cl_filename),' var: calving written'
+   
+         IF ( ASSOCIATED(first_berg) ) THEN
+   
+            ! Write variables
+            ! just write out the current point of the trajectory
+   
+            this => first_berg
+            jn = 0
+            DO WHILE (ASSOCIATED(this))
+               pt => this%current_point
+               jn=jn+1
+   
+               nret = NF90_PUT_VAR(ncid, numberid, this%number, (/1,jn/), (/nkounts,1/) )
+               nret = NF90_PUT_VAR(ncid, nscaling_id, this%mass_scaling, (/ jn /) )
+   
+               nret = NF90_PUT_VAR(ncid, nlonid, pt%lon, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nlatid, pt%lat, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nxid, pt%xi, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nyid, pt%yj, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nuvelid, pt%uvel, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nvvelid, pt%vvel, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nmassid, pt%mass, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nthicknessid, pt%thickness, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nwidthid, pt%width, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nlengthid, pt%length, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nyearid, pt%year, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, ndayid, pt%day, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nmass_of_bits_id, pt%mass_of_bits, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nheat_density_id, pt%heat_density, (/ jn /) )
+   
+               this=>this%next
+            END DO
+            !
+         ENDIF ! associated(first_berg)
+   
+         ! Finish up
+         nret = NF90_CLOSE(ncid)
+         IF (nret /= NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_close failed')
+   
+         ! Sanity check
+         jn = icb_utl_count()
+         IF ( lwp .AND. nn_verbose_level >= 0)   &
+            WRITE(numout,'(2(a,i5))') 'icebergs, icb_rst_write: # bergs =',jn,' on PE',narea-1
+         IF( lk_mpp ) THEN
+            CALL mpp_sum(jn)
+         ENDIF
+         IF(lwp)   WRITE(numout,'(a,i5,a,i5,a)') 'icebergs, icb_rst_write: ', jn,   &
+            &                                    ' bergs in total have been written at timestep ', kt
+         !
+         ! Finish up
+         !
       ENDIF
-      IF (nn_verbose_level >= 0) WRITE(numout,'(2a)') 'icebergs, write_restart: creating ',TRIM(cl_path)//TRIM(cl_filename)
-
-      nret = NF90_CREATE(TRIM(cl_path)//TRIM(cl_filename), NF90_CLOBBER, ncid)
-      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_create failed')
-
-      ! Dimensions
-      nret = NF90_DEF_DIM(ncid, 'x', jpi, ix_dim)
-      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim x failed')
-
-      nret = NF90_DEF_DIM(ncid, 'y', jpj, iy_dim)
-      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim y failed')
-
-      nret = NF90_DEF_DIM(ncid, 'c', nclasses, nc_dim)
-      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim c failed')
-
-      nret = NF90_DEF_DIM(ncid, 'k', nkounts, ik_dim)
-      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim k failed')
-
-      ! global attributes
-      IF( lk_mpp ) THEN
-         ! Set domain parameters (assume jpdom_local_full)
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_number_total'   , jpnij              )
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_number'         , narea-1            )
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_dimensions_ids' , (/1     , 2     /) )
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_size_global'    , (/jpiglo, jpjglo/) )
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_size_local'     , (/jpi   , jpj   /) )
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_position_first' , (/nimpp , njmpp /) )
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_position_last'  , (/nimpp + jpi - 1 , njmpp + jpj - 1  /) )
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_halo_size_start', (/nldi - 1        , nldj - 1         /) )
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_halo_size_end'  , (/jpi - nlei      , jpj - nlej       /) )
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_type'           , 'BOX'              )
-      ENDIF
-      
-      IF (associated(first_berg)) then
-         nret = NF90_DEF_DIM(ncid, 'n', NF90_UNLIMITED, in_dim)
-         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim n failed')
-      ENDIF
-
-      ! Variables
-      nret = NF90_DEF_VAR(ncid, 'kount'       , NF90_INT   , (/ ik_dim /), nkountid)
-      nret = NF90_DEF_VAR(ncid, 'calving'     , NF90_DOUBLE, (/ ix_dim, iy_dim /), ncalvid)
-      nret = NF90_DEF_VAR(ncid, 'calving_hflx', NF90_DOUBLE, (/ ix_dim, iy_dim /), ncalvhid)
-      nret = NF90_DEF_VAR(ncid, 'stored_ice'  , NF90_DOUBLE, (/ ix_dim, iy_dim, nc_dim /), nsiceid)
-      nret = NF90_DEF_VAR(ncid, 'stored_heat' , NF90_DOUBLE, (/ ix_dim, iy_dim /), nsheatid)
-
-      ! Attributes
-      nret = NF90_PUT_ATT(ncid, ncalvid , 'long_name', 'iceberg calving')
-      nret = NF90_PUT_ATT(ncid, ncalvid , 'units', 'some')
-      nret = NF90_PUT_ATT(ncid, ncalvhid, 'long_name', 'heat flux associated with iceberg calving')
-      nret = NF90_PUT_ATT(ncid, ncalvhid, 'units', 'some')
-      nret = NF90_PUT_ATT(ncid, nsiceid , 'long_name', 'stored ice used to calve icebergs')
-      nret = NF90_PUT_ATT(ncid, nsiceid , 'units', 'kg/s')
-      nret = NF90_PUT_ATT(ncid, nsheatid, 'long_name', 'heat in stored ice used to calve icebergs')
-      nret = NF90_PUT_ATT(ncid, nsheatid, 'units', 'J/kg/s')
-
-      IF ( ASSOCIATED(first_berg) ) THEN
-
-         ! Only add berg variables for this PE if we have anything to say
-
-         ! Variables
-         nret = NF90_DEF_VAR(ncid, 'lon', NF90_DOUBLE, in_dim, nlonid)
-         nret = NF90_DEF_VAR(ncid, 'lat', NF90_DOUBLE, in_dim, nlatid)
-         nret = NF90_DEF_VAR(ncid, 'xi', NF90_DOUBLE, in_dim, nxid)
-         nret = NF90_DEF_VAR(ncid, 'yj', NF90_DOUBLE, in_dim, nyid)
-         nret = NF90_DEF_VAR(ncid, 'uvel', NF90_DOUBLE, in_dim, nuvelid)
-         nret = NF90_DEF_VAR(ncid, 'vvel', NF90_DOUBLE, in_dim, nvvelid)
-         nret = NF90_DEF_VAR(ncid, 'mass', NF90_DOUBLE, in_dim, nmassid)
-         nret = NF90_DEF_VAR(ncid, 'thickness', NF90_DOUBLE, in_dim, nthicknessid)
-         nret = NF90_DEF_VAR(ncid, 'width', NF90_DOUBLE, in_dim, nwidthid)
-         nret = NF90_DEF_VAR(ncid, 'length', NF90_DOUBLE, in_dim, nlengthid)
-         nret = NF90_DEF_VAR(ncid, 'number', NF90_INT, (/ik_dim,in_dim/), numberid)
-         nret = NF90_DEF_VAR(ncid, 'year', NF90_INT, in_dim, nyearid)
-         nret = NF90_DEF_VAR(ncid, 'day', NF90_DOUBLE, in_dim, ndayid)
-         nret = NF90_DEF_VAR(ncid, 'mass_scaling', NF90_DOUBLE, in_dim, nscaling_id)
-         nret = NF90_DEF_VAR(ncid, 'mass_of_bits', NF90_DOUBLE, in_dim, nmass_of_bits_id)
-         nret = NF90_DEF_VAR(ncid, 'heat_density', NF90_DOUBLE, in_dim, nheat_density_id)
-
-         ! Attributes
-         nret = NF90_PUT_ATT(ncid, nlonid, 'long_name', 'longitude')
-         nret = NF90_PUT_ATT(ncid, nlonid, 'units', 'degrees_E')
-         nret = NF90_PUT_ATT(ncid, nlatid, 'long_name', 'latitude')
-         nret = NF90_PUT_ATT(ncid, nlatid, 'units', 'degrees_N')
-         nret = NF90_PUT_ATT(ncid, nxid, 'long_name', 'x grid box position')
-         nret = NF90_PUT_ATT(ncid, nxid, 'units', 'fractional')
-         nret = NF90_PUT_ATT(ncid, nyid, 'long_name', 'y grid box position')
-         nret = NF90_PUT_ATT(ncid, nyid, 'units', 'fractional')
-         nret = NF90_PUT_ATT(ncid, nuvelid, 'long_name', 'zonal velocity')
-         nret = NF90_PUT_ATT(ncid, nuvelid, 'units', 'm/s')
-         nret = NF90_PUT_ATT(ncid, nvvelid, 'long_name', 'meridional velocity')
-         nret = NF90_PUT_ATT(ncid, nvvelid, 'units', 'm/s')
-         nret = NF90_PUT_ATT(ncid, nmassid, 'long_name', 'mass')
-         nret = NF90_PUT_ATT(ncid, nmassid, 'units', 'kg')
-         nret = NF90_PUT_ATT(ncid, nthicknessid, 'long_name', 'thickness')
-         nret = NF90_PUT_ATT(ncid, nthicknessid, 'units', 'm')
-         nret = NF90_PUT_ATT(ncid, nwidthid, 'long_name', 'width')
-         nret = NF90_PUT_ATT(ncid, nwidthid, 'units', 'm')
-         nret = NF90_PUT_ATT(ncid, nlengthid, 'long_name', 'length')
-         nret = NF90_PUT_ATT(ncid, nlengthid, 'units', 'm')
-         nret = NF90_PUT_ATT(ncid, numberid, 'long_name', 'iceberg number on this processor')
-         nret = NF90_PUT_ATT(ncid, numberid, 'units', 'count')
-         nret = NF90_PUT_ATT(ncid, nyearid, 'long_name', 'calendar year of calving event')
-         nret = NF90_PUT_ATT(ncid, nyearid, 'units', 'years')
-         nret = NF90_PUT_ATT(ncid, ndayid, 'long_name', 'year day of calving event')
-         nret = NF90_PUT_ATT(ncid, ndayid, 'units', 'days')
-         nret = NF90_PUT_ATT(ncid, nscaling_id, 'long_name', 'scaling factor for mass of calving berg')
-         nret = NF90_PUT_ATT(ncid, nscaling_id, 'units', 'none')
-         nret = NF90_PUT_ATT(ncid, nmass_of_bits_id, 'long_name', 'mass of bergy bits')
-         nret = NF90_PUT_ATT(ncid, nmass_of_bits_id, 'units', 'kg')
-         nret = NF90_PUT_ATT(ncid, nheat_density_id, 'long_name', 'heat density')
-         nret = NF90_PUT_ATT(ncid, nheat_density_id, 'units', 'J/kg')
-
-      ENDIF ! associated(first_berg)
-
-      ! End define mode
-      nret = NF90_ENDDEF(ncid)
-
-      ! --------------------------------
-      ! now write some data
-
-      nstrt3(1) = 1
-      nstrt3(2) = 1
-      nlngth3(1) = jpi
-      nlngth3(2) = jpj
-      nlngth3(3) = 1
-
-      DO jn=1,nclasses
-         griddata(:,:,1) = berg_grid%stored_ice(:,:,jn)
-         nstrt3(3) = jn
-         nret = NF90_PUT_VAR( ncid, nsiceid, griddata, nstrt3, nlngth3 )
-         IF (nret .ne. NF90_NOERR) THEN
-            IF( lwp ) WRITE(numout,*) TRIM(NF90_STRERROR( nret ))
-            CALL ctl_stop('icebergs, write_restart: nf_put_var stored_ice failed')
-         ENDIF
-      ENDDO
-      IF( lwp ) WRITE(numout,*) 'file: ',TRIM(cl_path)//TRIM(cl_filename),' var: stored_ice  written'
-
-      nret = NF90_PUT_VAR( ncid, nkountid, num_bergs(:) )
-      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var kount failed')
-
-      nret = NF90_PUT_VAR( ncid, nsheatid, berg_grid%stored_heat(:,:) )
-      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var stored_heat failed')
-      IF( lwp ) WRITE(numout,*) 'file: ',TRIM(cl_path)//TRIM(cl_filename),' var: stored_heat written'
-
-      nret = NF90_PUT_VAR( ncid, ncalvid , src_calving(:,:) )
-      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var calving failed')
-      nret = NF90_PUT_VAR( ncid, ncalvhid, src_calving_hflx(:,:) )
-      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var calving_hflx failed')
-      IF( lwp ) WRITE(numout,*) 'file: ',TRIM(cl_path)//TRIM(cl_filename),' var: calving written'
-
-      IF ( ASSOCIATED(first_berg) ) THEN
-
-         ! Write variables
-         ! just write out the current point of the trajectory
-
-         this => first_berg
-         jn = 0
-         DO WHILE (ASSOCIATED(this))
-            pt => this%current_point
-            jn=jn+1
-
-            nret = NF90_PUT_VAR(ncid, numberid, this%number, (/1,jn/), (/nkounts,1/) )
-            nret = NF90_PUT_VAR(ncid, nscaling_id, this%mass_scaling, (/ jn /) )
-
-            nret = NF90_PUT_VAR(ncid, nlonid, pt%lon, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nlatid, pt%lat, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nxid, pt%xi, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nyid, pt%yj, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nuvelid, pt%uvel, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nvvelid, pt%vvel, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nmassid, pt%mass, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nthicknessid, pt%thickness, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nwidthid, pt%width, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nlengthid, pt%length, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nyearid, pt%year, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, ndayid, pt%day, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nmass_of_bits_id, pt%mass_of_bits, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nheat_density_id, pt%heat_density, (/ jn /) )
-
-            this=>this%next
-         END DO
-         !
-      ENDIF ! associated(first_berg)
-
-      ! Finish up
-      nret = NF90_CLOSE(ncid)
-      IF (nret /= NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_close failed')
-      !
    END SUBROUTINE icb_rst_write
    !
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbstp.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbstp.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbstp.F90	(revision 10288)
@@ -48,5 +48,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -71,5 +71,5 @@
       nktberg = kt
       !
-      IF( nn_test_icebergs < 0 ) THEN     !* read calving data
+      IF( nn_test_icebergs < 0 .OR. ln_use_calving ) THEN !* read calving data
          !
          CALL fld_read ( kt, 1, sf_icb )
@@ -99,5 +99,5 @@
                                      CALL icb_clv_flx( kt )   ! Accumulate ice from calving
       !                              !
-                                     CALL icb_clv()           ! Calve excess stored ice into icebergs
+                                     CALL icb_clv( kt )       ! Calve excess stored ice into icebergs
       !                              !
       !
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbthm.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbthm.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbthm.F90	(revision 10288)
@@ -33,5 +33,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -50,5 +50,5 @@
       REAL(wp) ::   zM, zT, zW, zL, zSST, zVol, zLn, zWn, zTn, znVol, zIC, zDn
       REAL(wp) ::   zMv, zMe, zMb, zmelt, zdvo, zdva, zdM, zSs, zdMe, zdMb, zdMv
-      REAL(wp) ::   zMnew, zMnew1, zMnew2, zheat
+      REAL(wp) ::   zMnew, zMnew1, zMnew2, zheat_hcflux, zheat_latent, z1_12
       REAL(wp) ::   zMbits, znMbits, zdMbitsE, zdMbitsM, zLbits, zAbits, zMbb
       REAL(wp) ::   zxi, zyj, zff, z1_rday, z1_e1e2, zdt, z1_dt, z1_dt_e1e2
@@ -58,4 +58,7 @@
       !
       z1_rday = 1._wp / rday
+      z1_12   = 1._wp / 12._wp
+      zdt     = berg_dt
+      z1_dt   = 1._wp / zdt
       !
       ! we're either going to ignore berg fresh water melt flux and associated heat
@@ -65,4 +68,5 @@
       !
       berg_grid%floating_melt(:,:) = 0._wp
+      ! calving_hflx re-used here as temporary workspace for the heat flux associated with melting
       berg_grid%calving_hflx(:,:)  = 0._wp
       !
@@ -91,20 +95,19 @@
          ij  = mj1( ij )
          zVol = zT * zW * zL
-         zdt = berg_dt   ;   z1_dt = 1._wp / zdt
 
          ! Environment
          zdvo = SQRT( (pt%uvel-pt%uo)**2 + (pt%vvel-pt%vo)**2 )
          zdva = SQRT( (pt%ua  -pt%uo)**2 + (pt%va  -pt%vo)**2 )
-         zSs  = 1.5 * SQRT( zdva ) + 0.1 * zdva                ! Sea state      (eqn M.A9)
+         zSs  = 1.5_wp * SQRT( zdva ) + 0.1_wp * zdva                ! Sea state      (eqn M.A9)
 
          ! Melt rates in m/s (i.e. division by rday)
-         zMv = MAX( 7.62e-3*zSST+1.29e-3*(zSST**2)            , 0._wp ) * z1_rday   ! Buoyant convection at sides (eqn M.A10)
-         zMb = MAX( 0.58*(zdvo**0.8)*(zSST+4.0)/(zL**0.2)      , 0._wp ) * z1_rday   ! Basal turbulent melting     (eqn M.A7 )
-         zMe = MAX( 1./12.*(zSST+2.)*zSs*(1+COS(rpi*(zIC**3))) , 0._wp ) * z1_rday   ! Wave erosion                (eqn M.A8 )
+         zMv = MAX( 7.62d-3*zSST+1.29d-3*(zSST**2)                    , 0._wp ) * z1_rday   ! Buoyant convection at sides (eqn M.A10)
+         zMb = MAX( 0.58_wp*(zdvo**0.8_wp)*(zSST+4.0_wp)/(zL**0.2_wp) , 0._wp ) * z1_rday   ! Basal turbulent melting     (eqn M.A7 )
+         zMe = MAX( z1_12*(zSST+2.)*zSs*(1._wp+COS(rpi*(zIC**3)))     , 0._wp ) * z1_rday   ! Wave erosion                (eqn M.A8 )
 
          IF( ln_operator_splitting ) THEN      ! Operator split update of volume/mass
             zTn    = MAX( zT - zMb*zdt , 0._wp )         ! new total thickness (m)
             znVol  = zTn * zW * zL                       ! new volume (m^3)
-            zMnew1 = (znVol/zVol) * zM                   ! new mass (kg)
+            zMnew1 = ( znVol / zVol ) * zM               ! new mass (kg)
             zdMb   = zM - zMnew1                         ! mass lost to basal melting (>0) (kg)
             !
@@ -112,5 +115,5 @@
             zWn    = MAX( zW - zMv*zdt , 0._wp )         ! new width (m)
             znVol  = zTn * zWn * zLn                     ! new volume (m^3)
-            zMnew2 = (znVol/zVol) * zM                   ! new mass (kg)
+            zMnew2 = ( znVol / zVol ) * zM               ! new mass (kg)
             zdMv   = zMnew1 - zMnew2                     ! mass lost to buoyant convection (>0) (kg)
             !
@@ -142,5 +145,6 @@
             zLbits   = MIN( zL, zW, zT, 40._wp )                                     ! assume bergy bits are smallest dimension or 40 meters
             zAbits   = ( zMbits / rn_rho_bergs ) / zLbits                            ! Effective bottom area (assuming T=Lbits)
-            zMbb     = MAX( 0.58*(zdvo**0.8)*(zSST+2.0)/(zLbits**0.2), 0.) * z1_rday ! Basal turbulent melting (for bits)
+            zMbb     = MAX( 0.58_wp*(zdvo**0.8_wp)*(zSST+2._wp) /   &
+               &                              ( zLbits**0.2_wp ) , 0._wp ) * z1_rday ! Basal turbulent melting (for bits)
             zMbb     = rn_rho_bergs * zAbits * zMbb                                  ! in kg/s
             zdMbitsM = MIN( zMbb*zdt , znMbits )                                     ! bergy bits mass lost to melting (kg)
@@ -163,7 +167,11 @@
             zmelt    = ( zdM - ( zdMbitsE - zdMbitsM ) ) * z1_dt   ! kg/s
             berg_grid%floating_melt(ii,ij) = berg_grid%floating_melt(ii,ij) + zmelt    * z1_e1e2    ! kg/m2/s
-            zheat = zmelt * pt%heat_density              ! kg/s x J/kg = J/s
-            berg_grid%calving_hflx (ii,ij) = berg_grid%calving_hflx (ii,ij) + zheat    * z1_e1e2    ! W/m2
-            CALL icb_dia_melt( ii, ij, zMnew, zheat, this%mass_scaling,       &
+            !! NB. The src_calving_hflx field is currently hardwired to zero in icb_stp, which means that the
+            !!     heat density of the icebergs is zero and the heat content flux to the ocean from iceberg
+            !!     melting is always zero. Leaving the term in the code until such a time as this is fixed. DS.
+            zheat_hcflux = zmelt * pt%heat_density       ! heat content flux : kg/s x J/kg = J/s
+            zheat_latent = - zmelt * rLfus               ! latent heat flux:  kg/s x J/kg = J/s
+            berg_grid%calving_hflx (ii,ij) = berg_grid%calving_hflx (ii,ij) + ( zheat_hcflux + zheat_latent ) * z1_e1e2    ! W/m2
+            CALL icb_dia_melt( ii, ij, zMnew, zheat_hcflux, zheat_latent, this%mass_scaling,       &
                &                       zdM, zdMbitsE, zdMbitsM, zdMb, zdMe,   &
                &                       zdMv, z1_dt_e1e2 )
@@ -211,5 +219,5 @@
       IF(.NOT. ln_passive_mode ) THEN
          emp (:,:) = emp (:,:) - berg_grid%floating_melt(:,:)
-!!       qns (:,:) = qns (:,:) + berg_grid%calving_hflx (:,:)  !!gm heat flux not yet properly coded ==>> need it, SOLVE that!
+         qns (:,:) = qns (:,:) + berg_grid%calving_hflx (:,:)  
       ENDIF
       !
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbtrj.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbtrj.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbtrj.F90	(revision 10288)
@@ -49,5 +49,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbutl.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbutl.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ICB/icbutl.F90	(revision 10288)
@@ -48,5 +48,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/IOM/in_out_manager.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/IOM/in_out_manager.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/IOM/in_out_manager.F90	(revision 10288)
@@ -160,5 +160,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!=====================================================================
 END MODULE in_out_manager
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/IOM/iom.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/IOM/iom.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/IOM/iom.F90	(revision 10288)
@@ -43,4 +43,7 @@
    USE ioipsl, ONLY :  ju2ymds    ! for calendar
    USE crs             ! Grid coarsening
+#if defined key_top
+   USE trc, ONLY    :  profsed
+#endif
    USE lib_fortran 
    USE diurnal_bulk, ONLY : ln_diurnal_only, ln_diurnal
@@ -83,17 +86,13 @@
       MODULE PROCEDURE iom_p0d, iom_p1d, iom_p2d, iom_p3d
    END INTERFACE iom_put
-   
-   LOGICAL, PARAMETER ::   ltmppatch = .TRUE.     !: seb: patch before we remove periodicity
-   INTEGER            ::   nldi_save, nlei_save   !:      and close boundaries in output files
-   INTEGER            ::   nldj_save, nlej_save   !:
   
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
 
-   SUBROUTINE iom_init( cdname, fname ) 
+   SUBROUTINE iom_init( cdname, fname, ld_tmppatch ) 
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE   ***
@@ -102,6 +101,7 @@
       !!
       !!----------------------------------------------------------------------
-      CHARACTER(len=*), INTENT(in)  :: cdname
+      CHARACTER(len=*),           INTENT(in)  :: cdname
       CHARACTER(len=*), OPTIONAL, INTENT(in)  :: fname
+      LOGICAL         , OPTIONAL, INTENT(in)  :: ld_tmppatch
 #if defined key_iomput
       !
@@ -113,8 +113,14 @@
       !
       REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: zt_bnds, zw_bnds
+      LOGICAL ::   ll_tmppatch = .TRUE.    !: seb: patch before we remove periodicity
+      INTEGER ::   nldi_save, nlei_save    !:      and close boundaries in output files
+      INTEGER ::   nldj_save, nlej_save    !:
       !!----------------------------------------------------------------------
       !
       ! seb: patch before we remove periodicity and close boundaries in output files
-      IF ( ltmppatch ) THEN
+      IF( PRESENT(ld_tmppatch) ) THEN   ;   ll_tmppatch = ld_tmppatch
+      ELSE                              ;   ll_tmppatch = .TRUE.
+      ENDIF
+      IF ( ll_tmppatch ) THEN
          nldi_save = nldi   ;   nlei_save = nlei
          nldj_save = nldj   ;   nlej_save = nlej
@@ -147,8 +153,8 @@
       !
       IF( TRIM(cdname) == TRIM(cxios_context) ) THEN  
-         CALL set_grid( "T", glamt, gphit, .FALSE. ) 
-         CALL set_grid( "U", glamu, gphiu, .FALSE. )
-         CALL set_grid( "V", glamv, gphiv, .FALSE. )
-         CALL set_grid( "W", glamt, gphit, .FALSE. )
+         CALL set_grid( "T", glamt, gphit, .FALSE., .FALSE. ) 
+         CALL set_grid( "U", glamu, gphiu, .FALSE., .FALSE. )
+         CALL set_grid( "V", glamv, gphiv, .FALSE., .FALSE. )
+         CALL set_grid( "W", glamt, gphit, .FALSE., .FALSE. )
          CALL set_grid_znl( gphit )
          !
@@ -168,8 +174,8 @@
          CALL dom_grid_crs   ! Save the parent grid information  & Switch to coarse grid domain
          !
-         CALL set_grid( "T", glamt_crs, gphit_crs, .FALSE. ) 
-         CALL set_grid( "U", glamu_crs, gphiu_crs, .FALSE. ) 
-         CALL set_grid( "V", glamv_crs, gphiv_crs, .FALSE. ) 
-         CALL set_grid( "W", glamt_crs, gphit_crs, .FALSE. ) 
+         CALL set_grid( "T", glamt_crs, gphit_crs, .FALSE., .FALSE. ) 
+         CALL set_grid( "U", glamu_crs, gphiu_crs, .FALSE., .FALSE. ) 
+         CALL set_grid( "V", glamv_crs, gphiv_crs, .FALSE., .FALSE. ) 
+         CALL set_grid( "W", glamt_crs, gphit_crs, .FALSE., .FALSE. ) 
          CALL set_grid_znl( gphit_crs )
           !
@@ -190,8 +196,8 @@
       ! vertical grid definition
       IF(.NOT.llrst_context) THEN
-          CALL iom_set_axis_attr( "deptht", paxis = gdept_1d )
-          CALL iom_set_axis_attr( "depthu", paxis = gdept_1d )
-          CALL iom_set_axis_attr( "depthv", paxis = gdept_1d )
-          CALL iom_set_axis_attr( "depthw", paxis = gdepw_1d )
+          CALL iom_set_axis_attr( "deptht",  paxis = gdept_1d )
+          CALL iom_set_axis_attr( "depthu",  paxis = gdept_1d )
+          CALL iom_set_axis_attr( "depthv",  paxis = gdept_1d )
+          CALL iom_set_axis_attr( "depthw",  paxis = gdepw_1d )
 
           ! Add vertical grid bounds
@@ -216,4 +222,7 @@
           CALL iom_set_axis_attr( "nstrait", (/ (REAL(ji,wp), ji=1,4) /) )
 # endif
+#if defined key_top
+          CALL iom_set_axis_attr( "profsed", paxis = profsed )
+#endif
           CALL iom_set_axis_attr( "icbcla", class_num )
           CALL iom_set_axis_attr( "iax_20C", (/ REAL(20,wp) /) )
@@ -224,5 +233,5 @@
       IF( TRIM(cdname) == TRIM(crxios_context) ) THEN
 !set names of the fields in restart file IF using XIOS to read data
-          CALL iom_set_rst_context()
+          CALL iom_set_rst_context(.TRUE.)
           CALL iom_set_rst_vars(rst_rfields)
 !set which fields are to be read from restart file
@@ -230,5 +239,5 @@
       ELSE IF( TRIM(cdname) == TRIM(cwxios_context) ) THEN
 !set names of the fields in restart file IF using XIOS to write data
-          CALL iom_set_rst_context()
+          CALL iom_set_rst_context(.FALSE.)
           CALL iom_set_rst_vars(rst_wfields)
 !set which fields are to be written to a restart file
@@ -246,5 +255,5 @@
       DEALLOCATE( zt_bnds, zw_bnds )
       !
-      IF ( ltmppatch ) THEN
+      IF ( ll_tmppatch ) THEN
          nldi = nldi_save   ;   nlei = nlei_save
          nldj = nldj_save   ;   nlej = nlej_save
@@ -568,5 +577,5 @@
    END SUBROUTINE iom_set_rstw_active
 
-   SUBROUTINE iom_set_rst_context( ) 
+   SUBROUTINE iom_set_rst_context(ld_rstr) 
      !!---------------------------------------------------------------------
       !!                   ***  SUBROUTINE  iom_set_rst_context  ***
@@ -576,4 +585,7 @@
       !!               
       !!---------------------------------------------------------------------
+   LOGICAL, INTENT(IN)               :: ld_rstr
+!ld_rstr is true for restart context. There is no need to define grid for 
+!restart read, because it's read from file
 #if defined key_iomput
    TYPE(xios_domaingroup)            :: domaingroup_hdl 
@@ -586,5 +598,5 @@
      CALL xios_get_handle("domain_definition",domaingroup_hdl) 
      CALL xios_add_child(domaingroup_hdl, domain_hdl, "grid_N") 
-     CALL set_grid("N", glamt, gphit, .TRUE.) 
+     CALL set_grid("N", glamt, gphit, .TRUE., ld_rstr) 
  
      CALL xios_get_handle("axis_definition",axisgroup_hdl) 
@@ -690,7 +702,5 @@
       ! do we read the overlap 
       ! ugly patch SM+JMM+RB to overwrite global definition in some cases
-      !llnoov = (jpni * jpnj ) == jpnij .AND. .NOT. lk_agrif
-      !llnoov = .true.
-      llnoov = .NOT. lk_agrif
+      llnoov = (jpni * jpnj ) == jpnij .AND. .NOT. lk_agrif
       ! create the file name by added, if needed, TRIM(Agrif_CFixed()) and TRIM(clsuffix)
       ! =============
@@ -1758,5 +1768,5 @@
    !!----------------------------------------------------------------------
 
-   SUBROUTINE iom_set_domain_attr( cdid, ni_glo, nj_glo, ibegin, jbegin, ni, nj, zoom_ibegin, zoom_jbegin, zoom_ni, zoom_nj,   &
+   SUBROUTINE iom_set_domain_attr( cdid, ni_glo, nj_glo, ibegin, jbegin, ni, nj,                                               &
       &                                    data_dim, data_ibegin, data_ni, data_jbegin, data_nj, lonvalue, latvalue, mask,     &
       &                                    nvertex, bounds_lon, bounds_lat, area )
@@ -1766,5 +1776,5 @@
       INTEGER                 , OPTIONAL, INTENT(in) ::   ni_glo, nj_glo, ibegin, jbegin, ni, nj
       INTEGER                 , OPTIONAL, INTENT(in) ::   data_dim, data_ibegin, data_ni, data_jbegin, data_nj
-      INTEGER                 , OPTIONAL, INTENT(in) ::   zoom_ibegin, zoom_jbegin, zoom_ni, zoom_nj, nvertex
+      INTEGER                 , OPTIONAL, INTENT(in) ::   nvertex
       REAL(wp), DIMENSION(:)  , OPTIONAL, INTENT(in) ::   lonvalue, latvalue
       REAL(wp), DIMENSION(:,:), OPTIONAL, INTENT(in) ::   bounds_lon, bounds_lat, area
@@ -1793,8 +1803,31 @@
       !!----------------------------------------------------------------------
       !!----------------------------------------------------------------------
-      CHARACTER(LEN=*)          , INTENT(in) ::   cdid
-      INTEGER         , OPTIONAL, INTENT(in) ::   ibegin, jbegin, ni, nj
-      !!----------------------------------------------------------------------
-      IF( xios_is_valid_zoom_domain(cdid) )   CALL xios_set_zoom_domain_attr( cdid, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj )
+      CHARACTER(LEN=*), INTENT(in) ::   cdid
+      INTEGER         , INTENT(in) ::   ibegin, jbegin, ni, nj
+      !
+      TYPE(xios_gridgroup) :: gridgroup_hdl
+      TYPE(xios_grid)      :: grid_hdl
+      TYPE(xios_domain)    :: domain_hdl 
+      TYPE(xios_axis)      :: axis_hdl 
+      CHARACTER(LEN=64)    :: cldomrefid   ! domain_ref name
+      CHARACTER(len=1)     :: cl1          ! last character of this name
+      !!----------------------------------------------------------------------
+      !
+      IF( xios_is_valid_zoom_domain(cdid) ) THEN
+         ! define the zoom_domain attributs
+         CALL xios_set_zoom_domain_attr( cdid, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj )
+         ! define a new 2D grid with this new domain
+         CALL xios_get_handle("grid_definition", gridgroup_hdl )
+         CALL xios_add_child(gridgroup_hdl, grid_hdl, TRIM(cdid)//'_2D' )   ! add a new 2D grid to grid_definition
+         CALL xios_add_child(grid_hdl, domain_hdl, TRIM(cdid) )             ! add its domain
+         ! define a new 3D grid with this new domain
+         CALL xios_add_child(gridgroup_hdl, grid_hdl, TRIM(cdid)//'_3D' )   ! add a new 3D grid to grid_definition
+         CALL xios_add_child(grid_hdl, domain_hdl, TRIM(cdid) )             ! add its domain
+         ! vertical axis
+         cl1 = cdid(LEN_TRIM(cdid):)                                        ! last letter of cdid
+         cl1 = CHAR(ICHAR(cl1)+32)                                          ! from upper to lower case
+         CALL xios_add_child(grid_hdl, axis_hdl, 'depth'//cl1)              ! add its axis
+      ENDIF
+      !      
    END SUBROUTINE iom_set_zoom_domain_attr
 
@@ -1909,5 +1942,5 @@
 
 
-   SUBROUTINE set_grid( cdgrd, plon, plat, ldxios )
+   SUBROUTINE set_grid( cdgrd, plon, plat, ldxios, ldrxios )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE set_grid  ***
@@ -1921,16 +1954,6 @@
       INTEGER  :: ni, nj
       REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zmask
-      LOGICAL, INTENT(IN) :: ldxios
-      !!----------------------------------------------------------------------
-      !
-      ! seb: patch before we remove periodicity and close boundaries in output files
-      IF ( ltmppatch ) THEN
-         nldi_save = nldi   ;   nlei_save = nlei
-         nldj_save = nldj   ;   nlej_save = nlej
-         IF( nimpp           ==      1 ) nldi = 1
-         IF( nimpp + jpi - 1 == jpiglo ) nlei = jpi
-         IF( njmpp           ==      1 ) nldj = 1
-         IF( njmpp + jpj - 1 == jpjglo ) nlej = jpj
-      ENDIF
+      LOGICAL, INTENT(IN) :: ldxios, ldrxios
+      !!----------------------------------------------------------------------
       !
       ni = nlei-nldi+1
@@ -1939,5 +1962,7 @@
       CALL iom_set_domain_attr("grid_"//cdgrd, ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-2, jbegin=njmpp+nldj-2, ni=ni, nj=nj)
       CALL iom_set_domain_attr("grid_"//cdgrd, data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj)
-      CALL iom_set_domain_attr("grid_"//cdgrd, lonvalue = RESHAPE(plon(nldi:nlei, nldj:nlej),(/ ni*nj /)),   &
+!don't define lon and lat for restart reading context. 
+      IF ( .NOT.ldrxios ) &
+         CALL iom_set_domain_attr("grid_"//cdgrd, lonvalue = RESHAPE(plon(nldi:nlei, nldj:nlej),(/ ni*nj /)),   &
          &                                     latvalue = RESHAPE(plat(nldi:nlei, nldj:nlej),(/ ni*nj /)))  
       !
@@ -1955,9 +1980,4 @@
       ENDIF
       !
-      IF ( ltmppatch ) THEN
-         nldi = nldi_save   ;   nlei = nlei_save
-         nldj = nldj_save   ;   nlej = nlej_save
-      ENDIF
-      !
    END SUBROUTINE set_grid
 
@@ -1981,14 +2001,4 @@
       REAL(wp), ALLOCATABLE, DIMENSION(:,:)     :: z_rot       ! Lat/lon working array for rotation of cells
       !!----------------------------------------------------------------------
-      !
-      ! seb: patch before we remove periodicity and close boundaries in output files
-      IF ( ltmppatch ) THEN
-         nldi_save = nldi   ;   nlei_save = nlei
-         nldj_save = nldj   ;   nlej_save = nlej
-         IF( nimpp           ==      1 ) nldi = 1
-         IF( nimpp + jpi - 1 == jpiglo ) nlei = jpi
-         IF( njmpp           ==      1 ) nldj = 1
-         IF( njmpp + jpj - 1 == jpjglo ) nlej = jpj
-      ENDIF
       !
       ALLOCATE( z_bnds(4,jpi,jpj,2), z_fld(jpi,jpj), z_rot(4,2)  )
@@ -2075,9 +2085,4 @@
       DEALLOCATE( z_bnds, z_fld, z_rot ) 
       !
-      IF ( ltmppatch ) THEN
-         nldi = nldi_save   ;   nlei = nlei_save
-         nldj = nldj_save   ;   nlej = nlej_save
-      ENDIF
-      !
    END SUBROUTINE set_grid_bounds
 
@@ -2095,14 +2100,4 @@
       REAL(wp), DIMENSION(:), ALLOCATABLE  ::   zlon
       !!----------------------------------------------------------------------
-      !
-      ! seb: patch before we remove periodicity and close boundaries in output files
-      IF ( ltmppatch ) THEN
-         nldi_save = nldi   ;   nlei_save = nlei
-         nldj_save = nldj   ;   nlej_save = nlej
-         IF( nimpp           ==      1 ) nldi = 1
-         IF( nimpp + jpi - 1 == jpiglo ) nlei = jpi
-         IF( njmpp           ==      1 ) nldj = 1
-         IF( njmpp + jpj - 1 == jpjglo ) nlej = jpj
-      ENDIF
       !
       ni=nlei-nldi+1       ! define zonal mean domain (jpj*jpk)
@@ -2116,12 +2111,8 @@
       CALL iom_set_domain_attr("gznl", lonvalue = zlon,   &
          &                             latvalue = RESHAPE(plat(nldi:nlei, nldj:nlej),(/ ni*nj /)))  
-      CALL iom_set_zoom_domain_attr ("ptr", ibegin=ix-1, jbegin=0, ni=1, nj=jpjglo)
+      CALL iom_set_zoom_domain_attr("znl_T", ibegin=ix-1, jbegin=0, ni=1, nj=jpjglo)
+      CALL iom_set_zoom_domain_attr("znl_W", ibegin=ix-1, jbegin=0, ni=1, nj=jpjglo)
       !
       CALL iom_update_file_name('ptr')
-      !
-      IF ( ltmppatch ) THEN
-         nldi = nldi_save   ;   nlei = nlei_save
-         nldj = nldj_save   ;   nlej = nlej_save
-      ENDIF
       !
    END SUBROUTINE set_grid_znl
@@ -2199,5 +2190,5 @@
          ! Equatorial section (attributs: jbegin, ni, name_suffix)
          CALL dom_ngb( 0., 0., ix, iy, cl1 )
-         CALL iom_set_zoom_domain_attr ('Eq'//cl1, jbegin=iy-1, ni=jpiglo)
+         CALL iom_set_zoom_domain_attr('Eq'//cl1, ibegin=0, jbegin=iy-1, ni=jpiglo, nj=1 )
          CALL iom_get_file_attr   ('Eq'//cl1, name_suffix = clsuff             )
          CALL iom_set_file_attr   ('Eq'//cl1, name_suffix = TRIM(clsuff)//'_Eq')
@@ -2278,5 +2269,5 @@
                ENDIF
                clname = TRIM(ADJUSTL(clat))//TRIM(ADJUSTL(clon))
-               CALL iom_set_zoom_domain_attr  (TRIM(clname)//cl1, ibegin= ix-1, jbegin= iy-1)
+               CALL iom_set_zoom_domain_attr(TRIM(clname)//cl1, ibegin= ix-1, jbegin= iy-1, ni=1, nj=1)
 
                CALL iom_get_file_attr   (TRIM(clname)//cl1, name_suffix = clsuff                         )
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/IOM/iom_def.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/IOM/iom_def.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/IOM/iom_def.F90	(revision 10288)
@@ -85,5 +85,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!======================================================================
 END MODULE iom_def
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/IOM/iom_nf90.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/IOM/iom_nf90.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/IOM/iom_nf90.F90	(revision 10288)
@@ -48,5 +48,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/IOM/prtctl.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/IOM/prtctl.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/IOM/prtctl.F90	(revision 10288)
@@ -37,5 +37,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/IOM/restart.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/IOM/restart.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/IOM/restart.F90	(revision 10288)
@@ -42,5 +42,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -118,5 +118,5 @@
                   clpname = TRIM(Agrif_CFixed())//"_"//clname   
                ENDIF
-               CALL iom_init( cwxios_context, TRIM(clpath)//TRIM(clpname))
+               CALL iom_init( cwxios_context, TRIM(clpath)//TRIM(clpname), .false. )
                CALL xios_update_calendar(nitrst)
                CALL iom_swap(      cxios_context          )
@@ -228,10 +228,10 @@
              IF( .NOT.lxios_set ) THEN
                  IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS'
-                 CALL iom_init( crxios_context )
+                 CALL iom_init( crxios_context, ld_tmppatch = .false. )
                  lxios_set = .TRUE.
              ENDIF
          ENDIF
          IF( TRIM(Agrif_CFixed()) /= '0' .AND. lrxios) THEN
-             CALL iom_init( crxios_context )
+             CALL iom_init( crxios_context, ld_tmppatch = .false. )
              IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS for AGRIF'
              lxios_set = .TRUE.
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LBC/lbclnk.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LBC/lbclnk.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LBC/lbclnk.F90	(revision 10288)
@@ -38,5 +38,5 @@
    !
    INTERFACE lbc_bdy_lnk
-      MODULE PROCEDURE mpp_lnk_bdy_2d, mpp_lnk_bdy_3d
+      MODULE PROCEDURE mpp_lnk_bdy_2d, mpp_lnk_bdy_3d, mpp_lnk_bdy_4d
    END INTERFACE
    !
@@ -53,5 +53,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -90,5 +90,5 @@
    !
    INTERFACE lbc_bdy_lnk
-      MODULE PROCEDURE lbc_bdy_lnk_2d, lbc_bdy_lnk_3d
+      MODULE PROCEDURE lbc_bdy_lnk_2d, lbc_bdy_lnk_3d, lbc_bdy_lnk_4d
    END INTERFACE
    !
@@ -105,5 +105,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -173,5 +173,5 @@
 
    !!----------------------------------------------------------------------
-   !!                   ***  routine lbc_bdy_lnk_(2,3)d  ***
+   !!                   ***  routine lbc_bdy_lnk_(2,3,4)d  ***
    !!
    !!   wrapper rountine to 'lbc_lnk_3d'. This wrapper is used
@@ -179,4 +179,14 @@
    !!----------------------------------------------------------------------
    
+   SUBROUTINE lbc_bdy_lnk_4d( pt4d, cd_type, psgn, ib_bdy )
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:,:,:,:), INTENT(inout) ::   pt4d      ! 4D array on which the lbc is applied
+      CHARACTER(len=1)            , INTENT(in   ) ::   cd_type   ! nature of pt4d grid-points
+      REAL(wp)                    , INTENT(in   ) ::   psgn      ! sign used across north fold 
+      INTEGER                     , INTENT(in   ) ::   ib_bdy    ! BDY boundary set
+      !!----------------------------------------------------------------------
+      CALL lbc_lnk_4d( pt4d, cd_type, psgn)
+   END SUBROUTINE lbc_bdy_lnk_4d
+
    SUBROUTINE lbc_bdy_lnk_3d( pt3d, cd_type, psgn, ib_bdy )
       !!----------------------------------------------------------------------
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LBC/lbcnfd.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LBC/lbcnfd.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LBC/lbcnfd.F90	(revision 10288)
@@ -58,5 +58,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LBC/lib_mpp.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LBC/lib_mpp.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LBC/lib_mpp.F90	(revision 10288)
@@ -88,5 +88,5 @@
    PUBLIC   mppsize
    PUBLIC   mppsend, mpprecv                          ! needed by TAM and ICB routines
-   PUBLIC   mpp_lnk_bdy_2d, mpp_lnk_bdy_3d
+   PUBLIC   mpp_lnk_bdy_2d, mpp_lnk_bdy_3d, mpp_lnk_bdy_4d
    PUBLIC   mpprank
    
@@ -172,5 +172,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -456,9 +456,9 @@
    !                       !==  4D array and array of 4D pointer  ==!
    !
-!!#  define DIM_4d
-!!#     define ROUTINE_BDY           mpp_lnk_bdy_4d
-!!#     include "mpp_bdy_generic.h90"
-!!#     undef ROUTINE_BDY
-!!#  undef DIM_4d
+#  define DIM_4d
+#     define ROUTINE_BDY           mpp_lnk_bdy_4d
+#     include "mpp_bdy_generic.h90"
+#     undef ROUTINE_BDY
+#  undef DIM_4d
 
    !!----------------------------------------------------------------------
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LBC/mpp_nfd_generic.h90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LBC/mpp_nfd_generic.h90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LBC/mpp_nfd_generic.h90	(revision 10288)
@@ -56,5 +56,5 @@
       INTEGER  ::   ipi, ipj, ipk, ipl, ipf         ! dimension of the input array
       INTEGER  ::   imigr, iihom, ijhom             ! local integers
-      INTEGER  ::   ierr, itaille, ildi, ilei, iilb
+      INTEGER  ::   ierr, itaille, ilci, ildi, ilei, iilb
       INTEGER  ::   ij, iproc
       INTEGER, DIMENSION (jpmaxngh)       ::   ml_req_nf   ! for mpi_isend when avoiding mpi_allgather
@@ -95,4 +95,13 @@
          ALLOCATE( ztabl(jpimax   ,4,ipk,ipl,ipf) , ztabr(jpimax*jpmaxngh,4,ipk,ipl,ipf) ) 
          !
+         ! when some processors of the north fold are suppressed, 
+         ! values of ztab* arrays corresponding to these suppressed domain won't be defined 
+         ! and we need a default definition to 0.
+         ! a better test should be: a testing if "suppressed land-processors" belongs to the north-pole folding
+         IF ( jpni*jpnj /= jpnij ) THEN
+            ztabr(:,:,:,:,:) = 0._wp
+            ztabl(:,:,:,:,:) = 0._wp
+         END IF
+         !
          DO jf = 1, ipf
             DO jl = 1, ipl
@@ -117,8 +126,9 @@
             IF(iproc /= -1) THEN
                iilb = nimppt(iproc+1)
+               ilci = nlcit (iproc+1)
                ildi = nldit (iproc+1)
                ilei = nleit (iproc+1)
-               IF( iilb           ==      1 )   ildi = 1     ! e-w boundary already done -> force to take 1st column
-               IF( iilb + jpi - 1 == jpiglo )   ilei = jpi   ! e-w boundary already done -> force to take last column
+               IF( iilb            ==      1 )   ildi = 1      ! e-w boundary already done -> force to take 1st column
+               IF( iilb + ilci - 1 == jpiglo )   ilei = ilci   ! e-w boundary already done -> force to take last column
                iilb = nfiimpp(isendto(jr),jpnj) - nfiimpp(isendto(1),jpnj)
             ENDIF
@@ -179,4 +189,10 @@
          ALLOCATE( znorthgloio(jpimax,4,ipk,ipl,ipf,jpni) )
          !
+         ! when some processors of the north fold are suppressed,
+         ! values of ztab* arrays corresponding to these suppressed domain won't be defined
+         ! and we need a default definition to 0.
+         ! a better test should be: a testing if "suppressed land-processors" belongs to the north-pole folding
+         IF ( jpni*jpnj /= jpnij ) ztab(:,:,:,:,:)=0._wp
+         !
          CALL MPI_ALLGATHER( znorthloc  , itaille, MPI_DOUBLE_PRECISION,                &
             &                znorthgloio, itaille, MPI_DOUBLE_PRECISION, ncomm_north, ierr )
@@ -185,8 +201,9 @@
             iproc = nrank_north(jr) + 1
             iilb  = nimppt(iproc)
+            ilci  = nlcit (iproc)
             ildi  = nldit (iproc)
             ilei  = nleit (iproc)
-            IF( iilb           ==      1 )   ildi = 1     ! e-w boundary already done -> force to take 1st column
-            IF( iilb + jpi - 1 == jpiglo )   ilei = jpi   ! e-w boundary already done -> force to take last column
+            IF( iilb            ==      1 )   ildi = 1      ! e-w boundary already done -> force to take 1st column
+            IF( iilb + ilci - 1 == jpiglo )   ilei = ilci   ! e-w boundary already done -> force to take last column
             DO jf = 1, ipf
                DO jl = 1, ipl
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LBC/mppini.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LBC/mppini.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LBC/mppini.F90	(revision 10288)
@@ -39,5 +39,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -536,5 +536,4 @@
                &                                ibonit (jproc), ibonjt (jproc) 
          END DO
-         CLOSE(inum)   
       END IF
 
@@ -577,11 +576,34 @@
       IF( jperio >= 3 .AND. jperio <= 6 .AND. jpni > 1 ) THEN
          CALL mpp_ini_north
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) '   ==>>>   North fold boundary prepared for jpni >1'
+         IF (lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) '   ==>>>   North fold boundary prepared for jpni >1'
+            ! additional prints in layout.dat
+            WRITE(inum,*)
+            WRITE(inum,*)
+            WRITE(inum,*) 'number of subdomains located along the north fold : ', ndim_rank_north
+            WRITE(inum,*) 'Rank of the subdomains located along the north fold : ', ndim_rank_north
+            DO jproc = 1, ndim_rank_north, 5
+               WRITE(inum,*) nrank_north( jproc:MINVAL( (/jproc+4,ndim_rank_north/) ) )
+            END DO
+         ENDIF
       ENDIF
       !
       CALL mpp_init_ioipsl       ! Prepare NetCDF output file (if necessary)
       !
-      IF( ln_nnogather )   CALL mpp_init_nfdcom     ! northfold neighbour lists
+      IF( ln_nnogather ) THEN
+         CALL mpp_init_nfdcom     ! northfold neighbour lists
+         IF (lwp) THEN
+            WRITE(inum,*)
+            WRITE(inum,*)
+            WRITE(inum,*) 'north fold exchanges with explicit point-to-point messaging :'
+            WRITE(inum,*) 'nfsloop : ', nfsloop
+            WRITE(inum,*) 'nfeloop : ', nfeloop
+            WRITE(inum,*) 'nsndto : ', nsndto
+            WRITE(inum,*) 'isendto : ', isendto
+         ENDIF
+      ENDIF
+      !
+      IF (lwp) CLOSE(inum)   
       !
       DEALLOCATE(iin, ijn, ii_nono, ii_noea, ii_noso, ii_nowe,    &
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LDF/ldfc1d_c2d.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LDF/ldfc1d_c2d.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LDF/ldfc1d_c2d.F90	(revision 10288)
@@ -32,6 +32,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: $
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LDF/ldfdyn.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LDF/ldfdyn.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LDF/ldfdyn.F90	(revision 10288)
@@ -77,5 +77,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LDF/ldfslp.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LDF/ldfslp.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LDF/ldfslp.F90	(revision 10288)
@@ -77,5 +77,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LDF/ldftra.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LDF/ldftra.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/LDF/ldftra.F90	(revision 10288)
@@ -98,5 +98,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/README.rst
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/README.rst	(revision 10288)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/README.rst	(revision 10288)
@@ -0,0 +1,1 @@
+link ../../../doc/rst/source/data_assimilation.rst
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/ddatetoymdhms.h90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/ddatetoymdhms.h90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/ddatetoymdhms.h90	(revision 10288)
@@ -2,5 +2,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/diaobs.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/diaobs.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/diaobs.F90	(revision 10288)
@@ -99,5 +99,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/find_obs_proc.h90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/find_obs_proc.h90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/find_obs_proc.h90	(revision 10288)
@@ -2,5 +2,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/grt_cir_dis.h90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/grt_cir_dis.h90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/grt_cir_dis.h90	(revision 10288)
@@ -2,5 +2,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/grt_cir_dis_saa.h90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/grt_cir_dis_saa.h90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/grt_cir_dis_saa.h90	(revision 10288)
@@ -2,5 +2,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/linquad.h90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/linquad.h90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/linquad.h90	(revision 10288)
@@ -2,5 +2,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/maxdist.h90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/maxdist.h90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/maxdist.h90	(revision 10288)
@@ -2,5 +2,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/mpp_map.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/mpp_map.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/mpp_map.F90	(revision 10288)
@@ -28,5 +28,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_averg_h2d.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_averg_h2d.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_averg_h2d.F90	(revision 10288)
@@ -45,6 +45,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: obs_averg_h2d.F90 2715 2011-03-30 15:58:35Z rblod $
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_const.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_const.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_const.F90	(revision 10288)
@@ -7,5 +7,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_conv.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_conv.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_conv.F90	(revision 10288)
@@ -37,5 +37,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_conv_functions.h90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_conv_functions.h90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_conv_functions.h90	(revision 10288)
@@ -2,5 +2,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_fbm.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_fbm.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_fbm.F90	(revision 10288)
@@ -130,5 +130,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_grid.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_grid.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_grid.F90	(revision 10288)
@@ -88,5 +88,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_inter_h2d.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_inter_h2d.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_inter_h2d.F90	(revision 10288)
@@ -49,5 +49,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_inter_sup.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_inter_sup.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_inter_sup.F90	(revision 10288)
@@ -29,5 +29,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_inter_z1d.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_inter_z1d.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_inter_z1d.F90	(revision 10288)
@@ -27,5 +27,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_level_search.h90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_level_search.h90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_level_search.h90	(revision 10288)
@@ -2,5 +2,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_mpp.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_mpp.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_mpp.F90	(revision 10288)
@@ -40,5 +40,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_oper.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_oper.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_oper.F90	(revision 10288)
@@ -34,5 +34,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_prep.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_prep.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_prep.F90	(revision 10288)
@@ -36,5 +36,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_profiles.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_profiles.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_profiles.F90	(revision 10288)
@@ -8,5 +8,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_profiles_def.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_profiles_def.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_profiles_def.F90	(revision 10288)
@@ -192,5 +192,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_read_altbias.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_read_altbias.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_read_altbias.F90	(revision 10288)
@@ -44,5 +44,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_read_prof.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_read_prof.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_read_prof.F90	(revision 10288)
@@ -38,5 +38,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_read_surf.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_read_surf.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_read_surf.F90	(revision 10288)
@@ -32,6 +32,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: obs_read_surf.F90 4990 2014-12-15 16:42:49Z timgraham $
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_readmdt.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_readmdt.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_readmdt.F90	(revision 10288)
@@ -40,5 +40,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_rot_vel.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_rot_vel.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_rot_vel.F90	(revision 10288)
@@ -31,5 +31,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_sort.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_sort.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_sort.F90	(revision 10288)
@@ -23,5 +23,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_surf_def.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_surf_def.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_surf_def.F90	(revision 10288)
@@ -116,5 +116,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_types.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_types.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_types.F90	(revision 10288)
@@ -50,5 +50,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_utils.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_utils.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_utils.F90	(revision 10288)
@@ -37,5 +37,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_write.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_write.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obs_write.F90	(revision 10288)
@@ -49,5 +49,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obsinter_h2d.h90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obsinter_h2d.h90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obsinter_h2d.h90	(revision 10288)
@@ -2,5 +2,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obsinter_z1d.h90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obsinter_z1d.h90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/obsinter_z1d.h90	(revision 10288)
@@ -2,5 +2,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/str_c_to_for.h90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/str_c_to_for.h90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/OBS/str_c_to_for.h90	(revision 10288)
@@ -2,5 +2,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/README.rst
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/README.rst	(revision 10288)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/README.rst	(revision 10288)
@@ -0,0 +1,1 @@
+link ../../../doc/rst/source/coupling.rst
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/cpl_oasis3.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/cpl_oasis3.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/cpl_oasis3.F90	(revision 10288)
@@ -69,4 +69,7 @@
    INTEGER, PUBLIC, PARAMETER ::   nmaxcat=5    ! Maximum number of coupling fields
    INTEGER, PUBLIC, PARAMETER ::   nmaxcpl=5    ! Maximum number of coupling fields
+   LOGICAL, PARAMETER         ::   ltmp_wapatch = .TRUE.   ! patch to restore wraparound rows in cpl_send, cpl_rcv, cpl_define  
+   INTEGER                    ::   nldi_save, nlei_save
+   INTEGER                    ::   nldj_save, nlej_save
    
    TYPE, PUBLIC ::   FLD_CPL               !: Type for coupling field information
@@ -87,5 +90,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -145,4 +148,13 @@
       !!--------------------------------------------------------------------
 
+      ! patch to restore wraparound rows in cpl_send, cpl_rcv, cpl_define
+      IF ( ltmp_wapatch ) THEN
+         nldi_save = nldi   ;   nlei_save = nlei
+         nldj_save = nldj   ;   nlej_save = nlej
+         IF( nimpp           ==      1 ) nldi = 1
+         IF( nimpp + jpi - 1 == jpiglo ) nlei = jpi
+         IF( njmpp           ==      1 ) nldj = 1
+         IF( njmpp + jpj - 1 == jpjglo ) nlej = jpj
+      ENDIF 
       IF(lwp) WRITE(numout,*)
       IF(lwp) WRITE(numout,*) 'cpl_define : initialization in coupled ocean/atmosphere case'
@@ -296,4 +308,8 @@
       IF( nerror /= OASIS_Ok )   CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in oasis_enddef')
       !
+      IF ( ltmp_wapatch ) THEN
+         nldi = nldi_save   ;   nlei = nlei_save
+         nldj = nldj_save   ;   nlej = nlej_save
+      ENDIF
    END SUBROUTINE cpl_define
    
@@ -313,4 +329,13 @@
       INTEGER                                   ::   jc,jm     ! local loop index
       !!--------------------------------------------------------------------
+      ! patch to restore wraparound rows in cpl_send, cpl_rcv, cpl_define
+      IF ( ltmp_wapatch ) THEN
+         nldi_save = nldi   ;   nlei_save = nlei
+         nldj_save = nldj   ;   nlej_save = nlej
+         IF( nimpp           ==      1 ) nldi = 1
+         IF( nimpp + jpi - 1 == jpiglo ) nlei = jpi
+         IF( njmpp           ==      1 ) nldj = 1
+         IF( njmpp + jpj - 1 == jpjglo ) nlej = jpj
+      ENDIF
       !
       ! snd data to OASIS3
@@ -341,4 +366,8 @@
          ENDDO
       ENDDO
+      IF ( ltmp_wapatch ) THEN
+         nldi = nldi_save   ;   nlei = nlei_save
+         nldj = nldj_save   ;   nlej = nlej_save
+      ENDIF
       !
     END SUBROUTINE cpl_snd
@@ -361,4 +390,9 @@
       LOGICAL                                   ::   llaction, llfisrt
       !!--------------------------------------------------------------------
+      ! patch to restore wraparound rows in cpl_send, cpl_rcv, cpl_define
+      IF ( ltmp_wapatch ) THEN
+         nldi_save = nldi   ;   nlei_save = nlei
+         nldj_save = nldj   ;   nlej_save = nlej
+      ENDIF
       !
       ! receive local data from OASIS3 on every process
@@ -367,4 +401,10 @@
       !
       DO jc = 1, srcv(kid)%nct
+         IF ( ltmp_wapatch ) THEN
+            IF( nimpp           ==      1 ) nldi = 1
+            IF( nimpp + jpi - 1 == jpiglo ) nlei = jpi
+            IF( njmpp           ==      1 ) nldj = 1
+            IF( njmpp + jpj - 1 == jpjglo ) nlej = jpj
+         ENDIF
          llfisrt = .TRUE.
 
@@ -408,4 +448,8 @@
          ENDDO
 
+         IF ( ltmp_wapatch ) THEN
+            nldi = nldi_save   ;   nlei = nlei_save
+            nldj = nldj_save   ;   nlej = nlej_save
+         ENDIF
          !--- Fill the overlap areas and extra hallows (mpp)
          !--- check periodicity conditions (all cases)
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/cyclone.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/cyclone.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/cyclone.F90	(revision 10288)
@@ -39,7 +39,7 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/fldread.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/fldread.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/fldread.F90	(revision 10288)
@@ -125,5 +125,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/geo2ocean.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/geo2ocean.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/geo2ocean.F90	(revision 10288)
@@ -55,5 +55,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/ocealb.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/ocealb.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/ocealb.F90	(revision 10288)
@@ -21,6 +21,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: ocealb.F90 8268 2017-07-03 15:01:04Z clem $
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbc_ice.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbc_ice.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbc_ice.F90	(revision 10288)
@@ -49,5 +49,5 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   qml_ice        !: heat available for snow / ice surface melting     [W/m2] 
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   qcn_ice        !: heat conduction flux in the layer below surface   [W/m2] 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   qsr_ice_tr     !: solar flux transmitted below the ice surface      [W/m2]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   qtr_ice_top    !: solar flux transmitted below the ice surface      [W/m2]
 
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   utau_ice       !: atmos-ice u-stress. VP: I-pt ; EVP: U,V-pts   [N/m2]
@@ -109,5 +109,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -126,11 +126,11 @@
       ALLOCATE( qns_ice (jpi,jpj,jpl) , qsr_ice  (jpi,jpj,jpl) ,     &
          &      qla_ice (jpi,jpj,jpl) , dqla_ice (jpi,jpj,jpl) ,     &
-         &      dqns_ice(jpi,jpj,jpl) , tn_ice   (jpi,jpj,jpl) , alb_ice   (jpi,jpj,jpl) ,   &
-         &      qml_ice (jpi,jpj,jpl) , qcn_ice  (jpi,jpj,jpl) , qsr_ice_tr(jpi,jpj,jpl) ,   &
-         &      utau_ice(jpi,jpj)     , vtau_ice (jpi,jpj)     , wndm_ice  (jpi,jpj)     ,   &
-         &      evap_ice(jpi,jpj,jpl) , devap_ice(jpi,jpj,jpl) , qprec_ice (jpi,jpj)     ,   &
-         &      qemp_ice(jpi,jpj)     , qevap_ice(jpi,jpj,jpl) , qemp_oce  (jpi,jpj)     ,   &
-         &      qns_oce (jpi,jpj)     , qsr_oce  (jpi,jpj)     , emp_oce   (jpi,jpj)     ,   &
-         &      emp_ice (jpi,jpj)     , tsfc_ice (jpi,jpj,jpl) , sstfrz    (jpi,jpj)     , STAT= ierr(2) )
+         &      dqns_ice(jpi,jpj,jpl) , tn_ice   (jpi,jpj,jpl) , alb_ice    (jpi,jpj,jpl) ,   &
+         &      qml_ice (jpi,jpj,jpl) , qcn_ice  (jpi,jpj,jpl) , qtr_ice_top(jpi,jpj,jpl) ,   &
+         &      utau_ice(jpi,jpj)     , vtau_ice (jpi,jpj)     , wndm_ice   (jpi,jpj)     ,   &
+         &      evap_ice(jpi,jpj,jpl) , devap_ice(jpi,jpj,jpl) , qprec_ice  (jpi,jpj)     ,   &
+         &      qemp_ice(jpi,jpj)     , qevap_ice(jpi,jpj,jpl) , qemp_oce   (jpi,jpj)     ,   &
+         &      qns_oce (jpi,jpj)     , qsr_oce  (jpi,jpj)     , emp_oce    (jpi,jpj)     ,   &
+         &      emp_ice (jpi,jpj)     , tsfc_ice (jpi,jpj,jpl) , sstfrz     (jpi,jpj)     , STAT= ierr(2) )
 #endif
 
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbc_oce.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbc_oce.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbc_oce.F90	(revision 10288)
@@ -154,5 +154,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcapr.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcapr.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcapr.F90	(revision 10288)
@@ -41,7 +41,7 @@
 
    !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcblk.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcblk.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcblk.F90	(revision 10288)
@@ -46,5 +46,5 @@
    USE lib_fortran    ! to use key_nosignedzero
 #if defined key_si3
-   USE ice     , ONLY :   u_ice, v_ice, jpl, a_i_b, at_i_b, tm_su, rn_cnd_s
+   USE ice     , ONLY :   u_ice, v_ice, jpl, a_i_b, at_i_b, tm_su, rn_cnd_s, hfx_err_dif
    USE icethd_dh      ! for CALL ice_thd_snwblow
 #endif
@@ -135,6 +135,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: sbcblk.F90 6416 2016-04-01 12:22:17Z clem $
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -239,5 +239,5 @@
       !drag coefficient read from wave model definable only with mfs bulk formulae and core 
          ELSEIF (ln_cdgw .AND. .NOT. ln_NCAR )       THEN       
-             CALL ctl_stop( 'drag coefficient read from wave model definable only with mfs bulk formulae and core')
+             CALL ctl_stop( 'drag coefficient read from wave model definable only with NCAR and CORE bulk formulae')
          ELSEIF (ln_stcor .AND. .NOT. ln_sdw)                             THEN
              CALL ctl_stop( 'Stokes-Coriolis term calculated only if activated Stokes Drift ln_sdw=T')
@@ -526,10 +526,10 @@
       !
       qns(:,:) = zqlw(:,:) - zqsb(:,:) - zqla(:,:)                                &   ! Downward Non Solar
-         &     - sf(jp_snow)%fnow(:,:,1) * rn_pfac * lfus                         &   ! remove latent melting heat for solid precip
+         &     - sf(jp_snow)%fnow(:,:,1) * rn_pfac * rLfus                        &   ! remove latent melting heat for solid precip
          &     - zevap(:,:) * pst(:,:) * rcp                                      &   ! remove evap heat content at SST
          &     + ( sf(jp_prec)%fnow(:,:,1) - sf(jp_snow)%fnow(:,:,1) ) * rn_pfac  &   ! add liquid precip heat content at Tair
          &     * ( sf(jp_tair)%fnow(:,:,1) - rt0 ) * rcp                          &
          &     + sf(jp_snow)%fnow(:,:,1) * rn_pfac                                &   ! add solid  precip heat content at min(Tair,Tsnow)
-         &     * ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic
+         &     * ( MIN( sf(jp_tair)%fnow(:,:,1), rt0 ) - rt0 ) * rcpi
       qns(:,:) = qns(:,:) * tmask(:,:,1)
       !
@@ -659,5 +659,5 @@
             zrv = pqa(ji,jj) / (1. - pqa(ji,jj))
             ziRT = 1. / (R_dry*ptak(ji,jj))    ! 1/RT
-            gamma_moist(ji,jj) = grav * ( 1. + cevap*zrv*ziRT ) / ( Cp_dry + cevap*cevap*zrv*reps0*ziRT/ptak(ji,jj) )
+            gamma_moist(ji,jj) = grav * ( 1. + rLevap*zrv*ziRT ) / ( Cp_dry + rLevap*rLevap*zrv*reps0*ziRT/ptak(ji,jj) )
          END DO
       END DO
@@ -792,5 +792,5 @@
       REAL(wp) ::   zst3                     ! local variable
       REAL(wp) ::   zcoef_dqlw, zcoef_dqla   !   -      -
-      REAL(wp) ::   zztmp, z1_lsub           !   -      -
+      REAL(wp) ::   zztmp, z1_rLsub           !   -      -
       REAL(wp) ::   zfr1, zfr2               ! local variables
       REAL(wp), DIMENSION(jpi,jpj,jpl) ::   z1_st         ! inverse of surface temperature
@@ -868,8 +868,8 @@
 
       ! --- evaporation --- !
-      z1_lsub = 1._wp / Lsub
-      evap_ice (:,:,:) = rn_efac * qla_ice (:,:,:) * z1_lsub    ! sublimation
-      devap_ice(:,:,:) = rn_efac * dqla_ice(:,:,:) * z1_lsub    ! d(sublimation)/dT
-      zevap    (:,:)   = rn_efac * ( emp(:,:) + tprecip(:,:) )  ! evaporation over ocean
+      z1_rLsub = 1._wp / rLsub
+      evap_ice (:,:,:) = rn_efac * qla_ice (:,:,:) * z1_rLsub    ! sublimation
+      devap_ice(:,:,:) = rn_efac * dqla_ice(:,:,:) * z1_rLsub    ! d(sublimation)/dT
+      zevap    (:,:)   = rn_efac * ( emp(:,:) + tprecip(:,:) )   ! evaporation over ocean
 
       ! --- evaporation minus precipitation --- !
@@ -884,7 +884,7 @@
          &          + ( tprecip(:,:) - sprecip(:,:) ) * ( sf(jp_tair)%fnow(:,:,1) - rt0 ) * rcp  & ! liquid precip at Tair
          &          +   sprecip(:,:) * ( 1._wp - zsnw ) *                                        & ! solid precip at min(Tair,Tsnow)
-         &              ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) - lfus )
+         &              ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0 ) - rt0 ) * rcpi * tmask(:,:,1) - rLfus )
       qemp_ice(:,:) =   sprecip(:,:) * zsnw *                                                    & ! solid precip (only)
-         &              ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) - lfus )
+         &              ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0 ) - rt0 ) * rcpi * tmask(:,:,1) - rLfus )
 
       ! --- total solar and non solar fluxes --- !
@@ -894,9 +894,9 @@
 
       ! --- heat content of precip over ice in J/m3 (to be used in 1D-thermo) --- !
-      qprec_ice(:,:) = rhosn * ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) - lfus )
+      qprec_ice(:,:) = rhos * ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0 ) - rt0 ) * rcpi * tmask(:,:,1) - rLfus )
 
       ! --- heat content of evap over ice in W/m2 (to be used in 1D-thermo) ---
       DO jl = 1, jpl
-         qevap_ice(:,:,jl) = 0._wp ! should be -evap_ice(:,:,jl)*( ( Tice - rt0 ) * cpic * tmask(:,:,1) )
+         qevap_ice(:,:,jl) = 0._wp ! should be -evap_ice(:,:,jl)*( ( Tice - rt0 ) * rcpi * tmask(:,:,1) )
          !                         ! But we do not have Tice => consider it at 0degC => evap=0 
       END DO
@@ -907,9 +907,9 @@
       !
       WHERE    ( phs(:,:,:) <= 0._wp .AND. phi(:,:,:) <  0.1_wp )       ! linear decrease from hi=0 to 10cm  
-         qsr_ice_tr(:,:,:) = qsr_ice(:,:,:) * ( zfr1 + zfr2 * ( 1._wp - phi(:,:,:) * 10._wp ) )
+         qtr_ice_top(:,:,:) = qsr_ice(:,:,:) * ( zfr1 + zfr2 * ( 1._wp - phi(:,:,:) * 10._wp ) )
       ELSEWHERE( phs(:,:,:) <= 0._wp .AND. phi(:,:,:) >= 0.1_wp )       ! constant (zfr1) when hi>10cm
-         qsr_ice_tr(:,:,:) = qsr_ice(:,:,:) * zfr1
+         qtr_ice_top(:,:,:) = qsr_ice(:,:,:) * zfr1
       ELSEWHERE                                                         ! zero when hs>0
-         qsr_ice_tr(:,:,:) = 0._wp 
+         qtr_ice_top(:,:,:) = 0._wp 
       END WHERE
       !
@@ -971,5 +971,5 @@
       CASE ( 1 , 2 )
          !
-         zfac  = 1._wp /  ( rn_cnd_s + rcdic )
+         zfac  = 1._wp /  ( rn_cnd_s + rcnd_i )
          zfac2 = EXP(1._wp) * 0.5_wp * zepsilon
          zfac3 = 2._wp / zepsilon
@@ -978,5 +978,5 @@
             DO jj = 1 , jpj
                DO ji = 1, jpi
-                  zhe = ( rn_cnd_s * phi(ji,jj,jl) + rcdic * phs(ji,jj,jl) ) * zfac                             ! Effective thickness
+                  zhe = ( rn_cnd_s * phi(ji,jj,jl) + rcnd_i * phs(ji,jj,jl) ) * zfac                            ! Effective thickness
                   IF( zhe >=  zfac2 )   zgfac(ji,jj,jl) = MIN( 2._wp, 0.5_wp * ( 1._wp + LOG( zhe * zfac3 ) ) ) ! Enhanced conduction factor
                END DO
@@ -990,5 +990,5 @@
       ! -------------------------------------------------------------!
       !
-      zfac = rcdic * rn_cnd_s
+      zfac = rcnd_i * rn_cnd_s
       !
       DO jl = 1, jpl
@@ -997,8 +997,8 @@
                !                    
                zkeff_h = zfac * zgfac(ji,jj,jl) / &                                    ! Effective conductivity of the snow-ice system divided by thickness
-                  &      ( rcdic * phs(ji,jj,jl) + rn_cnd_s * MAX( 0.01, phi(ji,jj,jl) ) )
+                  &      ( rcnd_i * phs(ji,jj,jl) + rn_cnd_s * MAX( 0.01, phi(ji,jj,jl) ) )
                ztsu    = ptsu(ji,jj,jl)                                                ! Store current iteration temperature
                ztsu0   = ptsu(ji,jj,jl)                                                ! Store initial surface temperature
-               zqa0    = qsr_ice(ji,jj,jl) - qsr_ice_tr(ji,jj,jl) + qns_ice(ji,jj,jl)  ! Net initial atmospheric heat flux
+               zqa0    = qsr_ice(ji,jj,jl) - qtr_ice_top(ji,jj,jl) + qns_ice(ji,jj,jl) ! Net initial atmospheric heat flux
                !
                DO iter = 1, nit     ! --- Iterative loop
@@ -1011,6 +1011,9 @@
                qcn_ice(ji,jj,jl) = zkeff_h * ( ptsu(ji,jj,jl) - ptb(ji,jj) )
                qns_ice(ji,jj,jl) = qns_ice(ji,jj,jl) + dqns_ice(ji,jj,jl) * ( ptsu(ji,jj,jl) - ztsu0 )
-               qml_ice(ji,jj,jl) = ( qsr_ice(ji,jj,jl) - qsr_ice_tr(ji,jj,jl) + qns_ice(ji,jj,jl) - qcn_ice(ji,jj,jl) )   &
+               qml_ice(ji,jj,jl) = ( qsr_ice(ji,jj,jl) - qtr_ice_top(ji,jj,jl) + qns_ice(ji,jj,jl) - qcn_ice(ji,jj,jl) )  &
                              &   * MAX( 0._wp , SIGN( 1._wp, ptsu(ji,jj,jl) - rt0 ) )
+
+               ! --- Diagnose the heat loss due to changing non-solar flux (as in icethd_zdf_bl99) --- !
+               hfx_err_dif(ji,jj) = hfx_err_dif(ji,jj) - ( dqns_ice(ji,jj,jl) * ( ptsu(ji,jj,jl) - ztsu0 ) ) * a_i_b(ji,jj,jl) 
 
             END DO
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcblk_algo_ncar.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcblk_algo_ncar.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcblk_algo_ncar.F90	(revision 10288)
@@ -149,4 +149,6 @@
       Ch = 1.e-3*sqrt_Cd_n10*(18.*stab + 32.7*(1. - stab))
       stab = sqrt_Cd_n10   ! Temporaty array !!! stab == SQRT(Cd)
+ 
+      IF( ln_cdgw )   Cen = Ce  ; Chn = Ch
 
       !! Initializing values at z_u with z_t values:
@@ -186,5 +188,12 @@
          IF( ln_cdgw ) THEN      ! surface wave case
             stab = vkarmn / ( vkarmn / sqrt_Cd_n10 - ztmp2 )  ! (stab == SQRT(Cd))
-            Cd      = stab * stab
+            Cd   = stab * stab
+            ztmp0 = (LOG(zu/10.) - zpsi_h_u) / vkarmn / sqrt_Cd_n10
+            ztmp2 = stab / sqrt_Cd_n10   ! (stab == SQRT(Cd))
+            ztmp1 = 1. + Chn * ztmp0     
+            Ch    = Chn * ztmp2 / ztmp1  ! L&Y 2004 eq. (10b)
+            ztmp1 = 1. + Cen * ztmp0
+            Ce    = Cen * ztmp2 / ztmp1  ! L&Y 2004 eq. (10c)
+
          ELSE
             ! Update neutral wind speed at 10m and neutral Cd at 10m (L&Y 2004 eq. 9a)...
@@ -205,15 +214,15 @@
             Cd      = ztmp0 / ( ztmp1*ztmp1 )
             stab = SQRT( Cd ) ! Temporary array !!! (stab == SQRT(Cd))
-         ENDIF
-
-         ztmp0 = (LOG(zu/10.) - zpsi_h_u) / vkarmn / sqrt_Cd_n10
-         ztmp2 = stab / sqrt_Cd_n10   ! (stab == SQRT(Cd))
-         ztmp1 = 1. + Cx_n10*ztmp0    ! (Cx_n10 == Ch_n10)
-         Ch  = Cx_n10*ztmp2 / ztmp1   ! L&Y 2004 eq. (10b)
-
-         Cx_n10  = 1.e-3 * (34.6 * sqrt_Cd_n10)  ! L&Y 2004 eq. (6b)    ! Cx_n10 == Ce_n10
-         Cen(:,:) = Cx_n10
-         ztmp1 = 1. + Cx_n10*ztmp0
-         Ce  = Cx_n10*ztmp2 / ztmp1  ! L&Y 2004 eq. (10c)
+
+            ztmp0 = (LOG(zu/10.) - zpsi_h_u) / vkarmn / sqrt_Cd_n10
+            ztmp2 = stab / sqrt_Cd_n10   ! (stab == SQRT(Cd))
+            ztmp1 = 1. + Cx_n10*ztmp0    ! (Cx_n10 == Ch_n10)
+            Ch  = Cx_n10*ztmp2 / ztmp1   ! L&Y 2004 eq. (10b)
+
+            Cx_n10  = 1.e-3 * (34.6 * sqrt_Cd_n10)  ! L&Y 2004 eq. (6b)    ! Cx_n10 == Ce_n10
+            Cen(:,:) = Cx_n10
+            ztmp1 = 1. + Cx_n10*ztmp0
+            Ce  = Cx_n10*ztmp2 / ztmp1  ! L&Y 2004 eq. (10c)
+            ENDIF
          !
       END DO
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbccpl.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbccpl.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbccpl.F90	(revision 10288)
@@ -202,5 +202,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -1352,5 +1352,5 @@
       IF( srcv(jpr_ocx1)%laction ) THEN                      ! received by sas in case of opa <-> sas coupling
          ssu_m(:,:) = frcv(jpr_ocx1)%z3(:,:,1)
-         ub (:,:,1) = ssu_m(:,:)                             ! will be used in icestp in the call of lim_sbc_tau
+         ub (:,:,1) = ssu_m(:,:)                             ! will be used in icestp in the call of ice_forcing_tau
          un (:,:,1) = ssu_m(:,:)                             ! will be used in sbc_cpl_snd if atmosphere coupling
          CALL iom_put( 'ssu_m', ssu_m )
@@ -1358,5 +1358,5 @@
       IF( srcv(jpr_ocy1)%laction ) THEN
          ssv_m(:,:) = frcv(jpr_ocy1)%z3(:,:,1)
-         vb (:,:,1) = ssv_m(:,:)                             ! will be used in icestp in the call of lim_sbc_tau
+         vb (:,:,1) = ssv_m(:,:)                             ! will be used in icestp in the call of ice_forcing_tau
          vn (:,:,1) = ssv_m(:,:)                             ! will be used in sbc_cpl_snd if atmosphere coupling
          CALL iom_put( 'ssv_m', ssv_m )
@@ -1418,9 +1418,9 @@
             zqns(:,:) =  zqns(:,:) - zemp(:,:) * sst_m(:,:) * rcp         ! remove heat content due to mass flux (assumed to be at SST)
             IF( srcv(jpr_snow  )%laction ) THEN
-               zqns(:,:) = zqns(:,:) - frcv(jpr_snow)%z3(:,:,1) * lfus    ! energy for melting solid precipitation over the free ocean
+               zqns(:,:) = zqns(:,:) - frcv(jpr_snow)%z3(:,:,1) * rLfus   ! energy for melting solid precipitation over the free ocean
             ENDIF
          ENDIF
          !
-         IF( srcv(jpr_icb)%laction )  zqns(:,:) = zqns(:,:) - frcv(jpr_icb)%z3(:,:,1) * lfus ! remove heat content associated to iceberg melting
+         IF( srcv(jpr_icb)%laction )  zqns(:,:) = zqns(:,:) - frcv(jpr_icb)%z3(:,:,1) * rLfus ! remove heat content associated to iceberg melting
          !
          IF( ln_mixcpl ) THEN   ;   qns(:,:) = qns(:,:) * xcplmask(:,:,0) + zqns(:,:) * zmsk(:,:)
@@ -1811,8 +1811,8 @@
       !                                     
       ! --- calving (removed from qns_tot) --- !
-      IF( srcv(jpr_cal)%laction )   zqns_tot(:,:) = zqns_tot(:,:) - frcv(jpr_cal)%z3(:,:,1) * lfus  ! remove latent heat of calving
-                                                                                                    ! we suppose it melts at 0deg, though it should be temp. of surrounding ocean
+      IF( srcv(jpr_cal)%laction )   zqns_tot(:,:) = zqns_tot(:,:) - frcv(jpr_cal)%z3(:,:,1) * rLfus  ! remove latent heat of calving
+                                                                                                     ! we suppose it melts at 0deg, though it should be temp. of surrounding ocean
       ! --- iceberg (removed from qns_tot) --- !
-      IF( srcv(jpr_icb)%laction )   zqns_tot(:,:) = zqns_tot(:,:) - frcv(jpr_icb)%z3(:,:,1) * lfus  ! remove latent heat of iceberg melting
+      IF( srcv(jpr_icb)%laction )   zqns_tot(:,:) = zqns_tot(:,:) - frcv(jpr_icb)%z3(:,:,1) * rLfus  ! remove latent heat of iceberg melting
 
 #if defined key_si3      
@@ -1823,5 +1823,5 @@
 
       ! Heat content per unit mass of snow (J/kg)
-      WHERE( SUM( a_i, dim=3 ) > 1.e-10 )   ;   zcptsnw(:,:) = cpic * SUM( (tn_ice - rt0) * a_i, dim=3 ) / SUM( a_i, dim=3 )
+      WHERE( SUM( a_i, dim=3 ) > 1.e-10 )   ;   zcptsnw(:,:) = rcpi * SUM( (tn_ice - rt0) * a_i, dim=3 ) / SUM( a_i, dim=3 )
       ELSEWHERE                             ;   zcptsnw(:,:) = zcptn(:,:)
       ENDWHERE
@@ -1830,9 +1830,9 @@
 
       ! --- enthalpy of snow precip over ice in J/m3 (to be used in 1D-thermo) --- !
-      zqprec_ice(:,:) = rhosn * ( zcptsnw(:,:) - lfus )
+      zqprec_ice(:,:) = rhos * ( zcptsnw(:,:) - rLfus )
 
       ! --- heat content of evap over ice in W/m2 (to be used in 1D-thermo) --- !
       DO jl = 1, jpl
-         zqevap_ice(:,:,jl) = 0._wp ! should be -evap * ( ( Tice - rt0 ) * cpic ) but atm. does not take it into account
+         zqevap_ice(:,:,jl) = 0._wp ! should be -evap * ( ( Tice - rt0 ) * rcpi ) but atm. does not take it into account
       END DO
 
@@ -1840,8 +1840,8 @@
       zqemp_oce(:,:) = -  zevap_oce(:,:)                                      *   zcptn   (:,:)   &        ! evap
          &             + ( ztprecip(:,:) - zsprecip(:,:) )                    *   zcptrain(:,:)   &        ! liquid precip
-         &             +   zsprecip(:,:)                   * ( 1._wp - zsnw ) * ( zcptsnw (:,:) - lfus )   ! solid precip over ocean + snow melting
-      zqemp_ice(:,:) =     zsprecip(:,:)                   * zsnw             * ( zcptsnw (:,:) - lfus )   ! solid precip over ice (qevap_ice=0 since atm. does not take it into account)
+         &             +   zsprecip(:,:)                   * ( 1._wp - zsnw ) * ( zcptsnw (:,:) - rLfus )  ! solid precip over ocean + snow melting
+      zqemp_ice(:,:) =     zsprecip(:,:)                   * zsnw             * ( zcptsnw (:,:) - rLfus )  ! solid precip over ice (qevap_ice=0 since atm. does not take it into account)
 !!    zqemp_ice(:,:) = -   frcv(jpr_ievp)%z3(:,:,1)        * picefr(:,:)      *   zcptsnw (:,:)   &        ! ice evap
-!!       &             +   zsprecip(:,:)                   * zsnw             * zqprec_ice(:,:) * r1_rhosn ! solid precip over ice
+!!       &             +   zsprecip(:,:)                   * zsnw             * zqprec_ice(:,:) * r1_rhos  ! solid precip over ice
       
       ! --- total non solar flux (including evap/precip) --- !
@@ -1874,7 +1874,7 @@
       
       ! clem: this formulation is certainly wrong... but better than it was...
-      zqns_tot(:,:) = zqns_tot(:,:)                            &          ! zqns_tot update over free ocean with:
-         &          - (  ziceld(:,:) * zsprecip(:,:) * lfus )  &          ! remove the latent heat flux of solid precip. melting
-         &          - (  zemp_tot(:,:)                         &          ! remove the heat content of mass flux (assumed to be at SST)
+      zqns_tot(:,:) = zqns_tot(:,:)                             &          ! zqns_tot update over free ocean with:
+         &          - (  ziceld(:,:) * zsprecip(:,:) * rLfus )  &          ! remove the latent heat flux of solid precip. melting
+         &          - (  zemp_tot(:,:)                          &          ! remove the heat content of mass flux (assumed to be at SST)
          &             - zemp_ice(:,:) ) * zcptn(:,:) 
 
@@ -1892,13 +1892,13 @@
 #endif
       ! outputs
-      IF ( srcv(jpr_cal)%laction       ) CALL iom_put('hflx_cal_cea'    , - frcv(jpr_cal)%z3(:,:,1) * lfus )                       ! latent heat from calving
-      IF ( srcv(jpr_icb)%laction       ) CALL iom_put('hflx_icb_cea'    , - frcv(jpr_icb)%z3(:,:,1) * lfus )                       ! latent heat from icebergs melting
+      IF ( srcv(jpr_cal)%laction       ) CALL iom_put('hflx_cal_cea'    , - frcv(jpr_cal)%z3(:,:,1) * rLfus )                      ! latent heat from calving
+      IF ( srcv(jpr_icb)%laction       ) CALL iom_put('hflx_icb_cea'    , - frcv(jpr_icb)%z3(:,:,1) * rLfus )                      ! latent heat from icebergs melting
       IF ( iom_use('hflx_rain_cea')    ) CALL iom_put('hflx_rain_cea'   , ( tprecip(:,:) - sprecip(:,:) ) * zcptrain(:,:) )        ! heat flux from rain (cell average)
       IF ( iom_use('hflx_evap_cea')    ) CALL iom_put('hflx_evap_cea'   , ( frcv(jpr_tevp)%z3(:,:,1) - frcv(jpr_ievp)%z3(:,:,1) &
            &                                                              * picefr(:,:) ) * zcptn(:,:) * tmask(:,:,1) )            ! heat flux from evap (cell average)
-      IF ( iom_use('hflx_snow_cea')    ) CALL iom_put('hflx_snow_cea'   , sprecip(:,:) * ( zcptsnw(:,:) - Lfus )   )               ! heat flux from snow (cell average)
-      IF ( iom_use('hflx_snow_ao_cea') ) CALL iom_put('hflx_snow_ao_cea', sprecip(:,:) * ( zcptsnw(:,:) - Lfus ) &
+      IF ( iom_use('hflx_snow_cea')    ) CALL iom_put('hflx_snow_cea'   , sprecip(:,:) * ( zcptsnw(:,:) - rLfus )  )               ! heat flux from snow (cell average)
+      IF ( iom_use('hflx_snow_ao_cea') ) CALL iom_put('hflx_snow_ao_cea', sprecip(:,:) * ( zcptsnw(:,:) - rLfus ) &
            &                                                              * ( 1._wp - zsnw(:,:) )                  )               ! heat flux from snow (over ocean)
-      IF ( iom_use('hflx_snow_ai_cea') ) CALL iom_put('hflx_snow_ai_cea', sprecip(:,:) * ( zcptsnw(:,:) - Lfus ) &
+      IF ( iom_use('hflx_snow_ai_cea') ) CALL iom_put('hflx_snow_ai_cea', sprecip(:,:) * ( zcptsnw(:,:) - rLfus ) & 
            &                                                              *           zsnw(:,:)                    )               ! heat flux from snow (over ice)
       ! note: hflx for runoff and iceshelf are done in sbcrnf and sbcisf resp.
@@ -1999,6 +1999,6 @@
       !                                                      ! ========================= !
       CASE ('coupled')
-         qml_ice(:,:,:) = frcv(jpr_topm)%z3(:,:,:) * a_i(:,:,:)
-         qcn_ice(:,:,:) = frcv(jpr_botm)%z3(:,:,:) * a_i(:,:,:)
+         qml_ice(:,:,:) = frcv(jpr_topm)%z3(:,:,:)
+         qcn_ice(:,:,:) = frcv(jpr_botm)%z3(:,:,:)
       END SELECT
       !
@@ -2012,13 +2012,13 @@
          ztri = 0.18 * ( 1.0 - cldf_ice ) + 0.35 * cldf_ice    ! surface transmission parameter (Grenfell Maykut 77)
          !
-         qsr_ice_tr(:,:,:) = ztri * qsr_ice(:,:,:)
-         WHERE( phs(:,:,:) >= 0.0_wp )   qsr_ice_tr(:,:,:) = 0._wp            ! snow fully opaque
-         WHERE( phi(:,:,:) <= 0.1_wp )   qsr_ice_tr(:,:,:) = qsr_ice(:,:,:)   ! thin ice transmits all solar radiation
+         qtr_ice_top(:,:,:) = ztri * qsr_ice(:,:,:)
+         WHERE( phs(:,:,:) >= 0.0_wp )   qtr_ice_top(:,:,:) = 0._wp            ! snow fully opaque
+         WHERE( phi(:,:,:) <= 0.1_wp )   qtr_ice_top(:,:,:) = qsr_ice(:,:,:)   ! thin ice transmits all solar radiation
          !     
       CASE( np_jules_ACTIVE )       !==  Jules coupler is active  ==!
          !
-         !                    ! ===> here we must receive the qsr_ice_tr array from the coupler
+         !                    ! ===> here we must receive the qtr_ice_top array from the coupler
          !                           for now just assume zero (fully opaque ice)
-         qsr_ice_tr(:,:,:) = 0._wp
+         qtr_ice_top(:,:,:) = 0._wp
          !
       END SELECT
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcdcy.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcdcy.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcdcy.F90	(revision 10288)
@@ -31,7 +31,7 @@
 
    !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcflx.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcflx.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcflx.F90	(revision 10288)
@@ -40,7 +40,7 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcfwb.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcfwb.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcfwb.F90	(revision 10288)
@@ -44,5 +44,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -155,13 +155,13 @@
             ztmsk_neg(:,:) = tmask_i(:,:) - ztmsk_pos(:,:)
             !
-            zsurf_neg = glob_sum( e1e2t(:,:)*ztmsk_neg(:,:) )  ! Area filled by <0 and >0 erp 
-            zsurf_pos = glob_sum( e1e2t(:,:)*ztmsk_pos(:,:) )
             !                                                  ! fwf global mean (excluding ocean to ice/snow exchanges) 
             z_fwf     = glob_sum( e1e2t(:,:) * ( emp(:,:) - rnf(:,:) + fwfisf(:,:) - snwice_fmass(:,:) ) ) / area
             !            
             IF( z_fwf < 0._wp ) THEN         ! spread out over >0 erp area to increase evaporation
+                zsurf_pos = glob_sum( e1e2t(:,:)*ztmsk_pos(:,:) )
                 zsurf_tospread      = zsurf_pos
                 ztmsk_tospread(:,:) = ztmsk_pos(:,:)
             ELSE                             ! spread out over <0 erp area to increase precipitation
+                zsurf_neg = glob_sum( e1e2t(:,:)*ztmsk_neg(:,:) )  ! Area filled by <0 and >0 erp 
                 zsurf_tospread      = zsurf_neg
                 ztmsk_tospread(:,:) = ztmsk_neg(:,:)
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcice_cice.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcice_cice.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcice_cice.F90	(revision 10288)
@@ -13,5 +13,5 @@
    USE dom_oce         ! ocean space and time domain
    USE domvvl
-   USE phycst, only : rcp, rau0, r1_rau0, rhosn, rhoic
+   USE phycst, only : rcp, rau0, r1_rau0, rhos, rhoi
    USE in_out_manager  ! I/O manager
    USE iom, ONLY : iom_put,iom_use              ! I/O manager library !!Joakim edit
@@ -89,7 +89,7 @@
 
    !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -222,5 +222,5 @@
       CALL cice2nemo(vsno(:,:,:),ztmp1,'T', 1. )
       CALL cice2nemo(vice(:,:,:),ztmp2,'T', 1. )
-      snwice_mass  (:,:) = ( rhosn * ztmp1(:,:) + rhoic * ztmp2(:,:)  )
+      snwice_mass  (:,:) = ( rhos * ztmp1(:,:) + rhoi * ztmp2(:,:)  )
       snwice_mass_b(:,:) = snwice_mass(:,:)
 
@@ -328,5 +328,5 @@
          ELSE
 ! emp_ice is set in sbc_cpl_ice_flx as sublimation-snow
-            qla_ice(:,:,1)= - ( emp_ice(:,:)+sprecip(:,:) ) * Lsub
+            qla_ice(:,:,1)= - ( emp_ice(:,:)+sprecip(:,:) ) * rLsub
 ! End of temporary code
             DO jj=1,jpj
@@ -644,5 +644,5 @@
       CALL cice2nemo(vsno(:,:,:),ztmp1,'T', 1. )
       CALL cice2nemo(vice(:,:,:),ztmp2,'T', 1. )
-      snwice_mass  (:,:) = ( rhosn * ztmp1(:,:) + rhoic * ztmp2(:,:)  )
+      snwice_mass  (:,:) = ( rhos * ztmp1(:,:) + rhoi * ztmp2(:,:)  )
       snwice_mass_b(:,:) = snwice_mass(:,:)
       snwice_fmass (:,:) = ( snwice_mass(:,:) - snwice_mass_b(:,:) ) / dt
@@ -801,5 +801,5 @@
       tprecip(:,:) = sf(jp_snow)%fnow(:,:,1)+sf(jp_rain)%fnow(:,:,1)
 ! May be better to do this conversion somewhere else
-      qla_ice(:,:,1) = -Lsub*sf(jp_sblm)%fnow(:,:,1)
+      qla_ice(:,:,1) = -rLsub*sf(jp_sblm)%fnow(:,:,1)
       topmelt(:,:,1) = sf(jp_top1)%fnow(:,:,1)
       topmelt(:,:,2) = sf(jp_top2)%fnow(:,:,1)
@@ -1051,12 +1051,17 @@
 
    SUBROUTINE sbc_ice_cice ( kt, ksbc )     ! Dummy routine
+      IMPLICIT NONE
+      INTEGER, INTENT( in ) :: kt, ksbc
       WRITE(*,*) 'sbc_ice_cice: You should not have seen this print! error?', kt
    END SUBROUTINE sbc_ice_cice
 
    SUBROUTINE cice_sbc_init (ksbc)    ! Dummy routine
-      WRITE(*,*) 'cice_sbc_init: You should not have seen this print! error?'
+      IMPLICIT NONE
+      INTEGER, INTENT( in ) :: ksbc
+      WRITE(*,*) 'cice_sbc_init: You should not have seen this print! error?', ksbc
    END SUBROUTINE cice_sbc_init
 
    SUBROUTINE cice_sbc_final     ! Dummy routine
+      IMPLICIT NONE
       WRITE(*,*) 'cice_sbc_final: You should not have seen this print! error?'
    END SUBROUTINE cice_sbc_final
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcice_if.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcice_if.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcice_if.F90	(revision 10288)
@@ -38,5 +38,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcisf.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcisf.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcisf.F90	(revision 10288)
@@ -52,9 +52,9 @@
    LOGICAL, PUBLIC ::   l_isfcpl = .false.       !: isf recieved from oasis
 
-   REAL(wp), PUBLIC, SAVE ::   rcpi     = 2000.0_wp     !: specific heat of ice shelf             [J/kg/K]
+   REAL(wp), PUBLIC, SAVE ::   rcpisf   = 2000.0_wp     !: specific heat of ice shelf             [J/kg/K]
    REAL(wp), PUBLIC, SAVE ::   rkappa   = 1.54e-6_wp    !: heat diffusivity through the ice-shelf [m2/s]
    REAL(wp), PUBLIC, SAVE ::   rhoisf   = 920.0_wp      !: volumic mass of ice shelf              [kg/m3]
    REAL(wp), PUBLIC, SAVE ::   tsurf    = -20.0_wp      !: air temperature on top of ice shelf    [C]
-   REAL(wp), PUBLIC, SAVE ::   rlfusisf = 0.334e6_wp    !: latent heat of fusion of ice shelf     [J/kg]
+   REAL(wp), PUBLIC, SAVE ::   rLfusisf = 0.334e6_wp    !: latent heat of fusion of ice shelf     [J/kg]
 
 !: Variable used in fldread to read the forcing file (nn_isf == 4 .OR. nn_isf == 3)
@@ -71,5 +71,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -114,5 +114,5 @@
             ! compute fwf and heat flux
             IF( .NOT.l_isfcpl ) THEN    ;   CALL sbc_isf_cav (kt)
-            ELSE                        ;   qisf(:,:)  = fwfisf(:,:) * rlfusisf  ! heat        flux
+            ELSE                        ;   qisf(:,:)  = fwfisf(:,:) * rLfusisf  ! heat        flux
             ENDIF
             !
@@ -127,5 +127,5 @@
                fwfisf(:,:) = - sf_rnfisf(1)%fnow(:,:,1)         ! fresh water flux from the isf (fwfisf <0 mean melting) 
             ENDIF
-            qisf(:,:)   = fwfisf(:,:) * rlfusisf             ! heat flux
+            qisf(:,:)   = fwfisf(:,:) * rLfusisf             ! heat flux
             stbl(:,:)   = soce
             !
@@ -137,5 +137,5 @@
                fwfisf(:,:) = -sf_fwfisf(1)%fnow(:,:,1)            ! fwf
             ENDIF
-            qisf(:,:)   = fwfisf(:,:) * rlfusisf               ! heat flux
+            qisf(:,:)   = fwfisf(:,:) * rLfusisf               ! heat flux
             stbl(:,:)   = soce
             !
@@ -454,5 +454,5 @@
                            & * r1_e1e2t(ji,jj) * tmask(ji,jj,jk)
              
-               fwfisf(ji,jj) = qisf(ji,jj) / rlfusisf          !fresh water flux kg/(m2s)                  
+               fwfisf(ji,jj) = qisf(ji,jj) / rLfusisf          !fresh water flux kg/(m2s)                  
                fwfisf(ji,jj) = fwfisf(ji,jj) * ( soce / stbl(ji,jj) )
                !add to salinity trend
@@ -526,5 +526,5 @@
                DO ji = 1, jpi
                   zhtflx(ji,jj) =   zgammat(ji,jj)*rcp*rau0*(ttbl(ji,jj)-zfrz(ji,jj))
-                  zfwflx(ji,jj) = - zhtflx(ji,jj)/rlfusisf
+                  zfwflx(ji,jj) = - zhtflx(ji,jj)/rLfusisf
                END DO
             END DO
@@ -544,6 +544,6 @@
                   ! compute coeficient to solve the 2nd order equation
                   zeps1 = rcp*rau0*zgammat(ji,jj)
-                  zeps2 = rlfusisf*rau0*zgammas(ji,jj)
-                  zeps3 = rhoisf*rcpi*rkappa/MAX(risfdep(ji,jj),zeps)
+                  zeps2 = rLfusisf*rau0*zgammas(ji,jj)
+                  zeps3 = rhoisf*rcpisf*rkappa/MAX(risfdep(ji,jj),zeps)
                   zeps4 = zlamb2+zlamb3*risfdep(ji,jj)
                   zeps6 = zeps4-ttbl(ji,jj)
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcmod.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcmod.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcmod.F90	(revision 10288)
@@ -46,4 +46,5 @@
    USE sbcfwb         ! surface boundary condition: freshwater budget
    USE icbstp         ! Icebergs
+   USE icb_oce  , ONLY : ln_passive_mode      ! iceberg interaction mode
    USE traqsr         ! active tracers: light penetration
    USE sbcwave        ! Wave module
@@ -68,7 +69,7 @@
 
    !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -156,7 +157,10 @@
          WRITE(numout,*) '               wave modified ocean stress component ln_tauw       = ', ln_tauw
          WRITE(numout,*) '               Stokes coriolis term                 ln_stcor      = ', ln_stcor
-         WRITE(numout,*) '               neutral drag coefficient (CORE, MFS) ln_cdgw       = ', ln_cdgw
-      ENDIF
-      !
+         WRITE(numout,*) '               neutral drag coefficient (CORE,NCAR) ln_cdgw       = ', ln_cdgw
+      ENDIF
+      !
+      IF( .NOT.ln_wave ) THEN
+         ln_sdw = .false. ; ln_cdgw = .false. ; ln_tauwoc = .false. ; ln_tauw = .false. ; ln_stcor = .false.
+      ENDIF 
       IF( ln_sdw ) THEN
          IF( .NOT.(nn_sdrift==jp_breivik_2014 .OR. nn_sdrift==jp_li_2017 .OR. nn_sdrift==jp_peakfr) ) &
@@ -432,5 +436,10 @@
       END SELECT
 
-      IF( ln_icebergs    )   CALL icb_stp( kt )                   ! compute icebergs
+      IF( ln_icebergs    )   THEN
+                                     CALL icb_stp( kt )           ! compute icebergs
+         ! icebergs may advect into haloes during the icb step and alter emp.
+         ! A lbc_lnk is necessary here to ensure restartability (#2113)
+         IF( .NOT. ln_passive_mode ) CALL lbc_lnk( emp, 'T', 1. ) ! ensure restartability with icebergs
+      ENDIF
 
       IF( ln_isf         )   CALL sbc_isf( kt )                   ! compute iceshelves
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcrnf.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcrnf.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcrnf.F90	(revision 10288)
@@ -71,5 +71,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -128,5 +128,5 @@
             END WHERE
             WHERE( sf_t_rnf(1)%fnow(:,:,1) == -222._wp )             ! where fwf comes from melting of ice shelves or iceberg
-               rnf_tsc(:,:,jp_tem) = ztfrz(:,:) * rnf(:,:) * r1_rau0 - rnf(:,:) * rlfusisf * r1_rau0_rcp
+               rnf_tsc(:,:,jp_tem) = ztfrz(:,:) * rnf(:,:) * r1_rau0 - rnf(:,:) * rLfusisf * r1_rau0_rcp
             END WHERE
          ELSE                                                        ! use SST as runoffs temperature
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcssm.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcssm.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcssm.F90	(revision 10288)
@@ -34,5 +34,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcssr.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcssr.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcssr.F90	(revision 10288)
@@ -49,5 +49,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbctide.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbctide.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbctide.F90	(revision 10288)
@@ -35,5 +35,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcwave.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcwave.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/sbcwave.F90	(revision 10288)
@@ -74,7 +74,7 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -131,8 +131,13 @@
          END DO
       ELSE IF( ll_st_peakfr ) THEN    ! peak wave number calculated from the peak frequency received by the wave model
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zk_t(ji,jj) = ( 2.0_wp * rpi * wfreq(ji,jj) ) * ( 2.0_wp * rpi * wfreq(ji,jj) ) / grav
+            END DO
+         END DO
          DO jj = 1, jpjm1
             DO ji = 1, jpim1
-               zk_u(ji,jj) = 0.5_wp * ( wfreq(ji,jj)*wfreq(ji,jj) + wfreq(ji+1,jj)*wfreq(ji+1,jj) ) / grav
-               zk_v(ji,jj) = 0.5_wp * ( wfreq(ji,jj)*wfreq(ji,jj) + wfreq(ji,jj+1)*wfreq(ji,jj+1) ) / grav
+               zk_u(ji,jj) = 0.5_wp * ( zk_t(ji,jj) + zk_t(ji+1,jj) )
+               zk_v(ji,jj) = 0.5_wp * ( zk_t(ji,jj) + zk_t(ji,jj+1) )
                !
                zu0_sd(ji,jj) = 0.5_wp * ( ut0sd(ji,jj) + ut0sd(ji+1,jj) )
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/tide_mod.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/tide_mod.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/tide_mod.F90	(revision 10288)
@@ -34,7 +34,7 @@
 
    !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/tideini.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/tideini.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/tideini.F90	(revision 10288)
@@ -41,5 +41,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/updtide.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/updtide.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/SBC/updtide.F90	(revision 10288)
@@ -23,5 +23,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/STO/stopar.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/STO/stopar.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/STO/stopar.F90	(revision 10288)
@@ -114,6 +114,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: dynhpg.F90 2528 2010-12-27 17:33:53Z rblod $
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/STO/stopts.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/STO/stopts.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/STO/stopts.F90	(revision 10288)
@@ -29,6 +29,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: eosbn2.F90 2528 2010-12-27 17:33:53Z rblod $
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/STO/storng.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/STO/storng.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/STO/storng.F90	(revision 10288)
@@ -59,6 +59,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: dynhpg.F90 2528 2010-12-27 17:33:53Z rblod $
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/eosbn2.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/eosbn2.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/eosbn2.F90	(revision 10288)
@@ -182,5 +182,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traadv.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traadv.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traadv.F90	(revision 10288)
@@ -71,5 +71,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traadv_cen.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traadv_cen.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traadv_cen.F90	(revision 10288)
@@ -39,6 +39,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id:$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traadv_fct.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traadv_fct.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traadv_fct.F90	(revision 10288)
@@ -48,5 +48,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -311,13 +311,18 @@
             IF( l_hst )   CALL dia_ar5_hst( jn, 'adv', ztrdx(:,:,:), ztrdy(:,:,:) )
             !
-            DEALLOCATE( ztrdx, ztrdy, ztrdz )
          ENDIF
          IF( l_ptr ) THEN              ! "Poleward" transports
             zptry(:,:,:) = zptry(:,:,:) + zwy(:,:,:)  ! <<< add anti-diffusive fluxes
             CALL dia_ptr_hst( jn, 'adv', zptry(:,:,:) )
-            DEALLOCATE( zptry )
          ENDIF
          !
       END DO                     ! end of tracer loop
+      !
+      IF( l_trd .OR. l_hst ) THEN 
+         DEALLOCATE( ztrdx, ztrdy, ztrdz )
+      ENDIF
+      IF( l_ptr ) THEN 
+         DEALLOCATE( zptry )
+      ENDIF
       !
    END SUBROUTINE tra_adv_fct
@@ -548,4 +553,8 @@
 !!gm  
       !
+      IF ( ln_isfcav ) THEN            ! set level two values which may not be set in ISF case
+         zwd(:,:,2) = 1._wp  ;  zwi(:,:,2) = 0._wp  ;  zws(:,:,2) = 0._wp  ;  zwrm(:,:,2) = 0._wp
+      END IF
+      !
       DO jj = 2, jpjm1                 ! 2nd order centered at top & bottom
          DO ji = fs_2, fs_jpim1
@@ -556,10 +565,10 @@
             zwi (ji,jj,ikt) = 0._wp
             zws (ji,jj,ikt) = 0._wp
-            zwrm(ji,jj,ikt) = 0.5_wp * ( pt_in(ji,jj,jk-1) + pt_in(ji,jj,jk) )
+            zwrm(ji,jj,ikt) = 0.5_wp * ( pt_in(ji,jj,ikt-1) + pt_in(ji,jj,ikt) )
             !
             zwd (ji,jj,ikb) = 1._wp          ! bottom
             zwi (ji,jj,ikb) = 0._wp
             zws (ji,jj,ikb) = 0._wp
-            zwrm(ji,jj,ikb) = 0.5_wp * ( pt_in(ji,jj,jk-1) + pt_in(ji,jj,jk) )            
+            zwrm(ji,jj,ikb) = 0.5_wp * ( pt_in(ji,jj,ikb-1) + pt_in(ji,jj,ikb) )            
          END DO
       END DO   
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traadv_mus.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traadv_mus.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traadv_mus.F90	(revision 10288)
@@ -50,5 +50,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traadv_qck.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traadv_qck.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traadv_qck.F90	(revision 10288)
@@ -43,5 +43,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traadv_ubs.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traadv_ubs.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traadv_ubs.F90	(revision 10288)
@@ -42,5 +42,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/trabbc.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/trabbc.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/trabbc.F90	(revision 10288)
@@ -47,5 +47,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/trabbl.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/trabbl.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/trabbl.F90	(revision 10288)
@@ -71,5 +71,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -526,5 +526,5 @@
       zmbku(:,:) = REAL( mbku_d(:,:), wp )   ;     zmbkv(:,:) = REAL( mbkv_d(:,:), wp )  
       CALL lbc_lnk_multi( zmbku,'U',1., zmbkv,'V',1.) 
-      mbku_d(:,:) = MAX( INT( zmbku(:,:) ), 1 ) ;  mbkv_d(:,:) = MAX( INT( zmbkv(:,:) ), 1 )
+      mbku_d(:,:) = MAX( INT( zmbku(:,:) ), 1 ) ;  mbkv_d(:,:) = MAX( NINT( zmbkv(:,:) ), 1 )
       !
       !                             !* sign of grad(H) at u- and v-points; zero if grad(H) = 0
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/tradmp.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/tradmp.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/tradmp.F90	(revision 10288)
@@ -56,5 +56,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traldf.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traldf.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traldf.F90	(revision 10288)
@@ -43,5 +43,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traldf_iso.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traldf_iso.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traldf_iso.F90	(revision 10288)
@@ -44,5 +44,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traldf_lap_blp.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traldf_lap_blp.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traldf_lap_blp.F90	(revision 10288)
@@ -41,5 +41,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traldf_triad.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traldf_triad.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traldf_triad.F90	(revision 10288)
@@ -44,5 +44,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/tramle.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/tramle.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/tramle.F90	(revision 10288)
@@ -52,5 +52,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -97,11 +97,13 @@
       !                                                ! compute from the 10m density to deal with the diurnal cycle
       inml_mle(:,:) = mbkt(:,:) + 1                    ! init. to number of ocean w-level (T-level + 1)
-      DO jk = jpkm1, nlb10, -1                         ! from the bottom to nlb10 (10m)
-         DO jj = 1, jpj
-            DO ji = 1, jpi                             ! index of the w-level at the ML based
-               IF( rhop(ji,jj,jk) > rhop(ji,jj,nla10) + rn_rho_c_mle )   inml_mle(ji,jj) = jk      ! Mixed layer
-            END DO
-         END DO
-      END DO
+      IF ( nla10 > 0 ) THEN                            ! avoid case where first level is thicker than 10m
+         DO jk = jpkm1, nlb10, -1                      ! from the bottom to nlb10 (10m)
+            DO jj = 1, jpj
+               DO ji = 1, jpi                          ! index of the w-level at the ML based
+                  IF( rhop(ji,jj,jk) > rhop(ji,jj,nla10) + rn_rho_c_mle )   inml_mle(ji,jj) = jk      ! Mixed layer
+               END DO
+            END DO
+         END DO
+      ENDIF
       ikmax = MIN( MAXVAL( inml_mle(:,:) ), jpkm1 )                  ! max level of the computation
       !
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/tranpc.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/tranpc.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/tranpc.F90	(revision 10288)
@@ -38,5 +38,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/tranxt.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/tranxt.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/tranxt.F90	(revision 10288)
@@ -58,7 +58,7 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -291,5 +291,5 @@
          ztrd_atf(:,:,:,:) = 0.0_wp
       ENDIF
-      zfact = 1._wp / r2dt
+      zfact = 1._wp / p2dt
       zfact1 = atfp * p2dt
       zfact2 = zfact1 * r1_rau0
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traqsr.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traqsr.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/traqsr.F90	(revision 10288)
@@ -71,5 +71,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/trasbc.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/trasbc.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/trasbc.F90	(revision 10288)
@@ -48,5 +48,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/trazdf.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/trazdf.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/trazdf.F90	(revision 10288)
@@ -40,5 +40,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/zpshde.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/zpshde.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRA/zpshde.F90	(revision 10288)
@@ -35,5 +35,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trd_oce.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trd_oce.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trd_oce.F90	(revision 10288)
@@ -78,5 +78,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!======================================================================
 END MODULE trd_oce
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trddyn.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trddyn.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trddyn.F90	(revision 10288)
@@ -40,5 +40,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdglo.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdglo.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdglo.F90	(revision 10288)
@@ -55,5 +55,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdini.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdini.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdini.F90	(revision 10288)
@@ -30,5 +30,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdken.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdken.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdken.F90	(revision 10288)
@@ -44,5 +44,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdmxl.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdmxl.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdmxl.F90	(revision 10288)
@@ -71,5 +71,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -303,5 +303,5 @@
       !!        of time-averaged mixed-layer fields, this residual WILL NOT BE ZERO
       !!        over the first two analysis windows (except if restart).
-      !!        N.B. For ORCA2_LIM, use e.g. nn_trd=5, rn_ucf=1., nn_ctls=8
+      !!        N.B. For ORCA2_ICE, use e.g. nn_trd=5, rn_ucf=1., nn_ctls=8
       !!             for checking residuals.
       !!             On a NEC-SX5 computer, this typically leads to:
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdmxl_oce.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdmxl_oce.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdmxl_oce.F90	(revision 10288)
@@ -84,5 +84,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdmxl_rst.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdmxl_rst.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdmxl_rst.F90	(revision 10288)
@@ -28,5 +28,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!---------------------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdpen.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdpen.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdpen.F90	(revision 10288)
@@ -40,5 +40,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdtra.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdtra.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdtra.F90	(revision 10288)
@@ -45,5 +45,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -358,54 +358,7 @@
          SELECT CASE( ktrd )
          CASE( jptra_atf  )   ;   CALL iom_put( "ttrd_atf" , ptrdx )        ! asselin time Filter
-            CALL iom_put( "strd_atf" , ptrdy )
+                                  CALL iom_put( "strd_atf" , ptrdy )
          END SELECT
       END IF
-      !
-      ! These trends are done every second time step. When 1ts output is selected must go different (2ts) file from standard T-file
-      IF( MOD( kt, 2 ) == 0 ) THEN
-         SELECT CASE( ktrd )
-         CASE( jptra_xad  )   ;   CALL iom_put( "ttrd_xad"  , ptrdx )         ! x- horizontal advection
-                                  CALL iom_put( "strd_xad"  , ptrdy )
-         CASE( jptra_yad  )   ;   CALL iom_put( "ttrd_yad"  , ptrdx )         ! y- horizontal advection
-                                  CALL iom_put( "strd_yad"  , ptrdy )
-         CASE( jptra_zad  )   ;   CALL iom_put( "ttrd_zad"  , ptrdx )         ! z- vertical   advection
-                                  CALL iom_put( "strd_zad"  , ptrdy )
-                                  IF( ln_linssh ) THEN                   ! cst volume : adv flux through z=0 surface
-                                     ALLOCATE( z2dx(jpi,jpj) , z2dy(jpi,jpj) )
-                                     z2dx(:,:) = wn(:,:,1) * tsn(:,:,1,jp_tem) / e3t_n(:,:,1)
-                                     z2dy(:,:) = wn(:,:,1) * tsn(:,:,1,jp_sal) / e3t_n(:,:,1)
-                                     CALL iom_put( "ttrd_sad", z2dx )
-                                     CALL iom_put( "strd_sad", z2dy )
-                                     DEALLOCATE( z2dx, z2dy )
-                                  ENDIF
-         CASE( jptra_totad  ) ;   CALL iom_put( "ttrd_totad", ptrdx )         ! total   advection
-                                  CALL iom_put( "strd_totad", ptrdy )
-         CASE( jptra_ldf  )   ;   CALL iom_put( "ttrd_ldf"  , ptrdx )         ! lateral diffusion
-                                  CALL iom_put( "strd_ldf"  , ptrdy )
-         CASE( jptra_zdf  )   ;   CALL iom_put( "ttrd_zdf"  , ptrdx )         ! vertical diffusion (including Kz contribution)
-                                  CALL iom_put( "strd_zdf"  , ptrdy )
-         CASE( jptra_zdfp )   ;   CALL iom_put( "ttrd_zdfp" , ptrdx )         ! PURE vertical diffusion (no isoneutral contribution)
-                                  CALL iom_put( "strd_zdfp" , ptrdy )
-         CASE( jptra_evd )    ;   CALL iom_put( "ttrd_evd"  , ptrdx )         ! EVD trend (convection)
-                                  CALL iom_put( "strd_evd"  , ptrdy )
-         CASE( jptra_dmp  )   ;   CALL iom_put( "ttrd_dmp"  , ptrdx )         ! internal restoring (damping)
-                                  CALL iom_put( "strd_dmp"  , ptrdy )
-         CASE( jptra_bbl  )   ;   CALL iom_put( "ttrd_bbl"  , ptrdx )         ! bottom boundary layer
-                                  CALL iom_put( "strd_bbl"  , ptrdy )
-         CASE( jptra_npc  )   ;   CALL iom_put( "ttrd_npc"  , ptrdx )         ! static instability mixing
-                                  CALL iom_put( "strd_npc"  , ptrdy )
-         CASE( jptra_bbc  )   ;   CALL iom_put( "ttrd_bbc"  , ptrdx )         ! geothermal heating   (only on temperature)
-         CASE( jptra_nsr  )   ;   CALL iom_put( "ttrd_qns"  , ptrdx(:,:,1) )  ! surface forcing + runoff (ln_rnf=T)
-                                  CALL iom_put( "strd_cdt"  , ptrdy(:,:,1) )        ! output as 2D surface fields
-         CASE( jptra_qsr  )   ;   CALL iom_put( "ttrd_qsr"  , ptrdx )         ! penetrative solar radiat. (only on temperature)
-         END SELECT
-         ! the Asselin filter trend  is also every other time step but needs to be lagged one time step
-         ! Even when 1ts output is selected can go to the same (2ts) file as the trends plotted every even time step.
-      ELSEIF( MOD( kt, 2 ) == 1 ) THEN
-         SELECT CASE( ktrd )
-         CASE( jptra_atf  )   ;   CALL iom_put( "ttrd_atf" , ptrdx )        ! asselin time Filter
-                                  CALL iom_put( "strd_atf" , ptrdy )
-         END SELECT
-      ENDIF
       !
    END SUBROUTINE trd_tra_iom
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdtrc.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdtrc.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdtrc.F90	(revision 10288)
@@ -19,5 +19,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!======================================================================
 END MODULE trdtrc
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdvor.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdvor.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdvor.F90	(revision 10288)
@@ -60,5 +60,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdvor_oce.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdvor_oce.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/TRD/trdvor_oce.F90	(revision 10288)
@@ -30,5 +30,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!======================================================================
 END MODULE trdvor_oce
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/README-setup-configs
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/README-setup-configs	(revision 10288)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/README-setup-configs	(revision 10288)
@@ -0,0 +1,53 @@
+==============================================================
+== HOW TO set up user’s configuration in NEMO version 4.0 : ==
+==============================================================
+This document describes how a configuration is set up in NEMO.
+
+In NEMO 4.0 two types of configurations can be build: global/regional and idealized.
+
+- create ./cfgs/your_config
+- case 1: regional or global 
+    => ln_read_cfg = .true. in ./cfgs/your_config/EXP00/namelist_cfg (i.e. read domain_cfg.nc)
+- case 2: idealized 
+    =>in ./cfgs/your_config/EXP00/namelist_cfg :
+      ln_read_cfg = .false. (need to define usrdef_hgr.F90 and usrdef_zgr.F90) 
+      ln_usr = .true.       (need to define usrdef_sbc.F90)    
+    => copy ./src/OCE/USR in ./cfgs/your_config/MY_SRC routines nedeed to set up domain, forcing fields and initial state
+    
+  Routines in NEMOGCM/NEMO/OCE/USR define analytically the domain, the initial state and the surface boundary conditions for the reference configuration GYRE.
+	  •	usrdef_hgr.F90 and usrdef_zgr.F90 : define horizontal and vertical grid
+	  •	usrdef_sbc.F90    : provides at each time-step the surface boundary condition, i.e. the momentum, heat and freshwater fluxes
+	  •	usrdef_istate.F90 : defines initialization of the dynamics and tracers
+	  •	usrdef_fmask.F90  : used just in ORCA CONFIGURATIONS for alteration of f-point land/ocean mask in some straits 
+	  •	usrdef_closea.F90 : used just in ORCA CONFIGURATIONS for specific treatments associated with closed seas
+	  •	usrdef_nam.F90    : set the domain characteristics of a user configuration
+
+  Other analytical examples are given in ./tests.
+
+===========================================
+== The domain_cfg.nc file must contain : ==
+===========================================
+   int ORCA  , ORCA_index            : configuration name, configuration resolution
+   int jpiglo, jpjglo , jpkglo       : global domain sizes 
+   int jperio                        : lateral global domain b.c. 
+   int ln_zco, ln_zps, ln_sco        : flags for z-coordinate, z-coordinate with partial steps and s-coordinate 
+   int ln_isfcav                     : flag  for ice shelf cavities 
+   double glamt, glamu, glamv, glamf : geographic position 
+   double gphit, gphiu, gphiv, gphif : geographic position
+   double iff, ff_f, ff_t            : Coriolis parameter (if not on the sphere)
+   double e1t, e1u, e1v, e1f         : horizontal scale factors
+   double e2t, e2u, e2v, e2f         : horizontal scale factors
+   double ie1e2u_v, e1e2u, e1e2v     : U and V surfaces (if grid size reduction in some straits)
+   double e3t_1d, e3w_1d             : reference vertical scale factors at T and W points
+   double e3t_0, e3u_0, e3v_0, e3f_0, e3w_0 : vertical scale factors 3D coordinate at T,U,V,F and W points
+   double e3uw_0,e3vw_0              : vertical scale factors 3D coordinate at UW and VW points
+   int bottom_level, top_level       : last wet T-points, 1st wet T-points (for ice shelf cavities)
+
+=======================================
+= HOW TO CREATE domain_cfg.nc file : ==
+=======================================
+Two options are possible :
+
+ - users can create with his own tool the domain_cfg.nc with all mandatory fields.  
+
+ - tool is available in ./tools/DOMAINcfg based on NEMO 3.6 version. See ./tools/DOMAINcfg/README.
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/README.rst
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/README.rst	(revision 10288)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/README.rst	(revision 10288)
@@ -0,0 +1,256 @@
+==============================
+Setting up a new configuration
+==============================
+
+.. include:: .global.rst
+
+.. contents::
+
+Starting from an existing configuration
+=======================================
+
+There are three options to build a new configuration from an existing one:
+
+---------------------------------------------
+Option 1: Duplicate an existing configuration
+---------------------------------------------
+
+The NEMO so-called Reference Configurations cover a number of major features for NEMO setup
+(global, regional, 1D, using embeded zoom with AGRIF...)
+
+One can create a new configuration by duplicating one of the reference configurations
+(``ORCA2_LIM3_PISCES`` in the following example)
+
+.. code-block:: sh
+
+	makenemo –n 'ORCA2_LIM3_PISCES_MINE' -r 'ORCA2_LIM3_PISCES'
+
+------------------------------------
+Option 2: Duplicate with differences
+------------------------------------
+
+Create and compile a new configuration based on a reference configuration
+(``ORCA2_LIM3_PISCES`` in the following example) but with different pre-processor options.
+For this either add ``add_key`` or ``del_key`` keys as required; e.g.
+
+.. code-block:: sh
+
+	makenemo –n 'ORCA2_LIM3_PISCES_MINE' -r 'ORCA2_LIM3_PISCES' del_key 'key_iomput' add_key 'key_xios'
+
+---------------------------------------------------------
+Option 3: Use the SIREN tools to subset an existing model
+---------------------------------------------------------
+
+Define a regional configuration which is a sub- or super-set of an existing configuration.
+
+This last option employs the SIREN software tools that are included in the standard distribution.
+The software is written in Fortran 95 and available in the ``./tools/SIREN`` directory.
+SIREN allows you to create your own regional configuration embedded in a wider one.
+
+SIREN is a set of programs to create all the input files you need to run a NEMO regional configuration.
+As a basic demonstrator, a set of GLORYS files (GLObal ReanalYSis on the ORCA025 grid),
+as well as examples of namelists are available `here`_.
+
+`SIREN documentation`_
+
+Any questions or comments regarding the use of SIREN should be posted in `the corresponding forum`_.
+
+Creating a completely new configuration
+=======================================
+
+From NEMO version 4.0 there are two ways to build configurations from scratch.
+The appropriate method to use depends largely on the target configuration.
+Method 1 is for more complex/realistic global or regional configurations and
+method 2 is intended for simpler, idealised configurations whose
+domains and characteristics can be described in simple geometries and formulae.
+
+----------------------------------------------------
+Option 1: Create and use a domain configuration file
+----------------------------------------------------
+
+This method is used by each of the reference configurations,
+so that downloading their input files linked to their description can help.
+Although starting from scratch it is advisable to create the directory structure to house your new configuration by
+duplicating the closest reference configuration to your target application.
+For example, if your application requires both ocean ice and passive tracers,
+then use the ``ORCA2_LIM3_PISCES`` as template,
+and execute following command to build your ``MY_NEW_CONFIG`` configuration:
+
+.. code-block:: sh
+
+	makenemo –n 'MY_NEW_CONFIG' -r 'ORCA2_LIM3_PISCES'
+
+where ``MY_NEW_CONFIG`` can be substituted with a suitably descriptive name for your new configuration.  
+
+The purpose of this step is simply to create and populate the appropriate ``WORK``, ``MY_SRC`` and
+``EXP00`` subdirectories for your new configuration.
+Other choices for the base reference configuration might be
+
+- ``GYRE``  - If your target application is ocean-only
+- ``AMM12`` - If your target application is regional with open boundaries
+
+All the domain information for your new configuration will be contained within
+a netcdf file called ``domain_cfg.nc`` which you will need to create and
+place in the ``./cfgs/MY_NEW_CONFIG/EXP00`` sub-directory.
+Firstly though, ensure that your configuration is set to use such a file by checking that
+
+.. code-block:: fortran
+
+	ln_read_cfg = .true.
+
+in	``./cfgs/MY_NEW_CONFIG/EXP00/namelist_cfg``
+
+Create the domain_cfg.nc file which must contain the following fields
+
+.. code-block:: c++
+
+	int    ORCA, ORCA_index                  /* configuration name, configuration resolution                 */
+	int    jpiglo, jpjglo, jpkglo            /* global domain sizes                                          */
+	int    jperio                            /* lateral global domain b.c.                                   */
+	int    ln_zco, ln_zps, ln_sco            /* flags for z-coord, z-coord with partial steps and s-coord    */
+	int    ln_isfcav                         /* flag  for ice shelf cavities                                 */
+	double glamt, glamu, glamv, glamf        /* geographic position                                          */
+	double gphit, gphiu, gphiv, gphif        /* geographic position                                          */
+	double iff, ff_f, ff_t                   /* Coriolis parameter (if not on the sphere)                    */
+	double e1t, e1u, e1v, e1f                /* horizontal scale factors                                     */
+	double e2t, e2u, e2v, e2f                /* horizontal scale factors                                     */
+	double ie1e2u_v, e1e2u, e1e2v            /* U and V surfaces (if grid size reduction in some straits)    */
+	double e3t_1d, e3w_1d                    /* reference vertical scale factors at T and W points           */
+	double e3t_0, e3u_0, e3v_0, e3f_0, e3w_0 /* vertical scale factors 3D coordinate at T,U,V,F and W points */
+	double e3uw_0, e3vw_0                    /* vertical scale factors 3D coordinate at UW and VW points     */
+	int    bottom_level, top_level           /* last wet T-points, 1st wet T-points (for ice shelf cavities) */
+
+There are two options for creating a domain_cfg.nc file:
+
+- Users can use tools of their own choice to build a ``domain_cfg.nc`` with all mandatory fields.
+- Users can adapt and apply the supplied tool available in ``./tools/DOMAINcfg``.
+  This tool is based on code extracted from NEMO version 3.6 and will allow similar choices for
+  the horizontal and vertical grids that were available internally to that version.
+  See ``./tools/DOMAINcfg/README`` for details.
+
+-----------------------------------------------------------------------------
+Option 2: Adapt the usr_def configuration module of NEMO for you own purposes
+-----------------------------------------------------------------------------
+
+This method is intended for configuring easily simple/idealised configurations which
+are often used as demonstrators or for process evaluation and comparison.
+This method can be used whenever the domain geometry has a simple mathematical description and
+the ocean initial state and boundary forcing is described analytically. 
+As a start, consider the case of starting a completely new ocean-only test case based on
+the ``LOCK_EXCHANGE`` example.
+[Note: we probably need an even more basic example than this with only one namelist and
+minimal changes to the usrdef modules]
+
+Firstly, construct the directory structure, starting in the ``cfgs`` directory:
+
+.. code-block:: sh
+
+	./makenemo -n 'MY_NEW_TEST' -t 'LOCK_EXCHANGE'
+
+where the ``-t`` option has been used to locate the new configuration in the ``tests`` subdirectory
+(it is recommended practice to keep full configurations and idealised cases clearly distinguishable).
+This command will have created (amongst others) the following files and directories::
+
+	./tests/MY_NEW_TEST:
+	BLD	  MY_SRC cpp_MY_NEW_TEST.fcm
+	EXP00   WORK
+	#
+	./tests/MY_NEW_TEST/EXP00:
+	context_nemo.xml       domain_def_nemo.xml
+	field_def_nemo-opa.xml file_def_nemo-opa.xml
+	iodef.xml
+	namelist_cfg
+	namelist_ref
+	#
+	./tests/MY_NEW_TEST/MY_SRC:
+	usrdef_hgr.F90    usrdef_nam.F90 usrdef_zgr.F90
+	usrdef_istate.F90 usrdef_sbc.F90 zdfini.F90
+
+The key to setting up an idealised configuration lies in adapting a small set of short Fortran 90 modules which
+should be dropped into the ``MY_SRC`` directory.
+Here the ``LOCK_EXCHANGE`` example is using 5 such routines but the full set that is available in
+the ``src/OCE/USR`` directory is::
+
+	./src/OCE/USR:
+	usrdef_closea.F90 usrdef_istate.F90 usrdef_zgr.F90
+	usrdef_fmask.F90  usrdef_nam.F90
+	usrdef_hgr.F90    usrdef_sbc.F90
+
+Before discussing these in more detail it is worth noting the various namelist controls that
+engage the different user-defined aspects.
+These controls are set using two new logical switches or are implied by the settings of existing ones.
+For example, the mandatory requirement for an idealised configuration is to provide routines which
+define the horizontal and vertical domains.
+Templates for these are provided in the ``usrdef_hgr.F90`` and ``usrdef_zgr.F90`` modules.
+The application of these modules is activated whenever:
+
+.. code-block:: fortran
+
+	ln_read_cfg = .false.
+
+in any configuration's ``namelist_cfg`` file.
+This setting also activates the reading of an optional ``nam_usrdef`` namelist which can be used to
+supply configuration specific settings.
+These need to be declared and read in the ``usrdef_nam.F90`` module.
+
+Another explicit control is available in the ``namsbc`` namelist which activates the use of analytical forcing.
+With
+
+.. code-block:: fortran
+
+	ln_usr = .true.
+
+Other usrdef modules are activated by less explicit means.
+For example, code in ``usrdef_istate.F90`` is used to define initial temperature and salinity fields if
+
+.. code-block:: fortran
+
+	ln_tsd_init   = .false.
+
+in the ``namtsd`` namelist.
+The remaining modules, namely::
+
+	usrdef_closea.F90 usrdef_fmask.F90
+
+are specific to ORCA configurations and set local variations of some specific fields for
+the various resolutions of the global models.
+They do not need to be considered here in the context of idealised cases but it is worth noting that all
+configuration specific code has now been isolated in the usrdef modules.
+In the case of these last two modules, they are activated only if an ORCA configuration is detected.
+Currently this requires a specific integer variable named ``ORCA`` to be set in a ``domain_cfg.nc`` file.
+[Note: this would be less confusing if the cn_cfg string is read directly as a character attribue from
+the ``domain_cfg.nc`` ]
+
+So, in most cases, the set up of idealised model configurations can be completed by
+copying the template routines from ``./src/OCE/USR`` into
+your new ``./cfgs/MY_NEW_TEST/MY_SRC`` directory and editing the appropriate modules as needed.
+The default set are those used for the GYRE reference configuration.
+The contents of ``MY_SRC`` directories from other idealised configurations may provide more convenient templates if
+they share common characteristics with your target application.
+
+Whatever the starting point it should not require too many changes or additional lines of code to
+produce routines in ``./src/OCE/USR`` that define analytically the domain,
+the initial state and the surface boundary conditions for your new configuration.
+
+To summarize, the base set of modules is:
+
+- ``usrdef_hgr.F90``   : define horizontal grid
+- ``usrdef_zgr.F90``   : define vertical grid
+- ``usrdef_sbc.F90``   : provides at each time-step the surface boundary condition, i.e. the momentum, heat and freshwater fluxes
+- ``usrdef_istate.F90``: defines initialization of the dynamics and tracers
+- ``usrdef_nam.F90``   : configuration-specific namelist processing to set any associated run-time parameters
+
+with two specialised ORCA modules
+(not related to idealised configurations but used to isolate configuration specific code that is used in
+ORCA2 reference configurations and established global configurations using the ORCA tripolar grid):
+
+- ``usrdef_fmask.F90`` : only used in ORCA CONFIGURATIONS for alteration of f-point land/ocean mask in some straits
+- ``usrdef_closea.F90``: only used in ORCA CONFIGURATIONS for specific treatments associated with closed seas
+
+From version 4.0, the NEMO release includes a ``tests`` subdirectory containing available and
+up to date test cases build by the community.
+These will not be fully supported as is NEMO reference but should provide a source of raw material.
+
+.. _here:                     http://prodn.idris.fr/thredds/catalog/ipsl_public/rron463/catalog.html?dataset=DatasetScanipsl_public/rron463/INPUT_SIREN.tar
+.. _the corresponding forum:  http://forge.ipsl.jussieu.fr/nemo/discussion/forum/2
+.. _SIREN documentation:      http://forge.ipsl.jussieu.fr/nemo/doxygen/index.html
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/usrdef_fmask.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/usrdef_fmask.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/usrdef_fmask.F90	(revision 10288)
@@ -30,6 +30,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id:$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$ 
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/usrdef_hgr.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/usrdef_hgr.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/usrdef_hgr.F90	(revision 10288)
@@ -28,6 +28,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id:$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$ 
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/usrdef_istate.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/usrdef_istate.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/usrdef_istate.F90	(revision 10288)
@@ -26,6 +26,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id:$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$ 
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/usrdef_nam.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/usrdef_nam.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/usrdef_nam.F90	(revision 10288)
@@ -32,6 +32,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id:$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$ 
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/usrdef_sbc.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/usrdef_sbc.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/usrdef_sbc.F90	(revision 10288)
@@ -34,6 +34,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id:$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/usrdef_zgr.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/usrdef_zgr.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/USR/usrdef_zgr.F90	(revision 10288)
@@ -33,6 +33,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id:$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS             
@@ -204,5 +204,5 @@
       CALL lbc_lnk( z2d, 'T', 1. )           ! set surrounding land to zero (here jperio=0 ==>> closed)
       !
-      k_bot(:,:) = INT( z2d(:,:) )           ! =jpkm1 over the ocean point, =0 elsewhere
+      k_bot(:,:) = NINT( z2d(:,:) )           ! =jpkm1 over the ocean point, =0 elsewhere
       !
       k_top(:,:) = MIN( 1 , k_bot(:,:) )     ! = 1    over the ocean point, =0 elsewhere
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdf_oce.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdf_oce.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdf_oce.F90	(revision 10288)
@@ -54,5 +54,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfddm.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfddm.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfddm.F90	(revision 10288)
@@ -34,5 +34,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfdrg.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfdrg.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfdrg.F90	(revision 10288)
@@ -76,6 +76,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: zdfdrg.F90 7753 2017-03-03 11:46:59Z gm $
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfevd.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfevd.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfevd.F90	(revision 10288)
@@ -34,5 +34,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfgls.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfgls.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfgls.F90	(revision 10288)
@@ -108,5 +108,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfiwm.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfiwm.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfiwm.F90	(revision 10288)
@@ -52,6 +52,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: zdfiwm.F90 8093 2017-05-30 08:13:14Z gm $
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfmxl.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfmxl.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfmxl.F90	(revision 10288)
@@ -38,5 +38,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfosm.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfosm.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfosm.F90	(revision 10288)
@@ -106,5 +106,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfphy.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfphy.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfphy.F90	(revision 10288)
@@ -56,6 +56,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: zdfphy.F90 8160 2017-06-10 07:31:34Z gm $
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfric.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfric.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfric.F90	(revision 10288)
@@ -54,5 +54,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfsh2.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfsh2.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfsh2.F90	(revision 10288)
@@ -23,6 +23,6 @@
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: $
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfswm.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfswm.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdfswm.F90	(revision 10288)
@@ -28,7 +28,7 @@
 
    !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
-   !! $Id:$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdftke.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdftke.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/ZDF/zdftke.F90	(revision 10288)
@@ -93,5 +93,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/lib_cray.f90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/lib_cray.f90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/lib_cray.f90	(revision 10288)
@@ -5,9 +5,9 @@
 !  
 !  wheneq
-!!----------------------------------------------------------------------
-!!  OPA 9.0 , NEMO Consortium (2018) 
-!! $Id$ 
-!! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
-!!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id$ 
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
 SUBROUTINE lib_cray
       WRITE(*,*) 'lib_cray: You should not have seen this print! error?'
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/lib_fortran.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/lib_fortran.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/lib_fortran.F90	(revision 10288)
@@ -58,5 +58,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/module_example
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/module_example	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/module_example	(revision 10288)
@@ -53,5 +53,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/nemo.f90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/nemo.f90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/nemo.f90	(revision 10288)
@@ -13,5 +13,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
    !
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/nemogcm.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/nemogcm.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/nemogcm.F90	(revision 10288)
@@ -105,5 +105,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/oce.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/oce.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/oce.F90	(revision 10288)
@@ -70,5 +70,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/par_kind.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/par_kind.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/par_kind.F90	(revision 10288)
@@ -36,5 +36,5 @@
    !! NEMO 3.3 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 END MODULE par_kind
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/par_oce.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/par_oce.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/par_oce.F90	(revision 10288)
@@ -79,5 +79,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!======================================================================
 END MODULE par_oce
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/step.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/step.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/step.F90	(revision 10288)
@@ -48,5 +48,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/step_oce.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/step_oce.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/step_oce.F90	(revision 10288)
@@ -112,5 +112,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!======================================================================
 END MODULE step_oce
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/stpctl.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/stpctl.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/stpctl.F90	(revision 10288)
@@ -36,5 +36,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -114,5 +114,5 @@
          CALL mpp_max_multiple( zmax(:), 5 )    ! max over the global domain
          !
-         nstop = INT( zmax(5) )                 ! nstop indicator sheared among all local domains
+         nstop = NINT( zmax(5) )                 ! nstop indicator sheared among all local domains
       ENDIF
       !
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/timing.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/timing.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/timing.F90	(revision 10288)
@@ -79,5 +79,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -211,5 +211,5 @@
          WRITE(numtime,*) '                             NEMO team'
          WRITE(numtime,*) '                  Ocean General Circulation Model'
-         WRITE(numtime,*) '                        version 3.6  (2015) '
+         WRITE(numtime,*) '                        version 4.0  (2018) '
          WRITE(numtime,*)
          WRITE(numtime,*) '                        Timing Informations '
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/trc_oce.F90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/trc_oce.F90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/trc_oce.F90	(revision 10288)
@@ -46,5 +46,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence     (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
Index: NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/vectopt_loop_substitute.h90
===================================================================
--- NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/vectopt_loop_substitute.h90	(revision 9871)
+++ NEMO/branches/2018/dev_r9866_HPC_03_globcom/src/OCE/vectopt_loop_substitute.h90	(revision 10288)
@@ -8,5 +8,5 @@
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 #if defined key_vectopt_loop
