New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
p4zsbc.F90 in branches/2016/dev_r6519_HPC_4/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z – NEMO

source: branches/2016/dev_r6519_HPC_4/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsbc.F90 @ 7508

Last change on this file since 7508 was 7508, checked in by mocavero, 7 years ago

changes on code duplication and workshare construct

  • Property svn:keywords set to Id
File size: 27.0 KB
Line 
1MODULE p4zsbc
2   !!======================================================================
3   !!                         ***  MODULE p4sbc  ***
4   !! TOP :   PISCES surface boundary conditions of external inputs of nutrients
5   !!======================================================================
6   !! History :   3.5  !  2012-07 (O. Aumont, C. Ethe) Original code
7   !!----------------------------------------------------------------------
8#if defined key_pisces
9   !!----------------------------------------------------------------------
10   !!   'key_pisces'                                       PISCES bio-model
11   !!----------------------------------------------------------------------
12   !!   p4z_sbc        :  Read and interpolate time-varying nutrients fluxes
13   !!   p4z_sbc_init   :  Initialization of p4z_sbc
14   !!----------------------------------------------------------------------
15   USE oce_trc         !  shared variables between ocean and passive tracers
16   USE trc             !  passive tracers common variables
17   USE sms_pisces      !  PISCES Source Minus Sink variables
18   USE iom             !  I/O manager
19   USE fldread         !  time interpolation
20
21   IMPLICIT NONE
22   PRIVATE
23
24   PUBLIC   p4z_sbc
25   PUBLIC   p4z_sbc_init   
26
27   LOGICAL , PUBLIC  :: ln_dust     !: boolean for dust input from the atmosphere
28   LOGICAL , PUBLIC  :: ln_solub    !: boolean for variable solubility of atmospheric iron
29   LOGICAL , PUBLIC  :: ln_river    !: boolean for river input of nutrients
30   LOGICAL , PUBLIC  :: ln_ndepo    !: boolean for atmospheric deposition of N
31   LOGICAL , PUBLIC  :: ln_ironsed  !: boolean for Fe input from sediments
32   LOGICAL , PUBLIC  :: ln_hydrofe  !: boolean for Fe input from hydrothermal vents
33   LOGICAL , PUBLIC  :: ln_ironice  !: boolean for Fe input from sea ice
34   REAL(wp), PUBLIC  :: sedfeinput  !: Coastal release of Iron
35   REAL(wp), PUBLIC  :: dustsolub   !: Solubility of the dust
36   REAL(wp), PUBLIC  :: mfrac       !: Mineral Content of the dust
37   REAL(wp), PUBLIC  :: icefeinput  !: Iron concentration in sea ice
38   REAL(wp), PUBLIC  :: wdust       !: Sinking speed of the dust
39   REAL(wp), PUBLIC  :: nitrfix     !: Nitrogen fixation rate   
40   REAL(wp), PUBLIC  :: diazolight  !: Nitrogen fixation sensitivty to light
41   REAL(wp), PUBLIC  :: concfediaz  !: Fe half-saturation Cste for diazotrophs
42   REAL(wp)          :: hratio      !: Fe:3He ratio assumed for vent iron supply
43
44   LOGICAL , PUBLIC  :: ll_sbc
45
46   LOGICAL  ::  ll_solub
47
48   INTEGER , PARAMETER  :: jpriv  = 7   !: Maximum number of river input fields
49   INTEGER , PARAMETER  :: jr_dic = 1   !: index of dissolved inorganic carbon
50   INTEGER , PARAMETER  :: jr_doc = 2   !: index of dissolved organic carbon
51   INTEGER , PARAMETER  :: jr_din = 3   !: index of dissolved inorganic nitrogen
52   INTEGER , PARAMETER  :: jr_don = 4   !: index of dissolved organic nitrogen
53   INTEGER , PARAMETER  :: jr_dip = 5   !: index of dissolved inorganic phosporus
54   INTEGER , PARAMETER  :: jr_dop = 6   !: index of dissolved organic phosphorus
55   INTEGER , PARAMETER  :: jr_dsi = 7   !: index of dissolved silicate
56
57
58   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_dust      ! structure of input dust
59   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_solub      ! structure of input dust
60   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_river  ! structure of input riverdic
61   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_ndepo     ! structure of input nitrogen deposition
62   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_ironsed   ! structure of input iron from sediment
63   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_hydrofe   ! structure of input iron from hydrothermal vents
64
65   INTEGER , PARAMETER :: nbtimes = 365  !: maximum number of times record in a file
66   INTEGER  :: ntimes_dust, ntimes_riv, ntimes_ndep       ! number of time steps in a file
67   INTEGER  :: ntimes_solub, ntimes_hydro                 ! number of time steps in a file
68
69   REAL(wp), PUBLIC, ALLOCATABLE, SAVE,   DIMENSION(:,:) :: dust, solub       !: dust fields
70   REAL(wp), PUBLIC, ALLOCATABLE, SAVE,   DIMENSION(:,:) :: rivdic, rivalk    !: river input fields
71   REAL(wp), PUBLIC, ALLOCATABLE, SAVE,   DIMENSION(:,:) :: rivdin, rivdip    !: river input fields
72   REAL(wp), PUBLIC, ALLOCATABLE, SAVE,   DIMENSION(:,:) :: rivdsi    !: river input fields
73   REAL(wp), PUBLIC, ALLOCATABLE, SAVE,   DIMENSION(:,:) :: nitdep    !: atmospheric N deposition
74   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ironsed   !: Coastal supply of iron
75   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: hydrofe   !: Hydrothermal vent supply of iron
76
77   REAL(wp), PUBLIC :: sumdepsi, rivalkinput, rivdicinput, nitdepinput
78   REAL(wp), PUBLIC :: rivdininput, rivdipinput, rivdsiinput
79
80   !! * Substitutions
81#  include "vectopt_loop_substitute.h90"
82   !!----------------------------------------------------------------------
83   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
84   !! $Id$
85   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
86   !!----------------------------------------------------------------------
87CONTAINS
88
89   SUBROUTINE p4z_sbc( kt )
90      !!----------------------------------------------------------------------
91      !!                  ***  routine p4z_sbc  ***
92      !!
93      !! ** purpose :   read and interpolate the external sources of nutrients
94      !!
95      !! ** method  :   read the files and interpolate the appropriate variables
96      !!
97      !! ** input   :   external netcdf files
98      !!
99      !!----------------------------------------------------------------------
100      !! * arguments
101      INTEGER, INTENT( in  ) ::   kt   ! ocean time step
102
103      !! * local declarations
104      INTEGER  :: ji,jj 
105      REAL(wp) :: zcoef, zyyss
106      !!---------------------------------------------------------------------
107      !
108      IF( nn_timing == 1 )  CALL timing_start('p4z_sbc')
109
110      !
111      ! Compute dust at nit000 or only if there is more than 1 time record in dust file
112      IF( ln_dust ) THEN
113         IF( kt == nit000 .OR. ( kt /= nit000 .AND. ntimes_dust > 1 ) ) THEN
114            CALL fld_read( kt, 1, sf_dust )
115            IF( nn_ice_tr == -1 .AND. .NOT. ln_ironice ) THEN
116!$OMP PARALLEL DO schedule(static) private(jj, ji)
117            DO jj = 1, jpj
118               DO ji = 1, jpi
119                  dust(ji,jj) = sf_dust(1)%fnow(ji,jj,1)
120               END DO
121            END DO
122            ELSE
123!$OMP PARALLEL DO schedule(static) private(jj, ji)
124            DO jj = 1, jpj
125               DO ji = 1, jpi
126                  dust(ji,jj) = sf_dust(1)%fnow(ji,jj,1) * ( 1.0 - fr_i(ji,jj) )
127               END DO
128            END DO
129            ENDIF
130         ENDIF
131      ENDIF
132
133      IF( ll_solub ) THEN
134         IF( kt == nit000 .OR. ( kt /= nit000 .AND. ntimes_solub > 1 ) ) THEN
135            CALL fld_read( kt, 1, sf_solub )
136!$OMP PARALLEL DO schedule(static) private(jj, ji)
137            DO jj = 1, jpj
138               DO ji = 1, jpi
139                  solub(ji,jj) = sf_solub(1)%fnow(ji,jj,1)
140               END DO
141            END DO
142         ENDIF
143      ENDIF
144
145      ! N/P and Si releases due to coastal rivers
146      ! Compute river at nit000 or only if there is more than 1 time record in river file
147      ! -----------------------------------------
148      IF( ln_river ) THEN
149         IF( kt == nit000 .OR. ( kt /= nit000 .AND. ntimes_riv > 1 ) ) THEN
150            CALL fld_read( kt, 1, sf_river )
151!$OMP PARALLEL DO schedule(static) private(jj, ji, zcoef)
152            DO jj = 1, jpj
153               DO ji = 1, jpi
154                  zcoef = ryyss * e1e2t(ji,jj) * h_rnf(ji,jj) 
155                  rivalk(ji,jj) =   sf_river(jr_dic)%fnow(ji,jj,1)                                    &
156                     &              * 1.E3        / ( 12. * zcoef + rtrn )
157                  rivdic(ji,jj) = ( sf_river(jr_dic)%fnow(ji,jj,1) + sf_river(jr_doc)%fnow(ji,jj,1) ) &
158                     &              * 1.E3         / ( 12. * zcoef + rtrn )
159                  rivdin(ji,jj) = ( sf_river(jr_din)%fnow(ji,jj,1) + sf_river(jr_don)%fnow(ji,jj,1) ) &
160                     &              * 1.E3 / rno3 / ( 14. * zcoef + rtrn )
161                  rivdip(ji,jj) = ( sf_river(jr_dip)%fnow(ji,jj,1) + sf_river(jr_dop)%fnow(ji,jj,1) ) &
162                     &              * 1.E3 / po4r / ( 31. * zcoef + rtrn )
163                  rivdsi(ji,jj) =   sf_river(jr_dsi)%fnow(ji,jj,1)                                    &
164                     &              * 1.E3        / ( 28.1 * zcoef + rtrn )
165               END DO
166            END DO
167         ENDIF
168      ENDIF
169
170      ! Compute N deposition at nit000 or only if there is more than 1 time record in N deposition file
171      IF( ln_ndepo ) THEN
172         IF( kt == nit000 .OR. ( kt /= nit000 .AND. ntimes_ndep > 1 ) ) THEN
173            CALL fld_read( kt, 1, sf_ndepo )
174!$OMP PARALLEL DO schedule(static) private(jj, ji)
175            DO jj = 1, jpj
176               DO ji = 1, jpi
177                  nitdep(ji,jj) = sf_ndepo(1)%fnow(ji,jj,1) / rno3 / ( 14E6 * ryyss * e3t_n(ji,jj,1) + rtrn )
178               END DO
179            END DO
180         ENDIF
181      ENDIF
182      !
183      IF( nn_timing == 1 )  CALL timing_stop('p4z_sbc')
184      !
185   END SUBROUTINE p4z_sbc
186
187   SUBROUTINE p4z_sbc_init
188
189      !!----------------------------------------------------------------------
190      !!                  ***  routine p4z_sbc_init  ***
191      !!
192      !! ** purpose :   initialization of the external sources of nutrients
193      !!
194      !! ** method  :   read the files and compute the budget
195      !!                called at the first timestep (nittrc000)
196      !!
197      !! ** input   :   external netcdf files
198      !!
199      !!----------------------------------------------------------------------
200      !
201      INTEGER  :: ji, jj, jk, jm, ifpr
202      INTEGER  :: ii0, ii1, ij0, ij1
203      INTEGER  :: numdust, numsolub, numriv, numiron, numdepo, numhydro
204      INTEGER  :: ierr, ierr1, ierr2, ierr3
205      INTEGER  :: ios                 ! Local integer output status for namelist read
206      INTEGER  :: ik50                !  last level where depth less than 50 m
207      INTEGER  :: isrow             ! index for ORCA1 starting row
208      REAL(wp) :: zexpide, zdenitide, zmaskt
209      REAL(wp) :: ztimes_dust, ztimes_riv, ztimes_ndep 
210      REAL(wp), DIMENSION(nbtimes) :: zsteps                 ! times records
211      REAL(wp), DIMENSION(:), ALLOCATABLE :: rivinput
212      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: zdust, zndepo, zriver, zcmask
213      !
214      CHARACTER(len=100) ::  cn_dir          ! Root directory for location of ssr files
215      TYPE(FLD_N), DIMENSION(jpriv) ::  slf_river    ! array of namelist informations on the fields to read
216      TYPE(FLD_N) ::   sn_dust, sn_solub, sn_ndepo, sn_ironsed, sn_hydrofe   ! informations about the fields to be read
217      TYPE(FLD_N) ::   sn_riverdoc, sn_riverdic, sn_riverdsi   ! informations about the fields to be read
218      TYPE(FLD_N) ::   sn_riverdin, sn_riverdon, sn_riverdip, sn_riverdop
219      !
220      NAMELIST/nampissbc/cn_dir, sn_dust, sn_solub, sn_riverdic, sn_riverdoc, sn_riverdin, sn_riverdon,     &
221        &                sn_riverdip, sn_riverdop, sn_riverdsi, sn_ndepo, sn_ironsed, sn_hydrofe, &
222        &                ln_dust, ln_solub, ln_river, ln_ndepo, ln_ironsed, ln_ironice, ln_hydrofe,    &
223        &                sedfeinput, dustsolub, icefeinput, wdust, mfrac, nitrfix, diazolight, concfediaz, hratio
224      !!----------------------------------------------------------------------
225      !
226      IF( nn_timing == 1 )  CALL timing_start('p4z_sbc_init')
227      !
228      !                            !* set file information
229      REWIND( numnatp_ref )              ! Namelist nampissbc in reference namelist : Pisces external sources of nutrients
230      READ  ( numnatp_ref, nampissbc, IOSTAT = ios, ERR = 901)
231901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampissbc in reference namelist', lwp )
232
233      REWIND( numnatp_cfg )              ! Namelist nampissbc in configuration namelist : Pisces external sources of nutrients
234      READ  ( numnatp_cfg, nampissbc, IOSTAT = ios, ERR = 902 )
235902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampissbc in configuration namelist', lwp )
236      IF(lwm) WRITE ( numonp, nampissbc )
237
238      IF ( ( nn_ice_tr >= 0 ) .AND. ln_ironice ) THEN
239         IF(lwp) THEN
240            WRITE(numout,*) ' ln_ironice incompatible with nn_ice_tr = ', nn_ice_tr
241            WRITE(numout,*) ' Specify your sea ice iron concentration in nampisice instead '
242            WRITE(numout,*) ' ln_ironice is forced to .FALSE. '
243            ln_ironice = .FALSE.
244         ENDIF
245      ENDIF
246
247      IF(lwp) THEN
248         WRITE(numout,*) ' '
249         WRITE(numout,*) ' namelist : nampissbc '
250         WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~ '
251         WRITE(numout,*) '    dust input from the atmosphere           ln_dust     = ', ln_dust
252         WRITE(numout,*) '    Variable solubility of iron input        ln_solub    = ', ln_solub
253         WRITE(numout,*) '    river input of nutrients                 ln_river    = ', ln_river
254         WRITE(numout,*) '    atmospheric deposition of n              ln_ndepo    = ', ln_ndepo
255         WRITE(numout,*) '    Fe input from sediments                  ln_ironsed  = ', ln_ironsed
256         WRITE(numout,*) '    Fe input from seaice                     ln_ironice  = ', ln_ironice
257         WRITE(numout,*) '    fe input from hydrothermal vents         ln_hydrofe  = ', ln_hydrofe
258         WRITE(numout,*) '    coastal release of iron                  sedfeinput  = ', sedfeinput
259         WRITE(numout,*) '    solubility of the dust                   dustsolub   = ', dustsolub
260         WRITE(numout,*) '    Mineral Fe content of the dust           mfrac       = ', mfrac
261         WRITE(numout,*) '    Iron concentration in sea ice            icefeinput  = ', icefeinput
262         WRITE(numout,*) '    sinking speed of the dust                wdust       = ', wdust
263         WRITE(numout,*) '    nitrogen fixation rate                   nitrfix     = ', nitrfix
264         WRITE(numout,*) '    nitrogen fixation sensitivty to light    diazolight  = ', diazolight
265         WRITE(numout,*) '    fe half-saturation cste for diazotrophs  concfediaz  = ', concfediaz
266         WRITE(numout,*) '    Fe to 3He ratio assumed for vent iron supply hratio  = ', hratio
267      END IF
268
269      IF( ln_dust .OR. ln_river .OR. ln_ndepo ) THEN  ;  ll_sbc = .TRUE.
270      ELSE                                            ;  ll_sbc = .FALSE.
271      ENDIF
272
273      IF( ln_dust .AND. ln_solub ) THEN               ;  ll_solub = .TRUE.
274      ELSE                                            ;  ll_solub = .FALSE.
275      ENDIF
276
277      ! set the number of level over which river runoffs are applied
278      ! online configuration : computed in sbcrnf
279      IF( lk_offline ) THEN
280!$OMP PARALLEL DO schedule(static) private(jj, ji)
281         DO jj = 1, jpj
282            DO ji = 1, jpi
283               nk_rnf(ji,jj) = 1
284               h_rnf (ji,jj) = gdept_n(ji,jj,1)
285            END DO
286         END DO
287      ENDIF
288
289      ! dust input from the atmosphere
290      ! ------------------------------
291      IF( ln_dust ) THEN 
292         !
293         IF(lwp) WRITE(numout,*) '    initialize dust input from atmosphere '
294         IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '
295         !
296         ALLOCATE( dust(jpi,jpj) )    ! allocation
297         !
298         ALLOCATE( sf_dust(1), STAT=ierr )           !* allocate and fill sf_sst (forcing structure) with sn_sst
299         IF( ierr > 0 )   CALL ctl_stop( 'STOP', 'p4z_sed_init: unable to allocate sf_dust structure' )
300         !
301         CALL fld_fill( sf_dust, (/ sn_dust /), cn_dir, 'p4z_sed_init', 'Atmospheric dust deposition', 'nampissed' )
302                                   ALLOCATE( sf_dust(1)%fnow(jpi,jpj,1)   )
303         IF( sn_dust%ln_tint )     ALLOCATE( sf_dust(1)%fdta(jpi,jpj,1,2) )
304         !
305         IF( Agrif_Root() ) THEN   !  Only on the master grid
306            ! Get total input dust ; need to compute total atmospheric supply of Si in a year
307            CALL iom_open (  TRIM( sn_dust%clname ) , numdust )
308            CALL iom_gettime( numdust, zsteps, kntime=ntimes_dust)  ! get number of record in file
309            ALLOCATE( zdust(jpi,jpj,ntimes_dust) )
310            DO jm = 1, ntimes_dust
311               CALL iom_get( numdust, jpdom_data, TRIM( sn_dust%clvar ), zdust(:,:,jm), jm )
312            END DO
313            CALL iom_close( numdust )
314            ztimes_dust = 1._wp / FLOAT( ntimes_dust ) 
315            sumdepsi = 0.e0
316            DO jm = 1, ntimes_dust
317               sumdepsi = sumdepsi + glob_sum( zdust(:,:,jm) * e1e2t(:,:) * tmask(:,:,1) * ztimes_dust )
318            ENDDO
319            sumdepsi = sumdepsi / ( nyear_len(1) * rday ) * 12. * 8.8 * 0.075 * mfrac / 28.1 
320            DEALLOCATE( zdust)
321         ENDIF
322      ELSE
323         sumdepsi  = 0._wp
324      END IF
325
326      ! Solubility of dust deposition of iron
327      ! Only if ln_dust and ln_solubility set to true (ll_solub = .true.)
328      ! -----------------------------------------------------------------
329      IF( ll_solub ) THEN
330         !
331         IF(lwp) WRITE(numout,*) '    initialize variable solubility of Fe '
332         IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '
333         !
334         ALLOCATE( solub(jpi,jpj) )    ! allocation
335         !
336         ALLOCATE( sf_solub(1), STAT=ierr )           !* allocate and fill sf_sst (forcing structure) with sn_sst
337         IF( ierr > 0 )   CALL ctl_stop( 'STOP', 'p4z_sed_init: unable to allocate sf_solub structure' )
338         !
339         CALL fld_fill( sf_solub, (/ sn_solub /), cn_dir, 'p4z_sed_init', 'Solubility of atm. iron ', 'nampissed' )
340                                   ALLOCATE( sf_solub(1)%fnow(jpi,jpj,1)   )
341         IF( sn_solub%ln_tint )    ALLOCATE( sf_solub(1)%fdta(jpi,jpj,1,2) )
342         ! get number of record in file
343         CALL iom_open (  TRIM( sn_solub%clname ) , numsolub )
344         CALL iom_gettime( numsolub, zsteps, kntime=ntimes_solub)  ! get number of record in file
345         CALL iom_close( numsolub )
346      ENDIF
347
348      ! nutrient input from rivers
349      ! --------------------------
350      IF( ln_river ) THEN
351         !
352         slf_river(jr_dic) = sn_riverdic  ;  slf_river(jr_doc) = sn_riverdoc  ;  slf_river(jr_din) = sn_riverdin 
353         slf_river(jr_don) = sn_riverdon  ;  slf_river(jr_dip) = sn_riverdip  ;  slf_river(jr_dop) = sn_riverdop
354         slf_river(jr_dsi) = sn_riverdsi 
355         !
356         ALLOCATE( rivdic(jpi,jpj), rivalk(jpi,jpj), rivdin(jpi,jpj), rivdip(jpi,jpj), rivdsi(jpi,jpj) ) 
357         !
358         ALLOCATE( sf_river(jpriv), rivinput(jpriv), STAT=ierr1 )           !* allocate and fill sf_river (forcing structure) with sn_river_
359         rivinput(:) = 0.0
360
361         IF( ierr1 > 0 )   CALL ctl_stop( 'STOP', 'p4z_sed_init: unable to allocate sf_irver structure' )
362         !
363         CALL fld_fill( sf_river, slf_river, cn_dir, 'p4z_sed_init', 'Input from river ', 'nampissed' )
364         DO ifpr = 1, jpriv
365                                          ALLOCATE( sf_river(ifpr)%fnow(jpi,jpj,1  ) )
366            IF( slf_river(ifpr)%ln_tint ) ALLOCATE( sf_river(ifpr)%fdta(jpi,jpj,1,2) )
367         END DO
368         IF( Agrif_Root() ) THEN   !  Only on the master grid
369            ! Get total input rivers ; need to compute total river supply in a year
370            DO ifpr = 1, jpriv
371               CALL iom_open ( TRIM( slf_river(ifpr)%clname ), numriv )
372               CALL iom_gettime( numriv, zsteps, kntime=ntimes_riv)
373               ALLOCATE( zriver(jpi,jpj,ntimes_riv) )
374               DO jm = 1, ntimes_riv
375                  CALL iom_get( numriv, jpdom_data, TRIM( slf_river(ifpr)%clvar ), zriver(:,:,jm), jm )
376               END DO
377               CALL iom_close( numriv )
378               ztimes_riv = 1._wp / FLOAT(ntimes_riv) 
379               DO jm = 1, ntimes_riv
380                  rivinput(ifpr) = rivinput(ifpr) + glob_sum( zriver(:,:,jm) * tmask(:,:,1) * ztimes_riv ) 
381               END DO
382               DEALLOCATE( zriver)
383            END DO
384            ! N/P and Si releases due to coastal rivers
385            ! -----------------------------------------
386            rivdicinput = (rivinput(jr_dic) + rivinput(jr_doc) ) * 1E3 / 12._wp
387            rivdininput = (rivinput(jr_din) + rivinput(jr_don) ) * 1E3 / rno3 / 14._wp
388            rivdipinput = (rivinput(jr_dip) + rivinput(jr_dop) ) * 1E3 / po4r / 31._wp
389            rivdsiinput = rivinput(jr_dsi) * 1E3 / 28.1_wp
390            rivalkinput = rivinput(jr_dic) * 1E3 / 12._wp
391            !
392         ENDIF
393      ELSE
394         rivdicinput = 0._wp
395         rivdininput = 0._wp
396         rivdipinput = 0._wp
397         rivdsiinput = 0._wp
398         rivalkinput = 0._wp
399      END IF 
400      ! nutrient input from dust
401      ! ------------------------
402      IF( ln_ndepo ) THEN
403         !
404         IF(lwp) WRITE(numout,*) '    initialize the nutrient input by dust from ndeposition.orca.nc'
405         IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
406         !
407         ALLOCATE( nitdep(jpi,jpj) )    ! allocation
408         !
409         ALLOCATE( sf_ndepo(1), STAT=ierr3 )           !* allocate and fill sf_sst (forcing structure) with sn_sst
410         IF( ierr3 > 0 )   CALL ctl_stop( 'STOP', 'p4z_sed_init: unable to allocate sf_ndepo structure' )
411         !
412         CALL fld_fill( sf_ndepo, (/ sn_ndepo /), cn_dir, 'p4z_sed_init', 'Nutrient atmospheric depositon ', 'nampissed' )
413                                   ALLOCATE( sf_ndepo(1)%fnow(jpi,jpj,1)   )
414         IF( sn_ndepo%ln_tint )    ALLOCATE( sf_ndepo(1)%fdta(jpi,jpj,1,2) )
415         !
416         IF( Agrif_Root() ) THEN   !  Only on the master grid
417            ! Get total input dust ; need to compute total atmospheric supply of N in a year
418            CALL iom_open ( TRIM( sn_ndepo%clname ), numdepo )
419            CALL iom_gettime( numdepo, zsteps, kntime=ntimes_ndep)
420            ALLOCATE( zndepo(jpi,jpj,ntimes_ndep) )
421            DO jm = 1, ntimes_ndep
422               CALL iom_get( numdepo, jpdom_data, TRIM( sn_ndepo%clvar ), zndepo(:,:,jm), jm )
423            END DO
424            CALL iom_close( numdepo )
425            ztimes_ndep = 1._wp / FLOAT( ntimes_ndep ) 
426            nitdepinput = 0._wp
427            DO jm = 1, ntimes_ndep
428              nitdepinput = nitdepinput + glob_sum( zndepo(:,:,jm) * e1e2t(:,:) * tmask(:,:,1) * ztimes_ndep )
429            ENDDO
430            nitdepinput = nitdepinput / rno3 / 14E6 
431            DEALLOCATE( zndepo)
432         ENDIF
433      ELSE
434         nitdepinput = 0._wp
435      ENDIF
436
437      ! coastal and island masks
438      ! ------------------------
439      IF( ln_ironsed ) THEN     
440         !
441         IF(lwp) WRITE(numout,*) '    computation of an island mask to enhance coastal supply of iron'
442         IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
443         !
444         ALLOCATE( ironsed(jpi,jpj,jpk) )    ! allocation
445         !
446         CALL iom_open ( TRIM( sn_ironsed%clname ), numiron )
447         ALLOCATE( zcmask(jpi,jpj,jpk) )
448         CALL iom_get  ( numiron, jpdom_data, TRIM( sn_ironsed%clvar ), zcmask(:,:,:), 1 )
449         CALL iom_close( numiron )
450         !
451         ik50 = 5        !  last level where depth less than 50 m
452         DO jk = jpkm1, 1, -1
453            IF( gdept_1d(jk) > 50. )  ik50 = jk - 1
454         END DO
455         IF (lwp) WRITE(numout,*)
456         IF (lwp) WRITE(numout,*) ' Level corresponding to 50m depth ',  ik50,' ', gdept_1d(ik50+1)
457         IF (lwp) WRITE(numout,*)
458!$OMP PARALLEL DO schedule(static) private(jk, jj, ji, zmaskt)
459         DO jk = 1, ik50
460            DO jj = 2, jpjm1
461               DO ji = fs_2, fs_jpim1
462                  IF( tmask(ji,jj,jk) /= 0. ) THEN
463                     zmaskt = tmask(ji+1,jj,jk) * tmask(ji-1,jj,jk) * tmask(ji,jj+1,jk)    &
464                        &                       * tmask(ji,jj-1,jk) * tmask(ji,jj,jk+1)
465                     IF( zmaskt == 0. )   zcmask(ji,jj,jk ) = MAX( 0.1, zcmask(ji,jj,jk) ) 
466                  END IF
467               END DO
468            END DO
469         END DO
470         !
471         CALL lbc_lnk( zcmask , 'T', 1. )      ! lateral boundary conditions on cmask   (sign unchanged)
472         !
473!$OMP PARALLEL
474!$OMP DO schedule(static) private(jk, jj, ji, zexpide, zdenitide)
475         DO jk = 1, jpk
476            DO jj = 1, jpj
477               DO ji = 1, jpi
478                  zexpide   = MIN( 8.,( gdept_n(ji,jj,jk) / 500. )**(-1.5) )
479                  zdenitide = -0.9543 + 0.7662 * LOG( zexpide ) - 0.235 * LOG( zexpide )**2
480                  zcmask(ji,jj,jk) = zcmask(ji,jj,jk) * MIN( 1., EXP( zdenitide ) / 0.5 )
481               END DO
482            END DO
483         END DO
484!$OMP END DO NOWAIT
485         ! Coastal supply of iron
486         ! -------------------------
487!$OMP PARALLEL DO schedule(static) private(jj, ji)
488         DO jj = 1, jpj
489            DO ji = 1, jpi
490               ironsed(ji,jj,jpk) = 0._wp
491            END DO
492         END DO
493!$OMP DO schedule(static) private(jk)
494         DO jk = 1, jpkm1
495            ironsed(:,:,jk) = sedfeinput * zcmask(:,:,jk) / ( e3t_n(:,:,jk) * rday )
496         END DO
497!$OMP END DO NOWAIT
498!$OMP END PARALLEL
499         DEALLOCATE( zcmask)
500      ENDIF
501      !
502      ! Iron from Hydrothermal vents
503      ! ------------------------
504      IF( ln_hydrofe ) THEN
505         !
506         IF(lwp) WRITE(numout,*) '    Input of iron from hydrothermal vents '
507         IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
508         !
509         ALLOCATE( hydrofe(jpi,jpj,jpk) )    ! allocation
510         !
511         CALL iom_open ( TRIM( sn_hydrofe%clname ), numhydro )
512         CALL iom_get  ( numhydro, jpdom_data, TRIM( sn_hydrofe%clvar ), hydrofe(:,:,:), 1 )
513         CALL iom_close( numhydro )
514         !
515!$OMP PARALLEL DO schedule(static) private(jk, jj, ji)
516         DO jk = 1, jpk
517            DO jj = 1, jpj
518               DO ji = 1, jpi
519                  hydrofe(ji,jj,jk) = ( hydrofe(ji,jj,jk) * hratio ) / ( cvol(ji,jj,jk) * ryyss + rtrn ) / 1000._wp
520               END DO
521            END DO
522         END DO
523         !
524      ENDIF
525      !
526      IF( ll_sbc ) CALL p4z_sbc( nit000 ) 
527      !
528      IF(lwp) THEN
529         WRITE(numout,*)
530         WRITE(numout,*) '    Total input of elements from river supply'
531         WRITE(numout,*) '    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
532         WRITE(numout,*) '    N Supply   : ', rivdininput*rno3*1E3/1E12*14.,' TgN/yr'
533         WRITE(numout,*) '    Si Supply  : ', rivdsiinput*1E3/1E12*28.1,' TgSi/yr'
534         WRITE(numout,*) '    P Supply   : ', rivdipinput*1E3*po4r/1E12*31.,' TgP/yr'
535         WRITE(numout,*) '    Alk Supply : ', rivalkinput*1E3/1E12,' Teq/yr'
536         WRITE(numout,*) '    DIC Supply : ', rivdicinput*1E3*12./1E12,'TgC/yr'
537         WRITE(numout,*) 
538         WRITE(numout,*) '    Total input of elements from atmospheric supply'
539         WRITE(numout,*) '    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
540         WRITE(numout,*) '    N Supply   : ', nitdepinput*rno3*1E3/1E12*14.,' TgN/yr'
541         WRITE(numout,*) 
542      ENDIF
543      !
544      IF( nn_timing == 1 )  CALL timing_stop('p4z_sbc_init')
545      !
546   END SUBROUTINE p4z_sbc_init
547
548#else
549   !!======================================================================
550   !!  Dummy module :                                   No PISCES bio-model
551   !!======================================================================
552CONTAINS
553   SUBROUTINE p4z_sbc                         ! Empty routine
554   END SUBROUTINE p4z_sbc
555#endif 
556
557   !!======================================================================
558END MODULE p4zsbc
Note: See TracBrowser for help on using the repository browser.