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

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
p4zsbc.F90 in NEMO/branches/2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps/src/TOP/PISCES/P4Z – NEMO

source: NEMO/branches/2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps/src/TOP/PISCES/P4Z/p4zsbc.F90 @ 11504

Last change on this file since 11504 was 10975, checked in by acc, 5 years ago

2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps : Finish converting all TOP routines and knock-on effects of these conversions. Fully SETTE tested (SETTE tests 1-6 and 9). This completes the first stage conversion of TRA and TOP but need to revisit and pass ts and tr arrays through the argument lists where appropriate.

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