-
Notifications
You must be signed in to change notification settings - Fork 317
/
WaterStateType.F90
1152 lines (995 loc) · 57.6 KB
/
WaterStateType.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 WaterstateType
#include "shr_assert.h"
!------------------------------------------------------------------------------
! !DESCRIPTION:
! Module variables for hydrology
!
! !USES:
use shr_kind_mod , only : r8 => shr_kind_r8
use shr_log_mod , only : errMsg => shr_log_errMsg
use decompMod , only : bounds_type
use clm_varctl , only : use_vancouver, use_mexicocity, use_cn, iulog, use_luna
use clm_varctl , only : use_fates_planthydro
use clm_varpar , only : nlevgrnd, nlevurb, nlevsno
use clm_varcon , only : spval
use LandunitType , only : lun
use ColumnType , only : col
!
implicit none
save
private
!
! !PUBLIC TYPES:
type, public :: waterstate_type
real(r8), pointer :: snow_depth_col (:) ! col snow height of snow covered area (m)
real(r8), pointer :: snow_persistence_col (:) ! col length of time that ground has had non-zero snow thickness (sec)
real(r8), pointer :: snowdp_col (:) ! col area-averaged snow height (m)
real(r8), pointer :: snowice_col (:) ! col average snow ice lens
real(r8), pointer :: snowliq_col (:) ! col average snow liquid water
real(r8), pointer :: int_snow_col (:) ! col integrated snowfall (mm H2O)
real(r8), pointer :: snow_layer_unity_col (:,:) ! value 1 for each snow layer, used for history diagnostics
real(r8), pointer :: bw_col (:,:) ! col partial density of water in the snow pack (ice + liquid) [kg/m3]
real(r8), pointer :: h2osno_col (:) ! col snow water (mm H2O)
real(r8), pointer :: h2osno_old_col (:) ! col snow mass for previous time step (kg/m2) (new)
real(r8), pointer :: h2osoi_liq_col (:,:) ! col liquid water (kg/m2) (new) (-nlevsno+1:nlevgrnd)
real(r8), pointer :: h2osoi_ice_col (:,:) ! col ice lens (kg/m2) (new) (-nlevsno+1:nlevgrnd)
real(r8), pointer :: h2osoi_liq_tot_col (:) ! vertically summed col liquid water (kg/m2) (new) (-nlevsno+1:nlevgrnd)
real(r8), pointer :: h2osoi_ice_tot_col (:) ! vertically summed col ice lens (kg/m2) (new) (-nlevsno+1:nlevgrnd)
real(r8), pointer :: h2osoi_liqice_10cm_col (:) ! col liquid water + ice lens in top 10cm of soil (kg/m2)
real(r8), pointer :: h2osoi_vol_col (:,:) ! col volumetric soil water (0<=h2osoi_vol<=watsat) [m3/m3] (nlevgrnd)
real(r8), pointer :: h2osoi_vol_prs_grc (:,:) ! grc volumetric soil water prescribed (0<=h2osoi_vol<=watsat) [m3/m3] (nlevgrnd)
real(r8), pointer :: air_vol_col (:,:) ! col air filled porosity
real(r8), pointer :: h2osoi_liqvol_col (:,:) ! col volumetric liquid water content (v/v)
real(r8), pointer :: h2ocan_patch (:) ! patch canopy water (mm H2O)
real(r8), pointer :: h2osfc_col (:) ! col surface water (mm H2O)
real(r8), pointer :: snocan_patch (:) ! patch canopy snow water (mm H2O)
real(r8), pointer :: liqcan_patch (:) ! patch canopy liquid water (mm H2O)
real(r8), pointer :: snounload_patch (:) ! Canopy snow unloading (mm H2O)
real(r8), pointer :: swe_old_col (:,:) ! col initial snow water
real(r8), pointer :: liq1_grc (:) ! grc initial gridcell total h2o liq content
real(r8), pointer :: liq2_grc (:) ! grc post land cover change total liq content
real(r8), pointer :: ice1_grc (:) ! grc initial gridcell total h2o ice content
real(r8), pointer :: ice2_grc (:) ! grc post land cover change total ice content
real(r8), pointer :: tws_grc (:) ! grc total water storage (mm H2O)
real(r8), pointer :: total_plant_stored_h2o_col(:) ! col water that is bound in plants, including roots, sapwood, leaves, etc
! in most cases, the vegetation scheme does not have a dynamic
! water storage in plants, and thus 0.0 is a suitable for the trivial case.
! When FATES is coupled in with plant hydraulics turned on, this storage
! term is set to non-zero. (kg/m2 H2O)
real(r8), pointer :: snw_rds_col (:,:) ! col snow grain radius (col,lyr) [m^-6, microns]
real(r8), pointer :: snw_rds_top_col (:) ! col snow grain radius (top layer) [m^-6, microns]
real(r8), pointer :: h2osno_top_col (:) ! col top-layer mass of snow [kg]
real(r8), pointer :: sno_liq_top_col (:) ! col snow liquid water fraction (mass), top layer [fraction]
real(r8), pointer :: q_ref2m_patch (:) ! patch 2 m height surface specific humidity (kg/kg)
real(r8), pointer :: rh_ref2m_patch (:) ! patch 2 m height surface relative humidity (%)
real(r8), pointer :: rh_ref2m_r_patch (:) ! patch 2 m height surface relative humidity - rural (%)
real(r8), pointer :: rh_ref2m_u_patch (:) ! patch 2 m height surface relative humidity - urban (%)
real(r8), pointer :: rh_af_patch (:) ! patch fractional humidity of canopy air (dimensionless) ! private
real(r8), pointer :: rh10_af_patch (:) ! 10-day mean patch fractional humidity of canopy air (dimensionless)
real(r8), pointer :: qg_snow_col (:) ! col ground specific humidity [kg/kg]
real(r8), pointer :: qg_soil_col (:) ! col ground specific humidity [kg/kg]
real(r8), pointer :: qg_h2osfc_col (:) ! col ground specific humidity [kg/kg]
real(r8), pointer :: qg_col (:) ! col ground specific humidity [kg/kg]
real(r8), pointer :: dqgdT_col (:) ! col d(qg)/dT
real(r8), pointer :: qaf_lun (:) ! lun urban canopy air specific humidity (kg/kg)
! Fractions
real(r8), pointer :: frac_sno_col (:) ! col fraction of ground covered by snow (0 to 1)
real(r8), pointer :: frac_sno_eff_col (:) ! col fraction of ground covered by snow (0 to 1)
real(r8), pointer :: frac_iceold_col (:,:) ! col fraction of ice relative to the tot water (new) (-nlevsno+1:nlevgrnd)
real(r8), pointer :: frac_h2osfc_col (:) ! col fractional area with surface water greater than zero
real(r8), pointer :: frac_h2osfc_nosnow_col (:) ! col fractional area with surface water greater than zero (if no snow present)
real(r8), pointer :: wf_col (:) ! col soil water as frac. of whc for top 0.05 m (0-1)
real(r8), pointer :: wf2_col (:) ! col soil water as frac. of whc for top 0.17 m (0-1)
real(r8), pointer :: fwet_patch (:) ! patch canopy fraction that is wet (0 to 1)
real(r8), pointer :: fcansno_patch (:) ! patch canopy fraction that is snow covered (0 to 1)
real(r8), pointer :: fdry_patch (:) ! patch canopy fraction of foliage that is green and dry [-] (new)
! Balance Checks
real(r8), pointer :: begwb_col (:) ! water mass begining of the time step
real(r8), pointer :: endwb_col (:) ! water mass end of the time step
real(r8), pointer :: errh2o_patch (:) ! water conservation error (mm H2O)
real(r8), pointer :: errh2o_col (:) ! water conservation error (mm H2O)
real(r8), pointer :: errh2osno_col (:) ! snow water conservation error(mm H2O)
contains
procedure :: Init
procedure :: Restart
procedure, public :: Reset
procedure, private :: InitAllocate
procedure, private :: InitHistory
procedure, private :: InitCold
end type waterstate_type
! minimum allowed snow effective radius (also "fresh snow" value) [microns]
real(r8), public, parameter :: snw_rds_min = 54.526_r8
character(len=*), parameter, private :: sourcefile = &
__FILE__
!------------------------------------------------------------------------
contains
!------------------------------------------------------------------------
subroutine Init(this, bounds, &
h2osno_input_col, snow_depth_input_col, watsat_col, t_soisno_col)
class(waterstate_type) :: this
type(bounds_type) , intent(in) :: bounds
real(r8) , intent(inout) :: h2osno_input_col(bounds%begc:)
real(r8) , intent(inout) :: snow_depth_input_col(bounds%begc:)
real(r8) , intent(inout) :: watsat_col(bounds%begc:, 1:) ! volumetric soil water at saturation (porosity)
real(r8) , intent(inout) :: t_soisno_col(bounds%begc:, -nlevsno+1:) ! col soil temperature (Kelvin)
#ifdef __PGI
# if __PGIC__ == 14 && __PGIC_MINOR__ == 7
! COMPILER_BUG(bja, 2015-04, pgi 14.7-?) occurs at: call this%InitCold(...)
! PGF90-F-0000-Internal compiler error. normalize_forall_array: non-conformable
! not sure why this fixes things....
real(r8), allocatable :: workaround_for_pgi_internal_compiler_error(:)
# endif
#endif
call this%InitAllocate(bounds)
call this%InitHistory(bounds)
call this%InitCold(bounds, &
h2osno_input_col, snow_depth_input_col, watsat_col, t_soisno_col)
end subroutine Init
!------------------------------------------------------------------------
subroutine InitAllocate(this, bounds)
!
! !DESCRIPTION:
! Initialize module data structure
!
! !USES:
use shr_infnan_mod , only : nan => shr_infnan_nan, assignment(=)
!
! !ARGUMENTS:
class(waterstate_type) :: this
type(bounds_type), intent(in) :: bounds
!
! !LOCAL VARIABLES:
integer :: begp, endp
integer :: begc, endc
integer :: begl, endl
integer :: begg, endg
!------------------------------------------------------------------------
begp = bounds%begp; endp= bounds%endp
begc = bounds%begc; endc= bounds%endc
begl = bounds%begl; endl= bounds%endl
begg = bounds%begg; endg= bounds%endg
allocate(this%snow_depth_col (begc:endc)) ; this%snow_depth_col (:) = nan
allocate(this%snow_persistence_col (begc:endc)) ; this%snow_persistence_col (:) = nan
allocate(this%snowdp_col (begc:endc)) ; this%snowdp_col (:) = nan
allocate(this%snowice_col (begc:endc)) ; this%snowice_col (:) = nan
allocate(this%snowliq_col (begc:endc)) ; this%snowliq_col (:) = nan
allocate(this%int_snow_col (begc:endc)) ; this%int_snow_col (:) = nan
allocate(this%snow_layer_unity_col (begc:endc,-nlevsno+1:0)) ; this%snow_layer_unity_col (:,:) = nan
allocate(this%bw_col (begc:endc,-nlevsno+1:0)) ; this%bw_col (:,:) = nan
allocate(this%h2osno_col (begc:endc)) ; this%h2osno_col (:) = nan
allocate(this%h2osno_old_col (begc:endc)) ; this%h2osno_old_col (:) = nan
allocate(this%h2osoi_liqice_10cm_col (begc:endc)) ; this%h2osoi_liqice_10cm_col (:) = nan
allocate(this%h2osoi_vol_col (begc:endc, 1:nlevgrnd)) ; this%h2osoi_vol_col (:,:) = nan
allocate(this%h2osoi_vol_prs_grc (begg:endg, 1:nlevgrnd)) ; this%h2osoi_vol_prs_grc (:,:) = nan
allocate(this%air_vol_col (begc:endc, 1:nlevgrnd)) ; this%air_vol_col (:,:) = nan
allocate(this%h2osoi_liqvol_col (begc:endc,-nlevsno+1:nlevgrnd)) ; this%h2osoi_liqvol_col (:,:) = nan
allocate(this%h2osoi_ice_col (begc:endc,-nlevsno+1:nlevgrnd)) ; this%h2osoi_ice_col (:,:) = nan
allocate(this%h2osoi_liq_col (begc:endc,-nlevsno+1:nlevgrnd)) ; this%h2osoi_liq_col (:,:) = nan
allocate(this%h2osoi_ice_tot_col (begc:endc)) ; this%h2osoi_ice_tot_col (:) = nan
allocate(this%h2osoi_liq_tot_col (begc:endc)) ; this%h2osoi_liq_tot_col (:) = nan
allocate(this%h2ocan_patch (begp:endp)) ; this%h2ocan_patch (:) = nan
allocate(this%snocan_patch (begp:endp)) ; this%snocan_patch (:) = nan
allocate(this%liqcan_patch (begp:endp)) ; this%liqcan_patch (:) = nan
allocate(this%snounload_patch (begp:endp)) ; this%snounload_patch (:) = nan
allocate(this%h2osfc_col (begc:endc)) ; this%h2osfc_col (:) = nan
allocate(this%swe_old_col (begc:endc,-nlevsno+1:0)) ; this%swe_old_col (:,:) = nan
allocate(this%liq1_grc (begg:endg)) ; this%liq1_grc (:) = nan
allocate(this%liq2_grc (begg:endg)) ; this%liq2_grc (:) = nan
allocate(this%ice1_grc (begg:endg)) ; this%ice1_grc (:) = nan
allocate(this%ice2_grc (begg:endg)) ; this%ice2_grc (:) = nan
allocate(this%tws_grc (begg:endg)) ; this%tws_grc (:) = nan
allocate(this%total_plant_stored_h2o_col(begc:endc)) ; this%total_plant_stored_h2o_col(:) = nan
allocate(this%snw_rds_col (begc:endc,-nlevsno+1:0)) ; this%snw_rds_col (:,:) = nan
allocate(this%snw_rds_top_col (begc:endc)) ; this%snw_rds_top_col (:) = nan
allocate(this%h2osno_top_col (begc:endc)) ; this%h2osno_top_col (:) = nan
allocate(this%sno_liq_top_col (begc:endc)) ; this%sno_liq_top_col (:) = nan
allocate(this%qg_snow_col (begc:endc)) ; this%qg_snow_col (:) = nan
allocate(this%qg_soil_col (begc:endc)) ; this%qg_soil_col (:) = nan
allocate(this%qg_h2osfc_col (begc:endc)) ; this%qg_h2osfc_col (:) = nan
allocate(this%qg_col (begc:endc)) ; this%qg_col (:) = nan
allocate(this%dqgdT_col (begc:endc)) ; this%dqgdT_col (:) = nan
allocate(this%qaf_lun (begl:endl)) ; this%qaf_lun (:) = nan
allocate(this%q_ref2m_patch (begp:endp)) ; this%q_ref2m_patch (:) = nan
allocate(this%rh_ref2m_patch (begp:endp)) ; this%rh_ref2m_patch (:) = nan
allocate(this%rh_ref2m_u_patch (begp:endp)) ; this%rh_ref2m_u_patch (:) = nan
allocate(this%rh_ref2m_r_patch (begp:endp)) ; this%rh_ref2m_r_patch (:) = nan
allocate(this%rh_af_patch (begp:endp)) ; this%rh_af_patch (:) = nan
allocate(this%rh10_af_patch (begp:endp)) ; this%rh10_af_patch (:) = spval
allocate(this%frac_sno_col (begc:endc)) ; this%frac_sno_col (:) = nan
allocate(this%frac_sno_eff_col (begc:endc)) ; this%frac_sno_eff_col (:) = nan
allocate(this%frac_iceold_col (begc:endc,-nlevsno+1:nlevgrnd)) ; this%frac_iceold_col (:,:) = nan
allocate(this%frac_h2osfc_col (begc:endc)) ; this%frac_h2osfc_col (:) = nan
allocate(this%frac_h2osfc_nosnow_col (begc:endc)) ; this%frac_h2osfc_nosnow_col (:) = nan
allocate(this%wf_col (begc:endc)) ; this%wf_col (:) = nan
allocate(this%wf2_col (begc:endc)) ;
allocate(this%fwet_patch (begp:endp)) ; this%fwet_patch (:) = nan
allocate(this%fcansno_patch (begp:endp)) ; this%fcansno_patch (:) = nan
allocate(this%fdry_patch (begp:endp)) ; this%fdry_patch (:) = nan
allocate(this%begwb_col (begc:endc)) ; this%begwb_col (:) = nan
allocate(this%endwb_col (begc:endc)) ; this%endwb_col (:) = nan
allocate(this%errh2o_patch (begp:endp)) ; this%errh2o_patch (:) = nan
allocate(this%errh2o_col (begc:endc)) ; this%errh2o_col (:) = nan
allocate(this%errh2osno_col (begc:endc)) ; this%errh2osno_col (:) = nan
end subroutine InitAllocate
!------------------------------------------------------------------------
subroutine InitHistory(this, bounds)
!
! !DESCRIPTION:
! Initialize module data structure
!
! !USES:
use shr_infnan_mod , only : nan => shr_infnan_nan, assignment(=)
use clm_varctl , only : use_cn, use_lch4, use_soil_moisture_streams
use clm_varctl , only : hist_wrtch4diag
use clm_varpar , only : nlevsno, nlevsoi
use histFileMod , only : hist_addfld1d, hist_addfld2d, no_snow_normal, no_snow_zero
!
! !ARGUMENTS:
class(waterstate_type) :: this
type(bounds_type), intent(in) :: bounds
!
! !LOCAL VARIABLES:
integer :: begp, endp
integer :: begc, endc
integer :: begg, endg
character(10) :: active
real(r8), pointer :: data2dptr(:,:), data1dptr(:) ! temp. pointers for slicing larger arrays
!------------------------------------------------------------------------
begp = bounds%begp; endp= bounds%endp
begc = bounds%begc; endc= bounds%endc
begg = bounds%begg; endg= bounds%endg
! h2osno also includes snow that is part of the soil column (an
! initial snow layer is only created if h2osno > 10mm).
data2dptr => this%h2osoi_liq_col(:,-nlevsno+1:0)
call hist_addfld2d (fname='SNO_LIQH2O', units='kg/m2', type2d='levsno', &
avgflag='A', long_name='Snow liquid water content', &
ptr_col=data2dptr, no_snow_behavior=no_snow_normal, default='inactive')
data2dptr => this%h2osoi_ice_col(:,-nlevsno+1:0)
call hist_addfld2d (fname='SNO_ICE', units='kg/m2', type2d='levsno', &
avgflag='A', long_name='Snow ice content', &
ptr_col=data2dptr, no_snow_behavior=no_snow_normal, default='inactive')
data2dptr => this%h2osoi_vol_col(begc:endc,1:nlevsoi)
call hist_addfld2d (fname='H2OSOI', units='mm3/mm3', type2d='levsoi', &
avgflag='A', long_name='volumetric soil water (vegetated landunits only)', &
ptr_col=this%h2osoi_vol_col, l2g_scale_type='veg')
if ( use_soil_moisture_streams )then
data2dptr => this%h2osoi_vol_prs_grc(begg:endg,1:nlevsoi)
call hist_addfld2d (fname='H2OSOI_PRESCRIBED_GRC', units='mm3/mm3', type2d='levsoi', &
avgflag='A', long_name='volumetric soil water prescribed (vegetated landunits only)', &
ptr_gcell=this%h2osoi_vol_prs_grc, default='inactive' )
end if
! this%h2osoi_liq_col(begc:endc,:) = spval
! call hist_addfld2d (fname='SOILLIQ', units='kg/m2', type2d='levgrnd', &
! avgflag='A', long_name='soil liquid water (vegetated landunits only)', &
! ptr_col=this%h2osoi_liq_col, l2g_scale_type='veg')
data2dptr => this%h2osoi_liq_col(begc:endc,1:nlevsoi)
call hist_addfld2d (fname='SOILLIQ', units='kg/m2', type2d='levsoi', &
avgflag='A', long_name='soil liquid water (vegetated landunits only)', &
ptr_col=data2dptr, l2g_scale_type='veg')
data2dptr => this%h2osoi_ice_col(begc:endc,1:nlevsoi)
call hist_addfld2d (fname='SOILICE', units='kg/m2', type2d='levsoi', &
avgflag='A', long_name='soil ice (vegetated landunits only)', &
ptr_col=data2dptr, l2g_scale_type='veg')
this%h2osoi_liqice_10cm_col(begc:endc) = spval
call hist_addfld1d (fname='SOILWATER_10CM', units='kg/m2', &
avgflag='A', long_name='soil liquid water + ice in top 10cm of soil (veg landunits only)', &
ptr_col=this%h2osoi_liqice_10cm_col, set_urb=spval, set_lake=spval, l2g_scale_type='veg')
this%h2osoi_liq_tot_col(begc:endc) = spval
call hist_addfld1d (fname='TOTSOILLIQ', units='kg/m2', &
avgflag='A', long_name='vertically summed soil liquid water (veg landunits only)', &
ptr_col=this%h2osoi_liq_tot_col, set_urb=spval, set_lake=spval, l2g_scale_type='veg')
this%h2osoi_ice_tot_col(begc:endc) = spval
call hist_addfld1d (fname='TOTSOILICE', units='kg/m2', &
avgflag='A', long_name='vertically summed soil cie (veg landunits only)', &
ptr_col=this%h2osoi_ice_tot_col, set_urb=spval, set_lake=spval, l2g_scale_type='veg')
this%h2ocan_patch(begp:endp) = spval
call hist_addfld1d (fname='H2OCAN', units='mm', &
avgflag='A', long_name='intercepted water', &
ptr_patch=this%h2ocan_patch, set_lake=0._r8)
this%snocan_patch(begp:endp) = spval
call hist_addfld1d (fname='SNOCAN', units='mm', &
avgflag='A', long_name='intercepted snow', &
ptr_patch=this%snocan_patch, set_lake=0._r8)
this%liqcan_patch(begp:endp) = spval
call hist_addfld1d (fname='LIQCAN', units='mm', &
avgflag='A', long_name='intercepted liquid water', &
ptr_patch=this%liqcan_patch, set_lake=0._r8)
this%snounload_patch(begp:endp) = spval
call hist_addfld1d (fname='SNOUNLOAD', units='mm', &
avgflag='A', long_name='Canopy snow unloading', &
ptr_patch=this%snounload_patch, set_lake=0._r8)
call hist_addfld1d (fname='H2OSNO', units='mm', &
avgflag='A', long_name='snow depth (liquid water)', &
ptr_col=this%h2osno_col, c2l_scale_type='urbanf')
call hist_addfld1d (fname='H2OSNO_ICE', units='mm', &
avgflag='A', long_name='snow depth (liquid water, ice landunits only)', &
ptr_col=this%h2osno_col, c2l_scale_type='urbanf', l2g_scale_type='ice', &
default='inactive')
this%liq1_grc(begg:endg) = spval
call hist_addfld1d (fname='LIQUID_CONTENT1', units='mm', &
avgflag='A', long_name='initial gridcell total liq content', &
ptr_lnd=this%liq1_grc)
this%liq2_grc(begg:endg) = spval
call hist_addfld1d (fname='LIQUID_CONTENT2', units='mm', &
avgflag='A', long_name='post landuse change gridcell total liq content', &
ptr_lnd=this%liq2_grc, default='inactive')
this%ice1_grc(begg:endg) = spval
call hist_addfld1d (fname='ICE_CONTENT1', units='mm', &
avgflag='A', long_name='initial gridcell total ice content', &
ptr_lnd=this%ice1_grc)
this%ice2_grc(begg:endg) = spval
call hist_addfld1d (fname='ICE_CONTENT2', units='mm', &
avgflag='A', long_name='post land cover change total ice content', &
ptr_lnd=this%ice2_grc, default='inactive')
this%h2osfc_col(begc:endc) = spval
call hist_addfld1d (fname='H2OSFC', units='mm', &
avgflag='A', long_name='surface water depth', &
ptr_col=this%h2osfc_col)
this%tws_grc(begg:endg) = spval
call hist_addfld1d (fname='TWS', units='mm', &
avgflag='A', long_name='total water storage', &
ptr_lnd=this%tws_grc)
! (rgk 02-02-2017) There is intentionally no entry here for stored plant water
! I think that since the value is zero in all cases except
! for FATES plant hydraulics, it will be confusing for users
! when they see their plants have no water in output files.
! So it is not useful diagnostic information. The information
! can be provided through FATES specific history diagnostics
! if need be.
! Humidity
this%q_ref2m_patch(begp:endp) = spval
call hist_addfld1d (fname='Q2M', units='kg/kg', &
avgflag='A', long_name='2m specific humidity', &
ptr_patch=this%q_ref2m_patch)
this%rh_ref2m_patch(begp:endp) = spval
call hist_addfld1d (fname='RH2M', units='%', &
avgflag='A', long_name='2m relative humidity', &
ptr_patch=this%rh_ref2m_patch)
this%rh_ref2m_r_patch(begp:endp) = spval
call hist_addfld1d (fname='RH2M_R', units='%', &
avgflag='A', long_name='Rural 2m specific humidity', &
ptr_patch=this%rh_ref2m_r_patch, set_spec=spval, default='inactive')
this%rh_ref2m_u_patch(begp:endp) = spval
call hist_addfld1d (fname='RH2M_U', units='%', &
avgflag='A', long_name='Urban 2m relative humidity', &
ptr_patch=this%rh_ref2m_u_patch, set_nourb=spval, default='inactive')
this%rh_af_patch(begp:endp) = spval
call hist_addfld1d (fname='RHAF', units='fraction', &
avgflag='A', long_name='fractional humidity of canopy air', &
ptr_patch=this%rh_af_patch, set_spec=spval, default='inactive')
if(use_luna)then
call hist_addfld1d (fname='RHAF10', units='fraction', &
avgflag='A', long_name='10 day running mean of fractional humidity of canopy air', &
ptr_patch=this%rh10_af_patch, set_spec=spval, default='inactive')
endif
! Fractions
this%frac_h2osfc_col(begc:endc) = spval
call hist_addfld1d (fname='FH2OSFC', units='unitless', &
avgflag='A', long_name='fraction of ground covered by surface water', &
ptr_col=this%frac_h2osfc_col)
this%frac_h2osfc_nosnow_col(begc:endc) = spval
call hist_addfld1d (fname='FH2OSFC_NOSNOW', units='unitless', &
avgflag='A', &
long_name='fraction of ground covered by surface water (if no snow present)', &
ptr_col=this%frac_h2osfc_nosnow_col, default='inactive')
this%frac_sno_col(begc:endc) = spval
call hist_addfld1d (fname='FSNO', units='unitless', &
avgflag='A', long_name='fraction of ground covered by snow', &
ptr_col=this%frac_sno_col, c2l_scale_type='urbanf')
call hist_addfld1d (fname='FSNO_ICE', units='unitless', &
avgflag='A', long_name='fraction of ground covered by snow (ice landunits only)', &
ptr_col=this%frac_sno_col, c2l_scale_type='urbanf', l2g_scale_type='ice', &
default='inactive')
this%frac_sno_eff_col(begc:endc) = spval
call hist_addfld1d (fname='FSNO_EFF', units='unitless', &
avgflag='A', long_name='effective fraction of ground covered by snow', &
ptr_col=this%frac_sno_eff_col, c2l_scale_type='urbanf')!, default='inactive')
if (use_cn) then
this%fwet_patch(begp:endp) = spval
call hist_addfld1d (fname='FWET', units='proportion', &
avgflag='A', long_name='fraction of canopy that is wet', &
ptr_patch=this%fwet_patch, default='inactive')
end if
if (use_cn) then
this%fcansno_patch(begp:endp) = spval
call hist_addfld1d (fname='FCANSNO', units='proportion', &
avgflag='A', long_name='fraction of canopy that is wet', &
ptr_patch=this%fcansno_patch, default='inactive')
end if
if (use_cn) then
this%fdry_patch(begp:endp) = spval
call hist_addfld1d (fname='FDRY', units='proportion', &
avgflag='A', long_name='fraction of foliage that is green and dry', &
ptr_patch=this%fdry_patch, default='inactive')
end if
if (use_cn)then
this%frac_iceold_col(begc:endc,:) = spval
call hist_addfld2d (fname='FRAC_ICEOLD', units='proportion', type2d='levgrnd', &
avgflag='A', long_name='fraction of ice relative to the tot water', &
ptr_col=this%frac_iceold_col, default='inactive')
end if
! Snow properties - these will be vertically averaged over the snow profile
this%snow_depth_col(begc:endc) = spval
call hist_addfld1d (fname='SNOW_DEPTH', units='m', &
avgflag='A', long_name='snow height of snow covered area', &
ptr_col=this%snow_depth_col, c2l_scale_type='urbanf')
call hist_addfld1d (fname='SNOW_DEPTH_ICE', units='m', &
avgflag='A', long_name='snow height of snow covered area (ice landunits only)', &
ptr_col=this%snow_depth_col, c2l_scale_type='urbanf', l2g_scale_type='ice', &
default='inactive')
this%snowdp_col(begc:endc) = spval
call hist_addfld1d (fname='SNOWDP', units='m', &
avgflag='A', long_name='gridcell mean snow height', &
ptr_col=this%snowdp_col, c2l_scale_type='urbanf')
this%snowliq_col(begc:endc) = spval
call hist_addfld1d (fname='SNOWLIQ', units='kg/m2', &
avgflag='A', long_name='snow liquid water', &
ptr_col=this%snowliq_col, c2l_scale_type='urbanf')
call hist_addfld1d (fname='SNOWLIQ_ICE', units='kg/m2', &
avgflag='A', long_name='snow liquid water (ice landunits only)', &
ptr_col=this%snowliq_col, c2l_scale_type='urbanf', l2g_scale_type='ice', &
default='inactive')
this%snowice_col(begc:endc) = spval
call hist_addfld1d (fname='SNOWICE', units='kg/m2', &
avgflag='A', long_name='snow ice', &
ptr_col=this%snowice_col, c2l_scale_type='urbanf')
call hist_addfld1d (fname='SNOWICE_ICE', units='kg/m2', &
avgflag='A', long_name='snow ice (ice landunits only)', &
ptr_col=this%snowice_col, c2l_scale_type='urbanf', l2g_scale_type='ice', &
default='inactive')
this%int_snow_col(begc:endc) = spval
call hist_addfld1d (fname='INT_SNOW', units='mm', &
avgflag='A', long_name='accumulated swe (vegetated landunits only)', &
ptr_col=this%int_snow_col, l2g_scale_type='veg', &
default='inactive')
call hist_addfld1d (fname='INT_SNOW_ICE', units='mm', &
avgflag='A', long_name='accumulated swe (ice landunits only)', &
ptr_col=this%int_snow_col, l2g_scale_type='ice', &
default='inactive')
this%snow_persistence_col(begc:endc) = spval
call hist_addfld1d (fname='SNOW_PERSISTENCE', units='seconds', &
avgflag='I', long_name='Length of time of continuous snow cover (nat. veg. landunits only)', &
ptr_col=this%snow_persistence_col, l2g_scale_type='natveg')
if (use_cn) then
this%wf_col(begc:endc) = spval
call hist_addfld1d (fname='WF', units='proportion', &
avgflag='A', long_name='soil water as frac. of whc for top 0.05 m', &
ptr_col=this%wf_col, default='inactive')
end if
this%h2osno_top_col(begc:endc) = spval
call hist_addfld1d (fname='H2OSNO_TOP', units='kg/m2', &
avgflag='A', long_name='mass of snow in top snow layer', &
ptr_col=this%h2osno_top_col, set_urb=spval)
this%snw_rds_top_col(begc:endc) = spval
call hist_addfld1d (fname='SNORDSL', units='m^-6', &
avgflag='A', long_name='top snow layer effective grain radius', &
ptr_col=this%snw_rds_top_col, set_urb=spval, default='inactive')
this%sno_liq_top_col(begc:endc) = spval
call hist_addfld1d (fname='SNOLIQFL', units='fraction', &
avgflag='A', long_name='top snow layer liquid water fraction (land)', &
ptr_col=this%sno_liq_top_col, set_urb=spval, default='inactive')
! We determine the fractional time (and fraction of the grid cell) over which each
! snow layer existed by running the snow averaging routine on a field whose value is 1
! everywhere
data2dptr => this%snow_layer_unity_col(:,-nlevsno+1:0)
call hist_addfld2d (fname='SNO_EXISTENCE', units='unitless', type2d='levsno', &
avgflag='A', long_name='Fraction of averaging period for which each snow layer existed', &
ptr_col=data2dptr, no_snow_behavior=no_snow_zero, default='inactive')
this%bw_col(begc:endc,-nlevsno+1:0) = spval
data2dptr => this%bw_col(:,-nlevsno+1:0)
call hist_addfld2d (fname='SNO_BW', units='kg/m3', type2d='levsno', &
avgflag='A', long_name='Partial density of water in the snow pack (ice + liquid)', &
ptr_col=data2dptr, no_snow_behavior=no_snow_normal, default='inactive')
call hist_addfld2d (fname='SNO_BW_ICE', units='kg/m3', type2d='levsno', &
avgflag='A', long_name='Partial density of water in the snow pack (ice + liquid, ice landunits only)', &
ptr_col=data2dptr, no_snow_behavior=no_snow_normal, &
l2g_scale_type='ice', default='inactive')
this%snw_rds_col(begc:endc,-nlevsno+1:0) = spval
data2dptr => this%snw_rds_col(:,-nlevsno+1:0)
call hist_addfld2d (fname='SNO_GS', units='Microns', type2d='levsno', &
avgflag='A', long_name='Mean snow grain size', &
ptr_col=data2dptr, no_snow_behavior=no_snow_normal, default='inactive')
call hist_addfld2d (fname='SNO_GS_ICE', units='Microns', type2d='levsno', &
avgflag='A', long_name='Mean snow grain size (ice landunits only)', &
ptr_col=data2dptr, no_snow_behavior=no_snow_normal, &
l2g_scale_type='ice', default='inactive')
this%errh2o_col(begc:endc) = spval
call hist_addfld1d (fname='ERRH2O', units='mm', &
avgflag='A', long_name='total water conservation error', &
ptr_col=this%errh2o_col)
this%errh2osno_col(begc:endc) = spval
call hist_addfld1d (fname='ERRH2OSNO', units='mm', &
avgflag='A', long_name='imbalance in snow depth (liquid water)', &
ptr_col=this%errh2osno_col, c2l_scale_type='urbanf')
end subroutine InitHistory
!-----------------------------------------------------------------------
subroutine InitCold(this, bounds, &
h2osno_input_col, snow_depth_input_col, watsat_col, t_soisno_col)
!
! !DESCRIPTION:
! Initialize time constant variables and cold start conditions
!
! !USES:
use shr_const_mod , only : shr_const_pi
use shr_log_mod , only : errMsg => shr_log_errMsg
use shr_spfn_mod , only : shr_spfn_erf
use shr_kind_mod , only : r8 => shr_kind_r8
use shr_const_mod , only : SHR_CONST_TKFRZ
use clm_varpar , only : nlevsoi, nlevgrnd, nlevsno, nlevlak, nlevurb
use landunit_varcon , only : istwet, istsoil, istdlak, istcrop, istice_mec
use column_varcon , only : icol_shadewall, icol_road_perv
use column_varcon , only : icol_road_imperv, icol_roof, icol_sunwall
use clm_varcon , only : denice, denh2o, spval, sb, bdsno
use clm_varcon , only : zlnd, tfrz, spval, pc
use clm_varctl , only : fsurdat, iulog
use clm_varctl , only : use_bedrock
use spmdMod , only : masterproc
use abortutils , only : endrun
use fileutils , only : getfil
use ncdio_pio , only : file_desc_t, ncd_io
!
! !ARGUMENTS:
class(waterstate_type) :: this
type(bounds_type) , intent(in) :: bounds
real(r8) , intent(in) :: h2osno_input_col(bounds%begc:)
real(r8) , intent(in) :: snow_depth_input_col(bounds%begc:)
real(r8) , intent(in) :: watsat_col(bounds%begc:, 1:) ! volumetric soil water at saturation (porosity)
real(r8) , intent(in) :: t_soisno_col(bounds%begc:, -nlevsno+1:) ! col soil temperature (Kelvin)
!
! !LOCAL VARIABLES:
integer :: p,c,j,l,g,lev,nlevs
real(r8) :: maxslope, slopemax, minslope
real(r8) :: d, fd, dfdd, slope0,slopebeta
real(r8) ,pointer :: std (:)
logical :: readvar
type(file_desc_t) :: ncid
character(len=256) :: locfn
real(r8) :: snowbd ! temporary calculation of snow bulk density (kg/m3)
real(r8) :: fmelt ! snowbd/100
integer :: nbedrock
!-----------------------------------------------------------------------
SHR_ASSERT_ALL((ubound(h2osno_input_col) == (/bounds%endc/)) , errMsg(sourcefile, __LINE__))
SHR_ASSERT_ALL((ubound(snow_depth_input_col) == (/bounds%endc/)) , errMsg(sourcefile, __LINE__))
SHR_ASSERT_ALL((ubound(watsat_col) == (/bounds%endc,nlevgrnd/)) , errMsg(sourcefile, __LINE__))
SHR_ASSERT_ALL((ubound(t_soisno_col) == (/bounds%endc,nlevgrnd/)) , errMsg(sourcefile, __LINE__))
! The first three arrays are initialized from the input argument
do c = bounds%begc,bounds%endc
this%h2osno_col(c) = h2osno_input_col(c)
this%int_snow_col(c) = h2osno_input_col(c)
this%snow_depth_col(c) = snow_depth_input_col(c)
this%snow_persistence_col(c) = 0._r8
this%snow_layer_unity_col(c,:) = 1._r8
end do
do c = bounds%begc,bounds%endc
this%wf_col(c) = spval
this%wf2_col(c) = spval
end do
do l = bounds%begl, bounds%endl
if (lun%urbpoi(l)) then
if (use_vancouver) then
this%qaf_lun(l) = 0.0111_r8
else if (use_mexicocity) then
this%qaf_lun(l) = 0.00248_r8
else
this%qaf_lun(l) = 1.e-4_r8 ! Arbitrary set since forc_q is not yet available
end if
end if
end do
! Water Stored in plants is almost always a static entity, with the exception
! of when FATES-hydraulics is used. As such, this is trivially set to 0.0 (rgk 03-2017)
this%total_plant_stored_h2o_col(bounds%begc:bounds%endc) = 0.0_r8
associate(snl => col%snl)
this%h2osfc_col(bounds%begc:bounds%endc) = 0._r8
this%h2ocan_patch(bounds%begp:bounds%endp) = 0._r8
this%snocan_patch(bounds%begp:bounds%endp) = 0._r8
this%liqcan_patch(bounds%begp:bounds%endp) = 0._r8
this%snounload_patch(bounds%begp:bounds%endp) = 0._r8
this%frac_h2osfc_col(bounds%begc:bounds%endc) = 0._r8
this%fwet_patch(bounds%begp:bounds%endp) = 0._r8
this%fdry_patch(bounds%begp:bounds%endp) = 0._r8
this%fcansno_patch(bounds%begp:bounds%endp) = 0._r8
!--------------------------------------------
! Set snow water
!--------------------------------------------
! Note: Glacier_mec columns are initialized with half the maximum snow cover.
! This gives more realistic values of qflx_glcice sooner in the simulation
! for columns with net ablation, at the cost of delaying ice formation
! in columns with net accumulation.
do c = bounds%begc, bounds%endc
l = col%landunit(c)
if (lun%urbpoi(l)) then
! From Bonan 1996 (LSM technical note)
this%frac_sno_col(c) = min( this%snow_depth_col(c)/0.05_r8, 1._r8)
else
this%frac_sno_col(c) = 0._r8
! snow cover fraction as in Niu and Yang 2007
if(this%snow_depth_col(c) > 0.0) then
snowbd = min(400._r8, this%h2osno_col(c)/this%snow_depth_col(c)) !bulk density of snow (kg/m3)
fmelt = (snowbd/100.)**1.
! 100 is the assumed fresh snow density; 1 is a melting factor that could be
! reconsidered, optimal value of 1.5 in Niu et al., 2007
this%frac_sno_col(c) = tanh( this%snow_depth_col(c) /(2.5 * zlnd * fmelt) )
endif
end if
end do
do c = bounds%begc,bounds%endc
if (snl(c) < 0) then
this%snw_rds_col(c,snl(c)+1:0) = snw_rds_min
this%snw_rds_col(c,-nlevsno+1:snl(c)) = 0._r8
this%snw_rds_top_col(c) = snw_rds_min
elseif (this%h2osno_col(c) > 0._r8) then
this%snw_rds_col(c,0) = snw_rds_min
this%snw_rds_col(c,-nlevsno+1:-1) = 0._r8
this%snw_rds_top_col(c) = spval
this%sno_liq_top_col(c) = spval
else
this%snw_rds_col(c,:) = 0._r8
this%snw_rds_top_col(c) = spval
this%sno_liq_top_col(c) = spval
endif
end do
!--------------------------------------------
! Set soil water
!--------------------------------------------
! volumetric water is set first and liquid content and ice lens are obtained
! NOTE: h2osoi_vol, h2osoi_liq and h2osoi_ice only have valid values over soil
! and urban pervious road (other urban columns have zero soil water)
this%h2osoi_vol_col(bounds%begc:bounds%endc, 1:) = spval
this%h2osoi_vol_prs_grc(bounds%begg:bounds%endg, 1:) = spval
this%h2osoi_liq_col(bounds%begc:bounds%endc,-nlevsno+1:) = spval
this%h2osoi_ice_col(bounds%begc:bounds%endc,-nlevsno+1:) = spval
do c = bounds%begc,bounds%endc
l = col%landunit(c)
if (.not. lun%lakpoi(l)) then !not lake
! volumetric water
if (lun%itype(l) == istsoil .or. lun%itype(l) == istcrop) then
nlevs = nlevgrnd
do j = 1, nlevs
if (use_bedrock) then
nbedrock = col%nbedrock(c)
else
nbedrock = nlevsoi
endif
if (j > nbedrock) then
this%h2osoi_vol_col(c,j) = 0.0_r8
else
if(use_fates_planthydro) then
this%h2osoi_vol_col(c,j) = 0.75_r8*watsat_col(c,j)
else
this%h2osoi_vol_col(c,j) = 0.15_r8
end if
endif
end do
else if (lun%urbpoi(l)) then
if (col%itype(c) == icol_road_perv) then
nlevs = nlevgrnd
do j = 1, nlevs
if (j <= nlevsoi) then
this%h2osoi_vol_col(c,j) = 0.3_r8
else
this%h2osoi_vol_col(c,j) = 0.0_r8
end if
end do
else if (col%itype(c) == icol_road_imperv) then
nlevs = nlevgrnd
do j = 1, nlevs
this%h2osoi_vol_col(c,j) = 0.0_r8
end do
else
nlevs = nlevurb
do j = 1, nlevs
this%h2osoi_vol_col(c,j) = 0.0_r8
end do
end if
else if (lun%itype(l) == istwet) then
nlevs = nlevgrnd
do j = 1, nlevs
if (j > nlevsoi) then
this%h2osoi_vol_col(c,j) = 0.0_r8
else
this%h2osoi_vol_col(c,j) = 1.0_r8
endif
end do
else if (lun%itype(l) == istice_mec) then
nlevs = nlevgrnd
do j = 1, nlevs
this%h2osoi_vol_col(c,j) = 1.0_r8
end do
endif
do j = 1, nlevs
this%h2osoi_vol_col(c,j) = min(this%h2osoi_vol_col(c,j), watsat_col(c,j))
if (t_soisno_col(c,j) <= SHR_CONST_TKFRZ) then
this%h2osoi_ice_col(c,j) = col%dz(c,j)*denice*this%h2osoi_vol_col(c,j)
this%h2osoi_liq_col(c,j) = 0._r8
else
this%h2osoi_ice_col(c,j) = 0._r8
this%h2osoi_liq_col(c,j) = col%dz(c,j)*denh2o*this%h2osoi_vol_col(c,j)
endif
end do
do j = -nlevsno+1, 0
if (j > snl(c)) then
this%h2osoi_ice_col(c,j) = col%dz(c,j)*250._r8
this%h2osoi_liq_col(c,j) = 0._r8
end if
end do
end if
end do
!--------------------------------------------
! Set Lake water
!--------------------------------------------
do c = bounds%begc, bounds%endc
l = col%landunit(c)
if (lun%lakpoi(l)) then
do j = -nlevsno+1, 0
if (j > snl(c)) then
this%h2osoi_ice_col(c,j) = col%dz(c,j)*bdsno
this%h2osoi_liq_col(c,j) = 0._r8
end if
end do
do j = 1,nlevgrnd
if (j <= nlevsoi) then ! soil
this%h2osoi_vol_col(c,j) = watsat_col(c,j)
this%h2osoi_liq_col(c,j) = spval
this%h2osoi_ice_col(c,j) = spval
else ! bedrock
this%h2osoi_vol_col(c,j) = 0._r8
end if
end do
end if
end do
!--------------------------------------------
! For frozen layers !TODO - does the following make sense ???? it seems to overwrite everything
!--------------------------------------------
do c = bounds%begc, bounds%endc
do j = 1,nlevgrnd
if (this%h2osoi_vol_col(c,j) /= spval) then
if (t_soisno_col(c,j) <= tfrz) then
this%h2osoi_ice_col(c,j) = col%dz(c,j)*denice*this%h2osoi_vol_col(c,j)
this%h2osoi_liq_col(c,j) = 0._r8
else
this%h2osoi_ice_col(c,j) = 0._r8
this%h2osoi_liq_col(c,j) = col%dz(c,j)*denh2o*this%h2osoi_vol_col(c,j)
endif
end if
end do
end do
end associate
end subroutine InitCold
!------------------------------------------------------------------------
subroutine Restart(this, bounds, ncid, flag, &
watsat_col)
!
! !DESCRIPTION:
! Read/Write module information to/from restart file.
!
! !USES:
use spmdMod , only : masterproc
use clm_varcon , only : denice, denh2o, pondmx, watmin, spval, nameg
use landunit_varcon , only : istcrop, istdlak, istsoil
use column_varcon , only : icol_roof, icol_sunwall, icol_shadewall
use clm_time_manager , only : is_first_step
use clm_varctl , only : bound_h2osoi
use ncdio_pio , only : file_desc_t, ncd_io, ncd_double
use restUtilMod
!
! !ARGUMENTS:
class(waterstate_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'
real(r8) , intent(in) :: watsat_col (bounds%begc:, 1:) ! volumetric soil water at saturation (porosity)
!
! !LOCAL VARIABLES:
integer :: c,l,j,nlevs
logical :: readvar
real(r8) :: maxwatsat ! maximum porosity
real(r8) :: excess ! excess volumetric soil water
real(r8) :: totwat ! total soil water (mm)
!------------------------------------------------------------------------
SHR_ASSERT_ALL((ubound(watsat_col) == (/bounds%endc,nlevgrnd/)) , errMsg(sourcefile, __LINE__))
call restartvar(ncid=ncid, flag=flag, varname='INT_SNOW', xtype=ncd_double, &
dim1name='column', &
long_name='accuumulated snow', units='mm', &
interpinic_flag='interp', readvar=readvar, data=this%int_snow_col)
if (flag=='read' .and. .not. readvar) then
this%int_snow_col(:) = 0.0_r8
end if
call restartvar(ncid=ncid, flag=flag, varname='H2OSFC', xtype=ncd_double, &
dim1name='column', &
long_name='surface water', units='kg/m2', &
interpinic_flag='interp', readvar=readvar, data=this%h2osfc_col)
if (flag=='read' .and. .not. readvar) then
this%h2osfc_col(bounds%begc:bounds%endc) = 0.0_r8
end if
call restartvar(ncid=ncid, flag=flag, varname='H2OSNO', xtype=ncd_double, &
dim1name='column', &
long_name='snow water', units='kg/m2', &
interpinic_flag='interp', readvar=readvar, data=this%h2osno_col)
call restartvar(ncid=ncid, flag=flag, varname='H2OSOI_LIQ', xtype=ncd_double, &
dim1name='column', dim2name='levtot', switchdim=.true., &
long_name='liquid water', units='kg/m2', &
interpinic_flag='interp', readvar=readvar, data=this%h2osoi_liq_col)
call restartvar(ncid=ncid, flag=flag, varname='H2OSOI_ICE', xtype=ncd_double, &
dim1name='column', dim2name='levtot', switchdim=.true., &
long_name='ice lens', units='kg/m2', &
interpinic_flag='interp', readvar=readvar, data=this%h2osoi_ice_col)
call restartvar(ncid=ncid, flag=flag, varname='H2OCAN', xtype=ncd_double, &
dim1name='pft', &
long_name='canopy water', units='kg/m2', &
interpinic_flag='interp', readvar=readvar, data=this%h2ocan_patch)
call restartvar(ncid=ncid, flag=flag, varname='SNOCAN', xtype=ncd_double, &
dim1name='pft', &
long_name='canopy snow water', units='kg/m2', &
interpinic_flag='interp', readvar=readvar, data=this%snocan_patch)
! NOTE(wjs, 2015-07-01) In old restart files, there was no LIQCAN variable. However,
! H2OCAN had similar meaning. So if we can't find LIQCAN, use H2OCAN to initialize
! liqcan_patch.
call restartvar(ncid=ncid, flag=flag, varname='LIQCAN:H2OCAN', xtype=ncd_double, &
dim1name='pft', &
long_name='canopy liquid water', units='kg/m2', &
interpinic_flag='interp', readvar=readvar, data=this%liqcan_patch)
call restartvar(ncid=ncid, flag=flag, varname='SNOUNLOAD', xtype=ncd_double, &
dim1name='pft', &
long_name='Canopy snow unloading', units='kg/m2', &
interpinic_flag='interp', readvar=readvar, data=this%snounload_patch)
! TWS is needed when methane is on and the TWS_inversion is used to get exact
! restart.
call restartvar(ncid=ncid, flag=flag, varname='TWS', xtype=ncd_double, &
dim1name=nameg, &
long_name='Total Water Storage', units='mm', &
interpinic_flag='interp', readvar=readvar, data=this%tws_grc)
if(use_luna)then
call restartvar(ncid=ncid, flag=flag, varname='rh10', xtype=ncd_double, &
dim1name='pft', long_name='10-day mean boundary layer relatie humidity', units='unitless', &
interpinic_flag='interp', readvar=readvar, data=this%rh10_af_patch)
endif
! Determine volumetric soil water (for read only)
if (flag == 'read' ) then
do c = bounds%begc, bounds%endc
l = col%landunit(c)
if ( col%itype(c) == icol_sunwall .or. &
col%itype(c) == icol_shadewall .or. &
col%itype(c) == icol_roof )then
nlevs = nlevurb
else
nlevs = nlevgrnd
end if
if ( lun%itype(l) /= istdlak ) then ! This calculation is now done for lakes in initLake.
do j = 1,nlevs
this%h2osoi_vol_col(c,j) = this%h2osoi_liq_col(c,j)/(col%dz(c,j)*denh2o) &
+ this%h2osoi_ice_col(c,j)/(col%dz(c,j)*denice)
end do
end if
end do
end if