Index: /branches/2014/dev_r4621_NOC4_BDY_VERT_INTERP/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90
===================================================================
--- /branches/2014/dev_r4621_NOC4_BDY_VERT_INTERP/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90	(revision 5890)
+++ /branches/2014/dev_r4621_NOC4_BDY_VERT_INTERP/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90	(revision 5891)
@@ -789,4 +789,8 @@
 
       IF( PRESENT(jpk_bdy) .AND. jpk_bdy>0 ) THEN       ! boundary data not on model grid: vertical interpolation
+         CALL iom_getatt(num, '_FillValue', fv, cdvar=clvar )
+         dta_read(:,:,:) = -ABS(fv)
+         dta_read_z(:,:,:) = 0._wp
+         dta_read_dz(:,:,:) = 0._wp
          CALL iom_get ( num, jpdom_unknown, clvar, dta_read(1:ilendta,1:ipj,1:jpk_bdy), nrec )
          SELECT CASE( igrd )                  
@@ -801,5 +805,4 @@
                CALL iom_get ( num, jpdom_unknown, 'e3v', dta_read_dz(1:ilendta,1:ipj,1:jpk_bdy) )
          END SELECT
-         CALL iom_getatt(num, '_FillValue', fv, cdvar=clvar )
 
 #if defined key_bdy
@@ -868,5 +871,9 @@
       
       fv_alt = -ABS(fv)  ! set _FillValue < 0 as we make use of MAXVAL and MAXLOC later
-      
+      DO ib = 1, ipi
+            zij = idx_bdy(ibdy)%nbi(ib,igrd)
+            zjj = idx_bdy(ibdy)%nbj(ib,igrd)
+         IF(narea==2) WRITE(*,*) 'MAPI', ib, igrd, map%ptr(ib), narea-1, zij, zjj
+      ENDDO
       !
       IF ( map%ll_unstruc ) THEN                            ! unstructured open boundary data file
@@ -885,4 +892,26 @@
             zjj = idx_bdy(ibdy)%nbj(ib,igrd)
             zh  = SUM(dta_read_dz(map%ptr(ib),1,:) )
+            ! Warnings to flag differences in the input and model topgraphy - is this useful/necessary?
+            SELECT CASE( igrd )                         
+               CASE(1)
+                  IF( ABS( (zh - ht_0(zij,zjj)) / ht_0(zij,zjj)) * tmask(zij,zjj,1) > 0.01_wp ) THEN
+                     WRITE(ibstr,"(I10.10)") map%ptr(ib) 
+                     CALL ctl_warn('fld_bdy_interp: T depths differ between grids at BDY point '//TRIM(ibstr)//' by more than 1%')
+                 !   IF(lwp) WRITE(*,*) 'DEPTHT', zh, sum(e3t_0(zij,zjj,:), mask=tmask(zij,zjj,:)==1),  ht_0(zij,zjj), map%ptr(ib), ib, zij, zjj
+                  ENDIF
+               CASE(2)
+                  IF( ABS( (zh - hu_0(zij,zjj)) / hu_0(zij,zjj)) * umask(zij,zjj,1) > 0.01_wp ) THEN
+                     WRITE(ibstr,"(I10.10)") map%ptr(ib) 
+                     CALL ctl_warn('fld_bdy_interp: U depths differ between grids at BDY point '//TRIM(ibstr)//' by more than 1%')
+                     IF(lwp) WRITE(*,*) 'DEPTHU', zh, sum(e3u_0(zij,zjj,:), mask=umask(zij,zjj,:)==1),  sum(umask(zij,zjj,:)), &
+                       &                hu_0(zij,zjj), map%ptr(ib), ib, zij, zjj, narea-1  , &
+                        &                dta_read(map%ptr(ib),1,:)
+                  ENDIF
+               CASE(3)
+                  IF( ABS( (zh - hv_0(zij,zjj)) / hv_0(zij,zjj)) * vmask(zij,zjj,1) > 0.01_wp ) THEN
+                     WRITE(ibstr,"(I10.10)") map%ptr(ib) 
+                     CALL ctl_warn('fld_bdy_interp: V depths differ between grids at BDY point '//TRIM(ibstr)//' by more than 1%')
+                  ENDIF
+            END SELECT
             DO ik = 1, ipk                      
                SELECT CASE( igrd )                       
@@ -988,4 +1017,23 @@
             zjj = idx_bdy(ibdy)%nbj(ib,igrd)
             zh  = SUM(dta_read_dz(ji,jj,:) )
+            ! Warnings to flag differences in the input and model topgraphy - is this useful/necessary?
+            SELECT CASE( igrd )                         
+               CASE(1)
+                  IF( ABS( (zh - ht_0(zij,zjj)) / ht_0(zij,zjj)) * tmask(zij,zjj,1) > 0.01_wp ) THEN
+                     WRITE(ibstr,"(I10.10)") map%ptr(ib) 
+                     CALL ctl_warn('fld_bdy_interp: T depths differ between grids at BDY point '//TRIM(ibstr)//' by more than 1%')
+                 !   IF(lwp) WRITE(*,*) 'DEPTHT', zh, sum(e3t_0(zij,zjj,:), mask=tmask(zij,zjj,:)==1),  ht_0(zij,zjj), map%ptr(ib), ib, zij, zjj
+                  ENDIF
+               CASE(2)
+                  IF( ABS( (zh - hu_0(zij,zjj)) / hu_0(zij,zjj)) * umask(zij,zjj,1) > 0.01_wp ) THEN
+                     WRITE(ibstr,"(I10.10)") map%ptr(ib) 
+                     CALL ctl_warn('fld_bdy_interp: U depths differ between grids at BDY point '//TRIM(ibstr)//' by more than 1%')
+                  ENDIF
+               CASE(3)
+                  IF( ABS( (zh - hv_0(zij,zjj)) / hv_0(zij,zjj)) * vmask(zij,zjj,1) > 0.01_wp ) THEN
+                     WRITE(ibstr,"(I10.10)") map%ptr(ib) 
+                     CALL ctl_warn('fld_bdy_interp: V depths differ between grids at BDY point '//TRIM(ibstr)//' by more than 1%')
+                  ENDIF
+            END SELECT
             DO ik = 1, ipk                      
                SELECT CASE( igrd )                          ! coded for sco - need zco and zps option using min
@@ -1024,50 +1072,50 @@
 
          IF(igrd == 2) THEN                                 ! do we need to adjust the transport term?
-            jj=1+floor(REAL(map%ptr(ib)-1)/REAL(ilendta))
-            ji=map%ptr(ib)-(jj-1)*ilendta
-            zij = idx_bdy(ibdy)%nbi(ib,igrd)
-            zjj = idx_bdy(ibdy)%nbj(ib,igrd)
             DO ib = 1, ipi
-              zh = SUM(dta_read_dz(ji,jj,:) )
-              ztrans = 0._wp
-              ztrans_new = 0._wp
-              DO ik = 1, jpk_bdy                            ! calculate transport on input grid
+               jj=1+floor(REAL(map%ptr(ib)-1)/REAL(ilendta))
+               ji=map%ptr(ib)-(jj-1)*ilendta
+               zij = idx_bdy(ibdy)%nbi(ib,igrd)
+               zjj = idx_bdy(ibdy)%nbj(ib,igrd)
+               zh = SUM(dta_read_dz(ji,jj,:) )
+               ztrans = 0._wp
+               ztrans_new = 0._wp
+               DO ik = 1, jpk_bdy                            ! calculate transport on input grid
                   ztrans = ztrans + dta_read(ji,jj,ik) * dta_read_dz(ji,jj,ik)
-              ENDDO
-              DO ik = 1, ipk                                ! calculate transport on model grid
+               ENDDO
+               DO ik = 1, ipk                                ! calculate transport on model grid
                   ztrans_new = ztrans_new + dta(ib,1,ik) * e3u_0(zij,zjj,ik) * umask(zij,zjj,ik)
-              ENDDO
-              DO ik = 1, ipk                                ! make transport correction
-                 IF(fvl) THEN ! bdy data are total velocity so adjust bt transport term to match input data
-                    dta(ib,1,ik) = ( dta(ib,1,ik) + ( ztrans - ztrans_new ) * hur(zij,zjj) ) * umask(zij,zjj,ik)
-                 ELSE ! we're just dealing with bc velocity so bt transport term should sum to zero
-                    dta(ib,1,ik) = ( dta(ib,1,ik) + ( 0._wp  - ztrans_new ) * hur(zij,zjj) ) * umask(zij,zjj,ik)
-                 ENDIF
-              ENDDO
+               ENDDO
+               DO ik = 1, ipk                                ! make transport correction
+                  IF(fvl) THEN ! bdy data are total velocity so adjust bt transport term to match input data
+                     dta(ib,1,ik) = ( dta(ib,1,ik) + ( ztrans - ztrans_new ) * hur(zij,zjj) ) * umask(zij,zjj,ik)
+                  ELSE ! we're just dealing with bc velocity so bt transport term should sum to zero
+                     dta(ib,1,ik) = ( dta(ib,1,ik) + ( 0._wp  - ztrans_new ) * hur(zij,zjj) ) * umask(zij,zjj,ik)
+                  ENDIF
+               ENDDO
             ENDDO
          ENDIF
 
          IF(igrd == 3) THEN                                 ! do we need to adjust the transport term?
-           DO ib = 1, ipi
-              jj  = 1+floor(REAL(map%ptr(ib)-1)/REAL(ilendta))
-              ji  = map%ptr(ib)-(jj-1)*ilendta
-              zij = idx_bdy(ibdy)%nbi(ib,igrd)
-              zjj = idx_bdy(ibdy)%nbj(ib,igrd)
-              zh  = SUM(dta_read_dz(ji,jj,:) )
-              ztrans = 0._wp
-              ztrans_new = 0._wp
-              DO ik = 1, jpk_bdy                            ! calculate transport on input grid
+            DO ib = 1, ipi
+               jj  = 1+floor(REAL(map%ptr(ib)-1)/REAL(ilendta))
+               ji  = map%ptr(ib)-(jj-1)*ilendta
+               zij = idx_bdy(ibdy)%nbi(ib,igrd)
+               zjj = idx_bdy(ibdy)%nbj(ib,igrd)
+               zh  = SUM(dta_read_dz(ji,jj,:) )
+               ztrans = 0._wp
+               ztrans_new = 0._wp
+               DO ik = 1, jpk_bdy                            ! calculate transport on input grid
                   ztrans     = ztrans     + dta_read(ji,jj,ik) * dta_read_dz(ji,jj,ik)
-              ENDDO
-              DO ik = 1, ipk                                ! calculate transport on model grid
+               ENDDO
+               DO ik = 1, ipk                                ! calculate transport on model grid
                   ztrans_new = ztrans_new + dta(ib,1,ik) * e3v_0(zij,zjj,ik) * vmask(zij,zjj,ik)
-              ENDDO
-              DO ik = 1, ipk                                ! make transport correction
-                 IF(fvl) THEN ! bdy data are total velocity so adjust bt transport term to match input data
-                    dta(ib,1,ik) = ( dta(ib,1,ik) + ( ztrans - ztrans_new ) * hvr(zij,zjj) ) * vmask(zij,zjj,ik)
-                 ELSE ! we're just dealing with bc velocity so bt transport term should sum to zero
-                    dta(ib,1,ik) = ( dta(ib,1,ik) + ( 0._wp  - ztrans_new ) * hvr(zij,zjj) ) * vmask(zij,zjj,ik)
-                 ENDIF
-              ENDDO
+               ENDDO
+               DO ik = 1, ipk                                ! make transport correction
+                  IF(fvl) THEN ! bdy data are total velocity so adjust bt transport term to match input data
+                     dta(ib,1,ik) = ( dta(ib,1,ik) + ( ztrans - ztrans_new ) * hvr(zij,zjj) ) * vmask(zij,zjj,ik)
+                  ELSE ! we're just dealing with bc velocity so bt transport term should sum to zero
+                     dta(ib,1,ik) = ( dta(ib,1,ik) + ( 0._wp  - ztrans_new ) * hvr(zij,zjj) ) * vmask(zij,zjj,ik)
+                  ENDIF
+               ENDDO
             ENDDO
          ENDIF
