Index: NEMO/branches/UKMO/NEMO_4.0_GC_couple_pkg/src/OCE/BDY/bdy_oce.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0_GC_couple_pkg/src/OCE/BDY/bdy_oce.F90	(revision 11104)
+++ NEMO/branches/UKMO/NEMO_4.0_GC_couple_pkg/src/OCE/BDY/bdy_oce.F90	(revision 11303)
@@ -85,5 +85,5 @@
    !
    INTEGER                    ::   nb_bdy                   !: number of open boundary sets
-   INTEGER                    ::   nb_jpk_bdy               !: number of levels in the bdy data (set < 0 if consistent with planned run)
+   INTEGER, DIMENSION(jp_bdy) ::   nb_jpk_bdy               !: number of levels in the bdy data (set < 0 if consistent with planned run)
    INTEGER, DIMENSION(jp_bdy) ::   nn_rimwidth              !: boundary rim width for Flow Relaxation Scheme
    INTEGER                    ::   nn_volctl                !: = 0 the total volume will have the variability of the surface Flux E-P 
Index: NEMO/branches/UKMO/NEMO_4.0_GC_couple_pkg/src/OCE/BDY/bdydta.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0_GC_couple_pkg/src/OCE/BDY/bdydta.F90	(revision 11104)
+++ NEMO/branches/UKMO/NEMO_4.0_GC_couple_pkg/src/OCE/BDY/bdydta.F90	(revision 11303)
@@ -243,5 +243,5 @@
                         IF( ln_full_vel_array(jbdy) ) THEN
                            CALL fld_read( kt=kt, kn_fsbc=1, sd=bf(jstart:jend), map=nbmap_ptr(jstart:jend),  &
-                                     & kit=jit, kt_offset=time_offset , jpk_bdy=nb_jpk_bdy,   &
+                                     & kit=jit, kt_offset=time_offset , jpk_bdy=nb_jpk_bdy(jbdy),   &
                                      & fvl=ln_full_vel_array(jbdy)  )
                         ELSE
@@ -313,5 +313,5 @@
                      jend = jstart + dta%nread(1) - 1
                      CALL fld_read( kt=kt, kn_fsbc=1, sd=bf(jstart:jend), &
-                                  & map=nbmap_ptr(jstart:jend), kt_offset=time_offset, jpk_bdy=nb_jpk_bdy,   &
+                                  & map=nbmap_ptr(jstart:jend), kt_offset=time_offset, jpk_bdy=nb_jpk_bdy(jbdy),   &
                                   & fvl=ln_full_vel_array(jbdy) )
                   ENDIF
@@ -446,5 +446,5 @@
       NAMELIST/nambdy_dta/ bn_a_i, bn_h_i, bn_h_s
 #endif
-      NAMELIST/nambdy_dta/ ln_full_vel, nb_jpk_bdy
+      NAMELIST/nambdy_dta/ ln_full_vel
       !!---------------------------------------------------------------------------
       !
@@ -508,9 +508,9 @@
       ! Read namelists
       ! --------------
-      REWIND(numnam_ref)
       REWIND(numnam_cfg)
       jfld = 0 
       DO jbdy = 1, nb_bdy         
          IF( nn_dta(jbdy) == 1 ) THEN
+            REWIND(numnam_ref)
             READ  ( numnam_ref, nambdy_dta, IOSTAT = ios, ERR = 901)
 901         IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy_dta in reference namelist', lwp )
Index: NEMO/branches/UKMO/NEMO_4.0_GC_couple_pkg/src/OCE/BDY/bdydyn2d.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0_GC_couple_pkg/src/OCE/BDY/bdydyn2d.F90	(revision 11104)
+++ NEMO/branches/UKMO/NEMO_4.0_GC_couple_pkg/src/OCE/BDY/bdydyn2d.F90	(revision 11303)
@@ -187,5 +187,5 @@
          ! Use characteristics method instead
          zflag = ABS(flagu)
-         zforc = dta%u2d(jb) * (1._wp - z1_2*zflag) + z1_2 * zflag * pua2d(iim1,ij)
+         zforc = dta%u2d(jb) * (1._wp - z1_2*zflag) + z1_2 * zflag * pua2d(ii+NINT(flagu),ij)
          pua2d(ii,ij) = zforc + (1._wp - z1_2*zflag) * zcorr * umask(ii,ij,1) 
       END DO
@@ -205,5 +205,5 @@
          ! Use characteristics method instead
          zflag = ABS(flagv)
-         zforc  = dta%v2d(jb) * (1._wp - z1_2*zflag) + z1_2 * zflag * pva2d(ii,ijm1)
+         zforc  = dta%v2d(jb) * (1._wp - z1_2*zflag) + z1_2 * zflag * pva2d(ii,ij+NINT(flagv))
          pva2d(ii,ij) = zforc + (1._wp - z1_2*zflag) * zcorr * vmask(ii,ij,1)
       END DO
Index: NEMO/branches/UKMO/NEMO_4.0_GC_couple_pkg/src/OCE/BDY/bdyice.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0_GC_couple_pkg/src/OCE/BDY/bdyice.F90	(revision 11104)
+++ NEMO/branches/UKMO/NEMO_4.0_GC_couple_pkg/src/OCE/BDY/bdyice.F90	(revision 11303)
@@ -57,6 +57,7 @@
       INTEGER ::   jbdy   ! BDY set index
       !!----------------------------------------------------------------------
-      !
-      IF( ln_timing )   CALL timing_start('bdy_ice_thd')
+      ! controls
+      IF( ln_timing    )   CALL timing_start('bdy_ice_thd')                                                            ! timing
+      IF( ln_icediachk )   CALL ice_cons_hsm(0,'bdy_ice_thd', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft) ! conservation
       !
       CALL ice_var_glo2eqv
@@ -78,6 +79,8 @@
       CALL ice_var_agg(1)
       !
-      IF( ln_icectl )   CALL ice_prt( kt, iiceprt, jiceprt, 1, ' - ice thermo bdy - ' )
-      IF( ln_timing )   CALL timing_stop('bdy_ice_thd')
+      ! controls
+      IF( ln_icediachk )   CALL ice_cons_hsm(1,'bdy_ice_thd', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft) ! conservation
+      IF( ln_icectl    )   CALL ice_prt     ( kt, iiceprt, jiceprt, 1, ' - ice thermo bdy - ' )                        ! prints
+      IF( ln_timing    )   CALL timing_stop ('bdy_ice_thd')                                                            ! timing
       !
    END SUBROUTINE bdy_ice
@@ -148,8 +151,8 @@
             jpbound = 0   ;   ib = ji   ;   jb = jj
             !
-            IF( u_ice(ji+1,jj  ) < 0. .AND. umask(ji-1,jj  ,1) == 0. )   jpbound = 1 ; ib = ji+1 ; jb = jj
-            IF( u_ice(ji-1,jj  ) > 0. .AND. umask(ji+1,jj  ,1) == 0. )   jpbound = 1 ; ib = ji-1 ; jb = jj
-            IF( v_ice(ji  ,jj+1) < 0. .AND. vmask(ji  ,jj-1,1) == 0. )   jpbound = 1 ; ib = ji   ; jb = jj+1
-            IF( v_ice(ji  ,jj-1) > 0. .AND. vmask(ji  ,jj+1,1) == 0. )   jpbound = 1 ; ib = ji   ; jb = jj-1
+            IF( u_ice(ji  ,jj  ) < 0. .AND. umask(ji-1,jj  ,1) == 0. )   jpbound = 1 ; ib = ji+1
+            IF( u_ice(ji-1,jj  ) > 0. .AND. umask(ji  ,jj  ,1) == 0. )   jpbound = 1 ; ib = ji-1
+            IF( v_ice(ji  ,jj  ) < 0. .AND. vmask(ji  ,jj-1,1) == 0. )   jpbound = 1 ; jb = jj+1
+            IF( v_ice(ji  ,jj-1) > 0. .AND. vmask(ji  ,jj  ,1) == 0. )   jpbound = 1 ; jb = jj-1
             !
             IF( nn_ice_dta(jbdy) == 0 )   jpbound = 0 ; ib = ji ; jb = jj   ! case ice boundaries = initial conditions
@@ -306,5 +309,5 @@
                      ! one of the two zmsk is always 0 (because of zflag)
                      zmsk1 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji+1,jj) ) ) ! 0 if no ice
-                     zmsk2 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji-1,jj) ) ) ! 0 if no ice
+                     zmsk2 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji,jj) ) )   ! 0 if no ice
                      !  
                      ! u_ice = u_ice of the adjacent grid point except if this grid point is ice-free (then do not change u_ice)
@@ -329,5 +332,5 @@
                      ! one of the two zmsk is always 0 (because of zflag)
                      zmsk1 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji,jj+1) ) ) ! 0 if no ice
-                     zmsk2 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji,jj-1) ) ) ! 0 if no ice
+                     zmsk2 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji,jj) ) )   ! 0 if no ice
                      !  
                      ! v_ice = v_ice of the adjacent grid point except if this grid point is ice-free (then do not change v_ice)
Index: NEMO/branches/UKMO/NEMO_4.0_GC_couple_pkg/src/OCE/BDY/bdyini.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0_GC_couple_pkg/src/OCE/BDY/bdyini.F90	(revision 11104)
+++ NEMO/branches/UKMO/NEMO_4.0_GC_couple_pkg/src/OCE/BDY/bdyini.F90	(revision 11303)
@@ -140,5 +140,5 @@
       INTEGER, ALLOCATABLE, DIMENSION(:,:,:)  ::   nbrdta           ! Discrete distance from rim points
       CHARACTER(LEN=1),DIMENSION(jpbgrd)      ::   cgrid
-      INTEGER :: com_east, com_west, com_south, com_north          ! Flags for boundaries sending
+      INTEGER :: com_east, com_west, com_south, com_north, jpk_max  ! Flags for boundaries sending
       INTEGER :: com_east_b, com_west_b, com_south_b, com_north_b  ! Flags for boundaries receiving
       INTEGER :: iw_b(4), ie_b(4), is_b(4), in_b(4)                ! Arrays for neighbours coordinates
@@ -397,5 +397,5 @@
           IF(lwp) WRITE(numout,*)
         ENDIF
-        IF( nb_jpk_bdy > 0 ) THEN
+        IF( nb_jpk_bdy(ib_bdy) > 0 ) THEN
            IF(lwp) WRITE(numout,*) '*** open boundary will be interpolate in the vertical onto the native grid ***'
         ELSE
@@ -516,25 +516,16 @@
          ALLOCATE( nbidta(jpbdta, jpbgrd, nb_bdy), nbjdta(jpbdta, jpbgrd, nb_bdy),    &
             &      nbrdta(jpbdta, jpbgrd, nb_bdy) )
-
-         IF( nb_jpk_bdy>0 ) THEN
-            ALLOCATE( dta_global(jpbdtau, 1, nb_jpk_bdy) )
-            ALLOCATE( dta_global_z(jpbdtau, 1, nb_jpk_bdy) )
-            ALLOCATE( dta_global_dz(jpbdtau, 1, nb_jpk_bdy) )
-         ELSE
-            ALLOCATE( dta_global(jpbdtau, 1, jpk) )
-            ALLOCATE( dta_global_z(jpbdtau, 1, jpk) ) ! needed ?? TODO
-            ALLOCATE( dta_global_dz(jpbdtau, 1, jpk) )! needed ?? TODO
-         ENDIF
+         
+         jpk_max = MAXVAL(nb_jpk_bdy)
+         jpk_max = MAX(jpk_max, jpk)
+
+         ALLOCATE( dta_global(jpbdtau, 1, jpk_max) )
+         ALLOCATE( dta_global_z(jpbdtau, 1, jpk_max) ) ! needed ?? TODO
+         ALLOCATE( dta_global_dz(jpbdtau, 1, jpk_max) )! needed ?? TODO
 
          IF ( icount>0 ) THEN
-            IF( nb_jpk_bdy>0 ) THEN
-               ALLOCATE( dta_global2(jpbdtas, nrimmax, nb_jpk_bdy) )
-               ALLOCATE( dta_global2_z(jpbdtas, nrimmax, nb_jpk_bdy) )
-               ALLOCATE( dta_global2_dz(jpbdtas, nrimmax, nb_jpk_bdy) )
-            ELSE
-               ALLOCATE( dta_global2(jpbdtas, nrimmax, jpk) )
-               ALLOCATE( dta_global2_z(jpbdtas, nrimmax, jpk) ) ! needed ?? TODO
-               ALLOCATE( dta_global2_dz(jpbdtas, nrimmax, jpk) )! needed ?? TODO  
-            ENDIF
+            ALLOCATE( dta_global2(jpbdtas, nrimmax, jpk_max) )
+            ALLOCATE( dta_global2_z(jpbdtas, nrimmax, jpk_max) ) ! needed ?? TODO
+            ALLOCATE( dta_global2_dz(jpbdtas, nrimmax, jpk_max) )! needed ?? TODO  
          ENDIF
          ! 
@@ -960,5 +951,5 @@
                        & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
                        ii = nbidta(ib,igrd,ib_bdy)- iw_b(1)+2
-                       if((com_west_b .ne. 1) .and. (ii == (nlcit(nowe+1)-1))) then
+                       if( ii == (nlcit(nowe+1)-1) ) then
                           ij = nbjdta(ib,igrd,ib_bdy) - is_b(1)+2
                           if((ij == 2) .and. (nbondj == 0 .or. nbondj == 1)) then
@@ -974,5 +965,5 @@
                        & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
                        ii = nbidta(ib,igrd,ib_bdy)- iw_b(2)+2
-                       if((com_east_b .ne. 1) .and. (ii == 2)) then
+                       if( ii == 2 ) then
                           ij = nbjdta(ib,igrd,ib_bdy) - is_b(2)+2
                           if((ij == 2) .and. (nbondj == 0 .or. nbondj == 1)) then
@@ -989,5 +980,5 @@
                        & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
                        ii = nbidta(ib,igrd,ib_bdy)- iw_b(1)+2
-                       if((com_west_b .ne. 1) .and. (ii == (nlcit(nowe+1)-1))) then
+                       if( ii == (nlcit(nowe+1)-1) ) then
                           ij = nbjdta(ib,igrd,ib_bdy) - is_b(1)+2
                           if((ij == 2) .and. (nbondj == 0 .or. nbondj == 1)) then
@@ -1004,5 +995,5 @@
                        & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
                        ii = nbidta(ib,igrd,ib_bdy)- iw_b(2)+2
-                       if((com_east_b .ne. 1) .and. (ii == 2)) then
+                       if( ii == 2 ) then
                           ij = nbjdta(ib,igrd,ib_bdy) - is_b(2)+2
                           if((ij == 2) .and. (nbondj == 0 .or. nbondj == 1)) then
