Index: /branches/UKMO/dev_rev5518_OBS_DoNotAssim/.project
===================================================================
--- /branches/UKMO/dev_rev5518_OBS_DoNotAssim/.project	(revision 7841)
+++ /branches/UKMO/dev_rev5518_OBS_DoNotAssim/.project	(revision 7841)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>dev_rev5518_OBS_DoNotAssim</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+	</buildSpec>
+	<natures>
+	</natures>
+</projectDescription>
Index: /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_prep.F90
===================================================================
--- /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_prep.F90	(revision 7840)
+++ /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_prep.F90	(revision 7841)
@@ -52,5 +52,5 @@
 
    SUBROUTINE obs_pre_pro( profdata, prodatqc, ld_t3d, ld_s3d, ld_nea, &
-      &                    kdailyavtypes )
+      &                    kdailyavtypes, kqc_cutoff )
       !!----------------------------------------------------------------------
       !!                    ***  ROUTINE obs_pre_pro  ***
@@ -86,5 +86,7 @@
       INTEGER, DIMENSION(imaxavtypes), OPTIONAL :: &
          & kdailyavtypes! Types for daily averages
+      INTEGER, INTENT(IN), OPTIONAL :: kqc_cutoff   ! cut off for QC value
       !! * Local declarations   
+      INTEGER :: iqc_cutoff = 255   ! cut off for QC value
       INTEGER :: iyea0         ! Initial date
       INTEGER :: imon0         !  - (year, month, day, hour, minute)
@@ -141,4 +143,7 @@
       inlasobs = 0
 
+      ! Set QC cutoff to optional value if provided
+      IF ( PRESENT(kqc_cutoff) ) iqc_cutoff=kqc_cutoff
+
       ! -----------------------------------------------------------------------
       ! Find time coordinate for profiles
@@ -151,5 +156,6 @@
             &                profdata%nday,    profdata%nhou, profdata%nmin, &
             &                profdata%ntyp,    profdata%nqc,  profdata%mstp, &
-            &                iotdobs, kdailyavtypes = kdailyavtypes        )
+            &                iotdobs, kdailyavtypes = kdailyavtypes,         &
+            &                kqc_cutoff = iqc_cutoff        )
       ELSE
          CALL obs_coo_tim_prof( icycle, &
@@ -158,5 +164,5 @@
             &                profdata%nday,    profdata%nhou, profdata%nmin, &
             &                profdata%ntyp,    profdata%nqc,  profdata%mstp, &
-            &                iotdobs )
+            &                iotdobs, kqc_cutoff = iqc_cutoff )
       ENDIF
       CALL obs_mpp_sum_integer( iotdobs, iotdobsmpp )
@@ -172,8 +178,8 @@
 
       ! -----------------------------------------------------------------------
-      ! Reject all observations for profiles with nqc > 10
-      ! -----------------------------------------------------------------------
-
-      CALL obs_pro_rej( profdata )
+      ! Reject all observations for profiles with nqc > iqc_cutoff
+      ! -----------------------------------------------------------------------
+
+      CALL obs_pro_rej( profdata, iqc_cutoff )
 
       ! -----------------------------------------------------------------------
@@ -196,5 +202,6 @@
          &                 profdata%nqc,          profdata%var(1)%nvqc, &
          &                 iosdtobs,              ilantobs,             &
-         &                 inlatobs,              ld_nea                )
+         &                 inlatobs,              ld_nea,               &
+         &                 iqc_cutoff                                   )
 
       CALL obs_mpp_sum_integer( iosdtobs, iosdtobsmpp )
@@ -216,5 +223,6 @@
          &                 profdata%nqc,          profdata%var(2)%nvqc, &
          &                 iosdsobs,              ilansobs,             &
-         &                 inlasobs,              ld_nea                )
+         &                 inlasobs,              ld_nea,               &
+         &                 iqc_cutoff                                   )
 
       CALL obs_mpp_sum_integer( iosdsobs, iosdsobsmpp )
@@ -234,9 +242,9 @@
       END DO
 
-      ! We want all data which has qc flags <= 10
-
-      llvalid%luse(:) = ( profdata%nqc(:)  <= 10 )
+      ! We want all data which has qc flags <= iqc_cutoff
+
+      llvalid%luse(:) = ( profdata%nqc(:)  <= iqc_cutoff )
       DO jvar = 1,profdata%nvar
-         llvvalid(jvar)%luse(:) = ( profdata%var(jvar)%nvqc(:) <= 10 )
+         llvvalid(jvar)%luse(:) = ( profdata%var(jvar)%nvqc(:) <= iqc_cutoff )
       END DO
 
@@ -337,5 +345,5 @@
    END SUBROUTINE obs_pre_pro
 
-   SUBROUTINE obs_pre_sla( sladata, sladatqc, ld_sla, ld_nea )
+   SUBROUTINE obs_pre_sla( sladata, sladatqc, ld_sla, ld_nea, kqc_cutoff )
       !!----------------------------------------------------------------------
       !!                    ***  ROUTINE obs_pre_sla  ***
@@ -366,5 +374,7 @@
       LOGICAL, INTENT(IN) :: ld_sla         ! Switch for SLA data
       LOGICAL, INTENT(IN) :: ld_nea         ! Switch for rejecting observation near land
+      INTEGER, INTENT(IN), OPTIONAL :: kqc_cutoff   ! cut off for QC value
       !! * Local declarations
+      INTEGER :: iqc_cutoff = 255   ! cut off for QC value
       INTEGER :: iyea0        ! Initial date
       INTEGER :: imon0        !  - (year, month, day, hour, minute)
@@ -410,4 +420,8 @@
       inlasobs = 0
 
+      ! Set QC cutoff to optional value if provided
+
+      IF ( PRESENT(kqc_cutoff) ) iqc_cutoff=kqc_cutoff
+
       ! -----------------------------------------------------------------------
       ! Find time coordinate for SLA data
@@ -442,5 +456,6 @@
          &                 tmask(:,:,1), sladata%nqc,  &
          &                 iosdsobs,     ilansobs,     &
-         &                 inlasobs,     ld_nea        )
+         &                 inlasobs,     ld_nea,       &
+         &                 iqc_cutoff                  )
 
       CALL obs_mpp_sum_integer( iosdsobs, iosdsobsmpp )
@@ -457,7 +472,7 @@
       ALLOCATE( llvalid(sladata%nsurf) )
       
-      ! We want all data which has qc flags <= 10
-
-      llvalid(:)  = ( sladata%nqc(:)  <= 10 )
+      ! We want all data which has qc flags <= iqc_cutoff
+
+      llvalid(:)  = ( sladata%nqc(:)  <= iqc_cutoff )
 
       ! The actual copying
@@ -526,5 +541,5 @@
    END SUBROUTINE obs_pre_sla
 
-   SUBROUTINE obs_pre_sst( sstdata, sstdatqc, ld_sst, ld_nea )
+   SUBROUTINE obs_pre_sst( sstdata, sstdatqc, ld_sst, ld_nea, kqc_cutoff  )
       !!----------------------------------------------------------------------
       !!                    ***  ROUTINE obs_pre_sst  ***
@@ -554,5 +569,7 @@
       LOGICAL :: ld_sst             ! Switch for SST data
       LOGICAL :: ld_nea             ! Switch for rejecting observation near land
+      INTEGER, INTENT(IN), OPTIONAL :: kqc_cutoff   ! cut off for QC value
       !! * Local declarations
+      INTEGER :: iqc_cutoff = 255   ! cut off for QC value
       INTEGER :: iyea0        ! Initial date
       INTEGER :: imon0        !  - (year, month, day, hour, minute)
@@ -598,4 +615,8 @@
       inlasobs = 0
 
+      ! Set QC cutoff to optional value if provided
+
+      IF ( PRESENT(kqc_cutoff) ) iqc_cutoff=kqc_cutoff
+
       ! -----------------------------------------------------------------------
       ! Find time coordinate for SST data
@@ -627,5 +648,6 @@
          &                 tmask(:,:,1), sstdata%nqc,  &
          &                 iosdsobs,     ilansobs,     &
-         &                 inlasobs,     ld_nea        )
+         &                 inlasobs,     ld_nea,       &
+         &                 iqc_cutoff                  )
 
       CALL obs_mpp_sum_integer( iosdsobs, iosdsobsmpp )
@@ -642,7 +664,7 @@
       ALLOCATE( llvalid(sstdata%nsurf) )
       
-      ! We want all data which has qc flags <= 0
-
-      llvalid(:)  = ( sstdata%nqc(:)  <= 10 )
+      ! We want all data which has qc flags <= iqc_cutoff
+
+      llvalid(:)  = ( sstdata%nqc(:)  <= iqc_cutoff )
 
       ! The actual copying
@@ -711,5 +733,5 @@
    END SUBROUTINE obs_pre_sst
 
-   SUBROUTINE obs_pre_seaice( seaicedata, seaicedatqc, ld_seaice, ld_nea )
+   SUBROUTINE obs_pre_seaice( seaicedata, seaicedatqc, ld_seaice, ld_nea, kqc_cutoff )
       !!----------------------------------------------------------------------
       !!                    ***  ROUTINE obs_pre_seaice  ***
@@ -739,5 +761,7 @@
       LOGICAL :: ld_seaice     ! Switch for sea ice data
       LOGICAL :: ld_nea        ! Switch for rejecting observation near land
+      INTEGER, INTENT(IN), OPTIONAL :: kqc_cutoff   ! cut off for QC value
       !! * Local declarations
+      INTEGER :: iqc_cutoff = 255   ! cut off for QC value
       INTEGER :: iyea0         ! Initial date
       INTEGER :: imon0         !  - (year, month, day, hour, minute)
@@ -783,4 +807,8 @@
       inlasobs = 0
 
+      ! Set QC cutoff to optional value if provided
+
+      IF ( PRESENT(kqc_cutoff) ) iqc_cutoff=kqc_cutoff
+
       ! -----------------------------------------------------------------------
       ! Find time coordinate for sea ice data
@@ -812,5 +840,6 @@
          &                 tmask(:,:,1),    seaicedata%nqc,  &
          &                 iosdsobs,        ilansobs,        &
-         &                 inlasobs,        ld_nea           )
+         &                 inlasobs,        ld_nea,          &
+         &                 iqc_cutoff                        )
 
       CALL obs_mpp_sum_integer( iosdsobs, iosdsobsmpp )
@@ -827,7 +856,7 @@
       ALLOCATE( llvalid(seaicedata%nsurf) )
       
-      ! We want all data which has qc flags <= 0
-
-      llvalid(:)  = ( seaicedata%nqc(:)  <= 10 )
+      ! We want all data which has qc flags <= iqc_cutoff
+
+      llvalid(:)  = ( seaicedata%nqc(:)  <= iqc_cutoff  )
 
       ! The actual copying
@@ -896,5 +925,5 @@
    END SUBROUTINE obs_pre_seaice
 
-   SUBROUTINE obs_pre_vel( profdata, prodatqc, ld_vel3d, ld_nea, ld_dailyav )
+   SUBROUTINE obs_pre_vel( profdata, prodatqc, ld_vel3d, ld_nea, ld_dailyav, kqc_cutoff )
       !!----------------------------------------------------------------------
       !!                    ***  ROUTINE obs_pre_taovel  ***
@@ -925,5 +954,7 @@
       LOGICAL, INTENT(IN) :: ld_nea        ! Switch for rejecting observation near land
       LOGICAL, INTENT(IN) :: ld_dailyav    ! Switch for daily average data
+      INTEGER, INTENT(IN), OPTIONAL :: kqc_cutoff   ! cut off for QC value
       !! * Local declarations
+      INTEGER :: iqc_cutoff = 255   ! cut off for QC value
       INTEGER :: iyea0        ! Initial date
       INTEGER :: imon0        !  - (year, month, day, hour, minute)
@@ -986,4 +1017,8 @@
       iuvchkv = 0
 
+      ! Set QC cutoff to optional value if provided
+
+      IF ( PRESENT(kqc_cutoff) ) iqc_cutoff=kqc_cutoff
+
       ! -----------------------------------------------------------------------
       ! Find time coordinate for profiles
@@ -995,5 +1030,6 @@
          &              profdata%nday,    profdata%nhou, profdata%nmin, &
          &              profdata%ntyp,    profdata%nqc,  profdata%mstp, &
-         &              iotdobs, ld_dailyav = ld_dailyav        )
+         &              iotdobs, ld_dailyav = ld_dailyav,               &
+         &              kqc_cutoff=kqc_cutoff )
 	 
       CALL obs_mpp_sum_integer( iotdobs, iotdobsmpp )
@@ -1014,5 +1050,5 @@
       ! -----------------------------------------------------------------------
 
-      CALL obs_pro_rej( profdata )
+      CALL obs_pro_rej( profdata, iqc_cutoff )
 
       ! -----------------------------------------------------------------------
@@ -1035,5 +1071,6 @@
          &                 profdata%nqc,          profdata%var(1)%nvqc, &
          &                 iosduobs,              ilanuobs,             &
-         &                 inlauobs,              ld_nea                )
+         &                 inlauobs,              ld_nea,               &
+         &                 iqc_cutoff                                   )
 
       CALL obs_mpp_sum_integer( iosduobs, iosduobsmpp )
@@ -1055,5 +1092,6 @@
          &                 profdata%nqc,          profdata%var(2)%nvqc, &
          &                 iosdvobs,              ilanvobs,             &
-         &                 inlavobs,              ld_nea                )
+         &                 inlavobs,              ld_nea,               &
+         &                 iqc_cutoff                                   )
 
       CALL obs_mpp_sum_integer( iosdvobs, iosdvobsmpp )
@@ -1065,5 +1103,5 @@
       ! -----------------------------------------------------------------------
 
-      CALL obs_uv_rej( profdata, iuvchku, iuvchkv )
+      CALL obs_uv_rej( profdata, iuvchku, iuvchkviqc_cutoff )
       CALL obs_mpp_sum_integer( iuvchku, iuvchkumpp )
       CALL obs_mpp_sum_integer( iuvchkv, iuvchkvmpp )
@@ -1081,9 +1119,9 @@
       END DO
 
-      ! We want all data which has qc flags = 0
-
-      llvalid%luse(:) = ( profdata%nqc(:)  <= 10 )
+      ! We want all data which has qc flags <= iqc_cutoff
+
+      llvalid%luse(:) = ( profdata%nqc(:)  <= iqc_cutoff )
       DO jvar = 1,profdata%nvar
-         llvvalid(jvar)%luse(:) = ( profdata%var(jvar)%nvqc(:) <= 10 )
+         llvvalid(jvar)%luse(:) = ( profdata%var(jvar)%nvqc(:) <= iqc_cutoff )
       END DO
 
@@ -1389,5 +1427,5 @@
       &                    kobsyea, kobsmon, kobsday, kobshou, kobsmin,   &
       &                    ktyp,    kobsqc,  kobsstp, kotdobs, kdailyavtypes, &
-      &                    ld_dailyav )
+      &                    ld_dailyav, kqc_cutoff )
       !!----------------------------------------------------------------------
       !!                    ***  ROUTINE obs_coo_tim ***
@@ -1434,6 +1472,8 @@
          & kdailyavtypes    ! Types for daily averages
       LOGICAL, OPTIONAL :: ld_dailyav    ! All types are daily averages
+      INTEGER, OPTIONAL, INTENT(IN) :: kqc_cutoff           ! QC cutoff value
       !! * Local declarations
       INTEGER :: jobs
+      INTEGER :: iqc_cutoff=255
 
       !-----------------------------------------------------------------------
@@ -1454,9 +1494,9 @@
          DO jobs = 1, kobsno
             
-            IF ( kobsqc(jobs) <= 10 ) THEN
+            IF ( kobsqc(jobs) <= iqc_cutoff ) THEN
                
                IF ( ( kobsstp(jobs) == (nit000 - 1) ).AND.&
                   & ( ANY (kdailyavtypes(:) == ktyp(jobs)) ) ) THEN
-                  kobsqc(jobs) = kobsqc(jobs) + 14
+                  kobsqc(jobs) = IBSET(kobsqc(jobs),13)
                   kotdobs      = kotdobs + 1
                   CYCLE
@@ -1475,8 +1515,8 @@
             DO jobs = 1, kobsno
                
-               IF ( kobsqc(jobs) <= 10 ) THEN
+               IF ( kobsqc(jobs) <= iqc_cutoff ) THEN
                   
                   IF ( kobsstp(jobs) == (nit000 - 1) ) THEN
-                     kobsqc(jobs) = kobsqc(jobs) + 14
+                     kobsqc(jobs) = IBSET(kobsqc(jobs),13)
                      kotdobs      = kotdobs + 1
                      CYCLE
@@ -1521,5 +1561,5 @@
       DO jobs = 1, kobsno
          IF ( ( kobsi(jobs) <= 0 ) .AND. ( kobsj(jobs) <= 0 ) ) THEN
-            kobsqc(jobs) = kobsqc(jobs) + 18
+            kobsqc(jobs) = IBSET(kobsqc(jobs),12)
             kgrdobs = kgrdobs + 1
          ENDIF
@@ -1532,5 +1572,5 @@
       &                       plam,   pphi,    pmask,            &
       &                       kobsqc, kosdobs, klanobs,          &
-      &                       knlaobs,ld_nea                     )
+      &                       knlaobs,ld_nea, kqc_cutoff         )
       !!----------------------------------------------------------------------
       !!                    ***  ROUTINE obs_coo_spc_2d  ***
@@ -1569,4 +1609,5 @@
       INTEGER, INTENT(INOUT) :: knlaobs   ! Observations near land
       LOGICAL, INTENT(IN) :: ld_nea       ! Flag observations near land
+      INTEGER, INTENT(IN) :: kqc_cutoff       ! Cutoff QC value
       !! * Local declarations
       REAL(KIND=wp), DIMENSION(2,2,kobsno) :: &
@@ -1588,5 +1629,5 @@
          ! For invalid points use 2,2
 
-         IF ( kobsqc(jobs) >= 10 ) THEN
+         IF ( kobsqc(jobs) >= kqc_cutoff ) THEN
 
             igrdi(1,1,jobs) = 1
@@ -1621,5 +1662,5 @@
 
          ! Skip bad observations
-         IF ( kobsqc(jobs) >= 10 ) CYCLE
+         IF ( kobsqc(jobs) >= kqc_cutoff ) CYCLE
 
          ! Flag if the observation falls outside the model spatial domain
@@ -1628,5 +1669,5 @@
             &  .OR. ( pobsphi(jobs) <  -90. ) &
             &  .OR. ( pobsphi(jobs) >   90. ) ) THEN
-            kobsqc(jobs) = kobsqc(jobs) + 11
+            kobsqc(jobs) = IBSET(kobsqc(jobs),11)
             kosdobs = kosdobs + 1
             CYCLE
@@ -1635,5 +1676,5 @@
          ! Flag if the observation falls with a model land cell
          IF ( SUM( zgmsk(1:2,1:2,jobs) ) == 0.0_wp ) THEN
-            kobsqc(jobs) = kobsqc(jobs)  + 12
+            kobsqc(jobs) = IBSET(kobsqc(jobs),10)
             klanobs = klanobs + 1
             CYCLE
@@ -1663,5 +1704,5 @@
          IF (lgridobs) THEN
             IF (zgmsk(iig,ijg,jobs) == 0.0_wp ) THEN
-               kobsqc(jobs) = kobsqc(jobs) + 12
+               kobsqc(jobs) = IBSET(kobsqc(jobs),10)
                klanobs = klanobs + 1
                CYCLE
@@ -1671,5 +1712,5 @@
          ! Flag if the observation falls is close to land
          IF ( MINVAL( zgmsk(1:2,1:2,jobs) ) == 0.0_wp) THEN
-            IF (ld_nea) kobsqc(jobs) = kobsqc(jobs) + 14
+            IF (ld_nea) kobsqc(jobs) = IBSET(kobsqc(jobs),9)
             knlaobs = knlaobs + 1
             CYCLE
@@ -1686,5 +1727,6 @@
       &                       plam,    pphi,    pdep,    pmask, &
       &                       kpobsqc, kobsqc,  kosdobs,        &
-      &                       klanobs, knlaobs, ld_nea          )
+      &                       klanobs, knlaobs, ld_nea,         &
+      &                       kqc_cutoff                        )
       !!----------------------------------------------------------------------
       !!                    ***  ROUTINE obs_coo_spc_3d  ***
@@ -1744,4 +1786,5 @@
       INTEGER, INTENT(INOUT) :: knlaobs     ! Observations near land
       LOGICAL, INTENT(IN) :: ld_nea         ! Flag observations near land
+      INTEGER, INTENT(IN) :: kqc_cutoff     ! Cutoff QC value
       !! * Local declarations
       REAL(KIND=wp), DIMENSION(2,2,kpk,kprofno) :: &
@@ -1763,5 +1806,5 @@
          ! For invalid points use 2,2
 
-         IF ( kpobsqc(jobs) >= 10 ) THEN
+         IF ( kpobsqc(jobs) >= kqc_cutoff ) THEN
             
             igrdi(1,1,jobs) = 1
@@ -1796,5 +1839,5 @@
 
          ! Skip bad profiles
-         IF ( kpobsqc(jobs) >= 10 ) CYCLE
+         IF ( kpobsqc(jobs) >= kqc_cutoff ) CYCLE
 
          ! Check if this observation is on a grid point
@@ -1827,5 +1870,5 @@
                &  .OR. ( pobsdep(jobsp) < 0.0          )       &
                &  .OR. ( pobsdep(jobsp) > gdepw_1d(kpk)) ) THEN
-               kobsqc(jobsp) = kobsqc(jobsp) + 11
+               kobsqc(jobsp) = IBSET(kobsqc(jobsp),11)
                kosdobs = kosdobs + 1
                CYCLE
@@ -1835,5 +1878,5 @@
             IF ( SUM( zgmsk(1:2,1:2,kobsk(jobsp)-1:kobsk(jobsp),jobs) ) &
                &  == 0.0_wp ) THEN
-               kobsqc(jobsp) = kobsqc(jobsp) + 12
+               kobsqc(jobsp) = IBSET(kobsqc(jobsp),10)
                klanobs = klanobs + 1
                CYCLE
@@ -1845,5 +1888,5 @@
             IF (lgridobs) THEN
                IF (zgmsk(iig,ijg,kobsk(jobsp)-1,jobs) == 0.0_wp ) THEN
-                  kobsqc(jobsp) = kobsqc(jobsp) + 12
+                  kobsqc(jobsp) = IBSET(kobsqc(jobsp),9)
                   klanobs = klanobs + 1
                   CYCLE
@@ -1854,5 +1897,5 @@
             IF ( MINVAL( zgmsk(1:2,1:2,kobsk(jobsp)-1:kobsk(jobsp),jobs) ) == &
                &  0.0_wp) THEN
-               IF (ld_nea) kobsqc(jobsp) = kobsqc(jobsp) + 14
+               IF (ld_nea) kobsqc(jobsp) = IBSET(kobsqc(jobsp),10)
                knlaobs = knlaobs + 1
             ENDIF
@@ -1868,5 +1911,5 @@
    END SUBROUTINE obs_coo_spc_3d
 
-   SUBROUTINE obs_pro_rej( profdata )
+   SUBROUTINE obs_pro_rej( profdata, kqc_cutoff )
       !!----------------------------------------------------------------------
       !!                    ***  ROUTINE obs_pro_rej ***
@@ -1886,4 +1929,5 @@
       !! * Arguments
       TYPE(obs_prof), INTENT(INOUT) :: profdata     ! Profile data
+      INTEGER, INTENT(IN) :: kqc_cutoff             ! QC cutoff value
       !! * Local declarations
       INTEGER :: jprof
@@ -1895,5 +1939,5 @@
       DO jprof = 1, profdata%nprof
 
-         IF ( profdata%nqc(jprof) > 10 ) THEN
+         IF ( profdata%nqc(jprof) >  kqc_cutoff ) THEN
             
             DO jvar = 1, profdata%nvar
@@ -1903,5 +1947,5 @@
                   
                   profdata%var(jvar)%nvqc(jobs) = &
-                     & profdata%var(jvar)%nvqc(jobs) + 26
+                     & IBSET(profdata%var(jvar)%nvqc(jobs),14)
 
                END DO
@@ -1915,5 +1959,5 @@
    END SUBROUTINE obs_pro_rej
 
-   SUBROUTINE obs_uv_rej( profdata, knumu, knumv )
+   SUBROUTINE obs_uv_rej( profdata, knumu, knumv, kqc_cutoff  )
       !!----------------------------------------------------------------------
       !!                    ***  ROUTINE obs_uv_rej ***
@@ -1935,4 +1979,5 @@
       INTEGER, INTENT(INOUT) :: knumu             ! Number of u rejected
       INTEGER, INTENT(INOUT) :: knumv             ! Number of v rejected
+      INTEGER, INTENT(IN) :: kqc_cutoff           ! QC cutoff value
       !! * Local declarations
       INTEGER :: jprof
@@ -1954,12 +1999,12 @@
          DO jobs = profdata%npvsta(jprof,1), profdata%npvend(jprof,1)
             
-            IF ( ( profdata%var(1)%nvqc(jobs) > 10 ) .AND. &
-               & ( profdata%var(2)%nvqc(jobs) <= 10) ) THEN
+            IF ( ( profdata%var(1)%nvqc(jobs) > kqc_cutoff ) .AND. &
+               & ( profdata%var(2)%nvqc(jobs) <= kqc_cutoff) ) THEN
                profdata%var(2)%nvqc(jobs) = profdata%var(2)%nvqc(jobs) + 42
                knumv = knumv + 1
             ENDIF
-            IF ( ( profdata%var(2)%nvqc(jobs) > 10 ) .AND. &
-               & ( profdata%var(1)%nvqc(jobs) <= 10) ) THEN
-               profdata%var(1)%nvqc(jobs) = profdata%var(1)%nvqc(jobs) + 42
+            IF ( ( profdata%var(2)%nvqc(jobs) > kqc_cutoff ) .AND. &
+               & ( profdata%var(1)%nvqc(jobs) <= kqc_cutoff) ) THEN
+               profdata%var(1)%nvqc(jobs) = IBSET(profdata%var(1)%nvqc(jobs),15)
                knumu = knumu + 1
             ENDIF
Index: /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_prof.F90
===================================================================
--- /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_prof.F90	(revision 7840)
+++ /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_prof.F90	(revision 7841)
@@ -308,7 +308,7 @@
             inowin = 0
             DO ji = 1, inpfiles(jj)%nobs
-               IF ( inpfiles(jj)%ioqc(ji) > 2 ) CYCLE
-               IF ( ( inpfiles(jj)%ivqc(ji,1) > 2 ) .AND. &
-                  & ( inpfiles(jj)%ivqc(ji,2) > 2 )) CYCLE
+               IF ( BTEST(inpfiles(jj)%ioqc(ji),2 ) ) CYCLE
+               IF ( BTEST(inpfiles(jj)%ivqc(ji,1),2) .AND. &
+                  & BTEST(inpfiles(jj)%ivqc(ji,2),2) ) CYCLE
                IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND. &
                   & ( inpfiles(jj)%ptim(ji) <= djulend(jj) )       ) THEN
@@ -323,7 +323,7 @@
             inowin = 0
             DO ji = 1, inpfiles(jj)%nobs
-               IF ( inpfiles(jj)%ioqc(ji) > 2 ) CYCLE
-               IF ( ( inpfiles(jj)%ivqc(ji,1) > 2 ) .AND. &
-                  & ( inpfiles(jj)%ivqc(ji,2) > 2 )) CYCLE
+               IF ( BTEST(inpfiles(jj)%ioqc(ji),2 ) ) CYCLE
+               IF ( BTEST(inpfiles(jj)%ivqc(ji,1),2) .AND. &
+                  & BTEST(inpfiles(jj)%ivqc(ji,2),2) ) CYCLE
                IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND. &
                   & ( inpfiles(jj)%ptim(ji) <= djulend(jj) )       ) THEN
@@ -338,7 +338,7 @@
             inowin = 0
             DO ji = 1, inpfiles(jj)%nobs
-               IF ( inpfiles(jj)%ioqc(ji) > 2 ) CYCLE
-               IF ( ( inpfiles(jj)%ivqc(ji,1) > 2 ) .AND. &
-                  & ( inpfiles(jj)%ivqc(ji,2) > 2 )) CYCLE
+               IF ( BTEST(inpfiles(jj)%ioqc(ji),2 ) ) CYCLE
+               IF ( BTEST(inpfiles(jj)%ivqc(ji,1),2) .AND. &
+                  & BTEST(inpfiles(jj)%ivqc(ji,2),2) ) CYCLE
                IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND. &
                   & ( inpfiles(jj)%ptim(ji) <= djulend(jj) )       ) THEN
@@ -352,7 +352,7 @@
 
             DO ji = 1, inpfiles(jj)%nobs
-               IF ( inpfiles(jj)%ioqc(ji) > 2 ) CYCLE
-               IF ( ( inpfiles(jj)%ivqc(ji,1) > 2 ) .AND. &
-                  & ( inpfiles(jj)%ivqc(ji,2) > 2 )) CYCLE
+               IF ( BTEST(inpfiles(jj)%ioqc(ji),2 ) ) CYCLE
+               IF ( BTEST(inpfiles(jj)%ivqc(ji,1),2) .AND. &
+                  & BTEST(inpfiles(jj)%ivqc(ji,2),2) ) CYCLE
                IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND. &
                   & ( inpfiles(jj)%ptim(ji) <= djulend(jj) )       ) THEN
@@ -367,6 +367,6 @@
                         IF ( inpfiles(jj)%pdep(ij,ji) >= 6000. ) &
                            & CYCLE
-                        IF ( ( inpfiles(jj)%ivlqc(ij,ji,1) <= 2 ) .AND. &
-                           & ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) THEN
+                        IF ( .NOT. BTEST(inpfiles(jj)%ivlqc(ij,ji,1),2) .AND. &
+                           & .NOT. BTEST(inpfiles(jj)%idqc(ij,ji),2) ) THEN
                            it3dt0 = it3dt0 + 1
                         ENDIF
@@ -377,6 +377,6 @@
                         IF ( inpfiles(jj)%pdep(ij,ji) >= 6000. ) &
                            & CYCLE
-                        IF ( ( inpfiles(jj)%ivlqc(ij,ji,2) <= 2 ) .AND. &
-                           & ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) THEN
+                        IF ( .NOT. BTEST(inpfiles(jj)%ivlqc(ij,ji,1),2) .AND. &
+                           & .NOT. BTEST(inpfiles(jj)%idqc(ij,ji),2) ) THEN
                            is3dt0 = is3dt0 + 1
                         ENDIF
@@ -386,10 +386,10 @@
                      IF ( inpfiles(jj)%pdep(ij,ji) >= 6000. ) &
                         & CYCLE
-                     IF ( ( ( ( inpfiles(jj)%ivlqc(ij,ji,1) <= 2 ) .AND. &
-                        &     ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) .AND. &
-                        &     ldt3d ) .OR. &
-                        & ( ( ( inpfiles(jj)%ivlqc(ij,ji,2) <= 2 ) .AND. &
-                        &     ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) .AND. &
-                        &     lds3d ) ) THEN
+                     IF ( ( .NOT. BTEST(inpfiles(jj)%ivlqc(ij,ji,1),2) .AND. &
+                        &   .NOT. BTEST(inpfiles(jj)%idqc(ij,ji),2) .AND. &
+                        &    ldt3d ) .OR. &
+                        & ( .NOT. BTEST(inpfiles(jj)%ivlqc(ij,ji,2),2) .AND. &
+                        &   .NOT. BTEST(inpfiles(jj)%idqc(ij,ji),2) .AND. &
+                        &   lds3d ) ) THEN
                         ip3dt = ip3dt + 1
                         llvalprof = .TRUE.
@@ -416,7 +416,7 @@
       DO jj = 1, inobf
          DO ji = 1, inpfiles(jj)%nobs
-            IF ( inpfiles(jj)%ioqc(ji) > 2 ) CYCLE
-            IF ( ( inpfiles(jj)%ivqc(ji,1) > 2 ) .AND. &
-               & ( inpfiles(jj)%ivqc(ji,2) > 2 )) CYCLE
+            IF ( BTEST(inpfiles(jj)%ioqc(ji),2 ) ) CYCLE
+            IF ( BTEST(inpfiles(jj)%ivqc(ji,1),2) .AND. &
+               & BTEST(inpfiles(jj)%ivqc(ji,2),2) ) CYCLE
             IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND. &
                & ( inpfiles(jj)%ptim(ji) <= djulend(jj) )       ) THEN
@@ -431,7 +431,7 @@
       DO jj = 1, inobf
          DO ji = 1, inpfiles(jj)%nobs
-            IF ( inpfiles(jj)%ioqc(ji) > 2 ) CYCLE
-            IF ( ( inpfiles(jj)%ivqc(ji,1) > 2 ) .AND. &
-               & ( inpfiles(jj)%ivqc(ji,2) > 2 )) CYCLE
+            IF ( BTEST(inpfiles(jj)%ioqc(ji),2 ) ) CYCLE
+            IF ( BTEST(inpfiles(jj)%ivqc(ji,1),2) .AND. &
+               & BTEST(inpfiles(jj)%ivqc(ji,2),2) ) CYCLE
             IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND. &
                & ( inpfiles(jj)%ptim(ji) <= djulend(jj) )       ) THEN
@@ -480,7 +480,7 @@
          ji = iprofidx(iindx(jk))
 
-         IF ( inpfiles(jj)%ioqc(ji) > 2 ) CYCLE
-         IF ( ( inpfiles(jj)%ivqc(ji,1) > 2 ) .AND. &
-            & ( inpfiles(jj)%ivqc(ji,2) > 2 )) CYCLE
+         IF ( BTEST(inpfiles(jj)%ioqc(ji),2 ) ) CYCLE
+         IF ( BTEST(inpfiles(jj)%ivqc(ji,1),2) .AND. &
+            & BTEST(inpfiles(jj)%ivqc(ji,2),2) ) CYCLE
 
          IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND.  &
@@ -495,8 +495,7 @@
             llvalprof = .FALSE.
 
-            IF ( inpfiles(jj)%ioqc(ji) > 2 ) CYCLE
-
-            IF ( ( inpfiles(jj)%ivqc(ji,1) > 2 ) .AND. &
-               & ( inpfiles(jj)%ivqc(ji,2) > 2 ) ) CYCLE
+            IF ( BTEST(inpfiles(jj)%ioqc(ji),2 ) ) CYCLE
+            IF ( BTEST(inpfiles(jj)%ivqc(ji,1),2) .AND. &
+               & BTEST(inpfiles(jj)%ivqc(ji,2),2) ) CYCLE
 
             loop_prof : DO ij = 1, inpfiles(jj)%nlev
@@ -505,6 +504,6 @@
                   & CYCLE
                
-               IF ( ( inpfiles(jj)%ivlqc(ij,ji,1) <= 2 ) .AND. &
-                  & ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) THEN
+               IF ( .NOT. BTEST(inpfiles(jj)%ivlqc(ij,ji,1),2) .AND. &
+                  & .NOT. BTEST(inpfiles(jj)%idqc(ij,ji),2) ) THEN
                   
                   llvalprof = .TRUE. 
@@ -513,6 +512,6 @@
                ENDIF
                
-               IF ( ( inpfiles(jj)%ivlqc(ij,ji,2) <= 2 ) .AND. &
-                  & ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) THEN
+               IF ( .NOT. BTEST(inpfiles(jj)%ivlqc(ij,ji,2),2) .AND. &
+                  & .NOT. BTEST(inpfiles(jj)%idqc(ij,ji),2) ) THEN
                   
                   llvalprof = .TRUE. 
@@ -592,10 +591,10 @@
                   IF (ldsatt) THEN
 
-                     IF ( ( ( ( inpfiles(jj)%ivlqc(ij,ji,1) <= 2 ) .AND. &
-                        &     ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) .AND. &
-                        &     ldt3d ) .OR. &
-                        & ( ( ( inpfiles(jj)%ivlqc(ij,ji,2) <= 2 ) .AND. &
-                        &     ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) .AND. &
-                        &     lds3d ) ) THEN
+                     IF ( ( .NOT. BTEST(inpfiles(jj)%ivlqc(ij,ji,1),2) .AND. &
+                        &   .NOT. BTEST(inpfiles(jj)%idqc(ij,ji),2) .AND. &
+                        &    ldt3d ) .OR. &
+                        & ( .NOT. BTEST(inpfiles(jj)%ivlqc(ij,ji,2),2) .AND. &
+                        &   .NOT. BTEST(inpfiles(jj)%idqc(ij,ji),2) .AND. &
+                        &   lds3d ) ) THEN
                         ip3dt = ip3dt + 1
                      ELSE
@@ -605,7 +604,7 @@
                   ENDIF
 
-                  IF ( ( ( ( inpfiles(jj)%ivlqc(ij,ji,1) <= 2 ) .AND. &
-                     &     ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) .AND. &
-                     &       ldt3d ) .OR. ldsatt ) THEN
+                  IF ( ( .NOT. BTEST(inpfiles(jj)%ivlqc(ij,ji,1),2) .AND. &
+                    &   .NOT. BTEST(inpfiles(jj)%idqc(ij,ji),2) .AND. &
+                    &    ldt3d ) .OR. ldsatt ) THEN
                      
                      IF (ldsatt) THEN
@@ -667,7 +666,7 @@
                   ENDIF
                   
-                  IF ( ( ( ( inpfiles(jj)%ivlqc(ij,ji,2) <= 2 ) .AND. &
-                     &   ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) .AND. &
-                     &   lds3d ) .OR. ldsatt ) THEN
+                  IF ( ( .NOT. BTEST(inpfiles(jj)%ivlqc(ij,ji,1),2) .AND. &
+                    &   .NOT. BTEST(inpfiles(jj)%idqc(ij,ji),2) .AND. &
+                    &    ldt3d ) .OR. ldsatt ) THEN
                      
                      IF (ldsatt) THEN
Index: /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_seaice.F90
===================================================================
--- /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_seaice.F90	(revision 7840)
+++ /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_seaice.F90	(revision 7841)
@@ -282,6 +282,5 @@
                   ENDIF
                   llvalprof = .FALSE.
-                  IF ( ( inpfiles(jj)%ivlqc(1,ji,1) == 1 ) .OR. &
-                     & ( inpfiles(jj)%ivlqc(1,ji,1) == 2 ) ) THEN
+                  IF ( .NOT. BTEST(inpfiles(jj)%ivlqc(1,ji,1),2) ) THEN
                      iobs = iobs + 1
                   ENDIF
@@ -355,6 +354,5 @@
             ! Set observation information
             
-            IF ( ( inpfiles(jj)%ivlqc(1,ji,1) == 1 ) .OR. &
-               & ( inpfiles(jj)%ivlqc(1,ji,1) == 2 ) ) THEN
+            IF ( .NOT. BTEST(inpfiles(jj)%ivlqc(1,ji,1),2) ) THEN
 
                iobs = iobs + 1
Index: /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_sla.F90
===================================================================
--- /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_sla.F90	(revision 7840)
+++ /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_sla.F90	(revision 7841)
@@ -269,6 +269,6 @@
             inowin = 0
             DO ji = 1, inpfiles(jj)%nobs
-               IF ( inpfiles(jj)%ioqc(ji) > 2 ) CYCLE
-               IF ( inpfiles(jj)%ivqc(ji,1) > 2 ) CYCLE
+               IF ( BTEST(inpfiles(jj)%ioqc(ji),2 ) ) CYCLE
+               IF ( BTEST(inpfiles(jj)%ivqc(ji,1),2) ) CYCLE
                IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND. &
                   & ( inpfiles(jj)%ptim(ji) <= djulend(jj) )       ) THEN
@@ -283,6 +283,6 @@
             inowin = 0
             DO ji = 1, inpfiles(jj)%nobs
-               IF ( inpfiles(jj)%ioqc(ji) > 2 ) CYCLE
-               IF ( inpfiles(jj)%ivqc(ji,1) > 2 ) CYCLE
+               IF ( BTEST(inpfiles(jj)%ioqc(ji),2 ) ) CYCLE
+               IF ( BTEST(inpfiles(jj)%ivqc(ji,1),2) ) CYCLE
                IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND. &
                   & ( inpfiles(jj)%ptim(ji) <= djulend(jj) )       ) THEN
@@ -297,6 +297,6 @@
             inowin = 0
             DO ji = 1, inpfiles(jj)%nobs
-               IF ( inpfiles(jj)%ioqc(ji) > 2 ) CYCLE
-               IF ( inpfiles(jj)%ivqc(ji,1) > 2 ) CYCLE
+               IF ( BTEST(inpfiles(jj)%ioqc(ji),2 ) ) CYCLE
+               IF ( BTEST(inpfiles(jj)%ivqc(ji,1),2) ) CYCLE
                IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND. &
                   & ( inpfiles(jj)%ptim(ji) <= djulend(jj) )       ) THEN
@@ -310,6 +310,6 @@
 
             DO ji = 1, inpfiles(jj)%nobs
-               IF ( inpfiles(jj)%ioqc(ji) > 2 ) CYCLE
-               IF ( inpfiles(jj)%ivqc(ji,1) > 2 ) CYCLE
+               IF ( BTEST(inpfiles(jj)%ioqc(ji),2 ) ) CYCLE
+               IF ( BTEST(inpfiles(jj)%ivqc(ji,1),2) ) CYCLE
                IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND. &
                   & ( inpfiles(jj)%ptim(ji) <= djulend(jj) )       ) THEN
@@ -320,6 +320,5 @@
                   ENDIF
                   llvalprof = .FALSE.
-                  IF ( ( inpfiles(jj)%ivlqc(1,ji,1) == 1 ) .OR. &
-                     & ( inpfiles(jj)%ivlqc(1,ji,1) == 2 ) ) THEN
+                  IF ( .NOT. BTEST(inpfiles(jj)%ivlqc(1,ji,1),2) ) THEN
                      iobs = iobs + 1
                   ENDIF
@@ -364,6 +363,6 @@
       DO jj = 1, inobf
          DO ji = 1, inpfiles(jj)%nobs
-            IF ( inpfiles(jj)%ioqc(ji) > 2 ) CYCLE
-            IF ( inpfiles(jj)%ivqc(ji,1) > 2 ) CYCLE
+            IF ( BTEST(inpfiles(jj)%ioqc(ji),2 ) ) CYCLE
+            IF ( BTEST(inpfiles(jj)%ivqc(ji,1),2) ) CYCLE
             IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND. &
                & ( inpfiles(jj)%ptim(ji) <= djulend(jj) )       ) THEN
@@ -378,6 +377,6 @@
       DO jj = 1, inobf
          DO ji = 1, inpfiles(jj)%nobs
-            IF ( inpfiles(jj)%ioqc(ji) > 2 ) CYCLE
-            IF ( inpfiles(jj)%ivqc(ji,1) > 2 ) CYCLE
+            IF ( BTEST(inpfiles(jj)%ioqc(ji),2 ) ) CYCLE
+            IF ( BTEST(inpfiles(jj)%ivqc(ji,1),2) ) CYCLE
             IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND. &
                & ( inpfiles(jj)%ptim(ji) <= djulend(jj) )       ) THEN
@@ -409,6 +408,6 @@
          ji = islaidx(iindx(jk))
 
-         IF ( inpfiles(jj)%ioqc(ji) > 2 ) CYCLE
-         IF ( inpfiles(jj)%ivqc(ji,1) > 2 ) CYCLE
+         IF ( BTEST(inpfiles(jj)%ioqc(ji),2 ) ) CYCLE
+         IF ( BTEST(inpfiles(jj)%ivqc(ji,1),2) ) CYCLE
 
          IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND.  &
@@ -423,6 +422,5 @@
             ! Set observation information
             
-            IF ( ( inpfiles(jj)%ivlqc(1,ji,1) == 1 ) .OR. &
-               & ( inpfiles(jj)%ivlqc(1,ji,1) == 2 ) ) THEN
+            IF ( .NOT. BTEST(inpfiles(jj)%ivlqc(1,ji,1),2) ) THEN
 
                iobs = iobs + 1
Index: /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_sst.F90
===================================================================
--- /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_sst.F90	(revision 7840)
+++ /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_sst.F90	(revision 7841)
@@ -282,6 +282,5 @@
                   ENDIF
                   llvalprof = .FALSE.
-                  IF ( ( inpfiles(jj)%ivlqc(1,ji,1) == 1 ) .OR. &
-                     & ( inpfiles(jj)%ivlqc(1,ji,1) == 2 ) ) THEN
+                  IF ( .NOT. BTEST(inpfiles(jj)%ivlqc(1,ji,1),2) ) THEN
                      iobs = iobs + 1
                   ENDIF
@@ -354,6 +353,5 @@
             ! Set observation information
             
-            IF ( ( inpfiles(jj)%ivlqc(1,ji,1) == 1 ) .OR. &
-               & ( inpfiles(jj)%ivlqc(1,ji,1) == 2 ) ) THEN
+            IF ( .NOT. BTEST(inpfiles(jj)%ivlqc(1,ji,1),2) ) THEN
 
                iobs = iobs + 1
Index: /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_vel.F90
===================================================================
--- /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_vel.F90	(revision 7840)
+++ /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_vel.F90	(revision 7841)
@@ -326,7 +326,7 @@
                         IF ( inpfiles(jj)%pdep(ij,ji) >= 6000. ) &
                            & CYCLE
-                        IF ( ( inpfiles(jj)%ivlqc(ij,ji,1) <= 2 ) .AND. &
-                           & ( inpfiles(jj)%ivlqc(ij,ji,2) <= 2 ) .AND. &
-                           & ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) THEN
+                        IF ( .NOT. BTEST(inpfiles(jj)%ivlqc(ij,ji,1),2) .AND. &
+                           & .NOT. BTEST(inpfiles(jj)%ivlqc(ij,ji,2),2) .AND. &
+                           & .NOT. BTEST(inpfiles(jj)%idqc(ij,ji),2) ) THEN
                            iuv3dt = iuv3dt + 1
                            llvalprof = .TRUE.
@@ -413,7 +413,7 @@
                   & CYCLE
                
-               IF ( ( inpfiles(jj)%ivlqc(ij,ji,1) <= 2 ) .AND. &
-                  & ( inpfiles(jj)%ivlqc(ij,ji,2) <= 2 ) .AND. &
-                  & ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) THEN
+               IF ( .NOT. BTEST(inpfiles(jj)%ivlqc(ij,ji,1),2) .AND. &
+                  & .NOT. BTEST(inpfiles(jj)%ivlqc(ij,ji,2),2) .AND. &
+                  & .NOT. BTEST(inpfiles(jj)%idqc(ij,ji),2) ) THEN
 
                   llvalprof = .TRUE.
@@ -492,7 +492,7 @@
                      & CYCLE
 
-                  IF ( ( inpfiles(jj)%ivlqc(ij,ji,1) <= 2 ) .AND. &
-                     & ( inpfiles(jj)%ivlqc(ij,ji,2) <= 2 ) .AND. &
-                     & ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) THEN
+                  IF ( .NOT. BTEST(inpfiles(jj)%ivlqc(ij,ji,1),2) .AND. &
+                     & .NOT. BTEST(inpfiles(jj)%ivlqc(ij,ji,2),2) .AND. &
+                     & .NOT. BTEST(inpfiles(jj)%idqc(ij,ji),2) ) THEN
                      iuv3dt = iuv3dt + 1
                   ELSE
Index: /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_readmdt.F90
===================================================================
--- /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_readmdt.F90	(revision 7840)
+++ /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_readmdt.F90	(revision 7841)
@@ -155,5 +155,5 @@
 
 ! mark any masked data with a QC flag
-            IF( zobsmask(1) == 0 )   sladata(jslano)%nqc(jobs) = 11
+            IF( zobsmask(1) == 0 )   sladata(jslano)%nqc(jobs) = IBSET(sladata(jslano)%nqc(jobs),15)
 
          END DO
Index: /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_write.F90
===================================================================
--- /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_write.F90	(revision 7840)
+++ /branches/UKMO/dev_rev5518_OBS_DoNotAssim/NEMOGCM/NEMO/OPA_SRC/OBS/obs_write.F90	(revision 7841)
@@ -173,8 +173,8 @@
          fbdata%ivqc(jo,:)    = profdata%ivqc(jo,:)
          fbdata%ivqcf(:,jo,:) = profdata%ivqcf(:,jo,:)
-         IF ( profdata%nqc(jo) > 10 ) THEN
-            fbdata%ioqc(jo)    = 4
+         IF ( profdata%nqc(jo) > 255 ) THEN
+            fbdata%ioqc(jo)    = IBSET(profdata%nqc(jo),2)
             fbdata%ioqcf(1,jo) = profdata%nqcf(1,jo)
-            fbdata%ioqcf(2,jo) = profdata%nqc(jo) - 10
+            fbdata%ioqcf(2,jo) = profdata%nqc(jo)
          ELSE
             fbdata%ioqc(jo)    = profdata%nqc(jo)
@@ -213,8 +213,8 @@
                fbdata%idqc(ik,jo)        = profdata%var(jvar)%idqc(jk)
                fbdata%idqcf(:,ik,jo)     = profdata%var(jvar)%idqcf(:,jk)
-               IF ( profdata%var(jvar)%nvqc(jk) > 10 ) THEN
-                  fbdata%ivlqc(ik,jo,jvar) = 4
+               IF ( profdata%var(jvar)%nvqc(jk) > 255 ) THEN
+                  fbdata%ivlqc(ik,jo,jvar) = IBSET(profdata%var(jvar)%nvqc(jk),2)
                   fbdata%ivlqcf(1,ik,jo,jvar) = profdata%var(jvar)%nvqcf(1,jk)
-                  fbdata%ivlqcf(2,ik,jo,jvar) = profdata%var(jvar)%nvqc(jk) - 10
+                  fbdata%ivlqcf(2,ik,jo,jvar) = IAND(profdata%var(jvar)%nvqc(jk),b'0000 0000 1111 1111')
                ELSE
                   fbdata%ivlqc(ik,jo,jvar) = profdata%var(jvar)%nvqc(jk)
@@ -360,8 +360,8 @@
          fbdata%ivqc(jo,:)    = 0
          fbdata%ivqcf(:,jo,:) = 0
-         IF ( sladata%nqc(jo) > 10 ) THEN
+         IF ( sladata%nqc(jo) > 255 ) THEN
             fbdata%ioqc(jo)    = 4
             fbdata%ioqcf(1,jo) = 0
-            fbdata%ioqcf(2,jo) = sladata%nqc(jo) - 10
+            fbdata%ioqcf(2,jo) =  IAND(sladata%nqc(jo),b'0000 0000 1111 1111')
          ELSE
             fbdata%ioqc(jo)    = sladata%nqc(jo)
@@ -395,9 +395,9 @@
          fbdata%idqc(1,jo)     = 0
          fbdata%idqcf(:,1,jo)  = 0
-         IF ( sladata%nqc(jo) > 10 ) THEN
+         IF ( sladata%nqc(jo) > 255 ) THEN
             fbdata%ivqc(jo,1)       = 4
             fbdata%ivlqc(1,jo,1)    = 4
             fbdata%ivlqcf(1,1,jo,1) = 0
-            fbdata%ivlqcf(2,1,jo,1) = sladata%nqc(jo) - 10
+            fbdata%ivlqcf(2,1,jo,1) =  IAND(sladata%nqc(jo),b'0000 0000 1111 1111')
          ELSE
             fbdata%ivqc(jo,1)       = sladata%nqc(jo)
@@ -514,8 +514,8 @@
          fbdata%ivqc(jo,:)    = 0
          fbdata%ivqcf(:,jo,:) = 0
-         IF ( sstdata%nqc(jo) > 10 ) THEN
+         IF ( sstdata%nqc(jo) > 255 ) THEN
             fbdata%ioqc(jo)    = 4
             fbdata%ioqcf(1,jo) = 0
-            fbdata%ioqcf(2,jo) = sstdata%nqc(jo) - 10
+            fbdata%ioqcf(2,jo) = IAND(sstdata%nqc(jo), b'0000 0000 1111 1111')
          ELSE
             fbdata%ioqc(jo)    = MAX(sstdata%nqc(jo),1)
@@ -548,9 +548,9 @@
          fbdata%idqc(1,jo)     = 0
          fbdata%idqcf(:,1,jo)  = 0
-         IF ( sstdata%nqc(jo) > 10 ) THEN
+         IF ( sstdata%nqc(jo) > 255 ) THEN
             fbdata%ivqc(jo,1)       = 4
             fbdata%ivlqc(1,jo,1)    = 4
             fbdata%ivlqcf(1,1,jo,1) = 0
-            fbdata%ivlqcf(2,1,jo,1) = sstdata%nqc(jo) - 10
+            fbdata%ivlqcf(2,1,jo,1) = IAND(sstdata%nqc(jo), b'0000 0000 1111 1111')
          ELSE
             fbdata%ivqc(jo,1)       = MAX(sstdata%nqc(jo),1)
@@ -670,8 +670,8 @@
          fbdata%ivqc(jo,:)    = 0
          fbdata%ivqcf(:,jo,:) = 0
-         IF ( seaicedata%nqc(jo) > 10 ) THEN
+         IF ( seaicedata%nqc(jo) > 255 ) THEN
             fbdata%ioqc(jo)    = 4
             fbdata%ioqcf(1,jo) = 0
-            fbdata%ioqcf(2,jo) = seaicedata%nqc(jo) - 10
+            fbdata%ioqcf(2,jo) = IAND(seaicedata%nqc(jo),b'0000 0000 1111 1111')
          ELSE
             fbdata%ioqc(jo)    = MAX(seaicedata%nqc(jo),1)
@@ -704,8 +704,8 @@
          fbdata%idqc(1,jo)     = 0
          fbdata%idqcf(:,1,jo)  = 0
-         IF ( seaicedata%nqc(jo) > 10 ) THEN
+         IF ( seaicedata%nqc(jo) > 255 ) THEN
             fbdata%ivlqc(1,jo,1) = 4
             fbdata%ivlqcf(1,1,jo,1) = 0
-            fbdata%ivlqcf(2,1,jo,1) = seaicedata%nqc(jo) - 10
+            fbdata%ivlqcf(2,1,jo,1) = IAND(seaicedata%nqc(jo),b'0000 0000 1111 1111')
          ELSE
             fbdata%ivlqc(1,jo,1) = MAX(seaicedata%nqc(jo),1)
@@ -849,8 +849,8 @@
          fbdata%ivqc(jo,:)    = profdata%ivqc(jo,:)
          fbdata%ivqcf(:,jo,:) = profdata%ivqcf(:,jo,:)
-         IF ( profdata%nqc(jo) > 10 ) THEN
+         IF ( profdata%nqc(jo) > 255 ) THEN
             fbdata%ioqc(jo)    = 4
             fbdata%ioqcf(1,jo) = profdata%nqcf(1,jo)
-            fbdata%ioqcf(2,jo) = profdata%nqc(jo) - 10
+            fbdata%ioqcf(2,jo) = IAND(profdata%nqc(jo), b'0000 0000 1111 1111')
          ELSE
             fbdata%ioqc(jo)    = profdata%nqc(jo)
@@ -894,8 +894,8 @@
                fbdata%idqc(ik,jo)        = profdata%var(jvar)%idqc(jk)
                fbdata%idqcf(:,ik,jo)     = profdata%var(jvar)%idqcf(:,jk)
-               IF ( profdata%var(jvar)%nvqc(jk) > 10 ) THEN
+               IF ( profdata%var(jvar)%nvqc(jk) > 255 ) THEN
                   fbdata%ivlqc(ik,jo,jvar) = 4
                   fbdata%ivlqcf(1,ik,jo,jvar) = profdata%var(jvar)%nvqcf(1,jk)
-                  fbdata%ivlqcf(2,ik,jo,jvar) = profdata%var(jvar)%nvqc(jk) - 10
+                  fbdata%ivlqcf(2,ik,jo,jvar) = IAND(profdata%nqc(jo), b'0000 0000 1111 1111')
                ELSE
                   fbdata%ivlqc(ik,jo,jvar) = profdata%var(jvar)%nvqc(jk)
