-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfennel.h
More file actions
executable file
·3133 lines (2971 loc) · 133 KB
/
fennel.h
File metadata and controls
executable file
·3133 lines (2971 loc) · 133 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
SUBROUTINE biology (ng,tile)
!
!svn $Id: redoxh.h UCPH-IGN: 2017 Daryabor & Bjerrum$
!***********************************************************************
! Copyright (c) 2002-2016 The ROMS/TOMS Group !
! Licensed under a MIT/X style license Hernan G. Arango !
! See License_ROMS.txt Katja Fennel !
!****************************************** Alexander F. Shchepetkin ***
! Biogeochemical model based insight into the coupling of Nitrogen !
! and Sulfur cycles Azhar et al. (2014). This routine is developed !
! on the Fennel et al. (2006) ecosystem model based on the sulfur !
! cycling component to compute the biological source and sinks. The !
! detailed equations of the sulfur cycle are given in Azhar et al. !
! (2014). !
! !
! By activation of the "BIO_REDOXH" option a biogeochemical model !
! coupled with the nitrogen and sulfur cycles will be implemented. !
! !
! It is recommended to activate always the "BIO_SEDIMENT" option !
! to ensure conservation of mass by converting the organic matter !
! that is sinking out of the bottom most grid cell into inorganic !
! nutrients (i.e., instantanaous remineralization at the water- !
! sediment interface). Additionally, the "DENITRIFICATION" option !
! can be activated. Hence, a fraction of the instantenous bottom !
! remineralization is assumed to occur through the anearobic !
! (denitrification) pathway and thus lost from the pool of !
! biologically availalbe fixed nitrogen. See Fennel et al. (2006) !
! for details. !
! !
! Additional options can be activated to enable simulation of !
! inorganic carbon and dissolved oxygen. Accounting of inorganic !
! carbon is activated by the "CARBON" option, and results in two !
! additional biological tracer variables: DIC and alkalinity. !
! See Fennel et al. (2008) for details. !
! !
! If the "pCO2_RZ" options is activated, in addition to "CARBON", !
! the carbonate system routines by Zeebe and Wolf-Gladrow (2001) !
! are used, while the OCMIP standard routines are the default. !
! There are two different ways of treating alkalinity. It can be !
! treated diagnostically (default), in this case alkalinity acts !
! like a passive tracer that is not affected by changes in the !
! concentration of nitrate or ammonium. However, if the option !
! "TALK_NONCONSERV" is used, the alkalinity will be affected by !
! sources and sinks in nitrate. See Fennel et al. (2008) for more !
! details. !
! !
! If the "OXYGEN" option is activated, one additional biological !
! tracer variable for dissolved oxygen. "OXYGEN" can be activated !
! independently of the "CARBON" option. If "OCMIP_OXYGEN_SC" is !
! used, in addition to "OXYGEN", the Schmidt number of oxygen in !
! seawater will be computed using the formulation proposed by !
! Keeling et al. (1998, Global Biogeochem. Cycles, 12, 141-163). !
! Otherwise, the Wanninkhof's (1992) formula will be used. !
! !
! References: !
! !
! Azhar, M. A., Canfield, D. E., Fennel, K., Thamdrup, B., & !
! Bjerrum, C. J. (2014). A model‐based insight into the coupling !
! of nitrogen and sulfur cycles in a coastal upwelling system. !
! Journal of Geophysical Research: Biogeosciences, 119(3), !
! 264-285. !
! !
! Fennel, K., Wilkin, J., Levin, J., Moisan, J., O Reilly, J., !
! Haidvogel, D., 2006: Nitrogen cycling in the Mid Atlantic !
! Bight and implications for the North Atlantic nitrogen !
! budget: Results from a three-dimensional model. Global !
! Biogeochemical Cycles 20, GB3007, doi:10.1029/2005GB002456. !
! !
! Fennel, K., Wilkin, J., Previdi, M., Najjar, R. 2008: !
! Denitrification effects on air-sea CO2 flux in the coastal !
! ocean: Simulations for the Northwest North Atlantic. !
! Geophys. Res. Letters 35, L24608, doi:10.1029/2008GL036147. !
! !
!***********************************************************************
!
USE mod_param
#ifdef DIAGNOSTICS_BIO
USE mod_diags
#endif
USE mod_forces
USE mod_grid
USE mod_ncparam
USE mod_ocean
USE mod_stepping
!
implicit none
!
! Imported variable declarations.
!
integer, intent(in) :: ng, tile
!
! Local variable declarations.
!
#include "tile.h"
!
! Set header file name.
!
#ifdef DISTRIBUTE
IF (Lbiofile(iNLM)) THEN
#else
IF (Lbiofile(iNLM).and.(tile.eq.0)) THEN
#endif
Lbiofile(iNLM)=.FALSE.
BIONAME(iNLM)=__FILE__
END IF
!
#ifdef PROFILE
CALL wclock_on (ng, iNLM, 15)
#endif
CALL biology_tile (ng, tile, &
& LBi, UBi, LBj, UBj, N(ng), NT(ng), &
& IminS, ImaxS, JminS, JmaxS, &
& nstp(ng), nnew(ng), &
#ifdef MASKING
& GRID(ng) % rmask, &
# if defined WET_DRY && defined DIAGNOSTICS_BIO
& GRID(ng) % rmask_full, &
# endif
#endif
& GRID(ng) % Hz, &
& GRID(ng) % z_r, &
& GRID(ng) % z_w, &
& FORCES(ng) % srflx, &
#if defined CARBON || (defined OXYGEN || defined H_SULF)
# ifdef BULK_FLUXES
& FORCES(ng) % Uwind, &
& FORCES(ng) % Vwind, &
# else
& FORCES(ng) % sustr, &
& FORCES(ng) % svstr, &
# endif
#endif
#ifdef CARBON
& OCEAN(ng) % pH, &
#endif
#if defined USECOS_BURIAL
& FORCES(ng) % bustr, &
& FORCES(ng) % bvstr, &
#endif
#ifdef DIAGNOSTICS_BIO
& DIAGS(ng) % DiaBio2d, &
& DIAGS(ng) % DiaBio3d, &
#endif
& OCEAN(ng) % t)
#ifdef PROFILE
CALL wclock_off (ng, iNLM, 15)
#endif
RETURN
END SUBROUTINE biology
!
!-----------------------------------------------------------------------
SUBROUTINE biology_tile (ng, tile, &
& LBi, UBi, LBj, UBj, UBk, UBt, &
& IminS, ImaxS, JminS, JmaxS, &
& nstp, nnew, &
#ifdef MASKING
& rmask, &
# if defined WET_DRY && defined DIAGNOSTICS_BIO
& rmask_full, &
# endif
#endif
& Hz, z_r, z_w, srflx, &
#if defined CARBON || (defined OXYGEN || defined H_SULF)
# ifdef BULK_FLUXES
& Uwind, Vwind, &
# else
& sustr, svstr, &
# endif
#endif
#ifdef CARBON
& pH, &
#endif
#if defined USECOS_BURIAL
bustr, bvstr, &
#endif
#ifdef DIAGNOSTICS_BIO
& DiaBio2d, DiaBio3d, &
#endif
& t)
!-----------------------------------------------------------------------
!
USE mod_param
USE mod_biology
USE mod_ncparam
USE mod_scalars
USE dateclock_mod
!
! Imported variable declarations.
!
integer, intent(in) :: ng, tile
integer, intent(in) :: LBi, UBi, LBj, UBj, UBk, UBt
integer, intent(in) :: IminS, ImaxS, JminS, JmaxS
integer, intent(in) :: nstp, nnew
#ifdef ASSUMED_SHAPE
# ifdef MASKING
real(r8), intent(in) :: rmask(LBi:,LBj:)
# if defined WET_DRY && defined DIAGNOSTICS_BIO
real(r8), intent(in) :: rmask_full(LBi:,LBj:)
# endif
# endif
real(r8), intent(in) :: Hz(LBi:,LBj:,:)
real(r8), intent(in) :: z_r(LBi:,LBj:,:)
real(r8), intent(in) :: z_w(LBi:,LBj:,0:)
real(r8), intent(in) :: srflx(LBi:,LBj:)
# if defined CARBON || (defined OXYGEN || defined H_SULF)
# ifdef BULK_FLUXES
real(r8), intent(in) :: Uwind(LBi:,LBj:)
real(r8), intent(in) :: Vwind(LBi:,LBj:)
# else
real(r8), intent(in) :: sustr(LBi:,LBj:)
real(r8), intent(in) :: svstr(LBi:,LBj:)
# endif
# endif
# if defined USECOS_BURIAL
real(r8), intent(in) :: bustr(LBi:,LBj:)
real(r8), intent(in) :: bvstr(LBi:,LBj:)
# endif
# ifdef CARBON
real(r8), intent(inout) :: pH(LBi:,LBj:)
# endif
# ifdef DIAGNOSTICS_BIO
real(r8), intent(inout) :: DiaBio2d(LBi:,LBj:,:)
real(r8), intent(inout) :: DiaBio3d(LBi:,LBj:,:,:)
# endif
real(r8), intent(inout) :: t(LBi:,LBj:,:,:,:)
#else
# ifdef MASKING
real(r8), intent(in) :: rmask(LBi:UBi,LBj:UBj)
# if defined WET_DRY && defined DIAGNOSTICS_BIO
real(r8), intent(in) :: rmask_full(LBi:UBi,LBj:UBj)
# endif
# endif
real(r8), intent(in) :: Hz(LBi:UBi,LBj:UBj,UBk)
real(r8), intent(in) :: z_r(LBi:UBi,LBj:UBj,UBk)
real(r8), intent(in) :: z_w(LBi:UBi,LBj:UBj,0:UBk)
real(r8), intent(in) :: srflx(LBi:UBi,LBj:UBj)
# if defined CARBON || (defined OXYGEN || defined H_SULF)
# ifdef BULK_FLUXES
real(r8), intent(in) :: Uwind(LBi:UBi,LBj:UBj)
real(r8), intent(in) :: Vwind(LBi:UBi,LBj:UBj)
# else
real(r8), intent(in) :: sustr(LBi:UBi,LBj:UBj)
real(r8), intent(in) :: svstr(LBi:UBi,LBj:UBj)
# endif
# endif
# if defined USECOS_BURIAL
real(r8), intent(in) :: bustr(LBi:UBi,LBj:UBj)
real(r8), intent(in) :: bvstr(LBi:UBi,LBj:UBj)
# endif
# ifdef CARBON
real(r8), intent(inout) :: pH(LBi:UBi,LBj:UBj)
# endif
# ifdef DIAGNOSTICS_BIO
real(r8), intent(inout) :: DiaBio2d(LBi:UBi,LBj:UBj,NDbio2d)
real(r8), intent(inout) :: DiaBio3d(LBi:UBi,LBj:UBj,UBk,NDbio3d)
# endif
real(r8), intent(inout) :: t(LBi:UBi,LBj:UBj,UBk,3,UBt)
#endif
!
! Local variable declarations.
!
#ifdef CARBON
integer, parameter :: Nsink = 9
#else
integer, parameter :: Nsink = 7
#endif
integer :: Iter, i, ibio, isink, itrc, ivar, j, k, ks
integer, dimension(Nsink) :: idsink
real(r8), parameter :: eps = 1.0e-20_r8
#if defined CARBON || (defined OXYGEN || defined H_SULF)
real(r8) :: u10squ
#endif
!
#if defined OXYGEN || defined H_SULF
real(r8), parameter :: OA0 = 2.00907_r8 ! Oxygen
real(r8), parameter :: OA1 = 3.22014_r8 ! saturation
real(r8), parameter :: OA2 = 4.05010_r8 ! coefficients
real(r8), parameter :: OA3 = 4.94457_r8
real(r8), parameter :: OA4 =-0.256847_r8
real(r8), parameter :: OA5 = 3.88767_r8
real(r8), parameter :: OB0 =-0.00624523_r8
real(r8), parameter :: OB1 =-0.00737614_r8
real(r8), parameter :: OB2 =-0.0103410_r8
real(r8), parameter :: OB3 =-0.00817083_r8
real(r8), parameter :: OC0 =-0.000000488682_r8
! real(r8), parameter :: rOxNO3= 8.625_r8 ! 138/16
! real(r8), parameter :: rOxNH4= 6.625_r8 ! 106/16
real(r8), parameter :: rOxNO3= 9.625_r8 ! 138/16
real(r8), parameter :: rOxNH4= 7.625_r8 ! 106/16
real(r8), parameter :: rOxPO4= 106.0_r8 ! 106/1
real(r8), parameter :: rNxP_D= 45.0_r8 ! 45
real(r8), parameter :: rNxP_P= 16.0_r8 ! 16
real(r8), parameter :: NxP_D= 0.02222222_r8 ! 45
real(r8), parameter :: NxP_P= 0.0625_r8 ! 16
!real(r8), parameter :: kinhO2dn = 0.1_r8 ! 7.0 (10-15)
real(r8), parameter :: kinhO2dn = 1.0_r8 ! 7.0 (10-15)
real(r8), parameter :: kinhO2an = 0.1_r8 ! 0.5 (1-5)
real(r8), parameter :: kinhNO3an= 4.0_r8 ! 5.0 (1-5)
real(r8), parameter :: kO2 = 0.3_r8 ! 5.0 (3)
real(r8), parameter :: kNO3= 15.0_r8 ! 7.0 (30)
! real(r8), parameter :: kNO2= 30.0_r8 ! 1.0 (?)
real(r8), parameter :: kNO2= 1.0_r8 ! 1.0 (?)
real(r8), parameter :: kSO2= 1.0_r8 ! Bo
real(r8), parameter :: kSNO3= 3.0_r8 ! Bo
real(r8), parameter :: kSNO2= 6.0_r8 ! Bo (?)
real(r8), parameter :: KH2SO= 0.93_r8 ! Bo
real(r8), parameter :: KH2SN1= 0.93_r8 ! Bo
real(r8), parameter :: KH2SN2= 0.33_r8 ! Bo
real(r8), parameter :: KANMX= 0.07_r8 ! Yakhusev 0.03
real(r8), parameter :: LNO3= 1.0_r8 ! Anderson, 1982
real(r8), parameter :: LNO2= 1.0_r8 ! 1-LNO3
real(r8), parameter :: eNO2= 1.0_r8 ! electron NO2 to NO3
! real(r8), parameter :: gNO2= 0.055_r8 ! rate nitrifi NO2 (d-1)
real(r8), parameter :: I_thNO2= 0.0364_r8 ! Olson, 1981
real(r8), parameter :: D_p5NO2= 0.074_r8 ! Olson, 1981 0.074
! real(r8), parameter :: NitriR2= 0.005_r8 ! 0.005
real(r8), parameter :: NitriR2= 0.05_r8 ! 0.05
real(r8) :: l2mol = 1000.0_r8/22.3916_r8 ! liter to mol
#endif
#ifdef CARBON
integer :: iday, month, year
integer, parameter :: DoNewton = 0 ! pCO2 solver
real(r8), parameter :: Acoef = 2073.1_r8 ! Schmidt
real(r8), parameter :: Bcoef = 125.62_r8 ! number
real(r8), parameter :: Ccoef = 3.6276_r8 ! transfer
real(r8), parameter :: Dcoef = 0.043219_r8 ! coefficients
real(r8), parameter :: A1 = -60.2409_r8 ! surface
real(r8), parameter :: A2 = 93.4517_r8 ! CO2
real(r8), parameter :: A3 = 23.3585_r8 ! solubility
real(r8), parameter :: B1 = 0.023517_r8 ! coefficients
real(r8), parameter :: B2 = -0.023656_r8
real(r8), parameter :: B3 = 0.0047036_r8
real(r8) :: pmonth ! months since Jan 1951
real(r8) :: pCO2air_secular
real(r8) :: yday, hour
real(r8), parameter :: pi2 = 6.2831853071796_r8
real(r8), parameter :: D0 = 282.6_r8 ! coefficients
real(r8), parameter :: D1 = 0.125_r8 ! to calculate
real(r8), parameter :: D2 =-7.18_r8 ! secular trend in
real(r8), parameter :: D3 = 0.86_r8 ! atmospheric pCO2
real(r8), parameter :: D4 =-0.99_r8
real(r8), parameter :: D5 = 0.28_r8
real(r8), parameter :: D6 =-0.80_r8
real(r8), parameter :: D7 = 0.06_r8
#endif
real(r8) :: Att, AttFac, ExpAtt, Itop, PAR, K_PO41, K_PO42
real(r8) :: Epp, L_NH4, L_NO3, LTOT, Vp, Epp2, Vp2
real(r8) :: Chl2C, dtdays, t_PPmax, inhNH4, t_PPmax2
real(r8) :: cff, cff1, cff2, cff3, cff4, cff5, cff6, cff7
real(r8) :: cff22, cff222, cff55, cff41, cff71, cff51, ranmx
real(r8) :: cff61, cff11, cffi, fac33, cff33, fanmx, fac22
real(r8) :: fac1, fac2, fac3, fac12, fac4, cff8, cff9
real(r8) :: cffL, cffR, cu, dltL, dltR, fac5, cff66, cff10
real(r8) :: total_N, T_N, K_f, K_p, PhyIS2, L_PO4
real(r8) :: ws, wscrit, Tcrit, amp, dlim2, fd2, cff32
real(r8) :: oxlim, dlim1, srlim, tolim, fox, fd1, fsr
real(r8) :: N_Flux_Lim, N_Flux_N, N_Flux_P, N_Flux_PmortalD
real(r8) :: N_Flux_RemineSc, N_Flux_RemineLc, N_Flux_RemineDc
real(r8) :: NO3_scratch, NH4_scratch, PO4_scratch
real(r8) :: PNfrac1, PNfrac2, N_Flux_NewProd_NO3_lim
real(r8) :: N_Flux_RegProd_lim, N_Flux_NewProd_P_lim
real(r8) :: TSS
#ifdef DIAGNOSTICS_BIO
real(r8) :: fiter
#endif
#if defined OXYGEN || defined H_SULF
real(r8) :: SchmidtN_Ox, O2satu, O2_Flux
real(r8) :: TS, AA
#endif
#ifdef CARBON
real(r8) :: CO2_Flux, CO2_sol, SchmidtN, TempK, cff1C, cff2C
real(r8) :: C_Flux_CoagP, C_Flux_CoagD, C_Flux_Remine
#endif
real(r8) :: N_Flux_Assim, P_Flux_Assim
real(r8) :: N_Assim_Excess
real(r8) :: N_Flux_CoagD, N_Flux_CoagP
real(r8) :: N_Flux_EgestP, N_Flux_EgestD
real(r8) :: P_Flux_EgestP, P_Flux_EgestD
real(r8) :: N_Flux_NewProd_NO3, N_Flux_RegProd
real(r8) :: N_Flux_Nitrifi, N_Flux_NewProd_NFix
real(r8) :: N_Flux_Nitrifi2, N_Flux_NewProd_P
real(r8) :: N_Flux_Pmortal, N_Flux_Zmortal
real(r8) :: N_Flux_Remine, P_Flux_Remine
real(r8) :: N_Flux_Zexcret, N_Flux_Zmetabo
real(r8) :: cff3P, fac12P, fac1P, fac33P, fac34
real(r8) :: fac34P, P_Flux_Zexcret
real(r8) :: cff1P, cff2P, P_Flux_CoagP, P_Flux_CoagD
real(r8) :: N_Flux_Zexcret_Diaz, N_Flux_Zexcret_Phyt
real(r8) :: P_Flux_Zexcret_Diaz, P_Flux_Zexcret_Phyt
real(r8) :: N_Flux_RemineD
real(r8) :: P_Flux_RemineD
real(r8) :: rDON
real(r8) :: Cbe, CNbur, ReSuspR, Ustarb
real(r8) :: cff12, cff13, cff14, cff15, cff16, cff17, cff18
real(r8) :: N_Flux_SolubS, N_Flux_SolubL, P_Flux_SolubS, P_Flux_SolubL
real(r8) :: N_Flux_RemineSa, N_Flux_RemineLa, N_Flux_RemineDa
real(r8) :: P_Flux_RemineSa, P_Flux_RemineLa, P_Flux_RemineDa
real(r8) :: f_NTR, f_DNF,cff3c,cff6c,cff9c
real(r8) :: cff3a,cff3b,cff13a,cff13b,cff16a,cff16b
real(r8), dimension(Nsink) :: Wbio
integer, dimension(IminS:ImaxS,N(ng)) :: ksource
real(r8), dimension(IminS:ImaxS) :: PARsur
#ifdef CARBON
real(r8), dimension(IminS:ImaxS) :: pCO2
#endif
real(r8), dimension(IminS:ImaxS,N(ng),NT(ng)) :: Bio
real(r8), dimension(IminS:ImaxS,N(ng),NT(ng)) :: Bio_old
real(r8), dimension(IminS:ImaxS,0:N(ng)) :: FC
real(r8), dimension(IminS:ImaxS,N(ng)) :: Hz_inv
real(r8), dimension(IminS:ImaxS,N(ng)) :: Hz_inv2
real(r8), dimension(IminS:ImaxS,N(ng)) :: Hz_inv3
real(r8), dimension(IminS:ImaxS,N(ng)) :: WL
real(r8), dimension(IminS:ImaxS,N(ng)) :: WR
real(r8), dimension(IminS:ImaxS,N(ng)) :: bL
real(r8), dimension(IminS:ImaxS,N(ng)) :: bR
real(r8), dimension(IminS:ImaxS,N(ng)) :: qc
#include "set_bounds.h"
#ifdef DIAGNOSTICS_BIO
!
!-----------------------------------------------------------------------
! If appropriate, initialize time-averaged diagnostic arrays.
!-----------------------------------------------------------------------
!
IF (((iic(ng).gt.ntsDIA(ng)).and. &
& (MOD(iic(ng),nDIA(ng)).eq.1)).or. &
& ((iic(ng).ge.ntsDIA(ng)).and.(nDIA(ng).eq.1)).or. &
& ((nrrec(ng).gt.0).and.(iic(ng).eq.ntstart(ng)))) THEN
DO ivar=1,NDbio2d
DO j=Jstr,Jend
DO i=Istr,Iend
DiaBio2d(i,j,ivar)=0.0_r8
END DO
END DO
END DO
DO ivar=1,NDbio3d
DO k=1,N(ng)
DO j=Jstr,Jend
DO i=Istr,Iend
DiaBio3d(i,j,k,ivar)=0.0_r8
END DO
END DO
END DO
END DO
END IF
#endif
!
!-----------------------------------------------------------------------
! Add biological Source/Sink terms.
!-----------------------------------------------------------------------
!
! Avoid computing source/sink terms if no biological iterations.
!
IF (BioIter(ng).le.0) RETURN
!
! Set time-stepping according to the number of iterations.
!
dtdays=dt(ng)*sec2day/REAL(BioIter(ng),r8)
#ifdef DIAGNOSTICS_BIO
!
! A factor to account for the number of iterations in accumulating
! diagnostic rate variables.
!
fiter=1.0_r8/REAL(BioIter(ng),r8)
#endif
!
! Set vertical sinking indentification vector.
!
idsink(1)=iPhyt
idsink(2)=iChlo
idsink(3)=iSDeN
idsink(4)=iLDeN
idsink(5)=iSDeP
idsink(6)=iLDeP
idsink(7)=iDiaz
#ifdef CARBON
idsink(8)=iSDeC
idsink(9)=iLDeC
#endif
!
! Set vertical sinking velocity vector in the same order as the
! identification vector, IDSINK.
!
Wbio(1)=wPhy(ng) ! phytoplankton
Wbio(2)=wPhy(ng) ! chlorophyll
Wbio(3)=wSDet(ng) ! small Nitrogen-detritus
Wbio(4)=wLDet(ng) ! large Nitrogen-detritus
Wbio(5)=wSDet(ng) ! small P-detritus
Wbio(6)=wLDet(ng) ! large P-detritus
Wbio(7)=wPhy(ng) ! Diazotroph
#ifdef CARBON
Wbio(8)=wSDet(ng) ! small Carbon-detritus
Wbio(9)=wLDet(ng) ! large Carbon-detritus
#endif
!
! Compute inverse thickness to avoid repeated divisions.
!
J_LOOP : DO j=Jstr,Jend
DO k=1,N(ng)
DO i=Istr,Iend
Hz_inv(i,k)=1.0_r8/Hz(i,j,k)
END DO
END DO
DO k=1,N(ng)-1
DO i=Istr,Iend
Hz_inv2(i,k)=1.0_r8/(Hz(i,j,k)+Hz(i,j,k+1))
END DO
END DO
DO k=2,N(ng)-1
DO i=Istr,Iend
Hz_inv3(i,k)=1.0_r8/(Hz(i,j,k-1)+Hz(i,j,k)+Hz(i,j,k+1))
END DO
END DO
!
! Extract biological variables from tracer arrays, place them into
! scratch arrays, and restrict their values to be positive definite.
! At input, all tracers (index nnew) from predictor step have
! transport units (m Tunits) since we do not have yet the new
! values for zeta and Hz. These are known after the 2D barotropic
! time-stepping.
!
DO itrc=1,NBT
ibio=idbio(itrc)
DO k=1,N(ng)
DO i=Istr,Iend
Bio_old(i,k,ibio)=MAX(0.0_r8,t(i,j,k,nstp,ibio))
Bio(i,k,ibio)=Bio_old(i,k,ibio)
END DO
END DO
END DO
#ifdef CARBON
DO k=1,N(ng)
DO i=Istr,Iend
Bio_old(i,k,iTIC_)=MIN(Bio_old(i,k,iTIC_),3000.0_r8)
Bio_old(i,k,iTIC_)=MAX(Bio_old(i,k,iTIC_),400.0_r8)
Bio(i,k,iTIC_)=Bio_old(i,k,iTIC_)
END DO
END DO
#endif
!
! Extract potential temperature and salinity.
!
DO k=1,N(ng)
DO i=Istr,Iend
Bio(i,k,itemp)=MIN(t(i,j,k,nstp,itemp),35.0_r8)
Bio(i,k,isalt)=MAX(t(i,j,k,nstp,isalt), 0.0_r8)
END DO
END DO
!
! Calculate surface Photosynthetically Available Radiation (PAR). The
! net shortwave radiation is scaled back to Watts/m2 and multiplied by
! the fraction that is photosynthetically available, PARfrac.
!
DO i=Istr,Iend
PARsur(i)=PARfrac(ng)*srflx(i,j)*rho0*Cp
END DO
!
!=======================================================================
! Start internal iterations to achieve convergence of the nonlinear
! backward-implicit solution.
!=======================================================================
!
! During the iterative procedure a series of fractional time steps are
! performed in a chained mode (splitting by different biological
! conversion processes) in sequence of the main food chain. In all
! stages the concentration of the component being consumed is treated
! in fully implicit manner, so the algorithm guarantees non-negative
! values, no matter how strong s the concentration of active consuming
! component (Phytoplankton or Zooplankton). The overall algorithm,
! as well as any stage of it, is formulated in conservative form
! (except explicit sinking) in sense that the sum of concentration of
! all components is conserved.
!
!
! In the implicit algorithm, we have for example (N: nitrate,
! P: phytoplankton),
!
! N(new) = N(old) - uptake * P(old) uptake = mu * N / (Kn + N)
! {Michaelis-Menten}
! below, we set
! The N in the numerator of
! cff = mu * P(old) / (Kn + N(old)) uptake is treated implicitly
! as N(new)
!
! so the time-stepping of the equations becomes:
!
! N(new) = N(old) / (1 + cff) (1) when substracting a sink term,
! consuming, divide by (1 + cff)
! and
!
! P(new) = P(old) + cff * N(new) (2) when adding a source term,
! growing, add (cff * source)
!
! Notice that if you substitute (1) in (2), you will get:
!
! P(new) = P(old) + cff * N(old) / (1 + cff) (3)
!
! If you add (1) and (3), you get
!
! N(new) + P(new) = N(old) + P(old)
!
! implying conservation regardless how "cff" is computed. Therefore,
! this scheme is unconditionally stable regardless of the conversion
! rate. It does not generate negative values since the constituent
! to be consumed is always treated implicitly. It is also biased
! toward damping oscillations.
!
! The iterative loop below is to iterate toward an universal Backward-
! Euler treatment of all terms. So if there are oscillations in the
! system, they are only physical oscillations. These iterations,
! however, do not improve the accuaracy of the solution.
!
ITER_LOOP: DO Iter=1,BioIter(ng)
!
!-----------------------------------------------------------------------
! Light-limited computations.
!-----------------------------------------------------------------------
!
! Compute attenuation coefficient based on the concentration of
! chlorophyll-a within each grid box. Then, attenuate surface
! photosynthetically available radiation (PARsur) down inot the
! water column. Thus, PAR at certain depth depends on the whole
! distribution of chlorophyll-a above.
! To compute rate of maximum primary productivity (t_PPmax), one needs
! PAR somewhat in the middle of the gridbox, so that attenuation "Att"
! corresponds to half of the grid box height, while PAR is multiplied
! by it twice: once to get it in the middle of grid-box and once the
! compute on the lower grid-box interface.
!
DO i=Istr,Iend
PAR=PARsur(i)
AttFac=0.0_r8
IF (PARsur(i).gt.0.0_r8) THEN
DO k=N(ng),1,-1
!ADD CHESROMS_BGC_ATT from original chesroms_ECB
TSS = (Bio(i,k,iZoop)*ZooCN(ng) + &
& Bio(i,k,iPhyt)*PhyCN(ng) + &
& Bio(i,k,iSDeC) + &
& Bio(i,k,iLDeC))*12.0_r8/1000.0_r8
! Convert TSS from g-C/m3 to g/m3:
TSS = TSS * 2.9_r8 ! Cerco et al., 2017.
!# ifdef ISS_2_SIZE_CLASSES
! TSS = TSS + Bio(i,k,iISS1) + Bio(i,k,iISS2)
!# endif
Att=(rkd1(ng)+rkdChl1(ng)*Bio(i,k,iChlo)+ &
& rkdTSS1(ng)*TSS+rkdS1(ng)*Bio(i,k,isalt))
Att=max( Att, 0.6_r8 ) ! The 0.6 is from Fei Da, 201705.
Att=Att*(z_w(i,j,k)-z_w(i,j,k-1))
!
! Compute average light attenuation for each grid cell. To include
! other attenuation contributions like suspended sediment or CDOM
! modify AttFac.
!
! Att=(AttSW(ng)+ &
! & AttChl(ng)*Bio(i,k,iChlo)+ &
! & AttFac)* &
! & (z_w(i,j,k)-z_w(i,j,k-1))
ExpAtt=EXP(-Att)
Itop=PAR
PAR=Itop*(1.0_r8-ExpAtt)/Att ! average at cell center
!
! Compute Chlorophyll-a phytoplankton ratio, [mg Chla / (mg C)].
!
cff=PhyCN(ng)*12.0_r8
cffi=Bio(i,k,iPhyt)+Bio(i,k,iDiaz)
Chl2C=MIN(Bio(i,k,iChlo)/(cffi*cff+eps), &
& Chl2C_m(ng))
! Temperature-limited and light-limited growth rate (Eppley, R.W.,
! 1972, Fishery Bulletin, 70: 1063-1085; here 0.59=ln(2)*0.851).
! Check value for Vp is 2.9124317 at 19.25 degC.
! Vp=Vp0(ng)*0.59_r8*(1.066_r8**Bio(i,k,itemp))
#ifdef FIXED_Vp0
Vp=Vp0(ng)
#else
!
! Temperature-dependent growth rate
! This replaces the Eppley-1972 parameterization of Fennel et al. 2006
! Rate is inspired from Cerco&Noel 2004 and Lomas et al. 2002 (Q10).
! psl20190904: Use linear Q10 of Lomas et al.2002; lower NPP in winter.
Vp = max( 1.50_r8, &
& 0.55_r8 * exp( 0.08065_r8 * Bio(i,k,itemp) ) )
!psl Vp = max( 2.15_r8, &
!psl & 0.60_r8 * exp( 0.07800_r8 * Bio(i,k,itemp) ) )
#endif
fac1=PAR*PhyIS(ng)
Epp=Vp/SQRT(Vp*Vp+fac1*fac1)
t_PPmax=Epp*fac1
!
! Nitrogen fixation (Fennel, 2002).
!
#ifdef BULK_FLUXES
ws=(Uwind(i,j)**2+Vwind(i,j)**2)*1.22_r8*0.0013_r8
#else
ws=SQRT((0.5_r8*(sustr(i,j)+sustr(i+1,j)))**2+ &
& (0.5_r8*(svstr(i,j)+svstr(i,j+1)))**2)
#endif
wscrit=0.062_r8
Tcrit=24.75_r8
IF (ws.le.wscrit) then
amp=(TANH(2.0_r8*(Bio(i,k,itemp)-Tcrit))+1.0_r8)/3.0_r8+ &
& (1.0_r8/3.0_r8)
ELSE
amp=(TANH(2.0_r8*(Bio(i,k,itemp)-Tcrit))+1.0_r8)/6.0_r8+ &
& (1.0_r8/6.0_r8)
END IF
! Vp2=2.2_r8*0.085_r8*(1.066_r8**Bio(i,k,itemp)) ! FeFac == 1.0nm Fe open ocean
Vp2=2.2_r8*0.0_r8*(1.066_r8**Bio(i,k,itemp)) ! change Vp2 to 0
Epp2=Vp2/SQRT(Vp2*Vp2+fac1*fac1)
t_PPmax2=Epp2*fac1 ! xamp
fac1=dtdays*t_PPmax
fac12=dtdays*t_PPmax2
!
! Nutrient-limitation terms (Parker 1993 Ecol Mod., 66, 113-120).
!
K_PO41=K_NO3(ng)*8.0_r8 ! 16
K_PO42=K_NO3(ng)*8.0_r8 ! 160
cff1=Bio(i,k,iNH4_)*K_NH4(ng)
cff2=Bio(i,k,iNO3_)*K_NO3(ng)
cff22=Bio(i,k,iPO4_)*K_PO41 ! uptake P by plankt
inhNH4=1.0_r8/(1.0_r8+cff1)
L_NH4=cff1/(1.0_r8+cff1)
L_NO3=cff2*inhNH4/(1.0_r8+cff2)
L_PO4=cff22/(1.0_r8+cff22)
LTOT=MIN(L_NO3+L_NH4,L_PO4)
!
! Nitrate and ammonium uptake by Phytoplankton.
!
! Updated from Azhar et al. (2014) as follows: the sink terms for
! NO3, NH4 and PO4 are each assigned initial scratch values; the
! scratch value for phosphorus uptake (N_Flux_NewProd_P) assumes
! that nitrogen is not limiting, and vice versa for the scratch
! nitrogen uptake (N_Flux_N). Then, the smaller of these two values
! is added to the phytoplankton biomass pool. Once this is done,
! the actual sinks of PO4, NO3, and NH4 are computed by multiplying
! the scratch values by the value PNfrac1 or PNfrac2. For example,
! if nitrogen is limiting, then the scratch nitrogen sink flux is
! made smaller by multiplying it by PNfrac1. -KGH, Mar. 2018.
! WC_NITRIFICATION && defined WC_DENITRIFICATION
f_NTR = Bio(i,k,iOxyg)/(Bio(i,k,iOxyg) + kinhO2dn)
f_DNF = kinhO2dn/(Bio(i,k,iOxyg) + kinhO2dn)
cff4=fac1*K_NO3(ng)*inhNH4/(1.0_r8+cff2)*Bio(i,k,iPhyt)
cff5=fac1*K_NH4(ng)/(1.0_r8+cff1)*Bio(i,k,iPhyt)
cff6=fac1*K_PO41/(1.0_r8+cff22)*(Bio(i,k,iPhyt))
NO3_scratch=Bio(i,k,iNO3_)/(1.0_r8+cff4)
NH4_scratch=Bio(i,k,iNH4_)/(1.0_r8+cff5)
PO4_scratch=Bio(i,k,iPO4_)/(1.0_r8+cff6)
N_Flux_NewProd_NO3=NO3_scratch*cff4
N_Flux_RegProd=NH4_scratch*cff5
N_Flux_NewProd_P=PO4_scratch*cff6*rNxP_P
N_Flux_N=N_Flux_NewProd_NO3+N_Flux_RegProd
N_Flux_Lim=MIN(N_Flux_N,N_Flux_NewProd_P)
Bio(i,k,iPhyt)=Bio(i,k,iPhyt)+ &
& (1.0_r8-EsDON(ng)- &
& (f_NTR+f_DNF)*ElDON(ng))*N_Flux_Lim
PNfrac1=N_Flux_NewProd_P/N_Flux_N
PNfrac2=1.0_r8/PNfrac1
N_Flux_NewProd_P_lim=N_Flux_NewProd_P*MIN(PNfrac2,1.0_r8)
N_Flux_NewProd_NO3_lim=N_Flux_NewProd_NO3*MIN(PNfrac1,1.0_r8)
N_Flux_RegProd_lim=N_Flux_RegProd*MIN(PNfrac1,1.0_r8)
Bio(i,k,iPO4_)=Bio(i,k,iPO4_)-N_Flux_NewProd_P_lim*NxP_P
Bio(i,k,iNO3_)=Bio(i,k,iNO3_)-N_Flux_NewProd_NO3_lim
Bio(i,k,iNH4_)=Bio(i,k,iNH4_)-N_Flux_RegProd_lim
!
! Nitrogen fixation by diazotrophs.
!
cff222=Bio(i,k,iPO4_)*K_PO42
cff55=fac12*K_PO42/(1.0_r8+cff222)*(Bio(i,k,iDiaz)/rNxP_D)
Bio(i,k,iPO4_)=Bio(i,k,iPO4_)/(1.0_r8+cff55)
N_Flux_NewProd_NFix=Bio(i,k,iPO4_)*cff55*rNxP_D
Bio(i,k,iDiaz)=Bio(i,k,iDiaz)+N_Flux_NewProd_NFix
Bio(i,k,iN2__)=Bio(i,k,iN2__)-N_Flux_NewProd_NFix
!
! End of Nitrogen fixation process
!
Bio(i,k,iChlo)=Bio(i,k,iChlo)+ &
& (1.0_r8-EsDON(ng)- &
& (f_NTR+f_DNF)*ElDON(ng))* &
& (dtdays*t_PPmax*t_PPmax*LTOT*LTOT* &
& Chl2C_m(ng)*Bio(i,k,iChlo))/ &
& (PhyIS(ng)*MAX(Chl2C,eps)*PAR+eps)
#ifdef DIAGNOSTICS_BIO
DiaBio3d(i,j,k,iPPro)=DiaBio3d(i,j,k,iPPro)+ &
# ifdef WET_DRY
& rmask_full(i,j)* &
# endif
& (N_Flux_Lim+ &
& N_Flux_NewProd_NFix)*fiter
DiaBio3d(i,j,k,iNO3u)=DiaBio3d(i,j,k,iNO3u)+ &
# ifdef WET_DRY
& rmask_full(i,j)* &
# endif
& N_Flux_NewProd_NO3_lim*fiter
DiaBio3d(i,j,k,iPO4u)=DiaBio3d(i,j,k,iPO4u)+ &
# ifdef WET_DRY
& rmask_full(i,j)* &
# endif
& N_Flux_NewProd_P_lim*NxP_P*fiter
DiaBio3d(i,j,k,iNFix)=DiaBio3d(i,j,k,iNFix)+ &
# ifdef WET_DRY
& rmask_full(i,j)* &
# endif
& N_Flux_NewProd_NFix* &
& fiter
#endif
! WC_NITRIFICATION && defined WC_DENITRIFICATION
f_NTR = Bio(i,k,iOxyg)/(Bio(i,k,iOxyg) + kinhO2dn)
f_DNF = kinhO2dn/(Bio(i,k,iOxyg) + kinhO2dn)
! Phytoplankton exudation of semilabile DON to DON
Bio(i,k,iDON_)=Bio(i,k,iDON_)+EsDON(ng)* &
& (N_Flux_NewProd_NO3_lim+N_Flux_RegProd_lim)
! Phytoplankton exudation of labile DON to NH4
Bio(i,k,iNH4_)=Bio(i,k,iNH4_)+(f_NTR+f_DNF)*ElDON(ng)* &
& (N_Flux_NewProd_NO3_lim+N_Flux_RegProd_lim)
! Phytoplankton exudation of semilabile DOP to DOP
Bio(i,k,iDOP_)=Bio(i,k,iDOP_)+EsDON(ng)* &
& N_Flux_NewProd_P_lim*NxP_P
! Phytoplankton exudation of labile DOP to PO4
Bio(i,k,iPO4_)=Bio(i,k,iPO4_)+ElDON(ng)* &
& N_Flux_NewProd_P_lim*NxP_P
#if defined OXYGEN || defined H_SULF
! WC_DENITRIFICATION
f_NTR = Bio(i,k,iOxyg)/(Bio(i,k,iOxyg) + kinhO2dn)
Bio(i,k,iOxyg)=Bio(i,k,iOxyg)+ &
& N_Flux_NewProd_NO3_lim*rOxNO3+ &
& N_Flux_NewProd_NFix*rOxNH4+ &
& N_Flux_RegProd_lim*rOxNH4 &
& -rOxNH4*f_NTR*ElDON(ng)* &
& (N_Flux_NewProd_NO3_lim+N_Flux_RegProd_lim)
Bio(i,k,iOxyg)=MAX(Bio(i,k,iOxyg),0.0_r8)
#endif
#ifdef CARBON
!
! Total inorganic carbon (CO2) uptake during phytoplankton growth.
!
cff1=PhyCN(ng)*(N_Flux_Lim+N_Flux_NewProd_NFix)
Bio(i,k,iTIC_)=Bio(i,k,iTIC_)-cff1
# ifdef TALK_NONCONSERV
!
! Account for the uptake of NO3 on total alkalinity.
!
Bio(i,k,iTAlk)=Bio(i,k,iTAlk)+N_Flux_NewProd_NO3_lim+ &
& N_Flux_NewProd_NFix
# endif
#endif
!
! The Nitrification of NH4 ==> NO3 is thought to occur only in dark and
! only in aerobic water (see Olson, R. J., 1981, JMR: (39), 227-238.).
!
! NH4+ + 3/2 O2 ==> NO2- + H2O; via Nitrosomonas bacteria
! NO2- + 1/2 O2 ==> NO3- ; via Nitrobacter bacteria
!
! Note that the entire process has a total loss of two moles of O2 per
! mole of NH4. If we were to resolve NO2 profiles, this is where we
! would change the code to split out the differential effects of the
! two different bacteria types. If OXYGEN is defined, nitrification is
! inhibited at low oxygen concentrations using a Michaelis-Menten term.
!
#if defined OXYGEN || defined H_SULF
fac2=MAX(Bio(i,k,iOxyg),0.0_r8) ! O2 max
fac3=MAX(fac2/(3.0_r8+fac2),0.0_r8) ! MM for O2 dependence
fac1=dtdays*NitriR(ng)*fac3
fac12=dtdays*NitriR2*fac3
#else
fac1=dtdays*NitriR(ng)
#endif
!
!...........Through Nitrosomonas
!
cff1=(PAR-I_thNH4(ng))/ &
& (D_p5NH4(ng)+PAR-2.0_r8*I_thNH4(ng))
cff2=1.0_r8-MAX(0.0_r8,cff1)
cff3=fac1*cff2
Bio(i,k,iNH4_)=Bio(i,k,iNH4_)/(1.0_r8+cff3)
N_Flux_Nitrifi=Bio(i,k,iNH4_)*cff3
Bio(i,k,iNO2_)=Bio(i,k,iNO2_)+N_Flux_Nitrifi
!
!...........Through Nitrobacter
!
cff4=(PAR-I_thNO2)/(D_p5NO2+PAR-2.0_r8*I_thNO2)
cff5=1.0_r8-MAX(0.0_r8,cff4)
cff6=fac12*cff5
Bio(i,k,iNO2_)=Bio(i,k,iNO2_)/(1.0_r8+cff6)
N_Flux_Nitrifi2=Bio(i,k,iNO2_)*cff6
Bio(i,k,iNO3_)=Bio(i,k,iNO3_)+N_Flux_Nitrifi2
#if defined OXYGEN || defined H_SULF
Bio(i,k,iOxyg)=Bio(i,k,iOxyg)-1.5_r8*N_Flux_Nitrifi- &
& 0.5_r8*N_Flux_Nitrifi2
#endif
#ifdef DIAGNOSTICS_BIO
DiaBio3d(i,j,k,iNit1)=DiaBio3d(i,j,k,iNit1)+ &
# ifdef WET_DRY
& rmask_full(i,j)* &
# endif
& N_Flux_Nitrifi*fiter
DiaBio3d(i,j,k,iNit2)=DiaBio3d(i,j,k,iNit2)+ &
# ifdef WET_DRY
& rmask_full(i,j)* &
# endif
& N_Flux_Nitrifi2*fiter
#endif
#if defined CARBON && defined TALK_NONCONSERV
Bio(i,k,iTAlk)=Bio(i,k,iTAlk)-N_Flux_Nitrifi
#endif
!
! Light attenuation at the bottom of the grid cell. It is the starting
! PAR value for the next (deeper) vertical grid cell.
!
PAR=Itop*ExpAtt
END DO
!
! If PARsur=0, nitrification occurs at the maximum rate (NitriR).
!
ELSE
DO k=N(ng),1,-1
#if defined OXYGEN || defined H_SULF
fac2=MAX(Bio(i,k,iOxyg)-0.3_r8,0.0_r8) ! O2 max
fac3=MAX(fac2/(1.0_r8+fac2),0.0_r8) ! MM for O2 dependence
cff3=dtdays*NitriR(ng)*fac3
cff32=dtdays*NitriR2*fac3
#else
cff3=dtdays*NitriR(ng)
cff32=dtdays*NitriR2
#endif
!
!.......Through Nitrosomonas
!
Bio(i,k,iNH4_)=Bio(i,k,iNH4_)/(1.0_r8+cff3)
N_Flux_Nitrifi=Bio(i,k,iNH4_)*cff3
Bio(i,k,iNO2_)=Bio(i,k,iNO2_)+N_Flux_Nitrifi
!
!.......Through Nitrobacter
!
Bio(i,k,iNO2_)=Bio(i,k,iNO2_)/(1.0_r8+cff32)
N_Flux_Nitrifi2=Bio(i,k,iNO2_)*cff32
Bio(i,k,iNO3_)=Bio(i,k,iNO3_)+N_Flux_Nitrifi2