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/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/TOP/PISCES/P4Z – NEMO

source: NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/TOP/PISCES/P4Z/p4zsms.F90 @ 10345

Last change on this file since 10345 was 10345, checked in by smasson, 5 years ago

dev_r10164_HPC09_ESIWACE_PREP_MERGE: merge with trunk@10344, see #2133

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