Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/LIM_SRC_2/ice_2.F90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/LIM_SRC_2/ice_2.F90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/LIM_SRC_2/ice_2.F90	(revision 5213)
@@ -57,4 +57,7 @@
    REAL(wp), PUBLIC ::   sangvg, cangvg        !: sin and cos of the turning angle for ocean stress
    REAL(wp), PUBLIC ::   pstarh                !: pstar / 2.0
+
+   !                                !!** switch for presence of ice or not 
+   REAL(wp), PUBLIC ::   rswitch
 
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ahiu , ahiv   !: hor. diffusivity coeff. at ocean U- and V-points (m2/s)
Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OFF_SRC/nemogcm.F90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OFF_SRC/nemogcm.F90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OFF_SRC/nemogcm.F90	(revision 5213)
@@ -46,5 +46,5 @@
    USE timing          ! Timing
    USE lib_fortran     ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
-   USE lbcnfd, ONLY: isendto, nsndto
+   USE lbcnfd, ONLY: isendto, nsndto, nfsloop, nfeloop ! Setup of north fold exchanges
 
    USE trc
@@ -594,5 +594,6 @@
       !!----------------------------------------------------------------------
       !!    1.0  ! 2011-10  (A. C. Coward, NOCS & J. Donners, PRACE)
-      !!    2.0  ! 2013-06 Setup avoiding MPI communication (I. Epicoco, S. Mocavero, CMCC) 
+      !!    2.0  ! 2013-06 Setup avoiding MPI communication (I. Epicoco, S.
+      !Mocavero, CMCC) 
       !!----------------------------------------------------------------------
 
@@ -617,27 +618,38 @@
           !loop over the other north-fold processes to find the processes
           !managing the points belonging to the sxT-dxT range
-          DO jn = jpnij - jpni +1, jpnij
-             IF ( njmppt(jn) == njmppmax ) THEN
+
+          DO jn = 1, jpni
                 !sxT is the first point (in the global domain) of the jn
                 !process
-                sxT = nimppt(jn)
+                sxT = nfiimpp(jn, jpnj)
                 !dxT is the last point (in the global domain) of the jn
                 !process
-                dxT = nimppt(jn) + nlcit(jn) - 1
+                dxT = nfiimpp(jn, jpnj) + nfilcit(jn, jpnj) - 1
                 IF ((sxM .gt. sxT) .AND. (sxM .lt. dxT)) THEN
                    nsndto = nsndto + 1
-                   isendto(nsndto) = jn
-                ELSEIF ((sxM .le. sxT) .AND. (dxM .gt. dxT)) THEN
+                     isendto(nsndto) = jn
+                ELSEIF ((sxM .le. sxT) .AND. (dxM .ge. dxT)) THEN
                    nsndto = nsndto + 1
-                   isendto(nsndto) = jn
+                     isendto(nsndto) = jn
                 ELSEIF ((dxM .lt. dxT) .AND. (sxT .lt. dxM)) THEN
                    nsndto = nsndto + 1
-                   isendto(nsndto) = jn
+                     isendto(nsndto) = jn
                 END IF
-             END IF
           END DO
+          nfsloop = 1
+          nfeloop = nlci
+          DO jn = 2,jpni-1
+           IF(nfipproc(jn,jpnj) .eq. (narea - 1)) THEN
+              IF (nfipproc(jn - 1 ,jpnj) .eq. -1) THEN
+                 nfsloop = nldi
+              ENDIF
+              IF (nfipproc(jn + 1,jpnj) .eq. -1) THEN
+                 nfeloop = nlei
+              ENDIF
+           ENDIF
+        END DO
+
       ENDIF
       l_north_nogather = .TRUE.
-
    END SUBROUTINE nemo_northcomms
 #else
Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/BDY/bdytides.F90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/BDY/bdytides.F90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/BDY/bdytides.F90	(revision 5213)
@@ -125,7 +125,7 @@
             IF(lwp) WRITE(numout,*) '             Number of tidal components to read: ', nb_harmo
             IF(lwp) THEN 
-                    WRITE(numout,*) '             Tidal cpt name    -     Phase speed (deg/hr)'            
+                    WRITE(numout,*) '             Tidal components: ' 
                DO itide = 1, nb_harmo
-                  WRITE(numout,*)  '             ', Wave(ntide(itide))%cname_tide, omega_tide(itide)   
+                  WRITE(numout,*)  '                 ', Wave(ntide(itide))%cname_tide 
                END DO
             ENDIF 
Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/C1D/dyndmp.F90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/C1D/dyndmp.F90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/C1D/dyndmp.F90	(revision 5213)
@@ -3,6 +3,9 @@
    !!                       ***  MODULE  dyndmp  ***
    !! Ocean dynamics: internal restoring trend on momentum (U and V current)
+   !!                 This should only be used for C1D case in current form
    !!======================================================================
    !! History :  3.5  ! 2013-08  (D. Calvert)  Original code
+   !!            3.6  ! 2014-08  (T. Graham) Modified to use netcdf file of
+   !!                             restoration coefficients supplied to tradmp
    !!----------------------------------------------------------------------
 
@@ -25,4 +28,5 @@
    USE wrk_nemo       ! Memory allocation
    USE timing         ! Timing
+   USE iom            ! I/O manager
 
    IMPLICIT NONE
@@ -73,4 +77,5 @@
       NAMELIST/namc1d_dyndmp/ ln_dyndmp
       INTEGER :: ios
+      INTEGER :: imask
       !!----------------------------------------------------------------------
 
@@ -91,10 +96,7 @@
          WRITE(numout,*) '      add a damping term or not       ln_dyndmp = ', ln_dyndmp
          WRITE(numout,*) '   Namelist namtra_dmp    : Set damping parameters'
-         WRITE(numout,*) '      horizontal damping option       nn_hdmp   = ', nn_hdmp
-         WRITE(numout,*) '      mixed layer damping option      nn_zdmp   = ', nn_zdmp, '(non-C1D zoom: forced to 0)'
-         WRITE(numout,*) '      surface time scale (days)       rn_surf   = ', rn_surf
-         WRITE(numout,*) '      bottom time scale (days)        rn_bot    = ', rn_bot
-         WRITE(numout,*) '      depth of transition (meters)    rn_dep    = ', rn_dep
-         WRITE(numout,*) '      create a damping.coeff file     nn_file   = ', nn_file
+         WRITE(numout,*) '      Apply relaxation   or not       ln_tradmp = ', ln_tradmp
+         WRITE(numout,*) '      mixed layer damping option      nn_zdmp   = ', nn_zdmp
+         WRITE(numout,*) '      Damping file name               cn_resto  = ', cn_resto
          WRITE(numout,*)
       ENDIF
@@ -104,14 +106,4 @@
          IF( dyn_dmp_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'dyn_dmp_init: unable to allocate arrays' )
          !
-#if ! defined key_c1d
-         SELECT CASE ( nn_hdmp )             !==   control print of horizontal option   ==!
-         CASE (  -1  )   ;   IF(lwp) WRITE(numout,*) '   momentum damping in the Med & Red seas only'
-         CASE ( 1:90 )   ;   IF(lwp) WRITE(numout,*) '   momentum damping poleward of', nn_hdmp, ' degrees'
-         CASE DEFAULT
-            WRITE(ctmp1,*) '          bad flag value for nn_hdmp = ', nn_hdmp
-            CALL ctl_stop(ctmp1)
-         END SELECT
-         !
-#endif
          SELECT CASE ( nn_zdmp )             !==   control print of vertical option   ==!
          CASE ( 0    )   ;   IF(lwp) WRITE(numout,*) '   momentum damping throughout the water column'
@@ -130,13 +122,9 @@
          utrdmp(:,:,:) = 0._wp               ! internal damping trends
          vtrdmp(:,:,:) = 0._wp
-         !                                   !==   Damping coefficients calculation:                           ==!
-         !                                   !==   use tradmp.F90 subroutines dtacof, dtacof_zoom and cofdis   ==!
-         !                                   !!!   NOTE: these need to be altered for use in this module if 
-         !                                   !!!       they are to be used outside the C1D context 
-         !                                   !!!       (use of U,V grid variables)
-         IF( lzoom .AND. .NOT. lk_c1d ) THEN   ;   CALL dtacof_zoom( resto_uv )
-         ELSE               ;   CALL dtacof( nn_hdmp, rn_surf, rn_bot, rn_dep, nn_file, 'DYN', resto_uv )
-         ENDIF
-         !
+         !
+         !Read in mask from file
+         CALL iom_open ( cn_resto, imask)
+         CALL iom_get  ( imask, jpdom_autoglo, 'resto', resto)
+         CALL iom_close( imask )
       ENDIF
       !
Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DIA/diaar5.F90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DIA/diaar5.F90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DIA/diaar5.F90	(revision 5213)
@@ -82,6 +82,4 @@
       CALL wrk_alloc( jpi , jpj , jpk        , zrhd      , zrhop    )
       CALL wrk_alloc( jpi , jpj , jpk , jpts , ztsn                 )
-
-      CALL iom_put( 'cellthc', fse3t(:,:,:) )
 
       zarea_ssh(:,:) = area(:,:) * sshn(:,:)
Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 5213)
@@ -142,85 +142,60 @@
       ENDIF
 
-      IF( lk_vvl ) THEN
-         z3d(:,:,:) = tsn(:,:,:,jp_tem) * fse3t_n(:,:,:)
-         CALL iom_put( "toce" , z3d                        )   ! heat content
+      IF( .NOT.lk_vvl ) THEN
+         CALL iom_put( "e3t" , fse3t_n(:,:,:) )
+         CALL iom_put( "e3u" , fse3u_n(:,:,:) )
+         CALL iom_put( "e3v" , fse3v_n(:,:,:) )
+         CALL iom_put( "e3w" , fse3w_n(:,:,:) )
+      ENDIF
+      
+      CALL iom_put( "toce", tsn(:,:,:,jp_tem) )    ! 3D temperature
+      CALL iom_put(  "sst", tsn(:,:,1,jp_tem) )    ! surface temperature
+      IF ( iom_use("sbt") ) THEN
          DO jj = 1, jpj
             DO ji = 1, jpi
-               z2d(ji,jj) = tsn(ji,jj,mikt(ji,jj),jp_tem) * fse3t_n(ji,jj,mikt(ji,jj))
-            END DO
-         END DO  
-         CALL iom_put( "sst"  , z2d(:,:)                 )   ! sea surface heat content      
+               z2d(ji,jj) = tsn(ji,jj,MAX(mbathy(ji,jj),1),jp_tem)
+            END DO
+         END DO
+         CALL iom_put( "sbt", z2d )                ! bottom temperature
+      ENDIF
+      
+      CALL iom_put( "soce", tsn(:,:,:,jp_sal) )    ! 3D salinity
+      CALL iom_put(  "sss", tsn(:,:,1,jp_sal) )    ! surface salinity
+      IF ( iom_use("sbs") ) THEN
          DO jj = 1, jpj
             DO ji = 1, jpi
-               z2d(ji,jj) = tsn(ji,jj,mikt(ji,jj),jp_tem)**2 * fse3t_n(ji,jj,mikt(ji,jj))
-            END DO
-         END DO  
-         CALL iom_put( "sst2" , z2d(:,:)      )   ! sea surface content of squared temperature
-         z3d(:,:,:) = tsn(:,:,:,jp_sal) * fse3t_n(:,:,:)            
-         CALL iom_put( "soce" , z3d                        )   ! salinity content
+               z2d(ji,jj) = tsn(ji,jj,MAX(mbathy(ji,jj),1),jp_sal)
+            END DO
+         END DO
+         CALL iom_put( "sbs", z2d )                ! bottom salinity
+      ENDIF
+         
+      CALL iom_put( "uoce", un(:,:,:)         )    ! 3D i-current
+      CALL iom_put(  "ssu", un(:,:,1)         )    ! surface i-current
+      IF ( iom_use("sbu") ) THEN
          DO jj = 1, jpj
             DO ji = 1, jpi
-               z2d(ji,jj) = tsn(ji,jj,mikt(ji,jj),jp_sal) * fse3t_n(ji,jj,mikt(ji,jj))
-            END DO
-         END DO  
-         CALL iom_put( "sss"  , z2d(:,:)                 )   ! sea surface salinity content
+               z2d(ji,jj) = un(ji,jj,MAX(mbathy(ji,jj),1))
+            END DO
+         END DO
+         CALL iom_put( "sbu", z2d )                ! bottom i-current
+      ENDIF
+      
+      CALL iom_put( "voce", vn(:,:,:)         )    ! 3D j-current
+      CALL iom_put(  "ssv", vn(:,:,1)         )    ! surface j-current
+      IF ( iom_use("sbv") ) THEN
          DO jj = 1, jpj
             DO ji = 1, jpi
-               z2d(ji,jj) = tsn(ji,jj,mikt(ji,jj),jp_sal)**2 * fse3t_n(ji,jj,mikt(ji,jj))
-            END DO
-         END DO  
-         CALL iom_put( "sss2" , z2d(:,:)                 )   ! sea surface content of squared salinity
-      ELSE
-         CALL iom_put( "toce" , tsn(:,:,:,jp_tem)        )   ! temperature
-         IF ( iom_use("sst") ) THEN
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  z2d(ji,jj) = tsn(ji,jj,mikt(ji,jj),jp_tem)
-               END DO
-            END DO
-            CALL iom_put( "sst"  , z2d(:,:)            ) ! sea surface temperature
-         ENDIF
-         IF ( iom_use("sst2") )   CALL iom_put( "sst2" , z2d(:,:) * z2d(:,:) ) ! square of sea surface temperature
-         CALL iom_put( "soce" , tsn(:,:,:,jp_sal)          )   ! salinity
-         IF ( iom_use("sss") ) THEN
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  z2d(ji,jj) = tsn(ji,jj,mikt(ji,jj),jp_sal)
-               END DO
-            END DO
-            CALL iom_put( "sss"  , z2d(:,:)            ) ! sea surface salinity
-         ENDIF
-         CALL iom_put( "sss2" , z2d(:,:) * z2d(:,:) ) ! square of sea surface salinity
-      END IF
-      IF( lk_vvl .AND. (.NOT. ln_dynadv_vec) ) THEN
-         CALL iom_put( "uoce" , umask(:,:,:) * un(:,:,:) * fse3u_n(:,:,:) )    ! i-transport
-         CALL iom_put( "voce" , vmask(:,:,:) * vn(:,:,:) * fse3v_n(:,:,:) )    ! j-transport
-      ELSE
-         CALL iom_put( "uoce" , umask(:,:,:) * un(:,:,:)                  )    ! i-current
-         CALL iom_put( "voce" , vmask(:,:,:) * vn(:,:,:)                  )    ! j-current
-         IF ( iom_use("ssu") ) THEN
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  z2d(ji,jj) = un(ji,jj,miku(ji,jj))
-               END DO
-            END DO
-            CALL iom_put( "ssu"   , z2d                                    )    ! i-current
-         ENDIF
-         IF ( iom_use("ssv") ) THEN
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  z2d(ji,jj) = vn(ji,jj,mikv(ji,jj))
-               END DO
-            END DO
-            CALL iom_put( "ssv"   , z2d                                    )    ! j-current
-         ENDIF
-      ENDIF
-      CALL iom_put(    "avt"  , avt                        )    ! T vert. eddy diff. coef.
-      CALL iom_put(    "avm"  , avmu                       )    ! T vert. eddy visc. coef.
-      IF( lk_zdfddm ) THEN
-         CALL iom_put( "avs" , fsavs(:,:,:)                          )    ! S vert. eddy diff. coef.
-      ENDIF
-
-      IF ( iom_use("sstgrad2") .OR. iom_use("sstgrad2") ) THEN
+               z2d(ji,jj) = vn(ji,jj,MAX(mbathy(ji,jj),1))
+            END DO
+         END DO
+         CALL iom_put( "sbv", z2d )                ! bottom j-current
+      ENDIF
+
+      CALL iom_put( "avt" , avt                        )    ! T vert. eddy diff. coef.
+      CALL iom_put( "avm" , avmu                       )    ! T vert. eddy visc. coef.
+      CALL iom_put( "avs" , fsavs(:,:,:)               )    ! S vert. eddy diff. coef. (useful only with key_zdfddm)
+
+      IF ( iom_use("sstgrad") .OR. iom_use("sstgrad2") ) THEN
          DO jj = 2, jpjm1                                    ! sst gradient
             DO ji = fs_2, fs_jpim1   ! vector opt.
@@ -234,5 +209,4 @@
          CALL lbc_lnk( z2d, 'T', 1. )
          CALL iom_put( "sstgrad2",  z2d               )    ! square of module of sst gradient
-         !CDIR NOVERRCHK<
          z2d(:,:) = SQRT( z2d(:,:) )
          CALL iom_put( "sstgrad" ,  z2d               )    ! module of sst gradient
@@ -243,11 +217,10 @@
          z2d(:,:)  = 0._wp 
          DO jk = 1, jpkm1
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
+            DO jj = 1, jpj
+               DO ji = 1, jpi
                   z2d(ji,jj) = z2d(ji,jj) + fse3t(ji,jj,jk) * tsn(ji,jj,jk,jp_tem) * tmask(ji,jj,jk)
                END DO
             END DO
          END DO
-         CALL lbc_lnk( z2d, 'T', 1. )
          CALL iom_put( "heatc", (rau0 * rcp) * z2d )    ! vertically integrated heat content (J/m2)
       ENDIF
@@ -256,11 +229,10 @@
          z2d(:,:)  = 0._wp 
          DO jk = 1, jpkm1
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
+            DO jj = 1, jpj
+               DO ji = 1, jpi
                   z2d(ji,jj) = z2d(ji,jj) + fse3t(ji,jj,jk) * tsn(ji,jj,jk,jp_sal) * tmask(ji,jj,jk)
                END DO
             END DO
          END DO
-         CALL lbc_lnk( z2d, 'T', 1. )
          CALL iom_put( "saltc", rau0 * z2d )   ! vertically integrated salt content (PSU*kg/m2)
       ENDIF
Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 5213)
@@ -588,11 +588,8 @@
       INTEGER, INTENT( in )               :: kt       ! time step
       !! * Local declarations
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: z_e3t_def
       INTEGER                             :: ji,jj,jk       ! dummy loop indices
       !!----------------------------------------------------------------------
 
       IF( nn_timing == 1 )  CALL timing_start('dom_vvl_sf_swp')
-      !
-      CALL wrk_alloc( jpi, jpj, jpk, z_e3t_def                )
       !
       IF( kt == nit000 )   THEN
@@ -679,14 +676,15 @@
       ! Write outputs
       ! =============
-      z_e3t_def(:,:,:) = ( ( fse3t_n(:,:,:) - e3t_0(:,:,:) ) / e3t_0(:,:,:) * 100 * tmask(:,:,:) ) ** 2
-      CALL iom_put( "cellthc" , fse3t_n  (:,:,:) )
+      CALL iom_put(     "e3t" , fse3t_n  (:,:,:) )
+      CALL iom_put(     "e3u" , fse3u_n  (:,:,:) )
+      CALL iom_put(     "e3v" , fse3v_n  (:,:,:) )
+      CALL iom_put(     "e3w" , fse3w_n  (:,:,:) )
       CALL iom_put( "tpt_dep" , fsde3w_n (:,:,:) )
-      CALL iom_put( "e3tdef"  , z_e3t_def(:,:,:) )
+      IF( iom_use("e3tdef") )   &
+         CALL iom_put( "e3tdef"  , ( ( fse3t_n(:,:,:) - e3t_0(:,:,:) ) / e3t_0(:,:,:) * 100 * tmask(:,:,:) ) ** 2 )
 
       ! write restart file
       ! ==================
       IF( lrst_oce ) CALL dom_vvl_rst( kt, 'WRITE' )
-      !
-      CALL wrk_dealloc( jpi, jpj, jpk, z_e3t_def )
       !
       IF( nn_timing == 1 )  CALL timing_stop('dom_vvl_sf_swp')
Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 5213)
@@ -365,16 +365,14 @@
       INTEGER  ::   ji, jj, jl, jk            ! dummy loop indices
       INTEGER  ::   inum                      ! temporary logical unit
+      INTEGER  ::   ierror                    ! error flag
       INTEGER  ::   ii_bump, ij_bump, ih      ! bump center position
       INTEGER  ::   ii0, ii1, ij0, ij1, ik    ! local indices
       REAL(wp) ::   r_bump , h_bump , h_oce   ! bump characteristics 
       REAL(wp) ::   zi, zj, zh, zhmin         ! local scalars
-      INTEGER , POINTER, DIMENSION(:,:) ::   idta   ! global domain integer data
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zdta   ! global domain scalar data
+      INTEGER , ALLOCATABLE, DIMENSION(:,:) ::   idta   ! global domain integer data
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zdta   ! global domain scalar data
       !!----------------------------------------------------------------------
       !
       IF( nn_timing == 1 )  CALL timing_start('zgr_bat')
-      !
-      CALL wrk_alloc( jpidta, jpjdta, idta )
-      CALL wrk_alloc( jpidta, jpjdta, zdta )
       !
       IF(lwp) WRITE(numout,*)
@@ -385,4 +383,9 @@
          !                                            ! ================== !
          !                                            ! global domain level and meter bathymetry (idta,zdta)
+         !
+         ALLOCATE( idta(jpidta,jpjdta), STAT=ierror )
+         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'zgr_bat: unable to allocate idta array' )
+         ALLOCATE( zdta(jpidta,jpjdta), STAT=ierror )
+         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'zgr_bat: unable to allocate zdta array' )
          !
          IF( ntopo == 0 ) THEN                        ! flat basin
@@ -489,4 +492,6 @@
             WHERE( bathy(:,:) <= 0._wp )  risfdep(:,:) = 0._wp
          END IF
+         !
+         DEALLOCATE( idta, zdta )
          !
          !                                            ! ================ !
@@ -593,7 +598,4 @@
       ENDIF
       !
-      CALL wrk_dealloc( jpidta, jpjdta, idta )
-      CALL wrk_dealloc( jpidta, jpjdta, zdta )
-      !
       IF( nn_timing == 1 )  CALL timing_stop('zgr_bat')
       !
Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DOM/phycst.F90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DOM/phycst.F90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DOM/phycst.F90	(revision 5213)
@@ -89,5 +89,4 @@
    !!----------------------------------------------------------------------
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv_ubs.F90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv_ubs.F90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv_ubs.F90	(revision 5213)
@@ -116,28 +116,25 @@
          DO jj = 2, jpjm1                          ! laplacian
             DO ji = fs_2, fs_jpim1   ! vector opt.
-               zlu_uu(ji,jj,jk,1) = ( ub (ji+1,jj,jk)-2.*ub (ji,jj,jk)+ub (ji-1,jj,jk) ) * umask(ji,jj,jk)
-               zlv_vv(ji,jj,jk,1) = ( vb (ji,jj+1,jk)-2.*vb (ji,jj,jk)+vb (ji,jj-1,jk) ) * vmask(ji,jj,jk) 
-               zlu_uv(ji,jj,jk,1) = ( ub (ji,jj+1,jk)-2.*ub (ji,jj,jk)+ub (ji,jj-1,jk) ) * umask(ji,jj,jk)
-               zlv_vu(ji,jj,jk,1) = ( vb (ji+1,jj,jk)-2.*vb (ji,jj,jk)+vb (ji-1,jj,jk) ) * vmask(ji,jj,jk)
-               !
-               zlu_uu(ji,jj,jk,2) = ( zfu(ji+1,jj,jk)-2.*zfu(ji,jj,jk)+zfu(ji-1,jj,jk) ) * umask(ji,jj,jk)
-               zlv_vv(ji,jj,jk,2) = ( zfv(ji,jj+1,jk)-2.*zfv(ji,jj,jk)+zfv(ji,jj-1,jk) ) * vmask(ji,jj,jk)
-               zlu_uv(ji,jj,jk,2) = ( zfu(ji,jj+1,jk)-2.*zfu(ji,jj,jk)+zfu(ji,jj-1,jk) ) * umask(ji,jj,jk)
-               zlv_vu(ji,jj,jk,2) = ( zfv(ji+1,jj,jk)-2.*zfv(ji,jj,jk)+zfv(ji-1,jj,jk) ) * vmask(ji,jj,jk)
-            END DO
-         END DO
-      END DO
-!!gm BUG !!!  just below this should be +1 in all the communications
-!      CALL lbc_lnk( zlu_uu(:,:,:,1), 'U', -1.)   ;   CALL lbc_lnk( zlu_uv(:,:,:,1), 'U', -1.)
-!      CALL lbc_lnk( zlu_uu(:,:,:,2), 'U', -1.)   ;   CALL lbc_lnk( zlu_uv(:,:,:,2), 'U', -1.)
-!      CALL lbc_lnk( zlv_vv(:,:,:,1), 'V', -1.)   ;   CALL lbc_lnk( zlv_vu(:,:,:,1), 'V', -1.)
-!      CALL lbc_lnk( zlv_vv(:,:,:,2), 'V', -1.)   ;   CALL lbc_lnk( zlv_vu(:,:,:,2), 'V', -1.)
-!
-!!gm corrected:
+               !
+               zlu_uu(ji,jj,jk,1) = ( ub (ji+1,jj  ,jk) - 2.*ub (ji,jj,jk) + ub (ji-1,jj  ,jk) ) * umask(ji,jj,jk)
+               zlv_vv(ji,jj,jk,1) = ( vb (ji  ,jj+1,jk) - 2.*vb (ji,jj,jk) + vb (ji  ,jj-1,jk) ) * vmask(ji,jj,jk)
+               zlu_uv(ji,jj,jk,1) = ( ub (ji  ,jj+1,jk) - ub (ji  ,jj  ,jk) ) * fmask(ji  ,jj  ,jk)   &
+                  &               - ( ub (ji  ,jj  ,jk) - ub (ji  ,jj-1,jk) ) * fmask(ji  ,jj-1,jk)
+               zlv_vu(ji,jj,jk,1) = ( vb (ji+1,jj  ,jk) - vb (ji  ,jj  ,jk) ) * fmask(ji  ,jj  ,jk)   &
+                  &               - ( vb (ji  ,jj  ,jk) - vb (ji-1,jj  ,jk) ) * fmask(ji-1,jj  ,jk)
+               !
+               zlu_uu(ji,jj,jk,2) = ( zfu(ji+1,jj  ,jk) - 2.*zfu(ji,jj,jk) + zfu(ji-1,jj  ,jk) ) * umask(ji,jj,jk)
+               zlv_vv(ji,jj,jk,2) = ( zfv(ji  ,jj+1,jk) - 2.*zfv(ji,jj,jk) + zfv(ji  ,jj-1,jk) ) * vmask(ji,jj,jk)
+               zlu_uv(ji,jj,jk,2) = ( zfu(ji  ,jj+1,jk) - zfu(ji  ,jj  ,jk) ) * fmask(ji  ,jj  ,jk)   &
+                  &               - ( zfu(ji  ,jj  ,jk) - zfu(ji  ,jj-1,jk) ) * fmask(ji  ,jj-1,jk)
+               zlv_vu(ji,jj,jk,2) = ( zfv(ji+1,jj  ,jk) - zfv(ji  ,jj  ,jk) ) * fmask(ji  ,jj  ,jk)   &
+                  &               - ( zfv(ji  ,jj  ,jk) - zfv(ji-1,jj  ,jk) ) * fmask(ji-1,jj  ,jk)
+            END DO
+         END DO
+      END DO
       CALL lbc_lnk( zlu_uu(:,:,:,1), 'U', 1. )   ;   CALL lbc_lnk( zlu_uv(:,:,:,1), 'U', 1. )
       CALL lbc_lnk( zlu_uu(:,:,:,2), 'U', 1. )   ;   CALL lbc_lnk( zlu_uv(:,:,:,2), 'U', 1. )
       CALL lbc_lnk( zlv_vv(:,:,:,1), 'V', 1. )   ;   CALL lbc_lnk( zlv_vu(:,:,:,1), 'V', 1. )
       CALL lbc_lnk( zlv_vv(:,:,:,2), 'V', 1. )   ;   CALL lbc_lnk( zlv_vu(:,:,:,2), 'V', 1. ) 
-!!gm end
       
       !                                      ! ====================== !
Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90	(revision 5213)
@@ -97,6 +97,6 @@
       ALLOCATE( wgtbtp1(3*nn_baro), wgtbtp2(3*nn_baro), zwz(jpi,jpj), STAT= ierr(2) )
 
-      IF( ln_dynvor_een ) ALLOCATE( ftnw(jpi,jpj) , ftne(jpi,jpj) , & 
-                             &      ftsw(jpi,jpj) , ftse(jpi,jpj) , STAT=ierr(3) )
+      IF( ln_dynvor_een .or. ln_dynvor_een_old ) ALLOCATE( ftnw(jpi,jpj) , ftne(jpi,jpj) , & 
+                                                    &      ftsw(jpi,jpj) , ftse(jpi,jpj) , STAT=ierr(3) )
 
       dyn_spg_ts_alloc = MAXVAL(ierr(:))
@@ -218,5 +218,25 @@
       !
       IF ( kt == nit000 .OR. lk_vvl ) THEN
-         IF ( ln_dynvor_een ) THEN
+         IF ( ln_dynvor_een_old ) THEN
+            DO jj = 1, jpjm1
+               DO ji = 1, jpim1
+                  zwz(ji,jj) =   ( ht(ji  ,jj+1) + ht(ji+1,jj+1) +                    &
+                        &          ht(ji  ,jj  ) + ht(ji+1,jj  )   ) / 4._wp  
+                  IF( zwz(ji,jj) /= 0._wp )   zwz(ji,jj) = 1._wp / zwz(ji,jj)
+               END DO
+            END DO
+            CALL lbc_lnk( zwz, 'F', 1._wp )
+            zwz(:,:) = ff(:,:) * zwz(:,:)
+
+            ftne(1,:) = 0._wp ; ftnw(1,:) = 0._wp ; ftse(1,:) = 0._wp ; ftsw(1,:) = 0._wp
+            DO jj = 2, jpj
+               DO ji = fs_2, jpi   ! vector opt.
+                  ftne(ji,jj) = zwz(ji-1,jj  ) + zwz(ji  ,jj  ) + zwz(ji  ,jj-1)
+                  ftnw(ji,jj) = zwz(ji-1,jj-1) + zwz(ji-1,jj  ) + zwz(ji  ,jj  )
+                  ftse(ji,jj) = zwz(ji  ,jj  ) + zwz(ji  ,jj-1) + zwz(ji-1,jj-1)
+                  ftsw(ji,jj) = zwz(ji  ,jj-1) + zwz(ji-1,jj-1) + zwz(ji-1,jj  )
+               END DO
+            END DO
+         ELSE IF ( ln_dynvor_een ) THEN
             DO jj = 1, jpjm1
                DO ji = 1, jpim1
@@ -339,5 +359,5 @@
          END DO
          !
-      ELSEIF ( ln_dynvor_een ) THEN                    ! enstrophy and energy conserving scheme
+      ELSEIF ( ln_dynvor_een .or. ln_dynvor_een_old ) THEN  ! enstrophy and energy conserving scheme
          DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1   ! vector opt.
@@ -687,5 +707,5 @@
             END DO
             !
-         ELSEIF ( ln_dynvor_een ) THEN                    !==  energy and enstrophy conserving scheme  ==!
+         ELSEIF ( ln_dynvor_een .or. ln_dynvor_een_old ) THEN !==  energy and enstrophy conserving scheme  ==!
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90	(revision 5213)
@@ -51,4 +51,5 @@
    LOGICAL, PUBLIC ::   ln_dynvor_mix   !: mixed scheme
    LOGICAL, PUBLIC ::   ln_dynvor_een   !: energy and enstrophy conserving scheme
+   LOGICAL, PUBLIC ::   ln_dynvor_een_old !: energy and enstrophy conserving scheme (original formulation)
 
    INTEGER ::   nvor = 0   ! type of vorticity trend used
@@ -596,15 +597,29 @@
 
       IF( kt == nit000 .OR. lk_vvl ) THEN      ! reciprocal of e3 at F-point (masked averaging of e3t over ocean points)
-         DO jk = 1, jpk
-            DO jj = 1, jpjm1
-               DO ji = 1, jpim1
-                  ze3  = ( fse3t(ji,jj+1,jk)*tmask(ji,jj+1,jk) + fse3t(ji+1,jj+1,jk)*tmask(ji+1,jj+1,jk)   &
-                     &   + fse3t(ji,jj  ,jk)*tmask(ji,jj  ,jk) + fse3t(ji+1,jj  ,jk)*tmask(ji+1,jj  ,jk) )
-                  zmsk = (                   tmask(ji,jj+1,jk) +                     tmask(ji+1,jj+1,jk)   &
-                     &                     + tmask(ji,jj  ,jk) +                     tmask(ji+1,jj  ,jk) )
-                  IF( ze3 /= 0._wp )   ze3f(ji,jj,jk) = zmsk / ze3
-               END DO
-            END DO
-         END DO
+
+         IF( ln_dynvor_een_old ) THEN ! original formulation
+            DO jk = 1, jpk
+               DO jj = 1, jpjm1
+                  DO ji = 1, jpim1
+                     ze3  = ( fse3t(ji,jj+1,jk)*tmask(ji,jj+1,jk) + fse3t(ji+1,jj+1,jk)*tmask(ji+1,jj+1,jk)   &
+                        &   + fse3t(ji,jj  ,jk)*tmask(ji,jj  ,jk) + fse3t(ji+1,jj  ,jk)*tmask(ji+1,jj  ,jk) )
+                     IF( ze3 /= 0._wp )   ze3f(ji,jj,jk) = 4.0_wp / ze3
+                  END DO
+               END DO
+            END DO
+         ELSE ! new formulation from NEMO 3.6
+            DO jk = 1, jpk
+               DO jj = 1, jpjm1
+                  DO ji = 1, jpim1
+                     ze3  = ( fse3t(ji,jj+1,jk)*tmask(ji,jj+1,jk) + fse3t(ji+1,jj+1,jk)*tmask(ji+1,jj+1,jk)   &
+                        &   + fse3t(ji,jj  ,jk)*tmask(ji,jj  ,jk) + fse3t(ji+1,jj  ,jk)*tmask(ji+1,jj  ,jk) )
+                     zmsk = (                   tmask(ji,jj+1,jk) +                     tmask(ji+1,jj+1,jk)   &
+                        &                     + tmask(ji,jj  ,jk) +                     tmask(ji+1,jj  ,jk) )
+                     IF( ze3 /= 0._wp )   ze3f(ji,jj,jk) = zmsk / ze3
+                  END DO
+               END DO
+            END DO
+         ENDIF
+
          CALL lbc_lnk( ze3f, 'F', 1. )
       ENDIF
@@ -705,5 +720,5 @@
       INTEGER ::   ios             ! Local integer output status for namelist read
       !!
-      NAMELIST/namdyn_vor/ ln_dynvor_ens, ln_dynvor_ene, ln_dynvor_mix, ln_dynvor_een
+      NAMELIST/namdyn_vor/ ln_dynvor_ens, ln_dynvor_ene, ln_dynvor_mix, ln_dynvor_een, ln_dynvor_een_old
       !!----------------------------------------------------------------------
 
@@ -726,4 +741,5 @@
          WRITE(numout,*) '           mixed enstrophy/energy conserving scheme   ln_dynvor_mix = ', ln_dynvor_mix
          WRITE(numout,*) '           enstrophy and energy conserving scheme     ln_dynvor_een = ', ln_dynvor_een
+         WRITE(numout,*) '           enstrophy and energy conserving scheme (old) ln_dynvor_een_old= ', ln_dynvor_een_old
       ENDIF
 
@@ -749,4 +765,5 @@
       IF( ln_dynvor_mix )   ioptio = ioptio + 1
       IF( ln_dynvor_een )   ioptio = ioptio + 1
+      IF( ln_dynvor_een_old )   ioptio = ioptio + 1
       IF( lk_esopa      )   ioptio =          1
 
@@ -757,5 +774,5 @@
       IF( ln_dynvor_ens )   nvor =  1
       IF( ln_dynvor_mix )   nvor =  2
-      IF( ln_dynvor_een )   nvor =  3
+      IF( ln_dynvor_een .or. ln_dynvor_een_old )   nvor =  3
       IF( lk_esopa      )   nvor = -1
       
Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 5213)
@@ -1202,5 +1202,5 @@
          CASE('T')   ;   zmask(:,:,:)       = tmask(:,:,:)
          CASE('U')   ;   zmask(2:jpim1,:,:) = tmask(2:jpim1,:,:) + tmask(3:jpi,:,:)   ;   CALL lbc_lnk( zmask, 'U', 1. )
-         CASE('V')   ;   zmask(:,2:jpjm1,:) = tmask(:,2:jpjm1,:) + tmask(:,3:jpi,:)   ;   CALL lbc_lnk( zmask, 'V', 1. )
+         CASE('V')   ;   zmask(:,2:jpjm1,:) = tmask(:,2:jpjm1,:) + tmask(:,3:jpj,:)   ;   CALL lbc_lnk( zmask, 'V', 1. )
          CASE('W')   ;   zmask(:,:,2:jpk  ) = tmask(:,:,1:jpkm1) + tmask(:,:,2:jpk)   ;   zmask(:,:,1) = tmask(:,:,1)
          END SELECT
Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/IOM/prtctl.F90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/IOM/prtctl.F90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/IOM/prtctl.F90	(revision 5213)
@@ -164,10 +164,12 @@
          ENDIF
 
-         IF ( clinfo3 == 'tra' )  THEN
-             zvctl1 = t_ctll(jn)
-             zvctl2 = s_ctll(jn)
-         ELSEIF ( clinfo3 == 'dyn' )   THEN
-             zvctl1 = u_ctll(jn)
-             zvctl2 = v_ctll(jn)
+         IF( PRESENT(clinfo3)) THEN
+            IF ( clinfo3 == 'tra' )  THEN
+               zvctl1 = t_ctll(jn)
+               zvctl2 = s_ctll(jn)
+            ELSEIF ( clinfo3 == 'dyn' )   THEN
+               zvctl1 = u_ctll(jn)
+               zvctl2 = v_ctll(jn)
+            ENDIF
          ENDIF
 
Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_c2d.h90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_c2d.h90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_c2d.h90	(revision 5213)
@@ -146,13 +146,12 @@
       INTEGER  ::   inum, iim, ijm            ! local integers
       INTEGER  ::   ifreq, il1, il2, ij, ii
-      INTEGER  ::   ijpt0,ijpt1
+      INTEGER  ::   ijpt0,ijpt1, ierror
       REAL(wp) ::   zahmeq, zcoft, zcoff, zmsk
       CHARACTER (len=15) ::   clexp
-      INTEGER, POINTER, DIMENSION(:,:)  :: icof
-      INTEGER, POINTER, DIMENSION(:,:)  :: idata
+      INTEGER,     POINTER, DIMENSION(:,:)  :: icof
+      INTEGER, ALLOCATABLE, DIMENSION(:,:)  :: idata
       !!----------------------------------------------------------------------
       !                                
       CALL wrk_alloc( jpi   , jpj   , icof  )
-      CALL wrk_alloc( jpidta, jpjdta, idata )
       !
       IF(lwp) WRITE(numout,*)
@@ -234,4 +233,7 @@
          ! ===================== equatorial strip (20N-20S) defined at t-points
          
+         ALLOCATE( idata(jpidta,jpjdta), STAT=ierror )
+         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'ldf_dyn_c2d_orca: unable to allocate idata array' )
+         !
          CALL ctl_opn( inum, 'ahmcoef', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp )
          READ(inum,9101) clexp, iim, ijm
@@ -269,5 +271,6 @@
 9201     FORMAT(3x,13(i3,12x))
 9202     FORMAT(i3,41i3)
-
+         
+         DEALLOCATE(idata)
 
          ! Set ahm1 and ahm2  ( T- and F- points) (used for laplacian operator)
@@ -346,5 +349,4 @@
       !
       CALL wrk_dealloc( jpi   , jpj   , icof  )
-      CALL wrk_dealloc( jpidta, jpjdta, idata )
       !
    END SUBROUTINE ldf_dyn_c2d_orca
@@ -374,13 +376,12 @@
       INTEGER ::   iim, ijm
       INTEGER ::   ifreq, il1, il2, ij, ii
-      INTEGER ::   ijpt0,ijpt1
+      INTEGER ::   ijpt0,ijpt1, ierror
       REAL(wp) ::   zahmeq, zcoft, zcoff, zmsk, zam20s
       CHARACTER (len=15) ::   clexp
-      INTEGER, POINTER, DIMENSION(:,:)  :: icof
-      INTEGER, POINTER, DIMENSION(:,:)  :: idata
+      INTEGER,     POINTER, DIMENSION(:,:)  :: icof
+      INTEGER, ALLOCATABLE, DIMENSION(:,:)  :: idata
       !!----------------------------------------------------------------------
       !                                
       CALL wrk_alloc( jpi   , jpj   , icof  )
-      CALL wrk_alloc( jpidta, jpjdta, idata )
       !                                
 
@@ -464,4 +465,7 @@
          ! ===================== equatorial strip (20N-20S) defined at t-points
          
+         ALLOCATE( idata(jpidta,jpjdta), STAT=ierror )
+         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'ldf_dyn_c2d_orca_R1: unable to allocate idata array' )
+         !
          CALL ctl_opn( inum, 'ahmcoef', 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL',   &
             &           1, numout, lwp )
@@ -501,5 +505,6 @@
 9201     FORMAT(3x,13(i3,12x))
 9202     FORMAT(i3,41i3)
-
+         
+         DEALLOCATE(idata)
 
          ! Set ahm1 and ahm2  ( T- and F- points) (used for laplacian operator)
@@ -583,5 +588,4 @@
       !
       CALL wrk_dealloc( jpi   , jpj   , icof  )
-      CALL wrk_dealloc( jpidta, jpjdta, idata )
       !
    END SUBROUTINE ldf_dyn_c2d_orca_R1
Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90	(revision 5213)
@@ -90,5 +90,4 @@
    !!----------------------------------------------------------------------
    !! NEMO/OPA 3.7 , NEMO-consortium (2014)
-   !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
@@ -848,5 +847,5 @@
       rgt33 = 0.5_wp + SIGN( 0.5_wp, (zw10 - 33._wp) )   ! If zw10 < 33. => 0, else => 1  
       cd_neutral_10m = 1.e-3 * ( &
-         &       (rgt33 + 1._wp)*( 2.7_wp/zw10 + 0.142_wp + zw10/13.09_wp - 3.14807E-10*zw10**6) & ! zw10< 33.
+         &       (1._wp - rgt33)*( 2.7_wp/zw10 + 0.142_wp + zw10/13.09_wp - 3.14807E-10*zw10**6) & ! zw10< 33.
          &      + rgt33         *      2.34   )                                                    ! zw10 >= 33.
       !
Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/TRA/tradmp.F90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/TRA/tradmp.F90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/OPA_SRC/TRA/tradmp.F90	(revision 5213)
@@ -21,7 +21,4 @@
    !!   tra_dmp       : update the tracer trend with the internal damping
    !!   tra_dmp_init  : initialization, namlist read, parameters control
-   !!   dtacof_zoom   : restoring coefficient for zoom domain
-   !!   dtacof        : restoring coefficient for global domain
-   !!   cofdis        : compute the distance to the coastline
    !!----------------------------------------------------------------------
    USE oce            ! ocean: variables
@@ -39,4 +36,5 @@
    USE wrk_nemo       ! Memory allocation
    USE timing         ! Timing
+   USE iom
 
    IMPLICIT NONE
@@ -45,17 +43,12 @@
    PUBLIC   tra_dmp      ! routine called by step.F90
    PUBLIC   tra_dmp_init ! routine called by opa.F90
-   PUBLIC   dtacof       ! routine called by tradmp.F90, trcdmp.F90 and dyndmp.F90
-   PUBLIC   dtacof_zoom  ! routine called by tradmp.F90, trcdmp.F90 and dyndmp.F90
-
-!!gm  why all namelist variable public????   only ln_tradmp should be sufficient
 
    !                               !!* Namelist namtra_dmp : T & S newtonian damping *
+   ! nn_zdmp and cn_resto are public as they are used by C1D/dyndmp.F90
    LOGICAL , PUBLIC ::   ln_tradmp   !: internal damping flag
-   INTEGER , PUBLIC ::   nn_hdmp     ! = 0/-1/'latitude' for damping over T and S
    INTEGER , PUBLIC ::   nn_zdmp     ! = 0/1/2 flag for damping in the mixed layer
-   REAL(wp), PUBLIC ::   rn_surf     ! surface time scale for internal damping        [days]
-   REAL(wp), PUBLIC ::   rn_bot      ! bottom time scale for internal damping         [days]
-   REAL(wp), PUBLIC ::   rn_dep      ! depth of transition between rn_surf and rn_bot [meters]
-   INTEGER , PUBLIC ::   nn_file     ! = 1 create a damping.coeff NetCDF file 
+   CHARACTER(LEN=200) , PUBLIC :: cn_resto      ! name of netcdf file containing restoration coefficient field
+   !
+
 
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   strdmp   !: damping salinity trend (psu/s)
@@ -197,623 +190,60 @@
       !! ** Method  :   read the namtra_dmp namelist and check the parameters
       !!----------------------------------------------------------------------
-      INTEGER  ::   ios   ! Local integer output status for namelist read
-      !!
-      NAMELIST/namtra_dmp/ ln_tradmp, nn_hdmp, nn_zdmp, rn_surf, rn_bot, rn_dep, nn_file
-      !!----------------------------------------------------------------------
-      !
-      REWIND( numnam_ref )              ! Namelist namtra_dmp in reference namelist : Temperature and salinity damping term
+      NAMELIST/namtra_dmp/ ln_tradmp, nn_zdmp, cn_resto
+      INTEGER ::  ios         ! Local integer for output status of namelist read
+      INTEGER :: imask        ! File handle 
+      !!
+      !!----------------------------------------------------------------------
+      !
+      REWIND( numnam_ref )   ! Namelist namtra_dmp in reference namelist : T & S relaxation
       READ  ( numnam_ref, namtra_dmp, IOSTAT = ios, ERR = 901)
 901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtra_dmp in reference namelist', lwp )
       !
-      REWIND( numnam_cfg )              ! Namelist namtra_dmp in configuration namelist : Temperature and salinity damping term
+      REWIND( numnam_cfg )   ! Namelist namtra_dmp in configuration namelist : T & S relaxation
       READ  ( numnam_cfg, namtra_dmp, IOSTAT = ios, ERR = 902 )
 902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtra_dmp in configuration namelist', lwp )
       IF(lwm) WRITE ( numond, namtra_dmp )
-      
-      IF( lzoom .AND. .NOT. lk_c1d )   nn_zdmp = 0          ! restoring to climatology at closed north or south boundaries
-
-      IF(lwp) THEN                       ! Namelist print
+
+      IF(lwp) THEN                 !Namelist print
          WRITE(numout,*)
-         WRITE(numout,*) 'tra_dmp_init : T and S newtonian damping'
+         WRITE(numout,*) 'tra_dmp_init : T and S newtonian relaxation'
          WRITE(numout,*) '~~~~~~~'
-         WRITE(numout,*) '   Namelist namtra_dmp : set damping parameter'
-         WRITE(numout,*) '      add a damping term or not       ln_tradmp = ', ln_tradmp
-         WRITE(numout,*) '      T and S damping option          nn_hdmp   = ', nn_hdmp
-         WRITE(numout,*) '      mixed layer damping option      nn_zdmp   = ', nn_zdmp, '(non-C1D zoom: forced to 0)'
-         WRITE(numout,*) '      surface time scale (days)       rn_surf   = ', rn_surf
-         WRITE(numout,*) '      bottom time scale (days)        rn_bot    = ', rn_bot
-         WRITE(numout,*) '      depth of transition (meters)    rn_dep    = ', rn_dep
-         WRITE(numout,*) '      create a damping.coeff file     nn_file   = ', nn_file
+         WRITE(numout,*) '   Namelist namtra_dmp : set relaxation parameters'
+         WRITE(numout,*) '      Apply relaxation   or not       ln_tradmp = ', ln_tradmp
+         WRITE(numout,*) '      mixed layer damping option      nn_zdmp   = ', nn_zdmp
+         WRITE(numout,*) '      Damping file name               cn_resto  = ', cn_resto
          WRITE(numout,*)
       ENDIF
 
-      IF( ln_tradmp ) THEN               ! initialization for T-S damping
-         !
+      IF( ln_tradmp) THEN
+         !
+         !Allocate arrays
          IF( tra_dmp_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'tra_dmp_init: unable to allocate arrays' )
-         !
-!!gm  I don't understand the specificities of c1d case......   
-!!gm  to be check with the autor of these lines
-         
-#if ! defined key_c1d
-         SELECT CASE ( nn_hdmp )
-         CASE (  -1  )   ;   IF(lwp) WRITE(numout,*) '   tracer damping in the Med & Red seas only'
-         CASE ( 1:90 )   ;   IF(lwp) WRITE(numout,*) '   tracer damping poleward of', nn_hdmp, ' degrees'
-         CASE DEFAULT
-            WRITE(ctmp1,*) '          bad flag value for nn_hdmp = ', nn_hdmp
-            CALL ctl_stop(ctmp1)
+
+         !Check values of nn_zdmp
+         SELECT CASE (nn_zdmp)
+         CASE ( 0 )  ; IF(lwp) WRITE(numout,*) '   tracer damping as specified by mask'
+         CASE ( 1 )  ; IF(lwp) WRITE(numout,*) '   no tracer damping in the turbocline'
+         CASE ( 2 )  ; IF(lwp) WRITE(numout,*) '   no tracer damping in the mixed layer'
          END SELECT
-         !
-#endif
-         SELECT CASE ( nn_zdmp )
-         CASE ( 0 )   ;   IF(lwp) WRITE(numout,*) '   tracer damping throughout the water column'
-         CASE ( 1 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the turbocline (avt > 5 cm2/s)'
-         CASE ( 2 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the mixed layer'
-         CASE DEFAULT
-            WRITE(ctmp1,*) 'bad flag value for nn_zdmp = ', nn_zdmp
-            CALL ctl_stop(ctmp1)
-         END SELECT
-         !
+
+         !TG: Initialisation of dtatsd - Would it be better to have dmpdta routine
+         !so can damp to something other than intitial conditions files?
          IF( .NOT.ln_tsd_tradmp ) THEN
             CALL ctl_warn( 'tra_dmp_init: read T-S data not initialized, we force ln_tsd_tradmp=T' )
             CALL dta_tsd_init( ld_tradmp=ln_tradmp )        ! forces the initialisation of T-S data
          ENDIF
-         !
-         strdmp(:,:,:) = 0._wp       ! internal damping salinity trend (used in asmtrj)
+
+         !initialise arrays - Are these actually used anywhere else?
+         strdmp(:,:,:) = 0._wp
          ttrdmp(:,:,:) = 0._wp
-         !                          ! Damping coefficients initialization
-         IF( lzoom .AND. .NOT. lk_c1d ) THEN   ;   CALL dtacof_zoom( resto )
-         ELSE               ;   CALL dtacof( nn_hdmp, rn_surf, rn_bot, rn_dep, nn_file, 'TRA', resto )
-         ENDIF
-         !
-      ENDIF
-      !
+
+         !Read in mask from file
+         CALL iom_open ( cn_resto, imask)
+         CALL iom_get  ( imask, jpdom_autoglo, 'resto', resto)
+         CALL iom_close( imask )
+       ENDIF
+
    END SUBROUTINE tra_dmp_init
 
-
-   SUBROUTINE dtacof_zoom( presto )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE dtacof_zoom  ***
-      !!
-      !! ** Purpose :   Compute the damping coefficient for zoom domain
-      !!
-      !! ** Method  : - set along closed boundary due to zoom a damping over
-      !!                6 points with a max time scale of 5 days.
-      !!              - ORCA arctic/antarctic zoom: set the damping along
-      !!                south/north boundary over a latitude strip.
-      !!
-      !! ** Action  : - resto, the damping coeff. for T and S
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout)  ::   presto   ! restoring coeff. (s-1)
-      !
-      INTEGER  ::   ji, jj, jk, jn   ! dummy loop indices
-      REAL(wp) ::   zlat, zlat0, zlat1, zlat2, z1_5d   ! local scalar
-      REAL(wp), DIMENSION(6)  ::   zfact               ! 1Dworkspace
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start( 'dtacof_zoom')
-      !
-
-      zfact(1) =  1._wp
-      zfact(2) =  1._wp
-      zfact(3) = 11._wp / 12._wp
-      zfact(4) =  8._wp / 12._wp
-      zfact(5) =  4._wp / 12._wp
-      zfact(6) =  1._wp / 12._wp
-      zfact(:) = zfact(:) / ( 5._wp * rday )    ! 5 days max restoring time scale
-
-      presto(:,:,:) = 0._wp
-
-      ! damping along the forced closed boundary over 6 grid-points
-      DO jn = 1, 6
-         IF( lzoom_w )   presto( mi0(jn+jpizoom):mi1(jn+jpizoom), : , : )                    = zfact(jn)   ! west  closed
-         IF( lzoom_s )   presto( : , mj0(jn+jpjzoom):mj1(jn+jpjzoom), : )                    = zfact(jn)   ! south closed 
-         IF( lzoom_e )   presto( mi0(jpiglo+jpizoom-1-jn):mi1(jpiglo+jpizoom-1-jn) , : , : ) = zfact(jn)   ! east  closed 
-         IF( lzoom_n )   presto( : , mj0(jpjglo+jpjzoom-1-jn):mj1(jpjglo+jpjzoom-1-jn) , : ) = zfact(jn)   ! north closed
-      END DO
-
-      !                                           ! ====================================================
-      IF( cp_cfz == "arctic" .OR. cp_cfz == "antarctic" ) THEN   !  ORCA configuration : arctic or antarctic zoom
-         !                                        ! ====================================================
-         IF(lwp) WRITE(numout,*)
-         IF(lwp .AND. cp_cfz == "arctic" ) WRITE(numout,*) '              dtacof_zoom : ORCA    Arctic zoom'
-         IF(lwp .AND. cp_cfz == "antarctic" ) WRITE(numout,*) '           dtacof_zoom : ORCA Antarctic zoom'
-         IF(lwp) WRITE(numout,*)
-         !
-         !                          ! Initialization : 
-         presto(:,:,:) = 0._wp
-         zlat0 = 10._wp                     ! zlat0 : latitude strip where resto decreases
-         zlat1 = 30._wp                     ! zlat1 : resto = 1 before zlat1
-         zlat2 = zlat1 + zlat0              ! zlat2 : resto decreases from 1 to 0 between zlat1 and zlat2
-         z1_5d = 1._wp / ( 5._wp * rday )   ! z1_5d : 1 / 5days
-
-         DO jk = 2, jpkm1           ! Compute arrays resto ; value for internal damping : 5 days
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zlat = ABS( gphit(ji,jj) )
-                  IF( zlat1 <= zlat .AND. zlat <= zlat2 ) THEN
-                     presto(ji,jj,jk) = 0.5_wp * z1_5d * (  1._wp - COS( rpi*(zlat2-zlat)/zlat0 )  ) 
-                  ELSEIF( zlat < zlat1 ) THEN
-                     presto(ji,jj,jk) = z1_5d
-                  ENDIF
-               END DO
-            END DO
-         END DO
-         !
-      ENDIF
-      !                             ! Mask resto array
-      presto(:,:,:) = presto(:,:,:) * tmask(:,:,:)
-      !
-      IF( nn_timing == 1 )  CALL timing_stop( 'dtacof_zoom')
-      !
-   END SUBROUTINE dtacof_zoom
-
-
-   SUBROUTINE dtacof( kn_hdmp, pn_surf, pn_bot, pn_dep,  &
-      &               kn_file, cdtype , presto           )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE dtacof  ***
-      !!
-      !! ** Purpose :   Compute the damping coefficient
-      !!
-      !! ** Method  :   Arrays defining the damping are computed for each grid
-      !!                point for temperature and salinity (resto)
-      !!                Damping depends on distance to coast, depth and latitude
-      !!
-      !! ** Action  : - resto, the damping coeff. for T and S
-      !!----------------------------------------------------------------------
-      USE iom
-      USE ioipsl
-      !!
-      INTEGER                         , INTENT(in   )  ::  kn_hdmp    ! damping option
-      REAL(wp)                        , INTENT(in   )  ::  pn_surf    ! surface time scale (days)
-      REAL(wp)                        , INTENT(in   )  ::  pn_bot     ! bottom time scale (days)
-      REAL(wp)                        , INTENT(in   )  ::  pn_dep     ! depth of transition (meters)
-      INTEGER                         , INTENT(in   )  ::  kn_file    ! save the damping coef on a file or not
-      CHARACTER(len=3)                , INTENT(in   )  ::  cdtype     ! =TRA, TRC or DYN (tracer/dynamics indicator)
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout)  ::  presto     ! restoring coeff. (s-1)
-      !
-      INTEGER  ::   ji, jj, jk                  ! dummy loop indices
-      INTEGER  ::   ii0, ii1, ij0, ij1          ! local integers
-      INTEGER  ::   inum0, icot                 !   -       -
-      REAL(wp) ::   zinfl, zlon                 ! local scalars
-      REAL(wp) ::   zlat, zlat0, zlat1, zlat2   !   -      -
-      REAL(wp) ::   zsdmp, zbdmp                !   -      -
-      CHARACTER(len=20)                   :: cfile
-      REAL(wp), POINTER, DIMENSION(:    ) :: zhfac 
-      REAL(wp), POINTER, DIMENSION(:,:  ) :: zmrs 
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zdct 
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('dtacof')
-      !
-      CALL wrk_alloc( jpk, zhfac          )
-      CALL wrk_alloc( jpi, jpj, zmrs      )
-      CALL wrk_alloc( jpi, jpj, jpk, zdct )
-#if defined key_c1d
-      !                                   ! ====================
-      !                                   !  C1D configuration : local domain
-      !                                   ! ====================
-      !
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) '              dtacof : C1D 3x3 local domain'
-      IF(lwp) WRITE(numout,*) '              -----------------------------'
-      !
-      presto(:,:,:) = 0._wp
-      !
-      zsdmp = 1._wp / ( pn_surf * rday )
-      zbdmp = 1._wp / ( pn_bot  * rday )
-      DO jk = 2, jpkm1
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               !   ONLY vertical variation from zsdmp (sea surface) to zbdmp (bottom)
-               presto(ji,jj,jk) = zbdmp + (zsdmp-zbdmp) * EXP(-fsdept(ji,jj,jk)/pn_dep)
-            END DO
-         END DO
-      END DO
-      !
-      presto(:,:, : ) = presto(:,:,:) * tmask(:,:,:)
-#else
-      !                                   ! ====================
-      !                                   !  ORCA configuration : global domain
-      !                                   ! ====================
-      !
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) '              dtacof : Global domain of ORCA'
-      IF(lwp) WRITE(numout,*) '              ------------------------------'
-      !
-      presto(:,:,:) = 0._wp
-      !
-      IF( kn_hdmp > 0 ) THEN      !  Damping poleward of 'nn_hdmp' degrees  !
-         !                        !-----------------------------------------!
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) '              Damping poleward of ', kn_hdmp, ' deg.'
-         !
-         CALL iom_open ( 'dist.coast.nc', icot, ldstop = .FALSE. )
-         !
-         IF( icot > 0 ) THEN          ! distance-to-coast read in file
-            CALL iom_get  ( icot, jpdom_data, 'Tcoast', zdct )
-            CALL iom_close( icot )
-         ELSE                         ! distance-to-coast computed and saved in file (output in zdct)
-            CALL cofdis( zdct )
-         ENDIF
-
-         !                            ! Compute arrays resto 
-         zinfl = 1000.e3_wp                ! distance of influence for damping term
-         zlat0 = 10._wp                    ! latitude strip where resto decreases
-         zlat1 = REAL( kn_hdmp )           ! resto = 0 between -zlat1 and zlat1
-         zlat2 = zlat1 + zlat0             ! resto increases from 0 to 1 between |zlat1| and |zlat2|
-
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               zlat = ABS( gphit(ji,jj) )
-               IF ( zlat1 <= zlat .AND. zlat <= zlat2 ) THEN
-                  presto(ji,jj,1) = 0.5_wp * (  1._wp - COS( rpi*(zlat-zlat1)/zlat0 )  )
-               ELSEIF ( zlat > zlat2 ) THEN
-                  presto(ji,jj,1) = 1._wp
-               ENDIF
-            END DO
-         END DO
-
-         IF ( kn_hdmp == 20 ) THEN       ! North Indian ocean (20N/30N x 45E/100E) : resto=0
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zlat = gphit(ji,jj)
-                  zlon = MOD( glamt(ji,jj), 360._wp )
-                  IF ( zlat1 < zlat .AND. zlat < zlat2 .AND. 45._wp < zlon .AND. zlon < 100._wp ) THEN
-                     presto(ji,jj,1) = 0._wp
-                  ENDIF
-               END DO
-            END DO
-         ENDIF
-
-         zsdmp = 1._wp / ( pn_surf * rday )
-         zbdmp = 1._wp / ( pn_bot  * rday )
-         DO jk = 2, jpkm1
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zdct(ji,jj,jk) = MIN( zinfl, zdct(ji,jj,jk) )
-                  !   ... Decrease the value in the vicinity of the coast
-                  presto(ji,jj,jk) = presto(ji,jj,1 ) * 0.5_wp * (  1._wp - COS( rpi*zdct(ji,jj,jk)/zinfl)  )
-                  !   ... Vertical variation from zsdmp (sea surface) to zbdmp (bottom)
-                  presto(ji,jj,jk) = presto(ji,jj,jk) * (  zbdmp + (zsdmp-zbdmp) * EXP(-fsdept(ji,jj,jk)/pn_dep)  )
-               END DO
-            END DO
-         END DO
-         !
-      ENDIF
-
-      !                                  ! =========================
-      !                                  !  Med and Red Sea damping    (ORCA configuration only)
-      !                                  ! =========================
-      IF( cp_cfg == "orca" .AND. ( kn_hdmp > 0 .OR. kn_hdmp == -1 ) ) THEN
-         IF(lwp)WRITE(numout,*)
-         IF(lwp)WRITE(numout,*) '              ORCA configuration: Damping in Med and Red Seas'
-         !
-         zmrs(:,:) = 0._wp
-         !
-         SELECT CASE ( jp_cfg )
-         !                                           ! =======================
-         CASE ( 4 )                                  !  ORCA_R4 configuration 
-            !                                        ! =======================
-            ij0 =  50   ;   ij1 =  56                    ! Mediterranean Sea
-
-            ii0 =  81   ;   ii1 =  91   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1._wp
-            ij0 =  50   ;   ij1 =  55
-            ii0 =  75   ;   ii1 =  80   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1._wp
-            ij0 =  52   ;   ij1 =  53
-            ii0 =  70   ;   ii1 =  74   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1._wp
-            ! Smooth transition from 0 at surface to 1./rday at the 18th level in Med and Red Sea
-            DO jk = 1, 17
-               zhfac (jk) = 0.5_wp * (  1._wp - COS( rpi * REAL(jk-1,wp) / 16._wp )  ) / rday
-            END DO
-            DO jk = 18, jpkm1
-               zhfac (jk) = 1._wp / rday
-            END DO
-            !                                        ! =======================
-         CASE ( 2 )                                  !  ORCA_R2 configuration 
-            !                                        ! =======================
-            ij0 =  96   ;   ij1 = 110                    ! Mediterranean Sea
-            ii0 = 157   ;   ii1 = 181   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1._wp
-            ij0 = 100   ;   ij1 = 110
-            ii0 = 144   ;   ii1 = 156   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1._wp
-            ij0 = 100   ;   ij1 = 103
-            ii0 = 139   ;   ii1 = 143   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1._wp
-            !
-            ij0 = 101   ;   ij1 = 102                    ! Decrease before Gibraltar Strait
-            ii0 = 139   ;   ii1 = 141   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0._wp
-            ii0 = 142   ;   ii1 = 142   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1._wp / 90._wp
-            ii0 = 143   ;   ii1 = 143   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.40_wp
-            ii0 = 144   ;   ii1 = 144   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.75_wp
-            !
-            ij0 =  87   ;   ij1 =  96                    ! Red Sea
-            ii0 = 147   ;   ii1 = 163   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1._wp
-            !
-            ij0 =  91   ;   ij1 =  91                    ! Decrease before Bab el Mandeb Strait
-            ii0 = 153   ;   ii1 = 160   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.80_wp
-            ij0 =  90   ;   ij1 =  90
-            ii0 = 153   ;   ii1 = 160   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.40_wp
-            ij0 =  89   ;   ij1 =  89
-            ii0 = 158   ;   ii1 = 160   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1._wp / 90._wp
-            ij0 =  88   ;   ij1 =  88
-            ii0 = 160   ;   ii1 = 163   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0._wp
-            ! Smooth transition from 0 at surface to 1./rday at the 18th level in Med and Red Sea
-            DO jk = 1, 17
-               zhfac (jk) = 0.5_wp * (  1._wp - COS( rpi * REAL(jk-1,wp) / 16._wp )  ) / rday
-            END DO
-            DO jk = 18, jpkm1
-               zhfac (jk) = 1._wp / rday
-            END DO
-            !                                        ! =======================
-         CASE ( 05 )                                 !  ORCA_R05 configuration
-            !                                        ! =======================
-            ii0 = 568   ;   ii1 = 574                    ! Mediterranean Sea
-            ij0 = 324   ;   ij1 = 333   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1._wp
-            ii0 = 575   ;   ii1 = 658
-            ij0 = 314   ;   ij1 = 366   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1._wp
-            !
-            ii0 = 641   ;   ii1 = 651                    ! Black Sea (remaining part
-            ij0 = 367   ;   ij1 = 372   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1._wp
-            !
-            ij0 = 324   ;   ij1 = 333                    ! Decrease before Gibraltar Strait
-            ii0 = 565   ;   ii1 = 565   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1._wp / 90._wp
-            ii0 = 566   ;   ii1 = 566   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.40_wp
-            ii0 = 567   ;   ii1 = 567   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.75_wp
-            !
-            ii0 = 641   ;   ii1 = 665                    ! Red Sea
-            ij0 = 270   ;   ij1 = 310   ;   zmrs( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 1._wp
-            !
-            ii0 = 666   ;   ii1 = 675                    ! Decrease before Bab el Mandeb Strait
-            ij0 = 270   ;   ij1 = 290   
-            DO ji = mi0(ii0), mi1(ii1)
-               zmrs( ji , mj0(ij0):mj1(ij1) ) = 0.1_wp * ABS( FLOAT(ji - mi1(ii1)) )
-            END DO 
-            zsdmp = 1._wp / ( pn_surf * rday )
-            zbdmp = 1._wp / ( pn_bot  * rday )
-            DO jk = 1, jpk
-               zhfac(jk) = (  zbdmp + (zsdmp-zbdmp) * EXP( -fsdept(1,1,jk)/pn_dep )  )
-            END DO
-            !                                       ! ========================
-         CASE ( 025 )                               !  ORCA_R025 configuration 
-            !                                       ! ========================
-            CALL ctl_stop( ' Not yet implemented in ORCA_R025' )
-            !
-         END SELECT
-
-         DO jk = 1, jpkm1
-            presto(:,:,jk) = zmrs(:,:) * zhfac(jk) + ( 1._wp - zmrs(:,:) ) * presto(:,:,jk)
-         END DO
-
-         ! Mask resto array and set to 0 first and last levels
-         presto(:,:, : ) = presto(:,:,:) * tmask(:,:,:)
-         presto(:,:, 1 ) = 0._wp
-         presto(:,:,jpk) = 0._wp
-         !                         !--------------------!
-      ELSE                         !     No damping     !
-         !                         !--------------------!
-         CALL ctl_stop( 'Choose a correct value of nn_hdmp or put ln_tradmp to FALSE' )
-      ENDIF
-#endif
-
-      !                            !--------------------------------!
-      IF( kn_file == 1 ) THEN      !  save damping coef. in a file  !
-         !                         !--------------------------------!
-         IF(lwp) WRITE(numout,*) '              create damping.coeff.nc file'
-         IF( cdtype == 'TRA' ) cfile = 'damping.coeff'
-         IF( cdtype == 'TRC' ) cfile = 'damping.coeff.trc'
-         IF( cdtype == 'DYN' ) cfile = 'damping.coeff.dyn'
-         cfile = TRIM( cfile )
-         CALL iom_open  ( cfile, inum0, ldwrt = .TRUE., kiolib = jprstlib )
-         CALL iom_rstput( 0, 0, inum0, 'Resto', presto )
-         CALL iom_close ( inum0 )
-      ENDIF
-      !
-      CALL wrk_dealloc( jpk, zhfac)
-      CALL wrk_dealloc( jpi, jpj, zmrs )
-      CALL wrk_dealloc( jpi, jpj, jpk, zdct )
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('dtacof')
-      !
-   END SUBROUTINE dtacof
-
-
-   SUBROUTINE cofdis( pdct )
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE cofdis  ***
-      !!
-      !! ** Purpose :   Compute the distance between ocean T-points and the
-      !!      ocean model coastlines. Save the distance in a NetCDF file.
-      !!
-      !! ** Method  :   For each model level, the distance-to-coast is 
-      !!      computed as follows : 
-      !!       - The coastline is defined as the serie of U-,V-,F-points
-      !!      that are at the ocean-land bound.
-      !!       - For each ocean T-point, the distance-to-coast is then 
-      !!      computed as the smallest distance (on the sphere) between the 
-      !!      T-point and all the coastline points.
-      !!       - For land T-points, the distance-to-coast is set to zero.
-      !!      C A U T I O N : Computation not yet implemented in mpp case.
-      !!
-      !! ** Action  : - pdct, distance to the coastline (argument)
-      !!              - NetCDF file 'dist.coast.nc' 
-      !!----------------------------------------------------------------------
-      USE ioipsl      ! IOipsl librairy
-      !!
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( out ) ::   pdct   ! distance to the coastline
-      !!
-      INTEGER ::   ji, jj, jk, jl   ! dummy loop indices
-      INTEGER ::   iju, ijt, icoast, itime, ierr, icot   ! local integers
-      CHARACTER (len=32) ::   clname                     ! local name
-      REAL(wp) ::   zdate0                               ! local scalar
-      REAL(wp), POINTER, DIMENSION(:,:) ::  zxt, zyt, zzt, zmask
-      REAL(wp), POINTER, DIMENSION(:  ) ::  zxc, zyc, zzc, zdis    ! temporary workspace
-      LOGICAL , ALLOCATABLE, DIMENSION(:,:) ::  llcotu, llcotv, llcotf   ! 2D logical workspace
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('cofdis')
-      !
-      CALL wrk_alloc( jpi, jpj , zxt, zyt, zzt, zmask    )
-      CALL wrk_alloc( 3*jpi*jpj, zxc, zyc, zzc, zdis     )
-      ALLOCATE( llcotu(jpi,jpj), llcotv(jpi,jpj), llcotf(jpi,jpj)  )
-      !
-      IF( lk_mpp    )   CALL mpp_sum( ierr )
-      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'cofdis: requested local arrays unavailable')
-
-      ! 0. Initialization
-      ! -----------------
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'cofdis : compute the distance to coastline'
-      IF(lwp) WRITE(numout,*) '~~~~~~'
-      IF(lwp) WRITE(numout,*)
-      IF( lk_mpp ) &
-           & CALL ctl_stop('         Computation not yet implemented with key_mpp_...', &
-           &               '         Rerun the code on another computer or ', &
-           &               '         create the "dist.coast.nc" file using IDL' )
-
-      pdct(:,:,:) = 0._wp
-      zxt(:,:) = COS( rad * gphit(:,:) ) * COS( rad * glamt(:,:) )
-      zyt(:,:) = COS( rad * gphit(:,:) ) * SIN( rad * glamt(:,:) )
-      zzt(:,:) = SIN( rad * gphit(:,:) )
-
-
-      ! 1. Loop on vertical levels
-      ! --------------------------
-      !                                                ! ===============
-      DO jk = 1, jpkm1                                 ! Horizontal slab
-         !                                             ! ===============
-         ! Define the coastline points (U, V and F)
-         DO jj = 2, jpjm1
-            DO ji = 2, jpim1
-               zmask(ji,jj) =  ( tmask(ji,jj+1,jk) + tmask(ji+1,jj+1,jk) &
-                   &           + tmask(ji,jj  ,jk) + tmask(ji+1,jj  ,jk) )
-               llcotu(ji,jj) = ( tmask(ji,jj,  jk) + tmask(ji+1,jj  ,jk) == 1._wp ) 
-               llcotv(ji,jj) = ( tmask(ji,jj  ,jk) + tmask(ji  ,jj+1,jk) == 1._wp ) 
-               llcotf(ji,jj) = ( zmask(ji,jj) > 0._wp ) .AND. ( zmask(ji,jj) < 4._wp )
-            END DO
-         END DO
-
-         ! Lateral boundaries conditions
-         llcotu(:, 1 ) = umask(:,  2  ,jk) == 1
-         llcotu(:,jpj) = umask(:,jpjm1,jk) == 1
-         llcotv(:, 1 ) = vmask(:,  2  ,jk) == 1
-         llcotv(:,jpj) = vmask(:,jpjm1,jk) == 1
-         llcotf(:, 1 ) = fmask(:,  2  ,jk) == 1
-         llcotf(:,jpj) = fmask(:,jpjm1,jk) == 1
-
-         IF( nperio == 1 .OR. nperio == 4 .OR. nperio == 6 ) THEN
-            llcotu( 1 ,:) = llcotu(jpim1,:)
-            llcotu(jpi,:) = llcotu(  2  ,:)
-            llcotv( 1 ,:) = llcotv(jpim1,:)
-            llcotv(jpi,:) = llcotv(  2  ,:)
-            llcotf( 1 ,:) = llcotf(jpim1,:)
-            llcotf(jpi,:) = llcotf(  2  ,:)
-         ELSE
-            llcotu( 1 ,:) = umask(  2  ,:,jk) == 1
-            llcotu(jpi,:) = umask(jpim1,:,jk) == 1
-            llcotv( 1 ,:) = vmask(  2  ,:,jk) == 1
-            llcotv(jpi,:) = vmask(jpim1,:,jk) == 1
-            llcotf( 1 ,:) = fmask(  2  ,:,jk) == 1
-            llcotf(jpi,:) = fmask(jpim1,:,jk) == 1
-         ENDIF
-         IF( nperio == 3 .OR. nperio == 4 ) THEN
-            DO ji = 1, jpim1
-               iju = jpi - ji + 1
-               llcotu(ji,jpj  ) = llcotu(iju,jpj-2)
-               llcotf(ji,jpjm1) = llcotf(iju,jpj-2)
-               llcotf(ji,jpj  ) = llcotf(iju,jpj-3)
-            END DO
-            DO ji = jpi/2, jpim1
-               iju = jpi - ji + 1
-               llcotu(ji,jpjm1) = llcotu(iju,jpjm1)
-            END DO
-            DO ji = 2, jpi
-               ijt = jpi - ji + 2
-               llcotv(ji,jpjm1) = llcotv(ijt,jpj-2)
-               llcotv(ji,jpj  ) = llcotv(ijt,jpj-3)
-            END DO
-         ENDIF
-         IF( nperio == 5 .OR. nperio == 6 ) THEN
-            DO ji = 1, jpim1
-               iju = jpi - ji
-               llcotu(ji,jpj  ) = llcotu(iju,jpjm1)
-               llcotf(ji,jpj  ) = llcotf(iju,jpj-2)
-            END DO
-            DO ji = jpi/2, jpim1
-               iju = jpi - ji
-               llcotf(ji,jpjm1) = llcotf(iju,jpjm1)
-            END DO
-            DO ji = 1, jpi
-               ijt = jpi - ji + 1
-               llcotv(ji,jpj  ) = llcotv(ijt,jpjm1)
-            END DO
-            DO ji = jpi/2+1, jpi
-               ijt = jpi - ji + 1
-               llcotv(ji,jpjm1) = llcotv(ijt,jpjm1)
-            END DO
-         ENDIF
-
-         ! Compute cartesian coordinates of coastline points
-         ! and the number of coastline points
-         icoast = 0
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               IF( llcotf(ji,jj) ) THEN
-                  icoast = icoast + 1
-                  zxc(icoast) = COS( rad*gphif(ji,jj) ) * COS( rad*glamf(ji,jj) )
-                  zyc(icoast) = COS( rad*gphif(ji,jj) ) * SIN( rad*glamf(ji,jj) )
-                  zzc(icoast) = SIN( rad*gphif(ji,jj) )
-               ENDIF
-               IF( llcotu(ji,jj) ) THEN
-                  icoast = icoast+1
-                  zxc(icoast) = COS( rad*gphiu(ji,jj) ) * COS( rad*glamu(ji,jj) )
-                  zyc(icoast) = COS( rad*gphiu(ji,jj) ) * SIN( rad*glamu(ji,jj) )
-                  zzc(icoast) = SIN( rad*gphiu(ji,jj) )
-               ENDIF
-               IF( llcotv(ji,jj) ) THEN
-                  icoast = icoast+1
-                  zxc(icoast) = COS( rad*gphiv(ji,jj) ) * COS( rad*glamv(ji,jj) )
-                  zyc(icoast) = COS( rad*gphiv(ji,jj) ) * SIN( rad*glamv(ji,jj) )
-                  zzc(icoast) = SIN( rad*gphiv(ji,jj) )
-               ENDIF
-            END DO
-         END DO
-
-         ! Distance for the T-points
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               IF( tmask(ji,jj,jk) == 0._wp ) THEN
-                  pdct(ji,jj,jk) = 0._wp
-               ELSE
-                  DO jl = 1, icoast
-                     zdis(jl) = ( zxt(ji,jj) - zxc(jl) )**2   &
-                        &     + ( zyt(ji,jj) - zyc(jl) )**2   &
-                        &     + ( zzt(ji,jj) - zzc(jl) )**2
-                  END DO
-                  pdct(ji,jj,jk) = ra * SQRT( MINVAL( zdis(1:icoast) ) )
-               ENDIF
-            END DO
-         END DO
-         !                                                ! ===============
-      END DO                                              !   End of slab
-      !                                                   ! ===============
-
-
-      ! 2. Create the  distance to the coast file in NetCDF format
-      ! ----------------------------------------------------------    
-      clname = 'dist.coast'
-      itime  = 0
-      CALL ymds2ju( 0     , 1       , 1     , 0._wp , zdate0 )
-      CALL restini( 'NONE', jpi     , jpj   , glamt, gphit ,   &
-         &          jpk   , gdept_1d, clname, itime, zdate0,   &
-         &          rdt   , icot                         )
-      CALL restput( icot, 'Tcoast', jpi, jpj, jpk, 0, pdct )
-      CALL restclo( icot )
-      !
-      CALL wrk_dealloc( jpi, jpj , zxt, zyt, zzt, zmask    )
-      CALL wrk_dealloc( 3*jpi*jpj, zxc, zyc, zzc, zdis     )
-      DEALLOCATE( llcotu, llcotv, llcotf  )
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('cofdis')
-      !
-   END SUBROUTINE cofdis
-   !!======================================================================
 END MODULE tradmp
Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/TOP_SRC/TRP/trcdmp.F90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/TOP_SRC/TRP/trcdmp.F90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/TOP_SRC/TRP/trcdmp.F90	(revision 5213)
@@ -24,4 +24,5 @@
    USE trdtra
    USE trd_oce
+   USE iom
 
    IMPLICIT NONE
@@ -302,13 +303,8 @@
       !!----------------------------------------------------------------------
       !
+      INTEGER :: imask  !local file handle
+
       IF( nn_timing == 1 )  CALL timing_start('trc_dmp_init')
       !
-      SELECT CASE ( nn_hdmp_tr )
-      CASE (  -1  )   ;   IF(lwp) WRITE(numout,*) '   tracer damping in the Med & Red seas only'
-      CASE ( 1:90 )   ;   IF(lwp) WRITE(numout,*) '   tracer damping poleward of', nn_hdmp_tr, ' degrees'
-      CASE DEFAULT
-         WRITE(ctmp1,*) '          bad flag value for nn_hdmp_tr = ', nn_hdmp_tr
-         CALL ctl_stop(ctmp1)
-      END SELECT
 
       IF( lzoom )   nn_zdmp_tr = 0           ! restoring to climatology at closed north or south boundaries
@@ -325,9 +321,9 @@
          &   CALL ctl_stop( 'passive trace damping need key_tradmp to compute damping coef.' )
       !
-      !                          ! Damping coefficients initialization
-      IF( lzoom ) THEN   ;   CALL dtacof_zoom( restotr )
-      ELSE               ;   CALL dtacof( nn_hdmp_tr, rn_surf_tr, rn_bot_tr, rn_dep_tr,  &
-                             &            nn_file_tr, 'TRC'     , restotr                )
-      ENDIF
+      !                          ! Read damping coefficients from file
+      !Read in mask from file
+      CALL iom_open ( cn_resto_tr, imask)
+      CALL iom_get  ( imask, jpdom_autoglo, 'resto', restotr)
+      CALL iom_close( imask )
       !
       IF( nn_timing == 1 )  CALL timing_stop('trc_dmp_init')
Index: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/TOP_SRC/TRP/trcnam_trp.F90
===================================================================
--- branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/TOP_SRC/TRP/trcnam_trp.F90	(revision 5162)
+++ branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/NEMO/TOP_SRC/TRP/trcnam_trp.F90	(revision 5213)
@@ -51,10 +51,6 @@
    !                                                 !!: ** newtonian damping namelist (nam_trcdmp) **
    !                          !!* Namelist namtrc_dmp : passive tracer newtonian damping *
-   INTEGER , PUBLIC ::   nn_hdmp_tr    ! = 0/-1/'latitude' for damping over passive tracer
    INTEGER , PUBLIC ::   nn_zdmp_tr    ! = 0/1/2 flag for damping in the mixed layer
-   REAL(wp), PUBLIC ::   rn_surf_tr    ! surface time scale for internal damping        [days]
-   REAL(wp), PUBLIC ::   rn_bot_tr     ! bottom time scale for internal damping         [days]
-   REAL(wp), PUBLIC ::   rn_dep_tr     ! depth of transition between rn_surf and rn_bot [meters]
-   INTEGER , PUBLIC ::   nn_file_tr    ! = 1 create a damping.coeff NetCDF file
+   CHARACTER(LEN=200) , PUBLIC :: cn_resto_tr    !File containing restoration coefficient
 
    !!----------------------------------------------------------------------
@@ -82,6 +78,5 @@
       NAMELIST/namtrc_zdf/ ln_trczdf_exp  , nn_trczdf_exp
       NAMELIST/namtrc_rad/ ln_trcrad
-      NAMELIST/namtrc_dmp/ nn_hdmp_tr, nn_zdmp_tr, rn_surf_tr, &
-        &                  rn_bot_tr , rn_dep_tr , nn_file_tr
+      NAMELIST/namtrc_dmp/ nn_zdmp_tr , cn_resto_tr
       !!----------------------------------------------------------------------
 
@@ -184,10 +179,6 @@
          WRITE(numout,*) '~~~~~~~'
          WRITE(numout,*) '   Namelist namtrc_dmp : set damping parameter'
-         WRITE(numout,*) '      tracer damping option          nn_hdmp_tr = ', nn_hdmp_tr
          WRITE(numout,*) '      mixed layer damping option     nn_zdmp_tr = ', nn_zdmp_tr, '(zoom: forced to 0)'
-         WRITE(numout,*) '      surface time scale (days)      rn_surf_tr = ', rn_surf_tr
-         WRITE(numout,*) '      bottom time scale (days)       rn_bot_tr  = ', rn_bot_tr
-         WRITE(numout,*) '      depth of transition (meters)   rn_dep_tr  = ', rn_dep_tr
-         WRITE(numout,*) '      create a damping.coeff file    nn_file_tr = ', nn_file_tr
+         WRITE(numout,*) '      Restoration coeff file    cn_resto_tr = ', cn_resto_tr
       ENDIF
       !
