-
Notifications
You must be signed in to change notification settings - Fork 93
/
csiro_bgc.F90
executable file
·2869 lines (2458 loc) · 111 KB
/
csiro_bgc.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
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! !!
!! GNU General Public License !!
!! !!
!! This file is part of the Flexible Modeling System (FMS). !!
!! !!
!! FMS is free software; you can redistribute it and/or modify !!
!! it and are expected to follow the terms of the GNU General Public !!
!! License as published by the Free Software Foundation. !!
!! !!
!! FMS is distributed in the hope that it will be useful, !!
!! but WITHOUT ANY WARRANTY; without even the implied warranty of !!
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !!
!! GNU General Public License for more details. !!
!! !!
!! You should have received a copy of the GNU General Public License !!
!! along with FMS; if not, write to: !!
!! Free Software Foundation, Inc. !!
!! 59 Temple Place, Suite 330 !!
!! Boston, MA 02111-1307 USA !!
!! or see: !!
!! http://www.gnu.org/licenses/gpl.txt !!
!! !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
!
!<CONTACT EMAIL="Richard.Matear@csiro.au"> Richard Matear
!</CONTACT>
!
!<CONTACT EMAIL="Matthew.Chamberlain@csiro.au"> Matt Chamberlain
!</CONTACT>
!
!<REVIEWER EMAIL="">
!</REVIEWER>
!
!<OVERVIEW>
! CSIRO v3 bgc model
!</OVERVIEW>
!
!<DESCRIPTION>
! Generic setup of the CSIRO BGC model; NO3-based NPZD cycle,
! with coupled carbon cycle
!</DESCRIPTION>
!
! <INFO>
! <REFERENCE>
! </REFERENCE>
!
! <REFERENCE>
! </REFERENCE>
!
! </INFO>
!
!------------------------------------------------------------------
!
! Module csiro_bgc_mod
!
! csiro bgc model version 3
!
!------------------------------------------------------------------
module csiro_bgc_mod !{
!------------------------------------------------------------------
!
! Global definitions
!
!------------------------------------------------------------------
!----------------------------------------------------------------------
!
! Modules
!
!----------------------------------------------------------------------
use diag_manager_mod, only: send_data
use field_manager_mod, only: fm_field_name_len, fm_path_name_len, fm_string_len
use field_manager_mod, only: fm_get_length, fm_get_value, fm_new_value
use field_manager_mod, only: fm_get_index
use fms_mod, only: write_data, write_version_number
use mpp_mod, only: stdout, stdlog, mpp_error, mpp_sum, FATAL
use mpp_mod, only: mpp_pe, mpp_root_pe, mpp_sync
use mpp_mod, only: mpp_clock_id, mpp_clock_begin, mpp_clock_end, CLOCK_ROUTINE
use fms_io_mod, only: register_restart_field, save_restart, restore_state
use fms_io_mod, only: restart_file_type, reset_field_pointer
use ocean_types_mod, only: ocean_domain_type, ocean_grid_type
use mpp_domains_mod, only: mpp_global_field, mpp_global_sum, BITWISE_EXACT_SUM
use time_manager_mod, only: get_date
use time_interp_external_mod, only: time_interp_external
use ocean_parameters_mod, only: rho0
use ocean_tpm_util_mod, only: otpm_set_tracer_package, otpm_set_prog_tracer
use fm_util_mod, only: fm_util_check_for_bad_fields, fm_util_set_value
use fm_util_mod, only: fm_util_get_string, fm_util_get_logical, fm_util_get_integer, fm_util_get_real
use fm_util_mod, only: fm_util_get_logical_array, fm_util_get_real_array, fm_util_get_string_array
use fm_util_mod, only: fm_util_start_namelist, fm_util_end_namelist
! use fm_util_mod, only: domain, grid, time, dtts
! use fm_util_mod, only: isc, iec, jsc, jec, nk, isd, ied, jsd, jed
! use fm_util_mod, only: taum1, tau, taup1
! use fm_util_mod, only: t_prog, t_diag
! use fm_util_mod, only: indsal, indtemp
! use fm_util_mod, only: end_of_year, end_of_month
use ocean_types_mod, only: ocean_thickness_type
use ocean_types_mod, only: ocean_density_type
use ocean_types_mod, only: ocean_grid_type, ocean_domain_type
use ocean_types_mod, only: ocean_prog_tracer_type, ocean_diag_tracer_type
use ocean_types_mod, only: ocean_time_type
use ocean_types_mod, only: ocean_public_type
use ocean_tracer_diag_mod, only: calc_mixed_layer_depth
!----------------------------------------------------------------------
! force all variables to be "typed"
!----------------------------------------------------------------------
implicit none
!----------------------------------------------------------------------
!
! Make all routines and variables private by default
!
!----------------------------------------------------------------------
private
!----------------------------------------------------------------------
!
! Public routines
!
!----------------------------------------------------------------------
! order of call init, start, loop(sbc, source, bbc, tracer), end
public :: csiro_bgc_bbc
public :: csiro_bgc_end
public :: csiro_bgc_init
public :: csiro_bgc_sbc
public :: csiro_bgc_source
public :: csiro_bgc_start
public :: csiro_bgc_tracer
public :: csiro_bgc_virtual_fluxes
!----------------------------------------------------------------------
!
! Private routines
!
!----------------------------------------------------------------------
private :: allocate_arrays
!----------------------------------------------------------------------
!
! Private parameters
!
!----------------------------------------------------------------------
character(len=fm_field_name_len), parameter :: package_name = 'csiro_bgc'
character(len=48), parameter :: mod_name = 'csiro_bgc_mod'
character(len=fm_string_len), parameter :: default_file_in = 'INPUT/csiro_bgc.res.nc'
character(len=fm_string_len), parameter :: default_file_out = 'RESTART/csiro_bgc.res.nc'
integer, parameter :: ntr_bmax = 10
!-------------------------------------------------------
! private types
!--------------------------------------------------------
type biotic_type !{
! set-up tracer indexes
integer :: ntr_bgc = ntr_bmax
integer, dimension(ntr_bmax) :: ind_bgc
integer, dimension(ntr_bmax) :: id_bgc_stf
integer, dimension(ntr_bmax) :: id_bgc_btf
integer, dimension(ntr_bmax) :: id_bgc_vstf
integer, dimension(ntr_bmax) :: id_bgc_src
logical :: init
character(len=fm_field_name_len) :: name
! arrays for air-sea fluxes
real :: sal_global
real, allocatable, dimension(:) :: bgc_global
real, allocatable, dimension(:,:) :: htotal
real, allocatable, dimension(:,:) :: alpha
real, allocatable, dimension(:,:) :: csat
real, allocatable, dimension(:,:) :: csat_csurf
real, allocatable, dimension(:,:) :: csat_acsurf
real, allocatable, dimension(:,:) :: csurf
real, allocatable, dimension(:,:) :: acsurf
real, allocatable, dimension(:,:) :: dpco2
real, allocatable, dimension(:,:) :: pco2surf
real, allocatable, dimension(:,:) :: paco2surf
real, allocatable, dimension(:,:) :: pco2atm
real, allocatable, dimension(:,:) :: paco2atm
real, allocatable, dimension(:,:) :: det_sediment ! mmol(NO3) m-2 in DET sitting at base of column as sediment.
real, allocatable, dimension(:,:) :: caco3_sediment ! mmol(CaCO3) m-2 sitting at base of column as sediment.
real, allocatable, dimension(:,:) :: det_sed_remin ! mmol(NO3) m-2 s-1, rate of remineralisation of DET in sediment.
real, allocatable, dimension(:,:) :: caco3_sed_remin ! mmol m-2 s-1, rate of remineralisation of CaCO3 in sediment.
real, allocatable, dimension(:,:) :: det_sed_depst ! mmol(NO3) m-2 s-1, rate of deposition of DET in sediment.
real, allocatable, dimension(:,:) :: caco3_sed_depst ! mmol m-2 s-1, rate of deposition of CaCO3 in sediment.
real, allocatable, dimension(:,:) :: sio2
real, allocatable, dimension(:,:) :: po4
real, allocatable, dimension(:,:,:) :: vstf
end type biotic_type !}
!----------------------------------------------------------------------
! Public variables
!----------------------------------------------------------------------
logical, public :: do_csiro_bgc
!----------------------------------------------------------------------
! Private variables
!----------------------------------------------------------------------
integer :: package_index
! set the tracer index for the various tracers
integer :: id_po4, id_dic, id_alk, id_o2, id_no3, id_phy, id_det, id_zoo &
, id_caco3, id_adic, id_fe, id_caco3_sediment, id_det_sediment
! internal pointer to make reading the code easier
integer,public :: ind_po4 = -1
integer,public :: ind_dic = -1
integer,public :: ind_alk = -1
integer,public :: ind_o2 = -1
integer,public :: ind_no3 = -1
integer,public :: ind_phy = -1
integer,public :: ind_det = -1
integer,public :: ind_zoo = -1
integer,public :: ind_caco3 = -1
integer,public :: ind_adic = -1
integer,public :: ind_fe = -1
character*6 :: qbio_model
integer :: bio_version ! version of the bgc module to use
logical :: zero_floor ! apply hard floor to bgc tracers
logical :: sw_thru_ice ! make this true in a coupled model, so bgc knows swflx is already modified for the presense of ice.
logical :: gasx_from_file ! use gasx exchange coefficients from provided files. mac, may13.
logical :: ice_file4gasx ! make this true in a ocean-only model, option to control whether to use ice file or the model ice when determining masking effect of ice on co2 gas exchange.
logical :: use_access_co2=.false. ! determine whether to use ACCESS atmospheric CO2 or a CO2 file to drive the ocean's anthropogenic CO2 tracer. mac, may13.
integer :: id_clock_csiro_obgc
integer :: atmpress_id
character*128 :: atmpress_file
character*32 :: atmpress_name
real, allocatable, dimension(:,:) :: fice_t
integer :: id_light_limit = -1
integer :: id_adic_intmld = -1
integer :: id_dic_intmld = -1
integer :: id_o2_intmld = -1
integer :: id_no3_intmld = -1
integer :: id_fe_intmld = -1
integer :: id_phy_intmld = -1
integer :: id_det_intmld = -1
integer :: id_pprod_gross_intmld = -1
integer :: id_npp_intmld = -1
integer :: id_radbio_intmld = -1
integer :: id_adic_int100 = -1
integer :: id_dic_int100 = -1
integer :: id_o2_int100 = -1
integer :: id_no3_int100 = -1
integer :: id_fe_int100 = -1
integer :: id_phy_int100 = -1
integer :: id_det_int100 = -1
integer :: id_pprod_gross_int100 = -1
integer :: id_npp_int100 = -1
integer :: id_radbio_int100 = -1
integer :: id_radbio1 = -1
integer :: id_radbio3d = -1
integer :: id_wdet100 = -1
integer :: id_npp1 = -1
integer :: id_npp2d = -1
integer :: id_npp3d = -1
integer :: id_pprod_gross = -1
integer :: id_pprod_gross_2d = -1
integer :: id_zprod_gross = -1
integer :: id_kw_o2 = -1
integer :: id_o2_sat = -1
integer :: id_sc_o2 = -1
integer :: id_pco2 = -1, id_paco2 = -1
integer :: id_co2_sat = -1, id_aco2_sat = -1
integer :: id_caco3_sed_remin, id_det_sed_remin
integer :: id_caco3_sed_depst, id_det_sed_depst
integer :: id_total_aco2_flux, id_total_co2_flux
real, allocatable, dimension(:,:) :: kw_co2
real, allocatable, dimension(:,:) :: kw_o2
real, allocatable, dimension(:,:) :: patm_t
integer :: pistonveloc_id
integer :: aco2_id
integer :: seaicefract_id
character*128 :: pistonveloc_file
character*32 :: pistonveloc_name
character*128 :: aco2_file
character*32 :: aco2_name
real, allocatable, dimension(:,:) :: sc_o2
real, allocatable, dimension(:,:) :: sc_co2
real, allocatable, dimension(:,:) :: o2_saturation
character*128 :: seaicefract_file
character*32 :: seaicefract_name
character*128 :: dust_file
character*32 :: dust_name
integer :: dust_id
real, allocatable, dimension(:,:) :: dust_t
real, allocatable, dimension(:,:) :: xkw_t
real, allocatable, dimension(:,:) :: aco2
real, allocatable, dimension(:,:) :: htotalhi
real, allocatable, dimension(:,:) :: htotallo
type(biotic_type), allocatable, dimension(:) :: biotic
integer :: instances
real, allocatable, dimension(:) :: tk
real, allocatable, dimension(:) :: ts
real, allocatable, dimension(:) :: ts2
real, allocatable, dimension(:) :: ts3
real, allocatable, dimension(:) :: ts4
real, allocatable, dimension(:) :: ts5
real, allocatable, dimension(:) :: tt
! rjm biotic parameters
integer :: n_eudepth=4
real :: p_k = 0.1
real :: rain_ratio = 8.48
real :: s_npp = -1
real :: ratio_poc(ntr_bmax)
real :: ratio_pic(ntr_bmax)
real, allocatable, dimension(:,:,:) :: poc
real, allocatable, dimension(:,:,:) :: pic
real, allocatable, dimension(:,:) :: poc_tot
real, allocatable, dimension(:,:) :: pic_tot
real, allocatable, dimension(:,:) :: pmax_growth
real, allocatable, dimension(:,:) :: pp
real, allocatable, dimension(:) :: fmin_poc
real, allocatable, dimension(:) :: fmin_pic
real, allocatable, dimension(:,:,:) :: biotr
real, allocatable, dimension(:,:) :: light_limit
real, allocatable, dimension(:,:) :: adic_intmld,dic_intmld,o2_intmld,no3_intmld,fe_intmld,phy_intmld,det_intmld
real, allocatable, dimension(:,:) :: adic_int100,dic_int100,o2_int100,no3_int100,fe_int100,phy_int100,det_int100
real, allocatable, dimension(:,:) :: pprod_gross_intmld,npp_intmld,radbio_intmld
real, allocatable, dimension(:,:) :: pprod_gross_int100,npp_int100,radbio_int100
real, allocatable, dimension(:,:,:) :: radbio3d
real, allocatable, dimension(:,:) :: wdet100
real, allocatable, dimension(:,:) :: npp2d
real, allocatable, dimension(:,:,:) :: npp3d
real, allocatable, dimension(:,:,:) :: pprod_gross
real, allocatable, dimension(:,:) :: pprod_gross_2d
real, allocatable, dimension(:,:,:) :: zprod_gross
real, allocatable, dimension(:) :: ray
real, allocatable, dimension(:) :: dummy
real :: dummy1
real, allocatable, dimension(:) :: tracer_sources
real, allocatable, dimension(:,:) :: area_k
real, allocatable, dimension(:,:) :: tmp
integer :: global_sum_flag ! flag for mpp_global_sum
integer :: alphabio_id
real, allocatable, dimension(:,:) :: alphabio
integer :: parbio_id
real, allocatable, dimension(:,:) :: parbio
integer :: kwbio_id
real, allocatable, dimension(:,:) :: kwbio
integer :: kcbio_id
real, allocatable, dimension(:,:) :: kcbio
integer :: abio_id
real, allocatable, dimension(:,:) :: abio
integer :: bbio_id
real, allocatable, dimension(:,:) :: bbio
integer :: cbio_id
real, allocatable, dimension(:,:) :: cbio
integer :: k1bio_id
real, allocatable, dimension(:,:) :: k1bio
integer :: muepbio_id
real, allocatable, dimension(:,:) :: muepbio
integer :: muepsbio_id
real, allocatable, dimension(:,:) :: muepsbio
integer :: gam1bio_id
real, allocatable, dimension(:,:) :: gam1bio
integer :: gbio_id
real, allocatable, dimension(:,:) :: gbio
integer :: epsbio_id
real, allocatable, dimension(:,:) :: epsbio
integer :: muezbio_id
real, allocatable, dimension(:,:) :: muezbio
integer :: gam2bio_id
real, allocatable, dimension(:,:) :: gam2bio
integer :: muedbio_id
real, allocatable, dimension(:,:) :: muedbio
integer :: muecaco3_id
real, allocatable, dimension(:,:) :: muecaco3
integer :: muedbio_sed_id
real, allocatable, dimension(:,:) :: muedbio_sed
integer :: muecaco3_sed_id
real, allocatable, dimension(:,:) :: muecaco3_sed
integer :: wdetbio_id
real, allocatable, dimension(:,:) :: wdetbio
integer :: wcaco3_id
real, allocatable, dimension(:,:) :: wcaco3
integer :: nat_co2_id
real, allocatable, dimension(:,:) :: nat_co2
integer :: tscav_fe_id
real, allocatable, dimension(:,:) :: tscav_fe
integer :: fe_bkgnd_id
real, allocatable, dimension(:,:) :: fe_bkgnd
integer :: f_inorg_id
real, allocatable, dimension(:,:) :: f_inorg
! for extra restart file(s)
integer :: id_restart(2)=0
type(restart_file_type), save :: sed_restart
! Tracer names
character(5), dimension(10) :: tracer_name
!-----------------------------------------------------------------------
!
! Subroutine and function definitions
!
!-----------------------------------------------------------------------
contains
!#######################################################################
! <SUBROUTINE NAME="allocate_arrays">
!
! <DESCRIPTION>
! Dynamically allocate arrays
! </DESCRIPTION>
!
subroutine allocate_arrays (isc, iec, jsc, jec, isd, ied, jsd, jed, nk) !{
! arguments
! local variables
integer, intent(in) :: isd, isc
integer, intent(in) :: ied, iec
integer, intent(in) :: jsd, jsc
integer, intent(in) :: jed, jec
integer, intent(in) :: nk
integer :: m
integer :: k
integer :: j
integer :: i
integer :: n
integer :: ntr_bgc
!-----------------------------------------------------------------------
! start executable code
!-----------------------------------------------------------------------
allocate( xkw_t(isd:ied,jsd:jed) )
allocate( patm_t(isd:ied,jsd:jed) )
allocate( fice_t(isd:ied,jsd:jed) )
allocate( aco2(isd:ied,jsd:jed) )
allocate( dust_t(isd:ied,jsd:jed) )
allocate( sc_o2(isc:iec,jsc:jec) )
allocate( sc_co2(isc:iec,jsc:jec) )
allocate( kw_o2(isc:iec,jsc:jec) )
allocate( kw_co2(isc:iec,jsc:jec) )
allocate( htotalhi(isd:ied,jsd:jed) )
allocate( htotallo(isd:ied,jsd:jed) )
allocate( o2_saturation(isc:iec,jsc:jec) )
allocate( tt(isc:iec) )
allocate( tk(isc:iec) )
allocate( ts(isc:iec) )
allocate( ts2(isc:iec) )
allocate( ts3(isc:iec) )
allocate( ts4(isc:iec) )
allocate( ts5(isc:iec) )
allocate( poc(isc:iec,jsc:jec,nk) )
allocate( pic(isc:iec,jsc:jec,nk) )
allocate( poc_tot(isc:iec,jsc:jec) )
allocate( pic_tot(isc:iec,jsc:jec) )
allocate( pmax_growth(isc:iec,nk) )
allocate( pp(isc:iec,nk) )
allocate( fmin_poc(nk) )
allocate( fmin_pic(nk) )
ntr_bgc = biotic(1)%ntr_bgc
allocate( ray(nk) )
allocate( biotr(isc:iec,nk,ntr_bgc) )
allocate( light_limit(isc:iec,jsc:jec) )
allocate( adic_intmld(isc:iec,jsc:jec) )
allocate( dic_intmld(isc:iec,jsc:jec) )
allocate( o2_intmld(isc:iec,jsc:jec) )
allocate( fe_intmld(isc:iec,jsc:jec) )
allocate( no3_intmld(isc:iec,jsc:jec) )
allocate( phy_intmld(isc:iec,jsc:jec) )
allocate( det_intmld(isc:iec,jsc:jec) )
allocate( pprod_gross_intmld(isc:iec,jsc:jec) )
allocate( npp_intmld(isc:iec,jsc:jec) )
allocate( radbio_intmld(isc:iec,jsc:jec) )
allocate( adic_int100(isc:iec,jsc:jec) )
allocate( dic_int100(isc:iec,jsc:jec) )
allocate( o2_int100(isc:iec,jsc:jec) )
allocate( fe_int100(isc:iec,jsc:jec) )
allocate( no3_int100(isc:iec,jsc:jec) )
allocate( phy_int100(isc:iec,jsc:jec) )
allocate( det_int100(isc:iec,jsc:jec) )
allocate( pprod_gross_int100(isc:iec,jsc:jec) )
allocate( npp_int100(isc:iec,jsc:jec) )
allocate( radbio_int100(isc:iec,jsc:jec) )
allocate( radbio3d(isc:iec,jsc:jec,nk) )
allocate( wdet100(isc:iec,jsc:jec) )
allocate( npp2d(isc:iec,jsc:jec) )
allocate( npp3d(isc:iec,jsc:jec,nk) )
allocate( pprod_gross(isc:iec,jsc:jec,nk) )
allocate( pprod_gross_2d(isc:iec,jsc:jec) )
allocate( zprod_gross(isc:iec,jsc:jec,nk) )
allocate (tmp(isd:ied,jsd:jed) )
allocate ( tracer_sources(0:nk) )
allocate(area_k(isd:ied,jsd:jed) )
allocate( dummy(isc:iec) )
! initialize some arrays
xkw_t(:,:) = 0.0
patm_t(:,:) = 0.0
fice_t(:,:) = 0.0
dust_t(:,:) = 0.0
aco2(:,:) = 0.0
sc_co2(:,:) = 0.0
kw_co2(:,:) = 0.0
sc_o2(:,:) = 0.0
kw_o2(:,:) = 0.0
o2_saturation(:,:) = 0.0
tt(:) = 0.0
tk(:) = 0.0
ts(:) = 0.0
ts2(:) = 0.0
ts3(:) = 0.0
ts4(:) = 0.0
ts5(:) = 0.0
! allocate biotic array elements
do n = 1, instances !{
! rjm problem - the allocation of the arrays is done
! after the initialization routine which cause problems
! solution - move the call to array allocation to the init subroutine
! ntr_bgc = biotic(n)%ntr_bgc
! allocate( biotic(n)%ind_bgc(1:ntr_bgc) )
allocate( biotic(n)%htotal(isd:ied,jsd:jed) )
allocate( biotic(n)%alpha(isd:ied,jsd:jed) )
allocate( biotic(n)%csat(isd:ied,jsd:jed) )
allocate( biotic(n)%csat_csurf(isd:ied,jsd:jed) )
allocate( biotic(n)%csat_acsurf(isd:ied,jsd:jed) )
allocate( biotic(n)%csurf(isd:ied,jsd:jed) )
allocate( biotic(n)%acsurf(isd:ied,jsd:jed) )
allocate( biotic(n)%dpco2(isd:ied,jsd:jed) )
allocate( biotic(n)%pco2atm(isd:ied,jsd:jed) )
allocate( biotic(n)%paco2atm(isd:ied,jsd:jed) )
allocate( biotic(n)%pco2surf(isd:ied,jsd:jed) )
allocate( biotic(n)%paco2surf(isd:ied,jsd:jed) )
allocate( biotic(n)%caco3_sediment(isd:ied,jsd:jed) )
allocate( biotic(n)%det_sediment(isd:ied,jsd:jed) )
allocate( biotic(n)%caco3_sed_remin(isd:ied,jsd:jed) )
allocate( biotic(n)%det_sed_remin(isd:ied,jsd:jed) )
allocate( biotic(n)%caco3_sed_depst(isd:ied,jsd:jed) )
allocate( biotic(n)%det_sed_depst(isd:ied,jsd:jed) )
allocate( biotic(n)%sio2(isd:ied,jsd:jed) )
allocate( biotic(n)%po4(isd:ied,jsd:jed) )
ntr_bgc = biotic(n)%ntr_bgc
allocate(biotic(n)%bgc_global(1:ntr_bgc) )
allocate(biotic(n)%vstf(isc:iec,jsc:jec,1:ntr_bgc) )
enddo !}
! allocate biotic parameters
allocate( alphabio(isd:ied,jsd:jed) )
allocate( parbio(isd:ied,jsd:jed) )
allocate( kwbio(isd:ied,jsd:jed) )
allocate( kcbio(isd:ied,jsd:jed) )
allocate( abio(isd:ied,jsd:jed) )
allocate( bbio(isd:ied,jsd:jed) )
allocate( cbio(isd:ied,jsd:jed) )
allocate( k1bio(isd:ied,jsd:jed) )
allocate( muepbio(isd:ied,jsd:jed) )
allocate( muepsbio(isd:ied,jsd:jed) )
allocate( gam1bio(isd:ied,jsd:jed) )
allocate( gbio(isd:ied,jsd:jed) )
allocate( epsbio(isd:ied,jsd:jed) )
allocate( muezbio(isd:ied,jsd:jed) )
allocate( gam2bio(isd:ied,jsd:jed) )
allocate( muedbio(isd:ied,jsd:jed) )
allocate( muecaco3(isd:ied,jsd:jed) )
allocate( muedbio_sed(isd:ied,jsd:jed) )
allocate( muecaco3_sed(isd:ied,jsd:jed) )
allocate( wdetbio(isd:ied,jsd:jed) )
allocate( wcaco3(isd:ied,jsd:jed) )
allocate( nat_co2(isd:ied,jsd:jed) )
allocate( tscav_fe(isd:ied,jsd:jed) )
allocate( fe_bkgnd(isd:ied,jsd:jed) )
allocate( f_inorg(isd:ied,jsd:jed) )
! initialize some arrays
do n = 1, instances !{
biotic(n)%htotal(:,:) = 1.e-8
biotic(n)%sio2(:,:) = 35. *1e-3
biotic(n)%bgc_global(:) = 0. ! this will make vstf zero
biotic(n)%sal_global = 35.
biotic(n)%vstf(:,:,:) = 0.
biotic(n)%caco3_sediment(:,:) = 0.0
biotic(n)%det_sediment(:,:) = 0.0
enddo !} n
return
end subroutine allocate_arrays !}
! </SUBROUTINE> NAME="allocate_arrays"
!#######################################################################
! <SUBROUTINE NAME="csiro_bgc_bbc">
!
! <DESCRIPTION>
! compute bottom boundary conditions e.g. fluxes due to
! interaction with the sediment
! </DESCRIPTION>
!
subroutine csiro_bgc_bbc (isc, iec, jsc, jec, T_prog, grid, Time) !{
integer, intent(in) :: isc, iec
integer, intent(in) :: jsc, jec
type(ocean_prog_tracer_type), dimension(:), intent(inout) :: T_prog
type(ocean_grid_type), intent(in) :: Grid
type(ocean_time_type), intent(in) :: Time
!-----------------------------------------------------------------------
! local definitions
!-----------------------------------------------------------------------
character(len=64), parameter :: sub_name = 'csiro_bgc_bbc'
character(len=256), parameter :: error_header = &
'==>Error from ' // trim(mod_name) // '(' // trim(sub_name) // '):'
character(len=256), parameter :: warn_header = &
'==>Warning from ' // trim(mod_name) // '(' // trim(sub_name) // '):'
character(len=256), parameter :: note_header = &
'==>Note from ' // trim(mod_name) // '(' // trim(sub_name) // '):'
integer :: i, j, n, k, nn
integer :: ind_temp
real :: fbc
logical :: used
! =====================================================================
! begin executable code
! =====================================================================
!
!! rjm -- relax Fe to 1 at ocean bottom with 1 day time-constant
!! Huh? This is setting it to zero. RASF
!! Should we delete commented out code? RASF
!! Yes, fe%btf() values are left as zero...
!! bottom values for fe are assigned in csiro_bgc_tracer subroutine...
!! so commenting out this block. mac, nov10.
!
!do n = 1, instances !{
! if (id_fe.ne.0) then
! ind_fe = biotic(n)%ind_bgc(id_fe)
! do j = jsc, jec !{
! do i = isc, iec !{
! k = grid%kmt(i,j)
! t_prog(ind_fe)%btf(i,j) = rho0 * -1./86400. *0 ! negative into the ocean
!!grid%tmask(i,j,k) &
!! / (-1.) * &
!! (1 - max(0.0,t_prog(ind_fe)%field(i,j,k,taum1)))
! enddo !} i
! enddo !} j
! endif
!enddo !} n
!
!! Trial fe source within csiro_bgc_bbc. mac, nov12.
!do n = 1, instances !{
! if (id_fe.ne.0) then
! do j = jsc, jec !{
! do i = isc, iec !{
! k = grid%kmt(i,j)
! if (grid%zw(k) .le. 200) &
!t_prog(ind_fe)%btf(i,j) = -1.0 * rho0 * 1000. / 86400.
!! t_prog(ind_fe)%btf(i,j) = -1.0 * rho0 * (0.999 - t_prog(ind_fe)%field(i,j,k,time%taum1)) * &
!! grid%dzt(k) / (0.1 * 86400) ! flux ~ density * diff(concentration) * dz / time_scale
! ! setting time scale initial to 0.1 of a day, since at present, the concentration of the bottom is fixed in csiro_bgc_tracer;
! ! and want the time scale to be shorter (stronger) than the scavenging to 0.6 within csiro_bgc_source.
! ! mac, nov12.
! enddo !} i
! enddo !} j
! endif
!enddo !} n
! find remineralisation rate of sediment tracers. mac, nov12.
call time_interp_external(muedbio_sed_id, time%model_time, muedbio_sed)
call time_interp_external(muecaco3_sed_id, time%model_time, muecaco3_sed)
ind_temp = fm_get_index('/ocean_mod/prog_tracers/temp')
do n = 1, instances !{
do j = jsc, jec !{
do i = isc, iec !{
k = grid%kmt(i,j)
if (k .gt. 0) then
fbc= bbio(i,j)**(cbio(i,j)*T_prog(ind_temp)%field(i,j,k,time%taum1))
biotic(n)%det_sed_remin(i,j) = muedbio_sed(i,j)*fbc*biotic(n)%det_sediment(i,j)
biotic(n)%caco3_sed_remin(i,j) = muecaco3_sed(i,j)*fbc*biotic(n)%caco3_sediment(i,j)
! remineralisation of sediments to supply nutrient fields.
! NB, btf values are positive from the water column into the sediment. mac, nov12.
T_prog(ind_no3)%btf(i,j) = -1.0 * rho0 * biotic(n)%det_sed_remin(i,j)
if (id_o2 .ne. 0) &
T_prog(ind_o2)%btf(i,j) = -172./16. * T_prog(ind_no3)%btf(i,j)
if (id_dic .ne. 0) &
T_prog(ind_dic)%btf(i,j) = 106./16. * T_prog(ind_no3)%btf(i,j) - &
rho0 * biotic(n)%caco3_sed_remin(i,j)
if (id_adic .ne. 0) &
T_prog(ind_adic)%btf(i,j) = T_prog(ind_dic)%btf(i,j)
if (id_fe .ne. 0) &
T_prog(ind_fe)%btf(i,j) = 2.0e-2 * T_prog(ind_no3)%btf(i,j)
if (id_alk .ne. 0) &
T_prog(ind_alk)%btf(i,j) = -2.0 * rho0 * biotic(n)%caco3_sed_remin(i,j) - &
T_prog(ind_no3)%btf(i,j)
endif !} k > 0
enddo !} i
enddo !} j
enddo !} n
! send rate of remineralisation of sediment tracers to output. mac, nov12.
do n = 1, instances !{
if (id_caco3_sed_remin .gt. 0) then
used = send_data(id_caco3_sed_remin, biotic(n)%caco3_sed_remin(isc:iec,jsc:jec), &
time%model_time, rmask = grid%tmask(isc:iec,jsc:jec,1))
endif
if (id_det_sed_remin .gt. 0) then
used = send_data(id_det_sed_remin, biotic(n)%det_sed_remin(isc:iec,jsc:jec), &
time%model_time, rmask = grid%tmask(isc:iec,jsc:jec,1))
endif
enddo
do n = 1, instances !{
do nn=1,biotic(n)%ntr_bgc
! save the tracer bottom fluxes
if (biotic(n)%id_bgc_btf(nn) .gt. 0) then
used = send_data(biotic(n)%id_bgc_btf(nn), &
t_prog(biotic(n)%ind_bgc(nn))%btf(isc:iec,jsc:jec)/rho0, &
time%model_time, rmask = grid%tmask(isc:iec,jsc:jec,1))
endif
enddo !} nn
enddo !} n
return
end subroutine csiro_bgc_bbc !}
! </SUBROUTINE> NAME="csiro_bgc_bbc"
!#######################################################################
! <SUBROUTINE NAME="csiro_bgc_end">
!
! <DESCRIPTION>
! Clean up various BIOTIC quantities for this run.
! </DESCRIPTION>
!
subroutine csiro_bgc_end(isc, iec, jsc, jec, taup1, Thickness, T_prog, grid) !{
type(ocean_thickness_type), intent(in) :: Thickness
integer, intent(in) :: isc
integer, intent(in) :: iec
integer, intent(in) :: jsc
integer, intent(in) :: jec
integer, intent(in) :: taup1
type(ocean_prog_tracer_type), dimension(:), intent(in) :: T_prog
type(ocean_grid_type), intent(in) :: Grid
!-----------------------------------------------------------------------
! local definitions
!-----------------------------------------------------------------------
character(len=64), parameter :: sub_name = 'csiro_bgc_end'
character(len=256), parameter :: error_header = &
'==>Error from ' // trim(mod_name) // '(' // trim(sub_name) // '):'
character(len=256), parameter :: warn_header = &
'==>Warning from ' // trim(mod_name) // '(' // trim(sub_name) // '):'
character(len=256), parameter :: note_header = &
'==>Note from ' // trim(mod_name) // '(' // trim(sub_name) // '):'
integer :: i
integer :: j
integer :: k
integer :: lun
integer :: n
real :: total_det
real :: total_zoo
real :: total_phy
real :: total_o2
real :: total_no3
! =====================================================================
! begin executable code
! =====================================================================
! integrate the total concentrations of some tracers
! for the end of the run
total_no3 = 0.0
total_phy = 0.0
total_o2 = 0.0
total_zoo = 0.0
total_det = 0.0
do n = 1, instances !{
do k = 1,grid%nk !{
do j = jsc, jec !{
do i = isc, iec !{
total_no3 = total_no3 + &
t_prog(biotic(n)%ind_bgc(1))%field(i,j,k,taup1) * &
grid%dat(i,j) * grid%tmask(i,j,k) * Thickness%rho_dzt(i,j,k,taup1)
total_phy = total_phy + &
t_prog(biotic(n)%ind_bgc(2))%field(i,j,k,taup1) * &
grid%dat(i,j) * grid%tmask(i,j,k) * Thickness%rho_dzt(i,j,k,taup1)
total_o2 = total_o2 + &
t_prog(biotic(n)%ind_bgc(3))%field(i,j,k,taup1) * &
grid%dat(i,j) * grid%tmask(i,j,k) * Thickness%rho_dzt(i,j,k,taup1)
total_zoo = total_zoo + &
t_prog(biotic(n)%ind_bgc(4))%field(i,j,k,taup1) * &
grid%dat(i,j) * grid%tmask(i,j,k) * Thickness%rho_dzt(i,j,k,taup1)
total_det = total_det + &
t_prog(biotic(n)%ind_bgc(5))%field(i,j,k,taup1) * &
grid%dat(i,j) * grid%tmask(i,j,k) * Thickness%rho_dzt(i,j,k,taup1)
enddo !} i
enddo !} j
enddo !} k
call mpp_sum(total_no3)
call mpp_sum(total_phy)
call mpp_sum(total_o2)
call mpp_sum(total_zoo)
call mpp_sum(total_det)
write (stdout(),*) ' Instance ', trim(biotic(n)%name)
write (stdout(), &
'(/'' Total NO3 = '',es19.12,'' Gmol N'')') &
total_no3 * 1.0e-12
write (stdout(), &
'(/'' Total PHY = '',es19.12,'' Gmol N'')') &
total_phy * 1.0e-12
write (stdout(), &
'(/'' Total O2 = '',es19.12,'' Gmol O2'')') &
total_o2 * 1.0e-12
write (stdout(), &
'(/'' Total ZOO = '',es19.12,'' Gmol N'')') &
total_zoo * 1.0e-12
write (stdout(), &
'(/'' Total DET = '',es19.12,'' Gmol N'')') &
total_det * 1.0e-12
write (stdout(), &
'(/'' Total N = '',es19.12,'' Gmol N'')') &
(total_no3+total_phy+total_zoo+total_det) * 1.0e-12
!
! Write out extra restart file(s)
!
call reset_field_pointer(sed_restart, id_restart(1), biotic(n)%caco3_sediment(:,:))
call reset_field_pointer(sed_restart, id_restart(2), biotic(n)%det_sediment(:,:))
call save_restart(sed_restart)
enddo !} n
return
end subroutine csiro_bgc_end !}
! </SUBROUTINE> NAME="csiro_bgc_end"
!#######################################################################
! <SUBROUTINE NAME="csiro_bgc_sbc">
!
! <DESCRIPTION>
! Calculate the surface boundary conditions
! </DESCRIPTION>
!
subroutine csiro_bgc_sbc(isc, iec, jsc, jec, isd, ied, jsd, jed, &
T_prog, aice, wnd, grid, time, use_waterflux, salt_restore_as_salt_flux, atm_co2, co2flux, sfc_co2, iof_nit, iof_alg)
use ocmip2_co2calc_mod
use mpp_mod, only : mpp_sum
use time_interp_external_mod, only: time_interp_external
use time_manager_mod, only: days_in_year, days_in_month, &
get_date, set_date
use field_manager_mod, only: fm_get_index
integer, intent(in) :: isc, iec
integer, intent(in) :: jsc, jec
integer, intent(in) :: isd, ied
integer, intent(in) :: jsd, jed
type(ocean_prog_tracer_type), dimension(:), intent(inout) :: T_prog
type(ocean_grid_type), intent(in) :: Grid
type(ocean_time_type), intent(in) :: Time
real, intent(in), dimension(isd:ied,jsd:jed) :: aice, wnd
real, intent(in), dimension(isd:ied,jsd:jed), optional :: iof_nit, iof_alg
logical, intent(in) :: use_waterflux, salt_restore_as_salt_flux
real, intent(in), dimension(isd:ied,jsd:jed), optional :: atm_co2
real, intent(out), dimension(isd:ied,jsd:jed), optional :: co2flux
real, intent(out), dimension(isd:ied,jsd:jed), optional :: sfc_co2
real :: total_co2_flux, total_aco2_flux
logical :: used
!-----------------------------------------------------------------------
! local definitions
!-----------------------------------------------------------------------
character(len=64), parameter :: sub_name = 'csiro_bgc_sbc'
character(len=256), parameter :: error_header = &
'==>Error from ' // trim(mod_name) // '(' // trim(sub_name) // '):'
character(len=256), parameter :: warn_header = &
'==>Warning from ' // trim(mod_name) // '(' // trim(sub_name) // '):'
character(len=256), parameter :: note_header = &
'==>Note from ' // trim(mod_name) // '(' // trim(sub_name) // '):'
! coefficients for O2 saturation
!
real, parameter :: a_0 = 2.00907
real, parameter :: a_1 = 3.22014
real, parameter :: a_2 = 4.05010
real, parameter :: a_3 = 4.94457
real, parameter :: a_4 = -2.56847e-01
real, parameter :: a_5 = 3.88767
real, parameter :: b_0 = -6.24523e-03
real, parameter :: b_1 = -7.37614e-03
real, parameter :: b_2 = -1.03410e-02
real, parameter :: b_3 = -8.17083e-03
real, parameter :: c_0 = -4.88682e-07
integer :: i
integer :: j
integer :: k
integer :: n
integer :: nn
integer :: ntr_bgc
integer :: ind_trc
integer :: m
integer :: kz
integer :: hour
integer :: day
real :: days_in_this_year
integer :: minute
integer :: month
integer :: num_days
integer :: second
integer :: year
integer :: indtemp, indsal
! =====================================================================
! begin executable code
! =====================================================================
call get_date(time%model_time, &
year, month, day, hour, minute, second)
num_days = days_in_year(time%model_time)
days_in_this_year = 0.0
do m = 1, month - 1
days_in_this_year = days_in_this_year + &
days_in_month(set_date(year, m, 1))
enddo
days_in_this_year = days_in_this_year + day - 1 + hour/24.0 + &
minute/1440.0 + second/86400.0
!---------------------------------------------------------------------