forked from ESCOMP/CTSM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSoilTemperatureMod.F90
More file actions
2982 lines (2612 loc) · 169 KB
/
SoilTemperatureMod.F90
File metadata and controls
2982 lines (2612 loc) · 169 KB
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 SoilTemperatureMod
#include "shr_assert.h"
!-----------------------------------------------------------------------
! !DESCRIPTION:
! Calculates snow and soil temperatures including phase change
!
! !USES:
use shr_kind_mod , only : r8 => shr_kind_r8
use shr_infnan_mod , only : nan => shr_infnan_nan, assignment(=)
use decompMod , only : bounds_type
use abortutils , only : endrun
use perf_mod , only : t_startf, t_stopf
use clm_varctl , only : iulog
use UrbanParamsType , only : urbanparams_type
use UrbanTimeVarType , only : urbantv_type
use atm2lndType , only : atm2lnd_type
use CanopyStateType , only : canopystate_type
use WaterFluxBulkType , only : waterfluxbulk_type
use WaterStateBulkType , only : waterstatebulk_type
use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type
use SolarAbsorbedType , only : solarabs_type
use SoilStateType , only : soilstate_type
use EnergyFluxType , only : energyflux_type
use TemperatureType , only : temperature_type
use LandunitType , only : lun
use ColumnType , only : col
use PatchType , only : patch
!
! !PUBLIC TYPES:
implicit none
save
private
!
! !PUBLIC MEMBER FUNCTIONS:
public :: SoilTemperature
!
! -> SoilTemperature: soil/snow and ground temperatures
! -> SoilTermProp thermal conductivities and heat capacities
! -> Tridiagonal tridiagonal matrix solution
! -> PhaseChange phase change of liquid/ice contents
!
! (1) Snow and soil temperatures
! o The volumetric heat capacity is calculated as a linear combination
! in terms of the volumetric fraction of the constituent phases.
! o The thermal conductivity of soil is computed from
! the algorithm of Johansen (as reported by Farouki 1981), and the
! conductivity of snow is from the formulation used in
! Sturm (1997) or Jordan (1991) p. 18 depending on namelist option.
! o Boundary conditions:
! F = Rnet - Hg - LEg (top), F= 0 (base of the soil column).
! o Soil / snow temperature is predicted from heat conduction
! in 10 soil layers and up to nlevsno snow layers.
! The thermal conductivities at the interfaces between two
! neighboring layers (j, j+1) are derived from an assumption that
! the flux across the interface is equal to that from the node j
! to the interface and the flux from the interface to the node j+1.
! The equation is solved using the Crank-Nicholson method and
! results in a tridiagonal system equation.
! (2) Phase change
!
! The following is only public for the sake of unit testing; it should not be called
! directly by CLM code outside this module
public :: ComputeGroundHeatFluxAndDeriv ! Computes G and dG/dT on surface of standing water, snow and soil
public :: ComputeHeatDiffFluxAndFactor ! Heat diffusion at layer interface and factor used in setting up of banded matrix
public :: SetRHSVec ! Sets up the RHS vector for the numerical solution of temperature for snow/standing-water/soil
public :: SetRHSVec_Snow ! Sets up the RHS vector corresponding to snow layers for all columns
public :: SetRHSVec_Soil ! Sets up the RHS vector corresponding to soil layers for all columns
public :: SetRHSVec_StandingSurfaceWater ! Sets up the RHS vector corresponding to standing water layers for all columns
public :: SetMatrix ! Sets up the matrix for the numerical solution of temperature for snow/standing-water/soil
public :: AssembleMatrixFromSubmatrices ! Assemble the full matrix from submatrices.
public :: SetMatrix_Snow ! Set up the matrix entries corresponding to snow layers for all columns
public :: SetMatrix_Soil ! Set up the matrix entries corresponding to soil layers for all columns
public :: SetMatrix_StandingSurfaceWater ! Set up the matrix entries corresponding to standing surface water for all columns
!
! !PRIVATE MEMBER FUNCTIONS:
private :: SoilThermProp ! Set therm conduct. and heat cap of snow/soil layers
private :: PhaseChangeH2osfc ! When surface water freezes move ice to bottom snow layer
private :: PhaseChange_beta ! Calculation of the phase change within snow and soil layers
private :: BuildingHAC ! Building Heating and Cooling for simpler method (introduced in CLM4.5)
real(r8), private, parameter :: thin_sfclayer = 1.0e-6_r8 ! Threshold for thin surface layer
character(len=*), parameter, private :: sourcefile = &
__FILE__
!-----------------------------------------------------------------------
contains
!-----------------------------------------------------------------------
subroutine SoilTemperature(bounds, num_urbanl, filter_urbanl, num_urbanc, filter_urbanc, &
num_nolakep, filter_nolakep, num_nolakec, filter_nolakec, &
atm2lnd_inst, urbanparams_inst, canopystate_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, waterfluxbulk_inst,&
solarabs_inst, soilstate_inst, energyflux_inst, temperature_inst, urbantv_inst)
!
! !DESCRIPTION:
! Snow and soil temperatures including phase change
! o The volumetric heat capacity is calculated as a linear combination
! in terms of the volumetric fraction of the constituent phases.
! o The thermal conductivity of soil is computed from
! the algorithm of Johansen (as reported by Farouki 1981), and the
! conductivity of snow is from the formulation used in
! Sturm (1997) or Jordan (1991) p. 18 depending on namelist option.
! o Boundary conditions:
! F = Rnet - Hg - LEg (top), F= 0 (base of the soil column).
! o Soil / snow temperature is predicted from heat conduction
! in 10 soil layers and up to nlevsno snow layers.
! The thermal conductivities at the interfaces between two
! neighboring layers (j, j+1) are derived from an assumption that
! the flux across the interface is equal to that from the node j
! to the interface and the flux from the interface to the node j+1.
! The equation is solved using the Crank-Nicholson method and
! results in a tridiagonal system equation.
!
! !USES:
use clm_time_manager , only : get_step_size_real
use clm_varpar , only : nlevsno, nlevgrnd, nlevurb, nlevmaxurbgrnd
use clm_varctl , only : iulog, use_excess_ice
use clm_varcon , only : cnfac, cpice, cpliq, denh2o, denice
use landunit_varcon , only : istsoil, istcrop
use column_varcon , only : icol_roof, icol_sunwall, icol_shadewall, icol_road_perv, icol_road_imperv
use BandDiagonalMod , only : BandDiagonal
use UrbanParamsType , only : IsSimpleBuildTemp, IsProgBuildTemp
use UrbBuildTempOleson2015Mod, only : BuildingTemperature
!
! !ARGUMENTS:
type(bounds_type) , intent(in) :: bounds
integer , intent(in) :: num_nolakep ! number of non-lake points in patch filter
integer , intent(in) :: filter_nolakep(:) ! patch filter for non-lake points
integer , intent(in) :: num_nolakec ! number of column non-lake points in column filter
integer , intent(in) :: filter_nolakec(:) ! column filter for non-lake points
integer , intent(in) :: num_urbanl ! number of urban landunits in clump
integer , intent(in) :: filter_urbanl(:) ! urban landunit filter
integer , intent(in) :: num_urbanc ! number of urban columns in clump
integer , intent(in) :: filter_urbanc(:) ! urban column filter
type(atm2lnd_type) , intent(in) :: atm2lnd_inst
type(urbanparams_type) , intent(in) :: urbanparams_inst
type(urbantv_type) , intent(in) :: urbantv_inst
type(canopystate_type) , intent(in) :: canopystate_inst
type(waterstatebulk_type) , intent(inout) :: waterstatebulk_inst
type(waterdiagnosticbulk_type) , intent(inout) :: waterdiagnosticbulk_inst
type(waterfluxbulk_type) , intent(inout) :: waterfluxbulk_inst
type(soilstate_type) , intent(inout) :: soilstate_inst
type(solarabs_type) , intent(inout) :: solarabs_inst
type(energyflux_type) , intent(inout) :: energyflux_inst
type(temperature_type) , intent(inout) :: temperature_inst
!
! !LOCAL VARIABLES:
integer :: j,c,l,g ! indices
integer :: fc, fp ! lake filtered column & patch indices
integer :: fl ! urban filtered landunit indices
integer :: jtop(bounds%begc:bounds%endc) ! top level at each column
real(r8) :: dtime ! land model time step (sec)
real(r8) :: cv (bounds%begc:bounds%endc,-nlevsno+1:nlevmaxurbgrnd) ! heat capacity [J/(m2 K)]
real(r8) :: tk (bounds%begc:bounds%endc,-nlevsno+1:nlevmaxurbgrnd) ! thermal conductivity [W/(m K)]
real(r8) :: fn (bounds%begc:bounds%endc,-nlevsno+1:nlevmaxurbgrnd) ! heat diffusion through the layer interface [W/m2]
real(r8) :: fn1(bounds%begc:bounds%endc,-nlevsno+1:nlevmaxurbgrnd) ! heat diffusion through the layer interface [W/m2]
real(r8) :: dzm ! used in computing tridiagonal matrix
real(r8) :: dzp ! used in computing tridiagonal matrix
real(r8) :: sabg_lyr_col(bounds%begc:bounds%endc,-nlevsno+1:1) ! absorbed solar radiation (col,lyr) [W/m2]
real(r8) :: eflx_gnet_top ! net energy flux into surface layer, patch-level [W/m2]
real(r8) :: hs_top(bounds%begc:bounds%endc) ! net energy flux into surface layer (col) [W/m2]
logical :: cool_on(bounds%begl:bounds%endl) ! is urban air conditioning on?
logical :: heat_on(bounds%begl:bounds%endl) ! is urban heating on?
real(r8) :: fn_h2osfc(bounds%begc:bounds%endc) ! heat diffusion through standing-water/soil interface [W/m2]
real(r8) :: dz_h2osfc(bounds%begc:bounds%endc) ! height of standing surface water [m]
integer, parameter :: nband=5
real(r8) :: bmatrix(bounds%begc:bounds%endc,nband,-nlevsno:nlevmaxurbgrnd) ! banded matrix for numerical solution of temperature
real(r8) :: tvector(bounds%begc:bounds%endc,-nlevsno:nlevmaxurbgrnd) ! initial temperature solution [K]
real(r8) :: rvector(bounds%begc:bounds%endc,-nlevsno:nlevmaxurbgrnd) ! RHS vector for numerical solution of temperature
real(r8) :: tk_h2osfc(bounds%begc:bounds%endc) ! thermal conductivity of h2osfc [W/(m K)] [col]
real(r8) :: dhsdT(bounds%begc:bounds%endc) ! temperature derivative of "hs" [col]
real(r8) :: hs_soil(bounds%begc:bounds%endc) ! heat flux on soil [W/m2]
real(r8) :: hs_top_snow(bounds%begc:bounds%endc) ! heat flux on top snow layer [W/m2]
real(r8) :: hs_h2osfc(bounds%begc:bounds%endc) ! heat flux on standing water [W/m2]
integer :: jbot(bounds%begc:bounds%endc) ! bottom level at each column
real(r8) :: dz_0(bounds%begc:bounds%endc,-nlevsno+1:nlevmaxurbgrnd) ! original layer thickness [m]
real(r8) :: z_0(bounds%begc:bounds%endc,-nlevsno+1:nlevmaxurbgrnd) ! original layer depth [m]
real(r8) :: zi_0(bounds%begc:bounds%endc,-nlevsno+0:nlevmaxurbgrnd) ! original layer interface level bellow layer "z" [m]
!-----------------------------------------------------------------------
associate( &
snl => col%snl , & ! Input: [integer (:) ] number of snow layers
zi => col%zi , & ! Input: [real(r8) (:,:) ] interface level below a "z" level (m)
dz => col%dz , & ! Input: [real(r8) (:,:) ] layer depth (m)
z => col%z , & ! Input: [real(r8) (:,:) ] layer thickness (m)
ctype => col%itype , & ! Input: [integer (:) ] column type
t_building_max => urbantv_inst%t_building_max , & ! Input: [real(r8) (:) ] maximum internal building air temperature [K]
t_building_min => urbanparams_inst%t_building_min , & ! Input: [real(r8) (:) ] minimum internal building air temperature [K]
forc_lwrad => atm2lnd_inst%forc_lwrad_downscaled_col , & ! Input: [real(r8) (:) ] downward infrared (longwave) radiation (W/m**2)
frac_veg_nosno => canopystate_inst%frac_veg_nosno_patch , & ! Input: [integer (:) ] fraction of vegetation not covered by snow (0 OR 1) [-]
frac_sno_eff => waterdiagnosticbulk_inst%frac_sno_eff_col , & ! Input: [real(r8) (:) ] eff. fraction of ground covered by snow (0 to 1)
snow_depth => waterdiagnosticbulk_inst%snow_depth_col , & ! Input: [real(r8) (:) ] snow height (m)
h2osfc => waterstatebulk_inst%h2osfc_col , & ! Input: [real(r8) (:) ] surface water (mm)
excess_ice => waterstatebulk_inst%excess_ice_col , & ! Input: [real(r8) (:,:) ] excess ice (kg/m2) (new) (1:nlevgrnd)
frac_h2osfc => waterdiagnosticbulk_inst%frac_h2osfc_col , & ! Input: [real(r8) (:) ] fraction of ground covered by surface water (0 to 1)
sabg_soil => solarabs_inst%sabg_soil_patch , & ! Input: [real(r8) (:) ] solar radiation absorbed by soil (W/m**2)
sabg_snow => solarabs_inst%sabg_snow_patch , & ! Input: [real(r8) (:) ] solar radiation absorbed by snow (W/m**2)
sabg_chk => solarabs_inst%sabg_chk_patch , & ! Output: [real(r8) (:) ] sum of soil/snow using current fsno, for balance check
sabg_lyr => solarabs_inst%sabg_lyr_patch , & ! Input: [real(r8) (:,:) ] absorbed solar radiation (pft,lyr) [W/m2]
sabg => solarabs_inst%sabg_patch , & ! Input: [real(r8) (:) ] solar radiation absorbed by ground (W/m**2)
htvp => energyflux_inst%htvp_col , & ! Input: [real(r8) (:) ] latent heat of vapor of water (or sublimation) [j/kg]
cgrnd => energyflux_inst%cgrnd_patch , & ! Input: [real(r8) (:) ] deriv. of soil energy flux wrt to soil temp [w/m2/k]
dlrad => energyflux_inst%dlrad_patch , & ! Input: [real(r8) (:) ] downward longwave radiation blow the canopy [W/m2]
eflx_sh_grnd => energyflux_inst%eflx_sh_grnd_patch , & ! Input: [real(r8) (:) ] sensible heat flux from ground (W/m**2) [+ to atm]
eflx_lwrad_net => energyflux_inst%eflx_lwrad_net_patch , & ! Input: [real(r8) (:) ] net infrared (longwave) rad (W/m**2) [+ = to atm]
eflx_sh_snow => energyflux_inst%eflx_sh_snow_patch , & ! Input: [real(r8) (:) ] sensible heat flux from snow (W/m**2) [+ to atm]
eflx_sh_soil => energyflux_inst%eflx_sh_soil_patch , & ! Input: [real(r8) (:) ] sensible heat flux from soil (W/m**2) [+ to atm]
eflx_sh_h2osfc => energyflux_inst%eflx_sh_h2osfc_patch , & ! Input: [real(r8) (:) ] sensible heat flux from surface water (W/m**2) [+ to atm]
eflx_bot => energyflux_inst%eflx_bot_col , & ! Input: [real(r8) (:) ] heat flux from beneath column (W/m**2) [+ = upward]
eflx_fgr12 => energyflux_inst%eflx_fgr12_col , & ! Output: [real(r8) (:) ] heat flux between soil layer 1 and 2 (W/m2)
eflx_fgr => energyflux_inst%eflx_fgr_col , & ! Output: [real(r8) (:,:) ] (rural) soil downward heat flux (W/m2) (1:nlevgrnd)
eflx_traffic => energyflux_inst%eflx_traffic_lun , & ! Input: [real(r8) (:) ] traffic sensible heat flux (W/m**2)
eflx_traffic_patch => energyflux_inst%eflx_traffic_patch , & ! Input: [real(r8) (:) ] traffic sensible heat flux (W/m**2)
eflx_wasteheat => energyflux_inst%eflx_wasteheat_lun , & ! Input: [real(r8) (:) ] sensible heat flux from urban heating/cooling sources of waste heat (W/m**2)
eflx_wasteheat_patch => energyflux_inst%eflx_wasteheat_patch , & ! Input: [real(r8) (:) ] sensible heat flux from urban heating/cooling sources of waste heat (W/m**2)
eflx_heat_from_ac => energyflux_inst%eflx_heat_from_ac_lun , & ! Input: [real(r8) (:) ] sensible heat flux put back into canyon due to removal by AC (W/m**2)
eflx_heat_from_ac_patch => energyflux_inst%eflx_heat_from_ac_patch , & ! Input: [real(r8) (:) ] sensible heat flux put back into canyon due to removal by AC (W/m**2)
eflx_anthro => energyflux_inst%eflx_anthro_patch , & ! Input: [real(r8) (:) ] total anthropogenic heat flux (W/m**2)
dgnetdT => energyflux_inst%dgnetdT_patch , & ! Output: [real(r8) (:) ] temperature derivative of ground net heat flux
eflx_gnet => energyflux_inst%eflx_gnet_patch , & ! Output: [real(r8) (:) ] net ground heat flux into the surface (W/m**2)
eflx_building_heat_errsoi => energyflux_inst%eflx_building_heat_errsoi_col, & ! Output: [real(r8) (:)] heat flux from urban building interior to walls, roof (W/m**2)
eflx_urban_ac_col => energyflux_inst%eflx_urban_ac_col , & ! Output: [real(r8) (:) ] urban air conditioning flux (W/m**2)
eflx_urban_heat_col => energyflux_inst%eflx_urban_heat_col , & ! Output: [real(r8) (:) ] urban heating flux (W/m**2)
emg => temperature_inst%emg_col , & ! Input: [real(r8) (:) ] ground emissivity
tssbef => temperature_inst%t_ssbef_col , & ! Input: [real(r8) (:,:) ] temperature at previous time step [K]
t_h2osfc => temperature_inst%t_h2osfc_col , & ! Output: [real(r8) (:) ] surface water temperature
t_soisno => temperature_inst%t_soisno_col , & ! Output: [real(r8) (:,:) ] soil temperature [K]
t_grnd => temperature_inst%t_grnd_col , & ! Output: [real(r8) (:) ] ground surface temperature [K]
t_building => temperature_inst%t_building_lun , & ! Output: [real(r8) (:) ] internal building air temperature [K]
t_roof_inner => temperature_inst%t_roof_inner_lun , & ! Input: [real(r8) (:) ] roof inside surface temperature [K]
t_sunw_inner => temperature_inst%t_sunw_inner_lun , & ! Input: [real(r8) (:) ] sunwall inside surface temperature [K]
t_shdw_inner => temperature_inst%t_shdw_inner_lun , & ! Input: [real(r8) (:) ] shadewall inside surface temperature [K]
xmf => temperature_inst%xmf_col , & ! Output: [real(r8) (:) ] melting or freezing within a time step [kg/m2]
xmf_h2osfc => temperature_inst%xmf_h2osfc_col , & ! Output: [real(r8) (:) ] latent heat of phase change of surface water [col]
fact => temperature_inst%fact_col , & ! Output: [real(r8) (:) ] used in computing tridiagonal matrix [col, lev]
c_h2osfc => temperature_inst%c_h2osfc_col , & ! Output: [real(r8) (:) ] heat capacity of surface water [col]
begc => bounds%begc , & ! Input: [integer ] beginning column index
endc => bounds%endc & ! Input: [integer ] ending column index
)
! Get step size
dtime = get_step_size_real()
if ( IsSimpleBuildTemp() ) call BuildingHAC( bounds, num_urbanl, &
filter_urbanl, temperature_inst, &
urbanparams_inst, urbantv_inst, &
cool_on, heat_on )
! set up compact matrix for band diagonal solver, requires additional
! sub/super diagonals (1 each), and one additional row for t_h2osfc
jtop = -9999
do fc = 1,num_nolakec
c = filter_nolakec(fc)
jtop(c) = snl(c)
! compute jbot
if ((col%itype(c) == icol_sunwall .or. col%itype(c) == icol_shadewall &
.or. col%itype(c) == icol_roof) ) then
jbot(c) = nlevurb
else
jbot(c) = nlevgrnd
endif
end do
!--------------------------------------------------------------
! Vertical coordinates adjustment for excess ice calculations
!--------------------------------------------------------------
if ( use_excess_ice ) then
! Save original soil depth to get put them back in et the end
dz_0(begc:endc,-nlevsno+1:nlevmaxurbgrnd) = dz(begc:endc,-nlevsno+1:nlevmaxurbgrnd)
zi_0(begc:endc,-nlevsno+0:nlevmaxurbgrnd) = zi(begc:endc,-nlevsno+0:nlevmaxurbgrnd)
z_0(begc:endc,-nlevsno+1:nlevmaxurbgrnd) = z(begc:endc,-nlevsno+1:nlevmaxurbgrnd)
! Adjust column depth for excess ice thickness
do fc = 1, num_nolakec
c = filter_nolakec(fc)
l = col%landunit(c)
if (lun%itype(l) == istsoil .or. lun%itype(l) == istcrop) then
dz(c,1:nlevmaxurbgrnd) = dz(c,1:nlevmaxurbgrnd) + excess_ice(c,1:nlevmaxurbgrnd) / denice ! add extra layer thickness
do j = 1, nlevmaxurbgrnd ! if excess ice amount dropped to zero there will be no adjustment
zi(c,j) = zi(c,j) + sum(excess_ice(c,1:j)) / denice
z(c,j) = (zi(c,j-1) + zi(c,j)) * 0.5_r8
end do
end if
end do
end if
!------------------------------------------------------
! Compute ground surface and soil temperatures
!------------------------------------------------------
! Thermal conductivity and Heat capacity
tk_h2osfc(begc:endc) = nan
call SoilThermProp(bounds, num_urbanc, filter_urbanc, num_nolakec, filter_nolakec, &
tk(begc:endc, :), &
cv(begc:endc, :), &
tk_h2osfc(begc:endc), &
urbanparams_inst, temperature_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, soilstate_inst)
! Net ground heat flux into the surface and its temperature derivative
! Added a patches loop here to get the average of hs and dhsdT over
! all Patches on the column. Precalculate the terms that do not depend on PFT.
call ComputeGroundHeatFluxAndDeriv(bounds, &
num_nolakep, filter_nolakep, num_nolakec, filter_nolakec, &
hs_h2osfc( begc:endc ), &
hs_top_snow( begc:endc ), &
hs_soil( begc:endc ), &
hs_top( begc:endc ), &
dhsdT( begc:endc ), &
sabg_lyr_col( begc:endc, -nlevsno+1: ), &
atm2lnd_inst, urbanparams_inst, canopystate_inst, waterdiagnosticbulk_inst, &
waterfluxbulk_inst, solarabs_inst, energyflux_inst, temperature_inst)
! Determine heat diffusion through the layer interface and factor used in computing
! banded diagonal matrix and set up vector r and vectors a, b, c that define banded
! diagonal matrix and solve system
call ComputeHeatDiffFluxAndFactor(bounds, num_nolakec, filter_nolakec, &
dtime, &
tk( begc:endc, -nlevsno+1: ), &
cv( begc:endc, -nlevsno+1: ), &
fn( begc:endc, -nlevsno+1: ), &
fact( begc:endc, -nlevsno+1: ), &
energyflux_inst, temperature_inst)
! compute thermal properties of h2osfc
do fc = 1,num_nolakec
c = filter_nolakec(fc)
if ( (h2osfc(c) > thin_sfclayer) .and. (frac_h2osfc(c) > thin_sfclayer) ) then
c_h2osfc(c) = max(thin_sfclayer, cpliq*h2osfc(c)/frac_h2osfc(c) )
dz_h2osfc(c) = max(thin_sfclayer, 1.0e-3*h2osfc(c)/frac_h2osfc(c) )
else
c_h2osfc(c) = thin_sfclayer
dz_h2osfc(c) = thin_sfclayer
endif
enddo
! Set up right-hand side vecor (vector r).
call SetRHSVec(bounds, num_nolakec, filter_nolakec, &
dtime, &
hs_h2osfc( begc:endc ), &
hs_top_snow( begc:endc ), &
hs_soil( begc:endc ), &
hs_top( begc:endc ), &
dhsdT( begc:endc ), &
sabg_lyr_col (begc:endc, -nlevsno+1: ), &
tk( begc:endc, -nlevsno+1: ), &
tk_h2osfc( begc:endc ), &
fact( begc:endc, -nlevsno+1: ), &
fn( begc:endc, -nlevsno+1: ), &
c_h2osfc( begc:endc ), &
dz_h2osfc( begc:endc ), &
temperature_inst, &
waterdiagnosticbulk_inst, &
rvector( begc:endc, -nlevsno: ))
! Set up the banded diagonal matrix
call SetMatrix(bounds, num_nolakec, filter_nolakec, &
dtime, &
nband, &
dhsdT( begc:endc ), &
tk( begc:endc, -nlevsno+1: ), &
tk_h2osfc( begc:endc ), &
fact( begc:endc, -nlevsno+1: ), &
c_h2osfc( begc:endc ), &
dz_h2osfc( begc:endc ), &
waterdiagnosticbulk_inst, &
bmatrix( begc:endc, 1:, -nlevsno: ))
! initialize initial temperature vector
tvector(begc:endc, :) = nan
do fc = 1,num_nolakec
c = filter_nolakec(fc)
do j = snl(c)+1, 0
tvector(c,j-1) = t_soisno(c,j)
end do
! surface water layer has two coefficients
tvector(c,0) = t_h2osfc(c)
! soil layers; top layer will have one offset and one extra coefficient
tvector(c,1:nlevmaxurbgrnd) = t_soisno(c,1:nlevmaxurbgrnd)
enddo
call t_startf( 'SoilTempBandDiag')
! Solve the system
call BandDiagonal(bounds, -nlevsno, nlevmaxurbgrnd, jtop(begc:endc), jbot(begc:endc), &
num_nolakec, filter_nolakec, nband, bmatrix(begc:endc, :, :), &
rvector(begc:endc, :), tvector(begc:endc, :))
call t_stopf( 'SoilTempBandDiag')
! return temperatures to original array
do fc = 1,num_nolakec
c = filter_nolakec(fc)
do j = snl(c)+1, 0
t_soisno(c,j) = tvector(c,j-1) !snow layers
end do
t_soisno(c,1:nlevmaxurbgrnd) = tvector(c,1:nlevmaxurbgrnd) !soil layers
if (frac_h2osfc(c) == 0._r8) then
t_h2osfc(c)=t_soisno(c,1)
else
t_h2osfc(c) = tvector(c,0) !surface water
endif
enddo
! Melting or Freezing
do j = -nlevsno+1,nlevmaxurbgrnd
do fc = 1,num_nolakec
c = filter_nolakec(fc)
l = col%landunit(c)
if ((col%itype(c) == icol_sunwall .or. col%itype(c) == icol_shadewall &
.or. col%itype(c) == icol_roof) .and. j <= nlevurb) then
if (j >= snl(c)+1) then
if (j <= nlevurb-1) then
fn1(c,j) = tk(c,j)*(t_soisno(c,j+1)-t_soisno(c,j))/(z(c,j+1)-z(c,j))
else if (j == nlevurb) then
! For urban sunwall, shadewall, and roof columns, there is a non-zero heat flux across
if ( IsSimpleBuildTemp() )then
! the bottom "soil" layer and the equations are derived assuming a prescribed internal
! building temperature. (See Oleson urban notes of 6/18/03).
! Note new formulation for fn, this will be used below in net energey flux computations
fn1(c,j) = tk(c,j) * (t_building(l) - t_soisno(c,j))/(zi(c,j) - z(c,j))
fn(c,j) = tk(c,j) * (t_building(l) - tssbef(c,j))/(zi(c,j) - z(c,j))
else
! the bottom "soil" layer and the equations are derived assuming a prognostic inner
! surface temperature.
if (ctype(c) == icol_sunwall) then
fn1(c,j) = tk(c,j) * (t_sunw_inner(l) - t_soisno(c,j))/(zi(c,j) - z(c,j))
fn(c,j) = tk(c,j) * (t_sunw_inner(l) - tssbef(c,j))/(zi(c,j) - z(c,j))
else if (ctype(c) == icol_shadewall) then
fn1(c,j) = tk(c,j) * (t_shdw_inner(l) - t_soisno(c,j))/(zi(c,j) - z(c,j))
fn(c,j) = tk(c,j) * (t_shdw_inner(l) - tssbef(c,j))/(zi(c,j) - z(c,j))
else if (ctype(c) == icol_roof) then
fn1(c,j) = tk(c,j) * (t_roof_inner(l) - t_soisno(c,j))/(zi(c,j) - z(c,j))
fn(c,j) = tk(c,j) * (t_roof_inner(l) - tssbef(c,j))/(zi(c,j) - z(c,j))
end if
end if
end if
end if
else if (col%itype(c) /= icol_sunwall .and. col%itype(c) /= icol_shadewall &
.and. col%itype(c) /= icol_roof) then
if (j >= snl(c)+1) then
if (j <= nlevgrnd-1) then
fn1(c,j) = tk(c,j)*(t_soisno(c,j+1)-t_soisno(c,j))/(z(c,j+1)-z(c,j))
else if (j == nlevgrnd) then
fn1(c,j) = 0._r8
end if
end if
end if
end do
end do
do fc = 1,num_nolakec
c = filter_nolakec(fc)
l = col%landunit(c)
if (lun%urbpoi(l)) then
if (col%itype(c) == icol_sunwall .or. col%itype(c) == icol_shadewall .or. col%itype(c) == icol_roof) then
eflx_building_heat_errsoi(c) = cnfac*fn(c,nlevurb) + (1._r8-cnfac)*fn1(c,nlevurb)
else
eflx_building_heat_errsoi(c) = 0._r8
end if
if ( IsSimpleBuildTemp() )then
if (cool_on(l)) then
eflx_urban_ac_col(c) = abs(eflx_building_heat_errsoi(c))
eflx_urban_heat_col(c) = 0._r8
else if (heat_on(l)) then
eflx_urban_ac_col(c) = 0._r8
eflx_urban_heat_col(c) = abs(eflx_building_heat_errsoi(c))
else
eflx_urban_ac_col(c) = 0._r8
eflx_urban_heat_col(c) = 0._r8
end if
end if
end if
end do
! compute phase change of h2osfc
do fc = 1,num_nolakec
c = filter_nolakec(fc)
xmf_h2osfc(c) = 0.
end do
call PhaseChangeH2osfc (bounds, num_nolakec, filter_nolakec, &
dhsdT(bounds%begc:bounds%endc), &
waterstatebulk_inst, waterdiagnosticbulk_inst, waterfluxbulk_inst, temperature_inst,energyflux_inst)
call Phasechange_beta (bounds, num_nolakec, filter_nolakec, &
dhsdT(bounds%begc:bounds%endc), &
soilstate_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, waterfluxbulk_inst, energyflux_inst, temperature_inst)
!--------------------------------------------------------------
! Vertical coordinates adjustment for excess ice calculations
!--------------------------------------------------------------
! bringing back the soil depth to the original state
if (use_excess_ice) then
! Adjust column depth for excess ice thickness
do fc = 1, num_nolakec
c = filter_nolakec(fc)
l = col%landunit(c)
if (lun%itype(l) == istsoil .or. lun%itype(l) == istcrop) then
dz(c,1:nlevmaxurbgrnd)=dz_0(c,1:nlevmaxurbgrnd)
zi(c,1:nlevmaxurbgrnd)=zi_0(c,1:nlevmaxurbgrnd)
z(c,1:nlevmaxurbgrnd)=z_0(c,1:nlevmaxurbgrnd)
end if
end do
end if
if ( IsProgBuildTemp() )then
call BuildingTemperature(bounds, num_urbanl, filter_urbanl, num_nolakec, filter_nolakec, &
tk(bounds%begc:bounds%endc, :), urbanparams_inst, &
temperature_inst, energyflux_inst, urbantv_inst, atm2lnd_inst)
end if
do fc = 1,num_nolakec
c = filter_nolakec(fc)
! this expression will (should) work whether there is snow or not
if (snl(c) < 0) then
if(frac_h2osfc(c) /= 0._r8) then
t_grnd(c) = frac_sno_eff(c) * t_soisno(c,snl(c)+1) &
+ (1.0_r8 - frac_sno_eff(c) - frac_h2osfc(c)) * t_soisno(c,1) &
+ frac_h2osfc(c) * t_h2osfc(c)
else
t_grnd(c) = frac_sno_eff(c) * t_soisno(c,snl(c)+1) &
+ (1.0_r8 - frac_sno_eff(c)) * t_soisno(c,1)
end if
else
if(frac_h2osfc(c) /= 0._r8) then
t_grnd(c) = (1._r8 - frac_h2osfc(c)) * t_soisno(c,1) + frac_h2osfc(c) * t_h2osfc(c)
else
t_grnd(c) = t_soisno(c,1)
end if
endif
end do
! Initialize soil heat content
do fc = 1,num_nolakec
c = filter_nolakec(fc)
l = col%landunit(c)
eflx_fgr12(c)= 0._r8
end do
! Calculate soil heat content and soil plus snow heat content
do j = -nlevsno+1,nlevgrnd
do fc = 1,num_nolakec
c = filter_nolakec(fc)
l = col%landunit(c)
if (j == 1) then ! this only needs to be done once
eflx_fgr12(c) = -cnfac*fn(c,1) - (1._r8-cnfac)*fn1(c,1)
end if
if (j > 0 .and. j < nlevgrnd .and. (lun%itype(l) == istsoil .or. lun%itype(l) == istcrop)) then
eflx_fgr(c,j) = -cnfac*fn(c,j) - (1._r8-cnfac)*fn1(c,j)
else if (j == nlevgrnd .and. (lun%itype(l) == istsoil .or. lun%itype(l) == istcrop)) then
eflx_fgr(c,j) = 0._r8
end if
end do
end do
end associate
end subroutine SoilTemperature
!-----------------------------------------------------------------------
subroutine SoilThermProp (bounds, num_urbanc, filter_urbanc, num_nolakec, filter_nolakec, &
tk, cv, tk_h2osfc, &
urbanparams_inst, temperature_inst, waterstatebulk_inst, waterdiagnosticbulk_inst, soilstate_inst)
!
! !DESCRIPTION:
! Calculation of thermal conductivities and heat capacities of
! snow/soil layers
! (1) The volumetric heat capacity is calculated as a linear combination
! in terms of the volumetric fraction of the constituent phases.
!
! (2) The thermal conductivity of soil is computed from the algorithm of
! Johansen (as reported by Farouki 1981), and of snow is from the
! formulation used in Sturm (1997) or Jordan (1991) p. 18 depending on
! namelist option.
! The thermal conductivities at the interfaces between two neighboring
! layers (j, j+1) are derived from an assumption that the flux across
! the interface is equal to that from the node j to the interface and the
! flux from the interface to the node j+1.
!
! !USES:
use shr_log_mod , only : errMsg => shr_log_errMsg
use clm_varpar , only : nlevsno, nlevgrnd, nlevurb, nlevsoi, nlevmaxurbgrnd
use clm_varcon , only : denh2o, denice, tfrz, tkwat, tkice, tkair, cpice, cpliq, thk_bedrock, csol_bedrock
use landunit_varcon , only : istice, istwet
use column_varcon , only : icol_roof, icol_sunwall, icol_shadewall, icol_road_perv, icol_road_imperv
use clm_varctl , only : iulog, snow_thermal_cond_method
!
! !ARGUMENTS:
type(bounds_type) , intent(in) :: bounds
integer , intent(in) :: num_urbanc ! number of urban columns in clump
integer , intent(in) :: filter_urbanc(:) ! urban column filter
integer , intent(in) :: num_nolakec ! number of column non-lake points in column filter
integer , intent(in) :: filter_nolakec(:) ! column filter for non-lake points
real(r8) , intent(out) :: cv( bounds%begc: , -nlevsno+1: ) ! heat capacity [J/(m2 K) ] [col, lev]
real(r8) , intent(out) :: tk( bounds%begc: , -nlevsno+1: ) ! thermal conductivity at the layer interface [W/(m K) ] [col, lev]
real(r8) , intent(out) :: tk_h2osfc( bounds%begc: ) ! thermal conductivity of h2osfc [W/(m K) ] [col]
type(urbanparams_type) , intent(in) :: urbanparams_inst
type(temperature_type) , intent(in) :: temperature_inst
type(waterstatebulk_type) , intent(inout) :: waterstatebulk_inst
type(waterdiagnosticbulk_type) , intent(inout) :: waterdiagnosticbulk_inst
type(soilstate_type) , intent(inout) :: soilstate_inst
!
! !LOCAL VARIABLES:
integer :: l,c,j ! indices
integer :: fc ! lake filtered column indices
real(r8) :: dksat ! thermal conductivity for saturated soil (j/(k s m))
real(r8) :: dke ! kersten number
real(r8) :: fl ! volume fraction of liquid or unfrozen water to total water
real(r8) :: satw ! relative total water content of soil.
real(r8) :: zh2osfc
character(len=*),parameter :: subname = 'SoilThermProp'
!-----------------------------------------------------------------------
call t_startf( 'SoilThermProp' )
! Enforce expected array sizes
SHR_ASSERT_ALL_FL((ubound(cv) == (/bounds%endc, nlevmaxurbgrnd/)), sourcefile, __LINE__)
SHR_ASSERT_ALL_FL((ubound(tk) == (/bounds%endc, nlevmaxurbgrnd/)), sourcefile, __LINE__)
SHR_ASSERT_ALL_FL((ubound(tk_h2osfc) == (/bounds%endc/)), sourcefile, __LINE__)
associate( &
nbedrock => col%nbedrock , & ! Input: [real(r8) (:,:) ] depth to bedrock (m)
snl => col%snl , & ! Input: [integer (:) ] number of snow layers
dz => col%dz , & ! Input: [real(r8) (:,:) ] layer depth (m)
zi => col%zi , & ! Input: [real(r8) (:,:) ] interface level below a "z" level (m)
z => col%z , & ! Input: [real(r8) (:,:) ] layer thickness (m)
nlev_improad => urbanparams_inst%nlev_improad , & ! Input: [integer (:) ] number of impervious road layers
tk_wall => urbanparams_inst%tk_wall , & ! Input: [real(r8) (:,:) ] thermal conductivity of urban wall
tk_roof => urbanparams_inst%tk_roof , & ! Input: [real(r8) (:,:) ] thermal conductivity of urban roof
tk_improad => urbanparams_inst%tk_improad , & ! Input: [real(r8) (:,:) ] thermal conductivity of urban impervious road
cv_wall => urbanparams_inst%cv_wall , & ! Input: [real(r8) (:,:) ] heat capacity of urban wall
cv_roof => urbanparams_inst%cv_roof , & ! Input: [real(r8) (:,:) ] heat capacity of urban roof
cv_improad => urbanparams_inst%cv_improad , & ! Input: [real(r8) (:,:) ] heat capacity of urban impervious road
t_soisno => temperature_inst%t_soisno_col , & ! Input: [real(r8) (:,:) ] soil temperature [K]
frac_sno => waterdiagnosticbulk_inst%frac_sno_eff_col , & ! Input: [real(r8) (:) ] fractional snow covered area
h2osfc => waterstatebulk_inst%h2osfc_col , & ! Input: [real(r8) (:) ] surface (mm H2O)
h2osno_no_layers => waterstatebulk_inst%h2osno_no_layers_col , & ! Input: [real(r8) (:) ] snow not resolved into layers (mm H2O)
h2osoi_liq => waterstatebulk_inst%h2osoi_liq_col , & ! Input: [real(r8) (:,:) ] liquid water (kg/m2)
h2osoi_ice => waterstatebulk_inst%h2osoi_ice_col , & ! Input: [real(r8) (:,:) ] ice lens (kg/m2)
excess_ice => waterstatebulk_inst%excess_ice_col , & ! Input: [real(r8) (:,:) ] excess ice lenses (kg/m2) (new) (1:nlevgrnd)
bw => waterdiagnosticbulk_inst%bw_col , & ! Output: [real(r8) (:,:) ] partial density of water in the snow pack (ice + liquid) [kg/m3]
tkmg => soilstate_inst%tkmg_col , & ! Input: [real(r8) (:,:) ] thermal conductivity, soil minerals [W/m-K]
tkdry => soilstate_inst%tkdry_col , & ! Input: [real(r8) (:,:) ] thermal conductivity, dry soil (W/m/K)
csol => soilstate_inst%csol_col , & ! Input: [real(r8) (:,:) ] heat capacity, soil solids (J/m**3/K)
watsat => soilstate_inst%watsat_col , & ! Input: [real(r8) (:,:) ] volumetric soil water at saturation (porosity)
tksatu => soilstate_inst%tksatu_col , & ! Input: [real(r8) (:,:) ] thermal conductivity, saturated soil [W/m-K]
thk => soilstate_inst%thk_col & ! Output: [real(r8) (:,:) ] thermal conductivity of each layer [W/m-K]
)
! Thermal conductivity of soil from Farouki (1981)
do j = -nlevsno+1,nlevgrnd
do fc = 1, num_nolakec
c = filter_nolakec(fc)
! Only examine levels from 1->nlevgrnd
if (j >= 1) then
l = col%landunit(c)
! This will include pervious road for all nlevgrnd layers and impervious road for j > nlev_improad
if ((lun%itype(l) /= istwet .and. lun%itype(l) /= istice &
.and. col%itype(c) /= icol_sunwall .and. col%itype(c) /= icol_shadewall .and. &
col%itype(c) /= icol_roof .and. col%itype(c) /= icol_road_imperv) .or. &
(col%itype(c) == icol_road_imperv .and. j > nlev_improad(l))) then
satw = (h2osoi_liq(c,j)/denh2o + h2osoi_ice(c,j)/denice +excess_ice(c,j)/denice)/(dz(c,j)*watsat(c,j))
satw = min(1._r8, satw)
if (satw > .1e-6_r8) then
if (t_soisno(c,j) >= tfrz) then ! Unfrozen soil
dke = max(0._r8, log10(satw) + 1.0_r8)
else ! Frozen soil
dke = satw
end if
fl = (h2osoi_liq(c,j)/(denh2o*dz(c,j))) / (h2osoi_liq(c,j)/(denh2o*dz(c,j)) + &
h2osoi_ice(c,j)/(denice*dz(c,j))+excess_ice(c,j)/(denice*dz(c,j)))
dksat = tkmg(c,j)*tkwat**(fl*watsat(c,j))*tkice**((1._r8-fl)*watsat(c,j))
thk(c,j) = dke*dksat + (1._r8-dke)*tkdry(c,j)
else
thk(c,j) = tkdry(c,j)
endif
if (j > nbedrock(c)) thk(c,j) = thk_bedrock
else if (lun%itype(l) == istice) then
thk(c,j) = tkwat
if (t_soisno(c,j) < tfrz) thk(c,j) = tkice
else if (lun%itype(l) == istwet) then
if (j > nlevsoi) then
thk(c,j) = thk_bedrock
else
thk(c,j) = tkwat
if (t_soisno(c,j) < tfrz) thk(c,j) = tkice
endif
endif
endif
! Thermal conductivity of snow
! Only examine levels from snl(c)+1 -> 0 where snl(c) < 1
if (snl(c)+1 < 1 .AND. (j >= snl(c)+1) .AND. (j <= 0)) then
bw(c,j) = (h2osoi_ice(c,j)+h2osoi_liq(c,j))/(frac_sno(c)*dz(c,j))
l = col%landunit(c)
! hard code to Jordan over glacier land unit
if (lun%itype(l) == istice) then
thk(c,j) = tkair + (7.75e-5_r8 *bw(c,j) + 1.105e-6_r8*bw(c,j)*bw(c,j))*(tkice-tkair)
else
select case (snow_thermal_cond_method)
case ('Jordan1991')
thk(c,j) = tkair + (7.75e-5_r8 *bw(c,j) + 1.105e-6_r8*bw(c,j)*bw(c,j))*(tkice-tkair)
case ('Sturm1997')
! Implemented by Vicky Dutch (VRD), Nick Rutter, and
! Leanne Wake (LMW)
! https://tc.copernicus.org/articles/16/4201/2022/
! See also https://tc.copernicus.org/articles/19/1539/2025/
! Code provided by Adrien Dams to Will Wieder
if (bw(c,j) <= 156) then !LMW or 0.156 ?
thk(c,j) = 0.023 + 0.234*(bw(c,j)/1000) !LMW - units changed by VRD
else !LMW
thk(c,j) = 0.138 - 1.01*(bw(c,j)/1000) +(3.233*((bw(c,j)/1000)*(bw(c,j)/1000))) ! LMW Sturm I think
end if
case default
write(iulog,*) subname//' ERROR: unknown snow_thermal_cond_method value: ', snow_thermal_cond_method
call endrun(msg=errMsg(sourcefile, __LINE__))
end select
end if ! close land unit if statement
end if
end do
end do
do j = 1,nlevurb
do fc = 1, num_urbanc
c = filter_urbanc(fc)
l = col%landunit(c)
if (col%itype(c) == icol_sunwall .or. col%itype(c) == icol_shadewall) then
thk(c,j) = tk_wall(l,j)
else if (col%itype(c) == icol_roof) then
thk(c,j) = tk_roof(l,j)
else if (col%itype(c) == icol_road_imperv .and. j <= nlev_improad(l)) then
thk(c,j) = tk_improad(l,j)
end if
end do
end do
! Thermal conductivity at the layer interface
do j = -nlevsno+1,nlevmaxurbgrnd
do fc = 1,num_nolakec
c = filter_nolakec(fc)
if ((col%itype(c) == icol_sunwall .or. col%itype(c) == icol_shadewall &
.or. col%itype(c) == icol_roof) .and. j <= nlevurb) then
if (j >= snl(c)+1 .AND. j <= nlevurb-1) then
tk(c,j) = thk(c,j)*thk(c,j+1)*(z(c,j+1)-z(c,j)) &
/(thk(c,j)*(z(c,j+1)-zi(c,j))+thk(c,j+1)*(zi(c,j)-z(c,j)))
else if (j == nlevurb) then
! For urban sunwall, shadewall, and roof columns, there is a non-zero heat flux across
! the bottom "soil" layer and the equations are derived assuming a prescribed internal
! building temperature. (See Oleson urban notes of 6/18/03).
tk(c,j) = thk(c,j)
end if
else if (col%itype(c) /= icol_sunwall .and. col%itype(c) /= icol_shadewall &
.and. col%itype(c) /= icol_roof) then
if (j >= snl(c)+1 .AND. j <= nlevgrnd-1) then
tk(c,j) = thk(c,j)*thk(c,j+1)*(z(c,j+1)-z(c,j)) &
/(thk(c,j)*(z(c,j+1)-zi(c,j))+thk(c,j+1)*(zi(c,j)-z(c,j)))
else if (j == nlevgrnd) then
tk(c,j) = 0._r8
end if
end if
end do
end do
! calculate thermal conductivity of h2osfc
do fc = 1, num_nolakec
c = filter_nolakec(fc)
zh2osfc=1.0e-3*(0.5*h2osfc(c)) !convert to [m] from [mm]
tk_h2osfc(c)= tkwat*thk(c,1)*(z(c,1)+zh2osfc) &
/(tkwat*z(c,1)+thk(c,1)*zh2osfc)
enddo
! Soil heat capacity, from de Vires (1963)
do j = 1, nlevgrnd
do fc = 1,num_nolakec
c = filter_nolakec(fc)
l = col%landunit(c)
if ((lun%itype(l) /= istwet .and. lun%itype(l) /= istice &
.and. col%itype(c) /= icol_sunwall .and. col%itype(c) /= icol_shadewall .and. &
col%itype(c) /= icol_roof .and. col%itype(c) /= icol_road_imperv) .or. &
(col%itype(c) == icol_road_imperv .and. j > nlev_improad(l))) then
cv(c,j) = csol(c,j)*(1._r8-watsat(c,j))*dz(c,j) + (h2osoi_ice(c,j)*cpice + &
h2osoi_liq(c,j)*cpliq) + excess_ice(c,j)*cpice
if (j > nbedrock(c)) cv(c,j) = csol_bedrock*dz(c,j)
else if (lun%itype(l) == istwet) then
cv(c,j) = (h2osoi_ice(c,j)*cpice + h2osoi_liq(c,j)*cpliq)
if (j > nbedrock(c)) cv(c,j) = csol_bedrock*dz(c,j)
else if (lun%itype(l) == istice) then
cv(c,j) = (h2osoi_ice(c,j)*cpice + h2osoi_liq(c,j)*cpliq)
endif
enddo
end do
do j = 1, nlevurb
do fc = 1,num_urbanc
c = filter_urbanc(fc)
l = col%landunit(c)
if (col%itype(c) == icol_sunwall .or. col%itype(c) == icol_shadewall) then
cv(c,j) = cv_wall(l,j) * dz(c,j)
else if (col%itype(c) == icol_roof) then
cv(c,j) = cv_roof(l,j) * dz(c,j)
else if (col%itype(c) == icol_road_imperv .and. j <= nlev_improad(l)) then
cv(c,j) = cv_improad(l,j) * dz(c,j)
endif
end do
end do
do fc = 1, num_nolakec
c = filter_nolakec(fc)
if (h2osno_no_layers(c) > 0._r8) then
cv(c,1) = cv(c,1) + cpice*h2osno_no_layers(c)
end if
end do
! Snow heat capacity
do j = -nlevsno+1,0
do fc = 1,num_nolakec
c = filter_nolakec(fc)
if (snl(c)+1 < 1 .and. j >= snl(c)+1) then
if (frac_sno(c) > 0._r8) then
cv(c,j) = max(thin_sfclayer,(cpliq*h2osoi_liq(c,j) + cpice*h2osoi_ice(c,j))/frac_sno(c))
else
cv(c,j) = thin_sfclayer
endif
end if
end do
end do
call t_stopf( 'SoilThermProp' )
end associate
end subroutine SoilThermProp
!-----------------------------------------------------------------------
subroutine PhaseChangeH2osfc (bounds, num_nolakec, filter_nolakec, &
dhsdT, waterstatebulk_inst, waterdiagnosticbulk_inst, waterfluxbulk_inst, temperature_inst,energyflux_inst)
!
! !DESCRIPTION:
! Only freezing is considered. When water freezes, move ice to bottom snow layer.
!
! !USES:
use clm_time_manager , only : get_step_size_real
use clm_varcon , only : tfrz, hfus, grav, denice, cnfac, cpice, cpliq
use clm_varpar , only : nlevsno, nlevgrnd
use clm_varctl , only : iulog
!
! !ARGUMENTS:
type(bounds_type) , intent(in) :: bounds
integer , intent(in) :: num_nolakec ! number of column non-lake points in column filter
integer , intent(in) :: filter_nolakec(:) ! column filter for non-lake points
real(r8) , intent(in) :: dhsdT ( bounds%begc: ) ! temperature derivative of "hs" [col ]
type(waterstatebulk_type) , intent(inout) :: waterstatebulk_inst
type(waterdiagnosticbulk_type) , intent(inout) :: waterdiagnosticbulk_inst
type(waterfluxbulk_type) , intent(inout) :: waterfluxbulk_inst
type(temperature_type) , intent(inout) :: temperature_inst
type(energyflux_type) , intent(inout) :: energyflux_inst
!
! !LOCAL VARIABLES:
integer :: j,c,g !do loop index
integer :: fc !lake filtered column indices
real(r8) :: dtime !land model time step (sec)
real(r8) :: temp1 !temporary variables [kg/m2 ]
real(r8) :: h2osno_total(bounds%begc:bounds%endc) ! total snow water (mm H2O)
real(r8) :: hm(bounds%begc:bounds%endc) !energy residual [W/m2 ]
real(r8) :: xm(bounds%begc:bounds%endc) !melting or freezing within a time step [kg/m2 ]
real(r8) :: tinc !t(n+1)-t(n) [K]
real(r8) :: smp !frozen water potential (mm)
real(r8) :: rho_avg !average density
real(r8) :: z_avg !average of snow depth
real(r8) :: c1 !weight to use for lowest snow layer
real(r8) :: c2 !weight to use for surface water layer
!-----------------------------------------------------------------------
call t_startf( 'PhaseChangeH2osfc' )
! Enforce expected array sizes
SHR_ASSERT_ALL_FL((ubound(dhsdT) == (/bounds%endc/)), sourcefile, __LINE__)
associate( &
eflx_h2osfc_to_snow_col => energyflux_inst%eflx_h2osfc_to_snow_col , & ! Output: [real(r8) (:) ] col snow melt to h2osfc heat flux (W/m**2)
snl => col%snl , & ! Input: [integer (:) ] number of snow layers
dz => col%dz , & ! Input: [real(r8) (:,:) ] layer thickness (m)
frac_sno => waterdiagnosticbulk_inst%frac_sno_eff_col , & ! Input: [real(r8) (:) ] fraction of ground covered by snow (0 to 1)
frac_h2osfc => waterdiagnosticbulk_inst%frac_h2osfc_col , & ! Input: [real(r8) (:) ] fraction of ground covered by surface water (0 to 1)
h2osno_no_layers => waterstatebulk_inst%h2osno_no_layers_col , & ! Output: [real(r8) (:) ] snow that is not resolved into layers (mm H2O)
h2osoi_ice => waterstatebulk_inst%h2osoi_ice_col , & ! Input: [real(r8) (:,:) ] ice lens (kg/m2) (new)
h2osfc => waterstatebulk_inst%h2osfc_col , & ! Output: [real(r8) (:) ] surface water (mm)
int_snow => waterstatebulk_inst%int_snow_col , & ! Output: [real(r8) (:) ] integrated snowfall [mm]
snow_depth => waterdiagnosticbulk_inst%snow_depth_col , & ! Output: [real(r8) (:) ] snow height (m)
qflx_h2osfc_to_ice => waterfluxbulk_inst%qflx_h2osfc_to_ice_col , & ! Output: [real(r8) (:) ] conversion of h2osfc to ice
fact => temperature_inst%fact_col , &
c_h2osfc => temperature_inst%c_h2osfc_col , &
xmf_h2osfc => temperature_inst%xmf_h2osfc_col, &
t_soisno => temperature_inst%t_soisno_col , & ! Output: [real(r8) (:,:) ] soil temperature [K]
t_h2osfc => temperature_inst%t_h2osfc_col & ! Output: [real(r8) (:) ] surface water temperature
)
! Get step size
dtime = get_step_size_real()
! Initialization
do fc = 1,num_nolakec
c = filter_nolakec(fc)
xmf_h2osfc(c) = 0._r8
hm(c) = 0._r8
xm(c) = 0._r8
qflx_h2osfc_to_ice(c) = 0._r8
eflx_h2osfc_to_snow_col(c) = 0._r8
end do
call waterstatebulk_inst%CalculateTotalH2osno(bounds, num_nolakec, filter_nolakec, &
caller = 'PhaseChangeH2osfc', &
h2osno_total = h2osno_total(bounds%begc:bounds%endc))
! Freezing identification
do fc = 1,num_nolakec
c = filter_nolakec(fc)
! If liquid exists below melt point, freeze some to ice.
if ( frac_h2osfc(c) > 0._r8 .AND. t_h2osfc(c) <= tfrz) then
tinc = tfrz - t_h2osfc(c)
t_h2osfc(c) = tfrz
! energy absorbed beyond freezing temperature
hm(c) = frac_h2osfc(c)*(dhsdT(c)*tinc - tinc*c_h2osfc(c)/dtime)
! mass of water converted from liquid to ice
xm(c) = hm(c)*dtime/hfus
temp1 = h2osfc(c) + xm(c)
z_avg=frac_sno(c)*snow_depth(c)
if (z_avg > 0._r8) then
rho_avg=min(800._r8,h2osno_total(c)/z_avg)
else
rho_avg=200._r8
endif
!===================== xm < h2osfc ====================================