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.
bio_medusa_update.F90 in branches/NERC/dev_r5518_GO6_GeoAlk_MEDUSA/NEMOGCM/NEMO/TOP_SRC/MEDUSA – NEMO

source: branches/NERC/dev_r5518_GO6_GeoAlk_MEDUSA/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_medusa_update.F90

Last change on this file was 11778, checked in by jpalmier, 5 years ago

debug 4

File size: 44.3 KB
Line 
1MODULE bio_medusa_update_mod
2   !!======================================================================
3   !!                         ***  MODULE bio_medusa_update_mod  ***
4   !! Update tracer fields
5   !!======================================================================
6   !! History :
7   !!   -   ! 2017-04 (M. Stringer)        Code taken from trcbio_medusa.F90
8   !!   -   ! 2017-08 (A. Yool)            Amend slow-detritus bug
9   !!   -   ! 2017-08 (A. Yool)            Reformatting for clarity
10   !!----------------------------------------------------------------------
11#if defined key_medusa
12   !!----------------------------------------------------------------------
13   !!                                                   MEDUSA bio-model
14   !!----------------------------------------------------------------------
15
16   IMPLICIT NONE
17   PRIVATE
18     
19   PUBLIC   bio_medusa_update        ! Called in trcbio_medusa.F90
20
21   !!----------------------------------------------------------------------
22   !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007)
23   !! $Id$
24   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
25   !!----------------------------------------------------------------------
26
27CONTAINS
28
29   SUBROUTINE bio_medusa_update( kt, jk )
30      !!---------------------------------------------------------------------
31      !!                     ***  ROUTINE bio_medusa_update  ***
32      !! This called from TRC_BIO_MEDUSA and updates the tracer fields
33      !!---------------------------------------------------------------------
34      USE bio_medusa_mod,    ONLY: b0, bddtalk3, bddtdic3, bddtdife3,        &
35                                   bddtdin3, bddtdisi3,                      &
36                                   ibenthic, ibio_switch, idf, idfval,       &
37                                   f_benout_c, f_benout_ca, f_benout_n,      &
38                                   f_benout_si,                              &
39                                   f_co2flux, f_o2flux,                      &
40                                   f_riv_loc_alk, f_riv_loc_c,               &
41                                   f_riv_loc_n, f_riv_loc_si,                & 
42                                   f_riv_alk, f_riv_c, f_riv_n, f_riv_si,    &
43                                   f_geoeng_alk,                             & ! AXY (23/10/19)
44                                   fbddtalk, fbddtdic, fbddtdife,            &
45                                   fbddtdin, fbddtdisi,                      & 
46                                   fdd, fdpd, fdpd2, fdpds, fdpds2,          &
47                                   fdpn, fdpn2,                              &
48                                   fdzme, fdzme2, fdzmi, fdzmi2,             &
49                                   ffast2slowc, ffast2slown,                 &
50                                   ffebot, ffetop, ffescav,                  &
51                                   fflx_fe, fflx_n, fflx_si,                 &
52                                   fgmed, fgmepd, fgmedc, fgmepd, fgmepds,   &
53                                   fgmepn, fgmezmi,                          &
54                                   fgmid, fgmidc, fgmipn,                    &
55                                   ficme, ficmi, finme, finmi,               &
56                                   fmeexcr, fmegrow, fmeresp,                &
57                                   fmiexcr, fmigrow, fmiresp,                &
58                                   fnit_cons, fnit_prod,                     &
59                                   fprd, fprds, fprn,                        &
60                                   frd,                                      &
61                                   freminc, freminca, freminn, freminsi,     &
62                                   frn,                                      &
63                                   fsil_cons, fsil_prod, fsdiss,             &
64                                   ftempca, fthetad, fthetan,                &
65                                   fslowsink, fslowgain, fslowloss,          & ! AXY (22/08/17)
66                                   f_sbenin_n, f_sbenin_c,                   &
67# if defined key_roam
68                                   fslowsinkc, fslowgainc, fslowlossc,       & ! AXY (22/08/17)
69                                   fcar_cons, fcar_prod, fcomm_resp,         &
70                                   fddc, fflx_a, fflx_c, fflx_o2, zoxy,      &
71                                   foxy_anox, foxy_cons, foxy_prod,          &
72# endif
73                                   zpds, zphd, zphn
74      USE dom_oce,           ONLY: e3t_0, gphit, mbathy, tmask, nyear          ! AXY (16/10/19)
75
76# if defined key_vvl
77      USE dom_oce,           ONLY: e3t_n
78# endif
79      USE in_out_manager,    ONLY: lwp, numout
80      USE lib_mpp,           ONLY: ctl_stop
81      USE par_kind,          ONLY: wp
82      USE par_medusa,        ONLY: jp_medusa, jp_msa0, jp_msa1,              &
83                                   jpalk, jpchd, jpchn, jpdet, jpdic,        &
84                                   jpdin, jpdtc, jpfer, jpoxy, jppds,        &
85                                   jpphd, jpphn, jpsil, jpzme, jpzmi,        &
86                                   jpalk_lc, jpchd_lc, jpchn_lc, jpdet_lc,   & 
87                                   jpdic_lc, jpdin_lc, jpdtc_lc, jpfer_lc,   & 
88                                   jpoxy_lc, jppds_lc, jpphd_lc, jpphn_lc,   &
89                                   jpsil_lc, jpzme_lc, jpzmi_lc
90      USE par_oce,           ONLY: jpi, jpim1, jpj, jpjm1, jpk
91      USE par_trc,           ONLY: jptra
92      USE sms_medusa,        ONLY: friver_dep,                               &
93                                   jinorgben, jorgben,                       &
94                                   jriver_alk, jriver_c,                     &
95                                   jriver_n, jriver_si,                      &
96                                   xbetac, xbetan,                           &
97                                   xfdfrac1, xfdfrac2, xfdfrac3,             &
98                                   xo2min, xphi, xrfn,                       &
99                                   xthetanit, xthetapd, xthetapn,            &
100                                   xthetarem, xthetazme, xthetazmi,          &
101                                   xxi
102      USE trc,               ONLY: med_diag, tra
103
104   !!* Substitution
105#  include "domzgr_substitute.h90"
106
107      !! time (integer timestep)
108      INTEGER, INTENT( in ) :: kt
109      !! Level
110      INTEGER, INTENT( in ) :: jk
111
112      !! Loop variables
113      INTEGER :: ji, jj, jn
114
115      !! AXY (23/08/13): changed from individual variables for each flux to
116      !!                 an array that holds all fluxes
117      REAL(wp), DIMENSION(jpi,jpj,jp_medusa) :: btra
118
119      !! nitrogen and silicon production and consumption
120      REAL(wp) :: fn_prod, fn_cons, fs_prod, fs_cons
121
122      !! carbon, alkalinity production and consumption
123      REAL(wp) :: fc_prod, fc_cons, fa_prod, fa_cons
124
125      !! oxygen production and consumption (and non-consumption)
126      REAL(wp), DIMENSION(jpi,jpj) :: fo2_prod, fo2_cons
127      REAL(wp), DIMENSION(jpi,jpj) :: fo2_ncons, fo2_ccons
128
129      !! temporary variables
130      REAL(wp) :: fq0
131
132      !!==========================================================
133      !! LOCAL GRID CELL TRENDS
134      !!==========================================================
135      !!
136      !!----------------------------------------------------------
137      !! Determination of trends
138      !!----------------------------------------------------------
139      DO jj = 2,jpjm1
140         DO ji = 2,jpim1
141            !! OPEN wet point IF..THEN loop
142            if (tmask(ji,jj,jk) == 1) then
143               !!
144               !!----------------------------------------------------------
145               !! chlorophyll
146               btra(ji,jj,jpchn_lc) = b0 * ( ( (frn(ji,jj) * fprn(ji,jj) *      &
147                                             zphn(ji,jj) ) -                 &
148                                           fgmipn(ji,jj) - fgmepn(ji,jj) -   &
149                                           fdpn(ji,jj) - fdpn2(ji,jj) ) *    &
150                                          (fthetan(ji,jj) / xxi) )
151               btra(ji,jj,jpchd_lc) = b0 * ( ( (frd(ji,jj) * fprd(ji,jj) *      &
152                                             zphd(ji,jj) ) -                 &
153                                           fgmepd(ji,jj) - fdpd(ji,jj) -     &
154                                           fdpd2(ji,jj) ) *                  &
155                                          (fthetad(ji,jj) / xxi) )
156            ENDIF
157         ENDDO
158      ENDDO
159
160      DO jj = 2,jpjm1
161         DO ji = 2,jpim1
162            if (tmask(ji,jj,jk) == 1) then
163               !!
164               !!----------------------------------------------------------
165               !! phytoplankton
166               btra(ji,jj,jpphn_lc) = b0 * ( (fprn(ji,jj) * zphn(ji,jj)) -      &
167                                          fgmipn(ji,jj) - fgmepn(ji,jj) -    &
168                                          fdpn(ji,jj) - fdpn2(ji,jj) )
169               btra(ji,jj,jpphd_lc) = b0 * ( (fprd(ji,jj) * zphd(ji,jj)) -      &
170                                          fgmepd(ji,jj) - fdpd(ji,jj) -      &
171                                          fdpd2(ji,jj) )
172               btra(ji,jj,jppds_lc) = b0 * ( (fprds(ji,jj) * zpds(ji,jj)) -     &
173                                          fgmepds(ji,jj) - fdpds(ji,jj) -    &
174                                          fsdiss(ji,jj) - fdpds2(ji,jj) )
175            ENDIF
176         ENDDO
177      ENDDO
178
179      DO jj = 2,jpjm1
180         DO ji = 2,jpim1
181            if (tmask(ji,jj,jk) == 1) then
182               !!
183               !!----------------------------------------------------------
184               !! zooplankton
185               btra(ji,jj,jpzmi_lc) = b0 * (fmigrow(ji,jj) - fgmezmi(ji,jj) -   &
186                                         fdzmi(ji,jj) - fdzmi2(ji,jj))
187               btra(ji,jj,jpzme_lc) = b0 * (fmegrow(ji,jj) - fdzme(ji,jj) -     &
188                                         fdzme2(ji,jj))
189            ENDIF
190         ENDDO
191      ENDDO
192
193      !!----------------------------------------------------------
194      !! detritus
195      DO jj = 2,jpjm1
196         DO ji = 2,jpim1
197            if (tmask(ji,jj,jk) == 1) then
198               !!
199               btra(ji,jj,jpdet_lc) = b0 * (                           &
200                   fdpn(ji,jj)                                         & ! mort. losses
201                 + ((1.0 - xfdfrac1) * fdpd(ji,jj))                    & ! mort. losses
202                 + fdzmi(ji,jj)                                        & ! mort. losses
203                 + ((1.0 - xfdfrac2) * fdzme(ji,jj))                   & ! mort. losses
204                 + ((1.0 - xbetan) * (finmi(ji,jj) + finme(ji,jj)))    & ! assim. inefficiency
205                 - fgmid(ji,jj) - fgmed(ji,jj)                         & ! grazing
206                 - fdd(ji,jj)                                          & ! remin.
207                 + fslowgain(ji,jj) - fslowloss(ji,jj)                 & ! slow-sinking
208                 - (f_sbenin_n(ji,jj) / fse3t(ji,jj,jk))               & ! slow-sinking loss to seafloor
209                 + ffast2slown(ji,jj) )                                  ! seafloor fast->slow
210            ENDIF
211         ENDDO
212      ENDDO
213
214      DO jj = 2,jpjm1
215         DO ji = 2,jpim1
216            if (tmask(ji,jj,jk) == 1) then
217               !!----------------------------------------------------------
218               !! dissolved inorganic nitrogen nutrient
219               !! primary production
220               fn_cons = - (fprn(ji,jj) * zphn(ji,jj)) -                     &
221                           (fprd(ji,jj) * zphd(ji,jj))
222               !!
223               fn_prod =                                                     &
224                                         ! messy feeding remin.
225                         (xphi * (fgmipn(ji,jj) + fgmid(ji,jj))) +           &
226                         (xphi * (fgmepn(ji,jj) + fgmepd(ji,jj) +            &
227                                  fgmezmi(ji,jj) + fgmed(ji,jj))) +          &
228                                         ! excretion and remin.
229                         fmiexcr(ji,jj) + fmeexcr(ji,jj) + fdd(ji,jj) +      &
230                         freminn(ji,jj) +                                    &
231                                         ! metab. losses
232                         fdpn2(ji,jj) + fdpd2(ji,jj) + fdzmi2(ji,jj) +       &
233                         fdzme2(ji,jj)
234               !!
235               !! riverine flux
236               !! (NOTE: this is "protected" for near-surface addition of riverine
237               !! by array friver_dep which is zero below a defined model level)
238               if ( jriver_n .gt. 0 ) then
239                  f_riv_loc_n(ji,jj) = f_riv_n(ji,jj) *                      &
240                     friver_dep(jk,mbathy(ji,jj)) / fse3t(ji,jj,jk)
241                  fn_prod = fn_prod + f_riv_loc_n(ji,jj)
242               endif
243               !! 
244               !! benthic remineralisation
245               if (jk.eq.mbathy(ji,jj) .and. jorgben.eq.1 .and.              &
246                   ibenthic.eq.1) then
247                  fn_prod = fn_prod + (f_benout_n(ji,jj) / fse3t(ji,jj,jk))
248               endif
249               !!
250               btra(ji,jj,jpdin_lc) = b0 * ( fn_prod + fn_cons )
251               !!
252               !! consumption of dissolved nitrogen
253               fnit_cons(ji,jj) = fnit_cons(ji,jj) + ( fse3t(ji,jj,jk) *     &
254                                                       fn_cons )
255               !! production of dissolved nitrogen
256               fnit_prod(ji,jj) = fnit_prod(ji,jj) + ( fse3t(ji,jj,jk) *     &
257                                                       fn_prod )
258            ENDIF
259         ENDDO
260      ENDDO
261
262      DO jj = 2,jpjm1
263         DO ji = 2,jpim1
264            if (tmask(ji,jj,jk) == 1) then
265               !!
266               !!----------------------------------------------------------
267               !! dissolved silicic acid nutrient
268               !! opal production
269               fs_cons = - (fprds(ji,jj) * zpds(ji,jj))
270               !!
271               fs_prod =                                                     &
272                             ! opal dissolution
273                         fsdiss(ji,jj) +                                     &
274                             ! mort. loss
275                         ((1.0 - xfdfrac1) * fdpds(ji,jj)) +                 &
276                             ! egestion of grazed Si
277                         ((1.0 - xfdfrac3) * fgmepds(ji,jj)) +               &
278                             ! fast diss. and metab. losses
279                         freminsi(ji,jj) + fdpds2(ji,jj)
280               !!
281               !! riverine flux
282               !! (NOTE: this is "protected" for near-surface addition of riverine
283               !! by array friver_dep which is zero below a defined model level)
284               if ( jriver_si .gt. 0 ) then
285                  f_riv_loc_si(ji,jj) = f_riv_si(ji,jj) *                    &
286                                        friver_dep(jk,mbathy(ji,jj)) /       &
287                                        fse3t(ji,jj,jk)
288                  fs_prod = fs_prod + f_riv_loc_si(ji,jj)
289               endif
290               !! 
291               !! benthic remineralisation
292               if (jk.eq.mbathy(ji,jj) .and. jinorgben.eq.1 .and.            &
293                   ibenthic.eq.1) then
294                  fs_prod = fs_prod + (f_benout_si(ji,jj) / fse3t(ji,jj,jk))
295               endif
296               !!
297               btra(ji,jj,jpsil_lc) = b0 * ( &
298                 fs_prod + fs_cons )
299               !! consumption of dissolved silicon
300               fsil_cons(ji,jj) = fsil_cons(ji,jj) + ( fse3t(ji,jj,jk) *     &
301                                                       fs_cons )
302               !! production of dissolved silicon
303               fsil_prod(ji,jj) = fsil_prod(ji,jj) + ( fse3t(ji,jj,jk) *     &
304                                                       fs_prod )
305            ENDIF
306         ENDDO
307      ENDDO
308
309      DO jj = 2,jpjm1
310         DO ji = 2,jpim1
311            if (tmask(ji,jj,jk) == 1) then !!
312               !!----------------------------------------------------------
313               !! dissolved "iron" nutrient
314               btra(ji,jj,jpfer_lc) = b0 * ( (xrfn * btra(ji,jj,jpdin_lc)) +       &
315                                          ffetop(ji,jj) + ffebot(ji,jj) -    &
316                                          ffescav(ji,jj) )
317            ENDIF
318         ENDDO
319      ENDDO
320
321# if defined key_roam
322      !!----------------------------------------------------------
323      !! AXY (26/11/08): implicit detrital carbon change
324      DO jj = 2,jpjm1
325         DO ji = 2,jpim1
326            if (tmask(ji,jj,jk) == 1) then 
327               !!
328               btra(ji,jj,jpdtc_lc) = b0 * (                           &
329                   (xthetapn * fdpn(ji,jj))                            & ! mort. losses
330                 + ((1.0 - xfdfrac1) * (xthetapd * fdpd(ji,jj)))       & ! mort. losses
331                 + (xthetazmi * fdzmi(ji,jj))                          & ! mort. losses
332                 + ((1.0 - xfdfrac2) * (xthetazme * fdzme(ji,jj)))     & ! mort. losses
333                 + ((1.0 - xbetac) * (ficmi(ji,jj) + ficme(ji,jj)))    & ! assim. inefficiency
334                 - fgmidc(ji,jj) - fgmedc(ji,jj)                       & ! grazing
335                 - fddc(ji,jj)                                         & ! remin.
336                 + fslowgainc(ji,jj) - fslowlossc(ji,jj)               & ! slow-sinking
337                 - (f_sbenin_c(ji,jj) / fse3t(ji,jj,jk))               & ! slow-sinking loss to seafloor
338                 + ffast2slowc(ji,jj) )                                  ! seafloor fast->slow
339            ENDIF
340         ENDDO
341      ENDDO
342
343      DO jj = 2,jpjm1
344         DO ji = 2,jpim1
345            if (tmask(ji,jj,jk) == 1) then
346               !!
347               !!----------------------------------------------------------
348               !! dissolved inorganic carbon
349               !! primary production
350               fc_cons = - (xthetapn * fprn(ji,jj) * zphn(ji,jj)) -          &
351                           (xthetapd * fprd(ji,jj) * zphd(ji,jj))
352               !!
353               fc_prod =                                                     &
354                            ! messy feeding remin
355                         (xthetapn * xphi * fgmipn(ji,jj)) +                 &
356                         (xphi * fgmidc(ji,jj)) +                            &
357                         (xthetapn * xphi * fgmepn(ji,jj)) +                 &
358                         (xthetapd * xphi * fgmepd(ji,jj)) +                 &
359                         (xthetazmi * xphi * fgmezmi(ji,jj)) +               &
360                         (xphi * fgmedc(ji,jj)) +                            &
361                            ! resp., remin., losses
362                         fmiresp(ji,jj) + fmeresp(ji,jj) + fddc(ji,jj) +     &
363                         freminc(ji,jj) + (xthetapn * fdpn2(ji,jj)) +        &
364                            ! losses
365                         (xthetapd * fdpd2(ji,jj)) +                         &
366                         (xthetazmi * fdzmi2(ji,jj)) +                       &
367                         (xthetazme * fdzme2(ji,jj))
368               !!
369               !! riverine flux
370               !! (NOTE: this is "protected" for near-surface addition of riverine
371               !! by array friver_dep which is zero below a defined model level)
372               if ( jriver_c .gt. 0 ) then
373                  f_riv_loc_c(ji,jj) = f_riv_c(ji,jj) *                      &
374                                       friver_dep(jk,mbathy(ji,jj)) /        &
375                                       fse3t(ji,jj,jk)
376                  fc_prod = fc_prod + f_riv_loc_c(ji,jj)
377               endif
378               !! 
379               !! benthic remineralisation
380               if (jk.eq.mbathy(ji,jj) .and. jorgben.eq.1 .and.              &
381                   ibenthic.eq.1) then
382                  fc_prod = fc_prod + (f_benout_c(ji,jj) / fse3t(ji,jj,jk))
383               endif
384               if (jk.eq.mbathy(ji,jj) .and. jinorgben.eq.1 .and.            &
385                   ibenthic.eq.1) then
386                  fc_prod = fc_prod + (f_benout_ca(ji,jj) / fse3t(ji,jj,jk))
387               endif
388               !!
389               !! community respiration (does not include CaCO3 terms -
390               !! obviously!)
391               fcomm_resp(ji,jj) = fcomm_resp(ji,jj) + fc_prod
392               !!
393               !! CaCO3
394               fc_prod = fc_prod - ftempca(ji,jj) + freminca(ji,jj)
395               !!
396               !! riverine flux
397               !! (NOTE: the lines immediately below are incorrect and riverine
398               !! flux is already handled above)
399               !! if ( jk .eq. 1 .and. jriver_c .gt. 0 ) then
400               !!    fc_prod = fc_prod + f_riv_c(ji,jj)
401               !! endif
402               !!
403               btra(ji,jj,jpdic_lc) = b0 * ( fc_prod + fc_cons )
404               !! consumption of dissolved carbon
405               fcar_cons(ji,jj) = fcar_cons(ji,jj) + ( fse3t(ji,jj,jk) *     &
406                                                       fc_cons )
407               !! production of dissolved carbon
408               fcar_prod(ji,jj) = fcar_prod(ji,jj) + ( fse3t(ji,jj,jk) *     &
409                                                       fc_prod )
410            ENDIF
411         ENDDO
412      ENDDO
413
414      DO jj = 2,jpjm1
415         DO ji = 2,jpim1
416            if (tmask(ji,jj,jk) == 1) then
417               !!
418               !!----------------------------------------------------------
419               !! alkalinity
420               !! CaCO3 dissolution
421               fa_prod = 2.0 * freminca(ji,jj)
422               !! CaCO3 production
423               fa_cons = - 2.0 * ftempca(ji,jj)
424               !!
425               !! riverine flux
426               !! (NOTE: this is "protected" for near-surface addition of riverine
427               !! by array friver_dep which is zero below a defined model level)
428               if ( jriver_alk .gt. 0 ) then
429                  f_riv_loc_alk(ji,jj) = f_riv_alk(ji,jj) *                  &
430                                         friver_dep(jk,mbathy(ji,jj)) /      &
431                                         fse3t(ji,jj,jk)
432                  fa_prod = fa_prod + f_riv_loc_alk(ji,jj)
433               endif
434          !!
435               !! AXY (16/10/19)
436               !! geoengineering flux
437               !! (NOTE: this is only added to the surface ocean grid cell, only
438               !! within a particular time window, and only within a particular
439               !! sub-polar geographical range; these parameters could be passed up
440               !! to ROSE if they need different values for different experiments)
441          if ( jk .eq. 1 .and. nyear .gt. 2014 .and. nyear .lt. 2050 .and. &
442                   gphit(ji,jj) .ge. -60.0 .and. gphit(ji,jj) .le. 70.0 ) then
443                  f_geoeng_alk(ji,jj) = 1.17 / fse3t(ji,jj,jk)
444                  fa_prod = fa_prod + f_geoeng_alk(ji,jj)
445               endif
446               !! 
447               !! benthic remineralisation
448               if (jk.eq.mbathy(ji,jj) .and. jinorgben.eq.1 .and.            &
449                   ibenthic.eq.1) then
450                  fa_prod = fa_prod + (2.0 * f_benout_ca(ji,jj) /            &
451                                       fse3t(ji,jj,jk))
452               endif
453               !!
454               btra(ji,jj,jpalk_lc) = b0 * ( fa_prod + fa_cons )
455            ENDIF
456         ENDDO
457      ENDDO
458
459      DO jj = 2,jpjm1
460         DO ji = 2,jpim1
461            if (tmask(ji,jj,jk) == 1) then
462               !!
463               !!----------------------------------------------------------
464               !! oxygen (has protection at low O2 concentrations;
465               !! OCMIP-2 style)
466               fo2_prod(ji,jj) =                                             &
467                                     ! Pn primary production, N
468                                 (xthetanit * fprn(ji,jj) * zphn(ji,jj)) +   &
469                                     ! Pd primary production, N
470                                 (xthetanit * fprd(ji,jj) * zphd(ji,jj)) +   &
471                                     ! Pn primary production, C
472                                 (xthetarem * xthetapn * fprn(ji,jj) *       &
473                                  zphn(ji,jj)) +                             &
474                                     ! Pd primary production, C
475                                  (xthetarem * xthetapd * fprd(ji,jj) *      &
476                                   zphd(ji,jj))
477               fo2_ncons(ji,jj) =                                            &
478                                     ! Pn messy feeding remin., N
479                                   - (xthetanit * xphi * fgmipn(ji,jj))      &
480                                     ! D  messy feeding remin., N
481                                   - (xthetanit * xphi * fgmid(ji,jj))       &
482                                     ! Pn messy feeding remin., N
483                                   - (xthetanit * xphi * fgmepn(ji,jj))      &
484                                     ! Pd messy feeding remin., N
485                                   - (xthetanit * xphi * fgmepd(ji,jj))      &
486                                     ! Zi messy feeding remin., N
487                                   - (xthetanit * xphi * fgmezmi(ji,jj))     &
488                                     ! D  messy feeding remin., N
489                                   - (xthetanit * xphi * fgmed(ji,jj))       &
490                                     ! microzoo excretion, N
491                                   - (xthetanit * fmiexcr(ji,jj))            &
492                                     ! mesozoo  excretion, N
493                                   - (xthetanit * fmeexcr(ji,jj))            &
494                                     ! slow detritus remin., N
495                                   - (xthetanit * fdd(ji,jj))                &
496                                     ! fast detritus remin., N
497                                   - (xthetanit * freminn(ji,jj))            &
498                                     ! Pn  losses, N
499                                   - (xthetanit * fdpn2(ji,jj))              &
500                                     ! Pd  losses, N
501                                   - (xthetanit * fdpd2(ji,jj))              &
502                                     ! Zmi losses, N
503                                   - (xthetanit * fdzmi2(ji,jj))             &
504                                     ! Zme losses, N
505                                   - (xthetanit * fdzme2(ji,jj))
506               !! 
507               !! benthic remineralisation
508               if (jk.eq.mbathy(ji,jj) .and. jorgben.eq.1 .and.              &
509                   ibenthic.eq.1) then
510                  fo2_ncons(ji,jj) = fo2_ncons(ji,jj) -                      &
511                                     (xthetanit * f_benout_n(ji,jj) /        &
512                                      fse3t(ji,jj,jk))
513               endif
514            ENDIF
515         ENDDO
516      ENDDO
517
518      DO jj = 2,jpjm1
519         DO ji = 2,jpim1
520            if (tmask(ji,jj,jk) == 1) then
521               fo2_ccons(ji,jj) =                                            &
522                                     ! Pn messy feeding remin., C
523                                  - (xthetarem * xthetapn * xphi *           &
524                                     fgmipn(ji,jj))                          &
525                                     ! D  messy feeding remin., C
526                                  - (xthetarem * xphi * fgmidc(ji,jj))       &
527                                     ! Pn messy feeding remin., C
528                                  - (xthetarem * xthetapn * xphi *           &
529                                     fgmepn(ji,jj))                          &
530                                     ! Pd messy feeding remin., C
531                                  - (xthetarem * xthetapd * xphi *           &
532                                     fgmepd(ji,jj))                          &
533                                     ! Zi messy feeding remin., C
534                                  - (xthetarem * xthetazmi * xphi *          &
535                                     fgmezmi(ji,jj))                         &
536                                     ! D  messy feeding remin., C
537                                  - (xthetarem * xphi * fgmedc(ji,jj))       &
538                                     ! microzoo respiration, C
539                                  - (xthetarem * fmiresp(ji,jj))             &
540                                     ! mesozoo  respiration, C
541                                  - (xthetarem * fmeresp(ji,jj))             &
542                                     ! slow detritus remin., C
543                                  - (xthetarem * fddc(ji,jj))                &
544                                     ! fast detritus remin., C
545                                  - (xthetarem * freminc(ji,jj))             &
546                                     ! Pn  losses, C
547                                  - (xthetarem * xthetapn * fdpn2(ji,jj))    &
548                                     ! Pd  losses, C
549                                  - (xthetarem * xthetapd * fdpd2(ji,jj))    &
550                                     ! Zmi losses, C
551                                  - (xthetarem * xthetazmi * fdzmi2(ji,jj))  &
552                                     ! Zme losses, C
553                                  - (xthetarem * xthetazme * fdzme2(ji,jj))
554               !! 
555               !! benthic remineralisation
556               if (jk.eq.mbathy(ji,jj) .and. jorgben.eq.1 .and.              &
557                   ibenthic.eq.1) then
558                  fo2_ccons(ji,jj) = fo2_ccons(ji,jj) - (xthetarem *         &
559                                                         f_benout_c(ji,jj) / &
560                                                         fse3t(ji,jj,jk))
561               endif
562               fo2_cons(ji,jj) = fo2_ncons(ji,jj) + fo2_ccons(ji,jj)
563            ENDIF
564         ENDDO
565      ENDDO
566
567      DO jj = 2,jpjm1
568         DO ji = 2,jpim1
569            if (tmask(ji,jj,jk) == 1) then
570               !!
571               !! is this a suboxic zone?
572               !! deficient O2; production fluxes only
573               if (zoxy(ji,jj).lt.xo2min) then
574                  btra(ji,jj,jpoxy_lc) = b0 * fo2_prod(ji,jj)
575                  foxy_prod(ji,jj) = foxy_prod(ji,jj) + ( fse3t(ji,jj,jk) *  &
576                                                          fo2_prod(ji,jj) )
577                  foxy_anox(ji,jj) = foxy_anox(ji,jj) + ( fse3t(ji,jj,jk) *  &
578                                                          fo2_cons(ji,jj) )
579               else
580                  !! sufficient O2; production + consumption fluxes
581                  btra(ji,jj,jpoxy_lc) = b0 * ( fo2_prod(ji,jj) +               &
582                                             fo2_cons(ji,jj) )
583                  foxy_prod(ji,jj) = foxy_prod(ji,jj) +                      &
584                                     ( fse3t(ji,jj,jk) * fo2_prod(ji,jj) )
585                  foxy_cons(ji,jj) = foxy_cons(ji,jj) +                      &
586                                     ( fse3t(ji,jj,jk) * fo2_cons(ji,jj) )
587               endif
588            ENDIF
589         ENDDO
590      ENDDO
591
592      DO jj = 2,jpjm1
593         DO ji = 2,jpim1
594            if (tmask(ji,jj,jk) == 1) then
595               !!
596               !! air-sea fluxes (if this is the surface box)
597               if (jk.eq.1) then
598                  !!
599                  !! CO2 flux
600                  btra(ji,jj,jpdic_lc) = btra(ji,jj,jpdic_lc) + (b0 *              &
601                                                           f_co2flux(ji,jj))
602                  !!
603                  !! O2 flux (mol/m3/s -> mmol/m3/d)
604                  btra(ji,jj,jpoxy_lc) = btra(ji,jj,jpoxy_lc) + (b0 *              &
605                                                           f_o2flux(ji,jj))
606               endif
607            ENDIF
608         ENDDO
609      ENDDO
610# endif
611
612# if defined key_debug_medusa
613! I DON'T THIS IS MUCH USE, NOW IT'S BEEN PULLED OUT OF THE MAIN DO LOOP
614! - marc 5/5/17
615      DO jj = 2,jpjm1
616         DO ji = 2,jpim1
617            if (tmask(ji,jj,jk) == 1) then
618               !! report state variable fluxes (not including
619               !! fast-sinking detritus)
620               if (idf.eq.1.AND.idfval.eq.1) then
621                  IF (lwp) write (numout,*) '------------------------------'
622                  IF (lwp) write (numout,*) 'btra(ji,jj,jpchn_lc)(',jk,')  = ', &
623                                            btra(ji,jj,jpchn_lc)
624                  IF (lwp) write (numout,*) 'btra(ji,jj,jpchd_lc)(',jk,')  = ', &
625                                            btra(ji,jj,jpchd_lc)
626                  IF (lwp) write (numout,*) 'btra(ji,jj,jpphn_lc)(',jk,')  = ', &
627                                            btra(ji,jj,jpphn_lc)
628                  IF (lwp) write (numout,*) 'btra(ji,jj,jpphd_lc)(',jk,')  = ', &
629                                            btra(ji,jj,jpphd_lc)
630                  IF (lwp) write (numout,*) 'btra(ji,jj,jppds_lc)(',jk,')  = ', &
631                                            btra(ji,jj,jppds_lc)
632                  IF (lwp) write (numout,*) 'btra(ji,jj,jpzmi_lc)(',jk,')  = ', &
633                                            btra(ji,jj,jpzmi_lc)
634                  IF (lwp) write (numout,*) 'btra(ji,jj,jpzme_lc)(',jk,')  = ', &
635                                            btra(ji,jj,jpzme_lc)
636                  IF (lwp) write (numout,*) 'btra(ji,jj,jpdet_lc)(',jk,')  = ', &
637                                            btra(ji,jj,jpdet_lc)
638                  IF (lwp) write (numout,*) 'btra(ji,jj,jpdin_lc)(',jk,')  = ', &
639                                            btra(ji,jj,jpdin_lc)
640                  IF (lwp) write (numout,*) 'btra(ji,jj,jpsil_lc)(',jk,')  = ', &
641                                            btra(ji,jj,jpsil_lc)
642                  IF (lwp) write (numout,*) 'btra(ji,jj,jpfer_lc)(',jk,')  = ', &
643                                            btra(ji,jj,jpfer_lc)
644#  if defined key_roam
645                  IF (lwp) write (numout,*) 'btra(ji,jj,jpdtc_lc)(',jk,')  = ', &
646                                            btra(ji,jj,jpdtc_lc)
647                  IF (lwp) write (numout,*) 'btra(ji,jj,jpdic_lc)(',jk,')  = ', &
648                                            btra(ji,jj,jpdic_lc)
649                  IF (lwp) write (numout,*) 'btra(ji,jj,jpalk_lc)(',jk,')  = ', &
650                                            btra(ji,jj,jpalk_lc)
651                  IF (lwp) write (numout,*) 'btra(ji,jj,jpoxy_lc)(',jk,')  = ', &
652                                            btra(ji,jj,jpoxy_lc)
653#  endif
654               endif
655            ENDIF
656         ENDDO
657      ENDDO
658# endif
659
660      !!----------------------------------------------------------
661      !! Integrate calculated fluxes for mass balance
662      !!----------------------------------------------------------
663      DO jj = 2,jpjm1
664         DO ji = 2,jpim1
665            if (tmask(ji,jj,jk) == 1) then
666               !!
667               !! === nitrogen ===
668               fflx_n(ji,jj)  = fflx_n(ji,jj) + fse3t(ji,jj,jk) *            &
669                                ( btra(ji,jj,jpphn_lc) + btra(ji,jj,jpphd_lc) +    &
670                                  btra(ji,jj,jpzmi_lc) + btra(ji,jj,jpzme_lc) +    &
671                                  btra(ji,jj,jpdet_lc) + btra(ji,jj,jpdin_lc) )
672               !! === silicon ===
673               fflx_si(ji,jj) = fflx_si(ji,jj) + fse3t(ji,jj,jk) *           &
674                                ( btra(ji,jj,jppds_lc) + btra(ji,jj,jpsil_lc) )
675               !! === iron ===
676               fflx_fe(ji,jj) = fflx_fe(ji,jj) + fse3t(ji,jj,jk) *           &
677                                ( (xrfn *                                    &
678                                   (btra(ji,jj,jpphn_lc) + btra(ji,jj,jpphd_lc) +  &
679                                    btra(ji,jj,jpzmi_lc) + btra(ji,jj,jpzme_lc) +  &
680                                    btra(ji,jj,jpdet_lc))) + btra(ji,jj,jpfer_lc) )
681# if defined key_roam
682               !! === carbon ===
683               fflx_c(ji,jj)  = fflx_c(ji,jj) + fse3t(ji,jj,jk) *            &
684                                ( (xthetapn * btra(ji,jj,jpphn_lc)) +           &
685                                  (xthetapd * btra(ji,jj,jpphd_lc)) +           &
686                                  (xthetazmi * btra(ji,jj,jpzmi_lc)) +          &
687                                  (xthetazme * btra(ji,jj,jpzme_lc)) +          &
688                                  btra(ji,jj,jpdtc_lc) + btra(ji,jj,jpdic_lc) )
689               !! === alkalinity ===
690               fflx_a(ji,jj)  = fflx_a(ji,jj) + fse3t(ji,jj,jk) *            &
691                                btra(ji,jj,jpalk_lc)
692               !! === oxygen ===
693               fflx_o2(ji,jj) = fflx_o2(ji,jj) + fse3t(ji,jj,jk) *           &
694                                btra(ji,jj,jpoxy_lc)
695# endif
696            ENDIF
697         ENDDO
698      ENDDO
699
700      !!----------------------------------------------------------
701      !! Apply calculated tracer fluxes
702      !!----------------------------------------------------------
703      !!
704      !! units: [unit of tracer] per second (fluxes are calculated
705      !! above per day)
706      !!
707      DO jj = 2,jpjm1
708         DO ji = 2,jpim1
709            if (tmask(ji,jj,jk) == 1) then
710               ibio_switch = 1
711# if defined key_gulf_finland
712               !! AXY (17/05/13): fudge in a Gulf of Finland correction;
713               !!                 uses longitude-latitude range to
714               !!                 establish if this is a Gulf of Finland
715               !!                 grid cell; if so, then BGC fluxes are
716               !!                 ignored (though still calculated); for
717               !!                 reference, this is meant to be a
718               !!                 temporary fix to see if all of my
719               !!                 problems can be done away with if I
720               !!                 switch off BGC fluxes in the Gulf of
721               !!                 Finland, which currently appears the
722               !!                 source of trouble
723               if ( glamt(ji,jj).gt.24.7 .and. glamt(ji,jj).lt.27.8 .and.    &
724                    gphit(ji,jj).gt.59.2 .and. gphit(ji,jj).lt.60.2 ) then
725                  ibio_switch = 0
726               endif
727# endif               
728               if (ibio_switch.eq.1) then
729                  tra(ji,jj,jk,jpchn) = tra(ji,jj,jk,jpchn) +                &
730                                        (btra(ji,jj,jpchn_lc) / 86400.)
731                  tra(ji,jj,jk,jpchd) = tra(ji,jj,jk,jpchd) +                &
732                                        (btra(ji,jj,jpchd_lc) / 86400.)
733                  tra(ji,jj,jk,jpphn) = tra(ji,jj,jk,jpphn) +                &
734                                        (btra(ji,jj,jpphn_lc) / 86400.)
735                  tra(ji,jj,jk,jpphd) = tra(ji,jj,jk,jpphd) +                &
736                                        (btra(ji,jj,jpphd_lc) / 86400.)
737                  tra(ji,jj,jk,jppds) = tra(ji,jj,jk,jppds) +                &
738                                        (btra(ji,jj,jppds_lc) / 86400.)
739                  tra(ji,jj,jk,jpzmi) = tra(ji,jj,jk,jpzmi) +                &
740                                        (btra(ji,jj,jpzmi_lc) / 86400.)
741                  tra(ji,jj,jk,jpzme) = tra(ji,jj,jk,jpzme) +                &
742                                        (btra(ji,jj,jpzme_lc) / 86400.)
743                  tra(ji,jj,jk,jpdet) = tra(ji,jj,jk,jpdet) +                &
744                                        (btra(ji,jj,jpdet_lc) / 86400.)
745                  tra(ji,jj,jk,jpdin) = tra(ji,jj,jk,jpdin) +                &
746                                        (btra(ji,jj,jpdin_lc) / 86400.)
747                  tra(ji,jj,jk,jpsil) = tra(ji,jj,jk,jpsil) +                &
748                                        (btra(ji,jj,jpsil_lc) / 86400.)
749                  tra(ji,jj,jk,jpfer) = tra(ji,jj,jk,jpfer) +                &
750                                        (btra(ji,jj,jpfer_lc) / 86400.)
751# if defined key_roam
752                  tra(ji,jj,jk,jpdtc) = tra(ji,jj,jk,jpdtc) +                &
753                                        (btra(ji,jj,jpdtc_lc) / 86400.)
754                  tra(ji,jj,jk,jpdic) = tra(ji,jj,jk,jpdic) +                &
755                                        (btra(ji,jj,jpdic_lc) / 86400.)
756                  tra(ji,jj,jk,jpalk) = tra(ji,jj,jk,jpalk) +                &
757                                        (btra(ji,jj,jpalk_lc) / 86400.)
758                  tra(ji,jj,jk,jpoxy) = tra(ji,jj,jk,jpoxy) +                &
759                                        (btra(ji,jj,jpoxy_lc) / 86400.)
760# endif
761               endif
762            ENDIF
763         ENDDO
764      ENDDO
765
766      DO jj = 2,jpjm1
767         DO ji = 2,jpim1
768            if (tmask(ji,jj,jk) == 1) then
769
770               !! AXY (18/11/16): CMIP6 diagnostics
771               IF( med_diag%FBDDTALK%dgsave )  THEN
772                  fbddtalk(ji,jj)  =  fbddtalk(ji,jj)  +                     &
773                                      (btra(ji,jj,jpalk_lc) * fse3t(ji,jj,jk))
774               ENDIF
775               IF( med_diag%FBDDTDIC%dgsave )  THEN
776                  fbddtdic(ji,jj)  =  fbddtdic(ji,jj)  +                     &
777                                      (btra(ji,jj,jpdic_lc) * fse3t(ji,jj,jk))
778               ENDIF
779               IF( med_diag%FBDDTDIFE%dgsave ) THEN
780                  fbddtdife(ji,jj) =  fbddtdife(ji,jj) +                     &
781                                      (btra(ji,jj,jpfer_lc) * fse3t(ji,jj,jk))
782               ENDIF
783               IF( med_diag%FBDDTDIN%dgsave )  THEN
784                  fbddtdin(ji,jj)  =  fbddtdin(ji,jj)  +                     &
785                                      (btra(ji,jj,jpdin_lc) * fse3t(ji,jj,jk))
786               ENDIF
787               IF( med_diag%FBDDTDISI%dgsave ) THEN
788                  fbddtdisi(ji,jj) =  fbddtdisi(ji,jj) +                     &
789                                      (btra(ji,jj,jpsil_lc) * fse3t(ji,jj,jk))
790               ENDIF
791          !!
792               IF( med_diag%BDDTALK3%dgsave )  THEN
793                  bddtalk3(ji,jj,jk)  =  btra(ji,jj,jpalk_lc)
794               ENDIF
795               IF( med_diag%BDDTDIC3%dgsave )  THEN
796                  bddtdic3(ji,jj,jk)  =  btra(ji,jj,jpdic_lc)
797               ENDIF
798               IF( med_diag%BDDTDIFE3%dgsave ) THEN
799                  bddtdife3(ji,jj,jk) =  btra(ji,jj,jpfer_lc)
800               ENDIF
801               IF( med_diag%BDDTDIN3%dgsave )  THEN
802                  bddtdin3(ji,jj,jk)  =  btra(ji,jj,jpdin_lc)
803               ENDIF
804               IF( med_diag%BDDTDISI3%dgsave ) THEN
805                  bddtdisi3(ji,jj,jk) =  btra(ji,jj,jpsil_lc)
806               ENDIF
807            ENDIF
808         ENDDO
809      ENDDO
810
811#   if defined key_debug_medusa
812      IF (lwp) write (numout,*) '------'
813      IF (lwp) write (numout,*) 'bio_medusa_update: end all calculations'
814      IF (lwp) write (numout,*) 'bio_medusa_update: now outputs kt = ', kt
815      CALL flush(numout)
816#   endif
817
818# if defined key_axy_nancheck
819      !!----------------------------------------------------------
820      !! Check calculated tracer fluxes
821      !!----------------------------------------------------------
822      DO jj = 2,jpjm1
823         DO ji = 2,jpim1
824            if (tmask(ji,jj,jk) == 1) then
825               !!
826               DO jn = 1,jp_medusa
827                  fq0 = btra(ji,jj,jn)
828                  !! AXY (30/01/14): "isnan" problem on HECTOR
829                  !! if (fq0 /= fq0 ) then
830                  if ( ieee_is_nan( fq0 ) ) then
831                     !! there's a NaN here
832                     if (lwp) write(numout,*) 'NAN detected in btra(ji,jj,',  &
833                        ji, ',', jj, ',', jk, ',', jn, ') at time', kt
834           CALL ctl_stop( 'trcbio_medusa, NAN in btra field' )
835                  endif
836               ENDDO
837               DO jn = jp_msa0,jp_msa1
838                  fq0 = tra(ji,jj,jk,jn)
839                  !! AXY (30/01/14): "isnan" problem on HECTOR
840                  !! if (fq0 /= fq0 ) then
841                  if ( ieee_is_nan( fq0 ) ) then
842                     !! there's a NaN here
843                     if (lwp) write(numout,*) 'NAN detected in tra(', ji, &
844                        ',', jj, ',', jk, ',', jn, ') at time', kt
845              CALL ctl_stop( 'trcbio_medusa, NAN in tra field' )
846                  endif
847               ENDDO
848               CALL flush(numout)
849            ENDIF
850         ENDDO
851      ENDDO
852# endif
853
854
855   END SUBROUTINE bio_medusa_update
856
857#else
858   !!======================================================================
859   !!  Dummy module :                                   No MEDUSA bio-model
860   !!======================================================================
861CONTAINS
862   SUBROUTINE bio_medusa_update( )                    ! Empty routine
863      WRITE(*,*) 'bio_medusa_update: You should not have seen this print! error?'
864   END SUBROUTINE bio_medusa_update
865#endif 
866
867   !!======================================================================
868END MODULE bio_medusa_update_mod
Note: See TracBrowser for help on using the repository browser.