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/CNRS/dev_r8832_PISCO/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z – NEMO

source: branches/CNRS/dev_r8832_PISCO/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsbc.F90 @ 9450

Last change on this file since 9450 was 9450, checked in by aumont, 6 years ago

debug PISCES code

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