Index: NEMO/branches/UKMO/dev_r10037_GPU/src/TOP/PISCES/P4Z/p4zsbc.F90
===================================================================
--- NEMO/branches/UKMO/dev_r10037_GPU/src/TOP/PISCES/P4Z/p4zsbc.F90	(revision 10842)
+++ NEMO/branches/UKMO/dev_r10037_GPU/src/TOP/PISCES/P4Z/p4zsbc.F90	(revision 10843)
@@ -37,4 +37,5 @@
    REAL(wp), PUBLIC ::   concfediaz   !: Fe half-saturation Cste for diazotrophs 
    REAL(wp)         ::   hratio       !: Fe:3He ratio assumed for vent iron supply
+   REAL(wp)         ::   distcoast    !: Distance off the coast for Iron from sediments
    REAL(wp), PUBLIC ::   fep_rats     !: Fep/Fer ratio from sed  sources
    REAL(wp), PUBLIC ::   fep_rath     !: Fep/Fer ratio from hydro sources
@@ -74,13 +75,14 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   hydrofe          !: Hydrothermal vent supply of iron
 
-   REAL(wp), PUBLIC ::   rivalkinput, rivdicinput, nitdepinput, sumdepsi
-   REAL(wp), PUBLIC ::   rivdininput, rivdipinput, rivdsiinput
+   REAL(wp), PUBLIC :: sedsilfrac, sedcalfrac
+   REAL(wp), PUBLIC :: rivalkinput, rivdicinput
+   REAL(wp), PUBLIC :: rivdininput, rivdipinput, rivdsiinput
 
    !! * Substitutions
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/TOP 3.3 , NEMO Consortium (2018)
+   !! NEMO/TOP 4.0 , NEMO Consortium (2018)
    !! $Id$
-   !! Software governed by the CeCILL licence (./LICENSE)
+   !! Software governed by the CeCILL license (see ./LICENSE)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -109,6 +111,6 @@
          IF( kt == nit000 .OR. ( kt /= nit000 .AND. ntimes_dust > 1 ) ) THEN
             CALL fld_read( kt, 1, sf_dust )
-            IF( nn_ice_tr == -1 .AND. .NOT.ln_ironice ) THEN   ;   dust(:,:) = sf_dust(1)%fnow(:,:,1)
-            ELSE                                               ;   dust(:,:) = sf_dust(1)%fnow(:,:,1) * ( 1.-fr_i(:,:) )
+            IF( nn_ice_tr == -1 .AND. .NOT.ln_ironice ) THEN   ;   dust(:,:) = MAX( rtrn, sf_dust(1)%fnow(:,:,1) )
+            ELSE                                               ;   dust(:,:) = MAX( rtrn, sf_dust(1)%fnow(:,:,1) * ( 1.-fr_i(:,:) ) )
             ENDIF
          ENDIF
@@ -173,9 +175,9 @@
              zcoef = rno3 * 14E6 * ryyss
              CALL fld_read( kt, 1, sf_ndepo )
-             nitdep(:,:) = sf_ndepo(1)%fnow(:,:,1) / zcoef / e3t_n(:,:,1) 
+             nitdep(:,:) = MAX( rtrn, sf_ndepo(1)%fnow(:,:,1) / zcoef / e3t_n(:,:,1) )
          ENDIF
          IF( .NOT.ln_linssh ) THEN
            zcoef = rno3 * 14E6 * ryyss
-           nitdep(:,:) = sf_ndepo(1)%fnow(:,:,1) / zcoef / e3t_n(:,:,1) 
+           nitdep(:,:) = MAX( rtrn, sf_ndepo(1)%fnow(:,:,1) / zcoef / e3t_n(:,:,1) )
          ENDIF
       ENDIF
@@ -205,9 +207,9 @@
       INTEGER  :: ik50                !  last level where depth less than 50 m
       INTEGER  :: isrow             ! index for ORCA1 starting row
-      REAL(wp) :: zexpide, zdenitide, zmaskt
+      REAL(wp) :: zexpide, zdenitide, zmaskt, zsurfc, zsurfp,ze3t, ze3t2, zcslp
       REAL(wp) :: ztimes_dust, ztimes_riv, ztimes_ndep 
       REAL(wp), DIMENSION(nbtimes) :: zsteps                 ! times records
       REAL(wp), DIMENSION(:), ALLOCATABLE :: rivinput
-      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: zdust, zndepo, zriver, zcmask
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: zriver, zcmask
       !
       CHARACTER(len=100) ::  cn_dir          ! Root directory for location of ssr files
@@ -220,5 +222,5 @@
         &                sn_riverdip, sn_riverdop, sn_riverdsi, sn_ndepo, sn_ironsed, sn_hydrofe, &
         &                ln_dust, ln_solub, ln_river, ln_ndepo, ln_ironsed, ln_ironice, ln_hydrofe,    &
-        &                sedfeinput, dustsolub, icefeinput, wdust, mfrac, nitrfix, diazolight, concfediaz, &
+        &                sedfeinput, distcoast, dustsolub, icefeinput, wdust, mfrac, nitrfix, diazolight, concfediaz, &
         &                hratio, fep_rats, fep_rath, lgw_rath
       !!----------------------------------------------------------------------
@@ -248,4 +250,5 @@
          WRITE(numout,*) '      fe input from hydrothermal vents         ln_hydrofe  = ', ln_hydrofe
          WRITE(numout,*) '      coastal release of iron                  sedfeinput  = ', sedfeinput
+         WRITE(numout,*) '      distance off the coast                   distcoast   = ', distcoast
          WRITE(numout,*) '      solubility of the dust                   dustsolub   = ', dustsolub
          WRITE(numout,*) '      Mineral Fe content of the dust           mfrac       = ', mfrac
@@ -307,19 +310,5 @@
             CALL iom_open (  TRIM( sn_dust%clname ) , numdust )
             CALL iom_gettime( numdust, zsteps, kntime=ntimes_dust)  ! get number of record in file
-            ALLOCATE( zdust(jpi,jpj,ntimes_dust) )
-            DO jm = 1, ntimes_dust
-               CALL iom_get( numdust, jpdom_data, TRIM( sn_dust%clvar ), zdust(:,:,jm), jm )
-            END DO
-            CALL iom_close( numdust )
-            ztimes_dust = 1._wp / REAL(ntimes_dust, wp) 
-            sumdepsi = 0.e0
-            DO jm = 1, ntimes_dust
-               sumdepsi = sumdepsi + glob_sum( zdust(:,:,jm) * e1e2t(:,:) * tmask(:,:,1) * ztimes_dust )
-            END DO
-            sumdepsi = sumdepsi / ( nyear_len(1) * rday ) * 12. * 8.8 * 0.075 * mfrac / 28.1 
-            DEALLOCATE( zdust)
-         ENDIF
-      ELSE
-         sumdepsi  = 0._wp
+         END IF
       END IF
 
@@ -419,19 +408,5 @@
             CALL iom_open ( TRIM( sn_ndepo%clname ), numdepo )
             CALL iom_gettime( numdepo, zsteps, kntime=ntimes_ndep)
-            ALLOCATE( zndepo(jpi,jpj,ntimes_ndep) )
-            DO jm = 1, ntimes_ndep
-               CALL iom_get( numdepo, jpdom_data, TRIM( sn_ndepo%clvar ), zndepo(:,:,jm), jm )
-            END DO
-            CALL iom_close( numdepo )
-            ztimes_ndep = 1._wp / REAL(ntimes_ndep, wp) 
-            nitdepinput = 0._wp
-            DO jm = 1, ntimes_ndep
-              nitdepinput = nitdepinput + glob_sum( zndepo(:,:,jm) * e1e2t(:,:) * tmask(:,:,1) * ztimes_ndep )
-            ENDDO
-            nitdepinput = nitdepinput / rno3 / 14E6 
-            DEALLOCATE( zndepo)
-         ENDIF
-      ELSE
-         nitdepinput = 0._wp
+         ENDIF
       ENDIF
 
@@ -459,9 +434,15 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1
-                  IF( tmask(ji,jj,jk) /= 0. ) THEN
-                     zmaskt = tmask(ji+1,jj,jk) * tmask(ji-1,jj,jk) * tmask(ji,jj+1,jk)    &
-                        &                       * tmask(ji,jj-1,jk) * tmask(ji,jj,jk+1)
-                     IF( zmaskt == 0. )   zcmask(ji,jj,jk ) = MAX( 0.1, zcmask(ji,jj,jk) ) 
-                  END IF
+                  ze3t   = e3t_0(ji,jj,jk)
+                  zsurfc =  e1u(ji,jj) * ( 1. - umask(ji  ,jj  ,jk) )   &
+                          + e1u(ji,jj) * ( 1. - umask(ji-1,jj  ,jk) )   &
+                          + e2v(ji,jj) * ( 1. - vmask(ji  ,jj  ,jk) )   &
+                          + e2v(ji,jj) * ( 1. - vmask(ji  ,jj-1,jk) )
+                  zsurfp = zsurfc * ze3t / e1e2t(ji,jj)
+                  ! estimation of the coastal slope : 5 km off the coast
+                  ze3t2 = ze3t * ze3t
+                  zcslp = SQRT( ( distcoast*distcoast + ze3t2 ) / ze3t2 )
+                  !
+                  zcmask(ji,jj,jk) = zcmask(ji,jj,jk) + zcslp * zsurfp
                END DO
             END DO
@@ -519,9 +500,8 @@
          WRITE(numout,*) '    DIC Supply : ', rivdicinput*1E3*12./1E12     ,' TgC/yr'
          WRITE(numout,*) 
-         WRITE(numout,*) '    Total input of elements from atmospheric supply'
-         WRITE(numout,*) '    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
-         WRITE(numout,*) '    N Supply   : ', nitdepinput*rno3*1E3/1E12*14.,' TgN/yr'
-         WRITE(numout,*) 
-      ENDIF
+      ENDIF
+      !
+      sedsilfrac = 0.03     ! percentage of silica loss in the sediments
+      sedcalfrac = 0.6      ! percentage of calcite loss in the sediments
       !
    END SUBROUTINE p4z_sbc_init
