Index: branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/CONFIG/SHARED/field_def.xml
===================================================================
--- branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/CONFIG/SHARED/field_def.xml	(revision 5331)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/CONFIG/SHARED/field_def.xml	(revision 5343)
@@ -185,6 +185,6 @@
          <field id="isfgammat"    long_name="transfert coefficient for isf (temperature) "                 unit="m/s"      />
          <field id="isfgammas"    long_name="transfert coefficient for isf (salinity)    "                 unit="m/s"      />
- 	     <field id="stbl"         long_name="salinity in the Losh tbl                    "                 unit="PSU"      />
-	     <field id="ttbl"         long_name="temperature in the Losh tbl                 "                 unit="C"        />
+ 	 <field id="stbl"         long_name="salinity in the Losh tbl                    "                 unit="PSU"      />
+	 <field id="ttbl"         long_name="temperature in the Losh tbl                 "                 unit="C"        />
 
          <!-- *_oce variables available with ln_blk_clio or ln_blk_core -->
@@ -340,4 +340,12 @@
          <field id="hfxdhc"    long_name="Heat content variation in snow and ice"   unit="W/m2" />
          <field id="hfxtur"    long_name="turbulent heat flux at the ice base"      unit="W/m2" />
+
+	 <!-- sbcssm variables -->
+         <field id="sst_m"    unit="degC" />
+         <field id="sss_m"    unit="psu"  />
+         <field id="ssu_m"    unit="m/s"  />
+         <field id="ssv_m"    unit="m/s"  />
+         <field id="ssh_m"    unit="m"    />
+         <field id="e3t_m"    unit="m"    />
 
       </field_group>
Index: branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/CONFIG/SHARED/namelist_ref
===================================================================
--- branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/CONFIG/SHARED/namelist_ref	(revision 5331)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/CONFIG/SHARED/namelist_ref	(revision 5343)
@@ -384,6 +384,7 @@
    sn_sal      = 'sas_grid_T' ,    120           , 'sosaline' ,  .true.    , .true. ,   'yearly'  , ''       , ''             , ''
    sn_ssh      = 'sas_grid_T' ,    120           , 'sossheig' ,  .true.    , .true. ,   'yearly'  , ''       , ''             , ''
-
-   ln_3d_uv    = .true.    !  specify whether we are supplying a 3D u,v field
+   sn_e3t      = 'sas_grid_T' ,    120           , 'e3t_m'    ,  .true.    , .true. ,   'yearly'  , ''       , ''             , ''
+
+   ln_3d_uve   = .true.    !  specify whether we are supplying a 3D u,v and e3 field
    cn_dir      = './'      !  root directory for the location of the bulk files are
 /
Index: branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/LIM_SRC_3/limistate.F90
===================================================================
--- branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/LIM_SRC_3/limistate.F90	(revision 5331)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/LIM_SRC_3/limistate.F90	(revision 5343)
@@ -117,5 +117,5 @@
 
       ! basal temperature (considered at freezing point)
-      t_bo(:,:) = ( eos_fzp( tsn(:,:,1,jp_sal) ) + rt0 ) * tmask(:,:,1) 
+      t_bo(:,:) = ( eos_fzp( sss_m(:,:) ) + rt0 ) * tmask(:,:,1) 
 
       IF( ln_iceini ) THEN
@@ -127,5 +127,5 @@
       DO jj = 1, jpj                                       ! ice if sst <= t-freez + ttest
          DO ji = 1, jpi
-            IF( ( tsn(ji,jj,1,jp_tem)  - ( t_bo(ji,jj) - rt0 ) ) * tmask(ji,jj,1) >= rn_thres_sst ) THEN 
+            IF( ( sst_m(ji,jj)  - ( t_bo(ji,jj) - rt0 ) ) * tmask(ji,jj,1) >= rn_thres_sst ) THEN 
                zswitch(ji,jj) = 0._wp * tmask(ji,jj,1)    ! no ice
             ELSE                                                                                   
Index: branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90
===================================================================
--- branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 5331)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 5343)
@@ -485,4 +485,6 @@
          srcv(jpr_otx1)%clgrid = 'U'        ! oce components given at U-point
          srcv(jpr_oty1)%clgrid = 'V'        !           and           V-point
+         ! Vectors: change of sign at north fold ONLY if on the local grid
+         srcv( (/jpr_otx1,jpr_oty1/) )%nsgn = -1.
          sn_rcv_tau%clvgrd = 'U,V'
          sn_rcv_tau%clvor = 'local grid'
@@ -981,11 +983,4 @@
       !  (arrays no more filled at sbcssm stage)
       !                                                      ! ================== !
-      !                                                      !        SST         !
-      !                                                      ! ================== !
-      IF( srcv(jpr_toce)%laction ) THEN                      ! received by sas in case of opa <-> sas coupling
-         sst_m(:,:) = frcv(jpr_toce)%z3(:,:,1)
-         tsn(:,:,1,jp_tem) = sst_m(:,:)
-      ENDIF
-      !                                                      ! ================== !
       !                                                      !        SSS         !
       !                                                      ! ================== !
@@ -993,4 +988,15 @@
          sss_m(:,:) = frcv(jpr_soce)%z3(:,:,1)
          tsn(:,:,1,jp_sal) = sss_m(:,:)
+      ENDIF
+      !                                               
+      !                                                      ! ================== !
+      !                                                      !        SST         !
+      !                                                      ! ================== !
+      IF( srcv(jpr_toce)%laction ) THEN                      ! received by sas in case of opa <-> sas coupling
+         sst_m(:,:) = frcv(jpr_toce)%z3(:,:,1)
+         tsn(:,:,1,jp_tem) = sst_m(:,:)                      ! keep the received (potential or conservative) temperature in tsn 
+         IF( srcv(jpr_soce)%laction .AND. ln_useCT ) THEN    ! make sure that sst_m is the potential temperature
+            sst_m(:,:) = eos_pt_from_ct( sst_m(:,:), sss_m(:,:) )
+         ENDIF
       ENDIF
       !                                                      ! ================== !
@@ -1057,7 +1063,9 @@
          END IF
          ! update qns over the free ocean with:
-         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
+         IF( nn_components /= jp_iam_opa ) THEN
+            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
+            ENDIF
          ENDIF
          IF( ln_mixcpl ) THEN   ;   qns(:,:) = qns(:,:) * xcplmask(:,:,0) + zqns(:,:) * zmsk(:,:)
@@ -1070,5 +1078,5 @@
          ELSE                                       ;   zqsr(:,:) = 0._wp
          ENDIF
-         IF( ln_dm2dc )   zqsr(:,:) = sbc_dcy( zqsr )                           ! modify qsr to include the diurnal cycle
+         IF( ln_dm2dc .AND. nn_components /= jp_iam_opa )   zqsr(:,:) = sbc_dcy( zqsr )   ! modify qsr to include the diurnal cycle
          IF( ln_mixcpl ) THEN   ;   qsr(:,:) = qsr(:,:) * xcplmask(:,:,0) + zqsr(:,:) * zmsk(:,:)
          ELSE                   ;   qsr(:,:) =                              zqsr(:,:)
@@ -1627,10 +1635,16 @@
       !                                                      ! ------------------------- !
       IF( ssnd(jps_toce)%laction .OR. ssnd(jps_tice)%laction .OR. ssnd(jps_tmix)%laction ) THEN
+         
          IF ( nn_components == jp_iam_opa ) THEN
-            ztmp1(:,:) = tsn(:,:,1,jp_tem)
+            ztmp1(:,:) = tsn(:,:,1,jp_tem)   ! send temperature as it is (potential or conservative) -> use of ln_useCT on the received part
          ELSE
+            ! we must send the surface potential temperature 
+            IF( ln_useCT )  THEN    ;   ztmp1(:,:) = eos_pt_from_ct( tsn(:,:,1,jp_tem), tsn(:,:,1,jp_sal) )
+            ELSE                    ;   ztmp1(:,:) = tsn(:,:,1,jp_tem)
+            ENDIF
+            !
             SELECT CASE( sn_snd_temp%cldes)
-            CASE( 'oce only'             )   ;   ztmp1(:,:) =   tsn(:,:,1,jp_tem) + rt0
-            CASE( 'weighted oce and ice' )   ;   ztmp1(:,:) = ( tsn(:,:,1,jp_tem) + rt0 ) * zfr_l(:,:)   
+            CASE( 'oce only'             )   ;   ztmp1(:,:) =   ztmp1(:,:) + rt0
+            CASE( 'weighted oce and ice' )   ;   ztmp1(:,:) = ( ztmp1(:,:) + rt0 ) * zfr_l(:,:)   
                SELECT CASE( sn_snd_temp%clcat )
                CASE( 'yes' )   
@@ -1644,5 +1658,5 @@
                END SELECT
             CASE( 'mixed oce-ice'        )   
-               ztmp1(:,:) = ( tsn(:,:,1,jp_tem) + rt0 ) * zfr_l(:,:) 
+               ztmp1(:,:) = ( ztmp1(:,:) + rt0 ) * zfr_l(:,:) 
                DO jl=1,jpl
                   ztmp1(:,:) = ztmp1(:,:) + tn_ice(:,:,jl) * a_i(:,:,jl)
Index: branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcssm.F90
===================================================================
--- branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcssm.F90	(revision 5331)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcssm.F90	(revision 5343)
@@ -162,4 +162,13 @@
       ENDIF
       !
+      IF( MOD( kt - 1 , nn_fsbc ) == 0 ) THEN          !   Mean value at each nn_fsbc time-step   !
+         CALL iom_put( 'ssu_m', ssu_m )
+         CALL iom_put( 'ssv_m', ssv_m )
+         CALL iom_put( 'sst_m', sst_m )
+         CALL iom_put( 'sss_m', sss_m )
+         CALL iom_put( 'ssh_m', ssh_m )
+         IF( lk_vvl )   CALL iom_put( 'e3t_m', fse3t_m(:,:) )
+      ENDIF
+      !
    END SUBROUTINE sbc_ssm
 
@@ -212,4 +221,18 @@
          ENDIF
       ENDIF
+
+      IF( .NOT. l_ssm_mean ) THEN   ! default initialisation. needed by lim_istate
+         !
+         IF(lwp) WRITE(numout,*) '          default initialisation of ss?_m arrays'
+         ssu_m(:,:) = ub(:,:,1)
+         ssv_m(:,:) = vb(:,:,1)
+         IF( ln_useCT )  THEN    ;   sst_m(:,:) = eos_pt_from_ct( tsn(:,:,1,jp_tem), tsn(:,:,1,jp_sal) )
+         ELSE                    ;   sst_m(:,:) = tsn(:,:,1,jp_tem)
+         ENDIF
+         sss_m(:,:) = tsn(:,:,1,jp_sal)
+         ssh_m(:,:) = sshn(:,:)
+         IF( lk_vvl )   fse3t_m(:,:) = fse3t_n(:,:,1)
+         !
+      ENDIF
       !
    END SUBROUTINE sbc_ssm_init
Index: branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2.F90
===================================================================
--- branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2.F90	(revision 5331)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2.F90	(revision 5343)
@@ -72,7 +72,7 @@
    PUBLIC   eos_init       ! called by istate module
 
-   !                                          !!* Namelist (nameos) *
-   INTEGER , PUBLIC ::   nn_eos   = 0         !: = 0/1/2 type of eq. of state and Brunt-Vaisala frequ.
-   LOGICAL , PUBLIC ::   ln_useCT  = .FALSE.  ! determine if eos_pt_from_ct is used to compute sst_m
+   !                                !!* Namelist (nameos) *
+   INTEGER , PUBLIC ::   nn_eos     ! = 0/1/2 type of eq. of state and Brunt-Vaisala frequ.
+   LOGICAL , PUBLIC ::   ln_useCT   ! determine if eos_pt_from_ct is used to compute sst_m
 
    !                                   !!!  simplified eos coefficients
@@ -1183,4 +1183,6 @@
             WRITE(numout,*) '             model uses Conservative Temperature'
             WRITE(numout,*) '             Important: model must be initialized with CT and SA fields'
+         ELSE
+            WRITE(numout,*) '             model does not use Conservative Temperature'
          ENDIF
       ENDIF
Index: branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/SAS_SRC/nemogcm.F90
===================================================================
--- branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/SAS_SRC/nemogcm.F90	(revision 5331)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/SAS_SRC/nemogcm.F90	(revision 5343)
@@ -42,5 +42,4 @@
    USE step_oce        ! module used in the ocean time stepping module
    USE sbc_oce         ! surface boundary condition: ocean
-   USE cla             ! cross land advection               (tra_cla routine)
    USE domcfg          ! domain configuration               (dom_cfg routine)
    USE daymod          ! calendar
@@ -50,4 +49,7 @@
    USE step            ! NEMO time-stepping                 (stp     routine)
    USE lib_mpp         ! distributed memory computing
+#if defined key_nosignedzero
+   USE lib_fortran     ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
+#endif
 #if defined key_iomput
    USE xios
@@ -182,5 +184,4 @@
       !
       cltxt = ''
-      cxios_context = 'sas'
       !
       !                             ! Open reference namelist and configuration namelist files
@@ -188,8 +189,10 @@
          CALL ctl_opn( numnam_ref, 'namelist_sas_ref', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
          CALL ctl_opn( numnam_cfg, 'namelist_sas_cfg', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
+         cxios_context = 'sas'
       ELSE
          CALL ctl_opn( numnam_ref, 'namelist_ref', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
          CALL ctl_opn( numnam_cfg, 'namelist_cfg', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
-      ENDIF
+         cxios_context = 'nemo'
+   ENDIF
       !
       REWIND( numnam_ref )              ! Namelist namctl in reference namelist : Control prints & Benchmark
@@ -505,5 +508,5 @@
       ierr = ierr + dom_oce_alloc   ()          ! ocean domain
       ALLOCATE( snwice_mass(jpi,jpj)  , snwice_mass_b(jpi,jpj),             &
-         &      snwice_fmass(jpi,jpj), STAT= ierr4 )
+         &      snwice_fmass(jpi,jpj), STAT= ierr1 )
       !
       ! lim code currently uses surface temperature and salinity in tsn array for initialisation
Index: branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/SAS_SRC/sbcssm.F90
===================================================================
--- branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/SAS_SRC/sbcssm.F90	(revision 5331)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/SAS_SRC/sbcssm.F90	(revision 5343)
@@ -36,23 +36,19 @@
    PUBLIC   sbc_ssm        ! called by sbc
 
-   CHARACTER(len=100)   ::   cn_dir     = './'    !: Root directory for location of ssm files
-   LOGICAL              ::   ln_3d_uv   = .true.  !: specify whether input velocity data is 3D
-   INTEGER  , SAVE      ::   nfld_3d
-   INTEGER  , SAVE      ::   nfld_2d
-
-   INTEGER  , PARAMETER ::   jpfld_3d = 4   ! maximum number of files to read
-   INTEGER  , PARAMETER ::   jpfld_2d = 1   ! maximum number of files to read
-   INTEGER  , SAVE      ::   jf_tem         ! index of temperature
-   INTEGER  , SAVE      ::   jf_sal         ! index of salinity
-   INTEGER  , SAVE      ::   jf_usp         ! index of u velocity component
-   INTEGER  , SAVE      ::   jf_vsp         ! index of v velocity component
-   INTEGER  , SAVE      ::   jf_ssh         ! index of sea surface height
+   CHARACTER(len=100)   ::   cn_dir      !: Root directory for location of ssm files
+   LOGICAL              ::   ln_3d_uve   !: specify whether input velocity data is 3D
+   INTEGER     ::   nfld_3d
+   INTEGER     ::   nfld_2d
+
+   INTEGER     ::   jf_tem         ! index of temperature
+   INTEGER     ::   jf_sal         ! index of salinity
+   INTEGER     ::   jf_usp         ! index of u velocity component
+   INTEGER     ::   jf_vsp         ! index of v velocity component
+   INTEGER     ::   jf_ssh         ! index of sea surface height
+   INTEGER     ::   jf_e3t         ! index of first T level thickness
 
    TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_ssm_3d  ! structure of input fields (file information, fields read)
    TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_ssm_2d  ! structure of input fields (file information, fields read)
 
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-#  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/OFF 3.3 , NEMO Consortium (2010)
@@ -86,10 +82,12 @@
       IF( nfld_2d > 0 ) CALL fld_read( kt, 1, sf_ssm_2d )      !==   read data at kt time step   ==!
       ! 
-      IF( ln_3d_uv ) THEN
+      IF( ln_3d_uve ) THEN
          ssu_m(:,:) = sf_ssm_3d(jf_usp)%fnow(:,:,1) * umask(:,:,1)    ! u-velocity
          ssv_m(:,:) = sf_ssm_3d(jf_vsp)%fnow(:,:,1) * vmask(:,:,1)    ! v-velocity 
+         IF( lk_vvl )   e3t_m(:,:) = sf_ssm_3d(jf_e3t)%fnow(:,:,1) * tmask(:,:,1)    ! v-velocity 
       ELSE
          ssu_m(:,:) = sf_ssm_2d(jf_usp)%fnow(:,:,1) * umask(:,:,1)    ! u-velocity
          ssv_m(:,:) = sf_ssm_2d(jf_vsp)%fnow(:,:,1) * vmask(:,:,1)    ! v-velocity 
+         IF( lk_vvl )   e3t_m(:,:) = sf_ssm_2d(jf_e3t)%fnow(:,:,1) * tmask(:,:,1)    ! v-velocity 
       ENDIF
       !
@@ -104,6 +102,6 @@
          tsb(:,:,1,jp_sal) = sss_m(:,:)
       ENDIF
-      ub (:,:,1       ) = ssu_m(:,:)
-      vb (:,:,1       ) = ssv_m(:,:)
+      ub (:,:,1) = ssu_m(:,:)
+      vb (:,:,1) = ssv_m(:,:)
 
       IF(ln_ctl) THEN                  ! print control
@@ -113,4 +111,5 @@
          CALL prt_ctl(tab2d_1=ssv_m, clinfo1=' ssv_m   - : ', mask1=vmask, ovlap=1   )
          CALL prt_ctl(tab2d_1=ssh_m, clinfo1=' ssh_m   - : ', mask1=tmask, ovlap=1   )
+         IF( lk_vvl )   CALL prt_ctl(tab2d_1=ssh_m, clinfo1=' e3t_m   - : ', mask1=tmask, ovlap=1   )
       ENDIF
       !
@@ -138,7 +137,8 @@
       TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) ::  slf_2d       ! array of namelist information on the fields to read
       TYPE(FLD_N) :: sn_tem, sn_sal                     ! information about the fields to be read
-      TYPE(FLD_N) :: sn_usp, sn_vsp, sn_ssh
-      !
-      NAMELIST/namsbc_sas/cn_dir, ln_3d_uv, sn_tem, sn_sal, sn_usp, sn_vsp, sn_ssh
+      TYPE(FLD_N) :: sn_usp, sn_vsp
+      TYPE(FLD_N) :: sn_ssh, sn_e3t
+      !
+      NAMELIST/namsbc_sas/cn_dir, ln_3d_uve, sn_tem, sn_sal, sn_usp, sn_vsp, sn_ssh, sn_e3t
       !!----------------------------------------------------------------------
       
@@ -195,18 +195,18 @@
       !! when we have other 3d arrays that we need to read in
       !! so if a new field is added i.e. jf_new, just give it the next integer in sequence
-      !! for the corresponding dimension (currently if ln_3d_uv is true, 4 for 2d and 3 for 3d,
-      !! alternatively if ln_3d_uv is false, 6 for 2d and 1 for 3d), reset nfld_3d, nfld_2d,
+      !! for the corresponding dimension (currently if ln_3d_uve is true, 4 for 2d and 3 for 3d,
+      !! alternatively if ln_3d_uve is false, 6 for 2d and 1 for 3d), reset nfld_3d, nfld_2d,
       !! and the rest of the logic should still work
       !
       jf_tem = 1 ; jf_sal = 2 ; jf_ssh = 3
       !
-      IF( ln_3d_uv ) THEN
-         jf_usp = 1 ; jf_vsp = 2
-         nfld_3d  = 2
+      IF( ln_3d_uve ) THEN
+         jf_usp = 1 ; jf_vsp = 2 ; jf_e3t = 3
+         nfld_3d  = 2 + COUNT( (/lk_vvl/) )
          nfld_2d  = 3
       ELSE
-         jf_usp = 4 ; jf_vsp = 5
+         jf_usp = 4 ; jf_vsp = 5 ; jf_e3t = 6
          nfld_3d  = 0
-         nfld_2d  = 5
+         nfld_2d  = 5 + COUNT( (/lk_vvl/) )
       ENDIF
 
@@ -216,8 +216,7 @@
             CALL ctl_stop( 'sbc_ssm_init: unable to allocate slf 3d structure' )   ;   RETURN
          ENDIF
-         IF( ln_3d_uv ) THEN
-            slf_3d(jf_usp) = sn_usp
-            slf_3d(jf_vsp) = sn_vsp
-         ENDIF
+         slf_3d(jf_usp) = sn_usp
+         slf_3d(jf_vsp) = sn_vsp
+         IF( lk_vvl )   slf_3d(jf_e3t) = sn_e3t
       ENDIF
 
@@ -228,9 +227,11 @@
          ENDIF
          slf_2d(jf_tem) = sn_tem ; slf_2d(jf_sal) = sn_sal ; slf_2d(jf_ssh) = sn_ssh
-         IF( .NOT. ln_3d_uv ) THEN
+         IF( .NOT. ln_3d_uve ) THEN
             slf_2d(jf_usp) = sn_usp ; slf_2d(jf_vsp) = sn_vsp
-         ENDIF
-      ENDIF
-      !
+            IF( lk_vvl )   slf_2d(jf_e3t) = sn_e3t
+         ENDIF
+      ENDIF
+      !
+      ierr1 = 0    ! default definition if slf_?d(ifpr)%ln_tint = .false. 
       IF( nfld_3d > 0 ) THEN
          ALLOCATE( sf_ssm_3d(nfld_3d), STAT=ierr )         ! set sf structure
@@ -269,4 +270,6 @@
       IF( nfld_3d > 0 ) DEALLOCATE( slf_3d, STAT=ierr )
       IF( nfld_2d > 0 ) DEALLOCATE( slf_2d, STAT=ierr )
+
+      call sbc_ssm( nit000 )   ! need to define ss?_m arrays used in limistate
       !
    END SUBROUTINE sbc_ssm_init
