Index: /branches/dev_003_CPL/CONFIG/ORCA2_LIM/EXP00/namelist
===================================================================
--- /branches/dev_003_CPL/CONFIG/ORCA2_LIM/EXP00/namelist	(revision 990)
+++ /branches/dev_003_CPL/CONFIG/ORCA2_LIM/EXP00/namelist	(revision 991)
@@ -300,4 +300,24 @@
 !-----------------------------------------------------------------------
 &namsbc_cpl
+! SEND
+cn_snd_temperature = 'oce only'              ! 'oce only' 'weighted oce and ice' 'mixed oce-ice'
+cn_snd_albedo      = 'none'                  ! 'none' 'weighted ice' 'mixed oce-ice'
+cn_snd_thickness   = 'weighted ice and snow' ! 'none' 'weighted ice and snow'
+cn_snd_current(1)  = 'none'                  ! 'none' 'oce only' 'weighted oce and ice' 'mixed oce-ice'
+cn_snd_current(2)  = 'spherical'             ! 'spherical' 'cartesian'
+cn_snd_current(3)  = 'eastward-northward'    ! 'eastward-northward' or 'local grid'
+cn_snd_current(4)  = 'T'                     ! 'T''U,V'
+! RECEIVE
+cn_rcv_w10m       = 'coupled'               ! 'none' 'coupled'
+cn_rcv_stress(1)  = 'oce and ice'           ! 'oce only' 'oce and ice' 'mixed oce-ice'
+cn_rcv_stress(2)  = 'spherical'             ! 'spherical' 'cartesian'
+cn_rcv_stress(3)  = 'eastward-northward'    ! 'eastward-northward' or 'local grid'
+cn_rcv_stress(4)  = 'U,V,F'                 ! 'T' 'U,V' 'U,V,F' 'U,V,I' 'T,F' 'T,I' 'T,U,V'
+cn_rcv_dqnsdt     = 'coupled'               ! 'none' 'coupled'
+cn_rcv_qsr        = 'conservative'          ! 'conservative' 'oce and ice' 'mixed oce-ice'
+cn_rcv_qns        = 'conservative'          ! 'conservative' 'oce and ice' 'mixed oce-ice'
+cn_rcv_emp        = 'conservative'          ! 'conservative' 'oce and ice' 'mixed oce-ice'
+cn_rcv_runoff     = 'climato'               ! 'coupled' 'climato' 'mixed'
+cn_rcv_calving    = 'none'                  ! 'none' 'coupled'
 /
 !-----------------------------------------------------------------------
Index: /branches/dev_003_CPL/NEMO/LIM_SRC_2/ice_2.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/LIM_SRC_2/ice_2.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/LIM_SRC_2/ice_2.F90	(revision 991)
@@ -80,9 +80,5 @@
    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qfvbq         !: Array used to store energy in case of toral lateral ablation (?)
    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   dmgwi         !: Variation of the mass of snow ice
-
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   albege        !: Albedo of the snow or ice (only for outputs)
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   albecn        !: Albedo of the ocean (only for outputs)
    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   tauc          !: Cloud optical depth
-
    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   ui_ice, vi_ice   !: two components of the ice   velocity at I-point (m/s)
    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   ui_oce, vi_oce   !: two components of the ocean velocity at I-point (m/s)
Index: /branches/dev_003_CPL/NEMO/LIM_SRC_2/iceini_2.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/LIM_SRC_2/iceini_2.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/LIM_SRC_2/iceini_2.F90	(revision 991)
@@ -73,10 +73,4 @@
          CALL lim_rst_read_2          ! start from a restart file
       ENDIF
-      
-      tn_ice(:,:) = sist(:,:)         ! initialisation of ice temperature   
-      freeze(:,:) = 1.0 - frld(:,:)   ! initialisation of sea/ice cover    
-# if defined key_coupled
-      alb_ice(:,:) = albege(:,:)      ! sea-ice albedo
-# endif
       !
    END SUBROUTINE ice_init_2
Index: /branches/dev_003_CPL/NEMO/LIM_SRC_2/limistate_2.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/LIM_SRC_2/limistate_2.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/LIM_SRC_2/limistate_2.F90	(revision 991)
@@ -113,7 +113,4 @@
       ui_ice(:,:)   = 0.e0
       vi_ice(:,:)   = 0.e0
-# if defined key_coupled
-      albege(:,:)   = 0.8 * tms(:,:)
-# endif
 
       !---  Moments for advection.             
Index: /branches/dev_003_CPL/NEMO/LIM_SRC_2/limrst_2.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/LIM_SRC_2/limrst_2.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/LIM_SRC_2/limrst_2.F90	(revision 991)
@@ -112,7 +112,4 @@
       CALL iom_rstput( iter, nitrst, numriw, 'frld'  , frld  (:,:)   )
       CALL iom_rstput( iter, nitrst, numriw, 'sist'  , sist  (:,:)   )
-# if defined key_coupled
-      CALL iom_rstput( iter, nitrst, numriw, 'albege', albege(:,:) )
-# endif
       CALL iom_rstput( iter, nitrst, numriw, 'tbif1' , tbif  (:,:,1) )
       CALL iom_rstput( iter, nitrst, numriw, 'tbif2' , tbif  (:,:,2) )
@@ -198,7 +195,4 @@
       CALL iom_get( numrir, jpdom_autoglo, 'frld'  , frld   )    
       CALL iom_get( numrir, jpdom_autoglo, 'sist'  , sist   )    
-# if defined key_coupled 
-      CALL iom_get( numrir, jpdom_autoglo, 'albege', albege )    
-# endif
       CALL iom_get( numrir, jpdom_autoglo, 'tbif1' , tbif(:,:,1) )    
       CALL iom_get( numrir, jpdom_autoglo, 'tbif2' , tbif(:,:,2) )    
Index: /branches/dev_003_CPL/NEMO/LIM_SRC_2/limsbc_2.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/LIM_SRC_2/limsbc_2.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/LIM_SRC_2/limsbc_2.F90	(revision 991)
@@ -83,8 +83,6 @@
       REAL(wp) ::   zutau , zvtau    ! lead fraction at U- & V-points
       REAL(wp) ::   zu_io , zv_io    ! 2 components of the ice-ocean velocity
-#if defined key_coupled    
       REAL(wp), DIMENSION(jpi,jpj) ::   zalb     ! albedo of ice under overcast sky
       REAL(wp), DIMENSION(jpi,jpj) ::   zalbp    ! albedo of ice under clear sky
-#endif
       REAL(wp) ::   zsang, zmod, zfm
       REAL(wp), DIMENSION(jpi,jpj) ::   ztio_u, ztio_v   ! ocean stress below sea-ice
@@ -215,17 +213,13 @@
 
       freeze(:,:) = 1.0 - frld(:,:)       ! Sea ice cover            
-      tn_ice(:,:) = sist(:,:)             ! Ice surface temperature                      
-
-#if defined key_coupled            
-      !------------------------------------------------!
-      !    Computation of snow/ice and ocean albedo    !
-      !------------------------------------------------!
-      zalb  (:,:) = 0.e0
-      zalbp (:,:) = 0.e0
-
-      CALL albedo_ice( sist, hicif, hsnif, zalbp, zalb )
-
-      alb_ice(:,:) =  0.5 * zalbp(:,:) + 0.5 * zalb (:,:)   ! Ice albedo (mean clear and overcast skys)
-#endif
+             
+      IF ( lk_cpl ) THEN           
+         ! Ice surface temperature 
+         tn_ice(:,:) = sist(:,:)              
+         ! Computation of snow/ice and ocean albedo
+         +++ INTERFACE 3D versus 2D
+         CALL albedo_ice( sist, hicif, hsnif, zalbp, zalb )
+         alb_ice(:,:) =  0.5 * ( zalbp(:,:) + zalb (:,:) )   ! Ice albedo (mean clear and overcast skys)
+      ENDIF
 
       IF(ln_ctl) THEN
Index: /branches/dev_003_CPL/NEMO/LIM_SRC_2/limthd_2.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/LIM_SRC_2/limthd_2.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/LIM_SRC_2/limthd_2.F90	(revision 991)
@@ -257,8 +257,8 @@
          CALL tab_2d_1d_2( nbpb, fr2_i0_1d  (1:nbpb)     , fr2_i0     , jpi, jpj, npb(1:nbpb) )
          CALL tab_2d_1d_2( nbpb, qns_ice_1d (1:nbpb)     , qns_ice    , jpi, jpj, npb(1:nbpb) )
-#if ! defined key_coupled
-         CALL tab_2d_1d_2( nbpb, qla_ice_1d (1:nbpb)     , qla_ice    , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d_2( nbpb, dqla_ice_1d(1:nbpb)     , dqla_ice   , jpi, jpj, npb(1:nbpb) )
-#endif
+         IF ( lk_cpl ) THEN 
+            CALL tab_2d_1d_2( nbpb, qla_ice_1d (1:nbpb)     , qla_ice    , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d_2( nbpb, dqla_ice_1d(1:nbpb)     , dqla_ice   , jpi, jpj, npb(1:nbpb) )
+         ENDIF
          CALL tab_2d_1d_2( nbpb, dqns_ice_1d(1:nbpb)     , dqns_ice   , jpi, jpj, npb(1:nbpb) )
          CALL tab_2d_1d_2( nbpb, tfu_1d     (1:nbpb)     , tfu        , jpi, jpj, npb(1:nbpb) )
Index: /branches/dev_003_CPL/NEMO/LIM_SRC_2/limthd_zdf_2.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/LIM_SRC_2/limthd_zdf_2.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/LIM_SRC_2/limthd_zdf_2.F90	(revision 991)
@@ -213,7 +213,4 @@
           zghe     = ( 1.0 - zihe ) * zheshth * ( 2.0 - zheshth )   &
              &     +         zihe   * 0.5 * ( 1.5 + LOG( 2.0 * zheshth ) )
-#if defined key_lim_cp3
-          zghe = 1.0
-#endif 
 
           !---effective conductivities 
@@ -297,19 +294,7 @@
        DO ji = kideb, kiut
           !---computation of the derivative of energy balance function 
-#if defined key_coupled
-#   if defined key_lim_cp2
-          zdfts   =   zksndh(ji)   & ! contribution of the conductive heat flux
-             &      + zrcpdt(ji)   & ! contribution of hsu * rcp / dt
-             &      - dqns_ice_1d(ji)      ! contribution of the total non solar radiation 
-#   else
-          zdfts   =   zksndh(ji)   & ! contribution of the conductive heat flux
-             &      + zrcpdt(ji)    ! contribution of hsu * rcp / dt
-#   endif
-
-#else
           zdfts    =  zksndh(ji)   & ! contribution of the conductive heat flux
              &      + zrcpdt(ji)   & ! contribution of hsu * rcp / dt
              &      - dqns_ice_1d (ji)     ! contribution of the total non solar radiation 
-#endif
           !---computation of the energy balance function 
           zfts    = - z1mi0 (ji) * qsr_ice_1d(ji)   & ! net absorbed solar radiation
@@ -318,7 +303,4 @@
           !---computation of surface temperature increment  
           zdts    = -zfts / zdfts
-#if defined key_lim_cp3
-          zdts = zdts / 3.0
-#endif
           !---computation of the new surface temperature 
           sist_1d(ji) = sist_1d(ji) + zdts
@@ -340,8 +322,8 @@
        DO ji = kideb, kiut
           sist_1d(ji) = MIN( ztsmlt(ji) , sist_1d(ji) )
-#if ! defined key_coupled
-          qns_ice_1d(ji) = qns_ice_1d(ji) + dqns_ice_1d(ji) * ( sist_1d(ji) - zts_old(ji) )
-          qla_ice_1d (ji) = qla_ice_1d (ji) + dqla_ice_1d(ji) * ( sist_1d(ji) - zts_old(ji) )
-#endif
+          IF ( .NOT. lk_cpl ) THEN
+             qns_ice_1d(ji) = qns_ice_1d(ji) + dqns_ice_1d(ji) * ( sist_1d(ji) - zts_old(ji) )
+             qla_ice_1d(ji) = qla_ice_1d(ji) + dqla_ice_1d(ji) * ( sist_1d(ji) - zts_old(ji) )
+          ENDIF
           zfcsu(ji)  = zksndh(ji) * ( ztbif(ji) - sist_1d(ji) )
        END DO
@@ -542,5 +524,11 @@
           !-----------------------------------------------------------------------
           !----change in snow and ice thicknesses due to sublimation or evaporation
-          zdhssub  = parsub * ( qla_ice_1d(ji) / ( rhosn * xsn ) ) * rdt_ice 
+          IF ( .NOT. lk_cpl ) THEN 
+             zdhssub  = parsub * ( qla_ice_1d(ji) / ( rhosn * xsn ) ) * rdt_ice 
+          ELSE IF (parsub == 1) THEN 
+             CALL ctl_stop( 'In coupled mode, use parsub = 0 or send dqla' ) 
+          ELSE
+             zdhssub  = 0.0
+          ENDIF
           zhsn     = h_snow_1d(ji) - zdhssub
           zdhisub  = MAX( zzero , -zhsn ) * rhosn/rhoic
Index: /branches/dev_003_CPL/NEMO/LIM_SRC_3/ice.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/LIM_SRC_3/ice.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/LIM_SRC_3/ice.F90	(revision 991)
@@ -330,6 +330,4 @@
 
    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::       &  !:
-      albege ,   &  !: Albedo of the snow or ice (only for outputs)
-      albecn ,   &  !: Albedo of the ocean (only for outputs)
       tauc          !: Cloud optical depth
 
Index: /branches/dev_003_CPL/NEMO/LIM_SRC_3/iceini.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/LIM_SRC_3/iceini.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/LIM_SRC_3/iceini.F90	(revision 991)
@@ -57,5 +57,5 @@
       !!   3.0  !  08-03  (M. Vancop) ITD, salinity, EVP-C
       !!----------------------------------------------------------------------
-
+      INTEGER ::   jl
       ! Open the namelist file 
       CALL ctlopn(numnam_ice,'namelist_ice','OLD', 'FORMATTED', 'SEQUENTIAL', 1,numout,.FALSE.,1)
@@ -92,10 +92,4 @@
          CALL lim_var_glo2eqv         ! convert global var in equivalent variables
       ENDIF
-
-      freeze(:,:) = at_i(:,:)   ! initialisation of sea/ice cover    
-# if defined key_coupled
-      Must be adpated to LIM3 
-      alb_ice(:,:,:) = albege(:,:)      ! sea-ice albedo
-# endif
 
       nstart = numit  + nn_fsbc      
@@ -255,6 +249,4 @@
       END DO
 
-      tn_ice(:,:,:) = t_su(:,:,:)
-
    END SUBROUTINE lim_itd_ini
 
Index: /branches/dev_003_CPL/NEMO/LIM_SRC_3/limistate.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/LIM_SRC_3/limistate.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/LIM_SRC_3/limistate.F90	(revision 991)
@@ -469,8 +469,4 @@
       stress2_i(:,:)  = 0.0
       stress12_i(:,:) = 0.0
-
-# if defined key_coupled
-      albege(:,:)   = 0.8 * tms(:,:)
-# endif
 
       !--------------------------------------------------------------------
Index: /branches/dev_003_CPL/NEMO/LIM_SRC_3/limrst.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/LIM_SRC_3/limrst.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/LIM_SRC_3/limrst.F90	(revision 991)
@@ -138,7 +138,4 @@
          CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
       END DO
-# if defined key_coupled
-      CALL iom_rstput( iter, nitrst, numriw, 'albege', albege(:,:) )
-# endif
       DO jl = 1, jpl 
          WRITE(zchar,'(I1)') jl
@@ -498,7 +495,4 @@
       ENDIF
 
-# if defined key_coupled 
-      CALL iom_get( numrir, jpdom_autoglo, 'albege'   , albege )
-# endif
       DO jl = 1, jpl 
          WRITE(zchar,'(I1)') jl
Index: /branches/dev_003_CPL/NEMO/LIM_SRC_3/limsbc.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/LIM_SRC_3/limsbc.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/LIM_SRC_3/limsbc.F90	(revision 991)
@@ -242,8 +242,6 @@
       REAL(wp) ::   zpme             ! freshwater exchanges at the ice/ocean interface
       REAL(wp), DIMENSION(jpi,jpj) ::   zfcm1 , zfcm2    ! solar/non solar heat fluxes
-#if defined key_coupled    
       REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zalb     ! albedo of ice under overcast sky
       REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zalbp    ! albedo of ice under clear sky
-#endif
       !!---------------------------------------------------------------------
 
@@ -422,19 +420,14 @@
       !-----------------------------------------------!
 
-      freeze(:,:)   = at_i(:,:)             ! Sea ice cover            
-      tn_ice(:,:,:) = t_su(:,:,:)           ! Ice surface temperature                      
-
-#if defined key_coupled            
-      !------------------------------------------------!
-      !    Computation of snow/ice and ocean albedo    !
-      !------------------------------------------------!
-      zalb  (:,:,:) = 0.e0
-      zalbp (:,:,:) = 0.e0
-
-      CALL albedo_ice( t_su, ht_i, ht_s, zalbp, zalb )
-
-      alb_ice(:,:,:) =  0.5 * zalbp(:,:,:) + 0.5 * zalb (:,:,:)   ! Ice albedo (mean clear and overcast skys)
-#endif
-
+      freeze(:,:)   = at_i(:,:)             ! Sea ice cover  
+
+      IF ( lk_cpl ) THEN                
+         ! Ice surface temperature
+         tn_ice(:,:,:) = t_su(:,:,:)           
+         ! Computation of snow/ice and ocean albedo
+         CALL albedo_ice( t_su, ht_i, ht_s, zalbp, zalb )
+         alb_ice(:,:,:) =  0.5 * ( zalbp(:,:,:) + zalb (:,:,:) )   ! Ice albedo (mean clear and overcast skys)
+      ENDIF
+         
       IF(ln_ctl) THEN
          CALL prt_ctl( tab2d_1=qsr   , clinfo1=' lim_sbc: qsr    : ', tab2d_2=qns , clinfo2=' qns     : ' )
Index: /branches/dev_003_CPL/NEMO/LIM_SRC_3/limthd.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/LIM_SRC_3/limthd.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/LIM_SRC_3/limthd.F90	(revision 991)
@@ -314,10 +314,8 @@
             CALL tab_2d_1d( nbpb, fr2_i0_1d  (1:nbpb)     , fr2_i0     , jpi, jpj, npb(1:nbpb) )
             CALL tab_2d_1d( nbpb, qnsr_ice_1d(1:nbpb)     , qns_ice(:,:,jl) , jpi, jpj, npb(1:nbpb) )
-
-#if ! defined key_coupled
-            CALL tab_2d_1d( nbpb, qla_ice_1d (1:nbpb)     , qla_ice(:,:,jl)    , jpi, jpj, npb(1:nbpb) )
-            CALL tab_2d_1d( nbpb, dqla_ice_1d(1:nbpb)     , dqla_ice(:,:,jl)   , jpi, jpj, npb(1:nbpb) )
-#endif
-
+            IF ( lk_cpl ) THEN
+               CALL tab_2d_1d( nbpb, qla_ice_1d (1:nbpb)     , qla_ice(:,:,jl)    , jpi, jpj, npb(1:nbpb) )
+               CALL tab_2d_1d( nbpb, dqla_ice_1d(1:nbpb)     , dqla_ice(:,:,jl)   , jpi, jpj, npb(1:nbpb) )
+            ENDIF
             CALL tab_2d_1d( nbpb, dqns_ice_1d(1:nbpb)     , dqns_ice(:,:,jl)   , jpi, jpj, npb(1:nbpb) )
             CALL tab_2d_1d( nbpb, t_bo_b     (1:nbpb)     , t_bo       , jpi, jpj, npb(1:nbpb) )
Index: /branches/dev_003_CPL/NEMO/LIM_SRC_3/limthd_dh.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/LIM_SRC_3/limthd_dh.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/LIM_SRC_3/limthd_dh.F90	(revision 991)
@@ -384,5 +384,12 @@
          ! if qla is positive (upwards), heat goes to the atmosphere, therefore
          ! snow sublimates, if qla is negative (downwards), snow condensates
-         zdh_s_sub(ji)   =  - parsub * qla_ice_1d(ji) / ( rhosn * lsub ) * rdt_ice
+         
+         IF ( .NOT. lk_cpl ) THEN 
+            zdh_s_sub(ji) = - parsub * qla_ice_1d(ji) / ( rhosn * lsub ) * rdt_ice
+         ELSE IF (parsub == 1) THEN 
+            CALL ctl_stop( 'In coupled mode, use parsub = 0 or send dqla' ) 
+         ELSE
+            zdh_s_sub(ji)  = 0.0
+         ENDIF
          dh_s_tot(ji)    =  dh_s_tot(ji) + zdh_s_sub(ji)
          zdhcf           =  ht_s_b(ji) + zdh_s_sub(ji) 
Index: /branches/dev_003_CPL/NEMO/OPA_SRC/DIA/diafwb.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/OPA_SRC/DIA/diafwb.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/OPA_SRC/DIA/diafwb.F90	(revision 991)
@@ -8,5 +8,5 @@
    !!            9.0  !  05-11  (V. Garnier) Surface pressure gradient organization
    !!----------------------------------------------------------------------
-#if ( defined key_orca_r2 || defined  key_orca_r4 ) && ! defined key_dynspg_rl && ! defined key_coupled
+#if ( defined key_orca_r2 || defined  key_orca_r4 ) && ! defined key_dynspg_rl && ! defined key_oasis3 && ! defined key_oasis4 
    !!----------------------------------------------------------------------
    !!   NOT "key_dynspg_rl" and "key_orca_r2 or 4"
Index: /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/cpl_oasis3.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/cpl_oasis3.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/cpl_oasis3.F90	(revision 991)
@@ -21,101 +21,40 @@
    !!   cpl_prism_init     : initialization of coupled mode communication
    !!   cpl_prism_define   : definition of grid and fields
-   !!   cpl_prism_send     : send out fields in coupled mode
-   !!   cpl_prism_recv     : receive fields in coupled mode
+   !!   cpl_prism_snd     : snd out fields in coupled mode
+   !!   cpl_prism_rcv     : receive fields in coupled mode
    !!   cpl_prism_finalize : finalize the coupled mode communication
    !!----------------------------------------------------------------------
-   !! * Modules used
-!##################### WARNING coupled mode ###############################
-!##################### WARNING coupled mode ###############################
-!   Following lines must be enabled if coupling with OASIS
+   USE mod_prism_proto              ! OASIS3 prism module
+   USE mod_prism_def_partition_proto! OASIS3 prism module for partitioning
+   USE mod_prism_grids_writing      ! OASIS3 prism module for writing grid files
+   USE mod_prism_put_proto          ! OASIS3 prism module for snding
+   USE mod_prism_get_proto          ! OASIS3 prism module for receiving
+   USE mod_prism_grids_writing      ! OASIS3 prism module for writing grids
+   USE par_oce                      !
+   USE dom_oce                      ! ocean space and time domain
+   USE sbccpl
+   USE in_out_manager               ! I/O manager
+   USE lib_mpp
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   IMPLICIT NONE
+   PRIVATE
 !
-!   USE mod_prism_proto              ! OASIS3 prism module
-!   USE mod_prism_def_partition_proto! OASIS3 prism module for partitioning
-!   USE mod_prism_grids_writing      ! OASIS3 prism module for writing grid files
-!   USE mod_prism_put_proto          ! OASIS3 prism module for sending
-!   USE mod_prism_get_proto          ! OASIS3 prism module for receiving
-!   USE mod_prism_grids_writing      ! OASIS3 prism module for writing grids
-!##################### WARNING coupled mode ###############################
-!##################### WARNING coupled mode ###############################
-#if defined key_mpp_mpi
-   USE lib_mpp, only : mppsize, mpprank ! message passing
-   USE lib_mpp, only : mppsend          ! message passing
-   USE lib_mpp, only : mpprecv          ! message passing
-#endif
-   USE daymod                       ! date and time info
-   USE dom_oce                      ! ocean space and time domain
-   USE sbc_ice                      ! surface boundary condition: ice
-   USE in_out_manager               ! I/O manager
-   USE par_oce                      !
-   USE phycst, only : rt0           ! freezing point of sea water
-
-   USE oce, only: tn, un, vn
-#if defined key_lim2
-   USE ice_2, only: frld, hicif, hsnif
-#endif
-
-   IMPLICIT NONE
-!
-! Exchange parameters for coupling ORCA-LIM with ECHAM5
-!
-#if defined key_cpl_ocevel
-   INTEGER, PARAMETER         :: nsend =  6
-#else
-   INTEGER, PARAMETER         :: nsend =  4
-#endif
-
-#if defined key_cpl_discharge
-   INTEGER, PARAMETER         :: nrecv = 20
-#else
-   INTEGER, PARAMETER         :: nrecv = 17
-#endif
-
-   INTEGER, DIMENSION(nsend)  :: send_id
-   INTEGER, DIMENSION(nrecv)  :: recv_id
-
-   CHARACTER(len=32)          :: cpl_send (nsend)
-   CHARACTER(len=32)          :: cpl_recv (nrecv)
-
-   PRIVATE
-
-   INTEGER                    :: localRank      ! local MPI rank
-   INTEGER                    :: comp_id        ! id returned by prism_init_comp
-
-   INTEGER                    :: range(5)
-
-   INTEGER, PARAMETER         :: localRoot  = 0
-   INTEGER                    :: localSize      ! local MPI size
-   INTEGER                    :: localComm      ! local MPI size
-   LOGICAL                    :: commRank       ! true for ranks doing OASIS communication
-
-   LOGICAL, SAVE              :: prism_was_initialized
-   LOGICAL, SAVE              :: prism_was_terminated
-   INTEGER, SAVE              :: write_grid
-
-   INTEGER                    :: ierror         ! return error code
+   LOGICAL, PUBLIC, PARAMETER :: lk_cpl = .TRUE.   !: coupled flag
+   INTEGER, PUBLIC            :: nlocalComm        ! local MPI size
+   INTEGER                    :: ncomp_id          ! id returned by prism_init_comp
+   INTEGER                    :: nerror            ! return error code
 
    REAL(wp), DIMENSION(:,:), ALLOCATABLE :: exfld  ! Temporary buffer for receiving
-
-#ifdef key_cpl_rootexchg
-   LOGICAL                               :: rootexchg =.true.     ! logical switch 
-#else
-   LOGICAL                               :: rootexchg =.false.    ! logical switch
-#endif
-
-   REAL(wp), DIMENSION(:),   ALLOCATABLE :: buffer ! Temporary buffer for exchange
-   INTEGER, DIMENSION(:,:),  ALLOCATABLE :: ranges ! Temporary buffer for exchange
 
    !! Routine accessibility
    PUBLIC cpl_prism_init
    PUBLIC cpl_prism_define
-   PUBLIC cpl_prism_send
-   PUBLIC cpl_prism_recv
+   PUBLIC cpl_prism_snd
+   PUBLIC cpl_prism_rcv
    PUBLIC cpl_prism_finalize
 
-   PUBLIC send_id, recv_id
-
    !!----------------------------------------------------------------------
    !!   OPA 9.0 , LOCEAN-IPSL (2006) 
-   !! $Id$
+   !! $Header$ 
    !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
@@ -123,7 +62,5 @@
 CONTAINS
 
-   SUBROUTINE cpl_prism_init( localCommunicator )
-
-      IMPLICIT NONE
+   SUBROUTINE cpl_prism_init
 
       !!-------------------------------------------------------------------
@@ -134,13 +71,4 @@
       !!
       !! ** Method  :   OASIS3 MPI communication 
-      !!--------------------------------------------------------------------
-      !! * Arguments
-      !!
-      INTEGER, INTENT(OUT)       :: localCommunicator
-      !!
-      !! * Local declarations
-      !!
-      CHARACTER(len=4)           :: comp_name      ! name of this PRISM component
-      !!
       !!--------------------------------------------------------------------
       !!
@@ -149,21 +77,12 @@
       IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~~'
       IF(lwp) WRITE(numout,*)
-     
-#if defined key_flx_bulk_monthly || defined key_flx_bulk_daily || defined key_flx_forced_daily
-      IF(lwp)WRITE(numout,cform_err)
-      IF(lwp)WRITE(numout,*) ' key_coupled and key_flx_bulk_* key_flx_forced_daily are incompatible'
-      nstop = nstop + 1
-#endif
-
-      comp_name = 'opa9'
-
+          
       !------------------------------------------------------------------
       ! 1st Initialize the PRISM system for the application
       !------------------------------------------------------------------
 
-      CALL prism_init_comp_proto ( comp_id, comp_name, ierror )
-      IF ( ierror /= PRISM_Ok ) &
-         CALL prism_abort_proto (comp_id, 'cpl_prism_init', 'Failure in prism_init_comp_proto')
-      prism_was_initialized = .true.
+      CALL prism_init_comp_proto ( ncomp_id, 'oceanx', nerror )
+      IF ( nerror /= PRISM_Ok ) &
+         CALL prism_abort_proto (ncomp_id, 'cpl_prism_init', 'Failure in prism_init_comp_proto')
 
       !------------------------------------------------------------------
@@ -171,9 +90,7 @@
       !------------------------------------------------------------------
 
-      CALL prism_get_localcomm_proto ( localComm, ierror )
-      IF ( ierror /= PRISM_Ok ) &
-         CALL prism_abort_proto (comp_id, 'cpl_prism_init','Failure in prism_get_localcomm_proto' )
-
-      localCommunicator = localComm
+      CALL prism_get_localcomm_proto ( nlocalComm, nerror )
+      IF ( nerror /= PRISM_Ok ) &
+         CALL prism_abort_proto (ncomp_id, 'cpl_prism_init','Failure in prism_get_localcomm_proto' )
 
    END SUBROUTINE cpl_prism_init
@@ -181,6 +98,4 @@
 
    SUBROUTINE cpl_prism_define ()
-
-      IMPLICIT NONE
 
       !!-------------------------------------------------------------------
@@ -196,950 +111,186 @@
       !! * Local declarations
       !!
-      INTEGER                    :: grid_id(2)     ! id returned by prism_def_grid
-      INTEGER                    :: part_id
-
+      INTEGER                    :: id_part
       INTEGER                    :: paral(5)       ! OASIS3 box partition
-
-      INTEGER                    :: shape(2,3)     ! shape of arrays passed to PSMILe
-      INTEGER                    :: nodim(2)
-      INTEGER                    :: data_type      ! data type of transients
-
-      INTEGER                    :: ji, jj         ! local loop indicees
-      INTEGER                    :: nx, ny, nc     ! local variables
-      INTEGER                    :: im1, ip1
-      INTEGER                    :: jm1, jp1
-      INTEGER                    :: i_grid         ! loop index
-      INTEGER                    :: info
-      INTEGER                    :: maxlen
-      INTEGER                    :: mask(jpi,jpj)
-      REAL(kind=wp)              :: area(jpi,jpj)
-
-      CHARACTER(len=4)           :: point_name     ! name of the grid points
-
-      REAL(kind=wp)              :: rclam(jpi,jpj,4)
-      REAL(kind=wp)              :: rcphi(jpi,jpj,4)
-
-      REAL(kind=wp)              :: glam_b(jpi,jpj) ! buffer for orca2 grid correction
-      REAL(kind=wp)              :: gphi_b(jpi,jpj) ! buffer for orca2 grid correction
-      !!
-      !!--------------------------------------------------------------------
-     
+      INTEGER                    :: ishape(2,2)    ! shape of arrays passed to PSMILe
+      INTEGER                    :: ji             ! local loop indicees
+      !!
+      !!--------------------------------------------------------------------
+
       IF(lwp) WRITE(numout,*)
       IF(lwp) WRITE(numout,*) 'cpl_prism_define : initialization in coupled ocean/atmosphere case'
       IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~~~'
       IF(lwp) WRITE(numout,*)
-     
-#if defined key_flx_bulk_monthly || defined key_flx_bulk_daily || defined key_flx_forced_daily
-      IF(lwp)WRITE(numout,cform_err)
-      IF(lwp)WRITE(numout,*) ' key_coupled and key_flx_bulk_... are incompatible'
-      nstop = nstop + 1
-#endif
-
-      ! -----------------------------------------------------------------
-      ! ... Some initialisation
-      ! -----------------------------------------------------------------
-
-      send_id = 0
-      recv_id = 0
-
-#if defined key_mpp_mpi
-
-      ! -----------------------------------------------------------------
-      ! ... Some MPI stuff relevant for optional exchange via root only
-      ! -----------------------------------------------------------------
-
-      commRank = .false.
-
-      localRank = mpprank ! from lib_mpp
-      localSize = mppsize ! from lib_mpp
-
-      IF ( rootexchg ) THEN
-         IF ( localRank == localRoot ) commRank = .true.
-      ELSE
-         commRank = .true.
-      ENDIF
-
-      IF ( rootexchg .and. localRank == localRoot ) THEN
-         ALLOCATE(ranges(5,0:localSize-1), stat = ierror)
-         IF (ierror > 0) THEN
-            CALL prism_abort_proto ( comp_id, 'cpl_prism_define', 'Failure in allocating Integer')
-            RETURN
-         ENDIF
-      ENDIF
-
-#else
-      !
-      ! For non-parallel configurations the one and only process ("localRoot")
-      ! takes part in the communication
-      ! 
-      localRank = localRoot
-      commRank = .true.
-
-#endif
-
-      ! -----------------------------------------------------------------
-      ! ... If necessary the root process writes the global grid info
-      ! -----------------------------------------------------------------
-
-      IF ( localRank == localRoot ) THEN
-
-         WRITE(numout,*)'Opening file SSTOCEAN, unit= 199'
-
-         OPEN (199,STATUS='NEW',FILE="sstocean",FORM='UNFORMATTED',err=310)
-
-         ! In case the sstocean of OASIS3 from a previous run exists
-         ! the programs jumps to the end of the if-block
-!    
-!*    2.0    Write exchange fields to OASIS data file.
-!            -----------------------------------------
-
-         WHERE (tmask(:,:,1) > 0.5 )
-            mask(:,:) = 0
-         ELSE WHERE
-            mask(:,:) = 1
-         END WHERE
-
-! Initialise ice mask at the very first start only
-         frld = 1.
-
-         WRITE(199) 'SSTOCEAN'
-         WRITE(199) (tn(:,:,1)*mask(:,:))+rt0
-
-         WRITE(199) 'SICOCEAN'
-         WRITE(199) (1.-frld(:,:))*mask(:,:)
-
-#if defined key_cpl_albedo
-# if defined key_lim3
-         Must be adapted for LIM3
-# endif
-         tn_ice  = 271.285
-	 alb_ice =   0.75
-
-         WRITE(199) 'STIOCEAN'
-         WRITE(199) tn_ice(:,:)
-
-         WRITE(199) 'SAIOCEAN'
-         WRITE(199) alb_ice(:,:)
-#else
-         hicit = 0.
-         hsnit = 0.
-         WRITE(199) 'SITOCEAN'
-         WRITE(199) hicif(:,:)*mask(:,:)
-
-         WRITE(199) 'SNTOCEAN'
-         WRITE(199) hsnif(:,:)*mask(:,:)
-#endif
-
-#if defined key_cpl_ocevel
-         un(:,:,1) = 0.
-         vn(:,:,1) = 0.
-
-         WHERE (umask(:,:,1) > 0.5 )
-            mask(:,:) = 0
-         ELSE WHERE
-            mask(:,:) = 1
-         END WHERE
-
-         WRITE(199) 'SUNOCEAN'
-         WRITE(199) un(:,:,1)*mask(:,:)
-
-         WHERE (vmask(:,:,1) > 0.5 )
-            mask(:,:) = 0
-         ELSE WHERE
-            mask(:,:) = 1
-         END WHERE
-
-         WRITE(199) 'SVNOCEAN'
-         WRITE(199) vn(:,:,1)*mask(:,:)
-#endif
-
-         WRITE(numout,*)
-         WRITE(numout,*)' sstocean written'
-         WRITE(numout,*)' ***************'
-
-         CLOSE(199)
-
- 310     CONTINUE
-
-         CALL prism_start_grids_writing ( write_grid )
-
-      ENDIF  ! localRank == localRoot
-
-      IF ( localRank == localRoot .and. write_grid == 1 ) THEN
-
-         !------------------------------------------------------------------
-         ! 1st write global grid information (ORCA tripolar) characteristics
-         !     for surface coupling into a OASIS3 specific grid file. For
-         !     surface coupling it is sufficient to specify only one vertical
-         !     z-level.
-         !------------------------------------------------------------------
-         !
-         ! ... Treat corners in the horizontal plane
-         !
-         nx = jpi
-         ny = jpj
-         nc = 4
-
-         DO i_grid = 1, 3
-
-            IF ( i_grid == 1 ) THEN
-
-               ! --------------------------------------------------------
-               ! ... Write the grid info for T points
-               ! --------------------------------------------------------
-
-               point_name = 'opat'
-
-               glam_b = glamt
-               gphi_b = gphit
-
-               DO ji = 1, jpi
-                  DO jj = 1, jpj
-
-                     im1 = ji-1
-                     jm1 = jj-1
-                     IF (ji == 1) im1 = jpi-2
-                     IF (jj == 1) jm1 = jj
-
-                     rclam(ji,jj,1) = glamf(ji,jj)
-                     rclam(ji,jj,2) = glamf(im1,jj)
-                     rclam(ji,jj,3) = glamf(im1,jm1)
-                     rclam(ji,jj,4) = glamf(ji,jm1)
-
-                     rcphi(ji,jj,1) = gphif(ji,jj)
-                     rcphi(ji,jj,2) = gphif(im1,jj)
-                     rcphi(ji,jj,3) = gphif(im1,jm1)
-                     rcphi(ji,jj,4) = gphif(ji,jm1)
-
-                  END DO
-               END DO
-
-               ! Correction of one (land) grid cell of the orca2 grid.
-               ! It was causing problems with the SCRIP interpolation.
-
-               IF (jpiglo == 182 .AND. jpjglo == 149) THEN
-                  rclam(145,106,2) = -1.0
-                  rcphi(145,106,2) = 41.0
-               ENDIF
-
-               WHERE (tmask(:,:,1) > 0.5 )
-                  mask(:,:) = 0
-               ELSE WHERE
-                  mask(:,:) = 1
-               END WHERE
-
-               area = e1t * e2t
-
-            ELSE IF ( i_grid == 2 ) THEN
-
-               ! --------------------------------------------------------
-               ! ... Write the grid info for u points
-               ! --------------------------------------------------------
-
-               point_name = 'opau'
-
-               glam_b = glamu
-               gphi_b = gphiu
-
-               DO ji = 1, jpi
-                  DO jj = 1, jpj
-
-                     ip1 = ji+1
-                     jm1 = jj-1
-
-                     IF (ji == jpiglo) ip1 = 3
-                     IF (jj == 1) jm1 = jj
-
-                     rclam(ji,jj,1) = glamv(ip1,jj)
-                     rclam(ji,jj,2) = glamv(ji,jj)
-                     rclam(ji,jj,3) = glamv(ji,jm1)
-                     rclam(ji,jj,4) = glamv(ip1,jm1)
-
-                     rcphi(ji,jj,1) = gphiv(ip1,jj)
-                     rcphi(ji,jj,2) = gphiv(ji,jj)
-                     rcphi(ji,jj,3) = gphiv(ji,jm1)
-                     rcphi(ji,jj,4) = gphiv(ip1,jm1)
-
-                  END DO
-               END DO
-
-               ! Correction of three (land) grid cell of the orca2 grid.
-               ! It was causing problems with the SCRIP interpolation.
-
-               IF (jpiglo == 182 .AND. jpjglo == 149) THEN
-                  glam_b(144,106)   = -1.0
-                  gphi_b(144,106)   = 40.5
-                  rclam (144,106,2) = -1.5  
-                  rcphi (144,106,2) = 41.0
-
-                  glam_b(144,107)   = -1.0
-                  gphi_b(144,107)   = 41.5
-                  rclam (144,107,2) = -1.5  
-                  rcphi (144,107,2) = 42.0
-                  rclam (144,107,3) = -1.5  
-                  rcphi (144,107,3) = 41.0
-
-                  glam_b(144,108)   = -1.0
-                  gphi_b(144,108)   = 42.5
-                  rclam (144,108,2) = -1.5  
-                  rcphi (144,108,2) = 43.0
-                  rclam (144,108,3) = -1.5  
-                  rcphi (144,108,3) = 42.0
-               ENDIF
-
-               WHERE (umask(:,:,1) > 0.5 )
-                  mask(:,:) = 0
-               ELSE WHERE
-                  mask(:,:) = 1
-               END WHERE
-
-               area = e1u * e2u
-
-            ELSE IF ( i_grid == 3 ) THEN
-
-               ! --------------------------------------------------------
-               ! ... Write the grid info for v points
-               ! --------------------------------------------------------
-
-               point_name = 'opav'
-
-               glam_b = glamv
-               gphi_b = gphiv
-
-               DO ji = 1, jpi
-                  DO jj = 1, jpj
-
-                     im1 = ji-1
-                     jp1 = jj+1
-                     IF (ji == 1) im1 = jpiglo-2
-                     IF (jj == jpjglo) jp1 = jj
-
-                     rclam(ji,jj,1) = glamu(ji,jp1)
-                     rclam(ji,jj,2) = glamu(im1,jp1)
-                     rclam(ji,jj,3) = glamu(im1,jj)
-                     rclam(ji,jj,4) = glamu(ji,jj)
-
-                     rcphi(ji,jj,1) = gphiu(ji,jp1)
-                     rcphi(ji,jj,2) = gphiu(im1,jp1)
-                     rcphi(ji,jj,3) = gphiu(im1,jj)
-                     rcphi(ji,jj,4) = gphiu(ji,jj)
-
-                  END DO
-               END DO
-
-               ! Correction of one (land) grid cell of the orca2 grid.
-               ! It was causing problems with the SCRIP interpolation.
-
-               IF (jpiglo == 182 .AND. jpjglo == 149) THEN
-                  rclam(145,105,2) = -1.0  
-                  rcphi(145,105,2) = 40.5
-               ENDIF
-
-               WHERE (vmask(:,:,1) > 0.5 )
-                  mask(:,:) = 0
-               ELSE WHERE
-                  mask(:,:) = 1
-               END WHERE
-
-               area = e1v * e2v
-
-            ENDIF ! i_grid
-
-            WHERE (glam_b(:,:) < 0.)
-               glam_b(:,:) = glam_b(:,:) + 360.
-            END WHERE
-            WHERE (glam_b(:,:) > 360.)
-               glam_b(:,:) = glam_b(:,:) - 360.
-            END WHERE
-
-            WHERE (rclam(:,:,:) < 0.)
-               rclam(:,:,:) = rclam(:,:,:) + 360.
-            END WHERE
-            WHERE (rclam(:,:,:) > 360.)
-               rclam(:,:,:) = rclam(:,:,:) - 360.
-            END WHERE
-
-            mask(:,jpjglo)=1
-
-            CALL prism_write_grid   ( point_name, nx, ny, glam_b, gphi_b ) 
-            CALL prism_write_corner ( point_name, nx, ny, nc, rclam, rcphi )
-            CALL prism_write_mask   ( point_name, nx, ny, mask )
-            CALL prism_write_area   ( point_name, nx, ny, area )
-
-         END DO ! i_grid
-
-         CALL prism_terminate_grids_writing ()
-
-      ENDIF ! localRank == localRoot .and. write_grid == 1
-
+
+      !
+      ! ... Define the shape for the area that excludes the halo
+      !     For serial configuration (key_mpp_mpi not being active)
+      !     nl* is set to the global values 1 and jp*glo.
+      !
+      ishape(:,1) = (/ 1, nlei-nldi+1 /)
+      ishape(:,2) = (/ 1, nlej-nldj+1 /)
+      !
+      ! ... Allocate memory for data exchange
+      !
+      ALLOCATE(exfld(nlei-nldi+1, nlej-nldj+1), stat = nerror)
+      IF (nerror > 0) THEN
+         CALL prism_abort_proto ( ncomp_id, 'cpl_prism_define', 'Failure in allocating exfld')
+         RETURN
+      ENDIF
+      !
       ! -----------------------------------------------------------------
       ! ... Define the partition 
       ! -----------------------------------------------------------------
-
-      IF ( rootexchg ) THEN
-
-         paral(1) = 2              ! box partitioning
-         paral(2) = 0              ! NEMO lower left corner global offset    
-         paral(3) = jpiglo         ! local extent in i 
-         paral(4) = jpjglo         ! local extent in j
-         paral(5) = jpiglo         ! global extent in x
-
-         range(1) = nimpp-1+nldi   ! global start in i
-         range(2) = nlei-nldi+1    ! local size in i of valid region
-         range(3) = njmpp-1+nldj   ! global start in j
-         range(4) = nlej-nldj+1    ! local size in j of valid region
-         range(5) = range(2) &
-                  * range(4)       ! local horizontal size
-
-         IF(ln_ctl) THEN
-         write(numout,*) ' rootexchg: range(1:5)', range
-         ENDIF
-
-         !
-         ! Collect ranges from all NEMO procs on the local root process
-         !
-         CALL mpi_gather(range,  5, MPI_INTEGER, &
-                         ranges, 5, MPI_INTEGER, localRoot, localComm, ierror)
-
-         IF ( localRank == localRoot ) THEN
-
-            maxlen = maxval(ranges(5,:))
-            
-            ALLOCATE(buffer(1:maxlen), stat = ierror)
-            IF (ierror > 0) THEN
-               CALL prism_abort_proto ( comp_id, 'cpl_prism_define', 'Failure in allocating buffer')
-               RETURN
+      
+      paral(1) = 2                                              ! box partitioning
+      paral(2) = jpiglo * (nldj-1+njmpp-1) + (nldi-1+nimpp-1)   ! NEMO lower left corner global offset    
+      paral(3) = nlei-nldi+1                                    ! local extent in i 
+      paral(4) = nlej-nldj+1                                    ! local extent in j
+      paral(5) = jpiglo                                         ! global extent in x
+      
+      IF( ln_ctl ) THEN
+         WRITE(numout,*) ' multiexchg: paral (1:5)', paral
+         WRITE(numout,*) ' multiexchg: jpi, jpj =', jpi, jpj
+         WRITE(numout,*) ' multiexchg: nldi, nlei, nimpp =', nldi, nlei, nimpp
+         WRITE(numout,*) ' multiexchg: nldj, nlej, njmpp =', nldj, nlej, njmpp
+      ENDIF
+      
+      CALL prism_def_partition_proto ( id_part, paral, nerror )
+      !
+      ! ... Announce send variables. 
+      !
+      DO ji = 1, jpsnd
+         IF ( scpl_snd(ji)%laction ) THEN 
+            CALL prism_def_var_proto (scpl_snd(ji)%nid, scpl_snd(ji)%cname, id_part, (/ 2, 0/),  g &
+               &                      PRISM_Out   , ishape   , PRISM_REAL, nerror)
+            IF ( nerror /= PRISM_Ok ) THEN
+               WRITE(numout,*) 'Failed to define transient ', ji, TRIM(scpl_snd(ji)%cname)
+               CALL prism_abort_proto ( scp_rcv(ji)%nid, 'cpl_prism_define', 'Failure in prism_def_var')
             ENDIF
-
-          ENDIF
-
-      ELSE
-
-         paral(1) = 2                  ! box partitioning
-!2dtest         paral(2) = jpiglo           &
-!2dtest                  * (nldj-1+njmpp-1) &
-!2dtest                  + (nldi-1+nimpp-1)   ! NEMO lower left corner global offset    
-         paral(2) = jpiglo &
-                  * (nldj-1+njmpp-1)   ! NEMO lower left corner global offset    
-         paral(3) = nlei-nldi+1        ! local extent in i 
-         paral(4) = nlej-nldj+1        ! local extent in j
-         paral(5) = jpiglo             ! global extent in x
-
-         IF(ln_ctl) THEN
-            print*, ' multiexchg: paral (1:5)', paral
-            print*, ' multiexchg: jpi, jpj =', jpi, jpj
-            print*, ' multiexchg: nldi, nlei, nimpp =', nldi, nlei, nimpp
-            print*, ' multiexchg: nldj, nlej, njmpp =', nldj, nlej, njmpp
-         ENDIF
-
-         IF ( paral(3) /= nlei-nldi+1 ) THEN
-              print*, 'WARNING!!! in cpl_oasis3 - cpl_prism_define'
-              print*, 'cpl_prism_define: local extend in i is ', paral(3), ' should equal ', nlei-nldi+1
-         ENDIF
-         IF ( paral(4) /= nlej-nldj+1 ) THEN
-              print*, 'WARNING!!! in cpl_oasis3 - cpl_prism_define'
-              print*, 'cpl_prism_define: local extend in j is ', paral(4), ' should equal ', nlej-nldj+1
-         ENDIF
-
-      ENDIF
-
-      IF ( commRank ) &
-      CALL prism_def_partition_proto ( part_id, paral, ierror )
-
-      grid_id(1)= part_id
-
-      !------------------------------------------------------------------
-      ! 3rd Declare the transient variables
-      !------------------------------------------------------------------
-      !
-      ! ... Define symbolic names for the transient fields send by the ocean
-      !     These must be identical to the names specified in the SMIOC file.
-      !
-      cpl_send( 1)='SSTOCEAN' ! sea surface temperature              -> sst_io
-      cpl_send( 2)='SICOCEAN' ! sea ice area fraction                -> 1.-frld
-#if defined key_cpl_albedo
-      cpl_send( 3)='STIOCEAN' ! surface temperature over sea ice     -> tn_ice
-      cpl_send( 4)='SAIOCEAN' ! albedo over sea ice                  -> alb_ice
-#else
-      cpl_send( 3)='SITOCEAN' ! sea ice thickness                    -> hicif (only 1 layer available!)
-      cpl_send( 4)='SNTOCEAN' ! surface snow thickness over sea ice  -> hsnif
-#endif
-#if defined key_cpl_ocevel
-      cpl_send( 5)='SUNOCEAN' ! U-velocity                           -> un
-      cpl_send( 6)='SVNOCEAN' ! V-velocity                           -> vn
-#endif
-      !
-      ! ...  Define symbolic names for transient fields received by the ocean.
-      !      These must be identical to the names specified in the SMIOC file.
-      !
-      ! ...  a) U-Grid fields
-      !
-      cpl_recv( 1)='TXWOCEWU' ! weighted surface downward eastward stress
-      cpl_recv( 2)='TYWOCEWU' ! weighted surface downward northward stress
-      cpl_recv( 3)='TXIOCEWU' ! weighted surface downward eastward stress over ice
-      cpl_recv( 4)='TYIOCEWU' ! weighted surface downward northward stress over ice
-      !
-      ! ...  a) V-Grid fields
-      !
-      cpl_recv( 5)='TXWOCEWV' ! weighted surface downward eastward stress
-      cpl_recv( 6)='TYWOCEWV' ! weighted surface downward northward stress
-      cpl_recv( 7)='TXIOCEWV' ! weighted surface downward eastward stress over ice
-      cpl_recv( 8)='TYIOCEWV' ! weighted surface downward northward stress over ice
-      !
-      ! ...  a) T-Grid fields
-      !
-      cpl_recv( 9)='FRWOCEPE' ! P-E over water                               -> zpew
-      cpl_recv(10)='FRIOCEPE' ! P-E over ice                                 -> zpei
-      cpl_recv(11)='FRROCESN' ! surface downward snow fall                   -> zpsol
-      cpl_recv(12)='FRIOCEEV' ! surface upward snow flux where sea ice       -> zevice
-
-      cpl_recv(13)='QSWOCESR' ! surface net downward shortwave flux          -> qsr_oce
-      cpl_recv(14)='QSWOCENS' ! surface downward non-solar heat flux in air  -> qnsr_oce
-      cpl_recv(15)='QSIOCESR' ! solar heat flux on sea ice                   -> qsr_ice
-      cpl_recv(16)='QSIOCENS' ! non-solar heat flux on sea ice               -> qnsr_ice
-      cpl_recv(17)='QSIOCEDQ' ! non-solar heat flux derivative               -> dqns_ice
-
-#ifdef key_cpl_discharge
-      cpl_recv(18)='FRWOCEIS' ! ice discharge into ocean                     -> calving
-      cpl_recv(19)='FRWOCERD' ! river discharge into ocean                   -> zrunriv
-      cpl_recv(20)='FRWOCECD' ! continental discharge into ocean             -> zruncot
-#endif
-      !
-      ! data_type has to be PRISM_REAL as PRISM_DOUBLE is not supported.
-      ! For exchange of double precision fields the OASIS3 has to be compiled
-      ! with use_realtype_single. (see OASIS3 User Guide prism_2-4, 5th Ed.,
-      ! p. 13 and p. 53 for further explanation.)
-      !
-      data_type = PRISM_REAL
-
-      nodim(1) = 3 ! check
-      nodim(2) = 0
-
-      !
-      ! ... Define the shape for the area that excludes the halo
-      !     For serial configuration (key_mpp_mpi not being active)
-      !     nl* is set to the global values 1 and jp*glo.
-      !
-      IF ( rootexchg ) THEN
-         shape(1,1) = 1
-         shape(2,1) = jpiglo
-         shape(1,2) = 1
-         shape(2,2) = jpjglo
-         shape(1,3) = 1
-         shape(2,3) = 1
-       ELSE
-         shape(1,1) = 1
-         shape(2,1) = nlei-nldi+1 ! jpi
-         shape(1,2) = 1
-         shape(2,2) = nlej-nldj+1 ! jpj
-         shape(1,3) = 1
-         shape(2,3) = 1
-      ENDIF
-      !
-      ! -----------------------------------------------------------------
-      ! ... Allocate memory for data exchange
-      ! -----------------------------------------------------------------
-      !
-      ALLOCATE(exfld(shape(1,1):shape(2,1),shape(1,2):shape(2,2)), stat = ierror)
-      IF (ierror > 0) THEN
-         CALL prism_abort_proto ( comp_id, 'cpl_prism_define', 'Failure in allocating exfld')
-         RETURN
-      ENDIF
-      !
-      ! ... Announce send variables, all on T points. 
-      !
-      info = PRISM_Out
-      !
-
-      IF ( commRank ) THEN
-
-         DO ji = 1, nsend
-            !        if ( ji == 2 ) ; then ; nodim(2) = 2 ; else ; nodim(2) = 0 ; endif
-            CALL prism_def_var_proto (send_id(ji), cpl_send(ji), grid_id(1), &
-                 nodim, info, shape, data_type, ierror)
-            IF ( ierror /= PRISM_Ok ) THEN
-               PRINT *, 'Failed to define transient ', ji, TRIM(cpl_send(ji))
-               CALL prism_abort_proto ( comp_id, 'cpl_prism_define', 'Failure in prism_def_var')
+         ENDIF
+      END DO
+      !
+      ! ... Announce received variables. 
+      !
+      DO ji = 1, jprcv
+         IF ( srcv(ji)%laction ) THEN 
+            CALL prism_def_var_proto ( srcv(ji)%nid, srcv(ji)%name, id_part, (/ 2, 0/),   &
+               &                      PRISM_In    , ishape   , PRISM_REAL, nerror)
+            IF ( nerror /= PRISM_Ok ) THEN
+               WRITE(numout,*) 'Failed to define transient ', ji, TRIM(srcv(ji)%name)
+               CALL prism_abort_proto ( srcv(ji)%nid, 'cpl_prism_define', 'Failure in prism_def_var')
             ENDIF
-         ENDDO
-         !
-         nodim(1) = 3 ! check
-         nodim(2) = 0
-         !
-         ! ... Announce recv variables. 
-         !
-         info = PRISM_In
-         !
-         ! ... a) on U points
-         !
-         DO ji = 1, 4
-            CALL prism_def_var_proto (recv_id(ji), cpl_recv(ji), grid_id(1), &
-                 nodim, info, shape, data_type, ierror)
-            IF ( ierror /= PRISM_Ok ) THEN
-               PRINT *, 'Failed to define transient ', ji, TRIM(cpl_recv(ji))
-               CALL prism_abort_proto ( comp_id, 'cpl_prism_define', 'Failure in prism_def_var')
-            ENDIF
-         ENDDO
-         !
-         ! ... b) on V points
-         !
-         DO ji = 5, 8
-            CALL prism_def_var_proto (recv_id(ji), cpl_recv(ji), grid_id(1), &
-                 nodim, info, shape, data_type, ierror)
-            IF ( ierror /= PRISM_Ok ) THEN
-               PRINT *, 'Failed to define transient ', TRIM(cpl_recv(ji))
-               CALL prism_abort_proto ( comp_id, 'cpl_prism_define', 'Failure in prism_def_var')
-            ENDIF
-         ENDDO
-         !
-         ! ... c) on T points
-         !
-         DO ji = 9, nrecv
-            CALL prism_def_var_proto (recv_id(ji), cpl_recv(ji), grid_id(1), &
-                 nodim, info, shape, data_type, ierror)
-            IF ( ierror /= PRISM_Ok ) THEN
-               PRINT *, 'Failed to define transient ', TRIM(cpl_recv(ji))
-               CALL prism_abort_proto ( comp_id, 'cpl_prism_define', 'Failure in prism_def_var')
-            ENDIF
-         ENDDO
-
-      ENDIF ! commRank
-
-      !------------------------------------------------------------------
-      ! 4th End of definition phase
-      !------------------------------------------------------------------
-
-      IF ( commRank ) THEN
-         CALL prism_enddef_proto(ierror)
-         IF ( ierror /= PRISM_Ok ) &
-              CALL prism_abort_proto ( comp_id, 'cpl_prism_define', 'Failure in prism_enddef')
-      ENDIF
-
+         ENDIF
+      END DO
+      
+      !------------------------------------------------------------------
+      ! End of definition phase
+      !------------------------------------------------------------------
+      
+      CALL prism_enddef_proto(nerror)
+      IF ( nerror /= PRISM_Ok )   CALL prism_abort_proto ( ncomp_id, 'cpl_prism_define', 'Failure in prism_enddef')
+      
    END SUBROUTINE cpl_prism_define
-
-
-
-   SUBROUTINE cpl_prism_send( var_id, date, data_array, info )
-
-      IMPLICIT NONE
+   
+   
+   SUBROUTINE cpl_prism_snd( kid, kstep, pdata, kinfo )
 
       !!---------------------------------------------------------------------
-      !!              ***  ROUTINE cpl_prism_send  ***
-      !!
-      !! ** Purpose : - At each coupling time-step,this routine sends fields
+      !!              ***  ROUTINE cpl_prism_snd  ***
+      !!
+      !! ** Purpose : - At each coupling time-step,this routine snds fields
       !!      like sst or ice cover to the coupler or remote application.
       !!----------------------------------------------------------------------
       !! * Arguments
       !!
-      INTEGER, INTENT( IN )  :: var_id    ! variable Id
-      INTEGER, INTENT( OUT ) :: info      ! OASIS3 info argument
-      INTEGER, INTENT( IN )  :: date      ! ocean time-step in seconds
-      REAL(wp)               :: data_array(:,:)
+      INTEGER,                      INTENT( IN    )   :: kid       ! variable intex in the array
+      INTEGER,                      INTENT(   OUT )   :: kinfo     ! OASIS3 info argument
+      INTEGER,                      INTENT( IN    )   :: kstep     ! ocean time-step in seconds
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( IN    )   :: pdata
       !!
       !! * Local declarations
       !!
-#if defined key_mpp_mpi
-      REAL(wp)               :: global_array(jpiglo,jpjglo)
-      !
-!mpi  INTEGER                :: status(MPI_STATUS_SIZE)
-!mpi  INTEGER                :: type       ! MPI data type
-      INTEGER                :: request    ! MPI isend request
-      INTEGER                :: ji, jj, jn ! local loop indicees
-#else
       INTEGER                :: ji
-#endif
-      !!
-      !!--------------------------------------------------------------------
-      !!
-
-#if defined key_mpp_mpi
-
-      request = 0
-
-      IF ( rootexchg ) THEN
-         !
-!mpi     IF ( wp == 4 ) type = MPI_REAL
-!mpi     IF ( wp == 8 ) type = MPI_DOUBLE_PRECISION
-         !
-         ! collect data on the local root process
-         !
-
-         if ( var_id == 1 .and. localRank == localRoot .and. ln_ctl )  then
-             do ji = 0, localSize-1
-                WRITE(numout,*) ' rootexchg: ranges for rank ', ji, ' are ', ranges(:,ji) 
-             enddo
-         endif
-
-         IF ( localRank /= localRoot ) THEN
-
-            DO jj = nldj, nlej
-               DO ji = nldi, nlei
-                  exfld(ji-nldi+1,jj-nldj+1)=data_array(ji,jj)
-               ENDDO
-            ENDDO
-
-!mpi        CALL mpi_send(exfld, range(5), type, localRoot, localRank, localComm, ierror)
-            CALL mppsend (localRank, exfld, range(5), localRoot, request)  
-
-            if ( var_id == 1 .and. ln_ctl )  then
-               WRITE(numout,*) ' rootexchg: This is process       ', localRank
-               WRITE(numout,*) ' rootexchg: We have a range of    ', range 
-!               WRITE(numout,*) ' rootexchg: We got SST to process ', data_array 
-            endif
-
-         ENDIF
-
-         IF ( localRank == localRoot ) THEN
-
-            DO jj = ranges(3,localRoot), ranges(3,localRoot)+ranges(4,localRoot)-1
-               DO ji = ranges(1,localRoot), ranges(1,localRoot)+ranges(2,localRoot)-1
-                  global_array(ji,jj) = data_array(ji,jj) ! workaround
-               ENDDO
-            ENDDO
-
-            DO jn = 1, localSize-1
-
-!mpi           CALL mpi_recv(buffer, ranges(5,jn), type, localRoot, jn, localComm, status, ierror)
-               CALL mpprecv(jn, buffer, ranges(5,jn))
-
-               if ( var_id == 1 .and. ln_ctl )  then
-                   WRITE(numout,*) ' rootexchg: Handling data from process ', jn
-!                   WRITE(numout,*) ' rootexchg: We got SST to process      ', buffer
-               endif
-
-
-               DO jj = ranges(3,jn), ranges(3,jn)+ranges(4,jn)-1
-                  DO ji = ranges(1,jn), ranges(1,jn)+ranges(2,jn)-1
-                     global_array(ji,jj) = buffer((jj-ranges(3,jn))*ranges(2,jn) + ji-ranges(1,jn)+1)
-                  ENDDO
-               ENDDO
-
-            ENDDO
-
-            CALL prism_put_proto ( var_id, date, global_array, info )
-
-         ENDIF
-
-      ELSE
-
-         DO jj = nldj, nlej
-            DO ji = nldi, nlei
-               exfld(ji-nldi+1,jj-nldj+1)=data_array(ji,jj)
-            ENDDO
-         ENDDO
-
-         CALL prism_put_proto ( var_id, date, exfld, info )
-
-      ENDIF
-
-#else
-
-      !
-      ! send local data from every process to OASIS3
-      !
-      IF ( commRank ) &
-      CALL prism_put_proto ( var_id, date, data_array, info )
-
-#endif
-
-      IF ( commRank ) THEN
-
-         IF (ln_ctl .and. lwp) THEN        
-
-            IF ( info == PRISM_Sent     .OR. &
-                 info == PRISM_ToRest   .OR. &
-                 info == PRISM_SentOut  .OR. &
-                 info == PRISM_ToRestOut       ) THEN
-               WRITE(numout,*) '****************'
-               DO ji = 1, nsend
-                  IF (var_id == send_id(ji) ) THEN
-                     WRITE(numout,*) 'prism_put_proto: Outgoing ', cpl_send(ji)
-                     EXIT
-                  ENDIF
-               ENDDO
-               WRITE(numout,*) 'prism_put_proto: var_id ', var_id
-               WRITE(numout,*) 'prism_put_proto:   date ', date
-               WRITE(numout,*) 'prism_put_proto:   info ', info
-               WRITE(numout,*) '     - Minimum value is ', MINVAL(data_array)
-               WRITE(numout,*) '     - Maximum value is ', MAXVAL(data_array)
-               WRITE(numout,*) '     -     Sum value is ', SUM(data_array)
-               WRITE(numout,*) '****************'
-            ENDIF
-
-         ENDIF
-
-      ENDIF
-
-   END SUBROUTINE cpl_prism_send
-
-
-
-   SUBROUTINE cpl_prism_recv( var_id, date, data_array, info )
-
-      IMPLICIT NONE
+      !!
+      !!--------------------------------------------------------------------
+      !
+      ! snd data to OASIS3
+      !
+      IF( lk_mpp ) THEN   ;   CALL prism_put_proto ( rcv(kid)%nid, kstep, pdata(nldi:nlei, nldj:nlej), kinfo )
+      ELSE                ;   CALL prism_put_proto ( rcv(kid)%nid, kstep, pdata                      , kinfo )
+      ENDIF
+      
+      IF ( ln_ctl ) THEN        
+         IF ( kinfo == PRISM_Sent     .OR. kinfo == PRISM_ToRest .OR.   &
+            & kinfo == PRISM_SentOut  .OR. kinfo == PRISM_ToRestOut ) THEN
+            WRITE(numout,*) '****************'
+            WRITE(numout,*) 'prism_put_proto: Outgoing ', ssnd(kid)%cname
+            WRITE(numout,*) 'prism_put_proto: ivarid ', ssnd(kid)%nid
+            WRITE(numout,*) 'prism_put_proto:  kstep ', kstep
+            WRITE(numout,*) 'prism_put_proto:   info ', kinfo
+            WRITE(numout,*) '     - Minimum value is ', MINVAL(pdata)
+            WRITE(numout,*) '     - Maximum value is ', MAXVAL(pdata)
+            WRITE(numout,*) '     -     Sum value is ', SUM(pdata)
+            WRITE(numout,*) '****************'
+         ENDIF
+      ENDIF
+
+   END SUBROUTINE cpl_prism_snd
+
+
+   SUBROUTINE cpl_prism_rcv( kid, kstep, pdata, kinfo )
 
       !!---------------------------------------------------------------------
-      !!              ***  ROUTINE cpl_prism_recv  ***
+      !!              ***  ROUTINE cpl_prism_rcv  ***
       !!
       !! ** Purpose : - At each coupling time-step,this routine receives fields
       !!      like stresses and fluxes from the coupler or remote application.
       !!----------------------------------------------------------------------
-      !! * Arguments
-      !!
-      INTEGER, INTENT( IN )  :: var_id    ! variable Id
-      INTEGER, INTENT( OUT ) :: info      ! variable Id
-      INTEGER, INTENT( IN )  :: date      ! ocean time-step in seconds
-      REAL(wp),INTENT( OUT ) :: data_array(:,:)
-      !!
-      !! * Local declarations
-      !!
-#if defined key_mpp_mpi
-      REAL(wp)               :: global_array(jpiglo,jpjglo)
-      !
-!      LOGICAL                :: action = .false.
-      LOGICAL                :: action
-!mpi  INTEGER                :: status(MPI_STATUS_SIZE)
-!mpi  INTEGER                :: type       ! MPI data type
-      INTEGER                :: request    ! MPI isend request
-      INTEGER                :: ji, jj, jn ! local loop indices
-#else
-      INTEGER                :: ji
-#endif
-      !!
-      !!--------------------------------------------------------------------
-      !!
-#ifdef key_mpp_mpi
-      action = .false.
-      request = 0
-
-      IF ( rootexchg ) THEN
-         !
-         ! receive data from OASIS3 on local root
-         !
-         IF ( commRank ) &
-              CALL prism_get_proto ( var_id, date, global_array, info )
-
-         CALL MPI_BCAST ( info, 1, MPI_INTEGER, localRoot, localComm, ierror )
-
-      ELSE
-         !
-         ! receive local data from OASIS3 on every process
-         !
-         CALL prism_get_proto ( var_id, date, exfld, info )
-
-      ENDIF
-
-      IF ( info == PRISM_Recvd        .OR. &
-           info == PRISM_FromRest     .OR. &
-           info == PRISM_RecvOut      .OR. &
-           info == PRISM_FromRestOut ) action = .true.
-
-      IF (ln_ctl .and. lwp) THEN        
-         WRITE(numout,*) "info", info, var_id
-         WRITE(numout,*) "date", date, var_id
-         WRITE(numout,*) "action", action, var_id
-      ENDIF
-
-      IF ( rootexchg .and. action ) THEN
-         !
-!mpi     IF ( wp == 4 ) type = MPI_REAL
-!mpi     IF ( wp == 8 ) type = MPI_DOUBLE_PRECISION
-         !
-         ! distribute data to processes
-         !
-         IF ( localRank == localRoot ) THEN
-
-            DO jj = ranges(3,localRoot), ranges(3,localRoot)+ranges(4,localRoot)-1
-               DO ji = ranges(1,localRoot), ranges(1,localRoot)+ranges(2,localRoot)-1
-                  exfld(ji-ranges(1,localRoot)+1,jj-ranges(3,localRoot)+1) = global_array(ji,jj)
-               ENDDO
-            ENDDO
-
-            DO jn = 1, localSize-1
-
-               DO jj = ranges(3,jn), ranges(3,jn)+ranges(4,jn)-1
-                  DO ji = ranges(1,jn), ranges(1,jn)+ranges(2,jn)-1
-                     buffer((jj-ranges(3,jn))*ranges(2,jn) + ji-ranges(1,jn)+1) = global_array(ji,jj)
-                  ENDDO
-               ENDDO
-
-!mpi           CALL mpi_send(buffer, ranges(5,jn), type, jn, jn, localComm, ierror)
-               CALL mppsend (jn, buffer, ranges(5,jn), jn, request)  
-
-            ENDDO
-
-         ENDIF
-
-         IF ( localRank /= localRoot ) THEN
-!mpi         CALL mpi_recv(exfld, range(5), type, localRoot, localRank, localComm, status, ierror)
-             CALL mpprecv(localRank, exfld, range(5))
-         ENDIF
-
-      ENDIF
-
-      IF ( action ) THEN
-
-         data_array = 0.0
-
-         DO jj = nldj, nlej
-            DO ji = nldi, nlei
-               data_array(ji,jj)=exfld(ji-nldi+1,jj-nldj+1)
-            ENDDO
-         ENDDO
-
-         IF (ln_ctl .and. lwp) THEN        
+      INTEGER,                      INTENT( IN    )   :: kid       ! variable intex in the array
+      INTEGER,                      INTENT( IN    )   :: kstep     ! ocean time-step in seconds
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( INOUT )   :: pdata     ! IN to keep the value if nothing is done
+      INTEGER,                      INTENT(   OUT )   :: kinfo     ! OASIS3 info argument
+      !!
+      LOGICAL                :: llaction
+      !!--------------------------------------------------------------------
+      !
+      ! receive local data from OASIS3 on every process
+      !
+      CALL prism_get_proto ( srcv(kid)%nid, kstep, exfld, kinfo )         
+
+      llaction = .false.
+      IF( kinfo == PRISM_Rcvd   .OR. kinfo == PRISM_FromRest .OR.   &
+          kinfo == PRISM_RcvOut .OR. kinfo == PRISM_FromRestOut )   llaction = .TRUE.
+
+      IF ( ln_ctl )   WRITE(numout,*) "llaction, kinfo, kstep, ivarid: " , llaction, kinfo, kstep, srcv(kid)%nid
+
+      IF ( llaction ) THEN
+
+         IF( lk_mpp ) THEN   ;   pdata(nldi:nlei, nldj:nlej) = exfld(:,:)
+         ELSE                ;   pdata(    :    ,     :    ) = exfld(:,:)
+         ENDIF
+         
+         !--- Fill the overlap areas and extra hallows (mpp)
+         !--- check periodicity conditions (all cases)
+         CALL lbc_lnk( pdata, srcv(kid)%cgrid, srcv(kid)%nsgn )   
+         
+         IF ( ln_ctl ) THEN        
             WRITE(numout,*) '****************'
-            DO ji = 1, nrecv
-               IF (var_id == recv_id(ji) ) THEN
-                  WRITE(numout,*) 'prism_get_proto: Incoming ', cpl_recv(ji)
-                  EXIT
-               ENDIF
-            ENDDO
-            WRITE(numout,*) 'prism_get_proto: var_id ', var_id
-            WRITE(numout,*) 'prism_get_proto:   date ', date
-            WRITE(numout,*) 'prism_get_proto:   info ', info
-            WRITE(numout,*) '     - Minimum value is ', MINVAL(data_array)
-            WRITE(numout,*) '     - Maximum value is ', MAXVAL(data_array)
-            WRITE(numout,*) '     -     Sum value is ', SUM(data_array)
+            WRITE(numout,*) 'prism_get_proto: Incoming ', srcv(kid)%cname
+            WRITE(numout,*) 'prism_get_proto: ivarid '  , srcv(kid)%nid
+            WRITE(numout,*) 'prism_get_proto:   kstep', kstep
+            WRITE(numout,*) 'prism_get_proto:   info ', kinfo
+            WRITE(numout,*) '     - Minimum value is ', MINVAL(pdata)
+            WRITE(numout,*) '     - Maximum value is ', MAXVAL(pdata)
+            WRITE(numout,*) '     -     Sum value is ', SUM(pdata)
             WRITE(numout,*) '****************'
          ENDIF
-
-      ENDIF
-#else
-      CALL prism_get_proto ( var_id, date, exfld, info)
-      
-      IF (info == PRISM_Recvd        .OR. &
-          info == PRISM_FromRest     .OR. &
-          info == PRISM_RecvOut      .OR. &
-          info == PRISM_FromRestOut )      THEN
-             data_array = exfld
-
-         IF (ln_ctl .and. lwp ) THEN        
-            WRITE(numout,*) '****************'
-            DO ji = 1, nrecv
-               IF (var_id == recv_id(ji) ) THEN
-                  WRITE(numout,*) 'prism_get_proto: Incoming ', cpl_recv(ji)
-                  EXIT
-               ENDIF
-            ENDDO
-            WRITE(numout,*) 'prism_get_proto: var_id ', var_id
-            WRITE(numout,*) 'prism_get_proto:   date ', date
-            WRITE(numout,*) 'prism_get_proto:   info ', info
-            WRITE(numout,*) '     - Minimum value is ', MINVAL(data_array)
-            WRITE(numout,*) '     - Maximum value is ', MAXVAL(data_array)
-            WRITE(numout,*) '     -     Sum value is ', SUM(data_array)
-            WRITE(numout,*) '****************'
-         ENDIF
-
-       ENDIF
-#endif
-
-   END SUBROUTINE cpl_prism_recv
-
+      
+      ENDIF
+
+   END SUBROUTINE cpl_prism_rcv
 
 
    SUBROUTINE cpl_prism_finalize
-
-      IMPLICIT NONE
 
       !!---------------------------------------------------------------------
@@ -1152,23 +303,30 @@
 
       DEALLOCATE(exfld)
-
-      if ( prism_was_initialized ) then
-
-         if ( prism_was_terminated ) then
-            print *, 'prism has already been terminated.'
-         else
-            call prism_terminate_proto ( ierror )
-            prism_was_terminated = .true.
-         endif
-
-      else
-
-         print *, 'Initialize prism before terminating it.'
-
-      endif
-
+      CALL prism_terminate_proto ( nerror )         
 
    END SUBROUTINE cpl_prism_finalize
 
+#else
+
+   !!----------------------------------------------------------------------
+   !!   Default case                                Forced Ocean/Atmosphere
+   !!----------------------------------------------------------------------
+   !!   Empty module
+   !!----------------------------------------------------------------------
+   USE in_out_manager               ! I/O manager
+   LOGICAL, PUBLIC, PARAMETER :: lk_cpl = .FALSE.   !: coupled flag
+   PUBLIC cpl_prism_init
+   PUBLIC cpl_prism_finalize
+
+CONTAINS
+
+   SUBROUTINE cpl_prism_init
+      WRITE(numout,*) 'cpl_prism_init: Error you sould not be there...'
+   END SUBROUTINE cpl_prism_init
+
+   SUBROUTINE cpl_prism_finalize
+      WRITE(numout,*) 'cpl_prism_finalize: Error you sould not be there...'
+   END SUBROUTINE cpl_prism_finalize
+
 #endif
 
Index: /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/sbc_ice.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/sbc_ice.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/sbc_ice.F90	(revision 991)
@@ -17,26 +17,18 @@
    IMPLICIT NONE
    PRIVATE
-
+! variables used in forced and coupled mode
 #if defined key_lim3 
    REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   qns_ice     !: non solar heat flux over ice  [W/m2]
    REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   qsr_ice     !: solar heat flux over ice      [W/m2]
    REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   dqns_ice    !: non solar heat flux sensibility over ice (LW+SEN+LA) [W/m2/K]
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   tn_ice      !: ice surface temperature       [K]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   alb_ice     !: albedo of ice
 #else
    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qns_ice     !: non solar heat flux over ice  [W/m2]
    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qsr_ice     !: solar heat flux over ice      [W/m2]
    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   dqns_ice    !: non solar heat flux sensibility over ice (LW+SEN+LA) [W/m2/K]
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   tn_ice      !: ice surface temperature       [K]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   alb_ice     !: albedo of ice
 #endif
 
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   tprecip     !: total precipitation           [Kg/m2/s]
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sprecip     !: solid precipitation           [Kg/m2/s]
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   utaui_ice   !: u-stress over ice (I-point)   [N/m2]
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   vtaui_ice   !: v-stress over ice (I-point)   [N/m2]
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   fr1_i0      !: 1st fraction of sol. rad.  which penetrate inside the ice cover
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   fr2_i0      !: 2nd fraction of sol. rad.  which penetrate inside the ice cover
-
-#if ! defined key_coupled
-
+! Variables used only in forced mode
 # if defined key_lim3 
    REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   qla_ice   !: latent flux over ice
@@ -47,15 +39,24 @@
 # endif
 
+! Variables used only in coupled mode
+#if defined key_lim3 
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   tn_ice      !: ice surface temperature       [K]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   tckice      !: ice thickness
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   tcksnw      !: oce thickness
 #else
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   tn_ice      !: ice surface temperature       [K]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   tckice      !: ice thickness
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   tcksnw      !: oce thickness
+#endif
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   freeze      !: ice fraction
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   tprecip     !: total precipitation for ice   [Kg/m2/s]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sprecip     !: solid precipitation ( - sublimation in coupled mode )          [Kg/m2/s]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   utaui_ice   !: u-stress over ice (I-point)   [N/m2]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   vtaui_ice   !: v-stress over ice (I-point)   [N/m2]
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   fr1_i0      !: 1st fraction of sol. rad.  which penetrate inside the ice cover
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   fr2_i0      !: 2nd fraction of sol. rad.  which penetrate inside the ice cover
 
-# if defined key_lim3 
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpl) ::   alb_ice   !: albedo of ice
-# else
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   alb_ice       !: albedo of ice
-# endif
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   rrunoff       !: runoff
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   calving       !: calving
-
-#endif
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   rnfcpl       !: runoff
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   ocalving     !: calving into the ocean
 
 #else
Index: /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/sbcblk_core.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/sbcblk_core.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/sbcblk_core.F90	(revision 991)
@@ -212,11 +212,9 @@
       !!      fields read in sbc_read
       !! 
-      !! ** Outputs : - utau    : i-component of the stress at U-point  (N/m2)
-      !!              - vtau    : j-component of the stress at V-point  (N/m2)
-      !!              - qsr     : Solar heat flux over the ocean        (W/m2)
-      !!              - qns     : Non Solar heat flux over the ocean    (W/m2)
-      !!              - evap    : Evaporation over the ocean            (kg/m2/s)
-      !!              - tprecip : Total precipitation                   (Kg/m2/s)
-      !!              - sprecip : Solid precipitation                   (Kg/m2/s)
+      !! ** Action  :   defined at each time-step at the air-sea interface
+      !!              - utau  &  vtau   : stress components in geographical ref.
+      !!              - qns   &  qsr    : non solar and solar heat fluxes
+      !!              - emp             : evap - precip (volume flux)
+      !!              - emps            : evap - precip (concentration/dillution)
       !!---------------------------------------------------------------------
       REAL(wp), INTENT(in), DIMENSION(jpi,jpj) ::   pst   ! surface temperature                      [Celcius]
Index: /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/sbccpl.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 991)
@@ -8,7 +8,7 @@
    !!            9.0   !  06-07  (G. Madec)  surface module
    !!----------------------------------------------------------------------
-#if defined key_sbc_cpl
-   !!----------------------------------------------------------------------
-   !!   'key_sbc_cpl'                   Coupled Ocean/Atmosphere formulation
+#if defined key_oasis3 || defined key_oasis4
+   !!----------------------------------------------------------------------
+   !!   'key_oasis3' or 'key_oasis4'   Coupled Ocean/Atmosphere formulation
    !!----------------------------------------------------------------------
    !!----------------------------------------------------------------------
@@ -16,87 +16,44 @@
    !!   sbc_cpl      : coupled formulation for the ocean surface boundary condition
    !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers
+
    USE dom_oce         ! ocean space and time domain
-   USE phycst          ! physical constants
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbc_ice         ! Surface boundary condition: ice fields
+#if defined key_lim3
+   USE par_ice          ! ice parameters
+#endif
+   USE cpl_oasis3      ! OASIS3 coupling (to ECHAM5)
+   USE geo2ocean
+   USE restart
    USE in_out_manager  ! I/O manager
+   USE iom             ! NetCDF library
    USE lib_mpp         ! distribued memory computing library
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE daymod          ! calendar
-
-   USE cpl_oasis3      ! OASIS3 coupling (to ECHAM5)
-   USE cpl_oasis4      ! OASIS4 coupling (to ECHAM5)
-   USE geo2ocean, ONLY : repere, repcmo
-   USE ice_2, only     : frld       ! : leads fraction = 1-a/totalarea
-
-   USE sbc_oce         ! Surface boundary condition: ocean fields
-
-   USE iom             ! NetCDF library
 
    IMPLICIT NONE
    PRIVATE
 
-   PUBLIC   sbc_cpl       ! routine called by step.F90
-
-   LOGICAL, PUBLIC ::   lk_sbc_cpl = .TRUE.   !: coupled formulation flag
-
-   INTEGER , PARAMETER                 ::   jpfld   = 5    ! maximum number of files to read 
-   INTEGER , PARAMETER                 ::   jp_taux = 1    ! index of wind stress (i-component) file
-   INTEGER , PARAMETER                 ::   jp_tauy = 2    ! index of wind stress (j-component) file
-   INTEGER , PARAMETER                 ::   jp_qtot = 3    ! index of total (non solar+solar) heat file
-   INTEGER , PARAMETER                 ::   jp_qsr  = 4    ! index of solar heat file
-   INTEGER , PARAMETER                 ::   jp_emp  = 5    ! index of evaporation-precipation file
+   PUBLIC   sbc_cpl_snd       ! routine called by step.F90
    
-!!wonsun         
-   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &
-      taux, tauy       &  !: surface stress components in (i,j) referential
-
-
-   USE sbc_ice, only : dqns_ice , & ! : derivative of non solar heat flux on sea ice
-                       qsr_ice  , & ! : solar flux over ice
-                       qns_ice  , & ! : total non solar heat flux (Longwave downward radiation) over ice
-                       tn_ice   , & ! : ice surface temperature
-                       alb_ice  , & ! : albedo of ice
-                       sprecip  , & ! : solid (snow) precipitation over water (!) what about ice?
-                       tprecip  , & ! : total precipitation ( or liquid precip minus evaporation in coupled mode)
-                       calving  , & ! : calving
-                       rrunoff  , & ! : monthly runoff (kg/m2/s)
-                       fr1_i0   , & ! : 1st part of the fraction of sol.rad. which penetrate inside the ice cover
-                       fr2_i0       ! : 2nd part of the fraction of sol.rad. which penetrate inside the ice cover
-
-   USE ice_2, only  : hicif ,     & ! : ice thickness
-                      frld  ,     & ! : leads fraction = 1-a/totalarea
-                      hsnif  ,    & ! : snow thickness
-                      u_ice , v_ice ! : ice velocity
-
-   USE sbc_oce, only : sst_m        ! : sea surface temperature
-
-   REAL(wp), PUBLIC ::            & !!! surface fluxes namelist (namflx)
-      q0    = 0.e0,               &  ! net heat flux
-      qsr0  = 0.e0,               &  ! solar heat flux
-      emp0  = 0.e0,               &  ! net freshwater flux
-      dqdt0 = -40.,               &  ! coefficient for SST damping (W/m2/K)
-      deds0 = 27.7                   ! coefficient for SSS damping (mm/day)
+   TYPE ::   FLD_CPL     ! Coupling Namelist field informations
+      LOGICAL            ::   laction   ! 
+      CHARACTER(len = 8) ::   clname      ! 
+      CHARACTER(len = 1) ::   clgrid      !
+      INTEGER            ::   nsgn      !
+   END TYPE FLD_CPL
    
-    REAL(wp), DIMENSION(jpi,jpj) ::   qsr_oce_recv , qsr_ice_recv 
-    REAL(wp), DIMENSION(jpi,jpj) ::   qns_oce_recv, qns_ice_recv
-    REAL(wp), DIMENSION(jpi,jpj) ::   dqns_ice_recv
-    REAL(wp), DIMENSION(jpi,jpj) ::   tprecip_recv , precip_recv
-    REAL(wp), DIMENSION(jpi,jpj) ::   fr1_i0_recv  , fr2_i0_recv     
-    REAL(wp), DIMENSION(jpi,jpj) ::   rrunoff_recv , calving_recv   
-#if defined key_cpl_ocevel
-    REAL(wp), DIMENSION(jpi,jpj) :: un_weighted, vn_weighted
-    REAL(wp), DIMENSION(jpi,jpj) :: un_send    , vn_send 
-#endif
-    REAL(wp), DIMENSION(jpi,jpj) :: zrunriv   ! river discharge into ocean
-    REAL(wp), DIMENSION(jpi,jpj) :: zruncot   ! continental discharge into ocean
-
-    REAL(wp), DIMENSION(jpi,jpj) :: zpew      ! P-E over water
-    REAL(wp), DIMENSION(jpi,jpj) :: zpei      ! P-E over ice
-    REAL(wp), DIMENSION(jpi,jpj) :: zpsol     ! surface downward snow fall
-    REAL(wp), DIMENSION(jpi,jpj) :: zevice    ! surface upward snow flux where sea ice
-!!wonsun         
-
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
+
+   TYPE(FLD_CPL):: sn_snd_fice
+
+
+
+
+
+
+   REAL(wp), DIMENSION(jpi,jpj) :: qsr_mix
+
+
+
+
    !!----------------------------------------------------------------------
    !!   OPA 9.0 , LOCEAN-IPSL (2006) 
@@ -107,277 +64,535 @@
 CONTAINS
 
-   SUBROUTINE sbc_cpl( kt )
+   SUBROUTINE sbc_cpl_init
+ 
+      NAMELIST/namsbc_cpl_rcv/ ...
+
+
       !!---------------------------------------------------------------------
-      !!                    ***  ROUTINE sbc_cpl  ***
-      !!                   
-      !! ** Purpose :   provide at each time step the surface ocean fluxes
-      !!                (momentum, heat, freshwater and runoff) in coupled mode
-      !!
-      !! ** Method  : - Recieve from a Atmospheric model via OASIS coupler :
-      !!                   i-component of the stress              taux  (N/m2)
-      !!                   j-component of the stress              tauy  (N/m2)
-      !!                   net downward heat flux                 qtot  (watt/m2)
-      !!                   net downward radiative flux            qsr   (watt/m2)
-      !!                   net upward freshwater (evapo - precip) emp   (kg/m2/s)
-      !!              - send to the Atmospheric model via OASIS coupler :
-      !!
-      !! ** Action  :   update at each time-step the two components of the 
-      !!                surface stress in both (i,j) and geographical ref.
-      !!
-      !!
-      !!      CAUTION :  - never mask the surface stress fields
-      !!
-      !! ** Action  :   update at each time-step
-      !!              - taux  & tauy    : stress components in (i,j) referential
-      !!              - qns             : non solar heat flux
-      !!              - qsr             : solar heat flux
-      !!              - emp             : evap - precip (volume flux)
-      !!              - emps            : evap - precip (concentration/dillution)
-      !!
-      !! References : The OASIS User Guide, Version 3.0 and 4.0
+
+
+
+
+         REWIND( numnam )                    ! ... read in namlist namsbc_cpl_rcv
+         READ  ( numnam, namsbc_cpl_rcv )
+         
+         !-------------------------------------
+         !-------------------------------------
+         ! Define the receive interface
+         !-------------------------------------
+         !-------------------------------------
+         !
+         ! Read restart of variables for coupling (needed to compute some values from the received data)
+
+
+!!$   Probleme: definir comment on initialise freeze, alb_ice et tn_ice 
+!!$             quand on n'a pas de restart (a nit000)
+
+
+         CALL iom_get( numror, 'freeze' , freeze  )
+         IF ( TRIM(cn_rcv_qsr) == 'mixed oce-ice' ) CALL iom_get( numror, 'alb_ice', alb_ice )
+!!!!!
+!!!!! +++ ERIC tu utilises tn_ice dans le calcule de Qns, c'est bien ca???
+!!!!!
+         IF ( TRIM(cn_rcv_qns) == 'mixed oce-ice' ) CALL iom_get( numror, 'tn_ice' , tn_ice  )
+
+
+
+
+
+         ! default definitions of srcv
+         nrcv = 0
+         srcv(:)%cgrid = 'T'
+         srcv(:)%nsgn = 1
+
+         !-------------------------------------
+         ! Qsr
+         nrcv = nrcv + 1   ;   jprcv_qsroce = nrcv   ;   srcv(nrcv)%cname = 'O_QsrOce'
+         nrcv = nrcv + 1   ;   jprcv_qsrice = nrcv   ;   srcv(nrcv)%cname = 'O_QsrIce'
+         nrcv = nrcv + 1   ;   jprcv_qsrmix = nrcv   ;   srcv(nrcv)%cname = 'O_QsrMix'
+         SELECT CASE (TRIM(cn_rcv_qsr))
+         CASE( 'conservative'  )   ;   srcv( (/jprcv_qsrice, jprcv_qsrmix/) )%laction = .TRUE.
+         CASE( 'oce and ice'   )   ;   srcv( (/jprcv_qsrice, jprcv_qsroce/) )%laction = .TRUE.
+         CASE( 'mixed oce-ice' )   ;   srcv(                 jprcv_qsrmix   )%laction = .TRUE. 
+         CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_rcv_qsr' )
+         END SELECT
+
+         !-------------------------------------
+         ! Qns
+         nrcv = nrcv + 1   ;   jprcv_qnsoce = nrcv   ;   srcv(nrcv)%cname = 'O_QnsOce'
+         nrcv = nrcv + 1   ;   jprcv_qnsice = nrcv   ;   srcv(nrcv)%cname = 'O_QnsIce'
+         nrcv = nrcv + 1   ;   jprcv_qnsmix = nrcv   ;   srcv(nrcv)%cname = 'O_QnsMix'
+         SELECT CASE (TRIM(cn_rcv_qns))
+         CASE( 'conservative'  )   ;   srcv( (/jprcv_qnsice, jprcv_qnsmix/) )%laction = .TRUE.
+         CASE( 'oce and ice'   )   ;   srcv( (/jprcv_qnsice, jprcv_qnsoce/) )%laction = .TRUE.
+         CASE( 'mixed oce-ice' )   ;   srcv(                 jprcv_qnsmix   )%laction = .TRUE. 
+         CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_rcv_qns' )
+         END SELECT
+
+         !-------------------------------------
+         ! emp, tprecip and sprecip
+         nrcv = nrcv + 1   ;   jprcv_rain = nrcv   ;   srcv(nrcv)%cname = 'OIceRain'   ! Rain = liquid precipitation
+         nrcv = nrcv + 1   ;   jprcv_snow = nrcv   ;   srcv(nrcv)%cname = 'OIceSnow'   
+         nrcv = nrcv + 1   ;   jprcv_tevp = nrcv   ;   srcv(nrcv)%cname = 'OTotEvap'   ! total evaporation ( over oce + ice )
+         nrcv = nrcv + 1   ;   jprcv_ievp = nrcv   ;   srcv(nrcv)%cname = 'OIceEvap'   ! evaporation iver ice (sublimation)
+         nrcv = nrcv + 1   ;   jprcv_tpre = nrcv   ;   srcv(nrcv)%cname = 'OIPr-Sub'   ! Pr = liquid + solid precipitation
+         nrcv = nrcv + 1   ;   jprcv_spre = nrcv   ;   srcv(nrcv)%cname = 'OISn-Sub'   ! Sub = Sublimation = Evap over ice
+         nrcv = nrcv + 1   ;   jprcv_oemp = nrcv   ;   srcv(nrcv)%cname = 'OOEv-OPr'   ! 
+         SELECT CASE (TRIM(cn_rcv_emp))
+         CASE( 'conservative'  )   ;   srcv( (/jprcv_rain, jprcv_snow, jprcv_ievp, jprcv_tevp/) )%laction = .TRUE.
+         CASE( 'oce and ice'   )   ;   srcv( (/            jprcv_tpre, jprcv_spre, jprcv_oemp/) )%laction = .TRUE.
+         CASE( 'mixed oce-ice' )   ;   srcv( (/jprcv_rain,             jprcv_spre, jprcv_tevp/) )%laction = .TRUE. 
+         CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_rcv_emp' )
+         END SELECT
+
+         !-------------------------------------
+         ! wind stress : utau, vtau, utaui_ice, vtaui_ice 
+         ! oce stress
+         nrcv = nrcv + 1   ;   jprcv_otx1 = nrcv   ;   srcv(nrcv)%cname = 'O_OTaux1' ! oce tau 1st component on 1st grid
+         nrcv = nrcv + 1   ;   jprcv_oty1 = nrcv   ;   srcv(nrcv)%cname = 'O_OTauy1' ! oce tau 2nd component on 1st grid
+         nrcv = nrcv + 1   ;   jprcv_otz1 = nrcv   ;   srcv(nrcv)%cname = 'O_OTauz1' ! oce tau 3rd component on 1st grid
+         nrcv = nrcv + 1   ;   jprcv_otx2 = nrcv   ;   srcv(nrcv)%cname = 'O_OTaux2' ! oce tau 1st component on 2nd grid
+         nrcv = nrcv + 1   ;   jprcv_oty2 = nrcv   ;   srcv(nrcv)%cname = 'O_OTauy2' ! oce tau 2nd component on 2nd grid
+         nrcv = nrcv + 1   ;   jprcv_otz2 = nrcv   ;   srcv(nrcv)%cname = 'O_OTauz2' ! oce tau 3rd component on 2nd grid
+         ! ice stress
+         nrcv = nrcv + 1   ;   jprcv_itx1 = nrcv   ;   srcv(nrcv)%cname = 'O_ITaux1' ! ice tau 1st component on 1st grid
+         nrcv = nrcv + 1   ;   jprcv_ity1 = nrcv   ;   srcv(nrcv)%cname = 'O_ITauy1' ! ice tau 2nd component on 1st grid
+         nrcv = nrcv + 1   ;   jprcv_itz1 = nrcv   ;   srcv(nrcv)%cname = 'O_ITauz1' ! ice tau 3rd component on 1st grid
+         nrcv = nrcv + 1   ;   jprcv_itx2 = nrcv   ;   srcv(nrcv)%cname = 'O_ITaux2' ! ice tau 1st component on 2nd grid
+         nrcv = nrcv + 1   ;   jprcv_ity2 = nrcv   ;   srcv(nrcv)%cname = 'O_ITauy2' ! ice tau 2nd component on 2nd grid
+         nrcv = nrcv + 1   ;   jprcv_itz2 = nrcv   ;   srcv(nrcv)%cname = 'O_ITauz2' ! ice tau 3rd component on 2nd grid
+         ! change default definition of srcv(:)%nsgn
+         srcv(jprcv_otx1:jprcv_itz2)%nsgn = -1
+         ! change default definition of srcv(:)%cgrid and srcv(:)%laction
+         SELECT CASE (LEN_TRIM(cn_rcv_stress(4)))   !  'T' 'U,V' 'U,V,F' 'U,V,I' 'T,F' 'T,I' 'T,U,V'
+         CASE( 1 )   ! 'T'
+            srcv(jprcv_otx1:jprcv_itz2)%cgrid = cltmp(1)   ! all oce and ice components on the same unique grid
+            srcv(jprcv_otx1:jprcv_otz1)%laction = .TRUE.   ! oce components on 1 grid 
+            srcv(jprcv_itx1:jprcv_itz1)%laction = .TRUE.   ! ice components on 1 grid 
+         CASE( 3 )   ! 'U,V' 'T,F' 'T,I'
+            cltmp = cn_rcv_stress(4)
+            SELECT CASE (cltmp(1))
+            CASE( 'T' )   ! 'T,F' 'T,I'
+                  srcv(jprcv_otx1:jprcv_otz2)%cgrid = cltmp(1)   ! oce and ice tau on 2 grids
+                  srcv(jprcv_itx1:jprcv_itz2)%cgrid = cltmp(3)   ! but oce(ice) components on the same grid
+                  srcv(jprcv_otx1:jprcv_otz1)%laction = .TRUE.   ! oce components on 1 grid
+                  srcv(jprcv_itx1:jprcv_itz1)%laction = .TRUE.   ! ice components on 1 grid
+            CASE( 'U' )   ! 'U,V'
+               IF ( cltmp(3) := 'V' ) THEN CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_rcv_stress(4)' )
+               srcv(jprcv_otx1:jprcv_otz1)%cgrid = cltmp(1)   ! oce(ice) components on 2 grids
+               srcv(jprcv_otx2:jprcv_otz2)%cgrid = cltmp(3)
+               srcv(jprcv_itx1:jprcv_itz1)%cgrid = cltmp(1)
+               srcv(jprcv_itx2:jprcv_itz2)%cgrid = cltmp(3)
+               srcv(jprcv_otx1:jprcv_itz2)%laction = .TRUE.   ! oce(ice) components on 2 grids
+            CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_rcv_stress(4)' )
+            END SELECT
+         CASE( 5 )   ! 'U,V,F' 'U,V,I' 'T,U,V'
+            cltmp = cn_rcv_stress(4)
+            SELECT CASE (cltmp(1))
+            CASE( 'T' )   ! 'T,U,V'
+                  srcv(jprcv_otx1:jprcv_otz2)%cgrid = cltmp(1)    ! oce components on 1 grid
+                  srcv(jprcv_itx1:jprcv_itz1)%cgrid = cltmp(3)    ! ice components on 2 grids
+                  srcv(jprcv_itx2:jprcv_itz2)%cgrid = cltmp(5)
+                  srcv(jprcv_otx1:jprcv_otz1)%laction = .TRUE.    ! oce components on 1 grid
+                  srcv(jprcv_itx1:jprcv_itz2)%laction = .TRUE.    ! ice components on 2 grids
+            CASE( 'U' )   ! 'U,V,F' 'U,V,I' 
+               IF ( cltmp(3) := 'V' ) THEN CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_rcv_stress(4)' )
+               srcv(jprcv_otx1:jprcv_otz1)%cgrid = cltmp(1)    ! oce components on 2 grids
+               srcv(jprcv_otx2:jprcv_otz2)%cgrid = cltmp(3)
+               srcv(jprcv_itx1:jprcv_itz2)%cgrid = cltmp(5)    ! ice components on 1 grid
+               srcv(jprcv_otx1:jprcv_otz2)%laction = .TRUE.    ! oce components on 2 grids 
+               srcv(jprcv_itx1:jprcv_itz1)%laction = .TRUE.    ! ice components on 1 grid 
+            CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_rcv_stress(4)' )
+            END SELECT
+         CASE default   ;   CALL ctl_stop( 'sbc_cpl_init: wrong definition of cn_rcv_stress(4)' )
+         END SELECT
+         ! force .FALSE. to 3rd component for spherical coodinates
+         IF ( TRIM(cn_rcv_stress(2)) == 'spherical' ) srcv((/jprcv_otz1, jprcv_otz2, jprcv_itz1, jprcv_itz2/))%laction = .FALSE. 
+         ! force .FALSE. to ice components if not 'oce and ice'
+         IF ( TRIM(cn_rcv_stress(1)) /= 'oce and ice' )   srcv(jprcv_itx1:jprcv_itz2)%laction = .FALSE. 
+
+         !-------------------------------------
+         ! 10 m wind speed
+         nrcv = nrcv + 1   ;   jprcv_w10m = nrcv   ;   srcv(nrcv)%cname = 'O_Wind10'
+         IF ( TRIM(cn_rcv_w10m) == 'coupled' ) srcv(jprcv_w10m)%laction = .TRUE.
+         ! +++ ---> A brancher et a blinder dans tke  si TRIM(cn_rcv_w10m) == 'none'
+
+         !-------------------------------------
+         ! d(Qns)/d(T) 
+         nrcv = nrcv + 1   ;   jprcv_dqnsdt = nrcv   ;   srcv(nrcv)%cname = 'O_dQnsdT'
+         IF ( TRIM(cn_rcv_dqnsdt) == 'coupled' ) srcv(jprcv_dqnsdt)%laction = .TRUE.
+
+         !-------------------------------------
+         ! Runoff
+         nrcv = nrcv + 1   ;   jprcv_rnf = nrcv   ;   srcv(nrcv)%cname = 'O_Runoff'
+         IF ( TRIM(cn_rcv_rnf) /= 'climato' ) srcv(jprcv_rnf)%laction = .TRUE.
+         ! +++ ---> A brancher  
+
+         !-------------------------------------
+         ! Calving
+         nrcv = nrcv + 1   ;   jprcv_cal = nrcv   ;   srcv(nrcv)%cname = 'OCalving'
+         IF ( TRIM(cn_rcv_cal) == 'coupled' ) srcv(jprcv_cal)%laction = .TRUE.
+         ! +++ ---> A brancher  
+
+         !-------------------------------------
+         ! fraction of net shortwave radiation which is not absorbed in the 
+         ! thin surface layer and penetrates inside the ice cover 
+         !  ( Maykut and Untersteiner, 1971 ; Elbert anbd Curry, 1993 )
+         ! Since cloud cover catm not transmitted from atmosphere 
+         ! ===> defined as constant value -> definition done in sbc_cpl_init
+!!$      catm(:,:) = 0.
+!!$      zcatm1(:,:) = 1.0 - catm(:,:)  !  fractional cloud cover
+!!$      fr1_i0(:,:) = 0.18 * zcatm1(:,:) + 0.35 * catm(:,:) 
+!!$      fr2_i0(:,:) = 0.82 * zcatm1(:,:) + 0.65 * catm(:,:)
+         fr1_i0(:,:) = 0.18
+         fr2_i0(:,:) = 0.82
+
+         !
+         !-------------------------------------
+         !-------------------------------------
+         ! Define the send interface
+         !-------------------------------------
+         !-------------------------------------
+         !
+         ! default definitions of nsnd
+         nsnd = 0
+         ssnd(:)%cgrid = 'T'
+         ssnd(:)%nsgn = 1
+         
+         !-------------------------------------
+         ! Ice fraction
+         nsnd = nsnd + 1   ;   jpsnd_fice = nsnd   ;   ssnd(nsnd)%cname = 'OIceFrac'
+         ssnd(jpsnd_fice)%laction = .TRUE.
+         
+         !-------------------------------------
+         ! T surf
+         nsnd = nsnd + 1   ;   jpsnd_toce = nsnd   ;   ssnd(nsnd)%cname = 'O_SSTSST'
+         nsnd = nsnd + 1   ;   jpsnd_tice = nsnd   ;   ssnd(nsnd)%cname = 'O_TepIce'
+         nsnd = nsnd + 1   ;   jpsnd_tmix = nsnd   ;   ssnd(nsnd)%cname = 'O_TepMix'
+         SELECT CASE (TRIM(cn_snd_temperature))
+         CASE( 'oce only'             )   ;   ssnd(   jpsnd_toce               )%laction = .TRUE.
+         CASE( 'weighted oce and ice' )   ;   ssnd( (/jpsnd_toce, jpsnd_tice/) )%laction = .TRUE.
+         CASE( 'mixed oce-ice'        )   ;   ssnd(   jpsnd_tmix               )%laction = .TRUE.
+         END SELECT
+
+         !-------------------------------------
+         ! Albedo
+         nsnd = nsnd + 1   ;   jpsnd_albice = nsnd   ;   ssnd(nsnd)%cname = 'O_AlbIce'
+         nsnd = nsnd + 1   ;   jpsnd_albmix = nsnd   ;   ssnd(nsnd)%cname = 'O_AlbMix'
+         SELECT CASE (TRIM(cn_snd_albedo))
+         CASE( 'none'          )       ! nothing to do
+         CASE( 'weighted ice'  )   ;   ssnd(jpsnd_albice)%laction = .TRUE.
+         CASE( 'mixed oce-ice' )   ;   ssnd(jpsnd_albmix)%laction = .TRUE.
+         END SELECT
+         
+         !-------------------------------------
+         ! Thickness
+         nsnd = nsnd + 1   ;   jpsnd_tckice = nsnd   ;   ssnd(nsnd)%cname = 'O_IceTck'
+         nsnd = nsnd + 1   ;   jpsnd_tcksnw = nsnd   ;   ssnd(nsnd)%cname = 'O_SnwTck'
+         IF ( TRIM(cn_snd_thickness) == 'weighted ice and snow' ) ssnd( (/jpsnd_tckice, jpsnd_tcksnw/) )%laction = .TRUE.
+         
+         !-------------------------------------
+         ! Surface current
+         nsnd = nsnd + 1   ;   jpsnd_uoce = nsnd   ;   ssnd(nsnd)%cname = 'O_UN_Oce'
+         nsnd = nsnd + 1   ;   jpsnd_voce = nsnd   ;   ssnd(nsnd)%cname = 'O_VN_OcE'
+         nsnd = nsnd + 1   ;   jpsnd_uice = nsnd   ;   ssnd(nsnd)%cname = 'O_UN_Ice'
+         nsnd = nsnd + 1   ;   jpsnd_vice = nsnd   ;   ssnd(nsnd)%cname = 'O_VN_IcE'
+         nsnd = nsnd + 1   ;   jpsnd_umix = nsnd   ;   ssnd(nsnd)%cname = 'O_UN_Mix'
+         nsnd = nsnd + 1   ;   jpsnd_vmix = nsnd   ;   ssnd(nsnd)%cname = 'O_VN_Mix'
+         ssnd(jpsnd_uoce:jpsnd_vmix)%nsgn = -1
+         SELECT CASE (TRIM(cn_snd_current(1)))
+         CASE( 'none'                 )       ! nothing to do
+         CASE( 'oce only'             )   ;   ssnd( (/jpsnd_uoce, jpsnd_voce                        /) )%laction = .TRUE.
+         CASE( 'weighted oce and ice' )   ;   ssnd( (/jpsnd_uoce, jpsnd_voce, jpsnd_uice, jpsnd_vice/) )%laction = .TRUE.
+         CASE( 'mixed oce-ice'        )   ;   ssnd( (/jpsnd_umix, jpsnd_vmix                        /) )%laction = .TRUE.
+         END SELECT
+         
+         !
+         !-------------------------------------
+         !-------------------------------------
+         CALL cpl_prism_define
+         !-------------------------------------
+         !-------------------------------------
+         !
+
+   END SUBROUTINE sbc_cpl_init
+
+
+
+   SUBROUTINE sbc_cpl_rcv( kt )
+
+      IF( kt == nit000 )   CALL sbc_cpl_init
+
+      isec = ( kt - nit000 ) * NINT(rdttra(1))        ! date of exchanges
+
+      !-------------------------------------
+      ! Qsr : we must get qsr and qsr_ice
+      IF ( srcv(jprcv_qsroce)%laction ) CALL cpl_prism_rcv( jprcv_qsroce, isec, qsr    , info ) 
+      IF ( srcv(jprcv_qsrice)%laction ) CALL cpl_prism_rcv( jprcv_qsrice, isec, qsr_ice, info ) 
+      IF ( srcv(jprcv_qsrmix)%laction ) CALL cpl_prism_rcv( jprcv_qsrmix, isec, qsr_mix, info )        
+      SELECT CASE (TRIM(cn_rcv_qsr))
+      CASE( 'conservative' )
+         qsr(:,:) = ( qsr_mix(:,:) - freeze(:,:) * qsr_ice(:,:) ) / (1. - freeze(:,:))
+      CASE( 'oce and ice' )
+         ! nothing to do
+      CASE( 'mixed oce-ice' )
+         ztmp(:,:) = qsr_mix(:,:) / (1. - ( 0.065*(1. - freeze(:,:)) + freeze(:,:)*alb_ice(:,:)) )
+         qsr_ice(:,:) = ztmp(:,:) * (1. - alb_ice(:,:))
+         qsr    (:,:) = ztmp(:,:) * (1. - 0.065)
+      END SELECT
+
+      !-------------------------------------
+      ! Qns : we must get qns and qns_ice
+      IF ( srcv(jprcv_qnsoce)%laction ) CALL cpl_prism_rcv( jprcv_qnsoce, isec, qns    , info ) 
+      IF ( srcv(jprcv_qnsice)%laction ) CALL cpl_prism_rcv( jprcv_qnsice, isec, qns_ice, info ) 
+      IF ( srcv(jprcv_qnsmix)%laction ) CALL cpl_prism_rcv( jprcv_qnsmix, isec, qns_mix, info )        
+      SELECT CASE (TRIM(cn_rcv_qns))
+      CASE( 'conservative' )
+         qns(:,:) = ( qns_mix(:,:) - freeze(:,:) * qns_ice(:,:) ) / (1. - freeze(:,:))
+      CASE( 'oce and ice' )
+         ! nothing to do
+      CASE( 'mixed oce-ice' )
+!!!!!
+!!!!! +++ ERIC il faut que tu mettes les bonnes formules...
+!!!!!
+!!$         qns_ice(:,:) = ...
+!!$         qns    (:,:) = ...
+      END SELECT
+
+      !-------------------------------------
+      ! Precipitations and Evaporation: we must get emp tprecip and sprecip
+      ! sprecip = snow_ice - evap_ice
+      ! tprecip = ( rain_ice + snow_ice ) - evap_ice
+      ! emp     = emp_oce = evap_oce - ( rain_oce + snow_oce ) ... runoff??? ... calving???
+      IF ( srcv(jprcv_snow)%laction )   CALL cpl_prism_rcv( jprcv_snow, isec, zsnow  , info ) ! snow
+      IF ( srcv(jprcv_rain)%laction )   CALL cpl_prism_rcv( jprcv_rain, isec, zrain  , info ) ! Rain = liquid precipitation
+      IF ( srcv(jprcv_tevp)%laction )   CALL cpl_prism_rcv( jprcv_tevp, isec, ztevp  , info ) ! total evaporation (over oce + ice)
+      IF ( srcv(jprcv_ievp)%laction )   CALL cpl_prism_rcv( jprcv_ievp, isec, zievp  , info ) ! evaporation over ice (sublimation)
+      IF ( srcv(jprcv_tpre)%laction )   CALL cpl_prism_rcv( jprcv_tpre, isec, tprecip, info ) ! see above
+      IF ( srcv(jprcv_spre)%laction )   CALL cpl_prism_rcv( jprcv_spre, isec, sprecip, info ) ! see above
+      IF ( srcv(jprcv_oemp)%laction )   CALL cpl_prism_rcv( jprcv_oemp, isec, emp    , info ) ! see above
+      SELECT CASE (TRIM(cn_rcv_emp))
+      CASE( 'conservative' )
+         sprecip(:,:) = zsnow(:,:) - zievp(:,:)
+         tprecip(:,:) = zrain(:,:) + sprecip(,:)
+         emp(:,:) = ( ztevp(:,:) - zievp(:,:)*(1. - freeze(:,:)) )/freeze(:,:) - tprecip(:,:)
+      CASE( 'oce and ice' )
+         ! nothing to do
+      CASE( 'mixed oce-ice' )
+         tprecip(:,:) = zrain(:,:) + sprecip(:,:)
+         emp(:,:) = ztevp(:,:) - ( tprecip(:,:) + sprecip(:,:) )
+      END SELECT
+      
+      !-------------------------------------
+      ! wind stress : we must get utau, vtau, utaui_ice, vtaui_ice 
+      ! oce stress
+      IF ( srcv(jprcv_otx1)%laction )   CALL cpl_prism_rcv( jprcv_otx1, isec, zotx1, info ) ! oce tau 1st component on 1st grid
+      IF ( srcv(jprcv_oty1)%laction )   CALL cpl_prism_rcv( jprcv_oty1, isec, zoty1, info ) ! oce tau 2nd component on 1st grid
+      IF ( srcv(jprcv_otz1)%laction )   CALL cpl_prism_rcv( jprcv_otz1, isec, zotz1, info ) ! oce tau 3rd component on 1st grid
+      IF ( srcv(jprcv_otx2)%laction )   CALL cpl_prism_rcv( jprcv_otx2, isec, zotx2, info ) ! oce tau 1st component on 2nd grid
+      IF ( srcv(jprcv_oty2)%laction )   CALL cpl_prism_rcv( jprcv_oty2, isec, zoty2, info ) ! oce tau 2nd component on 2nd grid
+      IF ( srcv(jprcv_otz2)%laction )   CALL cpl_prism_rcv( jprcv_otz2, isec, zotz2, info ) ! oce tau 3rd component on 2nd grid
+      ! ice stress
+      IF ( srcv(jprcv_itx1)%laction )   CALL cpl_prism_rcv( jprcv_itx1, isec, zitx1, info ) ! ice tau 1st component on 1st grid
+      IF ( srcv(jprcv_ity1)%laction )   CALL cpl_prism_rcv( jprcv_ity1, isec, zity1, info ) ! ice tau 2nd component on 1st grid
+      IF ( srcv(jprcv_itz1)%laction )   CALL cpl_prism_rcv( jprcv_itz1, isec, zitz1, info ) ! ice tau 3rd component on 1st grid
+      IF ( srcv(jprcv_itx2)%laction )   CALL cpl_prism_rcv( jprcv_itx2, isec, zitx2, info ) ! ice tau 1st component on 2nd grid
+      IF ( srcv(jprcv_ity2)%laction )   CALL cpl_prism_rcv( jprcv_ity2, isec, zity2, info ) ! ice tau 2nd component on 2nd grid
+      IF ( srcv(jprcv_itz2)%laction )   CALL cpl_prism_rcv( jprcv_itz2, isec, zitz2, info ) ! ice tau 3rd component on 2nd grid
+      ! cartesian to spherical coordinates -> 3 components to 2 components
+      IF ( TRIM(cn_rcv_stress(2)) == 'cartesian' ) THEN 
+         ! wind stress over ocean
+         SELECT CASE (srcv(jprcv_otx1)%cgrid) 
+         CASE( 'T' ) 
+            CALL geo2oce ( zotx1, zoty1, zotz1, 'T', glamt, gphit, ztmpx1, ztmpy1 ) ! 1st and 2nd components on the same grid
+         CASE( 'F' )
+            CALL geo2oce ( zotx1, zoty1, zotz1, 'F', glamf, gphif, ztmpx1, ztmpy1 ) ! 1st and 2nd components on the same grid
+         CASE( 'U' )
+            CALL geo2oce ( zotx1, zoty1, zotz1, 'U', glamu, gphiu, ztmpx1, ztmpy1 ) ! 1st and 2nd components on the 1st grid
+            CALL geo2oce ( zotx2, zoty2, zotz2, 'V', glamv, gphiv, ztmpx2, ztmpy2 ) ! 1st and 2nd components on the 2nd grid
+            zotx2(:,:) = ztmpx2(:,:)   ! overwrite 1st component on the 2nd grid
+            zoty2(:,:) = ztmpy2(:,:)   ! overwrite 2nd component on the 2nd grid
+         END SELECT
+         zotx1(:,:) = ztmpx1(:,:)   ! overwrite 1st component on the 1st grid
+         zoty1(:,:) = ztmpy1(:,:)   ! overwrite 2nd component on the 1st grid
+         ! wind stress over ice
+         IF ( srcv(jprcv_itx1)%laction ) THEN 
+            SELECT CASE (srcv(jprcv_itx1)%cgrid) 
+            CASE( 'T' ) 
+               CALL geo2oce ( zitx1, zity1, zitz1, 'T', glamt, gphit, ztmpx1, ztmpy1 ) ! 1st and 2nd comp. on the same grid
+            CASE( 'F' )
+               CALL geo2oce ( zitx1, zity1, zitz1, 'F', glamf, gphif, ztmpx1, ztmpy1 ) ! 1st and 2nd comp. on the same grid
+            CASE( 'U' )
+               CALL geo2oce ( zitx1, zity1, zitz1, 'U', glamu, gphiu, ztmpx1, ztmpy1 ) ! 1st and 2nd comp. on the 1st grid
+               CALL geo2oce ( zitx2, zity2, zitz2, 'V', glamv, gphiv, ztmpx2, ztmpy2 ) ! 1st and 2nd comp. on the 2nd grid
+               zitx2(:,:) = ztmpx2(:,:)   ! overwrite 1st comp. on the 2nd grid
+               zity2(:,:) = ztmpy2(:,:)   ! overwrite 2nd comp. on the 2nd grid
+            END SELECT
+            zitx1(:,:) = ztmpx1(:,:)   ! overwrite 1st comp. on the 1st grid
+            zity1(:,:) = ztmpy1(:,:)   ! overwrite 2nd comp. on the 2nd grid
+         ENDIF
+      ENDIF
+
+      ! 'eastward-northward' to 'local grid' axes -> totate the components
+      IF ( TRIM(cn_rcv_stress(3)) == 'eastward-northward' ) THEN                        ! Oce component
+         call rot_rep( zotx1, zoty1, srcv(jprcv_otx1)%cgrid, 'en->i', ztmpx1 )      ! 1st component on the 1st grid
+         zotx1(:,:) = ztmpx1(:,:)      ! overwrite 1st component on the 1st grid
+         IF ( srcv(jprcv_otx2)%laction ) then 
+            call rot_rep( zotx2, zoty2, srcv(jprcv_otx2)%cgrid, 'en->j', ztmpy2 )   ! 2nd component on the 2nd grid
+            zoty2(:,:) = ztmpy2(:,:)   ! overwrite 2nd component on the 2nd grid
+         ELSE
+            call rot_rep( zotx1, zoty1, srcv(jprcv_otx1)%cgrid, 'en->j', ztmpy1 )   ! 2nd component on the 1st grid
+            zoty1(:,:) = ztmpy1(:,:)   ! overwrite 2nd component on the 1st grid
+         ENDIF
+         IF ( srcv(jprcv_itx1)%laction ) THEN                                            ! Ice component
+            call rot_rep( zitx1, zity1, srcv(jprcv_itx1)%cgrid, 'en->i', ztmpx1 )      ! 1st component on the 1st grid
+            zitx1(:,:) = ztmpx1(:,:)      ! overwrite 1st component on the 1st grid
+            IF ( srcv(jprcv_itx2)%laction ) THEN
+               call rot_rep( zitx2, zity2, srcv(jprcv_itx2)%cgrid, 'en->j', ztmpy2 )   ! 2nd component on the 2nd grid
+               zity2(:,:) = ztmpy2(:,:)   ! overwrite 2nd component on the 2nd grid
+            ELSE
+               call rot_rep( zitx1, zity1, srcv(jprcv_itx1)%cgrid, 'en->j', ztmpy1 )   ! 2nd component on the 1st grid
+               zity1(:,:) = ztmpy1(:,:)   ! overwrite 2nd component on the 1st grid
+            ENDIF
+         ENDIF
+      ENDIF
+
+      ! oce stress must be on U,V grids
+      IF ( srcv(jprcv_otx1)%cgrid == 'T' ) THEN
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+              utau(ji,jj) = 0.5 * ( zotx1(ji,jj) + zotx1(ji+1,jj  ) ) ! T -> U grid
+              vtau(ji,jj) = 0.5 * ( zoty1(ji,jj) + zoty1(ji  ,jj+1) ) ! T -> V grid
+            END DO
+         END DO
+         CALL lbc_lnk( utau, 'U',  -1. )   ;   CALL lbc_lnk( vtau, 'V',  -1. )
+      ELSE
+         utau(:,:) = zotx1(:,:)
+         vtau(:,:) = zoty2(:,:)
+      ENDIF
+
+      ! make sure we have stress over ice
+      IF ( TRIM(cn_rcv_stress(1)) /= 'oce and ice' ) THEN 
+         zitx1(:,:) = zotx1(:,:)                                                ! 1st component on the 1st grid
+         IF ( srcv(jprcv_otx2)%laction ) THEN   ;   zity2(:,:) = zoty2(:,:)   ! 2nd component on the 2nd grid
+         ELSE                                     ;   zity1(:,:) = zoty1(:,:)   ! 2nd component on the 1st grid
+         ENDIF
+         srcv(jprcv_itx1)%cgrid = srcv(jprcv_otx1)%cgrid   ! update grid of the ice component
+      ENDIF
+      
+      ! ice stress must be on I grid
+      SELECT CASE ( srcv(jprcv_itx1)%cgrid )
+      CASE( 'U' )
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               utaui_ice(ji,jj) = 0.5 * ( zitx1(ji-1,jj  ) + zitx1(ji-1,jj-1) ) ! U -> I grid
+               vtaui_ice(ji,jj) = 0.5 * ( zity2(ji  ,jj-1) + zity2(ji-1,jj-1) ) ! V -> I grid
+            END DO
+         END DO
+         CALL lbc_lnk( utaui_ice, 'I',  -1. )   ;   CALL lbc_lnk( vtaui_ice, 'I',  -1. )
+      CASE( 'F' )
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               utaui_ice(ji,jj) = zitx1(ji-1,jj-1) ! F -> I grid
+               vtaui_ice(ji,jj) = zity1(ji-1,jj-1) ! F -> I grid
+            END DO
+         END DO
+         CALL lbc_lnk( utaui_ice, 'I',  -1. )   ;   CALL lbc_lnk( vtaui_ice, 'I',  -1. )
+      CASE( 'T' )
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               utaui_ice(ji,jj) = 0.25 * ( zitx1(ji,jj) + zitx1(ji-1,jj) + zitx1(ji,jj-1) + zitx1(ji-1,jj-1) ) ! T -> I grid
+               vtaui_ice(ji,jj) = 0.25 * ( zity1(ji,jj) + zity1(ji-1,jj) + zity1(ji,jj-1) + zity1(ji-1,jj-1) ) ! T -> I grid
+            END DO
+         END DO
+         CALL lbc_lnk( utaui_ice, 'I',  -1. )   ;   CALL lbc_lnk( vtaui_ice, 'I',  -1. )
+      CASE( 'I' )
+         utaui_ice(:,:) = zitx1(:,:)
+         vtaui_ice(:,:) = zity1(:,:)
+      END SELECT
+      
+      !-------------------------------------
+      ! 10 m wind speed
+      ! +++ ---> blinder dans tke  si TRIM(cn_rcv_w10m) == 'none'
+!!$     +++ IF ( srcv(jprcv_w10m  )%laction )   CALL cpl_prism_rcv( jprcv_dqnsdt, isec, wind10, info )
+      
+      !-------------------------------------
+      ! d(Qns)/d(T) 
+      IF ( srcv(jprcv_dqnsdt)%laction )   CALL cpl_prism_rcv( jprcv_dqnsdt, isec, dqns_ice, info )
+      
+      !-------------------------------------
+      ! Runoff
+      IF ( srcv(jprcv_rnf   )%laction )   CALL cpl_prism_rcv( jprcv_rnf   , isec, rnfcpl, info )
+      
+      !-------------------------------------
+      ! Calving
+      IF ( srcv(jprcv_cal   )%laction )   CALL cpl_prism_rcv( jprcv_cal   , isec, ocalving, info )
+      
+      !  fraction of net shortwave radiation which is not absorbed in the 
+      !  thin surface layer and penetrates inside the ice cover 
+      !  ( Maykut and Untersteiner, 1971 ; Elbert anbd Curry, 1993 )
+      !------------------------------------------------------------------
+      ! Since cloud cover catm not transmitted from atmosphere
+      ! ===> defined as constant value -> definition done in sbc_cpl_init
+
+   END SUBROUTINE sbc_cpl_rcv
+   
+   SUBROUTINE sbc_cpl_snd( kt )
+      
+      isec = ( kt - nit000 ) * NINT(rdttra(1))        ! date of exxhanges
+
+      !-------------------------------------
+      ! Ice fraction
+      IF ( ssnd(jpsnd_fice)%laction ) CALL cpl_prism_snd( jpsnd_fice, isec, freeze, info )
+
+      !-------------------------------------
+      ! T surf
+      ztmp(:,:) = tn(:,:,1) + rt0
+      SELECT CASE (TRIM(cn_snd_temperature))
+      CASE( 'oce only'             )       ! nothing to do
+      CASE( 'weighted oce and ice' )   ;   ztmp = ztmp(:,:) * (1. - freeze(:,:))
+      CASE( 'mixed oce-ice'        )   ;   ztmp = ztmp(:,:) * (1. - freeze(:,:)) + tn_ice(:,:)*freeze(:,:)
+      END SELECT
+      IF ( ssnd(jpsnd_toce)%laction ) CALL cpl_prism_snd( jpsnd_toce, isec, ztmp, info )
+      IF ( ssnd(jpsnd_tice)%laction ) CALL cpl_prism_snd( jpsnd_tice, isec, tn_ice(:,:) * freeze(:,:), info )
+      IF ( ssnd(jpsnd_tmix)%laction ) CALL cpl_prism_snd( jpsnd_tmix, isec, ztmp, info )
+      
+      !-------------------------------------
+      ! Albedo
+      IF ( ssnd(jpsnd_albice)%laction ) CALL cpl_prism_snd( jpsnd_albice, isec, alb_ice(:,:) * freeze(:,:), info )
+      IF ( ssnd(jpsnd_albmix)%laction ) THEN 
+!!!!! +++ ERIC   ztmp(:,:) = albedo de l'ocean a definir...
+         CALL cpl_prism_snd( jpsnd_albmix, isec, ztmp(:,:) * (1. - freeze(:,:)) + alb_ice(:,:) * freeze(:,:), info )
+      ENDIF
+      
+      !-------------------------------------
+      ! Thickness
+      IF ( ssnd(jpsnd_tckice)%laction ) CALL cpl_prism_snd( jpsnd_tckice, isec, tckice(:,:) * freeze(:,:), info )
+      IF ( ssnd(jpsnd_tcksnw)%laction ) CALL cpl_prism_snd( jpsnd_tcksnw, isec, tcksnw(:,:) * freeze(:,:), info )
+
+
+      
+      !-------------------------------------
+      ! Surface current
+
+      +++ seb ecriture des restarts...
+
+
+   END SUBROUTINE sbc_cpl_snd
+   
+
+
+
+
+#else
       !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kt   ! ocean time step
-      !!
-      INTEGER  ::   ji, jj      ! dummy loop indices
-#if defined key_cpl_ocevel
-      INTEGER  ::   ikchoix 
+      !!   Dummy routine                              NO coupling
+      !!----------------------------------------------------------------------
+
++++ a verifier ...
+
+
 #endif
-      INTEGER  ::   var_id, info
-      INTEGER  ::   date          !????  !!gm bug  this is a real !!!
-      REAL(wp) ::   zfacflx, zfacwat, zfact
-
-      REAL(wp), DIMENSION(jpi,jpj) ::   ztaueuw, ztauevw   ! eastward  wind stress over water at U and V-points
-      REAL(wp), DIMENSION(jpi,jpj) ::   ztaunuw, ztaunvw   ! northward wind stress over water at U and V-points
-      REAL(wp), DIMENSION(jpi,jpj) ::   ztaueui, ztauevi   ! eastward  wind stress over ice   at U and V-points
-      REAL(wp), DIMENSION(jpi,jpj) ::   ztaunui, ztaunvi   ! northward wind stress over ice   at U and V-points
-      REAL(wp), DIMENSION(jpi,jpj) ::   ztaueu , ztauev    ! eastward wind stress combined
-      REAL(wp), DIMENSION(jpi,jpj) ::   ztaunu , ztaunv    ! northward wind stress combined 
-      !!---------------------------------------------------------------------
-
-      date = ( kt - nit000 ) * rdttra(1)        ! date of exxhanges
-      !                                         ! Conversion factor (ocean units are W/m2 and Kg/m2/s]
-      zfacflx = 1.e0  ! no conversion    [W/m2]         ! W/m2 heat fluxes are send by the Atmosphere 
-      zfacwat = 1.e3  ! convert [m/s] to [kg/m2/s]      ! m/s freshwater fluxes are send by the atmosphere
-
-
-      !                                         ! =========================== !
-      !                                         !     Send Coupling fields    !
-      !                                         ! =========================== !
-      ! 
-!!gm bug ?  here send instantaneous SST, not mean over the coupling period....
-      var_id = send_id(1)   ;   CALL cpl_prism_send( var_id, date, tn(:,:,1)+rt0, info )   ! ocean surface temperature [K]
-      var_id = send_id(2)   ;   CALL cpl_prism_send( var_id, date, 1.0-frld     , info )   ! fraction of ice-cover
-#if defined key_cpl_albedo
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            IF( ( tn_ice(ji,jj) < 50 .OR. tn_ice(ji,jj) > 400 ) .AND. frld(ji,jj) < 1. ) THEN
-              WRITE(numout,*) ' tn_ice, ERROR ', ji, jj, ' = ', tn_ice(ji,jj),   &
-                 &            ' qns_ice_recv=', qns_ice_recv(ji,jj), ' dqns_ice_recv=', dqns_ice_recv(ji,jj)
-            ENDIF
-         END DO
-      END DO
-      var_id = send_id(3)   ;   CALL cpl_prism_send( var_id, date, tn_ice      , info )    ! ice surface temperature [K]  
-      var_id = send_id(4)   ;   CALL cpl_prism_send( var_id, date, alb_ice     , info )    ! ice albedo [%]
-#else
-      var_id = send_id(3)   ;   CALL cpl_prism_send( var_id, date, hicif       , info )    ! ice  thickness [m]
-      var_id = send_id(4)   ;   CALL cpl_prism_send( var_id, date, hsnif       , info )    ! snow thickness [m]
-#endif
-#if defined key_cpl_ocevel
-!!gm bug???  I have to check the grid point position...
-!!           a priori there is a error here as un, vn are not at the same grid point....
-!!           there should be a averaged to set u and v at T-point.... with caution for sea-ice velocity at I-point....
-      un_weighted = un(:,:,1) * frld + u_ice * ( 1. - frld )
-      vn_weighted = vn(:,:,1) * frld + v_ice * ( 1. - frld )
-      ikchoix = - 1         ! converte from (i,j) to geographic referential
-      CALL repere( un_weighted, vn_weighted, un_send, vn_send, ikchoix )
-!!gm bug : at lbc_lnk is to be added on un_send and vn_send  
-      var_id = send_id(5)   ;   CALL cpl_prism_send( var_id, date, un_send    , info )        ! surface current [m/s]
-      var_id = send_id(6)   ;   CALL cpl_prism_send( var_id, date, vn_send    , info )        ! surface current [m/s]
-#endif
-
-      !                                         ! =========================== !
-      !                                         !   Recieve Momentum fluxes   !
-      !                                         ! =========================== !
-      ! 
-      ! ... Receive wind stress fields in geographic component over water and ice
-      var_id = recv_id(1)   ;   CALL cpl_prism_recv( var_id, date, ztaueuw, info )           ! ???
-      var_id = recv_id(2)   ;   CALL cpl_prism_recv( var_id, date, ztaunuw, info )
-      var_id = recv_id(3)   ;   CALL cpl_prism_recv( var_id, date, ztaueui, info )
-      var_id = recv_id(4)   ;   CALL cpl_prism_recv( var_id, date, ztaunui, info )
-      var_id = recv_id(5)   ;   CALL cpl_prism_recv( var_id, date, ztauevw, info )
-      var_id = recv_id(6)   ;   CALL cpl_prism_recv( var_id, date, ztaunvw, info )
-      var_id = recv_id(7)   ;   CALL cpl_prism_recv( var_id, date, ztauevi, info )
-      var_id = recv_id(8)   ;   CALL cpl_prism_recv( var_id, date, ztaunvi, info )
-      !
-!!gm bug : keep separate ice and ocean stress !
-      ! ... combine water / ice stresses
-      ztaueu(:,:) = ztaueuw(:,:) * frld(:,:) + ztaueui(:,:) * ( 1.0 - frld(:,:) )
-      ztaunu(:,:) = ztaunuw(:,:) * frld(:,:) + ztaunui(:,:) * ( 1.0 - frld(:,:) )
-      ztauev(:,:) = ztauevw(:,:) * frld(:,:) + ztauevi(:,:) * ( 1.0 - frld(:,:) )
-      ztaunv(:,:) = ztaunvw(:,:) * frld(:,:) + ztaunvi(:,:) * ( 1.0 - frld(:,:) )
-      !
-      ! ... rotate vector components from geographic to (i,j) referential
-      CALL repcmo ( ztaueu, ztaunu, ztauev, ztaunv, utau, vtau, kt )
-      !
-!!gm bug??  not sure but put that for security
-      CALL lbc_lnk( utau , 'U', -1. )
-      CALL lbc_lnk( vtau , 'V', -1. )
-!!gm end bug??
-      !
-      !                                         ! =========================== !
-      !                                         !     Recieve heat fluxes     !
-      !                                         ! =========================== !
-      !
-      var_id = recv_id(13)   ;   CALL cpl_prism_recv( var_id, date, qsr_oce_recv , info )   ! ocean surface net downward shortwave flux
-      var_id = recv_id(14)   ;   CALL cpl_prism_recv( var_id, date, qns_oce_recv , info )   ! ocean surface downward non-solar heat flux
-      var_id = recv_id(15)   ;   CALL cpl_prism_recv( var_id, date, qsr_ice_recv , info )   ! ice solar heat flux
-      var_id = recv_id(16)   ;   CALL cpl_prism_recv( var_id, date, qns_ice_recv , info )   ! ice non-solar heat flux
-      var_id = recv_id(17)   ;   CALL cpl_prism_recv( var_id, date, dqns_ice_recv, info )   ! ice non-solar heat flux sensitivity
-
-      qsr_oce_recv (:,:) = qsr_oce_recv (:,:) * tmask(:,:,1) * zfacflx
-      qns_oce_recv (:,:) = qns_oce_recv (:,:) * tmask(:,:,1) * zfacflx
-      qsr_ice_recv (:,:) = qsr_ice_recv (:,:) * tmask(:,:,1) * zfacflx
-      qns_ice_recv (:,:) = qns_ice_recv (:,:) * tmask(:,:,1) * zfacflx
-      dqns_ice_recv(:,:) = dqns_ice_recv(:,:) * tmask(:,:,1) * zfacflx
-
-      IF( kt == nit000 ) THEN                   ! set once for all qsr penetration in sea-ice
-         !                                      ! Since cloud cover catm not transmitted from atmosphere, it is set to 0. 
-         !                                      ! i.e. constant penetration fractions of 0.18 and 0.82
-         !  fraction of net shortwave radiation which is not absorbed in the thin surface layer and penetrates
-         !  inside the ice cover ( Maykut and Untersteiner, 1971 ; Elbert anbd Curry, 1993 )
-         fr1_i0_recv(:,:) = 0.18 
-         fr2_i0_recv(:,:) = 0.82
-      ENDIF
-      !
-      !                                         ! =========================== !
-      !                                         !  Recieve freshwater fluxes  !
-      !                                         ! =========================== !
-      !
-      var_id = recv_id( 9)   ;   CALL cpl_prism_recv( var_id, date, zpew  , info )      ! P-E over water
-      var_id = recv_id(10)   ;   CALL cpl_prism_recv( var_id, date, zpei  , info )      ! P-E over ice
-      var_id = recv_id(11)   ;   CALL cpl_prism_recv( var_id, date, zpsol , info )      ! Snow fall over water and ice
-      var_id = recv_id(12)   ;   CALL cpl_prism_recv( var_id, date, zevice, info )      ! Evaporation over ice (sublimination)
-      !
-      ! ... calculate water flux (P-E over open ocean and ice) and solid precipitation  (positive upward)
-      tprecip_recv(:,:) = ( zpew (:,:) + zpei  (:,:) ) * tmask(:,:,1) * zfacwat
-      sprecip_recv(:,:) = ( zpsol(:,:) + zevice(:,:) ) * tmask(:,:,1) * zfacwat
-      
-      ! ... Control print & check
-      IF(ln_ctl) THEN
-         WRITE(numout,*) ' flx:tprecip_recv    - Minimum value is ', MINVAL( tprecip_recv )
-         WRITE(numout,*) ' flx:tprecip_recv    - Maximum value is ', MAXVAL( tprecip_recv )
-         WRITE(numout,*) ' flx:tprecip_recv    -     Sum value is ', SUM   ( tprecip_recv )
-      ENDIF
-!!gm bug in mpp SUM require a mmp_sum call
-!!gm further more this test is quite expensive ...  only needed at the first time-step???
-      IF( SUM( zpew*e1t*e2t ) /= SUM( zpew*e1t*e2t*tmask(:,:,1) ) ) THEN
-         WRITE(numout,*) ' flx: Forcing values outside Orca mask'
-         WRITE(numout,*) ' flx: Losses in water conservation'
-         WRITE(numout,*) ' flx:   Masked ', SUM(zpew*e1t*e2t*tmask(:,:,1))
-         WRITE(numout,*) ' flx: Unmasked ', SUM(zpew*e1t*e2t)
-         WRITE(numout,*) ' flx: Simulation STOP'
-         CALL FLUSH(numout)
-         STOP
-      END IF
-      !
-#if defined key_cpl_discharge
-      ! Runoffs
-      var_id = recv_id(18)   ;   CALL cpl_prism_recv ( var_id, date, calving_recv, info )   ! ice discharge into ocean
-      var_id = recv_id(19)   ;   CALL cpl_prism_recv ( var_id, date, zrunriv     , info )   ! river discharge into ocean
-      var_id = recv_id(20)   ;   CALL cpl_prism_recv ( var_id, date, zruncot     , info )   ! continental discharge into ocean
-
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            zfact = zfacwat * tmask(ji,jj,1) 
-            calving_recv(ji,jj) =               calving_recv(ji,jj)   * zfact
-            rrunoff_recv(ji,jj) = ( zrunriv(ji,jj) + zruncot(ji,jj) ) * zfact
-         END DO
-      END DO
-#else
-      calving_recv(:,:) = 0.
-      rrunoff_recv(:,:) = 0.
-#endif
-
-!!gm  bug  :  this is not valid in mpp
-!!gm          and I presum this is not required at all as a lbc_lnk is applied to all the fields at the end of the routine
-      ! Oasis mask shift and update lateral boundary conditions (E. Maisonnave)
-      ! not tested when mpp is used, W. Park
-!WSPTEST
-      qsr_oce_recv (jpi-1,:) = qsr_oce_recv (1,:)
-      qsr_ice_recv (jpi-1,:) = qsr_ice_recv (1,:)
-      qns_oce_recv (jpi-1,:) = qns_oce_recv (1,:)
-      qns_ice_recv (jpi-1,:) = qns_ice_recv (1,:)
-      dqns_ice_recv(jpi-1,:) = dqns_ice_recv(1,:)
-      tprecip_recv (jpi-1,:) = tprecip_recv (1,:)
-      sprecip_recv (jpi-1,:) = sprecip_recv (1,:)
-      fr1_i0_recv  (jpi-1,:) = fr1_i0_recv  (1,:)
-      fr2_i0_recv  (jpi-1,:) = fr2_i0_recv  (1,:)
-      rrunoff_recv (jpi-1,:) = rrunoff_recv (1,:)
-      calving_recv (jpi-1,:) = calving_recv (1,:)
-!!gm end bug
-
-      qsr     (:,:) = qsr_oce_recv (:,:)      ! ocean surface boundary condition
-      qns     (:,:) = qns_oce_recv (:,:)
-      emp     (:,:) = zpew         (:,:)
-      emps    (:,:) = zpew         (:,:)
-      
-      qsr_ice (:,:) = qsr_ice_recv (:,:)      ! ice forcing fields
-      qns_ice (:,:) = qns_ice_recv (:,:)
-      dqns_ice(:,:) = dqns_ice_recv(:,:)
-      tprecip (:,:) = tprecip_recv (:,:)
-      sprecip (:,:) = sprecip_recv (:,:)
-      fr1_i0  (:,:) = fr1_i0_recv  (:,:)
-      fr2_i0  (:,:) = fr2_i0_recv  (:,:)
-      
-!WSP    rrunoff = rrunoff_recv 
-!WSP    calving = calving_recv
-      rrunoff (:,:) = 0.e0   !WSP runoff and calving included in tprecip
-      calving (:,:) = 0.e0   !WSP
- 
-      IF(ln_ctl) THEN
-         WRITE(numout,*) 'flx:qsr_oce     - Minimum value is ', MINVAL( qsr_oce )
-         WRITE(numout,*) 'flx:qsr_oce     - Maximum value is ', MAXVAL( qsr_oce )
-         WRITE(numout,*) 'flx:qsr_oce     -     Sum value is ', SUM   ( qsr_oce )
-         !
-         WRITE(numout,*) 'flx:tprecip     - Minimum value is ', MINVAL( tprecip )
-         WRITE(numout,*) 'flx:tprecip     - Maximum value is ', MAXVAL( tprecip )
-         WRITE(numout,*) 'flx:tprecip     -     Sum value is ', SUM   ( tprecip )
-      ENDIF
-
-      CALL lbc_lnk( qsr_oce , 'T', 1. )
-      CALL lbc_lnk( qsr_ice , 'T', 1. )
-      CALL lbc_lnk( qns_oce , 'T', 1. )
-      CALL lbc_lnk( qns_ice , 'T', 1. )
-      CALL lbc_lnk( tprecip , 'T', 1. )
-      CALL lbc_lnk( sprecip , 'T', 1. )
-      CALL lbc_lnk( rrunoff , 'T', 1. )
-      CALL lbc_lnk( dqns_ice, 'T', 1. )
-      CALL lbc_lnk( calving , 'T', 1. )
-      CALL lbc_lnk( fr1_i0  , 'T', 1. )
-      CALL lbc_lnk( fr2_i0  , 'T', 1. )
-
-      IF(ln_ctl) THEN
-         WRITE(numout,*) 'flx(af lbc_lnk):qsr_oce     - Minimum value is ', MINVAL( qsr_oce )
-         WRITE(numout,*) 'flx(af lbc_lnk):qsr_oce     - Maximum value is ', MAXVAL( qsr_oce )
-         WRITE(numout,*) 'flx(af lbc_lnk):qsr_oce     -     Sum value is ', SUM   ( qsr_oce )
-         !
-         WRITE(numout,*) 'flx(af lbc_lnk):tprecip     - Minimum value is ', MINVAL( tprecip )
-         WRITE(numout,*) 'flx(af lbc_lnk):tprecip     - Maximum value is ', MAXVAL( tprecip )
-         WRITE(numout,*) 'flx(af lbc_lnk):tprecip     -     Sum value is ', SUM   ( tprecip )
-      ENDIF
-      !
-   END SUBROUTINE sbc_cpl
-
-#else
-   !!----------------------------------------------------------------------
-   !!   Dummy routine                              NO sea surface restoring
-   !!----------------------------------------------------------------------
-   LOGICAL, PUBLIC ::   lk_sbc_cpl = .FALSE.   !: coupled formulation flag
-CONTAINS
-   SUBROUTINE sbc_cpl( kt )         ! Dummy routine
-      WRITE(*,*) 'sbc_cpl: you should not have seen that print! error?', kt
-   END SUBROUTINE sbc_cpl
-#endif
-
-   !!======================================================================
-END MODULE sbccpl
+
+      !!======================================================================
+   END MODULE sbccpl
Index: /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/sbcice_lim_2.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/sbcice_lim_2.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/sbcice_lim_2.F90	(revision 991)
@@ -12,9 +12,9 @@
    !!   'key_lim2' :                                  LIM 2.0 sea-ice model
    !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
    !!   sbc_ice_lim_2  : sea-ice model time-stepping and
    !!                    update ocean sbc over ice-covered area
    !!----------------------------------------------------------------------
    USE oce             ! ocean dynamics and tracers
-   USE c1d             ! 1d configuration
    USE dom_oce         ! ocean space and time domain
    USE ice_2
@@ -46,5 +46,4 @@
    USE in_out_manager  ! I/O manager
    USE prtctl          ! Print control
-   USE ocfzpt          ! ocean freezing point
 
    IMPLICIT NONE
@@ -59,6 +58,6 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/SBC  3.0 , LOCEAN-IPSL (2008) 
-   !! $Id: $
+   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
+   !! $ Id: $
    !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
@@ -90,5 +89,4 @@
       !!
       INTEGER  ::   ji, jj   ! dummy loop indices
-      REAL(wp) ::   zinda    
       REAL(wp), DIMENSION(jpi,jpj,1) ::   alb_ice_os   ! albedo of the ice under overcast sky
       REAL(wp), DIMENSION(jpi,jpj,1) ::   alb_ice_cs   ! albedo of ice under clear sky
@@ -126,12 +124,17 @@
 
          ! ... masked sea surface freezing temperature [Kelvin] (set to rt0 over land)
-         tfu(:,:) = tfreez( sss_m ) +  rt0 
-
-         zsist (:,:,1) = sist (:,:)
-         zhicif(:,:,1) = hicif(:,:)   ;   zhsnif(:,:,1) = hsnif(:,:)
+         tfu(:,:) = tfreez( sss_m ) + rt0 
+
 
          ! ... ice albedo
-         CALL albedo_ice( zsist, zhicif, zhsnif, alb_ice_cs, alb_ice_os )
-
+         
+         IF ( nsbc /= 5 ) THEN
++++ INTERFACE 2D/3D suprimer les tableaux intermediaires
++++ les mettre sous cle cpp
++++ il faudrait utiliser les variables de transfert pour tn_ice, ice/snow thickness, albedo...
+
+            zsist (:,:,1) = sist (:,:)
+            zhicif(:,:,1) = hicif(:,:)   ;   zhsnif(:,:,1) = hsnif(:,:)
+            CALL albedo_ice( zsist, zhicif, zhsnif, alb_ice_cs, alb_ice_os )
          ! ... Sea-ice surface boundary conditions output from bulk formulae :
          !     - utaui_ice  ! surface ice stress i-component (I-point)   [N/m2]
@@ -154,13 +157,4 @@
                &                               tprecip   , sprecip    ,                          &
                &                               fr1_i0    , fr2_i0     , cl_grid  )
-
-            ! CAUTION: ocean shortwave radiation sets to zero if more than 50% of sea-ice !!gm to be removed
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zinda    = MAX(  0.e0, SIGN(  1.e0, -( -1.5 - freeze(ji,jj) )  )  )
-                  qsr(ji,jj) = zinda * qsr(ji,jj)
-               END DO
-            END DO
-
          CASE( 4 )           ! CORE bulk formulation
             CALL blk_ice_core( zsist , ui_ice , vi_ice   , alb_ice_cs ,                         &
@@ -175,4 +169,5 @@
          qla_ice(:,:) = zqla_ice(:,:,1)   ;   dqla_ice(:,:) = zdqla_ice(:,:,1)
 
+         ENDIF
          IF(ln_ctl) THEN         ! print mean trends (used for debugging)
             CALL prt_ctl_info( 'Ice Forcings ' )
@@ -188,15 +183,13 @@
          !  Ice model step  !
          ! ---------------- !
-                                        CALL lim_rst_opn_2  ( kt )      ! Open Ice restart file
-         IF( .NOT. lk_c1d ) THEN                                        ! Ice dynamics & transport (not in 1D case)
-                                        CALL lim_dyn_2      ( kt )           ! Ice dynamics    ( rheology/dynamics )
-                                        CALL lim_trp_2      ( kt )           ! Ice transport   ( Advection/diffusion )
-            IF( ln_limdmp )             CALL lim_dmp_2      ( kt )           ! Ice damping 
-         ENDIF
-                                        CALL lim_thd_2      ( kt )      ! Ice thermodynamics 
-                                        CALL lim_sbc_2      ( kt )      ! Ice/Ocean Mass & Heat fluxes 
+         ;                              CALL lim_rst_opn_2  ( kt )      ! Open Ice restart file
+         ;                              CALL lim_dyn_2      ( kt )      ! Ice dynamics    ( rheology/dynamics )
+         ;                              CALL lim_trp_2      ( kt )      ! Ice transport   ( Advection/diffusion )
+         IF( ln_limdmp )                CALL lim_dmp_2      ( kt )      ! Ice damping 
+         ;                              CALL lim_thd_2      ( kt )      ! Ice thermodynamics 
+         ;                              CALL lim_sbc_2      ( kt )      ! Ice/Ocean Mass & Heat fluxes 
          IF( MOD( kt+nn_fsbc-1, ninfo ) == 0 .OR.   &
             &  ntmoy == 1 )             CALL lim_dia_2      ( kt )      ! Ice Diagnostics 
-                                        CALL lim_wri_2      ( kt )      ! Ice outputs 
+         ;                              CALL lim_wri_2      ( kt )      ! Ice outputs 
          IF( lrst_ice )                 CALL lim_rst_write_2( kt )      ! Ice restart file 
          !
Index: /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/sbcmod.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 991)
@@ -49,5 +49,5 @@
    LOGICAL , PUBLIC ::   ln_blk_clio = .FALSE.   !: CLIO bulk formulation
    LOGICAL , PUBLIC ::   ln_blk_core = .FALSE.   !: CORE bulk formulation
-   LOGICAL , PUBLIC ::   ln_cpl      = .FALSE.   !: coupled   formulation (overwritten by key_sbc_coupled )
+   LOGICAL , PUBLIC ::   ln_cpl      = .FALSE.   !: coupled   formulation (overwritten by key_oasis3/4 )
    LOGICAL , PUBLIC ::   ln_dm2dc    = .FALSE.   !: Daily mean to Diurnal Cycle short wave (qsr)
    LOGICAL , PUBLIC ::   ln_rnf      = .FALSE.   !: runoffs / runoff mouths
Index: /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/sbcrnf_ORCA_R05.h90
===================================================================
--- /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/sbcrnf_ORCA_R05.h90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/OPA_SRC/SBC/sbcrnf_ORCA_R05.h90	(revision 991)
@@ -84,7 +84,4 @@
       INTEGER, INTENT( in  ) ::   kt ! ocean time step
 
-#if defined key_coupled
-      runoff(:,:) = 0.0e0
-#else
       !!----------------------------------------------------------------------
       !!  ORCA_R05
@@ -1532,6 +1529,4 @@
          ENDIF
       ENDIF
-    
-#endif
 
    END SUBROUTINE flx_rnf
Index: /branches/dev_003_CPL/NEMO/OPA_SRC/geo2ocean.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/OPA_SRC/geo2ocean.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/OPA_SRC/geo2ocean.F90	(revision 991)
@@ -329,5 +329,5 @@
 
    SUBROUTINE geo2oce ( pxx , pyy , pzz, cgrid,     &
-                        plon, plat, pte, ptn  , ptv )
+                        plon, plat, pte, ptn )
       !!----------------------------------------------------------------------
       !!                    ***  ROUTINE geo2oce  ***
@@ -346,24 +346,15 @@
       !!----------------------------------------------------------------------
       !! * Local declarations
-      REAL(wp), INTENT( in ), DIMENSION(jpi,jpj) ::   &
-         pxx, pyy, pzz
-      CHARACTER (len=1), INTENT( in) ::   &
-         cgrid
-      REAL(wp), INTENT( in ), DIMENSION(jpi,jpj) ::   &
-         plon, plat
-      REAL(wp), INTENT(out), DIMENSION(jpi,jpj) ::    &
-         pte, ptn, ptv
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( IN    ) ::  pxx, pyy, pzz
+      CHARACTER(len=1)            , INTENT( IN    ) ::  cgrid
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( IN    ) ::  plon, plat
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(   OUT ) ::  pte, ptn
+      !
       REAL(wp), PARAMETER :: rpi = 3.141592653E0
       REAL(wp), PARAMETER :: rad = rpi / 180.e0
-
-      !! * Local variables
       INTEGER ::   ig     !
-
       !! * Local save
-      REAL(wp), SAVE, DIMENSION(jpi,jpj,4) ::   &
-         zsinlon, zcoslon,   &
-         zsinlat, zcoslat
-      LOGICAL, SAVE, DIMENSION (4) ::   &
-         linit = .FALSE.
+      REAL(wp), SAVE, DIMENSION(jpi,jpj,4) ::   zsinlon, zcoslon, zsinlat, zcoslat
+      LOGICAL , SAVE, DIMENSION(4)         ::   linit = .FALSE.
       !!----------------------------------------------------------------------
 
@@ -392,7 +383,7 @@
             - zsinlon (:,:,ig) * zsinlat (:,:,ig) * pyy    &
             + zcoslat (:,:,ig) * pzz
-      ptv =   zcoslon (:,:,ig) * zcoslat (:,:,ig) * pxx    &
-            + zsinlon (:,:,ig) * zcoslat (:,:,ig) * pyy    &
-            + zsinlat (:,:,ig) * pzz
+!!$      ptv =   zcoslon (:,:,ig) * zcoslat (:,:,ig) * pxx    &
+!!$            + zsinlon (:,:,ig) * zcoslat (:,:,ig) * pyy    &
+!!$            + zsinlat (:,:,ig) * pzz
 
    END SUBROUTINE geo2oce
Index: /branches/dev_003_CPL/NEMO/OPA_SRC/ice_oce.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/OPA_SRC/ice_oce.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/OPA_SRC/ice_oce.F90	(revision 991)
@@ -33,16 +33,4 @@
    !! ice-ocean common variables
    !!----------------------------------------------------------------------
-# if defined key_coupled
-   REAL(wp), PUBLIC, DIMENSION(jpiglo,jpjglo) ::   &  !: cumulated fields
-      fqsr_oce ,      &   !: Net short wave heat flux on free ocean 
-      fqsr_ice ,      &   !: Net short wave heat flux on sea ice 
-      fqnsr_oce,      &   !: Net longwave heat flux on free ocean
-      fqnsr_ice,      &   !: Net longwave heat flux on sea ice
-      fdqns_ice,      &   !: Derivative of non solar heat flux on sea ice
-      ftprecip ,      &   !: Water flux (liquid precipitation - evaporation) 
-      fsprecip ,      &   !: Solid (snow) precipitation
-      frunoff  ,      &   !: runoff
-      fcalving            !: Iceberg calving 
-# endif
 
 # if defined key_lim3
@@ -51,11 +39,10 @@
       tatm_ice       , &  !: air temperature
       icethi              !: icethickness
-# endif
-   
+# endif   
    REAL(wp), PUBLIC ::   &  !:
       rdt_ice,           &  !: ice time step
       dtsd2                 !: ice time step divide by 2
+#else
 
-#else
    !!----------------------------------------------------------------------
    !!   Default option                      NO LIM 2.0 or 3.0 sea-ice model
Index: /branches/dev_003_CPL/NEMO/OPA_SRC/lib_mpp.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/OPA_SRC/lib_mpp.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/OPA_SRC/lib_mpp.F90	(revision 991)
@@ -61,7 +61,4 @@
    PUBLIC  mpp_lbc_north_e, mpp_minloc, mpp_maxloc, mpp_lnk_3d, mpp_lnk_2d, mpp_lnk_3d_gather, mpp_lnk_2d_e, mpplnks
    PUBLIC  mpprecv, mppsend, mppscatter, mppgather, mppobc, mpp_ini_north, mppstop, mppsync, mpp_ini_ice, mpp_comm_free
-#if defined key_oasis3 || defined key_oasis4
-   PUBLIC  mppsize, mpprank
-#endif
 
    !! * Interfaces
Index: /branches/dev_003_CPL/NEMO/OPA_SRC/ocfzpt.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/OPA_SRC/ocfzpt.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/OPA_SRC/ocfzpt.F90	(revision 991)
@@ -18,5 +18,4 @@
    !! * Shared module variables   
    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &  !:
-      freeze, freezn,  &  !: after and now ice mask (0 or 1)
       fzptb, fzptn        !: before and now freezing point
    !!----------------------------------------------------------------------
Index: /branches/dev_003_CPL/NEMO/OPA_SRC/opa.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/OPA_SRC/opa.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/OPA_SRC/opa.F90	(revision 991)
@@ -38,5 +38,4 @@
    !! * Modules used
    USE oce             ! dynamics and tracers variables
-   USE cpl_oce         ! ocean-atmosphere-sea ice coupled exchanges
    USE dom_oce         ! ocean space domain variables
    USE sbc_oce         ! surface boundary condition: ocean
@@ -70,9 +69,5 @@
 
    USE step            ! OPA time-stepping                  (stp     routine)
-#if defined key_oasis3
-   USE cpl_oasis3      ! OASIS3 coupling (to ECHAM5)
-#elif defined key_oasis4
-   USE cpl_oasis4      ! OASIS4 coupling (to ECHAM5)
-#endif
+   USE cpl_oasis3      ! OASIS3 coupling
    USE dynspg_oce      ! Control choice of surface pressure gradient schemes
    USE prtctl          ! Print control                 (prt_ctl_init routine)
@@ -159,10 +154,8 @@
 
       CALL opa_closefile
-#if defined key_oasis3 || defined key_oasis4
-      call cpl_prism_finalize
-#else
-      IF( lk_mpp )   CALL mppstop                          ! Close all files (mpp)
-#endif
-      !
+      IF      ( lk_cpl ) THEN   ;   CALL cpl_prism_finalize
+      ELSE IF ( lk_mpp ) THEN   ;   CALL mppstop                ! Close all files (mpp)
+      ENDIF
+                          
    END SUBROUTINE opa_model
 
@@ -175,10 +168,5 @@
       !!
       !!----------------------------------------------------------------------
-#if defined key_coupled
-      INTEGER ::   itro, istp0        ! ???
-#endif
-#if defined key_oasis3 || defined key_oasis4
       INTEGER :: localComm
-#endif
       CHARACTER (len=20) ::   namelistname
       CHARACTER (len=28) ::   file_out
@@ -212,12 +200,11 @@
       READ  ( numnam, namctl )
 
-#if defined key_oasis3 || defined key_oasis4
-      call cpl_prism_init(localComm)
-      ! Nodes selection
-      narea = mynode(localComm)
-#else
-      ! Nodes selection
-      narea = mynode()
-#endif
+      IF ( lk_cpl ) THEN
+         CALL cpl_prism_init()
+         narea = mynode(nlocalComm)
+      ELSE 
+         narea = mynode()
+      ENDIF
+          
       narea = narea + 1    ! mynode return the rank of proc (0 --> jpnij -1 )
       lwp   = narea == 1
@@ -290,17 +277,6 @@
       CALL trd_mod_init                         ! Mixed-layer/Vorticity/Integral constraints trends
 
-
 #if defined key_top
       CALL ini_trc                           ! Passive tracers
-#endif
-
-#if defined key_coupled && ! defined key_oasis3 && ! defined key_oasis4
-      itro  = nitend - nit000 + 1           ! Coupled
-      istp0 = NINT( rdt )
-      CALL cpl_init( itro, nexco, istp0 )   ! Signal processing and process id exchange
-#endif
-
-#if defined key_oasis3 || defined key_oasis4
-      CALL cpl_prism_define
 #endif
 
Index: /branches/dev_003_CPL/NEMO/OPA_SRC/step.F90
===================================================================
--- /branches/dev_003_CPL/NEMO/OPA_SRC/step.F90	(revision 990)
+++ /branches/dev_003_CPL/NEMO/OPA_SRC/step.F90	(revision 991)
@@ -364,6 +364,5 @@
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
-#if defined key_oasis3
-      IF( lk_cpl    )   CALL cpl_stp( kstp )                 ! coupled mode : field exchanges
+      IF( lk_cpl    )   CALL sbc_cpl_snd( kstp )                 ! coupled mode : field exchanges
 #endif
       !
