Index: branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/LIM_SRC_3/limthd.F90
===================================================================
--- branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/LIM_SRC_3/limthd.F90	(revision 5259)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/LIM_SRC_3/limthd.F90	(revision 5299)
@@ -28,5 +28,4 @@
    USE thd_ice        ! LIM thermodynamic sea-ice variables
    USE dom_ice        ! LIM sea-ice domain
-   USE domvvl         ! domain: variable volume level
    USE limthd_dif     ! LIM: thermodynamics, vertical diffusion
    USE limthd_dh      ! LIM: thermodynamics, ice and snow thickness variation
Index: branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 5259)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 5299)
@@ -121,5 +121,5 @@
       CALL set_scalar
 
-      IF( TRIM(cdname) == "nemo" ) THEN  
+      IF( TRIM(cdname) == TRIM(cxios_context) ) THEN  
          CALL set_grid( "T", glamt, gphit ) 
          CALL set_grid( "U", glamu, gphiu )
@@ -128,5 +128,5 @@
       ENDIF
 
-      IF( TRIM(cdname) == "nemo_crs" ) THEN  
+      IF( TRIM(cdname) == TRIM(cxios_context)//"_crs" ) THEN  
          CALL dom_grid_crs   ! Save the parent grid information  & Switch to coarse grid domain
          !
@@ -1200,5 +1200,5 @@
       CALL iom_swap( cdname )   ! swap to cdname context
       CALL xios_update_calendar(kt)
-      IF( cdname /= "nemo" ) CALL iom_swap( "nemo" )   ! return back to nemo context
+      IF( cdname /= TRIM(cxios_context) ) CALL iom_swap( TRIM(cxios_context) )   ! return back to nemo context
       !
    END SUBROUTINE iom_setkt
@@ -1210,5 +1210,5 @@
          CALL iom_swap( cdname )   ! swap to cdname context
          CALL xios_context_finalize() ! finalize the context
-         IF( cdname /= "nemo" ) CALL iom_swap( "nemo" )   ! return back to nemo context
+         IF( cdname /= TRIM(cxios_context) ) CALL iom_swap( TRIM(cxios_context) )   ! return back to nemo context
       ENDIF
       !
Index: branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90
===================================================================
--- branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90	(revision 5259)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90	(revision 5299)
@@ -25,4 +25,5 @@
    USE divcur          ! hor. divergence and curl      (div & cur routines)
    USE sbc_ice, ONLY : lk_lim3
+   USE sbc_oce, ONLY : nn_components, jp_iam_opa
 
    IMPLICIT NONE
@@ -121,5 +122,5 @@
                      CALL iom_rstput( kt, nitrst, numrow, 'sshb'   , sshb      )
                      !
-      IF( lk_lim3 )  CALL iom_rstput( kt, nitrst, numrow, 'fse3t_b', fse3t_b(:,:,:) )
+      IF( lk_lim3 .OR. ( nn_components == jp_iam_opa ) )  CALL iom_rstput( kt, nitrst, numrow, 'fse3t_b', fse3t_b(:,:,:) )
                      !
                      CALL iom_rstput( kt, nitrst, numrow, 'un'     , un        )     ! now fields
@@ -134,5 +135,5 @@
                      CALL iom_rstput( kt, nitrst, numrow, 'rhd'    , rhd       )
 #endif
-                  IF( lk_lim3 ) THEN
+                  IF( lk_lim3 .OR. ( nn_components == jp_iam_opa ) ) THEN
                      CALL iom_rstput( kt, nitrst, numrow, 'fraqsr_1lev'  , fraqsr_1lev     ) !clem modif
                   ENDIF
@@ -214,5 +215,7 @@
          CALL iom_get( numror, jpdom_autoglo, 'hdivb'  , hdivb   )
          CALL iom_get( numror, jpdom_autoglo, 'sshb'   , sshb    )
-         IF( lk_lim3 )   CALL iom_get( numror, jpdom_autoglo, 'fse3t_b', fse3t_b(:,:,:) )
+! EM Attention Ceci doit etre reimplemente correctement
+!EM         IF( lk_lim3 .OR. ( nn_components == jp_iam_opa ) )   CALL iom_get( numror, jpdom_autoglo, 'fse3t_b', fse3t_b(:,:,:) )
+         CALL iom_get( numror, jpdom_autoglo, 'fse3t_b', fse3t_b(:,:,:) )
       ELSE
          neuler = 0
@@ -257,5 +260,5 @@
          ENDIF
 
-         IF( lk_lim3 .AND. .NOT. lk_vvl ) THEN
+         IF( ( lk_lim3 .OR. ( nn_components == jp_iam_opa ) ) .AND. .NOT. lk_vvl ) THEN
             DO jk = 1, jpk
                fse3t_b(:,:,jk) = fse3t_n(:,:,jk)
@@ -265,7 +268,8 @@
       ENDIF
       !
-      IF( lk_lim3 ) THEN
+!EM Idem
+!EM      IF( lk_lim3 .OR. ( nn_components == jp_iam_opa ) ) THEN
          CALL iom_get( numror, jpdom_autoglo, 'fraqsr_1lev' , fraqsr_1lev )
-      ENDIF
+!EM      ENDIF
       !
    END SUBROUTINE rst_read
Index: branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90
===================================================================
--- branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90	(revision 5259)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90	(revision 5299)
@@ -433,16 +433,24 @@
       !
       DO ji = 1, nsnd
-         DO jm = 1, ncplmodel
-            IF( ssnd(ji)%nid(1,jm) /= -1 ) THEN
-               IF( TRIM(cdfieldname) == TRIM(ssnd(ji)%clname) ) id = ssnd(ji)%nid(1,jm)
-            ENDIF
-         ENDDO
+         IF (ssnd(ji)%laction ) THEN
+            DO jm = 1, ncplmodel
+               IF( ssnd(ji)%nid(1,jm) /= -1 ) THEN
+                  IF( TRIM(cdfieldname) == TRIM(ssnd(ji)%clname) ) THEN
+                     id = ssnd(ji)%nid(1,jm)
+                  ENDIF
+               ENDIF
+            ENDDO
+         ENDIF
       ENDDO
       DO ji = 1, nrcv
-         DO jm = 1, ncplmodel
-            IF( srcv(ji)%nid(1,jm) /= -1 ) THEN
-               IF( TRIM(cdfieldname) == TRIM(srcv(ji)%clname) ) id = srcv(ji)%nid(1,jm)
-            ENDIF
-         ENDDO
+         IF (srcv(ji)%laction ) THEN
+            DO jm = 1, ncplmodel
+               IF( srcv(ji)%nid(1,jm) /= -1 ) THEN
+                  IF( TRIM(cdfieldname) == TRIM(srcv(ji)%clname) ) THEN
+                     id = srcv(ji)%nid(1,jm)
+                  ENDIF
+               ENDIF
+            ENDDO
+         ENDIF
       ENDDO
       !
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 5259)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 5299)
@@ -33,5 +33,5 @@
    USE cpl_oasis3      ! OASIS3 coupling
    USE geo2ocean       ! 
-   USE oce   , ONLY : tsn, un, vn, sshn, ub, vb, tsb, sshb
+   USE oce   , ONLY : tsn, un, vn, sshn, ub, vb, tsb, sshb, fraqsr_1lev
    USE albedo          !
    USE in_out_manager  ! I/O manager
@@ -98,7 +98,9 @@
    INTEGER, PARAMETER ::   jpr_ssh    = 39            ! sea surface height
    INTEGER, PARAMETER ::   jpr_fice   = 40            ! ice fraction          
-   INTEGER, PARAMETER ::   jprcv      = 40            ! total number of fields received
-
-   INTEGER, PARAMETER ::   jps_fice   =  1            ! ice fraction 
+   INTEGER, PARAMETER ::   jpr_e3t1st = 41            ! first T level thickness 
+   INTEGER, PARAMETER ::   jpr_fraqsr = 42            ! fraction of solar net radiation absorbed in the first ocean level
+   INTEGER, PARAMETER ::   jprcv      = 42            ! total number of fields received
+
+   INTEGER, PARAMETER ::   jps_fice   =  1            ! ice fraction sent to the atmosphere
    INTEGER, PARAMETER ::   jps_toce   =  2            ! ocean temperature
    INTEGER, PARAMETER ::   jps_tice   =  3            ! ice   temperature
@@ -125,6 +127,8 @@
    INTEGER, PARAMETER ::   jps_rnf    = 24            ! runoffs
    INTEGER, PARAMETER ::   jps_taum   = 25            ! wind stress module
-   INTEGER, PARAMETER ::   jps_fice2  = 26            ! ice fraction sent twice if atmos and ice coupled via OASIS
-   INTEGER, PARAMETER ::   jpsnd      = 26            ! total number of fields sended
+   INTEGER, PARAMETER ::   jps_fice2  = 26            ! ice fraction sent to OPA (by SAS when doing SAS-OPA coupling)
+   INTEGER, PARAMETER ::   jps_e3t1st = 27            ! first level depth (vvl)
+   INTEGER, PARAMETER ::   jps_fraqsr = 28            ! fraction of solar net radiation absorbed in the first ocean level
+   INTEGER, PARAMETER ::   jpsnd      = 28            ! total number of fields sended
 
    !                                                         !!** namelist namsbc_cpl **
@@ -156,4 +160,5 @@
 
    !! Substitution
+#  include "domzgr_substitute.h90"
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
@@ -229,8 +234,10 @@
       IF(lwm) WRITE ( numond, namsbc_cpl )
 
-      IF(lwp .AND. nn_components /= jp_iam_opa ) THEN                        ! control print
+      IF(lwp) THEN                        ! control print
          WRITE(numout,*)
          WRITE(numout,*)'sbc_cpl_init : namsbc_cpl namelist '
          WRITE(numout,*)'~~~~~~~~~~~~'
+      ENDIF
+      IF( lwp .AND. nn_components /= jp_iam_opa .AND. ln_cpl ) THEN                        ! control print
          WRITE(numout,*)'  received fields (mutiple ice categogies)'
          WRITE(numout,*)'      10m wind module                 = ', TRIM(sn_rcv_w10m%cldes  ), ' (', TRIM(sn_rcv_w10m%clcat  ), ')'
@@ -472,28 +479,17 @@
       srcv(jpr_sflx)%clname = 'O_SFLX'
       srcv(jpr_fice)%clname = 'RIceFrc'
-      !                                                      ! -------------------------------- !
-      !                                                      !   OPA-SAS coupling - rcv by sas  !   
-      !                                                      ! -------------------------------- !
-      srcv(jpr_toce)%clname = 'I_SSTSST'
-      srcv(jpr_soce)%clname = 'I_SSSal'
-      srcv(jpr_ocx1)%clname = 'I_OCurx1'
-      srcv(jpr_ocy1)%clname = 'I_OCury1'
-      srcv(jpr_ssh)%clname  = 'I_SSHght'
-
+      !
       IF( nn_components == jp_iam_opa ) THEN    ! OPA coupled to SAS via OASIS: force received field by OPA (sent by SAS)
          srcv(:)%laction = .FALSE.   ! force default definition in case of opa <-> sas coupling
-         srcv(jpr_fice )%laction = .TRUE.
-         srcv( (/jpr_taum, jpr_otx1, jpr_oty1 /) )%laction = .TRUE.
-         srcv(jpr_otx1)%clgrid  = 'U'        ! oce components given at U-point
-         srcv(jpr_oty1)%clgrid  = 'V'        !           and           V-point
+         srcv( (/jpr_qsroce, jpr_qnsoce, jpr_oemp, jpr_sflx, jpr_fice, jpr_otx1, jpr_oty1, jpr_taum/) )%laction = .TRUE.
+         srcv(jpr_otx1)%clgrid = 'U'        ! oce components given at U-point
+         srcv(jpr_oty1)%clgrid = 'V'        !           and           V-point
          sn_rcv_tau%clvgrd = 'U,V'
          sn_rcv_tau%clvor = 'local grid'
          sn_rcv_tau%clvref = 'spherical'
-         srcv( (/jpr_qsroce, jpr_qnsoce /) )%laction = .TRUE.
-         srcv( (/jpr_oemp, jpr_sflx/) )%laction = .TRUE.
          sn_rcv_emp%cldes = 'oce only'
+         !
          IF(lwp) THEN                        ! control print
             WRITE(numout,*)
-            WRITE(numout,*)'sbc_cpl_init : namsbc_cpl namelist '
             WRITE(numout,*)'               Special conditions for SAS-OPA coupling  '
             WRITE(numout,*)'               OPA component  '
@@ -509,8 +505,19 @@
             WRITE(numout,*)
          ENDIF
-      ELSE IF( nn_components == jp_iam_sas ) THEN
+      ENDIF
+      !                                                      ! -------------------------------- !
+      !                                                      !   OPA-SAS coupling - rcv by sas  !   
+      !                                                      ! -------------------------------- !
+      srcv(jpr_toce  )%clname = 'I_SSTSST'
+      srcv(jpr_soce  )%clname = 'I_SSSal'
+      srcv(jpr_ocx1  )%clname = 'I_OCurx1'
+      srcv(jpr_ocy1  )%clname = 'I_OCury1'
+      srcv(jpr_ssh   )%clname = 'I_SSHght'
+      srcv(jpr_e3t1st)%clname = 'I_E3T1st'   
+      srcv(jpr_fraqsr)%clname = 'I_FraQsr'   
+      !
+      IF( nn_components == jp_iam_sas ) THEN
          IF( .NOT. ln_cpl ) srcv(:)%laction = .FALSE.   ! force default definition in case of opa <-> sas coupling
-         srcv(jpr_toce )%laction = .TRUE. ; srcv(jpr_soce )%laction = .TRUE. ; srcv(jpr_ocx1 )%laction = .TRUE. ;
-         srcv(jpr_ocy1 )%laction = .TRUE. ; srcv(jpr_ssh  )%laction = .TRUE.
+         srcv( (/jpr_toce, jpr_soce, jpr_ssh, jpr_e3t1st, jpr_fraqsr, jpr_ocx1, jps_ocy1/) )%laction = .TRUE.
          ! Vectors: change of sign at north fold ONLY if on the local grid
          srcv(jpr_ocx1:jpr_ocy1)%nsgn = -1.
@@ -519,27 +526,28 @@
             IF ( srcv(jn)%clname(1:1) == "O" ) srcv(jn)%clname = "S"//srcv(jn)%clname(2:LEN(srcv(jn)%clname))
          END DO
+         !
          IF(lwp) THEN                        ! control print
+            WRITE(numout,*)
+            WRITE(numout,*)'               Special conditions for SAS-OPA coupling  '
+            WRITE(numout,*)'               SAS component  '
+            WRITE(numout,*)
             IF( .NOT. ln_cpl ) THEN
-               WRITE(numout,*)
-               WRITE(numout,*)'sbc_cpl_init : namsbc_cpl namelist '
-               WRITE(numout,*)'               Special conditions for SAS-OPA coupling  '
-               WRITE(numout,*)'               SAS component  '
-               WRITE(numout,*)
                WRITE(numout,*)'  received fields from OPA component '
             ELSE
-               WRITE(numout,*)
-               WRITE(numout,*)'               Special conditions for SAS-OPA coupling  '
-               WRITE(numout,*)'               SAS component  '
-               WRITE(numout,*)
                WRITE(numout,*)'  Additional received fields from OPA component : '
             ENDIF
-            WRITE(numout,*)'               sea surface temperature (T before, Celcius) '
+            WRITE(numout,*)'               sea surface temperature (Celcius) '
             WRITE(numout,*)'               sea surface salinity ' 
             WRITE(numout,*)'               surface currents ' 
             WRITE(numout,*)'               sea surface height ' 
+            WRITE(numout,*)'               thickness of first ocean T level '        
+            WRITE(numout,*)'               fraction of solar net radiation absorbed in the first ocean level'
             WRITE(numout,*)
          ENDIF
       ENDIF
-      ! Allocate all parts of frcv used for received fields
+      
+      ! =================================================== !
+      ! Allocate all parts of frcv used for received fields !
+      ! =================================================== !
       DO jn = 1, jprcv
          IF ( srcv(jn)%laction ) ALLOCATE( frcv(jn)%z3(jpi,jpj,srcv(jn)%nct) )
@@ -549,4 +557,7 @@
       ! Allocate w10m part of frcv which is used even when not received as coupling field
       IF ( .NOT. srcv(jpr_w10m)%laction ) ALLOCATE( frcv(jpr_w10m)%z3(jpi,jpj,srcv(jpr_w10m)%nct) )
+      ! Allocate jpr_otx1 part of frcv which is used even when not received as coupling field
+      IF ( .NOT. srcv(jpr_otx1)%laction ) ALLOCATE( frcv(jpr_otx1)%z3(jpi,jpj,srcv(jpr_otx1)%nct) )
+      IF ( .NOT. srcv(jpr_oty1)%laction ) ALLOCATE( frcv(jpr_oty1)%z3(jpi,jpj,srcv(jpr_oty1)%nct) )
       ! Allocate itx1 and ity1 as they are used in sbc_cpl_ice_tau even if srcv(jpr_itx1)%laction = .FALSE.
       IF( k_ice /= 0 ) THEN
@@ -666,6 +677,31 @@
       !                                                      !   OPA-SAS coupling - snd by opa !   
       !                                                      ! ------------------------------- !
-      ssnd(jps_ssh )%clname = 'O_SSHght' 
-      ssnd(jps_soce)%clname = 'O_SSSal' 
+      ssnd(jps_ssh   )%clname = 'O_SSHght' 
+      ssnd(jps_soce  )%clname = 'O_SSSal' 
+      ssnd(jps_e3t1st)%clname = 'O_E3T1st'   
+      ssnd(jps_fraqsr)%clname = 'O_FraQsr'
+      !
+      IF( nn_components == jp_iam_opa ) THEN
+         ssnd(:)%laction = .FALSE.   ! force default definition in case of opa <-> sas coupling
+         ssnd( (/jps_toce, jps_soce, jps_ssh, jps_e3t1st, jps_fraqsr, jps_ocx1, jps_ocy1/) )%laction = .TRUE.
+         ! vector definition: not used but cleaner...
+         ssnd(jps_ocx1)%clgrid  = 'U'        ! oce components given at U-point
+         ssnd(jps_ocy1)%clgrid  = 'V'        !           and           V-point
+         sn_snd_crt%clvgrd = 'U,V'
+         sn_snd_crt%clvor = 'local grid'
+         sn_snd_crt%clvref = 'spherical'
+         !
+         IF(lwp) THEN                        ! control print
+            WRITE(numout,*)
+            WRITE(numout,*)'  sent fields to SAS component '
+            WRITE(numout,*)'               sea surface temperature (T before, Celcius) '
+            WRITE(numout,*)'               sea surface salinity ' 
+            WRITE(numout,*)'               surface currents U,V on local grid and spherical coordinates' 
+            WRITE(numout,*)'               sea surface height ' 
+            WRITE(numout,*)'               thickness of first ocean T level '        
+            WRITE(numout,*)'               fraction of solar net radiation absorbed in the first ocean level'
+            WRITE(numout,*)
+         ENDIF
+      ENDIF
       !                                                      ! ------------------------------- !
       !                                                      !   OPA-SAS coupling - snd by sas !   
@@ -680,52 +716,30 @@
       ssnd(jps_rnf   )%clname = 'I_Runoff'   
       ssnd(jps_taum  )%clname = 'I_TauMod'   
-
-      ! NEMO coupled to sea ice with OASIS
-      IF( nn_components == jp_iam_opa ) THEN
-         ssnd(:)%laction = .FALSE.   ! force default definition in case of opa <-> sas coupling
-         ssnd( jps_ssh )%laction = .TRUE. ; ssnd(jps_soce)%laction = .TRUE.
-         ssnd( jps_toce )%laction = .TRUE. ; ssnd( (/jps_ocx1,jps_ocy1/) )%laction = .TRUE.
-         ssnd(jps_ocx1)%clgrid  = 'U'        ! oce components given at U-point
-         ssnd(jps_ocy1)%clgrid  = 'V'        !           and           V-point
-         sn_snd_crt%clvgrd = 'U,V'
-         sn_snd_crt%clvor = 'local grid'
-         sn_snd_crt%clvref = 'spherical'
-         IF(lwp) THEN                        ! control print
-            WRITE(numout,*)
-            WRITE(numout,*)'  sent fields to SAS component '
-            WRITE(numout,*)'               sea surface temperature (T before, Celcius) '
-            WRITE(numout,*)'               sea surface salinity ' 
-            WRITE(numout,*)'               surface currents U,V on local grid and spherical coordinates' 
-            WRITE(numout,*)'               sea surface height ' 
-            WRITE(numout,*)
-         ENDIF
-      ! Sea ice coupled to NEMO with OASIS
-      ELSE IF( nn_components == jp_iam_sas ) THEN
+      !
+      IF( nn_components == jp_iam_sas ) THEN
          IF( .NOT. ln_cpl ) ssnd(:)%laction = .FALSE.   ! force default definition in case of opa <-> sas coupling
-         ssnd(jps_qsroce)%laction = .TRUE. ; ssnd(jps_qnsoce)%laction = .TRUE. ; ssnd(jps_oemp)%laction = .TRUE. 
-         ssnd(jps_sflx  )%laction = .TRUE. ; ssnd(jps_otx1  )%laction = .TRUE. ; ssnd(jps_oty1)%laction = .TRUE. 
-         ssnd(jps_taum  )%laction = .TRUE. 
-         ssnd(jps_fice2)%laction = .TRUE.    ! fr_i defined in sas, even if nn_ice == 0
-         sn_snd_thick%clcat = 'no'
-         IF (.NOT. ln_cpl) ssnd(jps_fice)%laction = .FALSE.
+         ssnd( (/jps_qsroce, jps_qnsoce, jps_oemp, jps_fice2, jps_sflx, jps_otx1, jps_oty1, jps_taum/) )%laction = .TRUE.
+         !
          ! Change first letter to couple with atmosphere if already coupled with sea_ice
+         ! this is nedeed as each variable name used in the namcouple must be unique:
+         ! for example O_SSTSST sent by OPA to SAS and therefore S_SSTSST sent by SAS to the Atmosphere
          DO jn = 1, jpsnd
             IF ( ssnd(jn)%clname(1:1) == "O" ) ssnd(jn)%clname = "S"//ssnd(jn)%clname(2:LEN(ssnd(jn)%clname))
          END DO
+         !
          IF(lwp) THEN                        ! control print
+            WRITE(numout,*)
             IF( .NOT. ln_cpl ) THEN
-               WRITE(numout,*)
                WRITE(numout,*)'  sent fields to OPA component '
             ELSE
-               WRITE(numout,*)
                WRITE(numout,*)'  Additional sent fields to OPA component : '
-               WRITE(numout,*)'                  ice cover '
-               WRITE(numout,*)'                  oce only EMP  '
-               WRITE(numout,*)'                  salt flux  '
-               WRITE(numout,*)'                  mixed oce-ice solar flux  '
-               WRITE(numout,*)'                  mixed oce-ice non solar flux  '
-               WRITE(numout,*)'                  wind stress U,V components'
-               WRITE(numout,*)'                  wind stress module'
             ENDIF
+            WRITE(numout,*)'                  ice cover '
+            WRITE(numout,*)'                  oce only EMP  '
+            WRITE(numout,*)'                  salt flux  '
+            WRITE(numout,*)'                  mixed oce-ice solar flux  '
+            WRITE(numout,*)'                  mixed oce-ice non solar flux  '
+            WRITE(numout,*)'                  wind stress U,V components'
+            WRITE(numout,*)'                  wind stress module'
          ENDIF
       ENDIF
@@ -891,5 +905,4 @@
          !
       ENDIF
-      
       !                                                      ! ========================= !
       !                                                      !    wind stress module     !   (taum)
@@ -920,5 +933,5 @@
          ENDIF
       ENDIF
-      
+      !
       !                                                      ! ========================= !
       !                                                      !      10 m wind speed      !   (wndm)
@@ -984,16 +997,30 @@
       !                                                      !        SSH         !
       !                                                      ! ================== !
-      IF( srcv(jpr_ssh )%laction )   ssh_m(:,:) = frcv(jpr_ssh )%z3(:,:,1)
-      
+      IF( srcv(jpr_ssh )%laction ) THEN                      ! received by sas in case of opa <-> sas coupling
+         ssh_m(:,:) = frcv(jpr_ssh )%z3(:,:,1)
+         sshn( :,:) = ssh_m(:,:)
+      ENDIF
       !                                                      ! ================== !
       !                                                      !  surface currents  !
       !                                                      ! ================== !
-      IF( srcv(jpr_ocx1)%laction ) THEN
+      IF( srcv(jpr_ocx1)%laction ) THEN                      ! received by sas in case of opa <-> sas coupling
          ssu_m(:,:) = frcv(jpr_ocx1)%z3(:,:,1)
-         ub (:,:,1       ) = ssu_m(:,:)
+         ub (:,:,1) = ssu_m(:,:)
       ENDIF
       IF( srcv(jpr_ocy1)%laction ) THEN
          ssv_m(:,:) = frcv(jpr_ocy1)%z3(:,:,1)
-         vb (:,:,1       ) = ssv_m(:,:)
+         vb (:,:,1) = ssv_m(:,:)
+      ENDIF
+      !                                                      ! ======================== !
+      !                                                      !  first T level thickness !
+      !                                                      ! ======================== !
+      IF( srcv(jpr_e3t1st )%laction ) THEN                   ! received by sas in case of opa <-> sas coupling
+         fse3t_m(:,:) = frcv(jpr_e3t1st )%z3(:,:,1)
+      ENDIF
+      !                                                      ! ================================ !
+      !                                                      !  fraction of solar net radiation !
+      !                                                      ! ================================ !
+      IF( srcv(jpr_fraqsr)%laction ) THEN                      ! received by sas in case of opa <-> sas coupling
+         fraqsr_1lev(:,:) = frcv(jpr_fraqsr)%z3(:,:,1)
       ENDIF
       
@@ -1153,5 +1180,4 @@
             !
          ENDIF
-
          !                                                      ! ======================= !
          !                                                      !     put on ice grid     !
@@ -1584,4 +1610,5 @@
       INTEGER ::   ji, jj, jl   ! dummy loop indices
       INTEGER ::   isec, info   ! local integer
+      REAL(wp) ::   zumax, zvmax
       REAL(wp), POINTER, DIMENSION(:,:)   ::   zfr_l, ztmp1, ztmp2, zotx1, zoty1, zotz1, zitx1, zity1, zitz1
       REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztmp3, ztmp4   
@@ -1601,5 +1628,5 @@
       IF( ssnd(jps_toce)%laction .OR. ssnd(jps_tice)%laction .OR. ssnd(jps_tmix)%laction ) THEN
          IF ( nn_components == jp_iam_opa ) THEN
-            ztmp1(:,:) = tsb(:,:,1,jp_tem)
+            ztmp1(:,:) = tsn(:,:,1,jp_tem)
          ELSE
             SELECT CASE( sn_snd_temp%cldes)
@@ -1645,6 +1672,6 @@
       !                                                      !  Ice fraction & Thickness ! 
       !                                                      ! ------------------------- !
-      ! Send ice fraction field 
-      IF( ssnd(jps_fice)%laction .OR. ssnd(jps_fice2)%laction ) THEN
+      ! Send ice fraction field to atmosphere
+      IF( ssnd(jps_fice)%laction ) THEN
          SELECT CASE( sn_snd_thick%clcat )
          CASE( 'yes' )   ;   ztmp3(:,:,1:jpl) =  a_i(:,:,1:jpl)
@@ -1652,5 +1679,10 @@
          CASE default    ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_thick%clcat' )
          END SELECT
-         IF( ssnd(jps_fice )%laction )   CALL cpl_snd( jps_fice , isec, ztmp3, info )
+         IF( ssnd(jps_fice)%laction )   CALL cpl_snd( jps_fice, isec, ztmp3, info )
+      ENDIF
+      
+      ! Send ice fraction field to OPA (sent by SAS in SAS-OPA coupling)
+      IF( ssnd(jps_fice2)%laction ) THEN
+         ztmp3(:,:,1) = fr_i(:,:)
          IF( ssnd(jps_fice2)%laction )   CALL cpl_snd( jps_fice2, isec, ztmp3, info )
       ENDIF
@@ -1702,6 +1734,6 @@
          !                                                               i      i+1 (for I)
          IF( nn_components == jp_iam_opa ) THEN
-            zotx1(:,:) = ub(:,:,1)  
-            zoty1(:,:) = vb(:,:,1)  
+            zotx1(:,:) = un(:,:,1)  
+            zoty1(:,:) = vn(:,:,1)  
          ELSE        
             SELECT CASE( TRIM( sn_snd_crt%cldes ) )
@@ -1826,5 +1858,5 @@
       !
       !
-      !  Fields sent to ice by ocean model when OASIS coupling
+      !  Fields sent to SAS by OPA when doing OPA<->SAS coupling
       !                                                        ! SSH
       IF( ssnd(jps_ssh )%laction )  THEN
@@ -1832,5 +1864,5 @@
          !                          forcing is used (for sea-ice dynamics)
          IF( ln_apr_dyn ) THEN   ;   ztmp1(:,:) = sshb(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) )
-         ELSE                    ;   ztmp1(:,:) = sshb(:,:)
+         ELSE                    ;   ztmp1(:,:) = sshn(:,:)
          ENDIF
          CALL cpl_snd( jps_ssh, isec, RESHAPE ( ztmp1, (/jpi,jpj,1/) ), info )
@@ -1838,7 +1870,17 @@
       ENDIF
       !                                                        ! SSS
-      IF( ssnd(jps_soce)%laction )  THEN
-         ztmp1(:,:) =   tsb(:,:,1,jp_sal)
-         CALL cpl_snd( jps_soce, isec, RESHAPE ( ztmp1, (/jpi,jpj,1/) ), info )
+      IF( ssnd(jps_soce  )%laction )  THEN
+         ztmp1(:,:) =  tsn(:,:,1,jp_sal)
+         CALL cpl_snd( jps_soce ,  isec, RESHAPE ( ztmp1, (/jpi,jpj,1/) ), info )
+      ENDIF
+      !                                                        ! first T level thickness 
+      IF( ssnd(jps_e3t1st )%laction )  THEN
+         ztmp1(:,:) =  fse3t_n(:,:,1)
+         CALL cpl_snd( jps_e3t1st,  isec, RESHAPE ( ztmp1, (/jpi,jpj,1/) ), info )
+      ENDIF
+      !                                                        ! Qsr fraction
+      IF( ssnd(jps_fraqsr)%laction )  THEN
+         ztmp1(:,:) =  fraqsr_1lev(:,:) 
+         CALL cpl_snd( jps_fraqsr, isec, RESHAPE ( ztmp1, (/jpi,jpj,1/) ), info )
       ENDIF
       !
Index: branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90
===================================================================
--- branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 5259)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 5299)
@@ -309,26 +309,6 @@
 
 
-      IF( nn_components /= jp_iam_sas ) THEN
-
-                               CALL sbc_ssm_init               ! Sea-surface mean fields initialisation
-      ELSE
-      !
-      ! sas currently uses surface temperature and salinity in tsn array
-      ! for initialisation
-      ! and ub, vb arrays in ice dynamics
-      ! so allocate enough of arrays to use
-      !
-         ierr3 = 0
-         jpm = MAX(jp_tem, jp_sal)
-         ALLOCATE( tsn(jpi,jpj,1,jpm), STAT=ierr0 )
-         ALLOCATE( ub(jpi,jpj,1)     , STAT=ierr1 )
-         ALLOCATE( vb(jpi,jpj,1)     , STAT=ierr2 )
-         IF ( nn_ice == 1 ) ALLOCATE( tsb(jpi,jpj,1,jpm), STAT=ierr3 )
-         ierr = ierr0 + ierr1 + ierr2 + ierr3
-         IF( ierr > 0 ) THEN
-            CALL ctl_stop('sbc_ssm_init: unable to allocate surface arrays')
-         ENDIF
-
-      ENDIF
+      IF( nn_components /= jp_iam_sas )   &
+         &                     CALL sbc_ssm_init               ! Sea-surface mean fields initialisation
       !
       IF( ln_ssr           )   CALL sbc_ssr_init               ! Sea-Surface Restoring initialisation
@@ -393,6 +373,6 @@
       CASE( jp_clio  )   ;   CALL sbc_blk_clio( kt )                    ! bulk formulation : CLIO for the ocean
       CASE( jp_core  )   
-                             IF( nn_components == jp_iam_sas ) &
-                                CALL sbc_cpl_rcv ( kt, nn_fsbc, nn_ice )     !  OASIS-coupled ice
+         IF( nn_components == jp_iam_sas ) &
+            &                CALL sbc_cpl_rcv ( kt, nn_fsbc, nn_ice )   ! OPA-SAS coupling: SAS receiving fields from OPA 
                              CALL sbc_blk_core( kt )                    ! bulk formulation : CORE for the ocean
                                                                         ! from oce: sea surface variables (sst_m, sss_m,  ssu_m,  ssv_m)
@@ -400,7 +380,7 @@
                                                                         !
       CASE( jp_mfs   )   ;   CALL sbc_blk_mfs ( kt )                    ! bulk formulation : MFS for the ocean
-      CASE( jp_none  )   ;   CALL sbc_cpl_rcv ( kt, nn_fsbc, nn_ice )   ! OASIS-coupled ice
-                                                         ! fluxes qsr, qns, emp, sfx,utau, vtau
-                                                         ! sss_m, ssu_m, ssv_m)
+      CASE( jp_none  ) 
+         IF( nn_components == jp_iam_opa ) &
+                             CALL sbc_cpl_rcv ( kt, nn_fsbc, nn_ice )   ! OPA-SAS coupling: OPA receiving fields from SAS
       CASE( jp_esopa )                                
                              CALL sbc_ana     ( kt )                    ! ESOPA, test ALL the formulations
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 5259)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcssm.F90	(revision 5299)
@@ -58,34 +58,18 @@
       REAL(wp) ::   zcoef, zf_sbc       ! local scalar
       REAL(wp), DIMENSION(jpi,jpj,jpts) :: zts
-      REAL(wp), DIMENSION(jpi,jpj)      :: zub, zvb,zdep
       !!---------------------------------------------------------------------
       
       !                                        !* surface T-, U-, V- ocean level variables (T, S, depth, velocity)
-      IF( nn_components == jp_iam_opa ) THEN
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               zts(ji,jj,jp_tem) = tsb(ji,jj,mikt(ji,jj),jp_tem)
-               zts(ji,jj,jp_sal) = tsb(ji,jj,mikt(ji,jj),jp_sal)
-            END DO
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zts(ji,jj,jp_tem) = tsn(ji,jj,mikt(ji,jj),jp_tem)
+            zts(ji,jj,jp_sal) = tsn(ji,jj,mikt(ji,jj),jp_sal)
          END DO
-      ELSE
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               zts(ji,jj,jp_tem) = tsb(ji,jj,mikt(ji,jj),jp_tem)
-               zts(ji,jj,jp_sal) = tsb(ji,jj,mikt(ji,jj),jp_sal)
-            END DO
-         END DO
-      ENDIF
-      zub(:,:)        = ub (:,:,1       )
-      zvb(:,:)        = vb (:,:,1       )
-      !
-      IF( lk_vvl ) THEN
-         zdep(:,:) = fse3t_n(:,:,1)
-      ENDIF
-      !                                                   ! ---------------------------------------- !
+      END DO
+      !
       IF( nn_fsbc == 1 ) THEN                             !   Instantaneous surface fields        !
          !                                                ! ---------------------------------------- !
-         ssu_m(:,:) = zub(:,:)
-         ssv_m(:,:) = zvb(:,:)
+         ssu_m(:,:) = ub(:,:,1)
+         ssv_m(:,:) = vb(:,:,1)
          IF( ln_useCT )  THEN    ;   sst_m(:,:) = eos_pt_from_ct( zts(:,:,jp_tem), zts(:,:,jp_sal) )
          ELSE                    ;   sst_m(:,:) = zts(:,:,jp_tem)
@@ -93,15 +77,9 @@
          sss_m(:,:) = zts(:,:,jp_sal)
          !                          ! removed inverse barometer ssh when Patm forcing is used (for sea-ice dynamics)
-         IF( nn_components == jp_iam_opa ) THEN
-            IF( ln_apr_dyn ) THEN   ;   ssh_m(:,:) = sshb(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) )
-            ELSE                    ;   ssh_m(:,:) = sshb(:,:)
-            ENDIF
-         ELSE
-            IF( ln_apr_dyn ) THEN   ;   ssh_m(:,:) = sshn(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) )
-            ELSE                    ;   ssh_m(:,:) = sshn(:,:)
-            ENDIF
-         ENDIF
-         !
-         IF( lk_vvl )   fse3t_m(:,:) = zdep(:,:)
+         IF( ln_apr_dyn ) THEN   ;   ssh_m(:,:) = sshn(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) )
+         ELSE                    ;   ssh_m(:,:) = sshn(:,:)
+         ENDIF
+         !
+         IF( lk_vvl )   fse3t_m(:,:) = fse3t_n(:,:,1)
          !
       ELSE
@@ -112,6 +90,6 @@
             IF(lwp) WRITE(numout,*) '~~~~~~~   mean fields initialised to instantaneous values'
             zcoef = REAL( nn_fsbc - 1, wp )
-            ssu_m(:,:) = zcoef * zub(:,:)
-            ssv_m(:,:) = zcoef * zvb(:,:)
+            ssu_m(:,:) = zcoef * ub(:,:,1)
+            ssv_m(:,:) = zcoef * vb(:,:,1)
             IF( ln_useCT )  THEN    ;   sst_m(:,:) = zcoef * eos_pt_from_ct( zts(:,:,jp_tem), zts(:,:,jp_sal) )
             ELSE                    ;   sst_m(:,:) = zcoef * zts(:,:,jp_tem)
@@ -119,15 +97,9 @@
             sss_m(:,:) = zcoef * zts(:,:,jp_sal)
             !                          ! removed inverse barometer ssh when Patm forcing is used (for sea-ice dynamics)
-            IF( nn_components == jp_iam_opa ) THEN
-               IF( ln_apr_dyn ) THEN   ;   ssh_m(:,:) = zcoef * ( sshb(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) ) )
-               ELSE                    ;   ssh_m(:,:) = zcoef * sshb(:,:)
-               ENDIF
-            ELSE
-               IF( ln_apr_dyn ) THEN   ;   ssh_m(:,:) = zcoef * ( sshn(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) ) )
-               ELSE                    ;   ssh_m(:,:) = zcoef * sshn(:,:)
-               ENDIF
+            IF( ln_apr_dyn ) THEN   ;   ssh_m(:,:) = zcoef * ( sshn(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) ) )
+            ELSE                    ;   ssh_m(:,:) = zcoef * sshn(:,:)
             ENDIF
             !
-            IF( lk_vvl )   fse3t_m(:,:) = zcoef * zdep(:,:)
+            IF( lk_vvl )   fse3t_m(:,:) = zcoef * fse3t_n(:,:,1)
             !                                             ! ---------------------------------------- !
          ELSEIF( MOD( kt - 2 , nn_fsbc ) == 0 ) THEN      !   Initialisation: New mean computation   !
@@ -143,6 +115,6 @@
          !                                                !        Cumulate at each time step        !
          !                                                ! ---------------------------------------- !
-         ssu_m(:,:) = ssu_m(:,:) + zub(:,:)
-         ssv_m(:,:) = ssv_m(:,:) + zvb(:,:)
+         ssu_m(:,:) = ssu_m(:,:) + ub(:,:,1)
+         ssv_m(:,:) = ssv_m(:,:) + vb(:,:,1)
          IF( ln_useCT )  THEN    ;   sst_m(:,:) = sst_m(:,:) + eos_pt_from_ct( zts(:,:,jp_tem), zts(:,:,jp_sal) )
          ELSE                    ;   sst_m(:,:) = sst_m(:,:) + zts(:,:,jp_tem)
@@ -150,15 +122,9 @@
          sss_m(:,:) = sss_m(:,:) + zts(:,:,jp_sal)
          !                          ! removed inverse barometer ssh when Patm forcing is used (for sea-ice dynamics)
-         IF( nn_components == jp_iam_opa ) THEN
-            IF( ln_apr_dyn ) THEN   ;   ssh_m(:,:) = ssh_m(:,:) + sshb(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) )
-            ELSE                    ;   ssh_m(:,:) = ssh_m(:,:) + sshb(:,:)
-            ENDIF
-         ELSE
-            IF( ln_apr_dyn ) THEN   ;   ssh_m(:,:) = ssh_m(:,:) + sshb(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) )
-            ELSE                    ;   ssh_m(:,:) = ssh_m(:,:) + sshb(:,:)
-            ENDIF
-         ENDIF
-         !
-         IF( lk_vvl )   fse3t_m(:,:) = fse3t_m(:,:) + zdep(:,:)
+         IF( ln_apr_dyn ) THEN   ;   ssh_m(:,:) = ssh_m(:,:) + sshn(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) )
+         ELSE                    ;   ssh_m(:,:) = ssh_m(:,:) + sshn(:,:)
+         ENDIF
+         !
+         IF( lk_vvl )   fse3t_m(:,:) = fse3t_m(:,:) + fse3t_n(:,:,1)
 
          !                                                ! ---------------------------------------- !
Index: branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/TRA/traqsr.F90
===================================================================
--- branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/TRA/traqsr.F90	(revision 5259)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/OPA_SRC/TRA/traqsr.F90	(revision 5299)
@@ -233,5 +233,5 @@
                END DO
                ! clem: store attenuation coefficient of the first ocean level
-               IF ( lk_lim3 .AND. ln_qsr_ice ) THEN
+               IF ( ln_qsr_ice ) THEN
                   DO jj = 1, jpj
                      DO ji = 1, jpi
@@ -256,5 +256,5 @@
                END DO
                ! clem: store attenuation coefficient of the first ocean level
-               IF ( lk_lim3 .AND. ln_qsr_ice ) THEN
+               IF ( ln_qsr_ice ) THEN
                   fraqsr_1lev(:,:) = etot3(:,:,1) / r1_rau0_rcp
                ENDIF
@@ -279,5 +279,5 @@
                END DO
                ! clem: store attenuation coefficient of the first ocean level
-               IF ( lk_lim3 .AND. ln_qsr_ice ) THEN
+               IF ( ln_qsr_ice ) THEN
                   DO jj = 1, jpj
                      DO ji = 1, jpi
@@ -298,5 +298,5 @@
                END DO
                ! clem: store attenuation coefficient of the first ocean level
-               IF ( lk_lim3 .AND. ln_qsr_ice ) THEN
+               IF ( ln_qsr_ice ) THEN
                   fraqsr_1lev(:,:) = etot3(:,:,1) / r1_rau0_rcp
                ENDIF
Index: branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/SAS_SRC/daymod.F90
===================================================================
--- branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/SAS_SRC/daymod.F90	(revision 5259)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/SAS_SRC/daymod.F90	(revision 5299)
@@ -131,5 +131,5 @@
 
       ! control print
-      IF(lwp) WRITE(numout,'(a,i6,a,i2,a,i2,a,i6)')' ==============>> 1/2 time step before the start of the run DATE Y/M/D = ',   &
+      IF(lwp) WRITE(numout,'(a,i6,a,i2,a,i2,a,i8,a,i8)')' =======>> 1/2 time step before the start of the run DATE Y/M/D = ',   &
            &                   nyear, '/', nmonth, '/', nday, '  nsec_day:', nsec_day, '  nsec_week:', nsec_week
 
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 5259)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/SAS_SRC/nemogcm.F90	(revision 5299)
@@ -97,5 +97,12 @@
       !                            !-----------------------!
 #if defined key_agrif
-      CALL Agrif_Declare_Var       ! AGRIF: set the meshes
+      CALL Agrif_Declare_Var_dom   ! AGRIF: set the meshes for DOM
+      CALL Agrif_Declare_Var       !  "      "   "   "      "  DYN/TRA 
+# if defined key_top
+      CALL Agrif_Declare_Var_top   !  "      "   "   "      "  TOP
+# endif
+# if defined key_lim2
+      CALL Agrif_Declare_Var_lim2  !  "      "   "   "      "  LIM
+# endif
 #endif
       ! check that all process are still there... If some process have an error,
@@ -119,4 +126,7 @@
          IF( lk_mpp )   CALL mpp_max( nstop )
       END DO
+      !
+      IF( ln_icebergs )   CALL icb_end( nitend )
+
       !                            !------------------------!
       !                            !==  finalize the run  ==!
@@ -137,4 +147,5 @@
       !
       CALL nemo_closefile
+      !
 #if defined key_iomput
       CALL xios_finalize                ! end mpp communications with xios
@@ -160,7 +171,6 @@
       INTEGER ::   ilocal_comm   ! local integer      
       INTEGER ::   ios
-
       CHARACTER(len=80), DIMENSION(16) ::   cltxt
-      !!
+      !
       NAMELIST/namctl/ ln_ctl  , nn_print, nn_ictls, nn_ictle,   &
          &             nn_isplt, nn_jsplt, nn_jctls, nn_jctle,   &
@@ -169,4 +179,5 @@
          &             jpizoom, jpjzoom, jperio, ln_use_jattr
       !!----------------------------------------------------------------------
+      !
       cltxt = ''
       cxios_context = 'sas'
@@ -198,4 +209,21 @@
 904   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in configuration namelist', .TRUE. )   
 
+! Force values for AGRIF zoom (cf. agrif_user.F90)
+#if defined key_agrif
+   IF( .NOT. Agrif_Root() ) THEN
+      jpiglo  = nbcellsx + 2 + 2*nbghostcells
+      jpjglo  = nbcellsy + 2 + 2*nbghostcells
+      jpi     = ( jpiglo-2*jpreci + (jpni-1+0) ) / jpni + 2*jpreci
+      jpj     = ( jpjglo-2*jprecj + (jpnj-1+0) ) / jpnj + 2*jprecj
+      jpidta  = jpiglo
+      jpjdta  = jpjglo
+      jpizoom = 1
+      jpjzoom = 1
+      nperio  = 0
+      jperio  = 0
+      ln_use_jattr = .false.
+   ENDIF
+#endif
+      !
       !                             !--------------------------------------------!
       !                             !  set communicator & select the local node  !
@@ -253,10 +281,12 @@
       ! than variables
       IF( Agrif_Root() ) THEN
+#if defined key_nemocice_decomp
+         jpi = ( nx_global+2-2*jpreci + (jpni-1) ) / jpni + 2*jpreci ! first  dim.
+         jpj = ( ny_global+2-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj ! second dim. 
+#else
          jpi = ( jpiglo-2*jpreci + (jpni-1) ) / jpni + 2*jpreci   ! first  dim.
-#if defined key_nemocice_decomp
-         jpj = ( jpjglo+1-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj ! second dim. 
-#else
          jpj = ( jpjglo-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj   ! second dim.
 #endif
+      ENDIF
          jpk = jpkdta                                             ! third dim
          jpim1 = jpi-1                                            ! inner domain indices
@@ -264,5 +294,4 @@
          jpkm1 = jpk-1                                            !   "           "
          jpij  = jpi*jpj                                          !  jpi x j
-      ENDIF
 
       IF(lwp) THEN                            ! open listing units
@@ -423,4 +452,8 @@
       ENDIF
       !
+      IF( 1_wp /= SIGN(1._wp,-0._wp)  )   CALL ctl_stop( 'nemo_ctl: The intrinsec SIGN function follows ',  &
+         &                                               'f2003 standard. '                              ,  &
+         &                                               'Compile with key_nosignedzero enabled' )
+      !
    END SUBROUTINE nemo_ctl
 
@@ -464,5 +497,6 @@
       USE oce       , ONLY : sshn, sshb, snwice_mass, snwice_mass_b, snwice_fmass 
       !
-      INTEGER :: ierr,ierr4
+      INTEGER :: ierr,ierr1,ierr2,ierr3,ierr4,ierr5,ierr6,ierr7
+      INTEGER :: jpm
       !!----------------------------------------------------------------------
       !
@@ -471,5 +505,14 @@
       ALLOCATE( snwice_mass(jpi,jpj)  , snwice_mass_b(jpi,jpj),             &
          &      snwice_fmass(jpi,jpj), STAT= ierr4 )
-      ierr = ierr + ierr4
+
+      jpm = MAX(jp_tem, jp_sal)
+      ALLOCATE( tsn(jpi,jpj,1,jpm)  , STAT=ierr2 )
+      ALLOCATE( ub(jpi,jpj,1)       , STAT=ierr3 )
+      ALLOCATE( vb(jpi,jpj,1)       , STAT=ierr4 )
+      ALLOCATE( tsb(jpi,jpj,1,jpm)  , STAT=ierr5 )
+      ALLOCATE( sshn(jpi,jpj)       , STAT=ierr6 )
+      ALLOCATE( fraqsr_1lev(jpi,jpj), STAT=ierr7 )
+
+      ierr = ierr + ierr1 + ierr2 + ierr3 + ierr4 + ierr5 + ierr6 + ierr7
       !
       IF( lk_mpp    )   CALL mpp_sum( ierr )
@@ -496,9 +539,9 @@
       INTEGER, DIMENSION(nfactmax) :: ifact ! Array of factors
       !!----------------------------------------------------------------------
-
+      !
       ierr = 0
-
+      !
       CALL factorise( ifact, nfactmax, nfact, num_pes, ierr )
-
+      !
       IF( nfact <= 1 ) THEN
          WRITE (numout, *) 'WARNING: factorisation of number of PEs failed'
@@ -542,5 +585,5 @@
       INTEGER, PARAMETER :: ntest = 14
       INTEGER :: ilfax(ntest)
-
+      !
       ! lfax contains the set of allowed factors.
       data (ilfax(jl),jl=1,ntest) / 16384, 8192, 4096, 2048, 1024, 512, 256,  &
@@ -627,16 +670,16 @@
           !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
@@ -645,6 +688,18 @@
                    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.
Index: branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/SAS_SRC/step.F90
===================================================================
--- branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/SAS_SRC/step.F90	(revision 5259)
+++ branches/2015/dev_r5218_CNRS17_coupling/NEMOGCM/NEMO/SAS_SRC/step.F90	(revision 5299)
@@ -17,4 +17,6 @@
    USE dom_oce          ! ocean space and time domain variables 
    USE in_out_manager   ! I/O manager
+   USE sbc_oce
+   USE sbccpl
    USE iom              !
    USE lbclnk
@@ -86,4 +88,9 @@
                                                           ! need to keep the same interface 
                              CALL stp_ctl( kstp, indic )
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Coupled mode
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( lk_oasis    )  CALL sbc_cpl_snd( kstp )     ! coupled mode : field exchanges if OASIS-coupled ice
+
 #if defined key_iomput
       IF( kstp == nitend .OR. indic < 0 ) THEN 
