Index: trunk/NEMO/OPA_SRC/SBC/sbcmod.F90
===================================================================
--- trunk/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 1172)
+++ trunk/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 1218)
@@ -4,5 +4,6 @@
    !! Surface module :  provide to the ocean its surface boundary condition
    !!======================================================================
-   !! History :  3.0   !  2006-07  (G. Madec)  Original code
+   !! History :  3.0   !  07-2006  (G. Madec)  Original code
+   !!             -    !  08-2008  (S. Masson, E. .... ) coupled interface
    !!----------------------------------------------------------------------
 
@@ -42,22 +43,5 @@
    PUBLIC   sbc        ! routine called by step.F90
    
-   !! * namsbc namelist (public variables)
-   LOGICAL , PUBLIC ::   ln_ana      = .FALSE.   !: analytical boundary condition flag
-   LOGICAL , PUBLIC ::   ln_flx      = .FALSE.   !: flux      formulation
-   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_dm2dc    = .FALSE.   !: Daily mean to Diurnal Cycle short wave (qsr)
-   LOGICAL , PUBLIC ::   ln_rnf      = .FALSE.   !: runoffs / runoff mouths
-   LOGICAL , PUBLIC ::   ln_ssr      = .FALSE.   !: Sea Surface restoring on SST and/or SSS      
-   INTEGER , PUBLIC ::   nn_ice      = 0         !: flag on ice in the surface boundary condition (=0/1/2)
-   INTEGER , PUBLIC ::   nn_fwb      = 0         !: type of FreshWater Budget control (=0/1/2)
-   INTEGER          ::   nn_ico_cpl  = 0         !: ice-ocean coupling indicator
-   !                                             !  = 0   LIM-3 old case
-   !                                             !  = 1   stresses computed using now ocean velocity
-   !                                             !  = 2   combination of 0 and 1 cases
-
    INTEGER ::   nsbc   ! type of surface boundary condition (deduced from namsbc informations)
-   INTEGER ::   nice   ! type of ice in the surface boundary condition (deduced from namsbc informations)
       
    !! * Substitutions
@@ -94,9 +78,9 @@
       ENDIF
 
-      REWIND ( numnam )                   ! Read Namelist namsbc
-      READ   ( numnam, namsbc )
+      REWIND( numnam )                   ! Read Namelist namsbc
+      READ  ( numnam, namsbc )
 
       ! overwrite namelist parameter using CPP key information
-!!gmhere no overwrite, test all option via namelist change: require more incore memory
+!!gm here no overwrite, test all option via namelist change: require more incore memory
 !!gm  IF( lk_sbc_cpl       ) THEN   ;   ln_cpl      = .TRUE.   ;   ELSE   ;   ln_cpl      = .FALSE.   ;   ENDIF
       IF( lk_lim2 )            nn_ice      = 2
@@ -109,5 +93,5 @@
       ! Control print
       IF(lwp) THEN
-         WRITE(numout,*) '        Namelist namsbc (overwritten using CPP key defined)'
+         WRITE(numout,*) '        Namelist namsbc (partly overwritten with CPP key setting)'
          WRITE(numout,*) '           frequency update of sbc (and ice)             nn_fsbc     = ', nn_fsbc
          WRITE(numout,*) '           Type of sbc : '
@@ -115,5 +99,5 @@
          WRITE(numout,*) '              flux       formulation                     ln_flx      = ', ln_flx
          WRITE(numout,*) '              CLIO bulk  formulation                     ln_blk_clio = ', ln_blk_clio
-         WRITE(numout,*) '              CORE bulk  formulation                     ln_blk_core = ', ln_blk_core
+         WRITE(numout,*) '              CLIO bulk  formulation                     ln_blk_core = ', ln_blk_core
          WRITE(numout,*) '              coupled    formulation (T if key_sbc_cpl)  ln_cpl      = ', ln_cpl
          WRITE(numout,*) '           Misc. options of sbc : '
@@ -127,29 +111,25 @@
       ENDIF
 
-      IF( .NOT. ln_rnf )   THEN                      ! no specific treatment in rivers mouths vicinity
-         ln_rnf_mouth = .false.                      
-         nkrnf = 0
-         rnfmsk(:,:) = 0.e0
-         rnfmsk_z(:) = 0.e0
-      ENDIF
-      IF( nn_ice == 0  )   fr_i(:,:) = 0.e0          ! no ice in the domain, ice fraction is always zero
-
-      ! Check consistancy   !!gm mixture of real and integer : coding to be changed....
-
-      IF( nn_ice == 2 )   THEN
-         IF( MOD( nitend - nit000 + 1, nn_fsbc) /= 0 ) THEN 
-            WRITE(ctmp1,*) 'experiment length (', nitend - nit000 + 1, ') is NOT a multiple of nn_fsbc (', nn_fsbc, ')'
-            CALL ctl_stop( ctmp1, 'Impossible to do proper restart files' )
-         ENDIF
-         IF( MOD( nstock, nn_fsbc) /= 0 ) THEN 
-            WRITE(ctmp1,*) 'nstock ('           , nstock             , ') is NOT a multiple of nn_fsbc (', nn_fsbc, ')'
-            CALL ctl_stop( ctmp1, 'Impossible to do proper restart files' )
-         ENDIF
-      ENDIF
-
-      IF( MOD( rday, nn_fsbc*rdt ) /= 0 )   CALL ctl_warn( 'nn_fsbc is NOT a multiple of the number of time steps in a day' )
-
+      IF( .NOT. ln_rnf ) THEN                      ! no specific treatment in vicinity of river mouths 
+         ln_rnf_mouth  = .false.                      
+         nkrnf         = 0
+         rnfmsk  (:,:) = 0.e0
+         rnfmsk_z(:)   = 0.e0
+      ENDIF
+      IF( nn_ice == 0  )   fr_i(:,:) = 0.e0        ! no ice in the domain, ice fraction is always zero
+
+      !                                            ! restartability   
+      IF( MOD( nitend - nit000 + 1, nn_fsbc) /= 0 .OR.   &
+          MOD( nstock             , nn_fsbc) /= 0 ) THEN 
+         WRITE(ctmp1,*) 'experiment length (', nitend - nit000 + 1, ') or nstock (', nstock,   &
+            &           ' is NOT a multiple of nn_fsbc (', nn_fsbc, ')'
+         CALL ctl_stop( ctmp1, 'Impossible to properly do model restart' )
+      ENDIF
+      !
+      IF( MOD( rday, REAL(nn_fsbc, wp) * rdt ) /= 0 )   &
+         &  CALL ctl_warn( 'nn_fsbc is NOT a multiple of the number of time steps in a day' )
+      !
       IF( nn_ice == 2 .AND. .NOT.( ln_blk_clio .OR. ln_blk_core ) )   &
-         &   CALL ctl_stop( 'sbc_init: sea-ice model requires a bulk formulation' )
+         &   CALL ctl_stop( 'sea-ice model requires a bulk formulation' )
       
       ! Choice of the Surface Boudary Condition (set nsbc)
@@ -214,17 +194,17 @@
       SELECT CASE( nsbc )                        ! Compute ocean surface boundary condition
       !                                          ! (i.e. utau,vtau, qns, qsr, emp, emps)
-      CASE(  0 )   ;   CALL sbc_gyre    ( kt )      ! analytical formulation : GYRE configuration
-      CASE(  1 )   ;   CALL sbc_ana     ( kt )      ! analytical formulation : uniform sbc
-      CASE(  2 )   ;   CALL sbc_flx     ( kt )      ! flux formulation
-      CASE(  3 )   ;   CALL sbc_blk_clio( kt )      ! bulk formulation : CLIO for the ocean
-      CASE(  4 )   ;   CALL sbc_blk_core( kt )      ! bulk formulation : CORE for the ocean
-      CASE(  5 )   ;   CALL sbc_cpl     ( kt )      ! coupled formulation
+      CASE(  0 )   ;   CALL sbc_gyre    ( kt )                    ! analytical formulation : GYRE configuration
+      CASE(  1 )   ;   CALL sbc_ana     ( kt )                    ! analytical formulation : uniform sbc
+      CASE(  2 )   ;   CALL sbc_flx     ( kt )                    ! flux formulation
+      CASE(  3 )   ;   CALL sbc_blk_clio( kt )                    ! bulk formulation : CLIO for the ocean
+      CASE(  4 )   ;   CALL sbc_blk_core( kt )                    ! bulk formulation : CORE for the ocean
+      CASE(  5 )   ;   CALL sbc_cpl_rcv ( kt, nn_fsbc, nn_ice )   ! coupled formulation
       CASE( -1 )                                
-                       CALL sbc_ana     ( kt )      ! ESOPA, test ALL the formulations
-                       CALL sbc_gyre    ( kt )
-                       CALL sbc_flx     ( kt )
-                       CALL sbc_blk_clio( kt )
-                       CALL sbc_blk_core( kt )
-                       CALL sbc_cpl     ( kt )
+                       CALL sbc_ana     ( kt )                     ! ESOPA, test ALL the formulations
+                       CALL sbc_gyre    ( kt )                     !
+                       CALL sbc_flx     ( kt )                     !
+                       CALL sbc_blk_clio( kt )                     !
+                       CALL sbc_blk_core( kt )                     !
+                       CALL sbc_cpl_rcv ( kt,  nn_fsbc, nn_ice )   !
       END SELECT
 
@@ -234,6 +214,6 @@
 !!gm  IF( ln_dm2dc       )   CALL sbc_dcy( kt )                 ! Daily mean qsr distributed over the Diurnal Cycle
       
-      SELECT CASE( nn_ice )                                     ! Update heat and freshwater fluxes over ice-covered areas
-      CASE(  1 )   ;       CALL sbc_ice_if ( kt )                     ! Ice-cover climatology ("Ice-if" model)
+      SELECT CASE( nn_ice )                                     ! Update heat and freshwater fluxes over sea-ice areas
+      CASE(  1 )   ;       CALL sbc_ice_if   ( kt )                   ! Ice-cover climatology ("Ice-if" model)
          !                                                      
       CASE(  2 )   ;       CALL sbc_ice_lim_2( kt, nsbc )             ! LIM 2.0 ice model
