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/2019/dev_r11085_ASINTER-05_Brodeau_Advanced_Bulk/src/TOP/PISCES/P4Z – NEMO

source: NEMO/branches/2019/dev_r11085_ASINTER-05_Brodeau_Advanced_Bulk/src/TOP/PISCES/P4Z/p4zsms.F90 @ 11831

Last change on this file since 11831 was 11831, checked in by laurent, 4 years ago

Update the branch to r11830 of the trunk!

  • Property svn:keywords set to Id
File size: 25.0 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) ::   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      !!---------------------------------------------------------------------
66      !
67      IF( ln_timing )   CALL timing_start('p4z_sms')
68      !
69      IF( kt == nittrc000 ) THEN
70        !
71        ALLOCATE( xnegtr(jpi,jpj,jpk) )
72        !
73        IF( .NOT. ln_rsttr ) THEN
74            CALL p4z_che                              ! initialize the chemical constants
75            CALL ahini_for_at(hi)   !  set PH at kt=nit000
76            t_oce_co2_flx_cum = 0._wp
77        ELSE
78            CALL p4z_rst( nittrc000, 'READ' )  !* read or initialize all required fields
79        ENDIF
80        !
81      ENDIF
82      !
83      IF( ln_pisdmp .AND. MOD( kt - nn_dttrc, nn_pisdmp ) == 0 )   CALL p4z_dmp( kt )      ! Relaxation of some tracers
84      !
85      rfact = r2dttrc
86      !
87      IF( ( ln_top_euler .AND. kt == nittrc000 )  .OR. ( .NOT.ln_top_euler .AND. kt <= nittrc000 + nn_dttrc ) ) THEN
88         rfactr  = 1. / rfact
89         rfact2  = rfact / REAL( nrdttrc, wp )
90         rfact2r = 1. / rfact2
91         xstep = rfact2 / rday         ! Time step duration for biology
92         IF(lwp) WRITE(numout,*) 
93         IF(lwp) WRITE(numout,*) '    Passive Tracer  time step    rfact  = ', rfact, ' rdt = ', rdt
94         IF(lwp) write(numout,*) '    PISCES  Biology time step    rfact2 = ', rfact2
95         IF(lwp) WRITE(numout,*)
96      ENDIF
97
98      IF( ( neuler == 0 .AND. kt == nittrc000 ) .OR. ln_top_euler ) THEN
99         DO jn = jp_pcs0, jp_pcs1              !   SMS on tracer without Asselin time-filter
100            trb(:,:,:,jn) = trn(:,:,:,jn)
101         END DO
102      ENDIF
103      !
104      IF( ll_sbc ) CALL p4z_sbc( kt )   ! external sources of nutrients
105      !
106#if ! defined key_sed_off
107      CALL p4z_che              ! computation of chemical constants
108      CALL p4z_int( kt )        ! computation of various rates for biogeochemistry
109      !
110      DO jnt = 1, nrdttrc          ! Potential time splitting if requested
111         !
112         CALL p4z_bio( kt, jnt )   ! Biology
113         CALL p4z_lys( kt, jnt )   ! Compute CaCO3 saturation
114         CALL p4z_sed( kt, jnt )   ! Surface and Bottom boundary conditions
115         CALL p4z_flx( kt, jnt )   ! Compute surface fluxes
116         !
117         xnegtr(:,:,:) = 1.e0
118         DO jn = jp_pcs0, jp_pcs1
119            DO jk = 1, jpk
120               DO jj = 1, jpj
121                  DO ji = 1, jpi
122                     IF( ( trb(ji,jj,jk,jn) + tra(ji,jj,jk,jn) ) < 0.e0 ) THEN
123                        ztra             = ABS( trb(ji,jj,jk,jn) ) / ( ABS( tra(ji,jj,jk,jn) ) + rtrn )
124                        xnegtr(ji,jj,jk) = MIN( xnegtr(ji,jj,jk),  ztra )
125                     ENDIF
126                 END DO
127               END DO
128            END DO
129         END DO
130         !                                ! where at least 1 tracer concentration becomes negative
131         !                                !
132         DO jn = jp_pcs0, jp_pcs1
133           trb(:,:,:,jn) = trb(:,:,:,jn) + xnegtr(:,:,:) * tra(:,:,:,jn)
134         END DO
135        !
136         DO jn = jp_pcs0, jp_pcs1
137            tra(:,:,:,jn) = 0._wp
138         END DO
139         !
140         IF( ln_top_euler ) THEN
141            DO jn = jp_pcs0, jp_pcs1
142               trn(:,:,:,jn) = trb(:,:,:,jn)
143            END DO
144         ENDIF
145      END DO
146
147      !
148      IF( l_trdtrc ) THEN
149         DO jn = jp_pcs0, jp_pcs1
150           CALL trd_trc( tra(:,:,:,jn), jn, jptra_sms, kt )   ! save trends
151         END DO
152      END IF
153#endif
154      !
155      IF( ln_sediment ) THEN 
156         !
157         CALL sed_model( kt )     !  Main program of Sediment model
158         !
159         IF( ln_top_euler ) THEN
160            DO jn = jp_pcs0, jp_pcs1
161               trn(:,:,:,jn) = trb(:,:,:,jn)
162            END DO
163         ENDIF
164         !
165      ENDIF
166      !
167      IF( lrst_trc )  CALL p4z_rst( kt, 'WRITE' )  !* Write PISCES informations in restart file
168      !
169
170      IF( lk_iomput .OR. ln_check_mass )  CALL p4z_chk_mass( kt )    ! Mass conservation checking
171
172      IF( lwm .AND. kt == nittrc000    )  CALL FLUSH( numonp )       ! flush output namelist PISCES
173      !
174      IF( ln_timing )  CALL timing_stop('p4z_sms')
175      !
176   END SUBROUTINE p4z_sms
177
178
179   SUBROUTINE p4z_sms_init
180      !!----------------------------------------------------------------------
181      !!                     ***  p4z_sms_init  *** 
182      !!
183      !! ** Purpose :   read PISCES namelist
184      !!
185      !! ** input   :   file 'namelist.trc.s' containing the following
186      !!             namelist: natext, natbio, natsms
187      !!----------------------------------------------------------------------
188      INTEGER :: ios                 ! Local integer output status for namelist read
189      !!
190      NAMELIST/nampisbio/ nrdttrc, wsbio, xkmort, ferat3, wsbio2, wsbio2max, wsbio2scale,    &
191         &                   ldocp, ldocz, lthet, no3rat3, po4rat3
192         !
193      NAMELIST/nampisdmp/ ln_pisdmp, nn_pisdmp
194      NAMELIST/nampismass/ ln_check_mass
195      !!----------------------------------------------------------------------
196      !
197      IF(lwp) THEN
198         WRITE(numout,*)
199         WRITE(numout,*) 'p4z_sms_init : PISCES initialization'
200         WRITE(numout,*) '~~~~~~~~~~~~'
201      ENDIF
202
203      REWIND( numnatp_ref )              ! Namelist nampisbio in reference namelist : Pisces variables
204      READ  ( numnatp_ref, nampisbio, IOSTAT = ios, ERR = 901)
205901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampisbio in reference namelist' )
206      REWIND( numnatp_cfg )              ! Namelist nampisbio in configuration namelist : Pisces variables
207      READ  ( numnatp_cfg, nampisbio, IOSTAT = ios, ERR = 902 )
208902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisbio in configuration namelist' )
209      IF(lwm) WRITE( numonp, nampisbio )
210      !
211      IF(lwp) THEN                         ! control print
212         WRITE(numout,*) '   Namelist : nampisbio'
213         WRITE(numout,*) '      frequency for the biology                 nrdttrc     =', nrdttrc
214         WRITE(numout,*) '      POC sinking speed                         wsbio       =', wsbio
215         WRITE(numout,*) '      half saturation constant for mortality    xkmort      =', xkmort 
216         IF( ln_p5z ) THEN
217            WRITE(numout,*) '      N/C in zooplankton                        no3rat3     =', no3rat3
218            WRITE(numout,*) '      P/C in zooplankton                        po4rat3     =', po4rat3
219         ENDIF
220         WRITE(numout,*) '      Fe/C in zooplankton                       ferat3      =', ferat3
221         WRITE(numout,*) '      Big particles sinking speed               wsbio2      =', wsbio2
222         WRITE(numout,*) '      Big particles maximum sinking speed       wsbio2max   =', wsbio2max
223         WRITE(numout,*) '      Big particles sinking speed length scale  wsbio2scale =', wsbio2scale
224         IF( ln_ligand ) THEN
225            IF( ln_p4z ) THEN
226               WRITE(numout,*) '      Phyto ligand production per unit doc           ldocp  =', ldocp
227               WRITE(numout,*) '      Zoo ligand production per unit doc             ldocz  =', ldocz
228               WRITE(numout,*) '      Proportional loss of ligands due to Fe uptake  lthet  =', lthet
229            ENDIF
230         ENDIF
231      ENDIF
232
233
234      REWIND( numnatp_ref )              ! Namelist nampisdmp in reference namelist : Pisces damping
235      READ  ( numnatp_ref, nampisdmp, IOSTAT = ios, ERR = 905)
236905   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampisdmp in reference namelist' )
237      REWIND( numnatp_cfg )              ! Namelist nampisdmp in configuration namelist : Pisces damping
238      READ  ( numnatp_cfg, nampisdmp, IOSTAT = ios, ERR = 906 )
239906   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisdmp in configuration namelist' )
240      IF(lwm) WRITE( numonp, nampisdmp )
241      !
242      IF(lwp) THEN                         ! control print
243         WRITE(numout,*)
244         WRITE(numout,*) '   Namelist : nampisdmp --- relaxation to GLODAP'
245         WRITE(numout,*) '      Relaxation of tracer to glodap mean value   ln_pisdmp =', ln_pisdmp
246         WRITE(numout,*) '      Frequency of Relaxation                     nn_pisdmp =', nn_pisdmp
247      ENDIF
248
249      REWIND( numnatp_ref )              ! Namelist nampismass in reference namelist : Pisces mass conservation check
250      READ  ( numnatp_ref, nampismass, IOSTAT = ios, ERR = 907)
251907   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampismass in reference namelist' )
252      REWIND( numnatp_cfg )              ! Namelist nampismass in configuration namelist : Pisces mass conservation check
253      READ  ( numnatp_cfg, nampismass, IOSTAT = ios, ERR = 908 )
254908   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampismass in configuration namelist' )
255      IF(lwm) WRITE( numonp, nampismass )
256
257      IF(lwp) THEN                         ! control print
258         WRITE(numout,*)
259         WRITE(numout,*) '   Namelist : nampismass  --- mass conservation checking'
260         WRITE(numout,*) '      Flag to check mass conservation of NO3/Si/TALK   ln_check_mass = ', ln_check_mass
261      ENDIF
262      !
263   END SUBROUTINE p4z_sms_init
264
265
266   SUBROUTINE p4z_rst( kt, cdrw )
267      !!---------------------------------------------------------------------
268      !!                   ***  ROUTINE p4z_rst  ***
269      !!
270      !!  ** Purpose : Read or write variables in restart file:
271      !!
272      !!  WRITE(READ) mode:
273      !!       kt        : number of time step since the begining of the experiment at the
274      !!                   end of the current(previous) run
275      !!---------------------------------------------------------------------
276      INTEGER         , INTENT(in) ::   kt         ! ocean time-step
277      CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag
278      !!---------------------------------------------------------------------
279      !
280      IF( TRIM(cdrw) == 'READ' ) THEN
281         !
282         IF(lwp) WRITE(numout,*)
283         IF(lwp) WRITE(numout,*) ' p4z_rst : Read specific variables from pisces model '
284         IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
285         !
286         IF( iom_varid( numrtr, 'PH', ldstop = .FALSE. ) > 0 ) THEN
287            CALL iom_get( numrtr, jpdom_autoglo, 'PH' , hi(:,:,:)  )
288         ELSE
289            CALL p4z_che                              ! initialize the chemical constants
290            CALL ahini_for_at(hi)
291         ENDIF
292         CALL iom_get( numrtr, jpdom_autoglo, 'Silicalim', xksi(:,:) )
293         IF( iom_varid( numrtr, 'Silicamax', ldstop = .FALSE. ) > 0 ) THEN
294            CALL iom_get( numrtr, jpdom_autoglo, 'Silicamax' , xksimax(:,:)  )
295         ELSE
296            xksimax(:,:) = xksi(:,:)
297         ENDIF
298         !
299         IF( iom_varid( numrtr, 'tcflxcum', ldstop = .FALSE. ) > 0 ) THEN  ! cumulative total flux of carbon
300            CALL iom_get( numrtr, 'tcflxcum' , t_oce_co2_flx_cum  )
301         ELSE
302            t_oce_co2_flx_cum = 0._wp
303         ENDIF
304         !
305         IF( ln_p5z ) THEN
306            IF( iom_varid( numrtr, 'sized', ldstop = .FALSE. ) > 0 ) THEN
307               CALL iom_get( numrtr, jpdom_autoglo, 'sizep' , sizep(:,:,:)  )
308               CALL iom_get( numrtr, jpdom_autoglo, 'sizen' , sizen(:,:,:)  )
309               CALL iom_get( numrtr, jpdom_autoglo, 'sized' , sized(:,:,:)  )
310            ELSE
311               sizep(:,:,:) = 1.
312               sizen(:,:,:) = 1.
313               sized(:,:,:) = 1.
314            ENDIF
315        ENDIF
316        !
317      ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN
318         IF( kt == nitrst ) THEN
319            IF(lwp) WRITE(numout,*)
320            IF(lwp) WRITE(numout,*) 'p4z_rst : write pisces restart file  kt =', kt
321            IF(lwp) WRITE(numout,*) '~~~~~~~'
322         ENDIF
323         CALL iom_rstput( kt, nitrst, numrtw, 'PH', hi(:,:,:) )
324         CALL iom_rstput( kt, nitrst, numrtw, 'Silicalim', xksi(:,:) )
325         CALL iom_rstput( kt, nitrst, numrtw, 'Silicamax', xksimax(:,:) )
326         CALL iom_rstput( kt, nitrst, numrtw, 'tcflxcum', t_oce_co2_flx_cum )
327         IF( ln_p5z ) THEN
328            CALL iom_rstput( kt, nitrst, numrtw, 'sizep', sizep(:,:,:) )
329            CALL iom_rstput( kt, nitrst, numrtw, 'sizen', sizen(:,:,:) )
330            CALL iom_rstput( kt, nitrst, numrtw, 'sized', sized(:,:,:) )
331         ENDIF
332      ENDIF
333      !
334   END SUBROUTINE p4z_rst
335
336
337   SUBROUTINE p4z_dmp( kt )
338      !!----------------------------------------------------------------------
339      !!                    ***  p4z_dmp  ***
340      !!
341      !! ** purpose  : Relaxation of some tracers
342      !!----------------------------------------------------------------------
343      !
344      INTEGER, INTENT( in )  ::     kt ! time step
345      !
346      REAL(wp) ::  alkmean = 2426.     ! mean value of alkalinity ( Glodap ; for Goyet 2391. )
347      REAL(wp) ::  po4mean = 2.165     ! mean value of phosphates
348      REAL(wp) ::  no3mean = 30.90     ! mean value of nitrate
349      REAL(wp) ::  silmean = 91.51     ! mean value of silicate
350      !
351      REAL(wp) :: zarea, zalksumn, zpo4sumn, zno3sumn, zsilsumn
352      REAL(wp) :: zalksumb, zpo4sumb, zno3sumb, zsilsumb
353      !!---------------------------------------------------------------------
354
355      IF(lwp)  WRITE(numout,*)
356      IF(lwp)  WRITE(numout,*) ' p4z_dmp : Restoring of nutrients at time-step kt = ', kt
357      IF(lwp)  WRITE(numout,*)
358
359      IF( cn_cfg == "ORCA" .OR. cn_cfg == "orca") THEN
360         IF( .NOT. lk_c1d ) THEN      ! ORCA configuration (not 1D) !
361            !                                                ! --------------------------- !
362            ! set total alkalinity, phosphate, nitrate & silicate
363            zarea          = 1._wp / glob_sum( 'p4zsms', cvol(:,:,:) ) * 1e6             
364
365            zalksumn = glob_sum( 'p4zsms', trn(:,:,:,jptal) * cvol(:,:,:)  ) * zarea
366            zpo4sumn = glob_sum( 'p4zsms', trn(:,:,:,jppo4) * cvol(:,:,:)  ) * zarea * po4r
367            zno3sumn = glob_sum( 'p4zsms', trn(:,:,:,jpno3) * cvol(:,:,:)  ) * zarea * rno3
368            zsilsumn = glob_sum( 'p4zsms', trn(:,:,:,jpsil) * cvol(:,:,:)  ) * zarea
369 
370            IF(lwp) WRITE(numout,*) '       TALKN mean : ', zalksumn
371            trn(:,:,:,jptal) = trn(:,:,:,jptal) * alkmean / zalksumn
372
373            IF(lwp) WRITE(numout,*) '       PO4N  mean : ', zpo4sumn
374            trn(:,:,:,jppo4) = trn(:,:,:,jppo4) * po4mean / zpo4sumn
375
376            IF(lwp) WRITE(numout,*) '       NO3N  mean : ', zno3sumn
377            trn(:,:,:,jpno3) = trn(:,:,:,jpno3) * no3mean / zno3sumn
378
379            IF(lwp) WRITE(numout,*) '       SiO3N mean : ', zsilsumn
380            trn(:,:,:,jpsil) = MIN( 400.e-6,trn(:,:,:,jpsil) * silmean / zsilsumn )
381            !
382            !
383            IF( .NOT. ln_top_euler ) THEN
384               zalksumb = glob_sum( 'p4zsms', trb(:,:,:,jptal) * cvol(:,:,:)  ) * zarea
385               zpo4sumb = glob_sum( 'p4zsms', trb(:,:,:,jppo4) * cvol(:,:,:)  ) * zarea * po4r
386               zno3sumb = glob_sum( 'p4zsms', trb(:,:,:,jpno3) * cvol(:,:,:)  ) * zarea * rno3
387               zsilsumb = glob_sum( 'p4zsms', trb(:,:,:,jpsil) * cvol(:,:,:)  ) * zarea
388 
389               IF(lwp) WRITE(numout,*) ' '
390               IF(lwp) WRITE(numout,*) '       TALKB mean : ', zalksumb
391               trb(:,:,:,jptal) = trb(:,:,:,jptal) * alkmean / zalksumb
392
393               IF(lwp) WRITE(numout,*) '       PO4B  mean : ', zpo4sumb
394               trb(:,:,:,jppo4) = trb(:,:,:,jppo4) * po4mean / zpo4sumb
395
396               IF(lwp) WRITE(numout,*) '       NO3B  mean : ', zno3sumb
397               trb(:,:,:,jpno3) = trb(:,:,:,jpno3) * no3mean / zno3sumb
398
399               IF(lwp) WRITE(numout,*) '       SiO3B mean : ', zsilsumb
400               trb(:,:,:,jpsil) = MIN( 400.e-6,trb(:,:,:,jpsil) * silmean / zsilsumb )
401           ENDIF
402        ENDIF
403        !
404      ENDIF
405        !
406   END SUBROUTINE p4z_dmp
407
408
409   SUBROUTINE p4z_chk_mass( kt )
410      !!----------------------------------------------------------------------
411      !!                  ***  ROUTINE p4z_chk_mass  ***
412      !!
413      !! ** Purpose :  Mass conservation check
414      !!
415      !!---------------------------------------------------------------------
416      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index     
417      REAL(wp)             ::  zrdenittot, zsdenittot, znitrpottot
418      CHARACTER(LEN=100)   ::   cltxt
419      INTEGER :: jk
420      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zwork
421      !!----------------------------------------------------------------------
422      !
423      IF( kt == nittrc000 ) THEN
424         xfact1 = rfact2r * 12. / 1.e15 * ryyss    ! conversion molC/kt --> PgC/yr
425         xfact2 = 1.e+3 * rno3 * 14. / 1.e12 * ryyss   ! conversion molC/l/s ----> TgN/m3/yr
426         xfact3 = 1.e+3 * rfact2r * rno3   ! conversion molC/l/kt ----> molN/m3/s
427         IF( ln_check_mass .AND. lwp) THEN      !   Open budget file of NO3, ALK, Si, Fer
428            CALL ctl_opn( numco2, 'carbon.budget'  , 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
429            CALL ctl_opn( numnut, 'nutrient.budget', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
430            CALL ctl_opn( numnit, 'nitrogen.budget', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
431            cltxt='time-step   Alkalinity        Nitrate        Phosphorus         Silicate           Iron'
432            IF( lwp ) WRITE(numnut,*)  TRIM(cltxt)
433            IF( lwp ) WRITE(numnut,*) 
434         ENDIF
435      ENDIF
436
437      IF( iom_use( "pno3tot" ) .OR. ( ln_check_mass .AND. kt == nitend )  ) THEN
438         !   Compute the budget of NO3, ALK, Si, Fer
439         IF( ln_p4z ) THEN
440            zwork(:,:,:) =    trn(:,:,:,jpno3) + trn(:,:,:,jpnh4)                      &
441               &          +   trn(:,:,:,jpphy) + trn(:,:,:,jpdia)                      &
442               &          +   trn(:,:,:,jppoc) + trn(:,:,:,jpgoc)  + trn(:,:,:,jpdoc)  &       
443               &          +   trn(:,:,:,jpzoo) + trn(:,:,:,jpmes) 
444        ELSE
445            zwork(:,:,:) =    trn(:,:,:,jpno3) + trn(:,:,:,jpnh4) + trn(:,:,:,jpnph)   &
446               &          +   trn(:,:,:,jpndi) + trn(:,:,:,jpnpi)                      & 
447               &          +   trn(:,:,:,jppon) + trn(:,:,:,jpgon) + trn(:,:,:,jpdon)   &
448               &          + ( trn(:,:,:,jpzoo) + trn(:,:,:,jpmes) ) * no3rat3 
449        ENDIF
450        !
451        no3budget = glob_sum( 'p4zsms', zwork(:,:,:) * cvol(:,:,:)  ) 
452        no3budget = no3budget / areatot
453        CALL iom_put( "pno3tot", no3budget )
454      ENDIF
455      !
456      IF( iom_use( "ppo4tot" ) .OR. ( ln_check_mass .AND. kt == nitend )  ) THEN
457         IF( ln_p4z ) THEN
458            zwork(:,:,:) =    trn(:,:,:,jppo4)                                         &
459               &          +   trn(:,:,:,jpphy) + trn(:,:,:,jpdia)                      &
460               &          +   trn(:,:,:,jppoc) + trn(:,:,:,jpgoc)  + trn(:,:,:,jpdoc)  &       
461               &          +   trn(:,:,:,jpzoo) + trn(:,:,:,jpmes) 
462        ELSE
463            zwork(:,:,:) =    trn(:,:,:,jppo4) + trn(:,:,:,jppph)                      &
464               &          +   trn(:,:,:,jppdi) + trn(:,:,:,jpppi)                      & 
465               &          +   trn(:,:,:,jppop) + trn(:,:,:,jpgop) + trn(:,:,:,jpdop)   &
466               &          + ( trn(:,:,:,jpzoo) + trn(:,:,:,jpmes) ) * po4rat3 
467        ENDIF
468        !
469        po4budget = glob_sum( 'p4zsms', zwork(:,:,:) * cvol(:,:,:)  ) 
470        po4budget = po4budget / areatot
471        CALL iom_put( "ppo4tot", po4budget )
472      ENDIF
473      !
474      IF( iom_use( "psiltot" ) .OR. ( ln_check_mass .AND. kt == nitend )  ) THEN
475         zwork(:,:,:) =  trn(:,:,:,jpsil) + trn(:,:,:,jpgsi) + trn(:,:,:,jpdsi) 
476         !
477         silbudget = glob_sum( 'p4zsms', zwork(:,:,:) * cvol(:,:,:)  ) 
478         silbudget = silbudget / areatot
479         CALL iom_put( "psiltot", silbudget )
480      ENDIF
481      !
482      IF( iom_use( "palktot" ) .OR. ( ln_check_mass .AND. kt == nitend )  ) THEN
483         zwork(:,:,:) =  trn(:,:,:,jpno3) * rno3 + trn(:,:,:,jptal) + trn(:,:,:,jpcal) * 2.             
484         !
485         alkbudget = glob_sum( 'p4zsms', zwork(:,:,:) * cvol(:,:,:)  )         !
486         alkbudget = alkbudget / areatot
487         CALL iom_put( "palktot", alkbudget )
488      ENDIF
489      !
490      IF( iom_use( "pfertot" ) .OR. ( ln_check_mass .AND. kt == nitend )  ) THEN
491         zwork(:,:,:) =   trn(:,:,:,jpfer) + trn(:,:,:,jpnfe) + trn(:,:,:,jpdfe)   &
492            &         +   trn(:,:,:,jpbfe) + trn(:,:,:,jpsfe)                      &
493            &         + ( trn(:,:,:,jpzoo) + trn(:,:,:,jpmes) )  * ferat3   
494         !
495         ferbudget = glob_sum( 'p4zsms', zwork(:,:,:) * cvol(:,:,:)  ) 
496         ferbudget = ferbudget / areatot
497         CALL iom_put( "pfertot", ferbudget )
498      ENDIF
499      !
500      ! Global budget of N SMS : denitrification in the water column and in the sediment
501      !                          nitrogen fixation by the diazotrophs
502      ! --------------------------------------------------------------------------------
503      IF( iom_use( "tnfix" ) .OR.  ( ln_check_mass .AND. kt == nitend )  ) THEN
504         znitrpottot  = glob_sum ( 'p4zsms', nitrpot(:,:,:) * nitrfix * cvol(:,:,:) )
505         CALL iom_put( "tnfix"  , znitrpottot * xfact3 )  ! Global  nitrogen fixation molC/l  to molN/m3
506      ENDIF
507      !
508      IF( iom_use( "tdenit" ) .OR.  ( ln_check_mass .AND. kt == nitend )  ) THEN
509         zrdenittot = glob_sum ( 'p4zsms', denitr(:,:,:) * rdenit * xnegtr(:,:,:) * cvol(:,:,:) )
510         zsdenittot = glob_sum ( 'p4zsms', sdenit(:,:) * e1e2t(:,:) * tmask(:,:,1) )
511         CALL iom_put( "tdenit" , ( zrdenittot + zsdenittot ) * xfact3 )  ! Total denitrification molC/l to molN/m3
512      ENDIF
513      !
514      IF( ln_check_mass .AND. kt == nitend ) THEN   ! Compute the budget of NO3, ALK, Si, Fer
515         t_atm_co2_flx  = t_atm_co2_flx / glob_sum( 'p4zsms', e1e2t(:,:) )
516         t_oce_co2_flx  = t_oce_co2_flx         * xfact1 * (-1 )
517         tpp            = tpp           * 1000. * xfact1
518         t_oce_co2_exp  = t_oce_co2_exp * 1000. * xfact1
519         IF( lwp ) WRITE(numco2,9000) ndastp, t_atm_co2_flx, t_oce_co2_flx, tpp, t_oce_co2_exp
520         IF( lwp ) WRITE(numnut,9100) ndastp, alkbudget        * 1.e+06, &
521             &                                no3budget * rno3 * 1.e+06, &
522             &                                po4budget * po4r * 1.e+06, &
523             &                                silbudget        * 1.e+06, &
524             &                                ferbudget        * 1.e+09
525         !
526         IF( lwp ) WRITE(numnit,9200) ndastp, znitrpottot * xfact2  , &
527            &                             zrdenittot  * xfact2  , &
528            &                             zsdenittot  * xfact2
529      ENDIF
530      !
531 9000  FORMAT(i8,f10.5,e18.10,f10.5,f10.5)
532 9100  FORMAT(i8,5e18.10)
533 9200  FORMAT(i8,3f10.5)
534       !
535   END SUBROUTINE p4z_chk_mass
536
537   !!======================================================================
538END MODULE p4zsms 
Note: See TracBrowser for help on using the repository browser.