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 NEMO/branches/2019/dev_r11943_MERGE_2019/src/TOP/PISCES/P4Z – NEMO

source: NEMO/branches/2019/dev_r11943_MERGE_2019/src/TOP/PISCES/P4Z/p4zsbc.F90 @ 11949

Last change on this file since 11949 was 11949, checked in by acc, 4 years ago

Merge in changes from 2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps. This just creates a fresh copy of this branch to use as the merge base. See ticket #2341

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