Index: branches/UKMO/dev_r4650_general_vert_coord_obsoper/NEMOGCM/NEMO/OPA_SRC/OBS/diaobs.F90
===================================================================
--- branches/UKMO/dev_r4650_general_vert_coord_obsoper/NEMOGCM/NEMO/OPA_SRC/OBS/diaobs.F90	(revision 6016)
+++ branches/UKMO/dev_r4650_general_vert_coord_obsoper/NEMOGCM/NEMO/OPA_SRC/OBS/diaobs.F90	(revision 6326)
@@ -25,4 +25,5 @@
    USE obs_read_sla             ! Reading and allocation of SLA observations  
    USE obs_read_sst             ! Reading and allocation of SST observations  
+   USE obs_sstbias              ! Bias correction routine for SST
    USE obs_readmdt              ! Reading and allocation of MDT for SLA.
    USE obs_read_seaice          ! Reading and allocation of Sea Ice observations  
@@ -87,4 +88,5 @@
    LOGICAL, PUBLIC :: ln_ignmis      !: Logical switch for ignoring missing files
    LOGICAL, PUBLIC :: ln_s_at_t      !: Logical switch to compute model S at T observations
+   LOGICAL, PUBLIC :: ln_sstbias     !: Logical switch for bias corection of SST
 
    REAL(KIND=dp), PUBLIC :: dobsini   !: Observation window start date YYYYMMDD.HHMMSS
@@ -103,4 +105,6 @@
       & ln_profb_enatim !: Change tim for 820 enact data set.
    
+   INTEGER, DIMENSION(MaxNumFiles), PUBLIC :: sstbias_type !SST bias type
+
    LOGICAL, DIMENSION(MaxNumFiles) :: &
       & ln_velfb_av   !: Is the velocity feedback files daily average?
@@ -137,4 +141,5 @@
       !!        !  06-10  (A. Weaver) Cleaning and add controls
       !!        !  07-03  (K. Mogensen) General handling of profiles
+      !!        !  14-08  (J.While) Incorporated SST bias correction
       !!----------------------------------------------------------------------
 
@@ -146,5 +151,6 @@
       CHARACTER(len=128) :: profbfiles(MaxNumFiles)
       CHARACTER(len=128) :: sstfiles(MaxNumFiles)      
-      CHARACTER(len=128) :: sstfbfiles(MaxNumFiles) 
+      CHARACTER(len=128) :: sstfbfiles(MaxNumFiles)
+      CHARACTER(len=128) :: sstbias_files(MaxNumFiles) 
       CHARACTER(len=128) :: slafilesact(MaxNumFiles)      
       CHARACTER(len=128) :: slafilespas(MaxNumFiles)      
@@ -182,5 +188,6 @@
          &            ln_velhradcp, velhradcpfiles,                   &
          &            ln_velfb, velfbfiles, ln_velfb_av,              &
-         &            ln_profb_enatim, ln_ignmis, ln_cl4
+         &            ln_profb_enatim, ln_ignmis, ln_cl4,             &
+         &            ln_sstbias, sstbias_files
 
       INTEGER :: jprofset
@@ -195,4 +202,5 @@
       INTEGER :: jnumsst
       INTEGER :: jnumsstfb
+      INTEGER :: jnumsstbias
       INTEGER :: jnumseaice
       INTEGER :: jnumvelavcur
@@ -229,4 +237,5 @@
       velcurfiles(:) = ''
       veladcpfiles(:) = ''
+      sstbias_files(:) = ''
       endailyavtypes(:) = -1
       endailyavtypes(1) = 820
@@ -290,4 +299,10 @@
          lmask(:) = .FALSE.
       ENDIF
+      IF (ln_sstbias) THEN  
+         lmask(:) = .FALSE.  
+         WHERE (sstbias_files(:) /= '') lmask(:) = .TRUE.  
+         jnumsstbias = COUNT(lmask)  
+         lmask(:) = .FALSE.  
+      ENDIF       
       IF (ln_seaice) THEN
          lmask(:) = .FALSE.
@@ -341,4 +356,5 @@
          WRITE(numout,*) '             Logical switch for GHRSST observations          ln_ghrsst = ', ln_ghrsst
          WRITE(numout,*) '             Logical switch for feedback SST data             ln_sstfb = ', ln_sstfb
+         WRITE(numout,*) '             Logical switch for SST bias correction         ln_sstbias = ', ln_sstbias
          WRITE(numout,*) '             Logical switch for night-time SST obs         ln_sstnight = ', ln_sstnight
          WRITE(numout,*) '             Logical switch for SSS observations                ln_sss = ', ln_sss
@@ -776,4 +792,14 @@
 
          ENDIF
+         
+         !Read in bias field and correct SST. 
+         IF ( ln_sstbias ) THEN 
+            IF ( jnumsstbias == 0 ) CALL ctl_stop("ln_sstbias set,"// & 
+                                             "  but no bias"// & 
+                                             " files to read in")    
+            CALL obs_app_sstbias( nsstsets, sstdatqc, n2dint, & 
+                                  jnumsstbias, &  
+                                  sstbias_files(1:jnumsstbias) ) 
+         ENDIF 
 
       ENDIF
