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 branches/2017/dev_merge_2017/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z – NEMO

source: branches/2017/dev_merge_2017/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsms.F90 @ 9081

Last change on this file since 9081 was 9081, checked in by cetlod, 6 years ago

dev_merge_2017 : use of lbclnk_4d for TOP arrays

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