-
Notifications
You must be signed in to change notification settings - Fork 0
/
CH4Mod_ELMv1b.F90
3796 lines (3281 loc) · 213 KB
/
CH4Mod_ELMv1b.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 CH4Mod
#include "shr_assert.h"
!-----------------------------------------------------------------------
! !DESCRIPTION:
! Module holding routines to calculate methane fluxes
! The driver averages up to gridcell, weighting by finundated, and checks for balance errors.
! Sources, sinks, "competition" for CH4 & O2, & transport are resolved in ch4_tran.
!
! !USES:
use shr_kind_mod , only : r8 => shr_kind_r8
use shr_infnan_mod , only : nan => shr_infnan_nan, assignment(=)
use shr_log_mod , only : errMsg => shr_log_errMsg
use clm_varpar , only : nlevsoi, ngases, nlevsno, nlevdecomp
use clm_varcon , only : denh2o, denice, tfrz, grav, spval, rgas, grlnd
use clm_varcon , only : catomw, s_con, d_con_w, d_con_g, c_h_inv, kh_theta, kh_tbase
use landunit_varcon , only : istdlak
use clm_time_manager , only : get_step_size, get_nstep
use clm_varctl , only : iulog, use_cn, use_nitrif_denitrif, use_lch4
use abortutils , only : endrun
use decompMod , only : bounds_type
use SharedParamsMod , only : ParamsShareInst
use atm2lndType , only : atm2lnd_type
use CanopyStateType , only : canopystate_type
use CNCarbonFluxType , only : carbonflux_type
use CNCarbonStateType , only : carbonstate_type
use CNNitrogenFluxType , only : nitrogenflux_type
use EnergyFluxType , only : energyflux_type
use LakeStateType , only : lakestate_type
use lnd2atmType , only : lnd2atm_type
use SoilHydrologyType , only : soilhydrology_type
use SoilStateType , only : soilstate_type
use TemperatureType , only : temperature_type
use WaterfluxType , only : waterflux_type
use WaterstateType , only : waterstate_type
use GridcellType , only : grc_pp
use TopounitDataType , only : top_as ! for topounit-level atmospheric state forcing
use LandunitType , only : lun_pp
use ColumnType , only : col_pp
use ColumnDataType , only : col_es, col_ws, col_wf, col_cf, col_nf
use VegetationType , only : veg_pp
use VegetationDataType , only : veg_wf, veg_cs, veg_cf
!
implicit none
save
private
! Non-tunable constants
real(r8) :: rgasm ! J/mol.K; rgas / 1000; will be set below
real(r8), parameter :: rgasLatm = 0.0821_r8 ! L.atm/mol.K
! !PUBLIC MEMBER FUNCTIONS:
public :: readCH4Params
public :: CH4
! !PRIVATE MEMBER FUNCTIONS:
private :: ch4_prod
private :: ch4_oxid
private :: ch4_aere
private :: ch4_ebul
private :: ch4_tran
private :: ch4_annualupdate
private :: get_jwt
type, private :: CH4ParamsType
! ch4 production constants
real(r8) :: q10ch4 ! additional Q10 for methane production ABOVE the soil decomposition temperature relationship
real(r8) :: q10ch4base ! temperature at which the effective f_ch4 actually equals the constant f_ch4
real(r8) :: f_ch4 ! ratio of CH4 production to total C mineralization
real(r8) :: rootlitfrac ! Fraction of soil organic matter associated with roots
real(r8) :: cnscalefactor ! scale factor on CN decomposition for assigning methane flux
real(r8) :: redoxlag ! Number of days to lag in the calculation of finundated_lag
real(r8) :: lake_decomp_fact ! Base decomposition rate (1/s) at 25C
real(r8) :: redoxlag_vertical ! time lag (days) to inhibit production for newly unsaturated layers
real(r8) :: pHmax ! maximum pH for methane production(= 9._r8)
real(r8) :: pHmin ! minimum pH for methane production(= 2.2_r8)
real(r8) :: oxinhib ! inhibition of methane production by oxygen (m^3/mol)
! ch4 oxidation constants
real(r8) :: vmax_ch4_oxid ! oxidation rate constant (= 45.e-6_r8 * 1000._r8 / 3600._r8) [mol/m3-w/s];
real(r8) :: k_m ! Michaelis-Menten oxidation rate constant for CH4 concentration
real(r8) :: q10_ch4oxid ! Q10 oxidation constant
real(r8) :: smp_crit ! Critical soil moisture potential
real(r8) :: k_m_o2 ! Michaelis-Menten oxidation rate constant for O2 concentration
real(r8) :: k_m_unsat ! Michaelis-Menten oxidation rate constant for CH4 concentration
real(r8) :: vmax_oxid_unsat ! (= 45.e-6_r8 * 1000._r8 / 3600._r8 / 10._r8) [mol/m3-w/s]
! ch4 aerenchyma constants
real(r8) :: aereoxid ! fraction of methane flux entering aerenchyma rhizosphere that will be
! oxidized rather than emitted
real(r8) :: scale_factor_aere ! scale factor on the aerenchyma area for sensitivity tests
real(r8) :: nongrassporosratio ! Ratio of root porosity in non-grass to grass, used for aerenchyma transport
real(r8) :: unsat_aere_ratio ! Ratio to multiply upland vegetation aerenchyma porosity by compared to inundated systems (= 0.05_r8 / 0.3_r8)
real(r8) :: porosmin ! minimum aerenchyma porosity (unitless)(= 0.05_r8)
! ch4 ebbulition constants
real(r8) :: vgc_max ! ratio of saturation pressure triggering ebullition
! ch4 transport constants
real(r8) :: satpow ! exponent on watsat for saturated soil solute diffusion
real(r8) :: scale_factor_gasdiff ! For sensitivity tests; convection would allow this to be > 1
real(r8) :: scale_factor_liqdiff ! For sensitivity tests; convection would allow this to be > 1
real(r8) :: capthick ! min thickness before assuming h2osfc is impermeable (mm) (= 100._r8)
! additional constants
real(r8) :: f_sat ! volumetric soil water defining top of water table or where production is allowed (=0.95)
real(r8) :: qflxlagd ! days to lag qflx_surf_lag in the tropics (days) ( = 30._r8)
real(r8) :: highlatfact ! multiple of qflxlagd for high latitudes (= 2._r8)
real(r8) :: q10lakebase ! (K) base temperature for lake CH4 production (= 298._r8)
real(r8) :: atmch4 ! Atmospheric CH4 mixing ratio to prescribe if not provided by the atmospheric model (= 1.7e-6_r8) (mol/mol)
real(r8) :: rob ! ratio of root length to vertical depth ("root obliquity") (= 3._r8)
end type CH4ParamsType
type(CH4ParamsType), private :: CH4ParamsInst
type, public :: ch4_type
real(r8), pointer, private :: ch4_prod_depth_sat_col (:,:) ! col CH4 production rate from methanotrophs (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: ch4_prod_depth_unsat_col (:,:) ! col CH4 production rate from methanotrophs (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: ch4_prod_depth_lake_col (:,:) ! col CH4 production rate from methanotrophs (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: ch4_oxid_depth_sat_col (:,:) ! col CH4 consumption rate via oxidation in each soil layer (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: ch4_oxid_depth_unsat_col (:,:) ! col CH4 consumption rate via oxidation in each soil layer (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: ch4_oxid_depth_lake_col (:,:) ! col CH4 consumption rate via oxidation in each soil layer (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: ch4_aere_depth_sat_col (:,:) ! col CH4 loss rate via aerenchyma in each soil layer (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: ch4_aere_depth_unsat_col (:,:) ! col CH4 loss rate via aerenchyma in each soil layer (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: ch4_tran_depth_sat_col (:,:) ! col CH4 loss rate via transpiration in each soil layer (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: ch4_tran_depth_unsat_col (:,:) ! col CH4 loss rate via transpiration in each soil layer (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: ch4_ebul_depth_sat_col (:,:) ! col CH4 loss rate via ebullition in each soil layer (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: ch4_ebul_depth_unsat_col (:,:) ! col CH4 loss rate via ebullition in each soil layer (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: ch4_ebul_total_sat_col (:) ! col Total col CH4 ebullition (mol/m2/s)
real(r8), pointer, private :: ch4_ebul_total_unsat_col (:) ! col Total col CH4 ebullition (mol/m2/s)
real(r8), pointer, private :: ch4_surf_aere_sat_col (:) ! col CH4 aerenchyma flux to atmosphere (after oxidation) (mol/m2/s)
real(r8), pointer, private :: ch4_surf_aere_unsat_col (:) ! col CH4 aerenchyma flux to atmosphere (after oxidation) (mol/m2/s)
real(r8), pointer, private :: ch4_surf_ebul_sat_col (:) ! col CH4 ebullition flux to atmosphere (after oxidation) (mol/m2/s)
real(r8), pointer, private :: ch4_surf_ebul_unsat_col (:) ! col CH4 ebullition flux to atmosphere (after oxidation) (mol/m2/s)
real(r8), pointer, private :: ch4_surf_ebul_lake_col (:) ! col CH4 ebullition flux to atmosphere (after oxidation) (mol/m2/s)
real(r8), pointer, private :: co2_aere_depth_sat_col (:,:) ! col CO2 loss rate via aerenchyma in each soil layer (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: co2_aere_depth_unsat_col (:,:) ! col CO2 loss rate via aerenchyma in each soil layer (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: o2_oxid_depth_sat_col (:,:) ! col O2 consumption rate via oxidation in each soil layer (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: o2_oxid_depth_unsat_col (:,:) ! col O2 consumption rate via oxidation in each soil layer (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: o2_aere_depth_sat_col (:,:) ! col O2 gain rate via aerenchyma in each soil layer (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: o2_aere_depth_unsat_col (:,:) ! col O2 gain rate via aerenchyma in each soil layer (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: co2_decomp_depth_sat_col (:,:) ! col CO2 production during decomposition in each soil layer (nlevsoi) (mol/m3/s)
real(r8), pointer, private :: co2_decomp_depth_unsat_col (:,:) ! col CO2 production during decomposition in each soil layer (nlevsoi) (mol/m3/s)
real(r8), pointer, private :: co2_oxid_depth_sat_col (:,:) ! col CO2 production rate via oxidation in each soil layer (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: co2_oxid_depth_unsat_col (:,:) ! col CO2 production rate via oxidation in each soil layer (mol/m3/s) (nlevsoi)
real(r8), pointer, private :: conc_o2_lake_col (:,:) ! col O2 conc in each soil layer (mol/m3) (nlevsoi)
real(r8), pointer, private :: conc_ch4_sat_col (:,:) ! col CH4 conc in each soil layer (mol/m3) (nlevsoi)
real(r8), pointer, private :: conc_ch4_unsat_col (:,:) ! col CH4 conc in each soil layer (mol/m3) (nlevsoi)
real(r8), pointer, private :: conc_ch4_lake_col (:,:) ! col CH4 conc in each soil layer (mol/m3) (nlevsoi)
real(r8), pointer, private :: ch4_surf_diff_sat_col (:) ! col CH4 surface flux (mol/m2/s)
real(r8), pointer, private :: ch4_surf_diff_unsat_col (:) ! col CH4 surface flux (mol/m2/s)
real(r8), pointer, private :: ch4_surf_diff_lake_col (:) ! col CH4 surface flux (mol/m2/s)
real(r8), pointer, private :: ch4_dfsat_flux_col (:) ! col CH4 flux to atm due to decreasing fsat (kg C/m^2/s) [+]
real(r8), pointer, private :: zwt_ch4_unsat_col (:) ! col depth of water table for unsaturated fraction (m)
real(r8), pointer, private :: fsat_bef_col (:) ! col fsat from previous timestep
real(r8), pointer, private :: lake_soilc_col (:,:) ! col total soil organic matter found in level (g C / m^3) (nlevsoi)
real(r8), pointer, private :: totcolch4_col (:) ! col total methane found in soil col (g C / m^2)
real(r8), pointer, private :: annsum_counter_col (:) ! col seconds since last annual accumulator turnover
real(r8), pointer, private :: tempavg_somhr_col (:) ! col temporary average SOM heterotrophic resp. (gC/m2/s)
real(r8), pointer, private :: annavg_somhr_col (:) ! col annual average SOM heterotrophic resp. (gC/m2/s)
real(r8), pointer, private :: tempavg_finrw_col (:) ! col respiration-weighted annual average of finundated
real(r8), pointer, private :: annavg_finrw_col (:) ! col respiration-weighted annual average of finundated
real(r8), pointer, private :: sif_col (:) ! col (unitless) ratio applied to sat. prod. to account for seasonal inundation
real(r8), pointer, private :: ch4stress_unsat_col (:,:) ! col Ratio of methane available to the total per-timestep methane sinks (nlevsoi)
real(r8), pointer, private :: ch4stress_sat_col (:,:) ! col Ratio of methane available to the total per-timestep methane sinks (nlevsoi)
real(r8), pointer, private :: qflx_surf_lag_col (:) ! col time-lagged surface runoff (mm H2O /s)
real(r8), pointer, private :: finundated_lag_col (:) ! col time-lagged fractional inundated area
real(r8), pointer, private :: layer_sat_lag_col (:,:) ! col Lagged saturation status of soil layer in the unsaturated zone (1 = sat)
real(r8), pointer, private :: zwt0_col (:) ! col coefficient for determining finundated (m)
real(r8), pointer, private :: f0_col (:) ! col maximum inundated fraction for a gridcell (for methane code)
real(r8), pointer, private :: p3_col (:) ! col coefficient for determining finundated (m)
real(r8), pointer, private :: pH_col (:) ! col pH values for methane production
!
real(r8), pointer, private :: c_atm_grc (:,:) ! grc atmospheric conc of CH4, O2, CO2 (mol/m3)
real(r8), pointer, private :: ch4co2f_grc (:) ! grc CO2 production from CH4 oxidation (g C/m**2/s)
real(r8), pointer, private :: ch4prodg_grc (:) ! grc average CH4 production (g C/m^2/s)
!
real(r8), pointer, public :: finundated_col (:) ! col fractional inundated area (excluding dedicated wetland cols)
real(r8), pointer, public :: o2stress_unsat_col (:,:) ! col Ratio of oxygen available to that demanded by roots, aerobes, & methanotrophs (nlevsoi)
real(r8), pointer, public :: o2stress_sat_col (:,:) ! col Ratio of oxygen available to that demanded by roots, aerobes, & methanotrophs (nlevsoi)
real(r8), pointer, public :: conc_o2_sat_col (:,:) ! col O2 conc in each soil layer (mol/m3) (nlevsoi)
real(r8), pointer, public :: conc_o2_unsat_col (:,:) ! col O2 conc in each soil layer (mol/m3) (nlevsoi)
real(r8), pointer, public :: o2_decomp_depth_sat_col (:,:) ! col O2 consumption during decomposition in each soil layer (nlevsoi) (mol/m3/s)
real(r8), pointer, public :: o2_decomp_depth_unsat_col (:,:) ! col O2 consumption during decomposition in each soil layer (nlevsoi) (mol/m3/s)
real(r8), pointer, public :: ch4_surf_flux_tot_col (:) ! col CH4 surface flux (to atm) (kg C/m**2/s)
real(r8), pointer, public :: grnd_ch4_cond_patch (:) ! patch tracer conductance for boundary layer [m/s]
real(r8), pointer, public :: grnd_ch4_cond_col (:) ! col tracer conductance for boundary layer [m/s]
contains
procedure, public :: Init
procedure, private :: InitAllocate
procedure, private :: InitHistory
procedure, private :: InitCold
procedure, public :: Restart
end type ch4_type
!------------------------------------------------------------------------
contains
!------------------------------------------------------------------------
subroutine Init( this, bounds, cellorg_col )
class(ch4_type) :: this
type(bounds_type), intent(in) :: bounds
real(r8) , intent(in) :: cellorg_col (bounds%begc:, 1:)
call this%InitAllocate (bounds)
if (use_lch4) then
call this%InitHistory (bounds)
call this%InitCold (bounds, cellorg_col)
end if
end subroutine Init
!-----------------------------------------------------------------------
subroutine InitAllocate(this, bounds)
!
! !DESCRIPTION:
! Allocate module variables and data structures
!
! !USES:
use shr_infnan_mod, only: nan => shr_infnan_nan, assignment(=)
use clm_varpar , only: nlevgrnd
!
! !ARGUMENTS:
class(ch4_type) :: this
type(bounds_type), intent(in) :: bounds
!
! !LOCAL VARIABLES:
integer :: begp, endp
integer :: begc, endc
integer :: begg, endg
!---------------------------------------------------------------------
begp = bounds%begp; endp = bounds%endp
begc = bounds%begc; endc = bounds%endc
begg = bounds%begg; endg = bounds%endg
allocate(this%ch4_prod_depth_sat_col (begc:endc,1:nlevgrnd)) ; this%ch4_prod_depth_sat_col (:,:) = nan
allocate(this%ch4_prod_depth_unsat_col (begc:endc,1:nlevgrnd)) ; this%ch4_prod_depth_unsat_col (:,:) = nan
allocate(this%ch4_prod_depth_lake_col (begc:endc,1:nlevgrnd)) ; this%ch4_prod_depth_lake_col (:,:) = nan
allocate(this%ch4_oxid_depth_sat_col (begc:endc,1:nlevgrnd)) ; this%ch4_oxid_depth_sat_col (:,:) = nan
allocate(this%ch4_oxid_depth_unsat_col (begc:endc,1:nlevgrnd)) ; this%ch4_oxid_depth_unsat_col (:,:) = nan
allocate(this%ch4_oxid_depth_lake_col (begc:endc,1:nlevgrnd)) ; this%ch4_oxid_depth_lake_col (:,:) = nan
allocate(this%o2_oxid_depth_sat_col (begc:endc,1:nlevgrnd)) ; this%o2_oxid_depth_sat_col (:,:) = nan
allocate(this%o2_oxid_depth_unsat_col (begc:endc,1:nlevgrnd)) ; this%o2_oxid_depth_unsat_col (:,:) = nan
allocate(this%o2_aere_depth_sat_col (begc:endc,1:nlevgrnd)) ; this%o2_aere_depth_sat_col (:,:) = nan
allocate(this%o2_aere_depth_unsat_col (begc:endc,1:nlevgrnd)) ; this%o2_aere_depth_unsat_col (:,:) = nan
allocate(this%co2_decomp_depth_sat_col (begc:endc,1:nlevgrnd)) ; this%co2_decomp_depth_sat_col (:,:) = nan
allocate(this%co2_decomp_depth_unsat_col (begc:endc,1:nlevgrnd)) ; this%co2_decomp_depth_unsat_col (:,:) = nan
allocate(this%co2_oxid_depth_sat_col (begc:endc,1:nlevgrnd)) ; this%co2_oxid_depth_sat_col (:,:) = nan
allocate(this%co2_oxid_depth_unsat_col (begc:endc,1:nlevgrnd)) ; this%co2_oxid_depth_unsat_col (:,:) = nan
allocate(this%ch4_aere_depth_sat_col (begc:endc,1:nlevgrnd)) ; this%ch4_aere_depth_sat_col (:,:) = nan
allocate(this%ch4_aere_depth_unsat_col (begc:endc,1:nlevgrnd)) ; this%ch4_aere_depth_unsat_col (:,:) = nan
allocate(this%ch4_tran_depth_sat_col (begc:endc,1:nlevgrnd)) ; this%ch4_tran_depth_sat_col (:,:) = nan
allocate(this%ch4_tran_depth_unsat_col (begc:endc,1:nlevgrnd)) ; this%ch4_tran_depth_unsat_col (:,:) = nan
allocate(this%co2_aere_depth_sat_col (begc:endc,1:nlevgrnd)) ; this%co2_aere_depth_sat_col (:,:) = nan
allocate(this%co2_aere_depth_unsat_col (begc:endc,1:nlevgrnd)) ; this%co2_aere_depth_unsat_col (:,:) = nan
allocate(this%ch4_surf_aere_sat_col (begc:endc)) ; this%ch4_surf_aere_sat_col (:) = nan
allocate(this%ch4_surf_aere_unsat_col (begc:endc)) ; this%ch4_surf_aere_unsat_col (:) = nan
allocate(this%ch4_ebul_depth_sat_col (begc:endc,1:nlevgrnd)) ; this%ch4_ebul_depth_sat_col (:,:) = nan
allocate(this%ch4_ebul_depth_unsat_col (begc:endc,1:nlevgrnd)) ; this%ch4_ebul_depth_unsat_col (:,:) = nan
allocate(this%ch4_ebul_total_sat_col (begc:endc)) ; this%ch4_ebul_total_sat_col (:) = nan
allocate(this%ch4_ebul_total_unsat_col (begc:endc)) ; this%ch4_ebul_total_unsat_col (:) = nan
allocate(this%ch4_surf_ebul_sat_col (begc:endc)) ; this%ch4_surf_ebul_sat_col (:) = nan
allocate(this%ch4_surf_ebul_unsat_col (begc:endc)) ; this%ch4_surf_ebul_unsat_col (:) = nan
allocate(this%ch4_surf_ebul_lake_col (begc:endc)) ; this%ch4_surf_ebul_lake_col (:) = nan
allocate(this%conc_ch4_sat_col (begc:endc,1:nlevgrnd)) ; this%conc_ch4_sat_col (:,:) = spval ! detect file input
allocate(this%conc_ch4_unsat_col (begc:endc,1:nlevgrnd)) ; this%conc_ch4_unsat_col (:,:) = spval ! detect file input
allocate(this%conc_ch4_lake_col (begc:endc,1:nlevgrnd)) ; this%conc_ch4_lake_col (:,:) = nan
allocate(this%ch4_surf_diff_sat_col (begc:endc)) ; this%ch4_surf_diff_sat_col (:) = nan
allocate(this%ch4_surf_diff_unsat_col (begc:endc)) ; this%ch4_surf_diff_unsat_col (:) = nan
allocate(this%ch4_surf_diff_lake_col (begc:endc)) ; this%ch4_surf_diff_lake_col (:) = nan
allocate(this%conc_o2_lake_col (begc:endc,1:nlevgrnd)) ; this%conc_o2_lake_col (:,:) = nan
allocate(this%ch4_dfsat_flux_col (begc:endc)) ; this%ch4_dfsat_flux_col (:) = nan
allocate(this%zwt_ch4_unsat_col (begc:endc)) ; this%zwt_ch4_unsat_col (:) = nan
allocate(this%fsat_bef_col (begc:endc)) ; this%fsat_bef_col (:) = nan
allocate(this%lake_soilc_col (begc:endc,1:nlevgrnd)) ; this%lake_soilc_col (:,:) = spval !first time-step
allocate(this%totcolch4_col (begc:endc)) ; this%totcolch4_col (:) = nan
allocate(this%annsum_counter_col (begc:endc)) ; this%annsum_counter_col (:) = nan
allocate(this%tempavg_somhr_col (begc:endc)) ; this%tempavg_somhr_col (:) = nan
allocate(this%annavg_somhr_col (begc:endc)) ; this%annavg_somhr_col (:) = nan
allocate(this%tempavg_finrw_col (begc:endc)) ; this%tempavg_finrw_col (:) = nan
allocate(this%annavg_finrw_col (begc:endc)) ; this%annavg_finrw_col (:) = nan
allocate(this%sif_col (begc:endc)) ; this%sif_col (:) = nan
allocate(this%ch4stress_unsat_col (begc:endc,1:nlevgrnd)) ; this%ch4stress_unsat_col (:,:) = nan
allocate(this%ch4stress_sat_col (begc:endc,1:nlevgrnd)) ; this%ch4stress_sat_col (:,:) = nan
allocate(this%qflx_surf_lag_col (begc:endc)) ; this%qflx_surf_lag_col (:) = nan
allocate(this%finundated_lag_col (begc:endc)) ; this%finundated_lag_col (:) = nan
allocate(this%layer_sat_lag_col (begc:endc,1:nlevgrnd)) ; this%layer_sat_lag_col (:,:) = nan
allocate(this%zwt0_col (begc:endc)) ; this%zwt0_col (:) = nan
allocate(this%f0_col (begc:endc)) ; this%f0_col (:) = nan
allocate(this%p3_col (begc:endc)) ; this%p3_col (:) = nan
allocate(this%pH_col (begc:endc)) ; this%pH_col (:) = nan
allocate(this%ch4_surf_flux_tot_col (begc:endc)) ; this%ch4_surf_flux_tot_col (:) = nan
allocate(this%c_atm_grc (begg:endg,1:ngases)) ; this%c_atm_grc (:,:) = nan
allocate(this%ch4co2f_grc (begg:endg)) ; this%ch4co2f_grc (:) = nan
allocate(this%ch4prodg_grc (begg:endg)) ; this%ch4prodg_grc (:) = nan
allocate(this%finundated_col (begc:endc)) ; this%finundated_col (:) = nan
allocate(this%o2stress_unsat_col (begc:endc,1:nlevgrnd)) ; this%o2stress_unsat_col (:,:) = nan
allocate(this%o2stress_sat_col (begc:endc,1:nlevgrnd)) ; this%o2stress_sat_col (:,:) = nan
allocate(this%conc_o2_sat_col (begc:endc,1:nlevgrnd)) ; this%conc_o2_sat_col (:,:) = nan
allocate(this%conc_o2_unsat_col (begc:endc,1:nlevgrnd)) ; this%conc_o2_unsat_col (:,:) = nan
allocate(this%o2_decomp_depth_sat_col (begc:endc,1:nlevgrnd)) ; this%o2_decomp_depth_sat_col (:,:) = nan
allocate(this%o2_decomp_depth_unsat_col (begc:endc,1:nlevgrnd)) ; this%o2_decomp_depth_unsat_col (:,:) = nan
allocate(this%ch4_surf_flux_tot_col (begc:endc)) ; this%ch4_surf_flux_tot_col (:) = nan
allocate(this%grnd_ch4_cond_patch (begp:endp)) ; this%grnd_ch4_cond_patch(:) = nan
allocate(this%grnd_ch4_cond_col (begc:endc)) ; this%grnd_ch4_cond_col (:) = nan
end subroutine InitAllocate
!-----------------------------------------------------------------------
subroutine InitHistory(this, bounds)
!
! !USES:
use clm_varpar , only : nlevgrnd, nlevdecomp
use clm_varctl , only : hist_wrtch4diag
use histFileMod, only : hist_addfld1d, hist_addfld2d, hist_addfld_decomp
use CH4varcon , only : allowlakeprod
!
! !ARGUMENTS:
class(ch4_type) :: this
type(bounds_type), intent(in) :: bounds
!
! !LOCAL VARIABLES:
character(8) :: vr_suffix
character(10) :: active
integer :: begc,endc
integer :: begg,endg
!---------------------------------------------------------------------
begc = bounds%begc; endc = bounds%endc
begg = bounds%begg; endg = bounds%endg
if (nlevdecomp > 1) then
vr_suffix = "_vr"
else
vr_suffix = ""
endif
if (hist_wrtch4diag) then
active = "active"
else
active = "inactive"
end if
this%finundated_col(begc:endc) = spval
call hist_addfld1d (fname='FINUNDATED', units='unitless', &
avgflag='A', long_name='fractional inundated area of vegetated columns', &
ptr_col=this%finundated_col)
this%finundated_lag_col(begc:endc) = spval
call hist_addfld1d (fname='FINUNDATED_LAG', units='unitless', &
avgflag='A', long_name='time-lagged inundated fraction of vegetated columns', &
ptr_col=this%finundated_lag_col)
this%ch4_surf_diff_sat_col(begc:endc) = spval
call hist_addfld1d (fname='CH4_SURF_DIFF_SAT', units='mol/m2/s', &
avgflag='A', long_name='diffusive surface CH4 flux for inundated / lake area; (+ to atm)', &
ptr_col=this%ch4_surf_diff_sat_col)
this%ch4_surf_diff_unsat_col(begc:endc) = spval
call hist_addfld1d (fname='CH4_SURF_DIFF_UNSAT', units='mol/m2/s', &
avgflag='A', long_name='diffusive surface CH4 flux for non-inundated area; (+ to atm)', &
ptr_col=this%ch4_surf_diff_unsat_col)
this%ch4_ebul_total_sat_col(begc:endc) = spval
call hist_addfld1d (fname='CH4_EBUL_TOTAL_SAT', units='mol/m2/s', &
avgflag='A', long_name='ebullition surface CH4 flux; (+ to atm)', &
ptr_col=this%ch4_ebul_total_sat_col, default='inactive')
this%ch4_ebul_total_unsat_col(begc:endc) = spval
call hist_addfld1d (fname='CH4_EBUL_TOTAL_UNSAT', units='mol/m2/s', &
avgflag='A', long_name='ebullition surface CH4 flux; (+ to atm)', &
ptr_col=this%ch4_ebul_total_unsat_col, default='inactive')
this%ch4_surf_ebul_sat_col(begc:endc) = spval
call hist_addfld1d (fname='CH4_SURF_EBUL_SAT', units='mol/m2/s', &
avgflag='A', long_name='ebullition surface CH4 flux for inundated / lake area; (+ to atm)', &
ptr_col=this%ch4_surf_ebul_sat_col)
this%ch4_surf_ebul_unsat_col(begc:endc) = spval
call hist_addfld1d (fname='CH4_SURF_EBUL_UNSAT', units='mol/m2/s', &
avgflag='A', long_name='ebullition surface CH4 flux for non-inundated area; (+ to atm)', &
ptr_col=this%ch4_surf_ebul_unsat_col)
this%ch4_surf_aere_sat_col(begc:endc) = spval
call hist_addfld1d (fname='CH4_SURF_AERE_SAT', units='mol/m2/s', &
avgflag='A', long_name='aerenchyma surface CH4 flux for inundated area; (+ to atm)', &
ptr_col=this%ch4_surf_aere_sat_col)
this%ch4_surf_aere_unsat_col(begc:endc) = spval
call hist_addfld1d (fname='CH4_SURF_AERE_UNSAT', units='mol/m2/s', &
avgflag='A', long_name='aerenchyma surface CH4 flux for non-inundated area; (+ to atm)', &
ptr_col=this%ch4_surf_aere_unsat_col)
this%totcolch4_col(begc:endc) = spval
call hist_addfld1d (fname='TOTCOLCH4', units='gC/m2', &
avgflag='A', long_name='total belowground CH4, (0 for non-lake special landunits)', &
ptr_col=this%totcolch4_col)
this%conc_ch4_sat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CONC_CH4_SAT', units='mol/m3', type2d='levgrnd', &
avgflag='A', long_name='CH4 soil Concentration for inundated / lake area', &
ptr_col=this%conc_ch4_sat_col)
this%conc_ch4_unsat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CONC_CH4_UNSAT', units='mol/m3', type2d='levgrnd', &
avgflag='A', long_name='CH4 soil Concentration for non-inundated area', &
ptr_col=this%conc_ch4_unsat_col)
if (hist_wrtch4diag) then
this%ch4_prod_depth_sat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CH4_PROD_DEPTH_SAT', units='mol/m3/s', type2d='levgrnd', &
avgflag='A', long_name='CH4 soil production for inundated / lake area', &
ptr_col=this%ch4_prod_depth_sat_col)
end if
if (hist_wrtch4diag) then
this%ch4_prod_depth_unsat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CH4_PROD_DEPTH_UNSAT', units='mol/m3/s', type2d='levgrnd', &
avgflag='A', long_name='CH4 soil production for non-inundated area', &
ptr_col=this%ch4_prod_depth_unsat_col)
end if
if (hist_wrtch4diag) then
this%ch4_oxid_depth_sat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CH4_OXID_DEPTH_SAT', units='mol/m3/s', type2d='levgrnd', &
avgflag='A', long_name='CH4 soil oxidation for inundated / lake area', &
ptr_col=this%ch4_oxid_depth_sat_col)
end if
if (hist_wrtch4diag) then
this%ch4_oxid_depth_unsat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CH4_OXID_DEPTH_UNSAT', units='mol/m3/s', type2d='levgrnd', &
avgflag='A', long_name='CH4 soil oxidation for non-inundated area', &
ptr_col=this%ch4_oxid_depth_unsat_col)
end if
if (hist_wrtch4diag) then
this%ch4_aere_depth_sat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CH4_AERE_DEPTH_SAT', units='mol/m3/s', type2d='levgrnd', &
avgflag='A', long_name='CH4 soil aerenchyma loss for inundated / lake area '// &
' (including transpiration flux if activated)', &
ptr_col=this%ch4_aere_depth_sat_col)
end if
if (hist_wrtch4diag) then
this%ch4_aere_depth_unsat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CH4_AERE_DEPTH_UNSAT', units='mol/m3/s', type2d='levgrnd', &
avgflag='A', long_name='CH4 soil aerenchyma loss for non-inundated area '// &
' (including transpiration flux if activated)', &
ptr_col=this%ch4_aere_depth_unsat_col)
end if
if (hist_wrtch4diag) then
this%o2_aere_depth_sat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='O2_AERE_DEPTH_SAT', units='mol/m3/s', type2d='levgrnd', &
avgflag='A', long_name='O2 aerenchyma diffusion into soil for inundated / lake area', &
ptr_col=this%o2_aere_depth_sat_col)
end if
if (hist_wrtch4diag) then
this%o2_aere_depth_unsat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='O2_AERE_DEPTH_UNSAT', units='mol/m3/s', type2d='levgrnd', &
avgflag='A', long_name='O2 aerenchyma diffusion into soil for non-inundated area', &
ptr_col=this%o2_aere_depth_unsat_col)
end if
if (hist_wrtch4diag) then
call hist_addfld2d (fname='O2_DECOMP_DEPTH_SAT', units='mol/m3/s', type2d='levgrnd', &
avgflag='A', long_name='O2 consumption from HR and AR for inundated / lake area', &
ptr_col=this%o2_decomp_depth_sat_col)
end if
this%o2_decomp_depth_unsat_col(begc:endc,1:nlevgrnd) = spval
if (hist_wrtch4diag) then
this%o2_decomp_depth_unsat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='O2_DECOMP_DEPTH_UNSAT', units='mol/m3/s', type2d='levgrnd', &
avgflag='A', long_name='O2 consumption from HR and AR for non-inundated area', &
ptr_col=this%o2_decomp_depth_unsat_col)
else
call hist_addfld2d (fname='o2_decomp_depth_unsat', units='mol/m3/2', type2d='levgrnd', &
avgflag='A', long_name='o2_decomp_depth_unsat', &
ptr_col=this%o2_decomp_depth_unsat_col)
end if
if (hist_wrtch4diag) then
this%ch4_tran_depth_sat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CH4_TRAN_DEPTH_SAT', units='mol/m3/s', type2d='levgrnd', &
avgflag='A', long_name='CH4 soil loss from transpiration for inundated / lake area', &
ptr_col=this%ch4_tran_depth_sat_col)
end if
if (hist_wrtch4diag) then
this%ch4_tran_depth_unsat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CH4_TRAN_DEPTH_UNSAT', units='mol/m3/s', type2d='levgrnd', &
avgflag='A', long_name='CH4 soil loss from transpiration for non-inundated area', &
ptr_col=this%ch4_tran_depth_unsat_col)
end if
if (hist_wrtch4diag) then
this%ch4_ebul_depth_sat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CH4_EBUL_DEPTH_SAT', units='mol/m3/s', type2d='levgrnd', &
avgflag='A', long_name='CH4 soil ebullition for inundated / lake area', &
ptr_col=this%ch4_ebul_depth_sat_col)
end if
if (hist_wrtch4diag) then
this%ch4_ebul_depth_unsat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CH4_EBUL_DEPTH_UNSAT', units='mol/m3/s', type2d='levgrnd', &
avgflag='A', long_name='CH4 soil ebullition for non-inundated area', &
ptr_col=this%ch4_ebul_depth_unsat_col)
end if
if (hist_wrtch4diag) then
this%o2stress_sat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='O2STRESS_SAT', units='unitless', type2d='levgrnd', &
avgflag='A', long_name='Ratio of oxygen available to demanded for non-inundated area', &
ptr_col=this%o2stress_sat_col)
end if
if (hist_wrtch4diag) then
this%o2stress_unsat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='O2STRESS_UNSAT', units='unitless', type2d='levgrnd', &
avgflag='A', long_name='Ratio of oxygen available to demanded for inundated / lake area', &
ptr_col=this%o2stress_unsat_col)
end if
if (hist_wrtch4diag) then
this%ch4stress_unsat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CH4STRESS_UNSAT', units='unitless', type2d='levgrnd', &
avgflag='A', long_name='Ratio of methane available to total potential sink for inundated / lake area', &
ptr_col=this%ch4stress_unsat_col)
end if
if (hist_wrtch4diag) then
this%ch4stress_sat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CH4STRESS_SAT', units='unitless', type2d='levgrnd', &
avgflag='A', long_name='Ratio of methane available to total potential sink for non-inundated area', &
ptr_col=this%ch4stress_sat_col)
end if
if (hist_wrtch4diag .and. allowlakeprod) then
this%ch4_prod_depth_sat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CH4_PROD_DEPTH_LAKE', units='mol/m3/s', type2d='levgrnd', &
avgflag='A', long_name='CH4 production in each soil layer, lake col. only', &
ptr_col=this%ch4_prod_depth_sat_col)
end if
if (hist_wrtch4diag .and. allowlakeprod) then
this%conc_ch4_sat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CONC_CH4_LAKE', units='mol/m3', type2d='levgrnd', &
avgflag='A', long_name='CH4 Concentration each soil layer, lake col. only', &
ptr_col=this%conc_ch4_sat_col)
end if
if (hist_wrtch4diag .and. allowlakeprod) then
this%conc_o2_sat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CONC_O2_LAKE', units='mol/m3', type2d='levgrnd', &
avgflag='A', long_name='O2 Concentration each soil layer, lake col. only', &
ptr_col=this%conc_o2_sat_col)
end if
if (hist_wrtch4diag .and. allowlakeprod) then
this%ch4_surf_diff_sat_col(begc:endc) = spval
call hist_addfld1d (fname='CH4_SURF_DIFF_LAKE', units='mol/m2/s', &
avgflag='A', long_name='diffusive surface CH4 flux, lake col. only (+ to atm)', &
ptr_col=this%ch4_surf_diff_sat_col)
end if
if (hist_wrtch4diag .and. allowlakeprod) then
this%ch4_surf_ebul_sat_col(begc:endc) = spval
call hist_addfld1d (fname='CH4_SURF_EBUL_LAKE', units='mol/m2/s', &
avgflag='A', long_name='ebullition surface CH4 flux, lake col. only (+ to atm)', &
ptr_col=this%ch4_surf_ebul_sat_col)
end if
if (hist_wrtch4diag .and. allowlakeprod) then
this%ch4_oxid_depth_sat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CH4_OXID_DEPTH_LAKE', units='mol/m2/s', type2d='levgrnd', &
avgflag='A', long_name='CH4 oxidation in each soil layer, lake col. only', &
ptr_col=this%ch4_oxid_depth_sat_col)
end if
if (hist_wrtch4diag) then
this%layer_sat_lag_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='LAYER_SAT_LAG', units='unitless', type2d='levgrnd', &
avgflag='A', long_name='lagged saturation status of layer in unsat. zone', &
ptr_col=this%layer_sat_lag_col)
end if
if (hist_wrtch4diag) then
this%annavg_finrw_col(begc:endc) = spval
call hist_addfld1d (fname='ANNAVG_FINRW', units='unitless', &
avgflag='A', long_name='annual average respiration-weighted FINUNDATED', &
ptr_col=this%annavg_finrw_col)
end if
if (hist_wrtch4diag) then
this%sif_col(begc:endc) = spval
call hist_addfld1d (fname='SIF', units='unitless', &
avgflag='A', long_name='seasonal inundation factor calculated for sat. CH4 prod. (non-lake)', &
ptr_col=this%sif_col)
end if
this%conc_o2_sat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CONC_O2_SAT', units='mol/m3', type2d='levgrnd', &
avgflag='A', long_name='O2 soil Concentration for inundated / lake area', &
ptr_col=this%conc_o2_sat_col)
this%conc_o2_unsat_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='CONC_O2_UNSAT', units='mol/m3', type2d='levgrnd', &
avgflag='A', long_name='O2 soil Concentration for non-inundated area', &
ptr_col=this%conc_o2_unsat_col)
this%ch4co2f_grc(begg:endg) = spval
call hist_addfld1d (fname='FCH4TOCO2', units='gC/m2/s', &
avgflag='A', long_name='Gridcell oxidation of CH4 to CO2', &
ptr_lnd=this%ch4co2f_grc)
this%ch4prodg_grc(begg:endg) = spval
call hist_addfld1d (fname='CH4PROD', units='gC/m2/s', &
avgflag='A', long_name='Gridcell total production of CH4', &
ptr_lnd=this%ch4prodg_grc)
this%ch4_dfsat_flux_col(begc:endc) = spval
call hist_addfld1d (fname='FCH4_DFSAT', units='kgC/m2/s', &
avgflag='A', long_name='CH4 additional flux due to changing fsat, vegetated landunits only', &
ptr_col=this%ch4_dfsat_flux_col)
this%zwt_ch4_unsat_col(begc:endc) = spval
call hist_addfld1d (fname='ZWT_CH4_UNSAT', units='m', &
avgflag='A', long_name='depth of water table for methane production used in non-inundated area', &
ptr_col=this%zwt_ch4_unsat_col)
this%qflx_surf_lag_col(begc:endc) = spval
call hist_addfld1d (fname='QOVER_LAG', units='mm/s', &
avgflag='A', long_name='time-lagged surface runoff for soil columns', &
ptr_col=this%qflx_surf_lag_col)
if (allowlakeprod) then
this%lake_soilc_col(begc:endc,1:nlevgrnd) = spval
call hist_addfld2d (fname='LAKE_SOILC', units='gC/m3', type2d='levgrnd', &
avgflag='A', long_name='Soil carbon under lakes', &
ptr_col=this%lake_soilc_col)
end if
this%grnd_ch4_cond_col(begc:endc) = spval
call hist_addfld1d (fname='WTGQ', units='m/s', &
avgflag='A', long_name='surface tracer conductance', &
ptr_col=this%grnd_ch4_cond_col)
end subroutine InitHistory
!-----------------------------------------------------------------------
subroutine InitCold(this, bounds, cellorg_col)
!
! !DESCRIPTION:
! - Sets cold start values for time varying values.
! Initializes the following time varying variables:
! conc_ch4_sat, conc_ch4_unsat, conc_o2_sat, conc_o2_unsat,
! lake_soilc, o2stress, finunduated
! - Sets variables for ch4 code that will not be input
! from restart/inic file.
! - Sets values for inactive CH4 columns to spval so that they will
! not be averaged in history file.
!
! !USES:
use shr_kind_mod , only : r8 => shr_kind_r8
use clm_varpar , only : nlevsoi, nlevgrnd, nlevdecomp
use landunit_varcon , only : istsoil, istdlak, istcrop
use clm_varctl , only : iulog, fsurdat
use CH4varcon , only : allowlakeprod, usephfact, fin_use_fsat
use spmdMod , only : masterproc
use fileutils , only : getfil
use ncdio_pio
!
! !ARGUMENTS:
class(ch4_type) :: this
type(bounds_type) , intent(in) :: bounds
real(r8) , intent(in) :: cellorg_col (bounds%begc:, 1:)
!
! !LOCAL VARIABLES:
integer :: j ,g, l,c,p ! indices
type(file_desc_t) :: ncid ! netcdf id
real(r8) ,pointer :: zwt0_in (:) ! read in - zwt0
real(r8) ,pointer :: f0_in (:) ! read in - f0
real(r8) ,pointer :: p3_in (:) ! read in - p3
real(r8) ,pointer :: pH_in (:) ! read in - pH
logical :: readvar
character(len=256) :: locfn
!-----------------------------------------------------------------------
SHR_ASSERT_ALL((ubound(cellorg_col) == (/bounds%endc, nlevgrnd/)), errMsg(__FILE__, __LINE__))
!----------------------------------------
! Initialize time constant variables
!----------------------------------------
allocate(zwt0_in(bounds%begg:bounds%endg))
allocate(f0_in(bounds%begg:bounds%endg))
allocate(p3_in(bounds%begg:bounds%endg))
if (usephfact) allocate(ph_in(bounds%begg:bounds%endg))
! Methane code parameters for finundated
if (.not. fin_use_fsat) then
call getfil (fsurdat, locfn, 0)
call ncd_pio_openfile (ncid, locfn, 0)
call ncd_io(ncid=ncid, varname='ZWT0', flag='read', data=zwt0_in, dim1name=grlnd, readvar=readvar)
if (.not. readvar) then
call endrun(msg=' ERROR: Running with CH4 Model but ZWT0 not on surfdata file'//&
errMsg(__FILE__, __LINE__))
end if
call ncd_io(ncid=ncid, varname='F0', flag='read', data=f0_in, dim1name=grlnd, readvar=readvar)
if (.not. readvar) then
call endrun(msg=' ERROR: Running with CH4 Model but F0 not on surfdata file'//&
errMsg(__FILE__, __LINE__))
end if
call ncd_io(ncid=ncid, varname='P3', flag='read', data=p3_in, dim1name=grlnd, readvar=readvar)
if (.not. readvar) then
call endrun(msg=' ERROR: Running with CH4 Model but P3 not on surfdata file'//&
errMsg(__FILE__, __LINE__))
end if
end if
! pH factor for methane model
if (usephfact) then
call ncd_io(ncid=ncid, varname='PH', flag='read', data=ph_in, dim1name=grlnd, readvar=readvar)
if (.not. readvar) then
call endrun(msg=' ERROR: CH4 pH production factor activated in ch4par_in'//&
'but pH is not on surfdata file'//errMsg(__FILE__, __LINE__))
end if
end if
do c = bounds%begc, bounds%endc
g = col_pp%gridcell(c)
if (.not. fin_use_fsat) then
this%zwt0_col(c) = zwt0_in(g)
this%f0_col(c) = f0_in(g)
this%p3_col(c) = p3_in(g)
end if
if (usephfact) this%pH_col(c) = pH_in(g)
end do
deallocate(zwt0_in, f0_in, p3_in)
if (usephfact) deallocate(pH_in)
!----------------------------------------
! Initialize time varying variables
!----------------------------------------
if ( masterproc ) write (iulog,*) 'Setting initial data to non-spun up values for CH4 Mod'
do c = bounds%begc,bounds%endc
! To detect first time-step
this%fsat_bef_col (c) = spval
this%annsum_counter_col (c) = spval
this%totcolch4_col (c) = spval
! To detect first year
this%annavg_somhr_col(c) = spval
this%annavg_finrw_col(c) = spval
! To detect file input
this%qflx_surf_lag_col (c) = spval
this%finundated_lag_col (c) = spval
this%layer_sat_lag_col (c,:) = spval
this%conc_ch4_sat_col (c,:) = spval
this%conc_ch4_unsat_col (c,:) = spval
this%conc_o2_sat_col (c,:) = spval
this%conc_o2_unsat_col (c,:) = spval
this%o2stress_sat_col (c,:) = spval
this%o2stress_unsat_col (c,:) = spval
this%ch4stress_sat_col (c,:) = spval
this%ch4stress_unsat_col(c,:) = spval
this%lake_soilc_col (c,:) = spval
! To detect first time-step for denitrification code
this%o2_decomp_depth_unsat_col(c,:)= spval
l = col_pp%landunit(c)
if (lun_pp%itype(l) == istsoil .or. lun_pp%itype(l) == istcrop) then
this%conc_ch4_sat_col (c,1:nlevsoi) = 0._r8
this%conc_ch4_unsat_col (c,1:nlevsoi) = 0._r8
this%conc_o2_sat_col (c,1:nlevsoi) = 0._r8
this%conc_o2_unsat_col (c,1:nlevsoi) = 0._r8
this%o2stress_sat_col (c,1:nlevsoi) = 1._r8
this%o2stress_unsat_col (c,1:nlevsoi) = 1._r8
this%layer_sat_lag_col (c,1:nlevsoi) = 1._r8
this%qflx_surf_lag_col (c) = 0._r8
this%finundated_lag_col (c) = 0._r8
this%finundated_col(c) = 0._r8
! finundated will be used to calculate soil decomposition if anoxia is used
! Note that finundated will be overwritten with this%fsat_bef_col upon reading
! a restart file - either in a continuation, branch or startup spun-up case
else if (lun_pp%itype(l) == istdlak) then
this%conc_ch4_sat_col(c,1:nlevsoi) = 0._r8
this%conc_o2_sat_col (c,1:nlevsoi) = 0._r8
this%lake_soilc_col (c,1:nlevsoi) = 580._r8 * cellorg_col(c,1:nlevsoi)
end if
! Set values for all columns equal below nlevsoi
this%conc_ch4_sat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%conc_ch4_unsat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%conc_o2_sat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%conc_o2_unsat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%lake_soilc_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%o2stress_sat_col (c,nlevsoi+1:nlevgrnd) = 1._r8
this%o2stress_unsat_col (c,nlevsoi+1:nlevgrnd) = 1._r8
this%layer_sat_lag_col (c,nlevsoi+1:nlevgrnd) = 1._r8
this%ch4_prod_depth_sat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%ch4_prod_depth_unsat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%ch4_prod_depth_lake_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%ch4_oxid_depth_sat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%ch4_oxid_depth_unsat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%ch4_oxid_depth_lake_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%o2_oxid_depth_sat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%o2_oxid_depth_unsat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%o2_decomp_depth_sat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%o2_decomp_depth_unsat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%o2_aere_depth_sat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%o2_aere_depth_unsat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%co2_decomp_depth_sat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%co2_decomp_depth_unsat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%co2_oxid_depth_sat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%co2_oxid_depth_unsat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%ch4_aere_depth_sat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%ch4_aere_depth_unsat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%ch4_tran_depth_sat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%ch4_tran_depth_unsat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%co2_aere_depth_sat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%co2_aere_depth_unsat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%ch4_ebul_depth_sat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%ch4_ebul_depth_unsat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%conc_ch4_lake_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%conc_o2_lake_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%ch4stress_unsat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
this%ch4stress_sat_col (c,nlevsoi+1:nlevgrnd) = 0._r8
if (lun_pp%itype(l) == istsoil .or. lun_pp%itype(l) == istcrop) then
this%conc_ch4_lake_col (c,:) = spval
this%conc_o2_lake_col (c,:) = spval
this%ch4_surf_diff_lake_col (c) = spval
this%ch4_surf_ebul_lake_col (c) = spval
this%ch4_prod_depth_lake_col (c,:) = spval
this%ch4_oxid_depth_lake_col (c,:) = spval
else if (lun_pp%itype(l) == istdlak .and. allowlakeprod) then
this%ch4_prod_depth_unsat_col (c,:) = spval
this%ch4_oxid_depth_unsat_col (c,:) = spval
this%o2_oxid_depth_unsat_col (c,:) = spval
this%o2_decomp_depth_unsat_col (c,:) = spval
this%o2_aere_depth_unsat_col (c,:) = spval
this%co2_decomp_depth_unsat_col (c,:) = spval
this%co2_oxid_depth_unsat_col (c,:) = spval
this%ch4_aere_depth_unsat_col (c,:) = spval
this%ch4_tran_depth_unsat_col (c,:) = spval
this%co2_aere_depth_unsat_col (c,:) = spval
this%ch4_surf_aere_unsat_col (c) = spval
this%ch4_ebul_depth_unsat_col (c,:) = spval
this%ch4_ebul_total_unsat_col (c) = spval
this%ch4_surf_ebul_unsat_col (c) = spval
this%ch4_surf_diff_unsat_col (c) = spval
this%ch4_dfsat_flux_col (c) = spval
this%zwt_ch4_unsat_col (c) = spval
this%sif_col (c) = spval
this%o2stress_unsat_col (c,:) = spval
this%ch4stress_unsat_col (c,:) = spval
this%finundated_col (c) = spval
else ! Inactive CH4 columns
this%ch4_prod_depth_sat_col (c,:) = spval
this%ch4_prod_depth_unsat_col (c,:) = spval
this%ch4_prod_depth_lake_col (c,:) = spval
this%ch4_oxid_depth_sat_col (c,:) = spval
this%ch4_oxid_depth_unsat_col (c,:) = spval
this%ch4_oxid_depth_lake_col (c,:) = spval
this%o2_oxid_depth_sat_col (c,:) = spval
this%o2_oxid_depth_unsat_col (c,:) = spval
this%o2_decomp_depth_sat_col (c,:) = spval
this%o2_decomp_depth_unsat_col (c,:) = spval
this%o2_aere_depth_sat_col (c,:) = spval
this%o2_aere_depth_unsat_col (c,:) = spval
this%co2_decomp_depth_sat_col (c,:) = spval
this%co2_decomp_depth_unsat_col (c,:) = spval
this%co2_oxid_depth_sat_col (c,:) = spval
this%co2_oxid_depth_unsat_col (c,:) = spval
this%ch4_aere_depth_sat_col (c,:) = spval
this%ch4_aere_depth_unsat_col (c,:) = spval
this%ch4_tran_depth_sat_col (c,:) = spval
this%ch4_tran_depth_unsat_col (c,:) = spval
this%co2_aere_depth_sat_col (c,:) = spval
this%co2_aere_depth_unsat_col (c,:) = spval
this%ch4_surf_aere_sat_col (c) = spval
this%ch4_surf_aere_unsat_col (c) = spval
this%ch4_ebul_depth_sat_col (c,:) = spval
this%ch4_ebul_depth_unsat_col (c,:) = spval
this%ch4_ebul_total_sat_col (c) = spval
this%ch4_ebul_total_unsat_col (c) = spval
this%ch4_surf_ebul_sat_col (c) = spval
this%ch4_surf_ebul_unsat_col (c) = spval
this%ch4_surf_ebul_lake_col (c) = spval
this%ch4_surf_diff_sat_col (c) = spval
this%ch4_surf_diff_unsat_col (c) = spval
this%ch4_surf_diff_lake_col (c) = spval
this%ch4_dfsat_flux_col (c) = spval
this%zwt_ch4_unsat_col (c) = spval
this%conc_ch4_lake_col (c,:) = spval
this%conc_o2_lake_col (c,:) = spval
this%sif_col (c) = spval
this%o2stress_unsat_col (c,:) = spval
this%o2stress_sat_col (c,:) = spval
this%ch4stress_unsat_col (c,:) = spval
this%ch4stress_sat_col (c,:) = spval
this%finundated_col (c) = spval
this%grnd_ch4_cond_col (c) = spval
! totcolch4 Set to zero for inactive columns so that this can be used
! as an appropriate area-weighted gridcell average soil methane content.
this%totcolch4_col (c) = 0._r8
end if
end do
end subroutine InitCold
!-----------------------------------------------------------------------
subroutine Restart( this, bounds, ncid, flag )
!
! !DESCRIPTION:
! Read/Write biogeophysics information to/from restart file.
!
! !USES:
use ncdio_pio , only : ncd_double
use pio , only : file_desc_t
use decompMod , only : bounds_type
use restUtilMod
!
! !ARGUMENTS:
class(ch4_type) :: this
type(bounds_type), intent(in) :: bounds
type(file_desc_t), intent(inout) :: ncid ! netcdf id
character(len=*), intent(in) :: flag ! 'read' or 'write'
!
! !LOCAL VARIABLES:
logical :: readvar ! determine if variable is on initial file
!-----------------------------------------------------------------------
call restartvar(ncid=ncid, flag=flag, varname='CONC_O2_SAT', xtype=ncd_double, &
dim1name='column', dim2name='levgrnd', switchdim=.true., &
long_name='oxygen soil concentration', units='mol/m^3', &
readvar=readvar, interpinic_flag='interp', data=this%conc_o2_sat_col)
call restartvar(ncid=ncid, flag=flag, varname='CONC_O2_UNSAT', xtype=ncd_double, &
dim1name='column', dim2name='levgrnd', switchdim=.true., &
long_name='oxygen soil concentration', units='mol/m^3', &
readvar=readvar, interpinic_flag='interp', data=this%conc_o2_unsat_col)
call restartvar(ncid=ncid, flag=flag, varname='O2STRESS_SAT', xtype=ncd_double, &
dim1name='column', dim2name='levgrnd', switchdim=.true., &
long_name='oxygen stress fraction', units='', &
readvar=readvar, interpinic_flag='interp', data=this%o2stress_sat_col)
call restartvar(ncid=ncid, flag=flag, varname='O2STRESS_UNSAT', xtype=ncd_double, &
dim1name='column', dim2name='levgrnd', switchdim=.true., &
long_name='oxygen stress fraction', units='', &
readvar=readvar, interpinic_flag='interp', data=this%o2stress_unsat_col)
call restartvar(ncid=ncid, flag=flag, varname='O2_DECOMP_DEPTH_SAT', xtype=ncd_double, &
dim1name='column', dim2name='levgrnd', switchdim=.true., &
long_name='O2 consumption during decomposition', units='mol/m3/s', &
readvar=readvar, interpinic_flag='interp', data=this%o2_decomp_depth_sat_col)
call restartvar(ncid=ncid, flag=flag, varname='O2_DECOMP_DEPTH_UNSAT', xtype=ncd_double, &
dim1name='column', dim2name='levgrnd', switchdim=.true., &
long_name='O2 consumption during decomposition', units='mol/m3/s', &
readvar=readvar, interpinic_flag='interp', data=this%o2_decomp_depth_unsat_col)
call restartvar(ncid=ncid, flag=flag, varname='CONC_CH4_SAT', xtype=ncd_double, &