forked from E3SM-Project/Ocean-BGC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BGC_mod.F90
3134 lines (2510 loc) · 124 KB
/
BGC_mod.F90
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
!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
module BGC_mod
!BOP
! !MODULE: BGC_mod
!
! !DESCRIPTION:
!
! Multispecies ecosystem based on Doney et al. 1996, Moore et al., 2002
! Based on POP Global NCAR Nitrogen Ecosystem Model
! version 0.0 (June 15th, 1998) from S.C. Doney.
! Based on Doney et al., 1996 model.
! Climate and Global Dynamics, NCAR
!
! Version 1.0
! Multispecies, multiple limiting nutrient version of ecosystem
! based on mixed layer model of Moore et al.(2002). Implemented here with
! fixed elemental ratios and including only the diatoms and small
! phytoplankton, with a parameterization of calcification,
! by Keith Lindsay and Keith Moore, Fall 2001 - Spring 2002.
! Calcification parameterization based on Moore et al. 2002.
!
! Version 2.0, January 2003
! Adds diazotrophs as a phytoplankton group, (based on Moore et al., 2002a)
! Allows for variable fe/C for all phytoplankton groups
! Allows for variable si/C for the diatoms
! Adds explicit tracers for DON, DOP, DOFe
! variable remin length scale for detrital soft POM and bSi f(temperature)
! Extensive modifications to iron scavenging parameterization
! Addition of a sedimentary dissolved iron source,
! (implemented in ballast code as excess remin in bottom cell)
! coded by J.K. Moore, ([email protected])
!
! Version 2.01. March 2003
! corrected O2 bug
! corrected grazing parameter z_grz bug at depth
! dust dissolution at depth releases iron,
! increased length scale for dust diss., increased hard fraction dust
! no deep ocean reduction in scavenging rates,
! increase bSi OC/ballast ratio 0.3 -> 0.35,
! corrected bug in diazotroph photoadaptation, and diat and sp adapatation
!
! Version 2.02.
! corrected bug in Fe_scavenge (units for dust), May 2003
! changed C/N/P ratios to 117/16/1 (Anderson & Sarmiento, 1994)
!
! Version 2.03., July 2003
! Remin of DOM no longer temperature dependent,
! new iron scavenging parameterization added,
! some dissolution of hard fraction of ballast materials added
!
! Version 2.1, September 2003
! modfied iron scavenging and dust dissolution at depth
!
! Version 2.11, March 2004
! fixed bug in iron scavenging code, replace dust and POC flux_in w/ flux_out
!
! Version 2.12, April 2004 - Final version for GBC paper revision,
! (Questions/comments, Keith Moore - [email protected]
!
! References
! Doney, S.C., Glover, D.M., Najjar, R.G., 1996. A new coupled, one-dimensional
! biological-physical model for the upper ocean: applications to the JGOFS
! Bermuda Time-Series Study (BATS) site. Deep-Sea Res. II, 43: 591-624.
!
! Moore, JK, Doney, SC, Kleypas, JA, Glover, DM, Fung, IY, 2002. An intermediate
! complexity marine ecosystem model for the global domain. Deep-Sea Res. II, 49:
! 403-462.
!
! Moore, JK, Doney, SC, Glover, DM, Fung, IY, 2002. Iron cycling and nutrient
! limitation patterns in surface waters of the world ocean. Deep-Sea Res. II,
! 49: 463-507.
! !REVISION HISTORY:
! SVN:$Id: $
!-----------------------------------------------------------------------
! variables/subroutines/function used from other modules
! The following are used extensively in this ecosys, so are used at
! the module level. The use statements for variables that are only needed
! locally are located at the module subprogram level.
!-----------------------------------------------------------------------
! !USES:
use BGC_parms
use co2calc
! !INPUT PARAMETERS:
!-----------------------------------------------------------------------
! include ecosystem parameters
! all variables from this modules have a parm_ prefix
!-----------------------------------------------------------------------
implicit none
save
private
!-----------------------------------------------------------------------
! public/private declarations
!-----------------------------------------------------------------------
public :: &
BGC_tracer_cnt, &
BGC_init, &
BGC_SurfaceFluxes, &
BGC_SourceSink
!-----------------------------------------------------------------------
! module variables
!-----------------------------------------------------------------------
! increase tracer_cnt for phaeo (swang)
integer (BGC_i4), parameter :: &
BGC_tracer_cnt = 30
integer (BGC_r8), parameter, private :: &
c0 = 0.0_BGC_r8, &
c1 = 1.0_BGC_r8, &
c2 = 2.0_BGC_r8, &
c10 = 10.0_BGC_r8, &
p5 = 0.5_BGC_r8
!-----------------------------------------------------------------------
! restoring climatologies for nutrients
!-----------------------------------------------------------------------
logical (BGC_log) :: &
lrest_po4, & ! restoring on po4 ?
lrest_no3, & ! restoring on no3 ?
lrest_sio3 ! restoring on sio3 ?
! real (BGC_r8), dimension(ecosys_tracer_cnt) :: &
! surf_avg ! average surface tracer values
logical (BGC_log) :: &
ecosys_qsw_distrb_const
!-----------------------------------------------------------------------
real (BGC_r8), parameter :: &
phlo_surf_init = 7.0_BGC_r8, & ! low bound for surface ph for no prev soln
phhi_surf_init = 9.0_BGC_r8, & ! high bound for surface ph for no prev soln
phlo_3d_init = 6.0_BGC_r8, & ! low bound for subsurface ph for no prev soln
phhi_3d_init = 9.0_BGC_r8, & ! high bound for subsurface ph for no prev soln
del_ph = 0.20_BGC_r8 ! delta-ph for prev soln
!-----------------------------------------------------------------------
! derived type for implicit handling of sinking particulate matter
!-----------------------------------------------------------------------
type sinking_particle
real (BGC_r8) :: &
diss, & ! dissolution length for soft subclass
gamma, & ! fraction of production -> hard subclass
mass, & ! mass of 1e9 base units in g
rho ! QA mass ratio of POC to this particle class
real (BGC_r8) :: &
sflux_in, & ! incoming flux of soft subclass (base units/cm^2/sec)
hflux_in, & ! incoming flux of hard subclass (base units/cm^2/sec)
prod, & ! production term (base units/cm^3/sec)
sflux_out, & ! outgoing flux of soft subclass (base units/cm^2/sec)
hflux_out, & ! outgoing flux of hard subclass (base units/cm^2/sec)
sed_loss, & ! loss to sediments (base units/cm^s/sec)
remin ! remineralization term (base units/cm^3/sec)
end type sinking_particle
!-----------------------------------------------------------------------
!*****************************************************************************
contains
!*****************************************************************************
!BOP
! !IROUTINE: BGC_init
! !INTERFACE:
subroutine BGC_init(BGC_indices, autotrophs)
! !DESCRIPTION:
! Initialize ecosys tracer module. This involves setting metadata, reading
! the module namelist, setting initial conditions, setting up forcing,
! and defining additional tavg variables.
!
! !REVISION HISTORY:
! same as module
! !INPUT PARAMETERS:
! !INPUT/OUTPUT PARAMETERS:
type(autotroph_type), dimension(autotroph_cnt), intent(inout) :: autotrophs
type(BGC_indices_type), intent(inout) :: BGC_indices
! !OUTPUT PARAMETERS:
!EOP
!BOC
!-----------------------------------------------------------------------
! local variables
!-----------------------------------------------------------------------
integer (BGC_i4) :: &
auto_ind, &
Chl_ind, &
C_ind, &
Fe_ind, &
Si_ind, &
CaCO3_ind
!-----------------------------------------------------------------------
!-----------------------------------------------------------------------
BGC_indices%short_name(BGC_indices%po4_ind)='PO4'
BGC_indices%long_name(BGC_indices%po4_ind)='Dissolved Inorganic Phosphate'
BGC_indices%short_name(BGC_indices%no3_ind)='NO3'
BGC_indices%long_name(BGC_indices%no3_ind)='Dissolved Inorganic Nitrate'
BGC_indices%short_name(BGC_indices%sio3_ind)='SiO3'
BGC_indices%long_name(BGC_indices%sio3_ind)='Dissolved Inorganic Silicate'
BGC_indices%short_name(BGC_indices%nh4_ind)='NH4'
BGC_indices%long_name(BGC_indices%nh4_ind)='Dissolved Ammonia'
BGC_indices%short_name(BGC_indices%fe_ind)='Fe'
BGC_indices%long_name(BGC_indices%fe_ind)='Dissolved Inorganic Iron'
BGC_indices%short_name(BGC_indices%o2_ind)='O2'
BGC_indices%long_name(BGC_indices%o2_ind)='Dissolved Oxygen'
BGC_indices%short_name(BGC_indices%dic_ind)='DIC'
BGC_indices%long_name(BGC_indices%dic_ind)='Dissolved Inorganic Carbon'
BGC_indices%short_name(BGC_indices%dic_alt_co2_ind)='DIC_ALT_CO2'
BGC_indices%long_name(BGC_indices%dic_alt_co2_ind)='Dissolved Inorganic Carbon, Alternative CO2'
BGC_indices%short_name(BGC_indices%alk_ind)='ALK'
BGC_indices%long_name(BGC_indices%alk_ind)='Alkalinity'
BGC_indices%short_name(BGC_indices%doc_ind)='DOC'
BGC_indices%long_name(BGC_indices%doc_ind)='Dissolved Organic Carbon'
BGC_indices%short_name(BGC_indices%don_ind)='DON'
BGC_indices%long_name(BGC_indices%don_ind)='Dissolved Organic Nitrogen'
BGC_indices%short_name(BGC_indices%dofe_ind)='DOFe'
BGC_indices%long_name(BGC_indices%dofe_ind)='Dissolved Organic Iron'
BGC_indices%short_name(BGC_indices%dop_ind)='DOP'
BGC_indices%long_name(BGC_indices%dop_ind)='Dissolved Organic Phosphorus'
BGC_indices%short_name(BGC_indices%dopr_ind)='DOPr'
BGC_indices%long_name(BGC_indices%dopr_ind)='Refractory DOP'
BGC_indices%short_name(BGC_indices%donr_ind)='DONr'
BGC_indices%long_name(BGC_indices%donr_ind)='Refractory DON'
BGC_indices%short_name(BGC_indices%zooC_ind)='zooC'
BGC_indices%long_name(BGC_indices%zooC_ind)='Zooplankton Carbon'
! now do autotrophs
do auto_ind = 1, autotroph_cnt
if (auto_ind == BGC_indices%sp_ind) then
Chl_ind = BGC_indices%spChl_ind
C_ind = BGC_indices%spC_ind
Fe_ind = BGC_indices%spFe_ind
elseif (auto_ind == BGC_indices%diat_ind) then
Chl_ind = BGC_indices%diatChl_ind
C_ind = BGC_indices%diatC_ind
Fe_ind = BGC_indices%diatFe_ind
elseif (auto_ind == BGC_indices%diaz_ind) then
Chl_ind = BGC_indices%diazChl_ind
C_ind = BGC_indices%diazC_ind
Fe_ind = BGC_indices%diazFe_ind
elseif (auto_ind == BGC_indices%phaeo_ind) then
Chl_ind = BGC_indices%phaeoChl_ind
C_ind = BGC_indices%phaeoC_ind
Fe_ind = BGC_indices%phaeoFe_ind
endif
BGC_indices%short_name(Chl_ind) = trim(autotrophs(auto_ind)%sname) // 'Chl'
BGC_indices%long_name(Chl_ind) = trim(autotrophs(auto_ind)%lname) // ' Chlorophyll'
autotrophs(auto_ind)%Chl_ind = Chl_ind
BGC_indices%short_name(C_ind) = trim(autotrophs(auto_ind)%sname) // 'C'
BGC_indices%long_name(C_ind) = trim(autotrophs(auto_ind)%lname) // ' Carbon'
autotrophs(auto_ind)%C_ind = C_ind
BGC_indices%short_name(Fe_ind) = trim(autotrophs(auto_ind)%sname) // 'Fe'
BGC_indices%long_name(Fe_ind) = trim(autotrophs(auto_ind)%lname) // ' Iron'
autotrophs(auto_ind)%Fe_ind = Fe_ind
if (autotrophs(auto_ind)%kSiO3 > c0) then
Si_ind = BGC_indices%diatSi_ind
BGC_indices%short_name(Si_ind) = trim(autotrophs(auto_ind)%sname) // 'Si'
BGC_indices%long_name(Si_ind) = trim(autotrophs(auto_ind)%lname) // ' Silicon'
autotrophs(auto_ind)%Si_ind = Si_ind
else
autotrophs(auto_ind)%Si_ind = 0
endif
if (autotrophs(auto_ind)%imp_calcifier .or. &
autotrophs(auto_ind)%exp_calcifier) then
CaCO3_ind = BGC_indices%spCaCO3_ind
BGC_indices%short_name(CaCO3_ind) = trim(autotrophs(auto_ind)%sname) // 'CaCO3'
BGC_indices%long_name(CaCO3_ind) = trim(autotrophs(auto_ind)%lname) // ' CaCO3'
autotrophs(auto_ind)%CaCO3_ind = CaCO3_ind
else
autotrophs(auto_ind)%CaCO3_ind = 0
endif
end do
BGC_indices%units(:) = 'mmol/m^3'
BGC_indices%units(BGC_indices%alk_ind) = 'meq/m^3'
BGC_indices%units(BGC_indices%spChl_ind) = 'mg/m^3'
BGC_indices%units(BGC_indices%diatChl_ind) = 'mg/m^3'
BGC_indices%units(BGC_indices%diazChl_ind) = 'mg/m^3'
BGC_indices%units(BGC_indices%phaeoChl_ind) = 'mg/m^3'
!-----------------------------------------------------------------------
!EOC
end subroutine BGC_init
!***********************************************************************
!BOP
! !IROUTINE: BGC_SourceSink
! !INTERFACE:
subroutine BGC_SourceSink(autotrophs, BGC_indices, BGC_input, BGC_forcing, &
BGC_output, BGC_diagnostic_fields, numLevelsMax, &
numColumnsMax, numColumns, alt_co2_use_eco)
! !DESCRIPTION:
! Compute time derivatives for ecosystem state variables
!
! !REVISION HISTORY:
! same as module
implicit none
! !INPUT PARAMETERS:
type(autotroph_type), dimension(autotroph_cnt), intent(in) :: autotrophs
type(BGC_indices_type), intent(in ) :: BGC_indices
type(BGC_input_type), intent(in ) :: BGC_input
type(BGC_forcing_type), intent(in ) :: BGC_forcing
integer (BGC_i4) :: numLevelsMax, numColumnsMax, numColumns
logical (BGC_log) :: alt_co2_use_eco
! !OUTPUT PARAMETERS:
type(BGC_output_type), intent(inout) :: BGC_output
type(BGC_diagnostics_type), intent(inout) :: BGC_diagnostic_fields
!EOP
!BOC
!-----------------------------------------------------------------------
! local variables
!-----------------------------------------------------------------------
type(sinking_particle) :: &
POC, & ! base units = nmol C
P_CaCO3, & ! base units = nmol CaCO3
P_SiO2, & ! base units = nmol SiO2
dust, & ! base units = g
P_iron ! base units = nmol Fe
real (BGC_r8), parameter :: &
mpercm = 0.01_BGC_r8 ! meters/cm
real (BGC_r8) :: &
QA_dust_def, & ! incoming deficit in the QA(dust) POC flux
dust_flux_in_loc,&! local copy of incoming surface dust flux
SED_DENITRIF, & ! sedimentary denitrification (nmol N/cm^3/sec)
OTHER_REMIN, & ! organic C remin not due oxic or denitrif (nmolC/cm^3/sec)
ZSATCALC, & ! Calcite Saturation Depth
ZSATARAG, & ! Aragonite Saturation Depth
CO3_CALC_ANOM_km1,&! CO3 concentration above calcite saturation at k-1
CO3_ARAG_ANOM_km1 ! CO3 concentration above aragonite saturation at k-1
! real (BGC_r8), dimension(km,numColumns) :: &
real (BGC_r8), allocatable, dimension(:,:) :: &
DIC_loc, & ! local copy of model DIC
DIC_ALT_CO2_loc,& ! local copy of model DIC_ALT_CO2
ALK_loc, & ! local copy of model ALK
PO4_loc, & ! local copy of model PO4
NO3_loc, & ! local copy of model NO3
SiO3_loc, & ! local copy of model SiO3
NH4_loc, & ! local copy of model NH4
Fe_loc, & ! local copy of model Fe
O2_loc, & ! local copy of model O2
DOC_loc, & ! local copy of model DOC
zooC_loc, & ! local copy of model zooC
DON_loc, & ! local copy of model DON
DOFe_loc, & ! local copy of model DOFe
DOP_loc, & ! local copy of model DOP
DOPr_loc, & ! local copy of model DOPr
DONr_loc ! local copy of model DONr
! real (BGC_r8), dimension(km,numColumns,autotroph_cnt) :: &
real (BGC_r8), allocatable, dimension(:,:,:) :: &
autotrophChl_loc, & ! local copy of model autotroph Chl
autotrophC_loc, & ! local copy of model autotroph C
autotrophFe_loc, & ! local copy of model autotroph Fe
autotrophSi_loc, & ! local copy of model autotroph Si
autotrophCaCO3_loc ! local copy of model autotroph CaCO3
logical (BGC_log) :: zero_mask
real (BGC_r8) :: &
work1,work2,work3,work4,work5,tmpTopt,tmpTmax ! temporaries
real (BGC_r8) :: &
f_loss_thres, &! fraction of grazing loss reduction at depth
ztop, & ! depth of top of cell
PAR_out, & ! photosynthetically available radiation (W/m^2)
PAR_in, & ! photosynthetically available radiation (W/m^2)
KPARdz, & ! PAR adsorption coefficient (non-dim)
PAR_avg, & ! average PAR over mixed layer depth (W/m^2)
DOC_prod, & ! production of DOC (mmol C/m^3/sec)
DOC_remin, & ! remineralization of DOC (mmol C/m^3/sec)
DON_remin, & ! portion of DON remineralized
DOFe_remin, & ! portion of DOFe remineralized
DOP_remin, & ! portion of DOP remineralized
NITRIF, & ! nitrification (NH4 -> NO3) (mmol N/m^3/sec)
DENITRIF, & ! WC nitrification (NO3 -> N2) (mmol N/m^3/sec)
RESTORE ! restoring terms for nutrients (mmol ./m^3/sec)
real (BGC_r8) :: &
z_umax, & ! max. zoo growth rate at local T (1/sec)
C_loss_thres ! bio-C threshold at which losses go to zero (mmol C/m^3)
real (BGC_r8) :: &
Tfunc, & ! temp response function GD98 (non-dim)
f_nut, & ! nut limitation factor, modifies C fixation (non-dim)
PCmax, & ! max value of PCphoto at temperature TEMP (1/sec)
light_lim, & ! light limitation factor
PCphoto, & ! C-specific rate of photosynth. (1/sec)
pChl ! Chl synth. regulation term (mg Chl/mmol N)
real (BGC_r8) :: & ! max of 39 continuation lines
f_zoo_detr, & ! frac of zoo losses into large detrital pool (non-dim)
Fe_scavenge_rate,&! annual scavenging rate of iron as % of ambient
Fe_scavenge, & ! loss of dissolved iron, scavenging (mmol Fe/m^3/sec)
Zprime, & ! used to limit zoo mort at low biomass (mmol C/m^3)
zoo_loss, & ! mortality & higher trophic grazing on zooplankton (mmol C/m^3/sec)
zoo_loss_doc, & ! zoo_loss routed to doc (mmol C/m^3/sec)
zoo_loss_dic ! zoo_loss routed to dic (mmol C/m^3/sec)
real (BGC_r8) :: &
VNC, & ! C-specific N uptake rate (mmol N/mmol C/sec)
VPO4, & ! C-specific PO4 uptake (non-dim)
VDOP, & ! C-specific DOP uptake rate (non-dim)
VPtot, & ! total P uptake rate (non-dim)
VFe, & ! C-specific Fe uptake (non-dim)
VSiO3 ! C-specific SiO3 uptake (non-dim)
real (BGC_r8), dimension(autotroph_cnt) :: &
thetaC, & ! local Chl/C ratio (mg Chl/mmol C)
QCaCO3, & ! CaCO3/C ratio (mmol CaCO3/mmol C)
VNO3, & ! NO3 uptake rate (non-dim)
VNH4, & ! NH4 uptake rate (non-dim)
VNtot, & ! total N uptake rate (non-dim)
NO3_V, & ! nitrate uptake (mmol NO3/m^3/sec)
NH4_V, & ! ammonium uptake (mmol NH4/m^3/sec)
PO4_V, & ! PO4 uptake (mmol PO4/m^3/sec)
DOP_V, & ! DOP uptake (mmol DOP/m^3/sec)
Qfe, & ! init fe/C ratio (mmolFe/mmolC)
gQfe, & ! fe/C for growth
Qsi, & ! initial Si/C ratio (mmol Si/mmol C)
gQsi, & ! diatom Si/C ratio for growth (new biomass)
Pprime, & ! used to limit autotroph mort at low biomass (mmol C/m^3)
auto_graze, & ! autotroph grazing rate (mmol C/m^3/sec)
auto_graze_zoo, & ! auto_graze routed to zoo (mmol C/m^3/sec)
auto_graze_poc, & ! auto_graze routed to poc (mmol C/m^3/sec)
auto_graze_doc, & ! auto_graze routed to doc (mmol C/m^3/sec)
auto_graze_dic, & ! auto_graze routed to dic (mmol C/m^3/sec)
auto_loss, & ! autotroph non-grazing mort (mmol C/m^3/sec)
auto_loss_poc, & ! auto_loss routed to poc (mmol C/m^3/sec)
auto_loss_doc, & ! auto_loss routed to doc (mmol C/m^3/sec)
auto_loss_dic, & ! auto_loss routed to dic (mmol C/m^3/sec)
auto_agg, & ! autotroph aggregation (mmol C/m^3/sec)
photoC, & ! C-fixation (mmol C/m^3/sec)
photoFe, & ! iron uptake
photoSi, & ! silicon uptake (mmol Si/m^3/sec)
CaCO3_PROD, & ! prod. of CaCO3 by small phyto (mmol CaCO3/m^3/sec)
photoacc, & ! Chl synth. term in photoadapt. (GD98) (mg Chl/m^3/sec)
Nfix, & ! total Nitrogen fixation (mmol N/m^3/sec)
Nexcrete ! fixed N excretion
real (BGC_r8) :: &
remaining_P ! used in routing P from autotrophs w/ Qp different from Qp_zoo_pom
real (BGC_r8), dimension(autotroph_cnt) :: &
remaining_P_dop,& ! remaining_P from mort routed to DOP pool
remaining_P_dip ! remaining_P from mort routed to remin
real (BGC_r8) :: &
DON_prod, & ! production of dissolved organic N
DOFe_prod, & ! produciton of dissolved organic Fe
DOP_prod, & ! production of dissolved organic P
O2_PRODUCTION, & ! O2 production
O2_CONSUMPTION, & ! O2 consumption
DONr_remin, & ! portion of refractory DON remineralized
DOPr_remin ! portion of refractory DOP remineralized
real (BGC_r8) :: &
partial_thickness_100m, &!
CO3, &! carbonate ion
HCO3, &! bicarbonate ion
H2CO3, &! carbonic acid
CO3_ALT_CO2, &! carbonate ion, alternative CO2
HCO3_ALT_CO2, &! bicarbonate ion, alternative CO2
H2CO3_ALT_CO2, &! carbonic acid, alternative CO2
OMEGA_CALC, &! solubility ratio for aragonite
OMEGA_ARAG ! solubility ratio for calcite
integer (BGC_i4) :: &
k, & ! vertical level index
n, & ! tracer index
auto_ind, & ! autotroph functional group index
auto_ind2, & ! autotroph functional group index
kmax, & ! maximum number of vertical levels in column
column ! index for looping over columns
!-----------------------------------------------------------------------
! local copies of non-autotroph indices
!-----------------------------------------------------------------------
integer (BGC_i4) :: &
po4_ind, &
no3_ind, &
sio3_ind, &
nh4_ind, &
fe_ind, &
o2_ind, &
dic_ind, &
dic_alt_co2_ind, &
alk_ind, &
doc_ind, &
don_ind, &
dofe_ind, &
dop_ind, &
dopr_ind, &
donr_ind, &
zooC_ind
logical (BGC_log) :: &
lcalc_co2_terms, &! are any alt_co2 terms being time averaged
lalt_co2_terms ! are any alt_co2 terms being time averaged
!-----------------------------------------------------------------------
!-----------------------------------------------------------------------
! initialize all tendencies to zero
!-----------------------------------------------------------------------
BGC_output%BGC_tendencies = c0
!-----------------------------------------------------------------------
! allocate local copies of tracers
!-----------------------------------------------------------------------
allocate(DIC_loc(numLevelsMax,numColumns))
allocate(DIC_ALT_CO2_loc(numLevelsMax,numColumns))
allocate(ALK_loc(numLevelsMax,numColumns))
allocate(PO4_loc(numLevelsMax,numColumns))
allocate(NO3_loc(numLevelsMax,numColumns))
allocate(SiO3_loc(numLevelsMax,numColumns))
allocate(NH4_loc(numLevelsMax,numColumns))
allocate(Fe_loc(numLevelsMax,numColumns))
allocate(O2_loc(numLevelsMax,numColumns))
allocate(DOC_loc(numLevelsMax,numColumns))
allocate(zooC_loc(numLevelsMax,numColumns))
allocate(DON_loc(numLevelsMax,numColumns))
allocate(DOFe_loc(numLevelsMax,numColumns))
allocate(DOP_loc(numLevelsMax,numColumns))
allocate(DOPr_loc(numLevelsMax,numColumns))
allocate(DONr_loc(numLevelsMax,numColumns))
allocate(autotrophChl_loc(numLevelsMax,numColumns,autotroph_cnt))
allocate(autotrophC_loc(numLevelsMax,numColumns,autotroph_cnt))
allocate(autotrophFe_loc(numLevelsMax,numColumns,autotroph_cnt))
allocate(autotrophSi_loc(numLevelsMax,numColumns,autotroph_cnt))
allocate(autotrophCaCO3_loc(numLevelsMax,numColumns,autotroph_cnt))
!-----------------------------------------------------------------------
! assign non-autotroph indices. this is not necessary but results in fewer
! differences between original and new code.
!-----------------------------------------------------------------------
po4_ind = BGC_indices%po4_ind
no3_ind = BGC_indices%no3_ind
sio3_ind = BGC_indices%sio3_ind
nh4_ind = BGC_indices%nh4_ind
fe_ind = BGC_indices%fe_ind
o2_ind = BGC_indices%o2_ind
dic_ind = BGC_indices%dic_ind
dic_alt_co2_ind = BGC_indices%dic_alt_co2_ind
alk_ind = BGC_indices%alk_ind
doc_ind = BGC_indices%doc_ind
don_ind = BGC_indices%don_ind
dofe_ind = BGC_indices%dofe_ind
dop_ind = BGC_indices%dop_ind
dopr_ind = BGC_indices%dopr_ind
donr_ind = BGC_indices%donr_ind
zooC_ind = BGC_indices%zooC_ind
!-----------------------------------------------------------------------
! initialize vertical integrals and sums over all autotrophs
!-----------------------------------------------------------------------
BGC_diagnostic_fields%diag_tot_CaCO3_form = c0
BGC_diagnostic_fields%diag_tot_bSi_form = c0
BGC_diagnostic_fields%diag_CaCO3_form_zint = c0
BGC_diagnostic_fields%diag_tot_CaCO3_form_zint = c0
BGC_diagnostic_fields%diag_photoC_zint = c0
BGC_diagnostic_fields%diag_photoC_TOT_zint = c0
BGC_diagnostic_fields%diag_tot_Nfix = c0
BGC_diagnostic_fields%diag_photoC_NO3_zint = c0
BGC_diagnostic_fields%diag_photoC_NO3_TOT = c0
BGC_diagnostic_fields%diag_photoC_NO3_TOT_zint = c0
BGC_diagnostic_fields%diag_Chl_TOT_zint_100m = c0
BGC_diagnostic_fields%diag_Jint_Ctot = c0
BGC_diagnostic_fields%diag_Jint_100m_Ctot = c0
BGC_diagnostic_fields%diag_Jint_Ntot = c0
BGC_diagnostic_fields%diag_Jint_100m_Ntot = c0
BGC_diagnostic_fields%diag_Jint_Ptot = c0
BGC_diagnostic_fields%diag_Jint_100m_Ptot = c0
BGC_diagnostic_fields%diag_Jint_Sitot = c0
BGC_diagnostic_fields%diag_Jint_100m_Sitot = c0
!-----------------------------------------------------------------------
! initialize ALL diags so that land below ocean points have zeros
!-----------------------------------------------------------------------
BGC_diagnostic_fields%diag_CO3 = c0
BGC_diagnostic_fields%diag_HCO3 = c0
BGC_diagnostic_fields%diag_H2CO3 = c0
BGC_diagnostic_fields%diag_pH_3D = c0
BGC_diagnostic_fields%diag_CO3_ALT_CO2 = c0
BGC_diagnostic_fields%diag_HCO3_ALT_CO2 = c0
BGC_diagnostic_fields%diag_H2CO3_ALT_CO2 = c0
BGC_diagnostic_fields%diag_pH_3D_ALT_CO2 = c0
BGC_diagnostic_fields%diag_co3_sat_calc = c0
BGC_diagnostic_fields%diag_co3_sat_arag = c0
BGC_diagnostic_fields%diag_NO3_RESTORE = c0
BGC_diagnostic_fields%diag_NITRIF = c0
BGC_diagnostic_fields%diag_DENITRIF = c0
BGC_diagnostic_fields%diag_SiO3_RESTORE = c0
BGC_diagnostic_fields%diag_PO4_RESTORE = c0
BGC_diagnostic_fields%diag_O2_PRODUCTION = c0
BGC_diagnostic_fields%diag_O2_CONSUMPTION = c0
BGC_diagnostic_fields%diag_AOU = c0
BGC_diagnostic_fields%diag_PAR_avg = c0
BGC_diagnostic_fields%diag_zoo_loss = c0
BGC_diagnostic_fields%diag_auto_graze_TOT = c0
BGC_diagnostic_fields%diag_photoC_TOT = c0
BGC_diagnostic_fields%diag_DOC_prod = c0
BGC_diagnostic_fields%diag_DOC_remin = c0
BGC_diagnostic_fields%diag_DON_prod = c0
BGC_diagnostic_fields%diag_DON_remin = c0
BGC_diagnostic_fields%diag_DOP_prod = c0
BGC_diagnostic_fields%diag_DOP_remin = c0
BGC_diagnostic_fields%diag_DOFe_prod = c0
BGC_diagnostic_fields%diag_DOFe_remin = c0
BGC_diagnostic_fields%diag_Fe_scavenge = c0
BGC_diagnostic_fields%diag_Fe_scavenge_rate = c0
BGC_diagnostic_fields%diag_POC_FLUX_IN = c0
BGC_diagnostic_fields%diag_POC_PROD = c0
BGC_diagnostic_fields%diag_POC_REMIN = c0
BGC_diagnostic_fields%diag_CaCO3_FLUX_IN = c0
BGC_diagnostic_fields%diag_CaCO3_PROD = c0
BGC_diagnostic_fields%diag_CaCO3_REMIN = c0
BGC_diagnostic_fields%diag_SiO2_FLUX_IN = c0
BGC_diagnostic_fields%diag_SiO2_PROD = c0
BGC_diagnostic_fields%diag_SiO2_REMIN = c0
BGC_diagnostic_fields%diag_dust_FLUX_IN = c0
BGC_diagnostic_fields%diag_dust_REMIN = c0
BGC_diagnostic_fields%diag_P_iron_FLUX_IN = c0
BGC_diagnostic_fields%diag_P_iron_PROD = c0
BGC_diagnostic_fields%diag_P_iron_REMIN = c0
BGC_diagnostic_fields%diag_calcToSed = c0
BGC_diagnostic_fields%diag_bsiToSed = c0
BGC_diagnostic_fields%diag_pocToSed = c0
BGC_diagnostic_fields%diag_SedDenitrif = c0
BGC_diagnostic_fields%diag_OtherRemin = c0
BGC_diagnostic_fields%diag_ponToSed = c0
BGC_diagnostic_fields%diag_popToSed = c0
BGC_diagnostic_fields%diag_dustToSed = c0
BGC_diagnostic_fields%diag_pfeToSed = c0
BGC_diagnostic_fields%diag_zsatcalc = c0
BGC_diagnostic_fields%diag_zsatarag = c0
BGC_diagnostic_fields%diag_O2_ZMIN = c0
BGC_diagnostic_fields%diag_O2_ZMIN_DEPTH = c0
BGC_diagnostic_fields%diag_N_lim = c0
BGC_diagnostic_fields%diag_Fe_lim = c0
BGC_diagnostic_fields%diag_P_lim = c0
BGC_diagnostic_fields%diag_SiO3_lim = c0
BGC_diagnostic_fields%diag_light_lim = c0
BGC_diagnostic_fields%diag_photoNO3 = c0
BGC_diagnostic_fields%diag_photoNH4 = c0
BGC_diagnostic_fields%diag_PO4_uptake = c0
BGC_diagnostic_fields%diag_DOP_uptake = c0
BGC_diagnostic_fields%diag_photoFe = c0
BGC_diagnostic_fields%diag_bSi_form = c0
BGC_diagnostic_fields%diag_CaCO3_form = c0
BGC_diagnostic_fields%diag_Nfix = c0
BGC_diagnostic_fields%diag_auto_graze = c0
BGC_diagnostic_fields%diag_auto_loss = c0
BGC_diagnostic_fields%diag_auto_agg = c0
BGC_diagnostic_fields%diag_photoC = c0
BGC_diagnostic_fields%diag_photoC_NO3 = c0
!-----------------------------------------------------------------------
! loop over levels
!-----------------------------------------------------------------------
setup_loop: do column = 1, numColumns
kmax = BGC_input%number_of_active_levels(column)
if (kmax < 1) cycle setup_loop
do k = 1, kmax
!-----------------------------------------------------------------------
! create local copies of model tracers
! treat negative values as zero
! apply mask to local copies
!-----------------------------------------------------------------------
!maltrud intel fails if i use c0 for max() instead of 0.0
DIC_loc(k,column) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,dic_ind))
DIC_ALT_CO2_loc(k,column) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,dic_alt_co2_ind))
ALK_loc(k,column) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,alk_ind))
PO4_loc(k,column) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,po4_ind))
NO3_loc(k,column) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,no3_ind))
SiO3_loc(k,column) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,sio3_ind))
NH4_loc(k,column) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,nh4_ind))
Fe_loc(k,column) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,fe_ind))
O2_loc(k,column) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,o2_ind))
DOC_loc(k,column) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,doc_ind))
zooC_loc(k,column) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,zooC_ind))
DON_loc(k,column) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,don_ind))
DOFe_loc(k,column) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,dofe_ind))
DOP_loc(k,column) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,dop_ind))
DOPr_loc(k,column) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,dopr_ind))
DONr_loc(k,column) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,donr_ind))
do auto_ind = 1, autotroph_cnt
n = autotrophs(auto_ind)%Chl_ind
autotrophChl_loc(k,column,auto_ind) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,n))
n = autotrophs(auto_ind)%C_ind
autotrophC_loc(k,column,auto_ind) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,n))
n = autotrophs(auto_ind)%Fe_ind
autotrophFe_loc(k,column,auto_ind) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,n))
n = autotrophs(auto_ind)%Si_ind
if (n > 0) then
autotrophSi_loc(k,column,auto_ind) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,n))
endif
n = autotrophs(auto_ind)%CaCO3_ind
if (n > 0) then
autotrophCaCO3_loc(k,column,auto_ind) = max(0.0_BGC_r8, BGC_input%BGC_tracers(k,column,n))
endif
end do
end do ! end of setup k loop
enddo setup_loop ! end of setup column loop
!-----------------------------------------------------------------------
! HERE IS WHERE MODEL AGNOSTIC SHOULD BEGIN
!-----------------------------------------------------------------------
!-----------------------------------------------------------------------
! loop over columns
!-----------------------------------------------------------------------
column_loop: do column = 1, numColumns
kmax = BGC_input%number_of_active_levels(column)
if (kmax < 1) cycle column_loop
!-----------------------------------------------------------------------
! various k==1 initializations
!-----------------------------------------------------------------------
dust_flux_in_loc = max (0.0_BGC_r8, BGC_forcing%dust_FLUX_IN(column))
call init_particulate_terms(POC, P_CaCO3, P_SiO2, dust, P_iron, &
QA_dust_def, dust_flux_in_loc)
PAR_out = max (0.0_BGC_r8, BGC_forcing%ShortWaveFlux_surface(column))
PAR_out = PAR_out*f_qsw_par
!-----------------------------------------------------------------------
! loop over levels
!-----------------------------------------------------------------------
do k = 1, kmax
!-----------------------------------------------------------------------
! If any phyto box are zero, set others to zeros.
!-----------------------------------------------------------------------
do auto_ind = 1, autotroph_cnt
zero_mask = autotrophChl_loc(k,column,auto_ind) == c0 .or. &
autotrophC_loc(k,column,auto_ind) == c0 .or. &
autotrophFe_loc(k,column,auto_ind) == c0
if (autotrophs(auto_ind)%Si_ind > 0) &
zero_mask = zero_mask .or. autotrophSi_loc(k,column,auto_ind) == c0
if (zero_mask) then
autotrophChl_loc(k,column,auto_ind) = c0
autotrophC_loc(k,column,auto_ind) = c0
autotrophFe_loc(k,column,auto_ind) = c0
end if
!maltrud maybe change these to single if .and. statements
if (autotrophs(auto_ind)%Si_ind > 0) then
if (zero_mask) autotrophSi_loc(k,column,auto_ind) = c0
endif
if (autotrophs(auto_ind)%CaCO3_ind > 0) then
if (zero_mask) autotrophCaCO3_loc(k,column,auto_ind) = c0
endif
end do
!-----------------------------------------------------------------------
! set local variables, with incoming ratios
!-----------------------------------------------------------------------
do auto_ind = 1, autotroph_cnt
thetaC(auto_ind) = autotrophChl_loc(k,column,auto_ind) / (autotrophC_loc(k,column,auto_ind) + epsC)
Qfe(auto_ind) = autotrophFe_loc(k,column,auto_ind) / (autotrophC_loc(k,column,auto_ind) + epsC)
if (autotrophs(auto_ind)%Si_ind > 0) then
Qsi(auto_ind) = min(autotrophSi_loc(k,column,auto_ind) / (autotrophC_loc(k,column,auto_ind) + epsC), gQsi_max)
endif
end do
!-----------------------------------------------------------------------
! DETERMINE NEW ELEMENTAL RATIOS FOR GROWTH (NEW BIOMASS)
! Modify these initial ratios under low ambient iron conditions
! Modify the initial si/C ratio under low ambient Si conditions
!-----------------------------------------------------------------------
do auto_ind = 1, autotroph_cnt
gQfe(auto_ind) = autotrophs(auto_ind)%gQfe_0
if (Fe_loc(k,column) < cks * autotrophs(auto_ind)%kFe) then
gQfe(auto_ind) = &
max((gQfe(auto_ind) * Fe_loc(k,column) / (cks * autotrophs(auto_ind)%kFe)), &
autotrophs(auto_ind)%gQfe_min)
end if
if (autotrophs(auto_ind)%Si_ind > 0) then
gQsi(auto_ind) = gQsi_0
if ((Fe_loc(k,column) < cksi * autotrophs(auto_ind)%kFe) .and. (Fe_loc(k,column) > c0) .and. &
(SiO3_loc(k,column) > (cksi * autotrophs(auto_ind)%kSiO3))) then
gQsi(auto_ind) = min((gQsi(auto_ind) * cksi * autotrophs(auto_ind)%kFe / Fe_loc(k,column)), gQsi_max)
end if
if (Fe_loc(k,column) == c0) then
gQsi(auto_ind) = gQsi_max
end if
if (SiO3_loc(k,column) < (cksi * autotrophs(auto_ind)%kSiO3)) then
gQsi(auto_ind) = max((gQsi(auto_ind) * SiO3_loc(k,column) / (cksi * autotrophs(auto_ind)%kSiO3)), &
gQsi_min)
end if
endif
!-----------------------------------------------------------------------
! QCaCO3 is the percentage of sp organic matter which is associated
! with coccolithophores
!-----------------------------------------------------------------------
if (autotrophs(auto_ind)%CaCO3_ind > 0) then
QCaCO3(auto_ind) = autotrophCaCO3_loc(k,column,auto_ind) / (autotrophC_loc(k,column,auto_ind) + epsC)
if (QCaCO3(auto_ind) > QCaCO3_max) QCaCO3(auto_ind) = QCaCO3_max
endif
end do
!-----------------------------------------------------------------------
! compute PAR related quantities
! Morel, Maritorena, JGR, Vol 106, No. C4, pp 7163--7180, 2001
!
! 0.45 fraction of incoming SW -> PAR (non-dim)
!-----------------------------------------------------------------------
PAR_in = PAR_out
!maltrud debug
!if(i==20.and.j==20.and.my_task==0)then
!write(*,*)'DEBUG7: ',k,PAR_in,PAR_out(i,j),PAR_surface(i,j,bid),sum(PAR_surface)
!endif
work1 = max(sum(autotrophChl_loc(k,column,:), dim=1), 0.02_BGC_r8)
if (work1 < 0.13224_BGC_r8) then
KPARdz = 0.000919_BGC_r8*(work1**0.3536_BGC_r8)
else
KPARdz = 0.001131_BGC_r8*(work1**0.4562_BGC_r8)
end if
KPARdz = KPARdz * BGC_input%cell_thickness(k,column)
PAR_out = PAR_in * exp(-KPARdz)
PAR_avg = PAR_in * (c1 - exp(-KPARdz)) / KPARdz
!maltrud debug
!if(i==20.and.j==20.and.my_task==0)then
!write(*,*)'DEBUG6: ',k,PAR_in,PAR_out(i,j),work1,KPARdz,PAR_avg,autotrophChl_loc(k,column,:)
!endif
!-----------------------------------------------------------------------
! compute terms of carbonate chemistry
!-----------------------------------------------------------------------
lcalc_co2_terms = .true.
lalt_co2_terms = .true.
! lcalc_co2_terms = .false.
! lalt_co2_terms = .false.
work3 = c0
work4 = c0
if (lcalc_co2_terms) then
if (BGC_output%PH_PREV_3D(k,column) /= c0) then
work1 = BGC_output%PH_PREV_3D(k,column) - del_ph
work2 = BGC_output%PH_PREV_3D(k,column) + del_ph
else
work1 = phlo_3d_init
work2 = phhi_3d_init
end if
work5 = BGC_input%cell_center_depth(k,column)*0.01_BGC_r8
! call comp_CO3terms( k, BGC_input%cell_center_depth(k,column), .true., &
call comp_CO3terms( k, work5, .true., &
BGC_input%PotentialTemperature(k,column), BGC_input%Salinity(k,column), DIC_loc(k,column), &
ALK_loc(k,column), PO4_loc(k,column), SiO3_loc(k,column), &
work1, work2, work3, H2CO3, HCO3, CO3)
BGC_output%PH_PREV_3D(k,column) = work3
else
H2CO3 = c0
HCO3 = c0
CO3 = c0
BGC_output%PH_PREV_3D(k,column) = 8.0
endif
if (lalt_co2_terms) then
if (BGC_output%PH_PREV_ALT_CO2_3D(k,column) /= c0) then
work1 = BGC_output%PH_PREV_ALT_CO2_3D(k,column) - del_ph
work2 = BGC_output%PH_PREV_ALT_CO2_3D(k,column) + del_ph
else
work1 = phlo_3d_init
work2 = phhi_3d_init
end if
work5 = BGC_input%cell_center_depth(k,column)*0.01_BGC_r8
! call comp_CO3terms( k, BGC_input%cell_center_depth(k,column), .true., &
call comp_CO3terms( k, work5, .true., &
BGC_input%PotentialTemperature(k,column), BGC_input%Salinity(k,column), DIC_loc(k,column), &
ALK_loc(k,column), PO4_loc(k,column), SiO3_loc(k,column), &
work1, work2, work4, H2CO3_ALT_CO2, HCO3_ALT_CO2, CO3_ALT_CO2)
BGC_output%PH_PREV_ALT_CO2_3D(k,column) = work4
else
H2CO3_ALT_CO2 = c0
HCO3_ALT_CO2 = c0
CO3_ALT_CO2 = c0
BGC_output%PH_PREV_ALT_CO2_3D(k,column) = 8.0
endif
BGC_diagnostic_fields%diag_CO3(k,column) = CO3
BGC_diagnostic_fields%diag_HCO3(k,column) = HCO3
BGC_diagnostic_fields%diag_H2CO3(k,column) = H2CO3
BGC_diagnostic_fields%diag_pH_3D(k,column) = work3
BGC_diagnostic_fields%diag_CO3_ALT_CO2(k,column) = CO3_ALT_CO2
BGC_diagnostic_fields%diag_HCO3_ALT_CO2(k,column) = HCO3_ALT_CO2
BGC_diagnostic_fields%diag_H2CO3_ALT_CO2(k,column) = H2CO3_ALT_CO2
BGC_diagnostic_fields%diag_pH_3D_ALT_CO2(k,column) = work4
work5 = BGC_input%cell_center_depth(k,column)*0.01_BGC_r8
! call comp_co3_sat_vals(k, BGC_input%cell_center_depth(k,column), &
call comp_co3_sat_vals(k, work5, &
BGC_input%PotentialTemperature(k,column), BGC_input%Salinity(k,column), work1, work2)
BGC_diagnostic_fields%diag_co3_sat_calc(k,column) = work1