Index: branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/diaobs.F90
===================================================================
--- branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/diaobs.F90	(revision 2357)
+++ branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/diaobs.F90	(revision 2358)
@@ -194,4 +194,12 @@
       INTEGER :: jset
       LOGICAL :: lmask(MaxNumFiles), ll_u3d, ll_v3d
+
+      !-----------------------------------------------------------------------
+      ! Force exit if AGRIF activated
+      !-----------------------------------------------------------------------
+    
+      IF( lk_agrif ) THEN
+        CALL ctl_stop( 'dia_obs_init : key_diaobs and key_agrif cannot be used together' )
+      ENDIF
 
       !-----------------------------------------------------------------------
Index: branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_grd_bruteforce.h90
===================================================================
--- branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_grd_bruteforce.h90	(revision 2358)
+++ branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_grd_bruteforce.h90	(revision 2358)
@@ -0,0 +1,349 @@
+   SUBROUTINE obs_grd_bruteforce( kpi, kpj, kpiglo, kpjglo,       &
+      &                            kldi, klei, kldj, klej,         &
+      &                            kmyproc, ktotproc,              &
+      &                            pglam, pgphi, pmask,            &
+      &                            kobs, plam, pphi, kobsi, kobsj, &
+      &                                   kproc)
+      !!----------------------------------------------------------------------
+      !!                ***  ROUTINE obs_grd_bruteforce ***
+      !!
+      !! ** Purpose : Search gridpoints to find the grid box containing
+      !!              the observations
+      !!
+      !! ** Method  : Call to linquad
+      !!
+      !! ** Action  : Return kproc holding the observation and kiobsi,kobsj
+      !!              valid on kproc=kmyproc processor only.
+      !!   
+      !! History :
+      !!        !  2001-11  (N. Daget, A. Weaver)
+      !!        !  2006-03  (A. Weaver) NEMOVAR migration.
+      !!        !  2006-05  (K. Mogensen) Moved to to separate routine.
+      !!        !  2007-10  (A. Vidard) Bug fix in wrap around checks; cleanup
+      !!----------------------------------------------------------------------
+
+      !! * Arguments
+      INTEGER, INTENT(IN) :: kpi                ! Number of local longitudes
+      INTEGER, INTENT(IN) :: kpj                ! Number of local latitudes
+      INTEGER, INTENT(IN) :: kpiglo             ! Number of global longitudes
+      INTEGER, INTENT(IN) :: kpjglo             ! Number of global latitudes
+      INTEGER, INTENT(IN) :: kldi               ! Start of inner domain in i
+      INTEGER, INTENT(IN) :: klei               ! End of inner domain in i
+      INTEGER, INTENT(IN) :: kldj               ! Start of inner domain in j
+      INTEGER, INTENT(IN) :: klej               ! End of inner domain in j
+      INTEGER, INTENT(IN) :: kmyproc            ! Processor number for MPP
+      INTEGER, INTENT(IN) :: ktotproc           ! Total number of processors
+      REAL(KIND=wp), DIMENSION(kpi,kpj), INTENT(IN) :: &
+         & pglam,   &               ! Grid point longitude
+         & pgphi,   &               ! Grid point latitude
+         & pmask                    ! Grid point mask
+      INTEGER,INTENT(IN) :: kobs                ! Size of the observation arrays
+      REAL(KIND=wp), DIMENSION(kobs), INTENT(IN) :: &
+         & plam, &                  ! Longitude of obsrvations 
+         & pphi                     ! Latitude of observations
+      INTEGER, DIMENSION(kobs), INTENT(OUT) :: &
+         & kobsi, &                 ! I-index of observations 
+         & kobsj, &                 ! J-index of observations 
+         & kproc                    ! Processor number of observations
+  
+      !! * Local declarations
+      REAL(wp), DIMENSION(:), ALLOCATABLE :: &
+         & zplam, zpphi
+      REAL(wp) :: zlammax
+      REAL(wp) :: zlam
+      INTEGER :: ji
+      INTEGER :: jj
+      INTEGER :: jk
+      INTEGER :: jo
+      INTEGER :: jlon
+      INTEGER :: jlat
+      INTEGER :: joffset
+      INTEGER :: jostride
+      REAL(KIND=wp), DIMENSION(:,:), ALLOCATABLE :: &
+         & zlamg, &
+         & zphig, &
+         & zmskg, &
+         & zphitmax,&
+         & zphitmin,&
+         & zlamtmax,&
+         & zlamtmin
+      LOGICAL, DIMENSION(:,:), ALLOCATABLE :: &
+         & llinvalidcell
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: &
+         & zlamtm,  &
+         & zphitm
+
+      !-----------------------------------------------------------------------
+      ! Define grid setup for grid search
+      !-----------------------------------------------------------------------
+      IF (ln_grid_global) THEN
+         jlon     = kpiglo
+         jlat     = kpjglo
+         joffset  = kmyproc
+         jostride = ktotproc
+      ELSE
+         jlon     = kpi
+         jlat     = kpj
+         joffset  = 0
+         jostride = 1
+      ENDIF
+      !-----------------------------------------------------------------------
+      ! Set up data for grid search
+      !-----------------------------------------------------------------------
+      ALLOCATE( &
+         & zlamg(jlon,jlat),             &
+         & zphig(jlon,jlat),             &
+         & zmskg(jlon,jlat),             &
+         & zphitmax(jlon-1,jlat-1),      &
+         & zphitmin(jlon-1,jlat-1),      &
+         & zlamtmax(jlon-1,jlat-1),      &
+         & zlamtmin(jlon-1,jlat-1),      &
+         & llinvalidcell(jlon-1,jlat-1), &
+         & zlamtm(4,jlon-1,jlat-1),      &
+         & zphitm(4,jlon-1,jlat-1)       &
+         & )
+      !-----------------------------------------------------------------------
+      ! Copy data to local arrays
+      !-----------------------------------------------------------------------
+      IF (ln_grid_global) THEN
+         zlamg(:,:) = -1.e+10
+         zphig(:,:) = -1.e+10
+         zmskg(:,:) = -1.e+10
+         DO jj = kldj, klej
+            DO ji = kldi, klei
+               zlamg(mig(ji),mjg(jj)) = pglam(ji,jj)
+               zphig(mig(ji),mjg(jj)) = pgphi(ji,jj)
+               zmskg(mig(ji),mjg(jj)) = pmask(ji,jj)
+            END DO
+         END DO
+         CALL mpp_global_max( zlamg )
+         CALL mpp_global_max( zphig )
+         CALL mpp_global_max( zmskg )
+      ELSE
+         DO jj = 1, jlat
+            DO ji = 1, jlon
+               zlamg(ji,jj) = pglam(ji,jj)
+               zphig(ji,jj) = pgphi(ji,jj)
+               zmskg(ji,jj) = pmask(ji,jj)
+            END DO
+         END DO
+      ENDIF
+      !-----------------------------------------------------------------------
+      ! Copy longitudes and latitudes
+      !-----------------------------------------------------------------------
+      ALLOCATE( &
+         & zplam(kobs), &
+         & zpphi(kobs)  &
+         & )
+      DO jo = 1, kobs
+         zplam(jo) = plam(jo)
+         zpphi(jo) = pphi(jo)
+      END DO
+      !-----------------------------------------------------------------------
+      ! Set default values for output
+      !-----------------------------------------------------------------------
+      kproc(:) = -1
+      kobsi(:) = -1
+      kobsj(:) = -1
+      !-----------------------------------------------------------------------
+      ! Copy grid positions to temporary arrays and renormalize to 0 to 360.
+      !-----------------------------------------------------------------------
+      DO jj = 1, jlat-1
+         DO ji = 1, jlon-1
+            zlamtm(1,ji,jj) = zlamg(ji  ,jj  )
+            zphitm(1,ji,jj) = zphig(ji  ,jj  )
+            zlamtm(2,ji,jj) = zlamg(ji+1,jj  )
+            zphitm(2,ji,jj) = zphig(ji+1,jj  )
+            zlamtm(3,ji,jj) = zlamg(ji+1,jj+1)
+            zphitm(3,ji,jj) = zphig(ji+1,jj+1)
+            zlamtm(4,ji,jj) = zlamg(ji  ,jj+1)
+            zphitm(4,ji,jj) = zphig(ji  ,jj+1)
+         END DO
+      END DO
+      WHERE ( zlamtm(:,:,:) < 0.0_wp )
+         zlamtm(:,:,:) = zlamtm(:,:,:) + 360.0_wp
+      END WHERE
+      WHERE ( zlamtm(:,:,:) > 360.0_wp )
+         zlamtm(:,:,:) = zlamtm(:,:,:) - 360.0_wp
+      END WHERE
+      !-----------------------------------------------------------------------
+      ! Handle case of the wraparound; beware, not working with orca180
+      !-----------------------------------------------------------------------
+      DO jj = 1, jlat-1
+         DO ji = 1, jlon-1
+            zlammax = MAXVAL( zlamtm(:,ji,jj) )
+            WHERE (zlammax - zlamtm(:, ji, jj) > 180 ) &
+               & zlamtm(:,ji,jj) = zlamtm(:,ji,jj) + 360._wp
+            zphitmax(ji,jj) = MAXVAL(zphitm(:,ji,jj))
+            zphitmin(ji,jj) = MINVAL(zphitm(:,ji,jj))
+            zlamtmax(ji,jj) = MAXVAL(zlamtm(:,ji,jj))
+            zlamtmin(ji,jj) = MINVAL(zlamtm(:,ji,jj))
+         END DO
+      END DO
+      !-----------------------------------------------------------------------
+      ! Search for boxes with only land points mark them invalid
+      !-----------------------------------------------------------------------
+      llinvalidcell(:,:) = .FALSE.
+      DO jj = 1, jlat-1
+         DO ji = 1, jlon-1
+            llinvalidcell(ji,jj) =               &
+               & zmskg(ji  ,jj  ) == 0.0_wp .AND. &
+               & zmskg(ji+1,jj  ) == 0.0_wp .AND. &
+               & zmskg(ji+1,jj+1) == 0.0_wp .AND. &
+               & zmskg(ji  ,jj+1) == 0.0_wp
+         END DO
+      END DO
+
+      !------------------------------------------------------------------------
+      ! Master loop for grid search
+      !------------------------------------------------------------------------
+
+      DO jo = 1+joffset, kobs, jostride
+
+         !---------------------------------------------------------------------
+         ! Ensure that all observation longtiudes are between 0 and 360
+         !---------------------------------------------------------------------
+
+         IF ( zplam(jo) <   0.0_wp ) zplam(jo) = zplam(jo) + 360.0_wp
+         IF ( zplam(jo) > 360.0_wp ) zplam(jo) = zplam(jo) - 360.0_wp
+
+         !---------------------------------------------------------------------
+         ! Find observations which are on within 1e-6 of a grid point
+         !---------------------------------------------------------------------
+
+         gridloop: DO jj = 1, jlat-1
+            DO ji = 1, jlon-1
+               IF ( ABS( zphig(ji,jj) - zpphi(jo) ) < 1e-6 )  THEN
+                  zlam = zlamg(ji,jj)
+                  IF ( zlam <   0.0_wp ) zlam = zlam + 360.0_wp
+                  IF ( zlam > 360.0_wp ) zlam = zlam - 360.0_wp
+                  IF ( ABS( zlam - zplam(jo) ) < 1e-6 ) THEN
+                     IF ( llinvalidcell(ji,jj) ) THEN
+                        kproc(jo) = kmyproc + 1000000
+                        kobsi(jo) = ji + 1
+                        kobsj(jo) = jj + 1
+                        CYCLE
+                     ELSE
+                        kproc(jo) = kmyproc
+                        kobsi(jo) = ji + 1
+                        kobsj(jo) = jj + 1
+                        EXIT gridloop
+                     ENDIF
+                  ENDIF
+               ENDIF
+            END DO
+         END DO gridloop
+         
+         !---------------------------------------------------------------------
+         ! Ensure that all observation longtiudes are between -180 and 180
+         !---------------------------------------------------------------------
+
+         IF ( zplam(jo) > 180 ) zplam(jo) = zplam(jo) - 360.0_wp
+
+         !---------------------------------------------------------------------
+         ! Do coordinate search using brute force.
+         ! - For land points kproc is set to number of the processor + 1000000
+         !   and we continue the search.
+         ! - For ocean points kproc is set to the number of the processor 
+         !   and we stop the search.
+         !---------------------------------------------------------------------
+
+         IF ( kproc(jo) == -1 ) THEN
+
+            ! Normal case
+            gridpoints : DO jj = 1, jlat-1
+               DO ji = 1, jlon-1
+                  
+                  IF ( ( zplam(jo) > zlamtmax(ji,jj) ) .OR. &
+                     & ( zplam(jo) < zlamtmin(ji,jj) ) ) CYCLE
+                  
+                  IF ( ABS( zpphi(jo) ) < 85 ) THEN
+                     IF ( ( zpphi(jo) > zphitmax(ji,jj) ) .OR. &
+                        & ( zpphi(jo) < zphitmin(ji,jj) ) ) CYCLE
+                  ENDIF
+                  
+                  IF ( linquad( zplam(jo), zpphi(jo), &
+                     &          zlamtm(:,ji,jj), zphitm(:,ji,jj) ) ) THEN
+                     IF ( llinvalidcell(ji,jj) ) THEN
+                        kproc(jo) = kmyproc + 1000000
+                        kobsi(jo) = ji + 1
+                        kobsj(jo) = jj + 1
+                        CYCLE
+                     ELSE
+                        kproc(jo) = kmyproc
+                        kobsi(jo) = ji + 1
+                        kobsj(jo) = jj + 1
+                        EXIT gridpoints
+                     ENDIF
+                  ENDIF
+                  
+               END DO
+            END DO gridpoints
+
+         ENDIF
+
+         ! In case of failure retry for obs. longtiude + 360.
+         IF ( kproc(jo) == -1 ) THEN
+            gridpoints_greenwich : DO jj = 1, jlat-1
+               DO ji = 1, jlon-1
+
+                  IF ( ( zplam(jo)+360.0_wp > zlamtmax(ji,jj) ) .OR. &
+                     & ( zplam(jo)+360.0_wp < zlamtmin(ji,jj) ) ) CYCLE
+
+                  IF ( ABS( zpphi(jo) ) < 85 ) THEN
+                     IF ( ( zpphi(jo) > zphitmax(ji,jj) ) .OR. &
+                        & ( zpphi(jo) < zphitmin(ji,jj) ) ) CYCLE
+                  ENDIF
+
+                  IF ( linquad( zplam(jo)+360.0_wp, zpphi(jo), &
+                     &          zlamtm(:,ji,jj), zphitm(:,ji,jj) ) ) THEN
+                     IF ( llinvalidcell(ji,jj) ) THEN
+                        kproc(jo) = kmyproc + 1000000
+                        kobsi(jo) = ji + 1
+                        kobsj(jo) = jj + 1
+                        CYCLE
+                     ELSE
+                        kproc(jo) = kmyproc
+                        kobsi(jo) = ji + 1
+                        kobsj(jo) = jj + 1
+                        EXIT gridpoints_greenwich
+                     ENDIF
+                  ENDIF
+
+               END DO
+            END DO gridpoints_greenwich
+
+         ENDIF
+      END DO
+
+      !----------------------------------------------------------------------
+      ! Synchronize kproc on all processors
+      !----------------------------------------------------------------------
+      IF ( ln_grid_global ) THEN
+         CALL obs_mpp_max_integer( kproc, kobs )
+         CALL obs_mpp_max_integer( kobsi, kobs )
+         CALL obs_mpp_max_integer( kobsj, kobs )
+      ELSE
+         CALL obs_mpp_find_obs_proc( kproc, kobsi, kobsj, kobs )
+      ENDIF
+
+      WHERE( kproc(:) >= 1000000 )
+         kproc(:) = kproc(:) - 1000000
+      END WHERE
+
+      DEALLOCATE( &
+         & zlamg,         &
+         & zphig,         &
+         & zmskg,         &
+         & zphitmax,      &
+         & zphitmin,      &
+         & zlamtmax,      &
+         & zlamtmin,      &
+         & llinvalidcell, &
+         & zlamtm,        &
+         & zphitm,        &
+         & zplam,         &
+         & zpphi          &
+         & )
+
+   END SUBROUTINE obs_grd_bruteforce
Index: branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_grid.F90
===================================================================
--- branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_grid.F90	(revision 2357)
+++ branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_grid.F90	(revision 2358)
@@ -44,6 +44,6 @@
    PRIVATE linquad,                    & ! Determine whether a point lies within a cell
       &    maxdist,                    & ! Find the maximum distance between 2 pts in a cell
-      &    obs_grid_search_bruteforce, & ! Find i, j on the ORCA grid from lat, lon
-      &    obs_grid_search_lookup        ! Find i, j on the ORCA grid from lat, lon quicker
+      &    obs_grd_bruteforce, & ! Find i, j on the ORCA grid from lat, lon
+      &    obs_grd_lookup        ! Find i, j on the ORCA grid from lat, lon quicker
 
    !!* Module variables
@@ -75,5 +75,5 @@
       & ixpos, &
       & iypos, &
-      & iproc    
+      & iprocn    
 
    ! Switches
@@ -98,7 +98,7 @@
       !! ** Purpose : Search local gridpoints to find the grid box containing
       !!              the observations calls either
-      !!              obs_grid_search_bruteforce - the original brute force search
+      !!              obs_grd_bruteforce - the original brute force search
       !!                     or
-      !!              obs_grid_search_lookup - uses a lookup table to do a fast 
+      !!              obs_grd_lookup - uses a lookup table to do a fast 
       !!search
       !!History :
@@ -122,9 +122,9 @@
 
          IF ( ln_grid_search_lookup .AND. ( cdgrid == 'T' ) ) THEN
-            CALL obs_grid_search_lookup( kobsin, plam, pphi, &
+            CALL obs_grd_lookup( kobsin, plam, pphi, &
                &                         kobsi, kobsj, kproc )
          ELSE
             IF ( cdgrid == 'T' ) THEN
-               CALL obs_grid_search_bruteforce( jpi, jpj, jpiglo, jpjglo, &
+               CALL obs_grd_bruteforce( jpi, jpj, jpiglo, jpjglo, &
                   &                             nldi, nlei,nldj,  nlej,   &
                   &                             nproc, jpnij,             &
@@ -133,5 +133,5 @@
                   &                             kobsi, kobsj, kproc )
             ELSEIF ( cdgrid == 'U' ) THEN
-               CALL obs_grid_search_bruteforce( jpi, jpj, jpiglo, jpjglo, &
+               CALL obs_grd_bruteforce( jpi, jpj, jpiglo, jpjglo, &
                   &                             nldi, nlei,nldj,  nlej,   &
                   &                             nproc, jpnij,             &
@@ -140,5 +140,5 @@
                   &                             kobsi, kobsj, kproc )
             ELSEIF ( cdgrid == 'V' ) THEN
-               CALL obs_grid_search_bruteforce( jpi, jpj, jpiglo, jpjglo, &
+               CALL obs_grd_bruteforce( jpi, jpj, jpiglo, jpjglo, &
                   &                             nldi, nlei,nldj,  nlej,   &
                   &                             nproc, jpnij,             &
@@ -147,5 +147,5 @@
                   &                             kobsi, kobsj, kproc )
             ELSEIF ( cdgrid == 'F' ) THEN
-               CALL obs_grid_search_bruteforce( jpi, jpj, jpiglo, jpjglo, &
+               CALL obs_grd_bruteforce( jpi, jpj, jpiglo, jpjglo, &
                   &                             nldi, nlei,nldj,  nlej,   &
                   &                             nproc, jpnij,             &
@@ -162,12 +162,12 @@
    END SUBROUTINE obs_grid_search
 
-#include "obs_grid_search_bruteforce.h90"
+#include "obs_grd_bruteforce.h90"
    
-   SUBROUTINE obs_grid_search_lookup( kobs, plam, pphi, kobsi, kobsj, kproc )
+   SUBROUTINE obs_grd_lookup( kobs, plam, pphi, kobsi, kobsj, kproc )
       !!----------------------------------------------------------------------
-      !!                ***  ROUTINE obs_grid_search_lookup ***
+      !!                ***  ROUTINE obs_grid_lookup ***
       !!
       !! ** Purpose : Search local gridpoints to find the grid box containing
-      !!              the observations (much faster then obs_grid_search_bruteforce)
+      !!              the observations (much faster then obs_grd_bruteforce)
       !!
       !! ** Method  : Call to linquad
@@ -361,5 +361,5 @@
       END DO
 
-      if(lwp) WRITE(numout,*) 'obs_grid_search_lookup do coordinate search using lookup table'
+      if(lwp) WRITE(numout,*) 'obs_grid_lookup do coordinate search using lookup table'
 
       !-----------------------------------------------------------------------
@@ -630,5 +630,5 @@
          & )
       
-   END SUBROUTINE obs_grid_search_lookup
+   END SUBROUTINE obs_grd_lookup
 
 
@@ -758,5 +758,5 @@
                & ixpos(nlons,nlats), &
                & iypos(nlons,nlats), &
-               & iproc(nlons,nlats)  &
+               & iprocn(nlons,nlats)  &
                & )
             
@@ -818,10 +818,10 @@
             END DO
             
-            CALL obs_grid_search_bruteforce( jpi, jpj, jpiglo, jpjglo,  &
-               &                             nldi, nlei,nldj,  nlej,    &
-               &                             nproc, jpnij,              &
-               &                             glamt, gphit, tmask,       &
-               &                             nlons*nlats, lonsi, latsi, &
-               &                             ixposi, iyposi, iproci )
+            CALL obs_grd_bruteforce( jpi, jpj, jpiglo, jpjglo,  &
+               &                     nldi, nlei,nldj,  nlej,    &
+               &                     nproc, jpnij,              &
+               &                     glamt, gphit, tmask,       &
+               &                     nlons*nlats, lonsi, latsi, &
+               &                     ixposi, iyposi, iproci )
             
             ! minimise file size by removing regions with no data from xypos file
@@ -873,5 +873,5 @@
                & ixpos(nlons,nlats),   &
                & iypos(nlons,nlats),   &
-               & iproc(nlons,nlats)    &
+               & iprocn(nlons,nlats)    &
                & )
 
@@ -880,5 +880,5 @@
             ixpos(:,:) = ixposi(jimin:jimax,jjmin:jjmax)
             iypos(:,:) = iyposi(jimin:jimax,jjmin:jjmax)
-            iproc(:,:) = iproci(jimin:jimax,jjmin:jjmax)
+            iprocn(:,:) = iproci(jimin:jimax,jjmin:jjmax)
 
             DEALLOCATE(lonsi,latsi,ixposi,iyposi,iproci)
@@ -1169,5 +1169,5 @@
 
       IF (ln_grid_search_lookup) THEN
-         DEALLOCATE( lons, lats, ixpos, iypos, iproc )
+         DEALLOCATE( lons, lats, ixpos, iypos, iprocn )
       ENDIF
       
Index: branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_grid_search_bruteforce.h90
===================================================================
--- branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_grid_search_bruteforce.h90	(revision 2357)
+++ 	(revision )
@@ -1,355 +1,0 @@
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
-   SUBROUTINE obs_grid_search_bruteforce( kpi, kpj, kpiglo, kpjglo,       &
-      &                                   kldi, klei, kldj, klej,         &
-      &                                   kmyproc, ktotproc,              &
-      &                                   pglam, pgphi, pmask,            &
-      &                                   kobs, plam, pphi, kobsi, kobsj, &
-      &                                   kproc)
-      !!----------------------------------------------------------------------
-      !!                ***  ROUTINE obs_grid_search_bruteforce ***
-      !!
-      !! ** Purpose : Search gridpoints to find the grid box containing
-      !!              the observations
-      !!
-      !! ** Method  : Call to linquad
-      !!
-      !! ** Action  : Return kproc holding the observation and kiobsi,kobsj
-      !!              valid on kproc=kmyproc processor only.
-      !!   
-      !! History :
-      !!        !  2001-11  (N. Daget, A. Weaver)
-      !!        !  2006-03  (A. Weaver) NEMOVAR migration.
-      !!        !  2006-05  (K. Mogensen) Moved to to separate routine.
-      !!        !  2007-10  (A. Vidard) Bug fix in wrap around checks; cleanup
-      !!----------------------------------------------------------------------
-
-      !! * Arguments
-      INTEGER, INTENT(IN) :: kpi                ! Number of local longitudes
-      INTEGER, INTENT(IN) :: kpj                ! Number of local latitudes
-      INTEGER, INTENT(IN) :: kpiglo             ! Number of global longitudes
-      INTEGER, INTENT(IN) :: kpjglo             ! Number of global latitudes
-      INTEGER, INTENT(IN) :: kldi               ! Start of inner domain in i
-      INTEGER, INTENT(IN) :: klei               ! End of inner domain in i
-      INTEGER, INTENT(IN) :: kldj               ! Start of inner domain in j
-      INTEGER, INTENT(IN) :: klej               ! End of inner domain in j
-      INTEGER, INTENT(IN) :: kmyproc            ! Processor number for MPP
-      INTEGER, INTENT(IN) :: ktotproc           ! Total number of processors
-      REAL(KIND=wp), DIMENSION(kpi,kpj), INTENT(IN) :: &
-         & pglam,   &               ! Grid point longitude
-         & pgphi,   &               ! Grid point latitude
-         & pmask                    ! Grid point mask
-      INTEGER,INTENT(IN) :: kobs                ! Size of the observation arrays
-      REAL(KIND=wp), DIMENSION(kobs), INTENT(IN) :: &
-         & plam, &                  ! Longitude of obsrvations 
-         & pphi                     ! Latitude of observations
-      INTEGER, DIMENSION(kobs), INTENT(OUT) :: &
-         & kobsi, &                 ! I-index of observations 
-         & kobsj, &                 ! J-index of observations 
-         & kproc                    ! Processor number of observations
-  
-      !! * Local declarations
-      REAL(wp), DIMENSION(:), ALLOCATABLE :: &
-         & zplam, zpphi
-      REAL(wp) :: zlammax
-      REAL(wp) :: zlam
-      INTEGER :: ji
-      INTEGER :: jj
-      INTEGER :: jk
-      INTEGER :: jo
-      INTEGER :: jlon
-      INTEGER :: jlat
-      INTEGER :: joffset
-      INTEGER :: jostride
-      REAL(KIND=wp), DIMENSION(:,:), ALLOCATABLE :: &
-         & zlamg, &
-         & zphig, &
-         & zmskg, &
-         & zphitmax,&
-         & zphitmin,&
-         & zlamtmax,&
-         & zlamtmin
-      LOGICAL, DIMENSION(:,:), ALLOCATABLE :: &
-         & llinvalidcell
-      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: &
-         & zlamtm,  &
-         & zphitm
-
-      !-----------------------------------------------------------------------
-      ! Define grid setup for grid search
-      !-----------------------------------------------------------------------
-      IF (ln_grid_global) THEN
-         jlon     = kpiglo
-         jlat     = kpjglo
-         joffset  = kmyproc
-         jostride = ktotproc
-      ELSE
-         jlon     = kpi
-         jlat     = kpj
-         joffset  = 0
-         jostride = 1
-      ENDIF
-      !-----------------------------------------------------------------------
-      ! Set up data for grid search
-      !-----------------------------------------------------------------------
-      ALLOCATE( &
-         & zlamg(jlon,jlat),             &
-         & zphig(jlon,jlat),             &
-         & zmskg(jlon,jlat),             &
-         & zphitmax(jlon-1,jlat-1),      &
-         & zphitmin(jlon-1,jlat-1),      &
-         & zlamtmax(jlon-1,jlat-1),      &
-         & zlamtmin(jlon-1,jlat-1),      &
-         & llinvalidcell(jlon-1,jlat-1), &
-         & zlamtm(4,jlon-1,jlat-1),      &
-         & zphitm(4,jlon-1,jlat-1)       &
-         & )
-      !-----------------------------------------------------------------------
-      ! Copy data to local arrays
-      !-----------------------------------------------------------------------
-      IF (ln_grid_global) THEN
-         zlamg(:,:) = -1.e+10
-         zphig(:,:) = -1.e+10
-         zmskg(:,:) = -1.e+10
-         DO jj = kldj, klej
-            DO ji = kldi, klei
-               zlamg(mig(ji),mjg(jj)) = pglam(ji,jj)
-               zphig(mig(ji),mjg(jj)) = pgphi(ji,jj)
-               zmskg(mig(ji),mjg(jj)) = pmask(ji,jj)
-            END DO
-         END DO
-         CALL mpp_global_max( zlamg )
-         CALL mpp_global_max( zphig )
-         CALL mpp_global_max( zmskg )
-      ELSE
-         DO jj = 1, jlat
-            DO ji = 1, jlon
-               zlamg(ji,jj) = pglam(ji,jj)
-               zphig(ji,jj) = pgphi(ji,jj)
-               zmskg(ji,jj) = pmask(ji,jj)
-            END DO
-         END DO
-      ENDIF
-      !-----------------------------------------------------------------------
-      ! Copy longitudes and latitudes
-      !-----------------------------------------------------------------------
-      ALLOCATE( &
-         & zplam(kobs), &
-         & zpphi(kobs)  &
-         & )
-      DO jo = 1, kobs
-         zplam(jo) = plam(jo)
-         zpphi(jo) = pphi(jo)
-      END DO
-      !-----------------------------------------------------------------------
-      ! Set default values for output
-      !-----------------------------------------------------------------------
-      kproc(:) = -1
-      kobsi(:) = -1
-      kobsj(:) = -1
-      !-----------------------------------------------------------------------
-      ! Copy grid positions to temporary arrays and renormalize to 0 to 360.
-      !-----------------------------------------------------------------------
-      DO jj = 1, jlat-1
-         DO ji = 1, jlon-1
-            zlamtm(1,ji,jj) = zlamg(ji  ,jj  )
-            zphitm(1,ji,jj) = zphig(ji  ,jj  )
-            zlamtm(2,ji,jj) = zlamg(ji+1,jj  )
-            zphitm(2,ji,jj) = zphig(ji+1,jj  )
-            zlamtm(3,ji,jj) = zlamg(ji+1,jj+1)
-            zphitm(3,ji,jj) = zphig(ji+1,jj+1)
-            zlamtm(4,ji,jj) = zlamg(ji  ,jj+1)
-            zphitm(4,ji,jj) = zphig(ji  ,jj+1)
-         END DO
-      END DO
-      WHERE ( zlamtm(:,:,:) < 0.0_wp )
-         zlamtm(:,:,:) = zlamtm(:,:,:) + 360.0_wp
-      END WHERE
-      WHERE ( zlamtm(:,:,:) > 360.0_wp )
-         zlamtm(:,:,:) = zlamtm(:,:,:) - 360.0_wp
-      END WHERE
-      !-----------------------------------------------------------------------
-      ! Handle case of the wraparound; beware, not working with orca180
-      !-----------------------------------------------------------------------
-      DO jj = 1, jlat-1
-         DO ji = 1, jlon-1
-            zlammax = MAXVAL( zlamtm(:,ji,jj) )
-            WHERE (zlammax - zlamtm(:, ji, jj) > 180 ) &
-               & zlamtm(:,ji,jj) = zlamtm(:,ji,jj) + 360._wp
-            zphitmax(ji,jj) = MAXVAL(zphitm(:,ji,jj))
-            zphitmin(ji,jj) = MINVAL(zphitm(:,ji,jj))
-            zlamtmax(ji,jj) = MAXVAL(zlamtm(:,ji,jj))
-            zlamtmin(ji,jj) = MINVAL(zlamtm(:,ji,jj))
-         END DO
-      END DO
-      !-----------------------------------------------------------------------
-      ! Search for boxes with only land points mark them invalid
-      !-----------------------------------------------------------------------
-      llinvalidcell(:,:) = .FALSE.
-      DO jj = 1, jlat-1
-         DO ji = 1, jlon-1
-            llinvalidcell(ji,jj) =               &
-               & zmskg(ji  ,jj  ) == 0.0_wp .AND. &
-               & zmskg(ji+1,jj  ) == 0.0_wp .AND. &
-               & zmskg(ji+1,jj+1) == 0.0_wp .AND. &
-               & zmskg(ji  ,jj+1) == 0.0_wp
-         END DO
-      END DO
-
-      !------------------------------------------------------------------------
-      ! Master loop for grid search
-      !------------------------------------------------------------------------
-
-      DO jo = 1+joffset, kobs, jostride
-
-         !---------------------------------------------------------------------
-         ! Ensure that all observation longtiudes are between 0 and 360
-         !---------------------------------------------------------------------
-
-         IF ( zplam(jo) <   0.0_wp ) zplam(jo) = zplam(jo) + 360.0_wp
-         IF ( zplam(jo) > 360.0_wp ) zplam(jo) = zplam(jo) - 360.0_wp
-
-         !---------------------------------------------------------------------
-         ! Find observations which are on within 1e-6 of a grid point
-         !---------------------------------------------------------------------
-
-         gridloop: DO jj = 1, jlat-1
-            DO ji = 1, jlon-1
-               IF ( ABS( zphig(ji,jj) - zpphi(jo) ) < 1e-6 )  THEN
-                  zlam = zlamg(ji,jj)
-                  IF ( zlam <   0.0_wp ) zlam = zlam + 360.0_wp
-                  IF ( zlam > 360.0_wp ) zlam = zlam - 360.0_wp
-                  IF ( ABS( zlam - zplam(jo) ) < 1e-6 ) THEN
-                     IF ( llinvalidcell(ji,jj) ) THEN
-                        kproc(jo) = kmyproc + 1000000
-                        kobsi(jo) = ji + 1
-                        kobsj(jo) = jj + 1
-                        CYCLE
-                     ELSE
-                        kproc(jo) = kmyproc
-                        kobsi(jo) = ji + 1
-                        kobsj(jo) = jj + 1
-                        EXIT gridloop
-                     ENDIF
-                  ENDIF
-               ENDIF
-            END DO
-         END DO gridloop
-         
-         !---------------------------------------------------------------------
-         ! Ensure that all observation longtiudes are between -180 and 180
-         !---------------------------------------------------------------------
-
-         IF ( zplam(jo) > 180 ) zplam(jo) = zplam(jo) - 360.0_wp
-
-         !---------------------------------------------------------------------
-         ! Do coordinate search using brute force.
-         ! - For land points kproc is set to number of the processor + 1000000
-         !   and we continue the search.
-         ! - For ocean points kproc is set to the number of the processor 
-         !   and we stop the search.
-         !---------------------------------------------------------------------
-
-         IF ( kproc(jo) == -1 ) THEN
-
-            ! Normal case
-            gridpoints : DO jj = 1, jlat-1
-               DO ji = 1, jlon-1
-                  
-                  IF ( ( zplam(jo) > zlamtmax(ji,jj) ) .OR. &
-                     & ( zplam(jo) < zlamtmin(ji,jj) ) ) CYCLE
-                  
-                  IF ( ABS( zpphi(jo) ) < 85 ) THEN
-                     IF ( ( zpphi(jo) > zphitmax(ji,jj) ) .OR. &
-                        & ( zpphi(jo) < zphitmin(ji,jj) ) ) CYCLE
-                  ENDIF
-                  
-                  IF ( linquad( zplam(jo), zpphi(jo), &
-                     &          zlamtm(:,ji,jj), zphitm(:,ji,jj) ) ) THEN
-                     IF ( llinvalidcell(ji,jj) ) THEN
-                        kproc(jo) = kmyproc + 1000000
-                        kobsi(jo) = ji + 1
-                        kobsj(jo) = jj + 1
-                        CYCLE
-                     ELSE
-                        kproc(jo) = kmyproc
-                        kobsi(jo) = ji + 1
-                        kobsj(jo) = jj + 1
-                        EXIT gridpoints
-                     ENDIF
-                  ENDIF
-                  
-               END DO
-            END DO gridpoints
-
-         ENDIF
-
-         ! In case of failure retry for obs. longtiude + 360.
-         IF ( kproc(jo) == -1 ) THEN
-            gridpoints_greenwich : DO jj = 1, jlat-1
-               DO ji = 1, jlon-1
-
-                  IF ( ( zplam(jo)+360.0_wp > zlamtmax(ji,jj) ) .OR. &
-                     & ( zplam(jo)+360.0_wp < zlamtmin(ji,jj) ) ) CYCLE
-
-                  IF ( ABS( zpphi(jo) ) < 85 ) THEN
-                     IF ( ( zpphi(jo) > zphitmax(ji,jj) ) .OR. &
-                        & ( zpphi(jo) < zphitmin(ji,jj) ) ) CYCLE
-                  ENDIF
-
-                  IF ( linquad( zplam(jo)+360.0_wp, zpphi(jo), &
-                     &          zlamtm(:,ji,jj), zphitm(:,ji,jj) ) ) THEN
-                     IF ( llinvalidcell(ji,jj) ) THEN
-                        kproc(jo) = kmyproc + 1000000
-                        kobsi(jo) = ji + 1
-                        kobsj(jo) = jj + 1
-                        CYCLE
-                     ELSE
-                        kproc(jo) = kmyproc
-                        kobsi(jo) = ji + 1
-                        kobsj(jo) = jj + 1
-                        EXIT gridpoints_greenwich
-                     ENDIF
-                  ENDIF
-
-               END DO
-            END DO gridpoints_greenwich
-
-         ENDIF
-      END DO
-
-      !----------------------------------------------------------------------
-      ! Synchronize kproc on all processors
-      !----------------------------------------------------------------------
-      IF ( ln_grid_global ) THEN
-         CALL obs_mpp_max_integer( kproc, kobs )
-         CALL obs_mpp_max_integer( kobsi, kobs )
-         CALL obs_mpp_max_integer( kobsj, kobs )
-      ELSE
-         CALL obs_mpp_find_obs_proc( kproc, kobsi, kobsj, kobs )
-      ENDIF
-
-      WHERE( kproc(:) >= 1000000 )
-         kproc(:) = kproc(:) - 1000000
-      END WHERE
-
-      DEALLOCATE( &
-         & zlamg,         &
-         & zphig,         &
-         & zmskg,         &
-         & zphitmax,      &
-         & zphitmin,      &
-         & zlamtmax,      &
-         & zlamtmin,      &
-         & llinvalidcell, &
-         & zlamtm,        &
-         & zphitm,        &
-         & zplam,         &
-         & zpphi          &
-         & )
-
-   END SUBROUTINE obs_grid_search_bruteforce
Index: branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_profiles.F90
===================================================================
--- branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_profiles.F90	(revision 2357)
+++ branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_profiles.F90	(revision 2358)
@@ -29,11 +29,15 @@
    INTEGER :: nprofvars                    ! Total number of variables for profiles
    INTEGER :: nprofextr                    ! Extra fields for each variable
+!$AGRIF_DO_NOT_TREAT
    TYPE(obs_prof), POINTER ::  profdata(:) ! Initial profile data
    TYPE(obs_prof), POINTER ::  prodatqc(:) ! Profile data after quality control
+!$AGRIF_END_DO_NOT_TREAT
 
    INTEGER :: nvelosets                     ! Total number of velocity profile data sets
    INTEGER :: nvelovars                     ! Total number of variables for profiles
    INTEGER :: nveloextr                     ! Extra fields for each variable
+!$AGRIF_DO_NOT_TREAT
    TYPE(obs_prof), POINTER ::  velodata(:)  ! Initial velocity profile data
    TYPE(obs_prof), POINTER ::  veldatqc(:)  ! Velocity profile data after quality control
+!$AGRIF_END_DO_NOT_TREAT
 END MODULE obs_profiles
Index: branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_seaice.F90
===================================================================
--- branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_seaice.F90	(revision 2357)
+++ branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_seaice.F90	(revision 2358)
@@ -29,6 +29,8 @@
                                                      ! variables
    INTEGER :: nseaicesets                               ! Number of seaicedata sets
+!$AGRIF_DO_NOT_TREAT
    TYPE(obs_surf), POINTER, DIMENSION(:) :: seaicedata  ! Initial sea ice data
    TYPE(obs_surf), POINTER, DIMENSION(:) :: seaicedatqc ! Sea ice data after quality control
+!$AGRIF_END_DO_NOT_TREAT
 
 END MODULE obs_seaice
Index: branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_sla.F90
===================================================================
--- branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_sla.F90	(revision 2357)
+++ branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_sla.F90	(revision 2358)
@@ -28,6 +28,8 @@
                                                      ! variables
    INTEGER :: nslasets                               ! Number of sladata sets                                               
+!$AGRIF_DO_NOT_TREAT
    TYPE(obs_surf), POINTER, DIMENSION(:) :: sladata  ! Initial SLA data
    TYPE(obs_surf), POINTER, DIMENSION(:) :: sladatqc ! SLA data after quality control
+!$AGRIF_END_DO_NOT_TREAT
 
 END MODULE obs_sla
Index: branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_sst.F90
===================================================================
--- branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_sst.F90	(revision 2357)
+++ branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_sst.F90	(revision 2358)
@@ -29,6 +29,8 @@
                                                      ! variables
    INTEGER :: nsstsets                               ! Number of sstdata sets
+!$AGRIF_DO_NOT_TREAT
    TYPE(obs_surf), POINTER, DIMENSION(:) :: sstdata  ! Initial SST data
    TYPE(obs_surf), POINTER, DIMENSION(:) :: sstdatqc ! SST data after quality control
+!$AGRIF_END_DO_NOT_TREAT
 
 END MODULE obs_sst
Index: branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_types.F90
===================================================================
--- branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_types.F90	(revision 2357)
+++ branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_types.F90	(revision 2358)
@@ -36,5 +36,5 @@
 
    INTEGER, PUBLIC, PARAMETER :: ntyp1770 = 1023
-   CHARACTER(LEN=4), PUBLIC, DIMENSION(0:ntyp1770) :: cwmotyp1770
+!RBbug useless ?   CHARACTER(LEN=4), PUBLIC, DIMENSION(0:ntyp1770) :: cwmotyp1770
    CHARACTER(LEN=80), PUBLIC, DIMENSION(0:ntyp1770) :: cwmonam1770
    CHARACTER(LEN=3), PUBLIC, DIMENSION(0:ntyp1770) :: ctypshort
@@ -119,9 +119,9 @@
          ctypshort(ji) = 'XBT'
 
-         IF ( ji < 1000 ) THEN
-            WRITE(cwmotyp1770(ji),'(1X,I3.3)') ji
-         ELSE
-            WRITE(cwmotyp1770(ji),'(I4.4)') ji
-         ENDIF
+!         IF ( ji < 1000 ) THEN
+!            WRITE(cwmotyp1770(ji),'(1X,I3.3)') ji
+!         ELSE
+!            WRITE(cwmotyp1770(ji),'(I4.4)') ji
+!         ENDIF
 
       END DO
Index: branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90
===================================================================
--- branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90	(revision 2357)
+++ branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90	(revision 2358)
@@ -576,5 +576,5 @@
             ELSE                      ;   CALL iom_get( sdjf%num, jpdom_data, sdjf%clvar, sdjf%fnow(:,:,1  ), sdjf%nrec_a(1) )
             ENDIF
-         CASE(jpk)
+         CASE DEFAULT
             IF( sdjf%ln_tint ) THEN   ;   CALL iom_get( sdjf%num, jpdom_data, sdjf%clvar, sdjf%fdta(:,:,:,2), sdjf%nrec_a(1) )
             ELSE                      ;   CALL iom_get( sdjf%num, jpdom_data, sdjf%clvar, sdjf%fnow(:,:,:  ), sdjf%nrec_a(1) )
@@ -995,5 +995,5 @@
       CASE(1)
            CALL iom_get( num, jpdom_unknown, clvar, ref_wgts(kw)%fly_dta(jpi1:jpi2,jpj1:jpj2,1), nrec, rec1, recn)
-      CASE(jpk)  
+      CASE DEFAULT
            CALL iom_get( num, jpdom_unknown, clvar, ref_wgts(kw)%fly_dta(jpi1:jpi2,jpj1:jpj2,:), nrec, rec1, recn)
       END SELECT 
@@ -1042,5 +1042,5 @@
               CASE(1)
                    CALL iom_get( num, jpdom_unknown, clvar, ref_wgts(kw)%col(:,jpj1:jpj2,1), nrec, rec1, recn)
-              CASE(jpk)         
+              CASE DEFAULT
                    CALL iom_get( num, jpdom_unknown, clvar, ref_wgts(kw)%col(:,jpj1:jpj2,:), nrec, rec1, recn)
               END SELECT      
@@ -1052,5 +1052,5 @@
               CASE(1)
                    CALL iom_get( num, jpdom_unknown, clvar, ref_wgts(kw)%col(:,jpj1:jpj2,1), nrec, rec1, recn)
-              CASE(jpk)
+              CASE DEFAULT
                    CALL iom_get( num, jpdom_unknown, clvar, ref_wgts(kw)%col(:,jpj1:jpj2,:), nrec, rec1, recn)
               END SELECT
