-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathmo_inventory_bgc.F90
2189 lines (1939 loc) · 111 KB
/
mo_inventory_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
! Copyright (C) 2002 P. Wetzel
! Copyright (C) 2022 K. Assmann, J. Tjiputra, J. Schwinger, T. Torsvik
!
! This file is part of BLOM/iHAMOCC.
!
! BLOM is free software: you can redistribute it and/or modify it under the
! terms of the GNU Lesser General Public License as published by the Free
! Software Foundation, either version 3 of the License, or (at your option)
! any later version.
!
! BLOM 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 Lesser General Public License for
! more details.
!
! You should have received a copy of the GNU Lesser General Public License
! along with BLOM. If not, see https://www.gnu.org/licenses/.
module mo_inventory_bgc
implicit none
private
public :: inventory_bgc
contains
subroutine inventory_bgc(kpie,kpje,kpke,dlxp,dlyp,ddpo,omask,iogrp)
!***********************************************************************************************
! Calculate the BGC inventory.
!
! P.Wetzel, *MPI-Met, HH* 29.07.02
!
! Modified
! T. Torsvik *UiB* 22.02.22
! Include option for writing inventory to netCDF file.
!***********************************************************************************************
use mod_xc, only: mnproc,ips,nbdy,xcsum
use mo_carbch, only: atm,atmflx,co3,hi,ndepnoyflx,rivinflx,ocetra,sedfluxo,ndepnhxflx
use mo_sedmnt, only: prcaca,prorca,silpro
use mo_biomod, only: expoor,expoca,exposi
use mo_param_bgc, only: rcar,rnit
use mo_control_bgc, only: do_ndep,do_rivinpt,io_stdo_bgc
use mo_bgcmean, only: bgct2d,jco2flux,jirdin,jn2flux,jn2oflux,jndepnoy,jndepnhx, &
jo2flux,jprcaca,jnh3flux,jdmsflux, &
jprorca,jsilpro,nbgcmax,glb_inventory
use mo_param1_bgc, only: ialkali,ian2o,iano3,iatmco2,iatmn2,iatmn2o,iatmo2,icalc,idet,idoc, &
igasnit,iopal,ioxygen,iphosph,iphy,ipowaic,ipowaox,ipowaph,ipowasi, &
ipown2,ipowno3,isco212,isilica,isssc12,issso12,issssil,izoo, &
irdin,irdip,irsi,iralk,irdoc,irdet,nocetra,npowtra,nsedtra,nriv, &
ianh4,iano2,iatmnh3,ipownh4,ipown2o,ipowno2,iatmdms
use mo_vgrid, only: dp_min
! NOT sedbypass
use mo_param1_bgc, only: ks
use mo_sedmnt, only: porwat,seddw,sedlay,burial,sedhpl,powtra,porsol
use mo_control_bgc, only: use_PBGC_CK_TIMESTEP,use_BOXATM,use_sedbypass,use_cisonew,use_AGG, &
use_CFC,use_natDIC,use_BROMO,use_extNcycle
! Arguments
integer, intent(in) :: kpie,kpje,kpke
integer, intent(in) :: iogrp
real, intent(in) :: dlxp(kpie,kpje)
real, intent(in) :: dlyp(kpie,kpje)
real, intent(in) :: ddpo(kpie,kpje,kpke)
real, intent(in) :: omask(kpie,kpje)
! Local variables
integer :: i,j,k,l
real :: ztmp1(1-nbdy:kpie+nbdy,1-nbdy:kpje+nbdy)
real :: ztmp2(1-nbdy:kpie+nbdy,1-nbdy:kpje+nbdy)
real :: vol
! ppm2con: atmospheric weight: ~10000kg/m^2, avrg. ~29 g/mol
! --> 350 kmol/m^2 --> 1ppm ~ 0.35e-3 kmol/m^2
real, parameter :: ppm2con = 0.35e-3
!=== Variables for global sums
real :: ztotvol ! Total ocean volume
real :: ztotarea ! Total sea surface area
!--- aqueous sediment tracer
real :: zsedtotvol ! Total pore water volume
real :: zpowtratot(npowtra) ! Sum : Pore water tracers
real :: zpowtratoc(npowtra) ! Mean concentration of pore water tracers
!--- non aqueous sediment tracer
real :: zsedhplto ! Total sediment accumulated hydrogen ions
real :: zsedlayto(nsedtra) ! Sum : Sediment layer tracers
real :: zburial(nsedtra) ! Sum : Sediment burial tracers
!--- oceanic tracers
real :: zocetratot(nocetra) ! Sum : Ocean tracers
real :: zocetratoc(nocetra) ! Mean concentration of ocean racers
!--- additional ocean tracer
real :: zhito ! Total hydrogen ion tracer
real :: zco3to ! Total dissolved carbonate (CO3) tracer
real :: ODZvol ! ODZ volume (O2threshold: 20 mumol)
!--- alkalinity of the first layer
real :: zvoltop ! Total volume of top ocean layer
real :: zalkali ! Total alkalinity of top ocean layer
real :: zphosph ! Total phosphate of top ocean layer
real :: zano3 ! Total nitrate of top ocean layer
!--- river fluxes
real :: srivflux(nriv) ! sum of riverfluxes
!--- atmosphere flux and atmospheric CO2
real :: sndepnoyflux ! sum of N dep fluxes
real :: sndepnhxflux ! sum of N dep fluxes
real :: zatmco2,zatmo2,zatmn2
real :: co2flux,so2flux,sn2flux,sn2oflux,snh3flux,sdmsflux
real :: zprorca,zprcaca,zsilpro
!--- total tracer budgets
real :: totalcarbon,totalphos,totalsil,totalnitr,totaloxy
!--- sediment fluxes
real :: sum_zprorca
real :: sum_zprcaca
real :: sum_zsilpro
real :: sum_sedfluxo(npowtra)
!--- export production
real :: sum_expoor
real :: sum_expoca
real :: sum_exposi
!=== aqueous sediment tracer
!----------------------------------------------------------------------
if (use_sedbypass) then
zsedtotvol = 0.0
zpowtratot(:)=0.0
zpowtratoc(:)=0.0
zsedlayto(:)=0.0
zburial(:)=0.0
zsedhplto=0.0
else
ztmp1(:,:)=0.0
do k=1,ks
do j=1,kpje
do i=1,kpie
ztmp1(i,j) = ztmp1(i,j) + omask(i,j)*seddw(k) &
& *dlxp(i,j)*dlyp(i,j)*porwat(i,j,k)
enddo
enddo
enddo
call xcsum(zsedtotvol,ztmp1,ips)
do l=1,npowtra
ztmp1(:,:)=0.0
do k=1,ks
do j=1,kpje
do i=1,kpie
vol = seddw(k)*dlxp(i,j)*dlyp(i,j)*porwat(i,j,k)
ztmp1(i,j)= ztmp1(i,j) + omask(i,j)*powtra(i,j,k,l)*vol
enddo
enddo
enddo
call xcsum(zpowtratot(l),ztmp1,ips)
zpowtratoc(l) = zpowtratot(l)/zsedtotvol
enddo
!=== non aqueous sediment tracer
!----------------------------------------------------------------------
zburial = sum2d_array(burial, nsedtra)
do l=1,nsedtra
ztmp1(:,:)=0.0
do k=1,ks
do j=1,kpje
do i=1,kpie
vol = porsol(i,j,k)*seddw(k)*dlxp(i,j)*dlyp(i,j)
ztmp1(i,j) = ztmp1(i,j) + omask(i,j)*sedlay(i,j,k,l)*vol
enddo
enddo
enddo
call xcsum(zsedlayto(l),ztmp1,ips)
enddo
ztmp1(:,:)=0.0
do k=1,ks
do j=1,kpje
do i=1,kpie
vol = porsol(i,j,k)*seddw(k)*dlxp(i,j)*dlyp(i,j)
ztmp1(i,j) = ztmp1(i,j) + omask(i,j)*sedhpl(i,j,k)*vol
enddo
enddo
enddo
call xcsum(zsedhplto,ztmp1,ips)
endif ! not sedbypass
!=== oceanic tracers
!----------------------------------------------------------------------
ztotvol = 0.
zocetratot = 0.
zocetratoc = 0.
ztmp1(:,:)=0.0
do k=1,kpke
do j=1,kpje
do i=1,kpie
if (ddpo(i,j,k).gt.dp_min) then
ztmp1(i,j) = ztmp1(i,j) &
& + omask(i,j)*dlxp(i,j)*dlyp(i,j)*ddpo(i,j,k)
endif
enddo
enddo
enddo
call xcsum(ztotvol,ztmp1,ips)
do l=1,nocetra
ztmp1(:,:)=0.0
do k=1,kpke
do j=1,kpje
do i=1,kpie
if (ddpo(i,j,k).gt.dp_min) then
vol = dlxp(i,j)*dlyp(i,j)*ddpo(i,j,k)
ztmp1(i,j) = ztmp1(i,j) + omask(i,j)*ocetra(i,j,k,l)*vol
! if (ocetra(i,j,k,l).lt.0.0) then
! write(io_stdo_bgc,*) 'ocetra -ve', l,ocetra(i,j,k,l)
! endif
endif
enddo
enddo
enddo
call xcsum(zocetratot(l),ztmp1,ips)
zocetratoc(l) = zocetratot(l)/ztotvol
enddo
!=== additional ocean tracer
!----------------------------------------------------------------------
zhito = 0.
zco3to = 0.
ztmp1(:,:)=0.0
ztmp2(:,:)=0.0
do k=1,kpke
do j=1,kpje
do i=1,kpie
if (ddpo(i,j,k).gt.dp_min) then
vol = dlxp(i,j)*dlyp(i,j)*ddpo(i,j,k)
ztmp1(i,j) = ztmp1(i,j) + omask(i,j)*hi(i,j,k) *vol
ztmp2(i,j) = ztmp2(i,j) + omask(i,j)*co3(i,j,k)*vol
endif
enddo
enddo
enddo
call xcsum(zhito ,ztmp1,ips)
call xcsum(zco3to,ztmp2,ips)
! ODZ volume
ODZvol = 0.
ztmp1(:,:)=0.0
do k=1,kpke
do j=1,kpje
do i=1,kpie
if (ddpo(i,j,k) > dp_min .and. ocetra(i,j,k,ioxygen) < 20.0e-6) then
! snapshot value for ODZ volume for hypoxic volume below 20mumol/L
vol = dlxp(i,j)*dlyp(i,j)*ddpo(i,j,k)
ztmp1(i,j) = ztmp1(i,j) + omask(i,j)*vol
endif
enddo
enddo
enddo
call xcsum(ODZvol,ztmp2,ips)
!=== alkalinity of the first layer
!--------------------------------------------------------------------
zvoltop = 0.
zalkali = 0.
k=1
ztmp1(:,:)=0.0
ztmp2(:,:)=0.0
do j=1,kpje
do i=1,kpie
ztmp1(i,j) = omask(i,j)*dlxp(i,j)*dlyp(i,j)*ddpo(i,j,k)
ztmp2(i,j) = ocetra(i,j,k,ialkali)*ztmp1(i,j)
enddo
enddo
call xcsum(zvoltop,ztmp1,ips)
call xcsum(zalkali,ztmp2,ips)
!=== phosphate and nitrate of the first layer
zphosph = 0.
zano3 = 0.
k=1
ztmp1(:,:)=0.0
ztmp2(:,:)=0.0
do j=1,kpje
do i=1,kpie
vol = omask(i,j)*dlxp(i,j)*dlyp(i,j)*ddpo(i,j,k)
ztmp1(i,j) = ocetra(i,j,k,iphosph)*vol
ztmp2(i,j) = ocetra(i,j,k,iano3)*vol
enddo
enddo
call xcsum(zphosph,ztmp1,ips)
call xcsum(zano3,ztmp2,ips)
!=== atmosphere flux and atmospheric CO2
!--------------------------------------------------------------------
ztotarea =0.
co2flux =0.
so2flux =0.
sn2flux =0.
sn2oflux =0.
snh3flux =0.
sdmsflux =0.
sndepnoyflux=0.
sndepnhxflux=0.
srivflux =0.
zatmco2 =0.
zatmo2 =0.
zatmn2 =0.
ztmp1(:,:)=0.0
do j=1,kpje
do i=1,kpie
ztmp1(i,j) = dlxp(i,j)*dlyp(i,j)
enddo
enddo
call xcsum(ztotarea,ztmp1,ips)
if (use_PBGC_CK_TIMESTEP) then
! only consider instantaneous fluxes in debugging mode
co2flux = sum2d(atmflx(:,:,iatmco2))
so2flux = sum2d(atmflx(:,:,iatmo2))
sn2flux = sum2d(atmflx(:,:,iatmn2))
sdmsflux = sum2d(atmflx(:,:,iatmdms))
sn2oflux = sum2d(atmflx(:,:,iatmn2o))
if (use_extNcycle) then
snh3flux = sum2d(atmflx(:,:,iatmnh3))
endif
! nitrogen deposition
if(do_ndep) then
sndepnoyflux = sum2d(ndepnoyflx)
if (use_extNcycle) then
sndepnhxflux = sum2d(ndepnhxflx)
endif
endif
! river fluxes
if(do_rivinpt) then
srivflux = sum2d_array(rivinflx, nriv)
endif
else
! consider accumulated fluxes in the regular mode
co2flux = sum2d(bgct2d(:,:,jco2flux))
so2flux = sum2d(bgct2d(:,:,jo2flux))
sn2flux = sum2d(bgct2d(:,:,jn2flux))
sdmsflux = sum2d(atmflx(:,:,iatmdms)) ! exception: DMS is instantanious flux (no accumulation)
sn2oflux = sum2d(bgct2d(:,:,jn2oflux))
if (use_extNcycle) then
snh3flux = sum2d(bgct2d(:,:,jnh3flux))
endif
! nitrogen deposition fluxes
if(do_ndep) then
sndepnoyflux = sum2d(bgct2d(:,:,jndepnoy))
if (use_extNcycle) then
sndepnhxflux = sum2d(bgct2d(:,:,jndepnhx))
endif
endif
! River fluxes
if(do_rivinpt) then
srivflux = sum2d_array(bgct2d(:,:,jirdin:jirdin+nriv-1), nriv)
endif
endif
if (use_BOXATM) then
zatmco2 = sum2d(atm(:,:,iatmco2))
zatmo2 = sum2d(atm(:,:,iatmo2))
zatmn2 = sum2d(atm(:,:,iatmn2))
endif
!--- Complete sum of inventory in between bgc.f90
zprorca = sum2d(prorca)
zprcaca = sum2d(prcaca)
zsilpro = sum2d(silpro)
!=== Sum of inventory
!----------------------------------------------------------------------
! Units in P have a C:P Ratio of 122:1
! totalcarbon= &
! & (zocetratot(idet)+zocetratot(idoc)+zocetratot(iphy) &
! & +zocetratot(izoo))*rcar+zocetratot(isco212)+zocetratot(icalc)
totalcarbon= &
(zocetratot(idet)+zocetratot(idoc)+zocetratot(iphy) &
+ zocetratot(izoo))*rcar+zocetratot(isco212)+zocetratot(icalc) &
+ zpowtratot(ipowaic)+zsedlayto(isssc12)+zsedlayto(issso12)*rcar &
+ zburial(isssc12)+zburial(issso12)*rcar &
+ zprorca*rcar+zprcaca
if (use_BOXATM) then
totalcarbon = totalcarbon + zatmco2*ppm2con
else
totalcarbon = totalcarbon + co2flux
endif
totalnitr= &
(zocetratot(idet)+zocetratot(idoc)+zocetratot(iphy) &
+ zocetratot(izoo))*rnit+zocetratot(iano3)+zocetratot(igasnit)*2 &
+ zpowtratot(ipowno3)+zpowtratot(ipown2)*2 &
+ zsedlayto(issso12)*rnit+zburial(issso12)*rnit &
+ zocetratot(ian2o)*2 &
- sndepnoyflux &
+ zprorca*rnit
if (use_BOXATM) then
totalnitr = totalnitr + zatmn2*ppm2con*2
else
totalnitr = totalnitr + sn2flux*2+sn2oflux*2
endif
if (use_extNcycle) then
totalnitr = totalnitr + zocetratot(ianh4)+zocetratot(iano2)+snh3flux&
& - sndepnhxflux &
& +zpowtratot(ipownh4)+zpowtratot(ipown2o)*2+zpowtratot(ipowno2)
endif
totalphos= &
zocetratot(idet)+zocetratot(idoc)+zocetratot(iphy) &
+ zocetratot(izoo)+zocetratot(iphosph) &
+ zpowtratot(ipowaph)+zsedlayto(issso12) &
+ zburial(issso12) &
+ zprorca
totalsil= &
zocetratot(isilica)+zocetratot(iopal) &
+ zpowtratot(ipowasi)+zsedlayto(issssil)+zburial(issssil) &
+ zsilpro
totaloxy= &
(zocetratot(idet)+zocetratot(idoc)+zocetratot(iphy) &
+ zocetratot(izoo))*(-24.)+zocetratot(ioxygen) &
+ zocetratot(iphosph)*2 +zocetratot(isco212)+zocetratot(icalc) &
+ zocetratot(iano3)*1.5+zocetratot(ian2o)*0.5 &
+ zsedlayto(issso12)*(-24.) + zsedlayto(isssc12) &
!+ zburial(issso12)*(-24.) + zburial(isssc12) &
+ zpowtratot(ipowno3)*1.5+zpowtratot(ipowaic) &
+ zpowtratot(ipowaox)+zpowtratot(ipowaph)*2 &
- sndepnoyflux*1.5 &
+ zprorca*(-24.)+zprcaca
if (use_BOXATM) then
totaloxy = totaloxy + zatmo2*ppm2con+zatmco2*ppm2con
else
totaloxy = totaloxy + so2flux+sn2oflux*0.5+co2flux
endif
if (use_extNcycle) then
totaloxy = totaloxy + zocetratot(iano2)+zpowtratot(ipown2o)*0.5+zpowtratot(ipowno2)
endif
if (do_rivinpt) then
totalcarbon = totalcarbon- (srivflux(irdoc)+srivflux(irdet))*rcar &
& - (srivflux(iralk)+srivflux(irdin)+srivflux(irdip)) ! =sco212
totalnitr = totalnitr - (srivflux(irdoc)+srivflux(irdet))*rnit - srivflux(irdin)
totalphos = totalphos - (srivflux(irdoc)+srivflux(irdet)+srivflux(irdip))
totalsil = totalsil - srivflux(irsi)
totaloxy = totaloxy - (srivflux(irdoc)+srivflux(irdet))*(-24.) &
& - srivflux(irdin)*1.5 - srivflux(irdip)*2. &
& - (srivflux(iralk)+srivflux(irdin)+srivflux(irdip))
endif
!=== Compute sediment fluxes
!----------------------------------------------------------------------
sum_zprorca = sum2d(bgct2d(:,:,jprorca))
sum_zprcaca = sum2d(bgct2d(:,:,jprcaca))
sum_zsilpro = sum2d(bgct2d(:,:,jsilpro))
sum_sedfluxo = sum2d_array(sedfluxo, npowtra)
sum_expoor = sum2d(expoor)
sum_expoca = sum2d(expoca)
sum_exposi = sum2d(exposi)
!=== Write output to netCDF file or stdout
!----------------------------------------------------------------------
if (mnproc == 1) then
if (iogrp == 0) then ! debug mode
call write_stdout
else if (GLB_INVENTORY(iogrp) == 2) then ! netcdf output
call write_netcdf(iogrp)
else ! default
call write_stdout
endif
endif
return
contains
function sum2d(var2d) result(total)
!**********************************************************************
!**** Sum 2D scalar fields
!**********************************************************************
implicit none
real, dimension(kpie,kpje), intent(in) :: var2d
real :: total
! Local variables
integer :: i,j
!--- input to xcsum require halo indices
real, dimension(1-nbdy:kpie+nbdy,1-nbdy:kpje+nbdy) :: ztmp
ztmp(:,:)=0.0
do j=1,kpje
do i=1,kpie
ztmp(i,j) = var2d(i,j)*dlxp(i,j)*dlyp(i,j)*omask(i,j)
enddo
enddo
call xcsum(total,ztmp,ips)
end function sum2d
function sum2d_array(var3d, narr) result(total)
!**********************************************************************
!**** Sum 2D array fields
!**********************************************************************
implicit none
integer, intent(in) :: narr
real, dimension(kpie,kpje,narr), intent(in) :: var3d
real, dimension(narr) :: total
! Local variables
integer :: i,j,k
!--- input to xcsum require halo indices
real, dimension(1-nbdy:kpie+nbdy,1-nbdy:kpje+nbdy) :: ztmp
ztmp(:,:)=0.0
do k=1,narr
do j=1,kpje
do i=1,kpie
ztmp(i,j) = var3d(i,j,k)*dlxp(i,j)*dlyp(i,j)*omask(i,j)
enddo
enddo
call xcsum(total(k),ztmp,ips)
enddo
end function sum2d_array
subroutine write_stdout
!**********************************************************************
!**** Write inventory to log file.
!**********************************************************************
implicit none
integer :: l
if (.not. use_sedbypass) then
!=== aqueous sediment tracer
!------------------------------------------------------------------
write(io_stdo_bgc,*) ' '
write(io_stdo_bgc,*)'Global inventory of aqueous sediment tracer'
write(io_stdo_bgc,*)'-------------------------------------------'
write(io_stdo_bgc,*) ' total[kmol] concentration[mol/L]'
do l=1,npowtra
write(io_stdo_bgc,*)'No. ',l,' ',zpowtratot(l), &
& ' ',zpowtratoc(l),' ',zsedtotvol
enddo
write(io_stdo_bgc,*) ' '
!=== non aqueous sediment tracer
!------------------------------------------------------------------
write(io_stdo_bgc,*) ' '
write(io_stdo_bgc,*) &
& 'Global inventory of solid sediment constituents'
write(io_stdo_bgc,*) &
& '----------------------------------------------------'
write(io_stdo_bgc,*) ' [kmol]'
do l=1,nsedtra
write(io_stdo_bgc,*) 'Sediment No. ',l,' ', zsedlayto(l)
write(io_stdo_bgc,*) 'Burial No. ',l,' ', zburial(l)
enddo
write(io_stdo_bgc,*) 'hpl ', zsedhplto
write(io_stdo_bgc,*) ' '
endif
!=== oceanic tracers
!------------------------------------------------------------------
write(io_stdo_bgc,*) ' '
write(io_stdo_bgc,*) 'Global inventory of advected ocean tracers'
write(io_stdo_bgc,*) '------------------------------------------'
write(io_stdo_bgc,*) ' '
write(io_stdo_bgc,*) ' total[kmol] concentration[kmol/m^3]'
write(io_stdo_bgc,*) ' '
write(io_stdo_bgc,*) 'ztotvol',ztotvol
do l=1,nocetra
write(io_stdo_bgc,*) 'No. ',l, zocetratot(l), zocetratoc(l)
enddo
!=== additional ocean tracer
!------------------------------------------------------------------
! write(io_stdo_bgc,*) ' '
! write(io_stdo_bgc,*) 'Glob. inventory of additional ocean tracer'
! write(io_stdo_bgc,*) '------------------------------------------'
! write(io_stdo_bgc,*) ' total[kmol] concentration[kmol/m^3]'
! write(io_stdo_bgc,*) ' '
! write(io_stdo_bgc,*) ' hi', zhito, zhito/ztotvol
! write(io_stdo_bgc,*) ' co3', zco3to, zco3to/ztotvol
! write(io_stdo_bgc,*) ' '
!=== alkalinity of the first layer
!------------------------------------------------------------------
! write(io_stdo_bgc,*) ' '
! write(io_stdo_bgc,*) 'Global inventory of first layer alkalinity'
! write(io_stdo_bgc,*) '------------------------------------------'
! write(io_stdo_bgc,*) ' '
! write(io_stdo_bgc,*) ' total[kmol] concentration[kmol/m^3]'
! write(io_stdo_bgc,*) ' '
! write(io_stdo_bgc,*) zalkali, zalkali/zvoltop
!=== atmosphere flux and atmospheric CO2
!------------------------------------------------------------------
! write(io_stdo_bgc,*) ' '
! write(io_stdo_bgc,*) 'Global fluxes into atmosphere'
! write(io_stdo_bgc,*) '-----------------------------'
! write(io_stdo_bgc,*) ' [kmol]'
! write(io_stdo_bgc,*) ' '
! write(io_stdo_bgc,*) 'CO2Flux :',co2flux
! write(io_stdo_bgc,*) 'O2 Flux :',so2flux
! write(io_stdo_bgc,*) 'N2 Flux :',sn2flux
! write(io_stdo_bgc,*) 'N2O Flux :',sn2oflux
if (use_extNcycle) then
! write(io_stdo_bgc,*) 'NH3 Flux :',snh3flux
endif
! write(io_stdo_bgc,*) ' '
if (use_BOXATM) then
! write(io_stdo_bgc,*) 'global atm. CO2[ppm] / kmol: ', &
! & zatmco2/ztotarea,zatmco2*ppm2con
! write(io_stdo_bgc,*) 'global atm. O2[ppm] / kmol : ', &
! & zatmo2/ztotarea,zatmo2*ppm2con
! write(io_stdo_bgc,*) 'global atm. N2[ppm] / kmol : ', &
! & zatmn2/ztotarea,zatmn2*ppm2con
endif
! write(io_stdo_bgc,*) ' '
! write(io_stdo_bgc,*) 'Should be zero at the end: '
! write(io_stdo_bgc,*) 'prorca, prcaca, silpro ', &
! & zprorca, zprcaca, zsilpro
! write(io_stdo_bgc,*) ' '
if(do_ndep) then
write(io_stdo_bgc,*) 'NdepNOyFlux :',sndepnoyflux
if (use_extNcycle) then
write(io_stdo_bgc,*) 'NdepNHxFlux :',sndepnhxflux
endif
endif
! riverine fluxes
!------------------------------------------------------------------
if (do_rivinpt)then
write(io_stdo_bgc,*) 'Riverine fluxes:'
do l=1,nriv
write(io_stdo_bgc,*) 'No. ',l,srivflux(l)
enddo
endif
!=== Sum of inventory
!------------------------------------------------------------------
! Units in P have a C:P Ratio of 122:1
write(io_stdo_bgc,*) 'Global total[kmol] of carbon : ', totalcarbon
write(io_stdo_bgc,*) ' '
write(io_stdo_bgc,*) 'Global total[kmol] of phosph. : ', totalphos
write(io_stdo_bgc,*) ' '
write(io_stdo_bgc,*) 'Global total[kmol] of silicate : ', totalsil
write(io_stdo_bgc,*) ' '
write(io_stdo_bgc,*) 'Global total[kmol] of nitrogen. : ', totalnitr
write(io_stdo_bgc,*) ' '
write(io_stdo_bgc,*) 'Global total[kmol] of oxygen. : ', totaloxy
!=== Write sediment fluxes
!------------------------------------------------------------------
write(io_stdo_bgc,*) ' '
write(io_stdo_bgc,*) 'Global fluxes into and out of the sediment'
write(io_stdo_bgc,*) '------------------------------------------'
write(io_stdo_bgc,*) ' [kmol]'
write(io_stdo_bgc,*) ' '
write(io_stdo_bgc,*) 'Detritus, Calcium Carbonate, Silicate ', &
& sum_zprorca, sum_zprcaca, sum_zsilpro
write(io_stdo_bgc,*) ' '
do l=1,npowtra
write(io_stdo_bgc,*) 'No. ',l,' ',sum_sedfluxo(l)
enddo
write(io_stdo_bgc,*) ' '
write(io_stdo_bgc,*) 'Global total export production'
write(io_stdo_bgc,*) '------------------------------'
write(io_stdo_bgc,*) ' [kmol]'
write(io_stdo_bgc,*) 'carbon : ',sum_expoor
write(io_stdo_bgc,*) 'carbonate: ',sum_expoca
write(io_stdo_bgc,*) 'silicate : ',sum_exposi
write(io_stdo_bgc,*) ' '
end subroutine write_stdout
subroutine write_netcdf(iogrp)
!*********************************************************************************************
!**** Write inventory to netCDF file.
!*********************************************************************************************
use netcdf, only: nf90_clobber, nf90_close, nf90_create, nf90_def_dim, &
nf90_def_var, nf90_double, nf90_enddef, nf90_global, &
nf90_inq_dimid, nf90_inq_varid, nf90_open, &
nf90_put_att, nf90_put_var, nf90_unlimited, nf90_write
use mod_types, only: r8
use mod_config, only: expcnf, runid, inst_suffix
use mod_time, only: date0, time0, date, time, nstep, nday_of_year,nstep_in_day,calendar
use mo_bgcmean, only: filefq_bgc, fileann_bgc, filemon_bgc,glb_fnametag
use mo_param1_bgc, only: idicsat,idms,ifdust,iiron,iprefalk,iprefdic,iprefo2,iprefpo4, &
iadust,inos,ibromo,icfc11,icfc12,isf6,icalc13,icalc14,idet13, &
idet14,idoc13,idoc14,iphy13,iphy14,isco213,isco214,izoo13,izoo14, &
inatalkali,inatcalc,inatsco212,ianh4,iano2,iprefsilica
use mo_control_bgc,only: use_PBGC_CK_TIMESTEP,use_BOXATM,use_sedbypass,use_cisonew,use_AGG, &
use_CFC,use_natDIC,use_BROMO,use_pref_tracers,dtbgc
implicit none
integer, intent(in) :: iogrp
!=== Save filename and counter variables
!--- netCDF output file names
character(len=256), dimension(nbgcmax), save :: fname_inv
integer, dimension(nbgcmax), save :: ncrec = 0
logical, dimension(nbgcmax), save :: append2file_inv
data append2file_inv /nbgcmax*.false./
!=== Local variables
character(len=:), allocatable :: prefix, sep1, sep2
character(len=20) :: tstamp
character(len=30) :: timeunits
integer :: l
real(r8) :: datenum
!=== Variables for netcdf
integer :: ncid, ncvarid, ncstat
integer :: wrstart(1)
!--- time: dimension and variable id
integer :: time_dimid
integer :: time_varid
!--- River
integer :: nriv_dimid,nriv_dimids(2),sriv_varid
integer :: nriv_wrstart(2) ! record start point
integer :: nriv_count(2) ! record count
! NOT sedbypass
!--- aqueous sediment tracers
integer :: npowtra_dimid ! id: aqueous sediments
integer :: zpowtra_dimids(2) ! aqueous sediment dimensions
integer :: zpowtra_wrstart(2) ! record start point
integer :: zpowtra_count(2) ! record count
integer :: zsedtotvol_varid ! id: Total sediment volume
integer :: zpowtratot_varid ! id: Total aqueous sediment tracer [kmol]
integer :: zpowtratoc_varid ! id: Sediment tracer concentration [kmol/L]
!--- non-aqueous sediment tracers
integer :: nsedtra_dimid ! id: solid sediments
integer :: zsedtra_dimids(2) ! solid sediments dimensions
integer :: zsedtra_wrstart(2) ! record start point
integer :: zsedtra_count(2) ! record count
integer :: zsedlayto_varid ! id: sediment layer tracers
integer :: zburial_varid ! id: sediment burial tracers
integer :: zsedhplto_varid ! id: accumulated hydrogen ions
!--- oceanic tracers
!--- Write total sum zt_<variable>_varid, and mean concentration zc_<variable>_varid
integer :: ztotvol_varid ! Total ocean volume
integer :: zt_sco212_varid, zc_sco212_varid ! Dissolved CO2
integer :: zt_alkali_varid, zc_alkali_varid ! Alkalinity
integer :: zt_alkalisrf_varid, zc_alkalisrf_varid ! Alkalinity in surface layer
integer :: zt_phosph_varid, zc_phosph_varid ! Dissolved phosphate
integer :: zt_phosphsrf_varid, zc_phosphsrf_varid ! Dissolved phosphate in surface layer
integer :: zt_oxygen_varid, zc_oxygen_varid ! Dissolved oxygen
integer :: zt_gasnit_varid, zc_gasnit_varid ! Gaseous nitrogen (N2)
integer :: zt_ano3_varid, zc_ano3_varid ! Dissolved nitrate
integer :: zt_ano3srf_varid, zc_ano3srf_varid ! Dissolved nitrate in surface layer
integer :: zt_silica_varid, zc_silica_varid ! Silicid acid (Si(OH)4)
integer :: zt_doc_varid, zc_doc_varid ! Dissolved organic carbon
integer :: zt_poc_varid, zc_poc_varid ! Particulate organic carbon
integer :: zt_phyto_varid, zc_phyto_varid ! Phytoplankton concentration
integer :: zt_grazer_varid, zc_grazer_varid ! Zooplankton concentration
integer :: zt_calciu_varid, zc_calciu_varid ! Calcium carbonate
integer :: zt_opal_varid, zc_opal_varid ! Biogenic silica
integer :: zt_n2o_varid, zc_n2o_varid ! Laughing gas (N2O)
integer :: zt_dms_varid, zc_dms_varid ! DiMethylSulfide
integer :: zt_fdust_varid, zc_fdust_varid ! Non-aggregated dust
integer :: zt_iron_varid, zc_iron_varid ! Dissolved iron
integer :: zt_prefo2_varid, zc_prefo2_varid ! Preformed oxygen
integer :: zt_prefpo4_varid, zc_prefpo4_varid ! Preformed phosphate
integer :: zt_prefsilica_varid,zc_prefsilica_varid ! Preformed silicate
integer :: zt_prefalk_varid, zc_prefalk_varid ! Preformed alkalinity
integer :: zt_prefdic_varid, zc_prefdic_varid ! Preformed DIC
integer :: zt_dicsat_varid, zc_dicsat_varid ! Saturated DIC
! cisonew
integer :: zt_sco213_varid, zc_sco213_varid ! Dissolved CO2-C13
integer :: zt_sco214_varid, zc_sco214_varid ! Dissolved CO2-C14
integer :: zt_doc13_varid, zc_doc13_varid ! Dissolved organic carbon-C13
integer :: zt_doc14_varid, zc_doc14_varid ! Dissolved organic carbon-C14
integer :: zt_poc13_varid, zc_poc13_varid ! Particulate organic carbon-C13
integer :: zt_poc14_varid, zc_poc14_varid ! Particulate organic carbon-C14
integer :: zt_phyto13_varid, zc_phyto13_varid ! Phytoplankton concentration-C13
integer :: zt_phyto14_varid, zc_phyto14_varid ! Phytoplankton concentration-C14
integer :: zt_grazer13_varid, zc_grazer13_varid ! Zooplankton concentration-C13
integer :: zt_grazer14_varid, zc_grazer14_varid ! Zooplankton concentration-C14
integer :: zt_calciu13_varid, zc_calciu13_varid ! Calcium carbonate-C13
integer :: zt_calciu14_varid, zc_calciu14_varid ! Calcium carbonate-C14
! AGG
integer :: zt_snos_varid, zc_snos_varid ! Marine snow aggregates per g sea water
integer :: zt_adust_varid, zc_adust_varid ! Aggregated dust
! CFC
integer :: zt_cfc11_varid, zc_cfc11_varid ! CFC-11 : Trichlorofluoromethane
integer :: zt_cfc12_varid, zc_cfc12_varid ! CFC-12 : Dichlorodifluoromethane
integer :: zt_sf6_varid, zc_sf6_varid ! SF6 : Sulfur hexafluoride
! natDIC
integer :: zt_natsco212_varid, zc_natsco212_varid ! Natural dissolved CO2
integer :: zt_natalkali_varid, zc_natalkali_varid ! Natural alkalinity
integer :: zt_natcalciu_varid, zc_natcalciu_varid ! Natural calcium carbonate
! BROMO
integer :: zt_bromo_varid, zc_bromo_varid ! Bromoform
! extNcycle
integer :: zt_nh4_varid, zc_nh4_varid ! Ammonium (NH4+)
integer :: zt_ano2_varid, zc_ano2_varid ! Nitrite (NO2-)
!--- sum of inventory
integer :: totcarb_varid, totphos_varid, totsili_varid, totnitr_varid
integer :: totoxyg_varid
!--- sediment fluxes
integer :: sum_zprorca_varid, sum_zprcaca_varid, sum_zsilpro_varid
integer :: sum_sedfluxo_varid
integer :: sum_expoor_varid, sum_expoca_varid, sum_exposi_varid
! atmosphere-ocean fluxes
integer :: co2flux_varid,so2flux_varid,sn2flux_varid,sn2oflux_varid,snh3flux_varid
integer :: sdmsflux_varid
integer :: sndepnoyflux_varid,sndepnhxflux_varid
! ODZ volume
integer :: ODZvol_varid
!=== Create new or open existing netCDF file
if (.not.append2file_inv(iogrp)) then
!--- file name : fname_inv(iogrp)
if (expcnf.eq.'cesm') then
prefix=trim(runid)//'.blom'//trim(inst_suffix)
sep1='.'
sep2='-'
else
prefix=trim(runid)
sep1='_'
sep2='.'
endif
write(tstamp,'(i4.4,a1,i2.2,a1,i2.2)') &
& date%year,sep2,date%month,sep2,date%day
fname_inv(iogrp) = prefix//sep1//trim(glb_fnametag(iogrp))//sep1// &
& 'i'//sep1//trim(tstamp)//'.nc'
!--- create a new netCDF file
write(io_stdo_bgc,*) 'Create BGC inventory file : ',trim(fname_inv(iogrp))
call nccheck( NF90_CREATE(trim(fname_inv(iogrp)), NF90_CLOBBER, ncid) )
!--- set time information
timeunits=' '
write(timeunits,'(a11,i4.4,a1,i2.2,a1,i2.2,a6)') &
& 'days since ',date0%year,'-',date0%month,'-',date0%day,' 00:00'
!--- Define global attributes
call nccheck(NF90_PUT_ATT(ncid,NF90_GLOBAL,'title','Global inventory for marine bgc') )
call nccheck(NF90_PUT_ATT(ncid,NF90_GLOBAL,'history','Global inventory for marine bgc') )
!--- Define dimensions
if (.not. use_sedbypass) then
call nccheck( NF90_DEF_DIM(ncid, 'npowtra', npowtra, npowtra_dimid) )
call nccheck( NF90_DEF_DIM(ncid, 'nsedtra', nsedtra, nsedtra_dimid) )
endif
if (do_rivinpt) then
call nccheck( NF90_DEF_DIM(ncid, 'nriv', nriv, nriv_dimid) )
endif
call nccheck( NF90_DEF_DIM(ncid, 'time', NF90_UNLIMITED, time_dimid) )
!--- Dimensions for arrays.
!--- The unlimited "time" dimension must come last in the list of dimensions.
if (.not. use_sedbypass) then
zpowtra_dimids = (/ npowtra_dimid, time_dimid /)
zsedtra_dimids = (/ nsedtra_dimid, time_dimid /)
endif
if (do_rivinpt) then
nriv_dimids = (/ nriv_dimid, time_dimid /)
endif
!--- Define variables : time
call nccheck( NF90_DEF_VAR(ncid, 'time', NF90_DOUBLE, time_dimid,time_varid) )
call nccheck( NF90_PUT_ATT(ncid, time_varid, 'units', timeunits) )
call nccheck( NF90_PUT_ATT(ncid, time_varid, 'calendar', calendar) )
call nccheck( NF90_PUT_ATT(ncid, time_varid, 'long_name', 'time') )
if (.not. use_sedbypass) then
!--- aqueous sediment tracers
call nccheck( NF90_DEF_VAR(ncid, 'zsedtotvol', NF90_DOUBLE, time_dimid, &
& zsedtotvol_varid) )
call nccheck( NF90_PUT_ATT(ncid, zsedtotvol_varid, 'long_name', &
& 'Total sediment pore water volume') )
call nccheck( NF90_PUT_ATT(ncid, zsedtotvol_varid, 'units', 'm^3') )
call nccheck( NF90_DEF_VAR(ncid, 'zpowtratot', NF90_DOUBLE, &
& zpowtra_dimids, zpowtratot_varid) )
call nccheck( NF90_PUT_ATT(ncid, zpowtratot_varid, 'long_name', &
& 'Total aqueous sediment tracer') )
call nccheck( NF90_PUT_ATT(ncid, zpowtratot_varid, 'units', 'kmol') )
call nccheck( NF90_DEF_VAR(ncid, 'zpowtratoc', NF90_DOUBLE, &
& zpowtra_dimids, zpowtratoc_varid) )
call nccheck( NF90_PUT_ATT(ncid, zpowtratoc_varid, 'long_name', &
& 'Aqueous sediment concentration') )
call nccheck( NF90_PUT_ATT(ncid, zpowtratoc_varid, 'units', 'kmol/m^3') )
call nccheck( NF90_DEF_VAR(ncid, 'sedfluxo', NF90_DOUBLE, &
& zpowtra_dimids, sum_sedfluxo_varid) )
call nccheck( NF90_PUT_ATT(ncid, sum_sedfluxo_varid, 'long_name', &
& 'Aqueous sediment tracer diffusive fluxes') )
call nccheck( NF90_PUT_ATT(ncid, sum_sedfluxo_varid, 'units', 'kmol/s') )
!--- non-aqueous sediment tracers
call nccheck( NF90_DEF_VAR(ncid, 'zsedlayto', NF90_DOUBLE, &
& zsedtra_dimids, zsedlayto_varid) )
call nccheck( NF90_PUT_ATT(ncid, zsedlayto_varid, 'long_name', &
& 'Sediment layer tracers') )
call nccheck( NF90_PUT_ATT(ncid, zsedlayto_varid, 'units', 'kmol') )
call nccheck( NF90_DEF_VAR(ncid, 'zburial', NF90_DOUBLE, &
& zsedtra_dimids, zburial_varid) )
call nccheck( NF90_PUT_ATT(ncid, zburial_varid, 'long_name', &
& 'Sediment burial tracers') )
call nccheck( NF90_PUT_ATT(ncid, zburial_varid, 'units', 'kmol') )
call nccheck( NF90_DEF_VAR(ncid, 'zsedhplto', NF90_DOUBLE, time_dimid, &
& zsedhplto_varid) )
call nccheck( NF90_PUT_ATT(ncid, zsedhplto_varid, 'long_name', &
& 'Total sediment accumulated hydrogen ions') )
call nccheck( NF90_PUT_ATT(ncid, zsedhplto_varid, 'units', 'kmol') )
endif
if (do_rivinpt) then
call nccheck( NF90_DEF_VAR(ncid, 'rivinput', NF90_DOUBLE, &
& nriv_dimids, sriv_varid) )
call nccheck( NF90_PUT_ATT(ncid, sriv_varid, 'long_name', &
& 'Total riverine tracer fluxes') )
call nccheck( NF90_PUT_ATT(ncid, sriv_varid, 'units', 'kmol(?)') )
endif
!--- Define variables : oceanic tracers
call nccheck( NF90_DEF_VAR(ncid, 'ztotvol', NF90_DOUBLE, time_dimid, &
& ztotvol_varid) )
call nccheck( NF90_PUT_ATT(ncid, ztotvol_varid, 'long_name', &
& 'Total ocean volume') )
call nccheck( NF90_PUT_ATT(ncid, ztotvol_varid, 'units', 'm^3') )
call nccheck( NF90_DEF_VAR(ncid, 'zt_sco212', NF90_DOUBLE, &
& time_dimid, zt_sco212_varid) )
call nccheck( NF90_PUT_ATT(ncid, zt_sco212_varid, 'long_name', &
& 'Total dissolved CO2 tracer') )
call nccheck( NF90_PUT_ATT(ncid, zt_sco212_varid, 'units', 'kmol') )
call nccheck( NF90_DEF_VAR(ncid, 'zc_sco212', NF90_DOUBLE, &
& time_dimid, zc_sco212_varid) )
call nccheck( NF90_PUT_ATT(ncid, zc_sco212_varid, 'long_name', &
& 'Mean dissolved CO2 concentration') )
call nccheck( NF90_PUT_ATT(ncid, zc_sco212_varid, 'units', 'kmol/m^3') )
call nccheck( NF90_DEF_VAR(ncid, 'zt_alkali', NF90_DOUBLE, &
& time_dimid, zt_alkali_varid) )
call nccheck( NF90_PUT_ATT(ncid, zt_alkali_varid, 'long_name', &
& 'Total alkalinity tracer') )
call nccheck( NF90_PUT_ATT(ncid, zt_alkali_varid, 'units', 'kmol') )
call nccheck( NF90_DEF_VAR(ncid, 'zc_alkali', NF90_DOUBLE, &
& time_dimid, zc_alkali_varid) )
call nccheck( NF90_PUT_ATT(ncid, zc_alkali_varid, 'long_name', &
& 'Mean alkalinity concentration') )
call nccheck( NF90_PUT_ATT(ncid, zc_alkali_varid, 'units', 'kmol/m^3') )
call nccheck( NF90_DEF_VAR(ncid, 'zt_alkalisrf', NF90_DOUBLE, &
& time_dimid, zt_alkalisrf_varid) )
call nccheck( NF90_PUT_ATT(ncid, zt_alkalisrf_varid, 'long_name', &
& 'Total surface alkalinity tracer') )
call nccheck( NF90_PUT_ATT(ncid, zt_alkalisrf_varid, 'units', 'kmol') )