Index: branches/UKMO/r6232_HZG_WAVE-coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcssm.F90
===================================================================
--- branches/UKMO/r6232_HZG_WAVE-coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcssm.F90	(revision 7655)
+++ branches/UKMO/r6232_HZG_WAVE-coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbcssm.F90	(revision 9259)
@@ -26,4 +26,5 @@
 
    PUBLIC   sbc_ssm         ! routine called by step.F90
+   PUBLIC   sbc_ssm_cpl     ! routine called by sbccpl.F90
    PUBLIC   sbc_ssm_init    ! routine called by sbcmod.F90
 
@@ -77,6 +78,8 @@
          sss_m(:,:) = zts(:,:,jp_sal)
          !                          ! removed inverse barometer ssh when Patm forcing is used (for sea-ice dynamics)
-         IF( ln_apr_dyn ) THEN   ;   ssh_m(:,:) = sshn(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) )
-         ELSE                    ;   ssh_m(:,:) = sshn(:,:)
+         IF( .NOT. cpl_mslp ) THEN
+            IF( ln_apr_dyn ) THEN   ;   ssh_m(:,:) = sshn(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) )
+            ELSE                    ;   ssh_m(:,:) = sshn(:,:)
+            ENDIF
          ENDIF
          !
@@ -99,6 +102,8 @@
             sss_m(:,:) = zcoef * zts(:,:,jp_sal)
             !                          ! removed inverse barometer ssh when Patm forcing is used (for sea-ice dynamics)
-            IF( ln_apr_dyn ) THEN   ;   ssh_m(:,:) = zcoef * ( sshn(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) ) )
-            ELSE                    ;   ssh_m(:,:) = zcoef * sshn(:,:)
+            IF( .NOT. cpl_mslp ) THEN
+               IF( ln_apr_dyn ) THEN   ;   ssh_m(:,:) = zcoef * ( sshn(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) ) )
+               ELSE                    ;   ssh_m(:,:) = zcoef * sshn(:,:)
+               ENDIF
             ENDIF
             !
@@ -113,5 +118,5 @@
             sst_m(:,:) = 0.e0
             sss_m(:,:) = 0.e0
-            ssh_m(:,:) = 0.e0
+            IF( .NOT. cpl_mslp ) ssh_m(:,:) = 0.e0
             IF( lk_vvl )   e3t_m(:,:) = 0.e0
             frq_m(:,:) = 0.e0
@@ -127,6 +132,8 @@
          sss_m(:,:) = sss_m(:,:) + zts(:,:,jp_sal)
          !                          ! removed inverse barometer ssh when Patm forcing is used (for sea-ice dynamics)
-         IF( ln_apr_dyn ) THEN   ;   ssh_m(:,:) = ssh_m(:,:) + sshn(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) )
-         ELSE                    ;   ssh_m(:,:) = ssh_m(:,:) + sshn(:,:)
+         IF( .NOT. cpl_mslp ) THEN
+            IF( ln_apr_dyn ) THEN   ;   ssh_m(:,:) = ssh_m(:,:) + sshn(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) )
+            ELSE                    ;   ssh_m(:,:) = ssh_m(:,:) + sshn(:,:)
+            ENDIF
          ENDIF
          !
@@ -143,5 +150,5 @@
             ssu_m(:,:) = ssu_m(:,:) * zcoef           ! mean suface current  [m/s]
             ssv_m(:,:) = ssv_m(:,:) * zcoef           !
-            ssh_m(:,:) = ssh_m(:,:) * zcoef           ! mean SSH             [m]
+            IF( .NOT. cpl_mslp ) ssh_m(:,:) = ssh_m(:,:) * zcoef           ! mean SSH             [m]
             IF( lk_vvl )   e3t_m(:,:) = fse3t_m(:,:) * zcoef   ! mean vertical scale factor [m]
             frq_m(:,:) = frq_m(:,:) * zcoef   ! mean fraction of solar net radiation absorbed in the 1st T level [-]
@@ -161,5 +168,5 @@
             CALL iom_rstput( kt, nitrst, numrow, 'sst_m'  , sst_m  )
             CALL iom_rstput( kt, nitrst, numrow, 'sss_m'  , sss_m  )
-            CALL iom_rstput( kt, nitrst, numrow, 'ssh_m'  , ssh_m  )
+            IF( .NOT. cpl_mslp ) CALL iom_rstput( kt, nitrst, numrow, 'ssh_m'  , ssh_m  )
             IF( lk_vvl )   CALL iom_rstput( kt, nitrst, numrow, 'e3t_m'  , e3t_m  )
             CALL iom_rstput( kt, nitrst, numrow, 'frq_m'  , frq_m  )
@@ -174,5 +181,5 @@
          CALL iom_put( 'sst_m', sst_m )
          CALL iom_put( 'sss_m', sss_m )
-         CALL iom_put( 'ssh_m', ssh_m )
+         IF( .NOT. cpl_mslp ) CALL iom_put( 'ssh_m', ssh_m )
          IF( lk_vvl )   CALL iom_put( 'e3t_m', e3t_m )
          CALL iom_put( 'frq_m', frq_m )
@@ -180,4 +187,67 @@
       !
    END SUBROUTINE sbc_ssm
+
+   SUBROUTINE sbc_ssm_cpl( kt )
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE sbc_ssm_cpl  ***
+      !!                     
+      !! ** Purpose :   provide ocean surface variable to sea-surface boundary
+      !!                condition computation when pressure is read from coupling
+      !!                
+      !! ** Method  :   The inverse barometer ssh (i.e. ssh associated with Patm)
+      !!                is added to ssh_m when ln_apr_dyn = T. Required for sea-ice dynamics.
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+      !
+      REAL(wp) ::   zcoef       ! local scalar
+      !!---------------------------------------------------------------------
+      !
+      IF( nn_fsbc == 1 ) THEN                             !   Instantaneous surface fields        !
+         !                                                ! ---------------------------------------- !
+         IF( ln_apr_dyn ) THEN   ;   ssh_m(:,:) = sshn(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) )
+         ELSE                    ;   ssh_m(:,:) = sshn(:,:)
+         ENDIF
+      ELSE
+         !                                                ! ----------------------------------------------- !
+         IF( kt == nit000 .AND. .NOT. l_ssm_mean ) THEN   !   Initialisation: 1st time-step, no input means !
+            !                                             ! ----------------------------------------------- !
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '~~~~~~~   mean ssh field initialised to instantaneous values'
+            zcoef = REAL( nn_fsbc - 1, wp )
+            zcoef = REAL( nn_fsbc - 1, wp )
+            IF( ln_apr_dyn ) THEN    ;  ssh_m(:,:) = zcoef * ( sshn(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) ) )
+            ELSE                     ;  ssh_m(:,:) = zcoef * sshn(:,:)
+            ENDIF
+            !                                             ! ---------------------------------------- !
+         ELSEIF( MOD( kt - 2 , nn_fsbc ) == 0 ) THEN      !   Initialisation: New mean computation   !
+            !                                             ! ---------------------------------------- !
+            ssh_m(:,:) = 0.e0
+         ENDIF
+
+         IF( ln_apr_dyn ) THEN   ;   ssh_m(:,:) = ssh_m(:,:) + sshn(:,:) - 0.5 * ( ssh_ib(:,:) + ssh_ibb(:,:) )
+         ELSE                    ;   ssh_m(:,:) = ssh_m(:,:) + sshn(:,:)
+         ENDIF
+         !                                                ! ---------------------------------------- !
+         IF( MOD( kt - 1 , nn_fsbc ) == 0 ) THEN          !   Mean value at each nn_fsbc time-step   !
+            !                                             ! ---------------------------------------- !
+            zcoef = 1. / REAL( nn_fsbc, wp )
+            ssh_m(:,:) = ssh_m(:,:) * zcoef           ! mean SSH             [m]
+         ENDIF
+         !                                                ! ---------------------------------------- !
+         IF( lrst_oce ) THEN                              !      Write in the ocean restart file     !
+            !                                             ! ---------------------------------------- !
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'sbc_ssm_cpl : ssh mean field written in ocean restart file ',   &
+               &                    'at it= ', kt,' date= ', ndastp
+            IF(lwp) WRITE(numout,*) '~~~~~~~'
+            CALL iom_rstput( kt, nitrst, numrow, 'ssh_m'  , ssh_m  )
+         ENDIF
+      ENDIF
+      !
+      IF( MOD( kt - 1 , nn_fsbc ) == 0 ) THEN          !   Mean value at each nn_fsbc time-step   !
+         CALL iom_put( 'ssh_m', ssh_m )
+      ENDIF
+      !
+   END SUBROUTINE sbc_ssm_cpl
 
    SUBROUTINE sbc_ssm_init
