Index: branches/UKMO/dev_r5518_obs_oper_update_SlaAssim/NEMOGCM/CONFIG/SHARED/namelist_ref
===================================================================
--- branches/UKMO/dev_r5518_obs_oper_update_SlaAssim/NEMOGCM/CONFIG/SHARED/namelist_ref	(revision 11863)
+++ branches/UKMO/dev_r5518_obs_oper_update_SlaAssim/NEMOGCM/CONFIG/SHARED/namelist_ref	(revision 12035)
@@ -1234,4 +1234,5 @@
    ln_sstnight = .false.            ! Logical switch for calculating night-time average for SST obs
    ln_output_clim = .false.         ! Logical switch for writing climatological values to fdbk files
+   ln_time_mean_sla_bkg = .false.   ! Logical switch for applying time mean of SLA background to remove tidal signal
    ln_default_fp_indegs = .true.    ! Logical: T=> averaging footprint is in degrees, F=> in metres
    ln_sla_fp_indegs = .true.        ! Logical: T=> averaging footprint is in degrees, F=> in metres
Index: branches/UKMO/dev_r5518_obs_oper_update_SlaAssim/NEMOGCM/NEMO/OPA_SRC/OBS/diaobs.F90
===================================================================
--- branches/UKMO/dev_r5518_obs_oper_update_SlaAssim/NEMOGCM/NEMO/OPA_SRC/OBS/diaobs.F90	(revision 11863)
+++ branches/UKMO/dev_r5518_obs_oper_update_SlaAssim/NEMOGCM/NEMO/OPA_SRC/OBS/diaobs.F90	(revision 12035)
@@ -55,4 +55,5 @@
    LOGICAL :: ln_sic_fp_indegs     !: T=> sea-ice obs footprint size specified in degrees, F=> in metres
    LOGICAL :: ln_output_clim       !: Logical switch for interpolating and writing T/S climatology
+   LOGICAL :: ln_time_mean_sla_bkg !: Logical switch for applying time mean of SLA background to remove tidal signal
 
    REAL(wp) :: rn_default_avglamscl !: Default E/W diameter of observation footprint
@@ -66,4 +67,7 @@
    REAL(wp) :: rn_sic_avglamscl     !: E/W diameter of sea-ice observation footprint
    REAL(wp) :: rn_sic_avgphiscl     !: N/S diameter of sea-ice observation footprint
+   REAL(wp), PUBLIC :: &
+      &        MeanPeriodHours = 24. + (5./6.) !: Meaning period for surface data.
+
 
    INTEGER :: nn_1dint         !: Vertical interpolation method
@@ -238,4 +242,5 @@
       LOGICAL :: ltype_night     ! Local version of ln_sstnight (false for other variables)
       LOGICAL :: ltype_clim      ! Local version of ln_output_clim
+      
 
       REAL(wp), POINTER, DIMENSION(:,:,:) :: &
@@ -262,5 +267,5 @@
          &            ln_ignmis, ln_s_at_t, ln_bound_reject,          &
          &            ln_sstnight,  ln_output_clim,                   &
-         &            ln_default_fp_indegs,                           &
+         &            ln_time_mean_sla_bkg, ln_default_fp_indegs,     &
          &            ln_sla_fp_indegs, ln_sst_fp_indegs,             &
          &            ln_sss_fp_indegs, ln_sic_fp_indegs,             &
@@ -427,4 +432,5 @@
          WRITE(numout,*) '             Logical switch for night-time SST obs               ln_sstnight = ', ln_sstnight
          WRITE(numout,*) '             Logical switch for writing climat. at obs points ln_output_clim = ', ln_output_clim
+         WRITE(numout,*) '             Logical switch for time-mean of SLA        ln_time_mean_sla_bkg = ', ln_time_mean_sla_bkg
       ENDIF
       !-----------------------------------------------------------------------
@@ -912,5 +918,5 @@
                &               clsurffiles(jtype,1:ifilessurf(jtype)), &
                &               nvarssurf(jtype), nextrsurf(jtype), nitend-nit000+2, &
-               &               rn_dobsini, rn_dobsend, ln_ignmis, .FALSE., &
+               &               rn_dobsini, rn_dobsend, MeanPeriodHours, ln_ignmis, .FALSE., &
                &               llnightav(jtype), ltype_clim, clvars )
 
@@ -1031,4 +1037,5 @@
       !! * Local declarations
       INTEGER :: idaystp           ! Number of timesteps per day
+      INTEGER :: imeanstp          ! Number of timesteps for sla averaging
       INTEGER :: jtype             ! Data loop variable
       INTEGER :: jvar              ! Variable number
@@ -1624,10 +1631,23 @@
             ENDIF
 
-            CALL obs_surf_opt( surfdataqc(jtype), kstp, jpi, jpj,       &
-               &               nit000, idaystp, zsurfvar,               &
-               &               zsurfclim, zsurfmask,                    &
-               &               n2dintsurf(jtype), llnightav(jtype),     &
-               &               ravglamscl(jtype), ravgphiscl(jtype),    &
-               &               lfpindegs(jtype) )
+            IF ( TRIM(cobstypessurf(jtype)) == 'sla' .AND.                 &
+                  &  ln_time_mean_sla_bkg ) THEN
+               !Number of time-steps in meaning period
+               imeanstp = NINT( ( MeanPeriodHours * 60. * 60. ) / rdt )
+               CALL obs_surf_opt( surfdataqc(jtype), kstp, jpi, jpj,       &
+                  &               nit000, idaystp, zsurfvar,               &
+                  &               zsurfclim, zsurfmask,                    &
+                  &               n2dintsurf(jtype), llnightav(jtype),     &
+                  &               ravglamscl(jtype), ravgphiscl(jtype),    &
+                  &               lfpindegs(jtype), kmeanstp = imeanstp )
+
+            ELSE
+               CALL obs_surf_opt( surfdataqc(jtype), kstp, jpi, jpj,       &
+                  &               nit000, idaystp, zsurfvar,               &
+                  &               zsurfclim, zsurfmask,                    &
+                  &               n2dintsurf(jtype), llnightav(jtype),     &
+                  &               ravglamscl(jtype), ravgphiscl(jtype),    &
+                  &               lfpindegs(jtype) )
+            ENDIF
 
          END DO
Index: branches/UKMO/dev_r5518_obs_oper_update_SlaAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_oper.F90
===================================================================
--- branches/UKMO/dev_r5518_obs_oper_update_SlaAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_oper.F90	(revision 11863)
+++ branches/UKMO/dev_r5518_obs_oper_update_SlaAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_oper.F90	(revision 12035)
@@ -542,5 +542,5 @@
       &                     kit000, kdaystp, psurf, pclim, psurfmask,   &
       &                     k2dint, ldnightav, plamscl, pphiscl, &
-      &                     lindegrees )
+      &                     lindegrees, kmeanstp )
 
       !!-----------------------------------------------------------------------
@@ -592,4 +592,7 @@
       INTEGER, INTENT(IN) :: kdaystp   ! Number of time steps per day
       INTEGER, INTENT(IN) :: k2dint    ! Horizontal interpolation type (see header)
+      INTEGER, INTENT(IN), OPTIONAL :: &
+                             kmeanstp  ! Number of time steps for the time meaning
+                                       ! Averaging is triggered if present and greater than one                    
       REAL(wp), INTENT(IN), DIMENSION(kpi,kpj) :: &
          & psurf,  &                   ! Model surface field
@@ -613,4 +616,5 @@
       INTEGER :: imodi, imodj
       INTEGER :: idayend
+      INTEGER :: imeanend
       INTEGER, DIMENSION(:,:,:), ALLOCATABLE :: &
          & igrdi,   &
@@ -625,4 +629,5 @@
       REAL(wp), DIMENSION(1) :: zext, zobsmask, zclm
       REAL(wp) :: zdaystp
+      REAL(wp) :: zmeanstp
       REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: &
          & zweig,  &
@@ -641,4 +646,6 @@
          & zouttmp, &
          & zmeanday    ! to compute model sst in region of 24h daylight (pole)
+
+      LOGICAL :: l_timemean
          
       !------------------------------------------------------------------------
@@ -649,8 +656,51 @@
       isurf = surfdataqc%nsstp(inrc)
 
+      l_timemean = .FALSE.
+      IF ( PRESENT( kmeanstp ) ) THEN
+         IF ( kmeanstp > 1 ) l_timemean = .TRUE.
+      ENDIF
+
       ! Work out the maximum footprint size for the 
       ! interpolation/averaging in model grid-points - has to be even.
 
       CALL obs_max_fpsize( k2dint, plamscl, pphiscl, lindegrees, psurfmask, imaxifp, imaxjfp )
+
+
+      IF ( l_timemean ) THEN
+         ! Initialize time mean for first timestep
+         imeanend = MOD( kt - kit000 + 1, kmeanstp )
+         IF (lwp) WRITE(numout,*) 'Obs time mean ', kt, kit000, kmeanstp, imeanend
+
+         ! Added kt == 0 test to catch restart case 
+         IF ( ( imeanend == 1 ) .OR. ( kt == 0 ) ) THEN
+            IF (lwp) WRITE(numout,*) 'Reset surfdataqc%vdmean on time-step: ',kt
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  surfdataqc%vdmean(ji,jj) = 0.0
+               END DO
+            END DO
+         ENDIF
+
+         ! On each time-step, increment the field for computing time mean
+         IF (lwp) WRITE(numout,*)'Accumulating surfdataqc%vdmean on time-step: ',kt
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               surfdataqc%vdmean(ji,jj) = surfdataqc%vdmean(ji,jj) &
+                  &                        + psurf(ji,jj)
+            END DO
+         END DO
+
+         ! Compute the time mean at the end of time period
+         IF ( imeanend == 0 ) THEN
+            zmeanstp = 1.0 / REAL( kmeanstp )
+            IF (lwp) WRITE(numout,*)'Calculating surfdataaqc%vdmean time mean on time-step: ',kt,' with weight: ',zmeanstp
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  surfdataqc%vdmean(ji,jj) = surfdataqc%vdmean(ji,jj) &
+                  &                        * zmeanstp
+               END DO
+            END DO
+         ENDIF
+      ENDIF !l_timemean
 
 
@@ -770,6 +820,17 @@
       CALL obs_int_comm_2d( imaxifp, imaxjfp, isurf, kpi, kpj, &
          &                  igrdi, igrdj, psurfmask, zmask )
-      CALL obs_int_comm_2d( imaxifp, imaxjfp, isurf, kpi, kpj, &
-         &                  igrdi, igrdj, psurf, zsurf )
+
+      ! At the end of the averaging period get interpolated means
+      IF ( l_timemean ) THEN
+         IF ( imeanend == 0 ) THEN
+            ALLOCATE( zsurfm(imaxifp,imaxjfp,isurf) )
+            IF (lwp) WRITE(numout,*)' Interpolating the time mean values on time step: ',kt
+            CALL obs_int_comm_2d( imaxifp, imaxjfp, isurf, kpi, kpj, &
+               &                  igrdi, igrdj, surfdataqc%vdmean(:,:), zsurfm )
+         ENDIF
+      ELSE
+         CALL obs_int_comm_2d( imaxifp, imaxjfp, isurf, kpi, kpj, &
+            &                  igrdi, igrdj, psurf, zsurf )
+      ENDIF
 
       IF ( k2dint > 4 ) THEN         
@@ -823,6 +884,6 @@
          zphi = surfdataqc%rphi(jobs)
 
-         IF ( ldnightav .AND. idayend == 0 ) THEN
-            ! Night-time averaged data
+         IF (( ldnightav .AND. idayend == 0 ) .OR. (l_timemean .AND. imeanend == 0)) THEN
+            ! Night-time or N=kmeanstp timestep averaged data
             zsurftmp(:,:,iobs) = zsurfm(:,:,iobs)
          ELSE
@@ -830,52 +891,55 @@
          ENDIF
 
-         IF ( k2dint <= 4 ) THEN
-
-            ! Get weights to interpolate the model value to the observation point
-            CALL obs_int_h2d_init( 1, 1, k2dint, zlam, zphi,         &
-               &                   zglam(:,:,iobs), zgphi(:,:,iobs), &
-               &                   zmask(:,:,iobs), zweig, zobsmask )
-
-            ! Interpolate the model value to the observation point 
-            CALL obs_int_h2d( 1, 1, zweig, zsurftmp(:,:,iobs), zext )
-
-            IF ( surfdataqc%lclim ) THEN  
-               CALL obs_int_h2d( 1, 1, zweig, zclim(:,:,iobs), zclm )
+         IF (   ( .NOT. l_timemean ) .OR. & 
+             &  ( l_timemean .AND. imeanend == 0) ) THEN
+            IF ( k2dint <= 4 ) THEN
+
+               ! Get weights to interpolate the model value to the observation point
+               CALL obs_int_h2d_init( 1, 1, k2dint, zlam, zphi,         &
+                  &                   zglam(:,:,iobs), zgphi(:,:,iobs), &
+                  &                   zmask(:,:,iobs), zweig, zobsmask )
+
+               ! Interpolate the model value to the observation point 
+               CALL obs_int_h2d( 1, 1, zweig, zsurftmp(:,:,iobs), zext )
+
+               IF ( surfdataqc%lclim ) THEN  
+                  CALL obs_int_h2d( 1, 1, zweig, zclim(:,:,iobs), zclm )
+               ENDIF
+
+
+            ELSE
+
+               ! Get weights to average the model SLA to the observation footprint
+               CALL obs_avg_h2d_init( 1, 1, imaxifp, imaxjfp, k2dint, zlam,  zphi, &
+                  &                   zglam(:,:,iobs), zgphi(:,:,iobs), &
+                  &                   zglamf(:,:,iobs), zgphif(:,:,iobs), &
+                  &                   zmask(:,:,iobs), plamscl, pphiscl, &
+                  &                   lindegrees, zweig, zobsmask )
+
+               ! Average the model SST to the observation footprint
+               CALL obs_avg_h2d( 1, 1, imaxifp, imaxjfp, &
+                  &              zweig, zsurftmp(:,:,iobs),  zext )
+
+               IF ( surfdataqc%lclim ) THEN  
+                  CALL obs_avg_h2d( 1, 1, imaxifp, imaxjfp, &
+                     &              zweig, zclim(:,:,iobs),  zclm )
+               ENDIF
+
             ENDIF
 
-
-         ELSE
-
-            ! Get weights to average the model SLA to the observation footprint
-            CALL obs_avg_h2d_init( 1, 1, imaxifp, imaxjfp, k2dint, zlam,  zphi, &
-               &                   zglam(:,:,iobs), zgphi(:,:,iobs), &
-               &                   zglamf(:,:,iobs), zgphif(:,:,iobs), &
-               &                   zmask(:,:,iobs), plamscl, pphiscl, &
-               &                   lindegrees, zweig, zobsmask )
-
-            ! Average the model SST to the observation footprint
-            CALL obs_avg_h2d( 1, 1, imaxifp, imaxjfp, &
-               &              zweig, zsurftmp(:,:,iobs),  zext )
-
-            IF ( surfdataqc%lclim ) THEN  
-               CALL obs_avg_h2d( 1, 1, imaxifp, imaxjfp, &
-                  &              zweig, zclim(:,:,iobs),  zclm )
+            IF ( TRIM(surfdataqc%cvars(1)) == 'SLA' .AND. surfdataqc%nextra == 2 ) THEN
+               ! ... Remove the MDT from the SSH at the observation point to get the SLA
+               surfdataqc%rext(jobs,1) = zext(1)
+               surfdataqc%rmod(jobs,1) = surfdataqc%rext(jobs,1) - surfdataqc%rext(jobs,2)
+            ELSE
+               surfdataqc%rmod(jobs,1) = zext(1)
             ENDIF
 
-         ENDIF
-
-         IF ( TRIM(surfdataqc%cvars(1)) == 'SLA' .AND. surfdataqc%nextra == 2 ) THEN
-            ! ... Remove the MDT from the SSH at the observation point to get the SLA
-            surfdataqc%rext(jobs,1) = zext(1)
-            surfdataqc%rmod(jobs,1) = surfdataqc%rext(jobs,1) - surfdataqc%rext(jobs,2)
-         ELSE
-            surfdataqc%rmod(jobs,1) = zext(1)
-         ENDIF
-         
-         IF ( surfdataqc%lclim ) surfdataqc%rclm(jobs,1) = zclm(1)
-         
-         IF ( zext(1) == obfillflt ) THEN
-            ! If the observation value is a fill value, set QC flag to bad
-            surfdataqc%nqc(jobs) = 4
+            IF ( surfdataqc%lclim ) surfdataqc%rclm(jobs,1) = zclm(1)
+
+            IF ( zext(1) == obfillflt ) THEN
+               ! If the observation value is a fill value, set QC flag to bad
+               surfdataqc%nqc(jobs) = 4
+            ENDIF         
          ENDIF
 
@@ -901,5 +965,5 @@
 
       ! At the end of the day also deallocate night-time mean array
-      IF ( idayend == 0 .AND. ldnightav ) THEN
+      IF (( idayend == 0 .AND. ldnightav ) .OR. ( imeanend == 0 .AND. l_timemean )) THEN
          DEALLOCATE( &
             & zsurfm  &
Index: branches/UKMO/dev_r5518_obs_oper_update_SlaAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_surf.F90
===================================================================
--- branches/UKMO/dev_r5518_obs_oper_update_SlaAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_surf.F90	(revision 11863)
+++ branches/UKMO/dev_r5518_obs_oper_update_SlaAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_surf.F90	(revision 12035)
@@ -39,5 +39,5 @@
 
    SUBROUTINE obs_rea_surf( surfdata, knumfiles, cdfilenames, &
-      &                     kvars, kextr, kstp, ddobsini, ddobsend, &
+      &                     kvars, kextr, kstp, ddobsini, ddobsend, MeanPeriodHours, &
       &                     ldignmis, ldmod, ldnightav, ldclim, cdvars )
       !!---------------------------------------------------------------------
@@ -74,4 +74,5 @@
       REAL(dp), INTENT(IN) :: ddobsini   ! Obs. ini time in YYYYMMDD.HHMMSS
       REAL(dp), INTENT(IN) :: ddobsend   ! Obs. end time in YYYYMMDD.HHMMSS
+      REAL(wp), INTENT(IN) :: MeanPeriodHours ! Averaging period in hours
       CHARACTER(len=8), DIMENSION(kvars), INTENT(IN) :: cdvars
 
@@ -280,4 +281,14 @@
                inpfiles(jj)%iobsj = -1
             ENDIF
+
+            !If the observations are representing a time mean then set the time
+            !of the obs to the end of that meaning period relative to the start of the run
+            IF ( MeanPeriodHours > 0._wp ) THEN
+               DO ji = 1, inpfiles(jj)%nobs
+	               inpfiles(jj)%ptim(ji) = &
+	                     & djulini(jj) + (MeanPeriodHours/24.)
+	            END DO
+            ENDIF   
+
             inowin = 0
             DO ji = 1, inpfiles(jj)%nobs
