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

source: branches/CNRS/dev_r6270_PISCES_QUOTA/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsbc.F90 @ 7617

Last change on this file since 7617 was 7617, checked in by aumont, 7 years ago

update diagnostics + changes in quota code

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