Index: NEMO/branches/UKMO/NEMO_4.0.4_generic_obs/src/OCE/DYN/dynspg_ts.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_generic_obs/src/OCE/DYN/dynspg_ts.F90	(revision 15246)
+++ NEMO/branches/UKMO/NEMO_4.0.4_generic_obs/src/OCE/DYN/dynspg_ts.F90	(revision 15248)
@@ -51,7 +51,8 @@
    USE agrif_oce
 #endif
-#if defined key_asminc   
-   USE asminc          ! Assimilation increment
-#endif
+! REMOVING THIS AS PER V3.6, BUT IS THIS THE BEST BRANCH TO DO IT IN?
+!#if defined key_asminc   
+!   USE asminc          ! Assimilation increment
+!#endif
    !
    USE in_out_manager  ! I/O manager
@@ -341,11 +342,12 @@
       ENDIF
       !
-#if defined key_asminc
-      !                                   !=  Add the IAU weighted SSH increment  =!
-      !                                   !  ------------------------------------  !
-      IF( lk_asminc .AND. ln_sshinc .AND. ln_asmiau ) THEN
-         zssh_frc(:,:) = zssh_frc(:,:) - ssh_iau(:,:)
-      ENDIF
-#endif
+! REMOVING THIS AS PER V3.6, BUT IS THIS THE BEST BRANCH TO DO IT IN?
+!#if defined key_asminc
+!      !                                   !=  Add the IAU weighted SSH increment  =!
+!      !                                   !  ------------------------------------  !
+!      IF( lk_asminc .AND. ln_sshinc .AND. ln_asmiau ) THEN
+!         zssh_frc(:,:) = zssh_frc(:,:) - ssh_iau(:,:)
+!      ENDIF
+!#endif
       !                                   != Fill boundary data arrays for AGRIF
       !                                   ! ------------------------------------
Index: NEMO/branches/UKMO/NEMO_4.0.4_generic_obs/src/OCE/OBS/obs_level_search.h90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_generic_obs/src/OCE/OBS/obs_level_search.h90	(revision 15246)
+++ NEMO/branches/UKMO/NEMO_4.0.4_generic_obs/src/OCE/OBS/obs_level_search.h90	(revision 15248)
@@ -13,5 +13,8 @@
       !! ** Method  : Straightforward search
       !!
-      !! ** Action  : 
+      !! ** Action  : Will return level associated with T-point below the obs
+      !!              depth, except when observation is in the top box will 
+      !!              return level 2. Also, if obs depth greater than depth 
+      !!              of last wet T-point (kpk-1) will return level kpk.
       !!
       !! History :
@@ -43,5 +46,5 @@
       DO ji = 1, kobs 
          kobsk(ji) = 1
-         depk: DO jk = 2, kgrd
+         depk: DO jk = 2, kgrd-1
             IF ( pgrddep(jk) >= pobsdep(ji) ) EXIT depk
          END DO depk
Index: NEMO/branches/UKMO/NEMO_4.0.4_generic_obs/src/OCE/OBS/obs_oper.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_generic_obs/src/OCE/OBS/obs_oper.F90	(revision 15246)
+++ NEMO/branches/UKMO/NEMO_4.0.4_generic_obs/src/OCE/OBS/obs_oper.F90	(revision 15248)
@@ -760,10 +760,15 @@
          & zmask(imaxifp,imaxjfp,isurf), &
          & zsurf(imaxifp,imaxjfp,isurf), &
-         & zsurftmp(imaxifp,imaxjfp,isurf),  &
-         & zglamf(imaxifp+1,imaxjfp+1,isurf), &
-         & zgphif(imaxifp+1,imaxjfp+1,isurf), &
-         & igrdip1(imaxifp+1,imaxjfp+1,isurf), &
-         & igrdjp1(imaxifp+1,imaxjfp+1,isurf) &
+         & zsurftmp(imaxifp,imaxjfp,isurf) &
          & )
+
+      IF ( k2dint > 4 ) THEN
+         ALLOCATE( &
+            & zglamf(imaxifp+1,imaxjfp+1,isurf),  &
+            & zgphif(imaxifp+1,imaxjfp+1,isurf),  &
+            & igrdip1(imaxifp+1,imaxjfp+1,isurf), &
+            & igrdjp1(imaxifp+1,imaxjfp+1,isurf)  &
+            & )
+      ENDIF
 
       IF ( ldclim ) THEN
@@ -787,6 +792,8 @@
                IF ( imodj > jpjglo ) imodj = jpjglo
                !
-               igrdip1(ji+1,jj+1,iobs) = imodi
-               igrdjp1(ji+1,jj+1,iobs) = imodj
+               IF ( k2dint > 4 ) THEN
+                  igrdip1(ji+1,jj+1,iobs) = imodi
+                  igrdjp1(ji+1,jj+1,iobs) = imodj
+               ENDIF
                !
                IF ( ji >= 1 .AND. jj >= 1 ) THEN
@@ -819,8 +826,10 @@
       ENDIF
 
-      CALL obs_int_comm_2d( imaxifp+1, imaxjfp+1, isurf, kpi, kpj, &
-         &                  igrdip1, igrdjp1, glamf, zglamf )
-      CALL obs_int_comm_2d( imaxifp+1, imaxjfp+1, isurf, kpi, kpj, &
-         &                  igrdip1, igrdjp1, gphif, zgphif )
+      IF ( k2dint > 4 ) THEN 
+         CALL obs_int_comm_2d( imaxifp+1, imaxjfp+1, isurf, kpi, kpj, &
+            &                  igrdip1, igrdjp1, glamf, zglamf )
+         CALL obs_int_comm_2d( imaxifp+1, imaxjfp+1, isurf, kpi, kpj, &
+            &                  igrdip1, igrdjp1, gphif, zgphif )
+      ENDIF
       
       IF ( ldclim ) THEN
@@ -955,10 +964,15 @@
          & zmask, &
          & zsurf, &
-         & zsurftmp, &
-         & zglamf, &
-         & zgphif, &
-         & igrdip1,&
-         & igrdjp1 &
+         & zsurftmp &
          & )
+
+      IF ( k2dint > 4 ) THEN
+         DEALLOCATE( &     
+            & zglamf, &
+            & zgphif, &
+            & igrdip1,&
+            & igrdjp1 &
+            & )
+      ENDIF
             
       IF ( ldclim ) THEN
Index: NEMO/branches/UKMO/NEMO_4.0.4_generic_obs/src/OCE/OBS/obs_prep.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_generic_obs/src/OCE/OBS/obs_prep.F90	(revision 15246)
+++ NEMO/branches/UKMO/NEMO_4.0.4_generic_obs/src/OCE/OBS/obs_prep.F90	(revision 15248)
@@ -1120,6 +1120,7 @@
          & gdept_n,       &
          & ln_zco,        &
-         & ln_zps             
-
+         & ln_zps,        &
+         & mbkt
+! I THINK MBKT IS CORRECT (V3.6 WAS MBATHY) BUT CONFIRM
       !! * Arguments
       INTEGER, INTENT(IN) :: kprofno      ! Number of profiles
@@ -1166,8 +1167,10 @@
       REAL(KIND=wp), DIMENSION(jpi,jpj) :: zbdymask
       REAL(KIND=wp), DIMENSION(2,2,kpk,kprofno) :: &
+         & zgdept, &
          & zgdepw
       REAL(KIND=wp), DIMENSION(2,2,kprofno) :: &
          & zglam, &           ! Model longitude at grid points
-         & zgphi              ! Model latitude at grid points
+         & zgphi, &           ! Model latitude at grid points
+         & zbathy             ! Index of deepest wet level at grid points
       INTEGER, DIMENSION(2,2,kprofno) :: &
          & igrdi, &           ! Grid i,j
@@ -1177,4 +1180,5 @@
       INTEGER :: iig, ijg           ! i,j of observation on model grid point.
       INTEGER :: jobs, jobsp, jk, ji, jj
+      REAL(KIND=wp) :: maxdept, maxdepw
       !!----------------------------------------------------------------------
 
@@ -1228,6 +1232,10 @@
       CALL obs_int_comm_2d( 2, 2, kprofno, kpi, kpj, igrdi, igrdj, plam, zglam )
       CALL obs_int_comm_2d( 2, 2, kprofno, kpi, kpj, igrdi, igrdj, pphi, zgphi )
+      CALL obs_int_comm_2d( 2, 2, kprofno, kpi, kpj, igrdi, igrdj, REAL(mbkt), zbathy )
+      ! Need to know the bathy depth for each observation for sco
       CALL obs_int_comm_3d( 2, 2, kprofno, kpi, kpj, kpk, igrdi, igrdj, gdepw_n(:,:,:), &
-        &                     zgdepw )
+        &                   zgdepw )
+      CALL obs_int_comm_3d( 2, 2, kprofno, kpi, kpj, kpk, igrdi, igrdj, gdept_n(:,:,:), &
+         &                  zgdept )
 
       DO jobs = 1, kprofno
@@ -1265,11 +1273,25 @@
          DO jobsp = kpstart(jobs), kpend(jobs)
 
+            ! Calculate max T and W depths of 2x2 grid
+            maxdept=zgdept(1,1,NINT(zbathy(1,1,jobs)),jobs)
+            maxdepw=zgdepw(1,1,NINT(zbathy(1,1,jobs))+1,jobs)
+            DO jj = 1, 2
+               DO ji = 1, 2
+                  IF ( zgdept(ji,jj,NINT(zbathy(ji,jj,jobs)),jobs) > maxdept ) THEN
+                     maxdept = zgdept(ji,jj,NINT(zbathy(ji,jj,jobs)),jobs)
+                  END IF
+                  IF ( zgdepw(ji,jj,NINT(zbathy(ji,jj,jobs))+1,jobs) > maxdepw ) THEN
+                     maxdepw = zgdepw(ji,jj,NINT(zbathy(ji,jj,jobs))+1,jobs)
+                  END IF
+               END DO
+            END DO
+
             ! Flag if the observation falls outside the model spatial domain
-            IF (       ( pobslam(jobs) < -180.         )       &
-               &  .OR. ( pobslam(jobs) >  180.         )       &
-               &  .OR. ( pobsphi(jobs) <  -90.         )       &
-               &  .OR. ( pobsphi(jobs) >   90.         )       &
-               &  .OR. ( pobsdep(jobsp) < 0.0          )       &
-               &  .OR. ( pobsdep(jobsp) > gdepw_1d(kpk)) ) THEN
+            IF (       ( pobslam(jobs) < -180.    )       &
+               &  .OR. ( pobslam(jobs) >  180.    )       &
+               &  .OR. ( pobsphi(jobs) <  -90.    )       &
+               &  .OR. ( pobsphi(jobs) >   90.    )       &
+               &  .OR. ( pobsdep(jobsp) < 0.0     )       &
+               &  .OR. ( pobsdep(jobsp) > maxdepw ) ) THEN
                kobsqc(jobsp) = IBSET(kobsqc(jobsp),11)
                kosdobs = kosdobs + 1
@@ -1317,7 +1339,13 @@
 
             ! Set observation depth equal to that of the first model depth
-            IF ( pobsdep(jobsp) <= pdep(1) ) THEN
-               pobsdep(jobsp) = pdep(1)  
-            ENDIF
+            IF ( pobsdep(jobsp) < MINVAL(zgdept(1:2,1:2,1,jobs) ) ) THEN
+               pobsdep(jobsp) = MINVAL(zgdept(1:2,1:2,1,jobs))
+            ENDIF
+
+            ! Set observation depth equal to that of the last wet T-point
+            IF ( ( pobsdep(jobsp) > maxdept ) .AND. &
+               & ( pobsdep(jobsp) < maxdepw ) ) THEN
+               pobsdep(jobsp) = maxdept
+            END IF
             
             IF (ln_bdy) THEN
