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.
p4zsms.F90 in NEMO/branches/2020/temporary_r4_trunk/src/TOP/PISCES/P4Z – NEMO

source: NEMO/branches/2020/temporary_r4_trunk/src/TOP/PISCES/P4Z/p4zsms.F90 @ 13470

Last change on this file since 13470 was 13470, checked in by smasson, 4 years ago

r4_trunk: second change of DO loops for routines to be merged, see #2523

  • Property svn:keywords set to Id
File size: 26.8 KB
Line 
1MODULE p4zsms
2   !!======================================================================
3   !!                         ***  MODULE p4zsms  ***
4   !! TOP :   PISCES Source Minus Sink manager
5   !!======================================================================
6   !! History :   1.0  !  2004-03 (O. Aumont) Original code
7   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  F90
8   !!----------------------------------------------------------------------
9   !!   p4z_sms        : Time loop of passive tracers sms
10   !!----------------------------------------------------------------------
11   USE oce_trc         ! shared variables between ocean and passive tracers
12   USE trc             ! passive tracers common variables
13   USE trcdta          !
14   USE sms_pisces      ! PISCES Source Minus Sink variables
15   USE p4zbio          ! Biological model
16   USE p4zche          ! Chemical model
17   USE p4zlys          ! Calcite saturation
18   USE p4zflx          ! Gas exchange
19   USE p4zsbc          ! External source of nutrients
20   USE p4zsed          ! Sedimentation
21   USE p4zint          ! time interpolation
22   USE p4zrem          ! remineralisation
23   USE iom             ! I/O manager
24   USE trd_oce         ! Ocean trends variables
25   USE trdtrc          ! TOP trends variables
26   USE sedmodel        ! Sediment model
27   USE prtctl_trc      ! print control for debugging
28
29   IMPLICIT NONE
30   PRIVATE
31
32   PUBLIC   p4z_sms_init   ! called in p4zsms.F90
33   PUBLIC   p4z_sms        ! called in p4zsms.F90
34
35   INTEGER ::    numco2, numnut, numnit      ! logical unit for co2 budget
36   REAL(wp) ::   alkbudget, no3budget, silbudget, ferbudget, po4budget
37   REAL(wp) ::   xfact, xfact1, xfact2, xfact3
38
39   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   xnegtr     ! Array used to indicate negative tracer values
40
41   !!----------------------------------------------------------------------
42   !! NEMO/TOP 4.0 , NEMO Consortium (2018)
43   !! $Id$
44   !! Software governed by the CeCILL license (see ./LICENSE)
45   !!----------------------------------------------------------------------
46CONTAINS
47
48   SUBROUTINE p4z_sms( kt )
49      !!---------------------------------------------------------------------
50      !!                     ***  ROUTINE p4z_sms  ***
51      !!
52      !! ** Purpose :   Managment of the call to Biological sources and sinks
53      !!              routines of PISCES bio-model
54      !!
55      !! ** Method  : - at each new day ...
56      !!              - several calls of bio and sed ???
57      !!              - ...
58      !!---------------------------------------------------------------------
59      !
60      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index     
61      !!
62      INTEGER ::   ji, jj, jk, jnt, jn, jl
63      REAL(wp) ::  ztra
64      CHARACTER (len=25) :: charout
65      REAL(wp), ALLOCATABLE, DIMENSION(:,:    ) :: zw2d
66      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:  ) :: zw3d
67      REAL(wp), DIMENSION(jpi,jpj,jpk,jp_pisces) :: ztrbbio
68
69      !!---------------------------------------------------------------------
70      !
71      IF( ln_timing )   CALL timing_start('p4z_sms')
72      !
73      IF( kt == nittrc000 ) THEN
74        !
75        ALLOCATE( xnegtr(jpi,jpj,jpk) )
76        !
77        IF( .NOT. ln_rsttr ) THEN
78            CALL p4z_che                              ! initialize the chemical constants
79            CALL ahini_for_at(hi)   !  set PH at kt=nit000
80            t_oce_co2_flx_cum = 0._wp
81        ELSE
82            CALL p4z_rst( nittrc000, 'READ' )  !* read or initialize all required fields
83        ENDIF
84        !
85      ENDIF
86      !
87      IF( ln_pisdmp .AND. MOD( kt - nn_dttrc, nn_pisdmp ) == 0 )   CALL p4z_dmp( kt )      ! Relaxation of some tracers
88      !
89      rfact = r2dttrc
90      !
91      IF( ( ln_top_euler .AND. kt == nittrc000 )  .OR. ( .NOT.ln_top_euler .AND. kt <= nittrc000 + nn_dttrc ) ) THEN
92         rfactr  = 1. / rfact
93         rfact2  = rfact / REAL( nrdttrc, wp )
94         rfact2r = 1. / rfact2
95         xstep = rfact2 / rday         ! Time step duration for biology
96         xfact = 1.e+3 * rfact2r
97         IF(lwp) WRITE(numout,*) 
98         IF(lwp) WRITE(numout,*) '    Passive Tracer  time step    rfact  = ', rfact, ' rdt = ', rdt
99         IF(lwp) write(numout,*) '    PISCES  Biology time step    rfact2 = ', rfact2
100         IF(lwp) WRITE(numout,*)
101      ENDIF
102
103      IF( ( neuler == 0 .AND. kt == nittrc000 ) .OR. ln_top_euler ) THEN
104         DO jn = jp_pcs0, jp_pcs1              !   SMS on tracer without Asselin time-filter
105            trb(:,:,:,jn) = trn(:,:,:,jn)
106         END DO
107      ENDIF
108
109      DO jn = jp_pcs0, jp_pcs1              !   Store the tracer concentrations before entering PISCES
110         ztrbbio(:,:,:,jn) = trb(:,:,:,jn)
111      END DO
112
113      !
114      IF( ll_sbc ) CALL p4z_sbc( kt )   ! external sources of nutrients
115      !
116#if ! defined key_sed_off
117      CALL p4z_che              ! computation of chemical constants
118      CALL p4z_int( kt )        ! computation of various rates for biogeochemistry
119      !
120      DO jnt = 1, nrdttrc          ! Potential time splitting if requested
121         !
122         CALL p4z_bio( kt, jnt )   ! Biology
123         CALL p4z_lys( kt, jnt )   ! Compute CaCO3 saturation
124         CALL p4z_sed( kt, jnt )   ! Surface and Bottom boundary conditions
125         CALL p4z_flx( kt, jnt )   ! Compute surface fluxes
126         !
127         xnegtr(:,:,:) = 1.e0
128         DO jn = jp_pcs0, jp_pcs1
129            DO_3D( 1, 1, 1, 1, 1, jpk )
130               IF( ( trb(ji,jj,jk,jn) + tra(ji,jj,jk,jn) ) < 0.e0 ) THEN
131                  ztra             = ABS( trb(ji,jj,jk,jn) ) / ( ABS( tra(ji,jj,jk,jn) ) + rtrn )
132                  xnegtr(ji,jj,jk) = MIN( xnegtr(ji,jj,jk),  ztra )
133               ENDIF
134            END_3D
135         END DO
136         !                                ! where at least 1 tracer concentration becomes negative
137         !                                !
138         DO jn = jp_pcs0, jp_pcs1
139           trb(:,:,:,jn) = trb(:,:,:,jn) + xnegtr(:,:,:) * tra(:,:,:,jn)
140         END DO
141       
142        !
143        IF(  iom_use( 'INTdtAlk' ) .OR. iom_use( 'INTdtDIC' ) .OR. iom_use( 'INTdtFer' ) .OR.  &
144          &  iom_use( 'INTdtDIN' ) .OR. iom_use( 'INTdtDIP' ) .OR. iom_use( 'INTdtSil' ) )  THEN
145          !
146          ALLOCATE( zw3d(jpi,jpj,jpk), zw2d(jpi,jpj) )
147          zw3d(:,:,jpk) = 0.
148          DO jk = 1, jpkm1
149              zw3d(:,:,jk) = xnegtr(:,:,jk) * xfact * e3t_n(:,:,jk) * tmask(:,:,jk)
150          ENDDO
151          !
152          zw2d(:,:) = 0.
153          DO jk = 1, jpkm1
154             zw2d(:,:) = zw2d(:,:) + zw3d(:,:,jk) * tra(:,:,jk,jptal)
155          ENDDO
156          CALL iom_put( 'INTdtAlk', zw2d )
157          !
158          zw2d(:,:) = 0.
159          DO jk = 1, jpkm1
160             zw2d(:,:) = zw2d(:,:) + zw3d(:,:,jk) * tra(:,:,jk,jpdic)
161          ENDDO
162          CALL iom_put( 'INTdtDIC', zw2d )
163          !
164          zw2d(:,:) = 0.
165          DO jk = 1, jpkm1
166             zw2d(:,:) = zw2d(:,:) + zw3d(:,:,jk) * rno3 * ( tra(:,:,jk,jpno3) + tra(:,:,jk,jpnh4) )
167          ENDDO
168          CALL iom_put( 'INTdtDIN', zw2d )
169          !
170          zw2d(:,:) = 0.
171          DO jk = 1, jpkm1
172             zw2d(:,:) = zw2d(:,:) + zw3d(:,:,jk) * po4r * tra(:,:,jk,jppo4)
173          ENDDO
174          CALL iom_put( 'INTdtDIP', zw2d )
175          !
176          zw2d(:,:) = 0.
177          DO jk = 1, jpkm1
178             zw2d(:,:) = zw2d(:,:) + zw3d(:,:,jk) * tra(:,:,jk,jpfer)
179          ENDDO
180          CALL iom_put( 'INTdtFer', zw2d )
181          !
182          zw2d(:,:) = 0.
183          DO jk = 1, jpkm1
184             zw2d(:,:) = zw2d(:,:) + zw3d(:,:,jk) * tra(:,:,jk,jpsil)
185          ENDDO
186          CALL iom_put( 'INTdtSil', zw2d )
187          !
188          DEALLOCATE( zw3d, zw2d )
189        ENDIF
190        !
191        DO jn = jp_pcs0, jp_pcs1
192           tra(:,:,:,jn) = 0._wp
193        END DO
194        !
195      END DO
196      !
197#endif
198      !
199      IF( ln_sediment ) THEN 
200         !
201         CALL sed_model( kt )     !  Main program of Sediment model
202         !
203      ENDIF
204      !
205      DO jn = jp_pcs0, jp_pcs1
206         tra(:,:,:,jn) = ( trb(:,:,:,jn) - ztrbbio(:,:,:,jn) ) * rfactr
207         trb(:,:,:,jn) = ztrbbio(:,:,:,jn)
208         ztrbbio(:,:,:,jn) = 0._wp
209      END DO
210      !
211      IF( l_trdtrc ) THEN
212         DO jn = jp_pcs0, jp_pcs1
213           CALL trd_trc( tra(:,:,:,jn), jn, jptra_sms, kt )   ! save trends
214         END DO
215      END IF
216     
217      IF( lrst_trc )  CALL p4z_rst( kt, 'WRITE' )  !* Write PISCES informations in restart file
218      !
219
220      IF( lk_iomput .OR. ln_check_mass )  CALL p4z_chk_mass( kt )    ! Mass conservation checking
221
222      IF( lwm .AND. kt == nittrc000    )  CALL FLUSH( numonp )       ! flush output namelist PISCES
223      !
224      IF( ln_timing )  CALL timing_stop('p4z_sms')
225      !
226   END SUBROUTINE p4z_sms
227
228
229   SUBROUTINE p4z_sms_init
230      !!----------------------------------------------------------------------
231      !!                     ***  p4z_sms_init  *** 
232      !!
233      !! ** Purpose :   read PISCES namelist
234      !!
235      !! ** input   :   file 'namelist.trc.s' containing the following
236      !!             namelist: natext, natbio, natsms
237      !!----------------------------------------------------------------------
238      INTEGER :: ios                 ! Local integer output status for namelist read
239      !!
240      NAMELIST/nampisbio/ nrdttrc, wsbio, xkmort, ferat3, wsbio2, wsbio2max, wsbio2scale,    &
241         &                   ldocp, ldocz, lthet, no3rat3, po4rat3
242         !
243      NAMELIST/nampisdmp/ ln_pisdmp, nn_pisdmp
244      NAMELIST/nampismass/ ln_check_mass
245      !!----------------------------------------------------------------------
246      !
247      IF(lwp) THEN
248         WRITE(numout,*)
249         WRITE(numout,*) 'p4z_sms_init : PISCES initialization'
250         WRITE(numout,*) '~~~~~~~~~~~~'
251      ENDIF
252
253      REWIND( numnatp_ref )              ! Namelist nampisbio in reference namelist : Pisces variables
254      READ  ( numnatp_ref, nampisbio, IOSTAT = ios, ERR = 901)
255901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampisbio in reference namelist' )
256      REWIND( numnatp_cfg )              ! Namelist nampisbio in configuration namelist : Pisces variables
257      READ  ( numnatp_cfg, nampisbio, IOSTAT = ios, ERR = 902 )
258902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisbio in configuration namelist' )
259      IF(lwm) WRITE( numonp, nampisbio )
260      !
261      IF(lwp) THEN                         ! control print
262         WRITE(numout,*) '   Namelist : nampisbio'
263         WRITE(numout,*) '      frequency for the biology                 nrdttrc     =', nrdttrc
264         WRITE(numout,*) '      POC sinking speed                         wsbio       =', wsbio
265         WRITE(numout,*) '      half saturation constant for mortality    xkmort      =', xkmort 
266         IF( ln_p5z ) THEN
267            WRITE(numout,*) '      N/C in zooplankton                        no3rat3     =', no3rat3
268            WRITE(numout,*) '      P/C in zooplankton                        po4rat3     =', po4rat3
269         ENDIF
270         WRITE(numout,*) '      Fe/C in zooplankton                       ferat3      =', ferat3
271         WRITE(numout,*) '      Big particles sinking speed               wsbio2      =', wsbio2
272         WRITE(numout,*) '      Big particles maximum sinking speed       wsbio2max   =', wsbio2max
273         WRITE(numout,*) '      Big particles sinking speed length scale  wsbio2scale =', wsbio2scale
274         IF( ln_ligand ) THEN
275            IF( ln_p4z ) THEN
276               WRITE(numout,*) '      Phyto ligand production per unit doc           ldocp  =', ldocp
277               WRITE(numout,*) '      Zoo ligand production per unit doc             ldocz  =', ldocz
278               WRITE(numout,*) '      Proportional loss of ligands due to Fe uptake  lthet  =', lthet
279            ENDIF
280         ENDIF
281      ENDIF
282
283
284      REWIND( numnatp_ref )              ! Namelist nampisdmp in reference namelist : Pisces damping
285      READ  ( numnatp_ref, nampisdmp, IOSTAT = ios, ERR = 905)
286905   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampisdmp in reference namelist' )
287      REWIND( numnatp_cfg )              ! Namelist nampisdmp in configuration namelist : Pisces damping
288      READ  ( numnatp_cfg, nampisdmp, IOSTAT = ios, ERR = 906 )
289906   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisdmp in configuration namelist' )
290      IF(lwm) WRITE( numonp, nampisdmp )
291      !
292      IF(lwp) THEN                         ! control print
293         WRITE(numout,*)
294         WRITE(numout,*) '   Namelist : nampisdmp --- relaxation to GLODAP'
295         WRITE(numout,*) '      Relaxation of tracer to glodap mean value   ln_pisdmp =', ln_pisdmp
296         WRITE(numout,*) '      Frequency of Relaxation                     nn_pisdmp =', nn_pisdmp
297      ENDIF
298
299      REWIND( numnatp_ref )              ! Namelist nampismass in reference namelist : Pisces mass conservation check
300      READ  ( numnatp_ref, nampismass, IOSTAT = ios, ERR = 907)
301907   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampismass in reference namelist' )
302      REWIND( numnatp_cfg )              ! Namelist nampismass in configuration namelist : Pisces mass conservation check
303      READ  ( numnatp_cfg, nampismass, IOSTAT = ios, ERR = 908 )
304908   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampismass in configuration namelist' )
305      IF(lwm) WRITE( numonp, nampismass )
306
307      IF(lwp) THEN                         ! control print
308         WRITE(numout,*)
309         WRITE(numout,*) '   Namelist : nampismass  --- mass conservation checking'
310         WRITE(numout,*) '      Flag to check mass conservation of NO3/Si/TALK   ln_check_mass = ', ln_check_mass
311      ENDIF
312      !
313   END SUBROUTINE p4z_sms_init
314
315
316   SUBROUTINE p4z_rst( kt, cdrw )
317      !!---------------------------------------------------------------------
318      !!                   ***  ROUTINE p4z_rst  ***
319      !!
320      !!  ** Purpose : Read or write variables in restart file:
321      !!
322      !!  WRITE(READ) mode:
323      !!       kt        : number of time step since the begining of the experiment at the
324      !!                   end of the current(previous) run
325      !!---------------------------------------------------------------------
326      INTEGER         , INTENT(in) ::   kt         ! ocean time-step
327      CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag
328      !!---------------------------------------------------------------------
329      !
330      IF( TRIM(cdrw) == 'READ' ) THEN
331         !
332         IF(lwp) WRITE(numout,*)
333         IF(lwp) WRITE(numout,*) ' p4z_rst : Read specific variables from pisces model '
334         IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
335         !
336         IF( iom_varid( numrtr, 'PH', ldstop = .FALSE. ) > 0 ) THEN
337            CALL iom_get( numrtr, jpdom_autoglo, 'PH' , hi(:,:,:)  )
338         ELSE
339            CALL p4z_che                              ! initialize the chemical constants
340            CALL ahini_for_at(hi)
341         ENDIF
342         CALL iom_get( numrtr, jpdom_autoglo, 'Silicalim', xksi(:,:) )
343         IF( iom_varid( numrtr, 'Silicamax', ldstop = .FALSE. ) > 0 ) THEN
344            CALL iom_get( numrtr, jpdom_autoglo, 'Silicamax' , xksimax(:,:)  )
345         ELSE
346            xksimax(:,:) = xksi(:,:)
347         ENDIF
348         !
349         IF( iom_varid( numrtr, 'tcflxcum', ldstop = .FALSE. ) > 0 ) THEN  ! cumulative total flux of carbon
350            CALL iom_get( numrtr, 'tcflxcum' , t_oce_co2_flx_cum  )
351         ELSE
352            t_oce_co2_flx_cum = 0._wp
353         ENDIF
354         !
355         IF( ln_p5z ) THEN
356            IF( iom_varid( numrtr, 'sized', ldstop = .FALSE. ) > 0 ) THEN
357               CALL iom_get( numrtr, jpdom_autoglo, 'sizep' , sizep(:,:,:)  )
358               CALL iom_get( numrtr, jpdom_autoglo, 'sizen' , sizen(:,:,:)  )
359               CALL iom_get( numrtr, jpdom_autoglo, 'sized' , sized(:,:,:)  )
360            ELSE
361               sizep(:,:,:) = 1.
362               sizen(:,:,:) = 1.
363               sized(:,:,:) = 1.
364            ENDIF
365        ENDIF
366        !
367      ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN
368         IF( kt == nitrst ) THEN
369            IF(lwp) WRITE(numout,*)
370            IF(lwp) WRITE(numout,*) 'p4z_rst : write pisces restart file  kt =', kt
371            IF(lwp) WRITE(numout,*) '~~~~~~~'
372         ENDIF
373         CALL iom_rstput( kt, nitrst, numrtw, 'PH', hi(:,:,:) )
374         CALL iom_rstput( kt, nitrst, numrtw, 'Silicalim', xksi(:,:) )
375         CALL iom_rstput( kt, nitrst, numrtw, 'Silicamax', xksimax(:,:) )
376         CALL iom_rstput( kt, nitrst, numrtw, 'tcflxcum', t_oce_co2_flx_cum )
377         IF( ln_p5z ) THEN
378            CALL iom_rstput( kt, nitrst, numrtw, 'sizep', sizep(:,:,:) )
379            CALL iom_rstput( kt, nitrst, numrtw, 'sizen', sizen(:,:,:) )
380            CALL iom_rstput( kt, nitrst, numrtw, 'sized', sized(:,:,:) )
381         ENDIF
382      ENDIF
383      !
384   END SUBROUTINE p4z_rst
385
386
387   SUBROUTINE p4z_dmp( kt )
388      !!----------------------------------------------------------------------
389      !!                    ***  p4z_dmp  ***
390      !!
391      !! ** purpose  : Relaxation of some tracers
392      !!----------------------------------------------------------------------
393      !
394      INTEGER, INTENT( in )  ::     kt ! time step
395      !
396      REAL(wp) ::  alkmean = 2426.     ! mean value of alkalinity ( Glodap ; for Goyet 2391. )
397      REAL(wp) ::  po4mean = 2.165     ! mean value of phosphates
398      REAL(wp) ::  no3mean = 30.90     ! mean value of nitrate
399      REAL(wp) ::  silmean = 91.51     ! mean value of silicate
400      !
401      REAL(wp) :: zarea, zalksumn, zpo4sumn, zno3sumn, zsilsumn
402      REAL(wp) :: zalksumb, zpo4sumb, zno3sumb, zsilsumb
403      !!---------------------------------------------------------------------
404
405      IF(lwp)  WRITE(numout,*)
406      IF(lwp)  WRITE(numout,*) ' p4z_dmp : Restoring of nutrients at time-step kt = ', kt
407      IF(lwp)  WRITE(numout,*)
408
409      IF( cn_cfg == "ORCA" .OR. cn_cfg == "orca") THEN
410         IF( .NOT. lk_c1d ) THEN      ! ORCA configuration (not 1D) !
411            !                                                ! --------------------------- !
412            ! set total alkalinity, phosphate, nitrate & silicate
413            zarea          = 1._wp / glob_sum( 'p4zsms', cvol(:,:,:) ) * 1e6             
414
415            zalksumn = glob_sum( 'p4zsms', trn(:,:,:,jptal) * cvol(:,:,:)  ) * zarea
416            zpo4sumn = glob_sum( 'p4zsms', trn(:,:,:,jppo4) * cvol(:,:,:)  ) * zarea * po4r
417            zno3sumn = glob_sum( 'p4zsms', trn(:,:,:,jpno3) * cvol(:,:,:)  ) * zarea * rno3
418            zsilsumn = glob_sum( 'p4zsms', trn(:,:,:,jpsil) * cvol(:,:,:)  ) * zarea
419 
420            IF(lwp) WRITE(numout,*) '       TALKN mean : ', zalksumn
421            trn(:,:,:,jptal) = trn(:,:,:,jptal) * alkmean / zalksumn
422
423            IF(lwp) WRITE(numout,*) '       PO4N  mean : ', zpo4sumn
424            trn(:,:,:,jppo4) = trn(:,:,:,jppo4) * po4mean / zpo4sumn
425
426            IF(lwp) WRITE(numout,*) '       NO3N  mean : ', zno3sumn
427            trn(:,:,:,jpno3) = trn(:,:,:,jpno3) * no3mean / zno3sumn
428
429            IF(lwp) WRITE(numout,*) '       SiO3N mean : ', zsilsumn
430            trn(:,:,:,jpsil) = MIN( 400.e-6,trn(:,:,:,jpsil) * silmean / zsilsumn )
431            !
432            !
433            IF( .NOT. ln_top_euler ) THEN
434               zalksumb = glob_sum( 'p4zsms', trb(:,:,:,jptal) * cvol(:,:,:)  ) * zarea
435               zpo4sumb = glob_sum( 'p4zsms', trb(:,:,:,jppo4) * cvol(:,:,:)  ) * zarea * po4r
436               zno3sumb = glob_sum( 'p4zsms', trb(:,:,:,jpno3) * cvol(:,:,:)  ) * zarea * rno3
437               zsilsumb = glob_sum( 'p4zsms', trb(:,:,:,jpsil) * cvol(:,:,:)  ) * zarea
438 
439               IF(lwp) WRITE(numout,*) ' '
440               IF(lwp) WRITE(numout,*) '       TALKB mean : ', zalksumb
441               trb(:,:,:,jptal) = trb(:,:,:,jptal) * alkmean / zalksumb
442
443               IF(lwp) WRITE(numout,*) '       PO4B  mean : ', zpo4sumb
444               trb(:,:,:,jppo4) = trb(:,:,:,jppo4) * po4mean / zpo4sumb
445
446               IF(lwp) WRITE(numout,*) '       NO3B  mean : ', zno3sumb
447               trb(:,:,:,jpno3) = trb(:,:,:,jpno3) * no3mean / zno3sumb
448
449               IF(lwp) WRITE(numout,*) '       SiO3B mean : ', zsilsumb
450               trb(:,:,:,jpsil) = MIN( 400.e-6,trb(:,:,:,jpsil) * silmean / zsilsumb )
451           ENDIF
452        ENDIF
453        !
454      ENDIF
455        !
456   END SUBROUTINE p4z_dmp
457
458
459   SUBROUTINE p4z_chk_mass( kt )
460      !!----------------------------------------------------------------------
461      !!                  ***  ROUTINE p4z_chk_mass  ***
462      !!
463      !! ** Purpose :  Mass conservation check
464      !!
465      !!---------------------------------------------------------------------
466      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index     
467      REAL(wp)             ::  zrdenittot, zsdenittot, znitrpottot
468      CHARACTER(LEN=100)   ::   cltxt
469      INTEGER :: jk
470      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zwork
471      !!----------------------------------------------------------------------
472      !
473      IF( kt == nittrc000 ) THEN
474         xfact1 = rfact2r * 12. / 1.e15 * ryyss    ! conversion molC/kt --> PgC/yr
475         xfact2 = 1.e+3 * rno3 * 14. / 1.e12 * ryyss   ! conversion molC/l/s ----> TgN/m3/yr
476         xfact3 = 1.e+3 * rfact2r * rno3   ! conversion molC/l/kt ----> molN/m3/s
477         IF( ln_check_mass .AND. lwp) THEN      !   Open budget file of NO3, ALK, Si, Fer
478            CALL ctl_opn( numco2, 'carbon.budget'  , 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
479            CALL ctl_opn( numnut, 'nutrient.budget', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
480            CALL ctl_opn( numnit, 'nitrogen.budget', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
481            cltxt='time-step   Alkalinity        Nitrate        Phosphorus         Silicate           Iron'
482            IF( lwp ) WRITE(numnut,*)  TRIM(cltxt)
483            IF( lwp ) WRITE(numnut,*) 
484         ENDIF
485      ENDIF
486
487      IF( iom_use( "pno3tot" ) .OR. ( ln_check_mass .AND. kt == nitend )  ) THEN
488         !   Compute the budget of NO3, ALK, Si, Fer
489         IF( ln_p4z ) THEN
490            zwork(:,:,:) =    trn(:,:,:,jpno3) + trn(:,:,:,jpnh4)                      &
491               &          +   trn(:,:,:,jpphy) + trn(:,:,:,jpdia)                      &
492               &          +   trn(:,:,:,jppoc) + trn(:,:,:,jpgoc)  + trn(:,:,:,jpdoc)  &       
493               &          +   trn(:,:,:,jpzoo) + trn(:,:,:,jpmes) 
494        ELSE
495            zwork(:,:,:) =    trn(:,:,:,jpno3) + trn(:,:,:,jpnh4) + trn(:,:,:,jpnph)   &
496               &          +   trn(:,:,:,jpndi) + trn(:,:,:,jpnpi)                      & 
497               &          +   trn(:,:,:,jppon) + trn(:,:,:,jpgon) + trn(:,:,:,jpdon)   &
498               &          + ( trn(:,:,:,jpzoo) + trn(:,:,:,jpmes) ) * no3rat3 
499        ENDIF
500        !
501        no3budget = glob_sum( 'p4zsms', zwork(:,:,:) * cvol(:,:,:)  ) 
502        no3budget = no3budget / areatot
503        CALL iom_put( "pno3tot", no3budget )
504      ENDIF
505      !
506      IF( iom_use( "ppo4tot" ) .OR. ( ln_check_mass .AND. kt == nitend )  ) THEN
507         IF( ln_p4z ) THEN
508            zwork(:,:,:) =    trn(:,:,:,jppo4)                                         &
509               &          +   trn(:,:,:,jpphy) + trn(:,:,:,jpdia)                      &
510               &          +   trn(:,:,:,jppoc) + trn(:,:,:,jpgoc)  + trn(:,:,:,jpdoc)  &       
511               &          +   trn(:,:,:,jpzoo) + trn(:,:,:,jpmes) 
512        ELSE
513            zwork(:,:,:) =    trn(:,:,:,jppo4) + trn(:,:,:,jppph)                      &
514               &          +   trn(:,:,:,jppdi) + trn(:,:,:,jpppi)                      & 
515               &          +   trn(:,:,:,jppop) + trn(:,:,:,jpgop) + trn(:,:,:,jpdop)   &
516               &          + ( trn(:,:,:,jpzoo) + trn(:,:,:,jpmes) ) * po4rat3 
517        ENDIF
518        !
519        po4budget = glob_sum( 'p4zsms', zwork(:,:,:) * cvol(:,:,:)  ) 
520        po4budget = po4budget / areatot
521        CALL iom_put( "ppo4tot", po4budget )
522      ENDIF
523      !
524      IF( iom_use( "psiltot" ) .OR. ( ln_check_mass .AND. kt == nitend )  ) THEN
525         zwork(:,:,:) =  trn(:,:,:,jpsil) + trn(:,:,:,jpgsi) + trn(:,:,:,jpdsi) 
526         !
527         silbudget = glob_sum( 'p4zsms', zwork(:,:,:) * cvol(:,:,:)  ) 
528         silbudget = silbudget / areatot
529         CALL iom_put( "psiltot", silbudget )
530      ENDIF
531      !
532      IF( iom_use( "palktot" ) .OR. ( ln_check_mass .AND. kt == nitend )  ) THEN
533         zwork(:,:,:) =  trn(:,:,:,jpno3) * rno3 + trn(:,:,:,jptal) + trn(:,:,:,jpcal) * 2.             
534         !
535         alkbudget = glob_sum( 'p4zsms', zwork(:,:,:) * cvol(:,:,:)  )         !
536         alkbudget = alkbudget / areatot
537         CALL iom_put( "palktot", alkbudget )
538      ENDIF
539      !
540      IF( iom_use( "pfertot" ) .OR. ( ln_check_mass .AND. kt == nitend )  ) THEN
541         zwork(:,:,:) =   trn(:,:,:,jpfer) + trn(:,:,:,jpnfe) + trn(:,:,:,jpdfe)   &
542            &         +   trn(:,:,:,jpbfe) + trn(:,:,:,jpsfe)                      &
543            &         + ( trn(:,:,:,jpzoo) + trn(:,:,:,jpmes) )  * ferat3   
544         !
545         ferbudget = glob_sum( 'p4zsms', zwork(:,:,:) * cvol(:,:,:)  ) 
546         ferbudget = ferbudget / areatot
547         CALL iom_put( "pfertot", ferbudget )
548      ENDIF
549      !
550      ! Global budget of N SMS : denitrification in the water column and in the sediment
551      !                          nitrogen fixation by the diazotrophs
552      ! --------------------------------------------------------------------------------
553      IF( iom_use( "tnfix" ) .OR.  ( ln_check_mass .AND. kt == nitend )  ) THEN
554         znitrpottot  = glob_sum ( 'p4zsms', nitrpot(:,:,:) * nitrfix * cvol(:,:,:) )
555         CALL iom_put( "tnfix"  , znitrpottot * xfact3 )  ! Global  nitrogen fixation molC/l  to molN/m3
556      ENDIF
557      !
558      IF( iom_use( "tdenit" ) .OR.  ( ln_check_mass .AND. kt == nitend )  ) THEN
559         zrdenittot = glob_sum ( 'p4zsms', denitr(:,:,:) * rdenit * xnegtr(:,:,:) * cvol(:,:,:) )
560         zsdenittot = glob_sum ( 'p4zsms', sdenit(:,:) * e1e2t(:,:) * tmask(:,:,1) )
561         CALL iom_put( "tdenit" , ( zrdenittot + zsdenittot ) * xfact3 )  ! Total denitrification molC/l to molN/m3
562      ENDIF
563      !
564      IF( ln_check_mass .AND. kt == nitend ) THEN   ! Compute the budget of NO3, ALK, Si, Fer
565         t_atm_co2_flx  = t_atm_co2_flx / glob_sum( 'p4zsms', e1e2t(:,:) )
566         t_oce_co2_flx  = t_oce_co2_flx         * xfact1 * (-1 )
567         tpp            = tpp           * 1000. * xfact1
568         t_oce_co2_exp  = t_oce_co2_exp * 1000. * xfact1
569         IF( lwp ) WRITE(numco2,9000) ndastp, t_atm_co2_flx, t_oce_co2_flx, tpp, t_oce_co2_exp
570         IF( lwp ) WRITE(numnut,9100) ndastp, alkbudget        * 1.e+06, &
571             &                                no3budget * rno3 * 1.e+06, &
572             &                                po4budget * po4r * 1.e+06, &
573             &                                silbudget        * 1.e+06, &
574             &                                ferbudget        * 1.e+09
575         !
576         IF( lwp ) WRITE(numnit,9200) ndastp, znitrpottot * xfact2  , &
577            &                             zrdenittot  * xfact2  , &
578            &                             zsdenittot  * xfact2
579      ENDIF
580      !
581 9000  FORMAT(i8,f10.5,e18.10,f10.5,f10.5)
582 9100  FORMAT(i8,5e18.10)
583 9200  FORMAT(i8,3f10.5)
584       !
585   END SUBROUTINE p4z_chk_mass
586
587   !!======================================================================
588END MODULE p4zsms 
Note: See TracBrowser for help on using the repository browser.