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/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/TOP/PISCES/P4Z – NEMO

source: NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/TOP/PISCES/P4Z/p4zsbc.F90 @ 10368

Last change on this file since 10368 was 10368, checked in by smasson, 5 years ago

dev_r10164_HPC09_ESIWACE_PREP_MERGE: merge with trunk@10365, see #2133

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