Index: branches/UKMO/dev_r5518_obs_oper_update_vel_obsoper/NEMOGCM/NEMO/OPA_SRC/OBS/obs_prep.F90
===================================================================
--- branches/UKMO/dev_r5518_obs_oper_update_vel_obsoper/NEMOGCM/NEMO/OPA_SRC/OBS/obs_prep.F90	(revision 13368)
+++ branches/UKMO/dev_r5518_obs_oper_update_vel_obsoper/NEMOGCM/NEMO/OPA_SRC/OBS/obs_prep.F90	(revision 13384)
@@ -53,8 +53,11 @@
 CONTAINS
 
-   SUBROUTINE obs_pre_surf( surfdata, surfdataqc, ld_nea, ld_bound_reject, &
-                            ld_seaicetypes, kqc_cutoff )
-      !!----------------------------------------------------------------------
-      !!                    ***  ROUTINE obs_pre_sla  ***
+   SUBROUTINE obs_pre_surf( surfdata, surfdataqc, &
+      &                     kpi, kpj, &   
+      &                     zmask, pglam, pgphi, &
+      &                     ld_nea, ld_bound_reject, &
+      &                     ld_seaicetypes, kqc_cutoff )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE obs_pre_surf  ***
       !!
       !! ** Purpose : First level check and screening of surface observations
@@ -82,4 +85,10 @@
       TYPE(obs_surf), INTENT(INOUT) :: surfdata    ! Full set of surface data
       TYPE(obs_surf), INTENT(INOUT) :: surfdataqc  ! Subset of surface data not failing screening
+      INTEGER, INTENT(IN) :: kpi, kpj              ! Local domain sizes      
+      REAL(wp), INTENT(IN), DIMENSION(kpi,kpj,surfdata%nvar) :: &
+         & zmask      
+      REAL(wp), INTENT(IN), DIMENSION(kpi,kpj,surfdata%nvar) :: &
+         & pglam, &
+         & pgphi
       LOGICAL, INTENT(IN) :: ld_nea                ! Switch for rejecting observation near land
       LOGICAL, INTENT(IN) :: ld_bound_reject       ! Switch for rejecting obs near the boundary
@@ -94,24 +103,27 @@
       INTEGER :: imin0
       INTEGER :: icycle       ! Current assimilation cycle
-                              ! Counters for observations that
-      INTEGER :: iotdobs      !  - outside time domain
-      INTEGER :: iosdsobs     !  - outside space domain
-      INTEGER :: ilansobs     !  - within a model land cell
-      INTEGER :: inlasobs     !  - close to land
-      INTEGER :: igrdobs      !  - fail the grid search
-      INTEGER :: ibdysobs     !  - close to open boundary
-                              ! Global counters for observations that
-      INTEGER :: iotdobsmpp     !  - outside time domain
-      INTEGER :: iosdsobsmpp    !  - outside space domain
-      INTEGER :: ilansobsmpp    !  - within a model land cell
-      INTEGER :: inlasobsmpp    !  - close to land
-      INTEGER :: igrdobsmpp     !  - fail the grid search
-      INTEGER :: ibdysobsmpp  !  - close to open boundary
+                                                        ! Counters for observations that are
+      INTEGER                           :: iotdobs      !  - outside time domain
+      INTEGER, DIMENSION(surfdata%nvar) :: iosdsobs     !  - outside space domain
+      INTEGER, DIMENSION(surfdata%nvar) :: ilansobs     !  - within a model land cell
+      INTEGER, DIMENSION(surfdata%nvar) :: inlasobs     !  - close to land
+      INTEGER, DIMENSION(surfdata%nvar) :: ibdysobs     !  - close to open boundary
+      INTEGER                           :: igrdobs      !  - fail the grid search      
+                                                        ! Global counters for observations that
+      INTEGER                           :: iotdobsmpp   !  - outside time domain
+      INTEGER, DIMENSION(surfdata%nvar) :: iosdsobsmpp  !  - outside space domain
+      INTEGER, DIMENSION(surfdata%nvar) :: ilansobsmpp  !  - within a model land cell
+      INTEGER, DIMENSION(surfdata%nvar) :: inlasobsmpp  !  - close to land
+      INTEGER, DIMENSION(surfdata%nvar) :: ibdysobsmpp  !  - close to open boundary
+      INTEGER                           :: igrdobsmpp   !  - fail the grid search
+
       LOGICAL, DIMENSION(:), ALLOCATABLE :: & 
          & llvalid            ! SLA data selection
-      INTEGER :: jobs         ! Obs. loop variable
+      INTEGER :: jobs         ! Obs. loop counter
+      INTEGER :: jvar         ! Variable loop counter
       INTEGER :: jstp         ! Time loop variable
       INTEGER :: inrc         ! Time index variable
-
+      CHARACTER(LEN=256) :: cout1  ! Diagnostic output line
+      
       IF(lwp) WRITE(numout,*)'obs_pre_surf : Preparing the surface observations...'
       IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
@@ -130,8 +142,8 @@
       iotdobs  = 0
       igrdobs  = 0
-      iosdsobs = 0
-      ilansobs = 0
-      inlasobs = 0
-      ibdysobs = 0 
+      iosdsobs(:) = 0
+      ilansobs(:) = 0
+      inlasobs(:) = 0
+      ibdysobs(:) = 0 
 
       ! Set QC cutoff to optional value if provided
@@ -162,8 +174,9 @@
       ! Check for surface data failing the grid search
       ! -----------------------------------------------------------------------
-
-      CALL obs_coo_grd( surfdata%nsurf,   surfdata%mi, surfdata%mj, &
-         &              surfdata%nqc,     igrdobs                         )
-
+      DO jvar = 1, surfdata%nvar
+         CALL obs_coo_grd( surfdata%nsurf,   surfdata%mi(:,jvar), surfdata%mj(:,jvar), &
+            &              surfdata%nqc,     igrdobs )
+      END DO
+      
       CALL obs_mpp_sum_integer( igrdobs, igrdobsmpp )
 
@@ -172,20 +185,21 @@
       ! -----------------------------------------------------------------------
 
-      CALL obs_coo_spc_2d( surfdata%nsurf,              &
-         &                 jpi,          jpj,          &
-         &                 surfdata%mi,   surfdata%mj,   & 
-         &                 surfdata%rlam, surfdata%rphi, &
-         &                 glamt,        gphit,        &
-         &                 tmask(:,:,1), surfdata%nqc,  &
-         &                 iosdsobs,     ilansobs,     &
-         &                 inlasobs,     ld_nea,       &
-         &                 ibdysobs,     ld_bound_reject, &
-         &                 iqc_cutoff                     )
-
-      CALL obs_mpp_sum_integer( iosdsobs, iosdsobsmpp )
-      CALL obs_mpp_sum_integer( ilansobs, ilansobsmpp )
-      CALL obs_mpp_sum_integer( inlasobs, inlasobsmpp )
-      CALL obs_mpp_sum_integer( ibdysobs, ibdysobsmpp )
-
+      DO jvar = 1, surfdata%nvar
+         CALL obs_coo_spc_2d( surfdata%nsurf,                         &
+            &                 jpi,          jpj,                      &
+            &                 surfdata%mi(:,jvar), surfdata%mj(:,jvar), & 
+            &                 surfdata%rlam, surfdata%rphi,           &
+            &                 pglam(:,:,jvar), pgphi(:,:,jvar),       &
+            &                 zmask(:,:,jvar), surfdata%nqc(:),       &
+            &                 iosdsobs(jvar),     ilansobs(jvar),     &
+            &                 inlasobs(jvar),     ld_nea,             &
+            &                 ibdysobs(jvar),     ld_bound_reject,    &
+            &                 iqc_cutoff                     )
+         CALL obs_mpp_sum_integer( iosdsobs(jvar), iosdsobsmpp(jvar) )
+         CALL obs_mpp_sum_integer( ilansobs(jvar), ilansobsmpp(jvar) )
+         CALL obs_mpp_sum_integer( inlasobs(jvar), inlasobsmpp(jvar) )
+         CALL obs_mpp_sum_integer( ibdysobs(jvar), ibdysobsmpp(jvar) )
+      END DO
+           
       ! -----------------------------------------------------------------------
       ! Copy useful data from the surfdata data structure to
@@ -216,29 +230,41 @@
       
       IF(lwp) THEN
+
+         DO jvar = 1, surfdataqc%nvar       
+            IF ( jvar == 1 ) THEN
+               cout1=TRIM(surfdataqc%cvars(1))                  
+            ELSE
+               WRITE(cout1,'(A,A1,A)') TRIM(cout1), '/', TRIM(surfdataqc%cvars(jvar))            
+            ENDIF
+         END DO
+               
          WRITE(numout,*)
-         WRITE(numout,*) ' '//surfdataqc%cvars(1)//' data outside time domain                  = ', &
+         WRITE(numout,*) ' '//TRIM(cout1)//' data outside time domain                  = ', &
             &            iotdobsmpp
-         WRITE(numout,*) ' Remaining '//surfdataqc%cvars(1)//' data that failed grid search    = ', &
+         WRITE(numout,*) ' Remaining '//TRIM(cout1)//' data that failed grid search    = ', &
             &            igrdobsmpp
-         WRITE(numout,*) ' Remaining '//surfdataqc%cvars(1)//' data outside space domain       = ', &
-            &            iosdsobsmpp
-         WRITE(numout,*) ' Remaining '//surfdataqc%cvars(1)//' data at land points             = ', &
-            &            ilansobsmpp
-         IF (ld_nea) THEN
-            WRITE(numout,*) ' Remaining '//surfdataqc%cvars(1)//' data near land points (removed) = ', &
-               &            inlasobsmpp
-         ELSE
-            WRITE(numout,*) ' Remaining '//surfdataqc%cvars(1)//' data near land points (kept)    = ', &
-               &            inlasobsmpp
-         ENDIF
-         WRITE(numout,*) ' Remaining '//surfdataqc%cvars(1)//' data near open boundary (removed) = ', &
-            &            ibdysobsmpp  
-         WRITE(numout,*) ' '//surfdataqc%cvars(1)//' data accepted                             = ', &
-            &            surfdataqc%nsurfmpp
+
+         DO jvar = 1, surfdataqc%nvar            
+            WRITE(numout,*) ' Remaining '//surfdataqc%cvars(jvar)//' data outside space domain       = ', &
+                &            iosdsobsmpp(jvar)
+             WRITE(numout,*) ' Remaining '//surfdataqc%cvars(jvar)//' data at land points             = ', &
+                &            ilansobsmpp(jvar)
+             IF (ld_nea) THEN
+                WRITE(numout,*) ' Remaining '//surfdataqc%cvars(jvar)//' data near land points (removed) = ', &
+                   &            inlasobsmpp(jvar)
+             ELSE
+                WRITE(numout,*) ' Remaining '//surfdataqc%cvars(jvar)//' data near land points (kept)    = ', &
+                   &            inlasobsmpp(jvar)
+             ENDIF     
+             WRITE(numout,*) ' Remaining '//surfdataqc%cvars(jvar)//' data near open boundary (removed) = ', &
+                &            ibdysobsmpp(jvar)
+          END DO
+          WRITE(numout,*) ' '//TRIM(cout1)//' data accepted                             = ', &
+             &            surfdataqc%nsurfmpp
 
          WRITE(numout,*)
          WRITE(numout,*) ' Number of observations per time step :'
          WRITE(numout,*)
-         WRITE(numout,'(10X,A,10X,A)')'Time step',surfdataqc%cvars(1)
+         WRITE(numout,'(10X,A,10X,A)')'Time step',TRIM(cout1)
          WRITE(numout,'(10X,A,5X,A)')'---------','-----------------'
          CALL FLUSH(numout)
@@ -445,5 +471,5 @@
 
       IF ( TRIM(profdata%cvars(1)) == 'UVEL' ) THEN
-         CALL obs_uv_rej( profdata, iuvchku, iuvchkv, iqc_cutoff )
+         CALL obs_uv_rej_pro( profdata, iuvchku, iuvchkv, iqc_cutoff )
          CALL obs_mpp_sum_integer( iuvchku, iuvchkumpp )
          CALL obs_mpp_sum_integer( iuvchkv, iuvchkvmpp )
@@ -1457,7 +1483,7 @@
    END SUBROUTINE obs_pro_rej
 
-   SUBROUTINE obs_uv_rej( profdata, knumu, knumv, kqc_cutoff )
-      !!----------------------------------------------------------------------
-      !!                    ***  ROUTINE obs_uv_rej ***
+   SUBROUTINE obs_uv_rej_pro( profdata, knumu, knumv, kqc_cutoff )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE obs_uv_rej_pro ***
       !!
       !! ** Purpose : Reject u if v is rejected and vice versa
@@ -1513,5 +1539,5 @@
       END DO
 
-   END SUBROUTINE obs_uv_rej
+   END SUBROUTINE obs_uv_rej_pro
 
 END MODULE obs_prep
