-
Notifications
You must be signed in to change notification settings - Fork 317
/
CanopyFluxesMod.F90
1669 lines (1428 loc) · 97.8 KB
/
CanopyFluxesMod.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 CanopyFluxesMod
#include "shr_assert.h"
!------------------------------------------------------------------------------
! !DESCRIPTION:
! Performs calculation of leaf temperature and surface fluxes.
! SoilFluxes then determines soil/snow and ground temperatures and updates the surface
! fluxes for the new ground temperature.
!
! !USES:
use shr_sys_mod , only : shr_sys_flush
use shr_kind_mod , only : r8 => shr_kind_r8
use shr_log_mod , only : errMsg => shr_log_errMsg
use abortutils , only : endrun
use clm_varctl , only : iulog, use_cn, use_lch4, use_c13, use_c14, use_cndv, use_fates, &
use_luna, use_hydrstress, use_biomass_heat_storage
use clm_varpar , only : nlevgrnd, nlevsno, nlevcan, mxpft
use pftconMod , only : pftcon
use decompMod , only : bounds_type, subgrid_level_patch
use ActiveLayerMod , only : active_layer_type
use PhotosynthesisMod , only : Photosynthesis, PhotoSynthesisHydraulicStress, PhotosynthesisTotal, Fractionation
use EDAccumulateFluxesMod , only : AccumulateFluxes_ED
use SoilMoistStressMod , only : calc_effective_soilporosity, calc_volumetric_h2oliq
use SoilMoistStressMod , only : calc_root_moist_stress, set_perchroot_opt
use SimpleMathMod , only : array_div_vector
use SurfaceResistanceMod , only : do_soilevap_beta,do_soil_resistance_sl14
use atm2lndType , only : atm2lnd_type
use CanopyStateType , only : canopystate_type
use EnergyFluxType , only : energyflux_type
use FrictionvelocityMod , only : frictionvel_type
use OzoneBaseMod , only : ozone_base_type
use SoilStateType , only : soilstate_type
use SolarAbsorbedType , only : solarabs_type
use SurfaceAlbedoType , only : surfalb_type
use TemperatureType , only : temperature_type
use WaterFluxBulkType , only : waterfluxbulk_type
use WaterStateBulkType , only : waterstatebulk_type
use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type
use Wateratm2lndBulkType , only : wateratm2lndbulk_type
use HumanIndexMod , only : humanindex_type
use ch4Mod , only : ch4_type
use PhotosynthesisMod , only : photosyns_type
use GridcellType , only : grc
use ColumnType , only : col
use PatchType , only : patch
use EDTypesMod , only : ed_site_type
use SoilWaterRetentionCurveMod, only : soil_water_retention_curve_type
use LunaMod , only : Update_Photosynthesis_Capacity, Acc24_Climate_LUNA,Acc240_Climate_LUNA,Clear24_Climate_LUNA
!
! !PUBLIC TYPES:
implicit none
!
! !PUBLIC MEMBER FUNCTIONS:
public :: CanopyFluxesReadNML ! Read in namelist settings
public :: CanopyFluxes ! Calculate canopy fluxes
public :: readParams
type, private :: params_type
real(r8) :: lai_dl ! Plant litter area index (m2/m2)
real(r8) :: z_dl ! Litter layer thickness (m)
real(r8) :: a_coef ! Drag coefficient under less dense canopy (unitless)
real(r8) :: a_exp ! Drag exponent under less dense canopy (unitless)
real(r8) :: csoilc ! Soil drag coefficient under dense canopy (unitless)
real(r8) :: cv ! Turbulent transfer coeff. between canopy surface and canopy air (m/s^(1/2))
real(r8) :: wind_min ! Minimum wind speed at the atmospheric forcing height (m/s)
end type params_type
type(params_type), private :: params_inst
!
! !PUBLIC DATA MEMBERS:
! true => btran is based only on unfrozen soil levels
logical, public :: perchroot = .false.
! true => btran is based on active layer (defined over two years);
! false => btran is based on currently unfrozen levels
logical, public :: perchroot_alt = .false.
!
! !PRIVATE DATA MEMBERS:
logical, private :: use_undercanopy_stability = .false. ! use undercanopy stability term or not
integer, private :: itmax_canopy_fluxes = -1 ! max # of iterations used in subroutine CanopyFluxes
character(len=*), parameter, private :: sourcefile = &
__FILE__
!------------------------------------------------------------------------------
contains
!------------------------------------------------------------------------
subroutine CanopyFluxesReadNML(NLFilename)
!
! !DESCRIPTION:
! Read the namelist for Canopy Fluxes
!
! !USES:
use fileutils , only : getavu, relavu, opnfil
use shr_nl_mod , only : shr_nl_find_group_name
use spmdMod , only : masterproc, mpicom
use shr_mpi_mod , only : shr_mpi_bcast
use clm_varctl , only : iulog
!
! !ARGUMENTS:
character(len=*), intent(IN) :: NLFilename ! Namelist filename
!
! !LOCAL VARIABLES:
integer :: ierr ! error code
integer :: unitn ! unit for namelist file
character(len=*), parameter :: subname = 'CanopyFluxesReadNML'
character(len=*), parameter :: nmlname = 'canopyfluxes_inparm'
!-----------------------------------------------------------------------
namelist /canopyfluxes_inparm/ use_undercanopy_stability
namelist /canopyfluxes_inparm/ use_biomass_heat_storage
namelist /canopyfluxes_inparm/ itmax_canopy_fluxes
! Initialize options to default values, in case they are not specified in
! the namelist
if (masterproc) then
unitn = getavu()
write(iulog,*) 'Read in '//nmlname//' namelist'
call opnfil (NLFilename, unitn, 'F')
call shr_nl_find_group_name(unitn, nmlname, status=ierr)
if (ierr == 0) then
read(unitn, nml=canopyfluxes_inparm, iostat=ierr)
if (ierr /= 0) then
call endrun(msg="ERROR reading "//nmlname//"namelist"//errmsg(sourcefile, __LINE__))
end if
else
call endrun(msg="ERROR could NOT find "//nmlname//"namelist"//errmsg(sourcefile, __LINE__))
end if
if (itmax_canopy_fluxes < 1) then
call endrun(msg=' ERROR: expecting itmax_canopy_fluxes > 0 ' // &
errMsg(sourcefile, __LINE__))
end if
call relavu( unitn )
end if
call shr_mpi_bcast (use_undercanopy_stability, mpicom)
call shr_mpi_bcast (use_biomass_heat_storage, mpicom)
call shr_mpi_bcast (itmax_canopy_fluxes, mpicom)
if (masterproc) then
write(iulog,*) ' '
write(iulog,*) nmlname//' settings:'
write(iulog,nml=canopyfluxes_inparm)
write(iulog,*) ' '
end if
end subroutine CanopyFluxesReadNML
!------------------------------------------------------------------------------
subroutine readParams( ncid )
!
! !USES:
use ncdio_pio, only: file_desc_t
use paramUtilMod, only: readNcdioScalar
!
! !ARGUMENTS:
implicit none
type(file_desc_t),intent(inout) :: ncid ! pio netCDF file id
!
! !LOCAL VARIABLES:
character(len=*), parameter :: subname = 'readParams_CanopyFluxes'
!--------------------------------------------------------------------
!added by K.Sakaguchi for litter resistance: Plant litter area index (m2/m2)
call readNcdioScalar(ncid, 'lai_dl', subname, params_inst%lai_dl)
!added by K.Sakaguchi for litter resistance: Litter layer thickness (m)
call readNcdioScalar(ncid, 'z_dl', subname, params_inst%z_dl)
! Drag coefficient under less dense canopy (unitless)
call readNcdioScalar(ncid, 'a_coef', subname, params_inst%a_coef)
! Drag exponent under less dense canopy (unitless)
call readNcdioScalar(ncid, 'a_exp', subname, params_inst%a_exp)
! Drag coefficient for soil under dense canopy (unitless)
call readNcdioScalar(ncid, 'csoilc', subname, params_inst%csoilc)
! Turbulent transfer coeff between canopy surface and canopy air (m/s^(1/2))
call readNcdioScalar(ncid, 'cv', subname, params_inst%cv)
! Minimum wind speed at the atmospheric forcing height (m/s)
call readNcdioScalar(ncid, 'wind_min', subname, params_inst%wind_min)
end subroutine readParams
!------------------------------------------------------------------------------
subroutine CanopyFluxes(bounds, num_exposedvegp, filter_exposedvegp, &
clm_fates, nc, active_layer_inst, atm2lnd_inst, canopystate_inst, &
energyflux_inst, frictionvel_inst, soilstate_inst, solarabs_inst, surfalb_inst, &
temperature_inst, waterfluxbulk_inst, waterstatebulk_inst, &
waterdiagnosticbulk_inst, wateratm2lndbulk_inst, ch4_inst, ozone_inst, &
photosyns_inst, &
humanindex_inst, soil_water_retention_curve, &
downreg_patch, leafn_patch, froot_carbon, croot_carbon)
!
! !DESCRIPTION:
! 1. Calculates the leaf temperature:
! 2. Calculates the leaf fluxes, transpiration, photosynthesis and
! updates the dew accumulation due to evaporation.
!
! Method:
! Use the Newton-Raphson iteration to solve for the foliage
! temperature that balances the surface energy budget:
!
! f(t_veg) = Net radiation - Sensible - Latent = 0
! f(t_veg) + d(f)/d(t_veg) * dt_veg = 0 (*)
!
! Note:
! (1) In solving for t_veg, t_grnd is given from the previous timestep.
! (2) The partial derivatives of aerodynamical resistances, which cannot
! be determined analytically, are ignored for d(H)/dT and d(LE)/dT
! (3) The weighted stomatal resistance of sunlit and shaded foliage is used
! (4) Canopy air temperature and humidity are derived from => Hc + Hg = Ha
! => Ec + Eg = Ea
! (5) Energy loss is due to: numerical truncation of energy budget equation
! (*); and "ecidif" (see the code) which is dropped into the sensible
! heat
! (6) The convergence criteria: the difference, del = t_veg(n+1)-t_veg(n)
! and del2 = t_veg(n)-t_veg(n-1) less than 0.01 K, and the difference
! of water flux from the leaf between the iteration step (n+1) and (n)
! less than 0.1 W/m2; or the iterative steps over 40.
!
! !USES:
use shr_const_mod , only : SHR_CONST_RGAS, shr_const_pi
use clm_time_manager , only : get_step_size_real, get_prev_date, is_near_local_noon
use clm_varcon , only : sb, cpair, hvap, vkc, grav, denice, c_to_b
use clm_varcon , only : denh2o, tfrz, tlsai_crit, alpha_aero
use clm_varcon , only : c14ratio, spval
use clm_varcon , only : c_water, c_dry_biomass, c_to_b
use perf_mod , only : t_startf, t_stopf
use QSatMod , only : QSat
use CLMFatesInterfaceMod, only : hlm_fates_interface_type
use HumanIndexMod , only : all_human_stress_indices, fast_human_stress_indices, &
Wet_Bulb, Wet_BulbS, HeatIndex, AppTemp, &
swbgt, hmdex, dis_coi, dis_coiS, THIndex, &
SwampCoolEff, KtoC, VaporPres
use SoilWaterRetentionCurveMod, only : soil_water_retention_curve_type
use LunaMod , only : is_time_to_run_LUNA
!
! !ARGUMENTS:
type(bounds_type) , intent(in) :: bounds
integer , intent(in) :: num_exposedvegp ! number of points in filter_exposedvegp
integer , intent(in) :: filter_exposedvegp(:) ! patch filter for non-snow-covered veg
type(hlm_fates_interface_type) , intent(inout) :: clm_fates
integer , intent(in) :: nc ! clump index
type(active_layer_type) , intent(in) :: active_layer_inst
type(atm2lnd_type) , intent(in) :: atm2lnd_inst
type(canopystate_type) , intent(inout) :: canopystate_inst
type(energyflux_type) , intent(inout) :: energyflux_inst
type(frictionvel_type) , intent(inout) :: frictionvel_inst
type(solarabs_type) , intent(inout) :: solarabs_inst
type(surfalb_type) , intent(in) :: surfalb_inst
type(soilstate_type) , intent(inout) :: soilstate_inst
type(temperature_type) , intent(inout) :: temperature_inst
type(waterstatebulk_type) , intent(inout) :: waterstatebulk_inst
type(waterdiagnosticbulk_type) , intent(inout) :: waterdiagnosticbulk_inst
type(waterfluxbulk_type) , intent(inout) :: waterfluxbulk_inst
type(wateratm2lndbulk_type) , intent(inout) :: wateratm2lndbulk_inst
type(ch4_type) , intent(inout) :: ch4_inst
class(ozone_base_type) , intent(inout) :: ozone_inst
type(photosyns_type) , intent(inout) :: photosyns_inst
type(humanindex_type) , intent(inout) :: humanindex_inst
class(soil_water_retention_curve_type) , intent(in) :: soil_water_retention_curve
real(r8), intent(in) :: downreg_patch(bounds%begp:) ! fractional reduction in GPP due to N limitation (dimensionless)
real(r8), intent(in) :: leafn_patch(bounds%begp:) ! leaf N (gN/m2)
real(r8), intent(inout) :: froot_carbon(bounds%begp:) ! fine root biomass (gC/m2)
real(r8), intent(inout) :: croot_carbon(bounds%begp:) ! live coarse root biomass (gC/m2)
!
! !LOCAL VARIABLES:
real(r8), pointer :: bsun(:) ! sunlit canopy transpiration wetness factor (0 to 1)
real(r8), pointer :: bsha(:) ! shaded canopy transpiration wetness factor (0 to 1)
real(r8), parameter :: btran0 = 0.0_r8 ! initial value
real(r8), parameter :: zii = 1000.0_r8 ! convective boundary layer height [m]
real(r8), parameter :: beta = 1.0_r8 ! coefficient of conective velocity [-]
real(r8), parameter :: delmax = 1.0_r8 ! maxchange in leaf temperature [K]
real(r8), parameter :: dlemin = 0.1_r8 ! max limit for energy flux convergence [w/m2]
real(r8), parameter :: dtmin = 0.01_r8 ! max limit for temperature convergence [K]
integer , parameter :: itmin = 2 ! minimum number of iteration [-]
!added by K.Sakaguchi for stability formulation
real(r8), parameter :: ria = 0.5_r8 ! free parameter for stable formulation (currently = 0.5, "gamma" in Sakaguchi&Zeng,2008)
real(r8) :: dtime ! land model time step (sec)
real(r8) :: zldis(bounds%begp:bounds%endp) ! reference height "minus" zero displacement height [m]
real(r8) :: wc ! convective velocity [m/s]
real(r8) :: dth(bounds%begp:bounds%endp) ! diff of virtual temp. between ref. height and surface
real(r8) :: dthv(bounds%begp:bounds%endp) ! diff of vir. poten. temp. between ref. height and surface
real(r8) :: dqh(bounds%begp:bounds%endp) ! diff of humidity between ref. height and surface
real(r8) :: ur(bounds%begp:bounds%endp) ! wind speed at reference height [m/s]
real(r8) :: temp1(bounds%begp:bounds%endp) ! relation for potential temperature profile
real(r8) :: temp12m(bounds%begp:bounds%endp) ! relation for potential temperature profile applied at 2-m
real(r8) :: temp2(bounds%begp:bounds%endp) ! relation for specific humidity profile
real(r8) :: temp22m(bounds%begp:bounds%endp) ! relation for specific humidity profile applied at 2-m
real(r8) :: tstar ! temperature scaling parameter
real(r8) :: qstar ! moisture scaling parameter
real(r8) :: thvstar ! virtual potential temperature scaling parameter
real(r8) :: rpp ! fraction of potential evaporation from leaf [-]
real(r8) :: rppdry ! fraction of potential evaporation through transp [-]
real(r8) :: cf ! heat transfer coefficient from leaves [-]
real(r8) :: rb(bounds%begp:bounds%endp) ! leaf boundary layer resistance [s/m]
real(r8) :: rah(bounds%begp:bounds%endp,2) ! thermal resistance [s/m] (air, ground)
real(r8) :: raw(bounds%begp:bounds%endp,2) ! moisture resistance [s/m] (air, ground)
real(r8) :: wta ! heat conductance for air [m/s]
real(r8) :: wtg(bounds%begp:bounds%endp) ! heat conductance for ground [m/s]
real(r8) :: wtl ! heat conductance for leaf [m/s]
real(r8) :: wtstem ! heat conductance for stem [m/s]
real(r8) :: wta0(bounds%begp:bounds%endp) ! normalized heat conductance for air [-]
real(r8) :: wtl0(bounds%begp:bounds%endp) ! normalized heat conductance for leaf [-]
real(r8) :: wtg0 ! normalized heat conductance for ground [-]
real(r8) :: wtstem0(bounds%begp:bounds%endp) ! normalized heat conductance for stem [-]
real(r8) :: wtal(bounds%begp:bounds%endp) ! normalized heat conductance for air and leaf [-]
real(r8) :: wtga(bounds%begp:bounds%endp) ! normalized heat cond. for air and ground [-]
real(r8) :: wtaq ! latent heat conductance for air [m/s]
real(r8) :: wtlq ! latent heat conductance for leaf [m/s]
real(r8) :: wtgq(bounds%begp:bounds%endp) ! latent heat conductance for ground [m/s]
real(r8) :: wtaq0(bounds%begp:bounds%endp) ! normalized latent heat conductance for air [-]
real(r8) :: wtlq0(bounds%begp:bounds%endp) ! normalized latent heat conductance for leaf [-]
real(r8) :: wtgq0 ! normalized heat conductance for ground [-]
real(r8) :: wtalq(bounds%begp:bounds%endp) ! normalized latent heat cond. for air and leaf [-]
real(r8) :: wtgaq ! normalized latent heat cond. for air and ground [-]
real(r8) :: el(bounds%begp:bounds%endp) ! vapor pressure on leaf surface [pa]
real(r8) :: qsatl(bounds%begp:bounds%endp) ! leaf specific humidity [kg/kg]
real(r8) :: qsatldT(bounds%begp:bounds%endp) ! derivative of "qsatl" on "t_veg"
real(r8) :: e_ref2m ! 2 m height surface saturated vapor pressure [Pa]
real(r8) :: qsat_ref2m ! 2 m height surface saturated specific humidity [kg/kg]
real(r8) :: gs ! canopy conductance for iwue cal [molH2O/m2ground/s]
real(r8) :: air(bounds%begp:bounds%endp) ! atmos. radiation temporay set
real(r8) :: bir(bounds%begp:bounds%endp) ! atmos. radiation temporay set
real(r8) :: cir(bounds%begp:bounds%endp) ! atmos. radiation temporay set
real(r8) :: dc1,dc2 ! derivative of energy flux [W/m2/K]
real(r8) :: delt ! temporary
real(r8) :: delq(bounds%begp:bounds%endp) ! temporary
real(r8) :: del(bounds%begp:bounds%endp) ! absolute change in leaf temp in current iteration [K]
real(r8) :: del2(bounds%begp:bounds%endp) ! change in leaf temperature in previous iteration [K]
real(r8) :: dele(bounds%begp:bounds%endp) ! change in latent heat flux from leaf [K]
real(r8) :: dels ! change in leaf temperature in current iteration [K]
real(r8) :: det(bounds%begp:bounds%endp) ! maximum leaf temp. change in two consecutive iter [K]
real(r8) :: efeb(bounds%begp:bounds%endp) ! latent heat flux from leaf (previous iter) [mm/s]
real(r8) :: efeold ! latent heat flux from leaf (previous iter) [mm/s]
real(r8) :: efpot ! potential latent energy flux [kg/m2/s]
real(r8) :: efe(bounds%begp:bounds%endp) ! water flux from leaf [mm/s]
real(r8) :: efsh ! sensible heat from leaf [mm/s]
real(r8) :: obuold(bounds%begp:bounds%endp) ! monin-obukhov length from previous iteration
real(r8) :: tlbef(bounds%begp:bounds%endp) ! leaf temperature from previous iteration [K]
real(r8) :: tl_ini(bounds%begp:bounds%endp) ! leaf temperature from beginning of time step [K]
real(r8) :: ts_ini(bounds%begp:bounds%endp) ! stem temperature from beginning of time step [K]
real(r8) :: ecidif ! excess energies [W/m2]
real(r8) :: err(bounds%begp:bounds%endp) ! balance error
real(r8) :: erre ! balance error
real(r8) :: co2(bounds%begp:bounds%endp) ! atmospheric co2 partial pressure (pa)
real(r8) :: c13o2(bounds%begp:bounds%endp) ! atmospheric c13o2 partial pressure (pa)
real(r8) :: o2(bounds%begp:bounds%endp) ! atmospheric o2 partial pressure (pa)
real(r8) :: svpts(bounds%begp:bounds%endp) ! saturation vapor pressure at t_veg (pa)
real(r8) :: eah(bounds%begp:bounds%endp) ! canopy air vapor pressure (pa)
real(r8) :: s_node ! vol_liq/eff_porosity
real(r8) :: smp_node ! matrix potential
real(r8) :: smp_node_lf ! F. Li and S. Levis
real(r8) :: vol_liq ! partial volume of liquid water in layer
integer :: itlef ! counter for leaf temperature iteration [-]
integer :: nmozsgn(bounds%begp:bounds%endp) ! number of times stability changes sign
real(r8) :: w ! exp(-LSAI)
real(r8) :: csoilcn ! interpolated csoilc for less than dense canopies
real(r8) :: fm(bounds%begp:bounds%endp) ! needed for BGC only to diagnose 10m wind speed
real(r8) :: wtshi ! sensible heat resistance for air, grnd and leaf [-]
real(r8) :: wtsqi ! latent heat resistance for air, grnd and leaf [-]
integer :: j ! soil/snow level index
integer :: p ! patch index
integer :: c ! column index
integer :: l ! landunit index
integer :: g ! gridcell index
integer :: fn ! number of values in vegetated patch filter
integer :: filterp(bounds%endp-bounds%begp+1) ! vegetated patch filter
integer :: fnorig ! number of values in patch filter copy
integer :: fporig(bounds%endp-bounds%begp+1) ! temporary filter
integer :: fnold ! temporary copy of patch count
integer :: f ! filter index
logical :: found ! error flag for canopy above forcing hgt
integer :: index ! patch index for error
real(r8) :: egvf ! effective green vegetation fraction
real(r8) :: lt ! elai+esai
real(r8) :: ri ! stability parameter for under canopy air (unitless)
real(r8) :: csoilb ! turbulent transfer coefficient over bare soil (unitless)
real(r8) :: ricsoilc ! modified transfer coefficient under dense canopy (unitless)
real(r8) :: snow_depth_c ! critical snow depth to cover plant litter (m)
real(r8) :: rdl ! dry litter layer resistance for water vapor (s/m)
real(r8) :: elai_dl ! exposed (dry) plant litter area index
real(r8) :: fsno_dl ! effective snow cover over plant litter
real(r8) :: dayl_factor(bounds%begp:bounds%endp) ! scalar (0-1) for daylength effect on Vcmax
! If no unfrozen layers, put all in the top layer.
real(r8) :: rootsum(bounds%begp:bounds%endp)
real(r8) :: delt_snow
real(r8) :: delt_soil
real(r8) :: delt_h2osfc
real(r8) :: lw_grnd
real(r8) :: delq_snow
real(r8) :: delq_soil
real(r8) :: delq_h2osfc
real(r8) :: dt_veg(bounds%begp:bounds%endp) ! change in t_veg, last iteration (Kelvin)
integer :: jtop(bounds%begc:bounds%endc) ! lbning
integer :: filterc_tmp(bounds%endp-bounds%begp+1) ! temporary variable
integer :: ft ! plant functional type index
real(r8) :: h2ocan ! total canopy water (mm H2O)
real(r8) :: dt_veg_temp(bounds%begp:bounds%endp)
integer, parameter :: iv=1 ! index for first canopy layer (iwue calculation)
real(r8) :: dbh(bounds%begp:bounds%endp) ! diameter at breast height of vegetation
real(r8) :: cp_leaf(bounds%begp:bounds%endp) ! heat capacity of leaves
real(r8) :: cp_stem(bounds%begp:bounds%endp) ! heat capacity of stems
real(r8) :: rstem(bounds%begp:bounds%endp) ! stem resistance to heat transfer
real(r8) :: dt_stem(bounds%begp:bounds%endp) ! change in stem temperature
real(r8) :: frac_rad_abs_by_stem(bounds%begp:bounds%endp) ! fraction of incoming radiation absorbed by stems
real(r8) :: lw_stem(bounds%begp:bounds%endp) ! internal longwave stem
real(r8) :: lw_leaf(bounds%begp:bounds%endp) ! internal longwave leaf
real(r8) :: sa_stem(bounds%begp:bounds%endp) ! surface area stem m2/m2_ground
real(r8) :: sa_leaf(bounds%begp:bounds%endp) ! surface area leaf m2/m2_ground
real(r8) :: sa_internal(bounds%begp:bounds%endp) ! min(sa_stem,sa_leaf)
real(r8) :: uuc(bounds%begp:bounds%endp) ! undercanopy windspeed
real(r8) :: carea_stem ! cross-sectional area of stem
real(r8) :: dlrad_leaf ! Downward longwave radition from leaf
! Indices for raw and rah
integer, parameter :: above_canopy = 1 ! Above canopy
integer, parameter :: below_canopy = 2 ! Below canopy
! Biomass heat storage tuning parameters
! These parameters can be used to account for differences
! in vegetation shape.
real(r8), parameter :: k_vert = 0.1_r8 !vertical distribution of stem
real(r8), parameter :: k_cyl_vol = 1.0_r8 !departure from cylindrical volume
real(r8), parameter :: k_cyl_area = 1.0_r8 !departure from cylindrical area
real(r8), parameter :: k_internal = 0.0_r8 !self-absorbtion of leaf/stem longwave
real(r8), parameter :: min_stem_diameter = 0.05_r8 !minimum stem diameter for which to calculate stem interactions
integer :: dummy_to_make_pgi_happy
!------------------------------------------------------------------------------
SHR_ASSERT_ALL_FL((ubound(downreg_patch) == (/bounds%endp/)), sourcefile, __LINE__)
SHR_ASSERT_ALL_FL((ubound(leafn_patch) == (/bounds%endp/)), sourcefile, __LINE__)
associate( &
t_stem => temperature_inst%t_stem_patch , & ! Output: [real(r8) (:) ] stem temperature (Kelvin)
dhsdt_canopy => energyflux_inst%dhsdt_canopy_patch , & ! Output: [real(r8) (:) ] change in heat storage of stem (W/m**2) [+ to atm]
soilresis => soilstate_inst%soilresis_col , & ! Input: [real(r8) (:) ] soil evaporative resistance
snl => col%snl , & ! Input: [integer (:) ] number of snow layers
dayl => grc%dayl , & ! Input: [real(r8) (:) ] daylength (s)
max_dayl => grc%max_dayl , & ! Input: [real(r8) (:) ] maximum daylength for this grid cell (s)
is_tree => pftcon%is_tree , & ! Input: tree patch or not
is_shrub => pftcon%is_shrub , & ! Input: shrub patch or not
dleaf => pftcon%dleaf , & ! Input: characteristic leaf dimension (m)
dbh_param => pftcon%dbh , & ! Input: diameter at brest height (m)
slatop => pftcon%slatop , & ! SLA at top of canopy [m^2/gC]
fbw => pftcon%fbw , & ! Input: fraction of biomass that is water
nstem => pftcon%nstem , & ! Input: stem number density (#ind/m2)
rstem_per_dbh => pftcon%rstem_per_dbh , & ! Input: stem resistance per stem diameter (s/m**2)
wood_density => pftcon%wood_density , & ! Input: dry wood density (kg/m3)
forc_lwrad => atm2lnd_inst%forc_lwrad_downscaled_col , & ! Input: [real(r8) (:) ] downward infrared (longwave) radiation (W/m**2)
forc_q => wateratm2lndbulk_inst%forc_q_downscaled_col , & ! Input: [real(r8) (:) ] atmospheric specific humidity (kg/kg)
forc_pbot => atm2lnd_inst%forc_pbot_downscaled_col , & ! Input: [real(r8) (:) ] atmospheric pressure (Pa)
forc_th => atm2lnd_inst%forc_th_downscaled_col , & ! Input: [real(r8) (:) ] atmospheric potential temperature (Kelvin)
forc_rho => atm2lnd_inst%forc_rho_downscaled_col , & ! Input: [real(r8) (:) ] density (kg/m**3)
forc_t => atm2lnd_inst%forc_t_downscaled_col , & ! Input: [real(r8) (:) ] atmospheric temperature (Kelvin)
forc_u => atm2lnd_inst%forc_u_grc , & ! Input: [real(r8) (:) ] atmospheric wind speed in east direction (m/s)
forc_v => atm2lnd_inst%forc_v_grc , & ! Input: [real(r8) (:) ] atmospheric wind speed in north direction (m/s)
forc_pco2 => atm2lnd_inst%forc_pco2_grc , & ! Input: [real(r8) (:) ] partial pressure co2 (Pa)
forc_pc13o2 => atm2lnd_inst%forc_pc13o2_grc , & ! Input: [real(r8) (:) ] partial pressure c13o2 (Pa)
forc_po2 => atm2lnd_inst%forc_po2_grc , & ! Input: [real(r8) (:) ] partial pressure o2 (Pa)
tc_ref2m => humanindex_inst%tc_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m height surface air temperature (C)
vap_ref2m => humanindex_inst%vap_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m height vapor pressure (Pa)
appar_temp_ref2m => humanindex_inst%appar_temp_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m apparent temperature (C)
appar_temp_ref2m_r => humanindex_inst%appar_temp_ref2m_r_patch , & ! Output: [real(r8) (:) ] Rural 2 m apparent temperature (C)
swbgt_ref2m => humanindex_inst%swbgt_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m Simplified Wetbulb Globe temperature (C)
swbgt_ref2m_r => humanindex_inst%swbgt_ref2m_r_patch , & ! Output: [real(r8) (:) ] Rural 2 m Simplified Wetbulb Globe temperature (C)
humidex_ref2m => humanindex_inst%humidex_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m Humidex (C)
humidex_ref2m_r => humanindex_inst%humidex_ref2m_r_patch , & ! Output: [real(r8) (:) ] Rural 2 m Humidex (C)
wbt_ref2m => humanindex_inst%wbt_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m Stull Wet Bulb temperature (C)
wbt_ref2m_r => humanindex_inst%wbt_ref2m_r_patch , & ! Output: [real(r8) (:) ] Rural 2 m Stull Wet Bulb temperature (C)
wb_ref2m => humanindex_inst%wb_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m Wet Bulb temperature (C)
wb_ref2m_r => humanindex_inst%wb_ref2m_r_patch , & ! Output: [real(r8) (:) ] Rural 2 m Wet Bulb temperature (C)
teq_ref2m => humanindex_inst%teq_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m height Equivalent temperature (K)
teq_ref2m_r => humanindex_inst%teq_ref2m_r_patch , & ! Output: [real(r8) (:) ] Rural 2 m Equivalent temperature (K)
ept_ref2m => humanindex_inst%ept_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m height Equivalent Potential temperature (K)
ept_ref2m_r => humanindex_inst%ept_ref2m_r_patch , & ! Output: [real(r8) (:) ] Rural 2 m height Equivalent Potential temperature (K)
discomf_index_ref2m => humanindex_inst%discomf_index_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m Discomfort Index temperature (C)
discomf_index_ref2m_r => humanindex_inst%discomf_index_ref2m_r_patch , & ! Output: [real(r8) (:) ] Rural 2 m Discomfort Index temperature (C)
discomf_index_ref2mS => humanindex_inst%discomf_index_ref2mS_patch , & ! Output: [real(r8) (:) ] 2 m height Discomfort Index Stull temperature (C)
discomf_index_ref2mS_r => humanindex_inst%discomf_index_ref2mS_r_patch , & ! Output: [real(r8) (:) ] Rural 2 m Discomfort Index Stull temperature (K)
nws_hi_ref2m => humanindex_inst%nws_hi_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m NWS Heat Index (C)
nws_hi_ref2m_r => humanindex_inst%nws_hi_ref2m_r_patch , & ! Output: [real(r8) (:) ] Rural 2 m NWS Heat Index (C)
thip_ref2m => humanindex_inst%thip_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m Temperature Humidity Index Physiology (C)
thip_ref2m_r => humanindex_inst%thip_ref2m_r_patch , & ! Output: [real(r8) (:) ] Rural 2 m Temperature Humidity Index Physiology (C)
thic_ref2m => humanindex_inst%thic_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m Temperature Humidity Index Comfort (C)
thic_ref2m_r => humanindex_inst%thic_ref2m_r_patch , & ! Output: [real(r8) (:) ] Rural 2 m Temperature Humidity Index Comfort (C)
swmp65_ref2m => humanindex_inst%swmp65_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m Swamp Cooler temperature 65% effi (C)
swmp65_ref2m_r => humanindex_inst%swmp65_ref2m_r_patch , & ! Output: [real(r8) (:) ] Rural 2 m Swamp Cooler temperature 65% effi (C)
swmp80_ref2m => humanindex_inst%swmp80_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m Swamp Cooler temperature 80% effi (C)
swmp80_ref2m_r => humanindex_inst%swmp80_ref2m_r_patch , & ! Output: [real(r8) (:) ] Rural 2 m Swamp Cooler temperature 80% effi (C)
sabv => solarabs_inst%sabv_patch , & ! Input: [real(r8) (:) ] solar radiation absorbed by vegetation (W/m**2)
par_z_sun => solarabs_inst%parsun_z_patch , & ! Input: [real(r8) (:,:) ] par absorbed per unit lai for canopy layer (w/m**2)
frac_veg_nosno => canopystate_inst%frac_veg_nosno_patch , & ! Input: [integer (:) ] fraction of vegetation not covered by snow (0 OR 1) [-]
elai => canopystate_inst%elai_patch , & ! Input: [real(r8) (:) ] one-sided leaf area index with burying by snow
esai => canopystate_inst%esai_patch , & ! Input: [real(r8) (:) ] one-sided stem area index with burying by snow
laisun => canopystate_inst%laisun_patch , & ! Input: [real(r8) (:) ] sunlit leaf area
laisha => canopystate_inst%laisha_patch , & ! Input: [real(r8) (:) ] shaded leaf area
displa => canopystate_inst%displa_patch , & ! Input: [real(r8) (:) ] displacement height (m)
stem_biomass => canopystate_inst%stem_biomass_patch , & ! Output: [real(r8) (:) ] Aboveground stem biomass (kg/m**2)
leaf_biomass => canopystate_inst%leaf_biomass_patch , & ! Output: [real(r8) (:) ] Aboveground leaf biomass (kg/m**2)
htop => canopystate_inst%htop_patch , & ! Input: [real(r8) (:) ] canopy top(m)
dleaf_patch => canopystate_inst%dleaf_patch , & ! Output: [real(r8) (:) ] mean leaf diameter for this patch/pft
watsat => soilstate_inst%watsat_col , & ! Input: [real(r8) (:,:) ] volumetric soil water at saturation (porosity) (constant)
watdry => soilstate_inst%watdry_col , & ! Input: [real(r8) (:,:) ] btran parameter for btran=0 (constant)
watopt => soilstate_inst%watopt_col , & ! Input: [real(r8) (:,:) ] btran parameter for btran=1 (constant)
eff_porosity => soilstate_inst%eff_porosity_col , & ! Output: [real(r8) (:,:) ] effective soil porosity
soilbeta => soilstate_inst%soilbeta_col , & ! Input: [real(r8) (:) ] soil wetness relative to field capacity
u10_clm => frictionvel_inst%u10_clm_patch , & ! Input: [real(r8) (:) ] 10 m height winds (m/s)
forc_hgt_u_patch => frictionvel_inst%forc_hgt_u_patch , & ! Input: [real(r8) (:) ] observational height of wind at patch level [m]
z0mg => frictionvel_inst%z0mg_col , & ! Input: [real(r8) (:) ] roughness length of ground, momentum [m]
zetamax => frictionvel_inst%zetamaxstable , & ! Input: [real(r8) ] max zeta value under stable conditions
ram1 => frictionvel_inst%ram1_patch , & ! Output: [real(r8) (:) ] aerodynamical resistance (s/m)
z0mv => frictionvel_inst%z0mv_patch , & ! Output: [real(r8) (:) ] roughness length over vegetation, momentum [m]
z0hv => frictionvel_inst%z0hv_patch , & ! Output: [real(r8) (:) ] roughness length over vegetation, sensible heat [m]
z0qv => frictionvel_inst%z0qv_patch , & ! Output: [real(r8) (:) ] roughness length over vegetation, latent heat [m]
rb1 => frictionvel_inst%rb1_patch , & ! Output: [real(r8) (:) ] boundary layer resistance (s/m)
t_h2osfc => temperature_inst%t_h2osfc_col , & ! Input: [real(r8) (:) ] surface water temperature
t_soisno => temperature_inst%t_soisno_col , & ! Input: [real(r8) (:,:) ] soil temperature (Kelvin)
t_grnd => temperature_inst%t_grnd_col , & ! Input: [real(r8) (:) ] ground surface temperature [K]
thv => temperature_inst%thv_col , & ! Input: [real(r8) (:) ] virtual potential temperature (kelvin)
thm => temperature_inst%thm_patch , & ! Input: [real(r8) (:) ] intermediate variable (forc_t+0.0098*forc_hgt_t_patch)
emv => temperature_inst%emv_patch , & ! Input: [real(r8) (:) ] vegetation emissivity
emg => temperature_inst%emg_col , & ! Input: [real(r8) (:) ] vegetation emissivity
t_veg => temperature_inst%t_veg_patch , & ! Output: [real(r8) (:) ] vegetation temperature (Kelvin)
t_ref2m => temperature_inst%t_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m height surface air temperature (Kelvin)
t_ref2m_r => temperature_inst%t_ref2m_r_patch , & ! Output: [real(r8) (:) ] Rural 2 m height surface air temperature (Kelvin)
t_skin_patch => temperature_inst%t_skin_patch , & ! Output: [real(r8) (:) ] patch skin temperature (K)
frac_h2osfc => waterdiagnosticbulk_inst%frac_h2osfc_col , & ! Input: [real(r8) (:) ] fraction of surface water
fwet => waterdiagnosticbulk_inst%fwet_patch , & ! Input: [real(r8) (:) ] fraction of canopy that is wet (0 to 1)
fdry => waterdiagnosticbulk_inst%fdry_patch , & ! Input: [real(r8) (:) ] fraction of foliage that is green and dry [-]
frac_sno => waterdiagnosticbulk_inst%frac_sno_eff_col , & ! Input: [real(r8) (:) ] fraction of ground covered by snow (0 to 1)
snow_depth => waterdiagnosticbulk_inst%snow_depth_col , & ! Input: [real(r8) (:) ] snow height (m)
qg_snow => waterdiagnosticbulk_inst%qg_snow_col , & ! Input: [real(r8) (:) ] specific humidity at snow surface [kg/kg]
qg_soil => waterdiagnosticbulk_inst%qg_soil_col , & ! Input: [real(r8) (:) ] specific humidity at soil surface [kg/kg]
qg_h2osfc => waterdiagnosticbulk_inst%qg_h2osfc_col , & ! Input: [real(r8) (:) ] specific humidity at h2osfc surface [kg/kg]
qg => waterdiagnosticbulk_inst%qg_col , & ! Input: [real(r8) (:) ] specific humidity at ground surface [kg/kg]
dqgdT => waterdiagnosticbulk_inst%dqgdT_col , & ! Input: [real(r8) (:) ] temperature derivative of "qg"
h2osoi_ice => waterstatebulk_inst%h2osoi_ice_col , & ! Input: [real(r8) (:,:) ] ice lens (kg/m2)
h2osoi_vol => waterstatebulk_inst%h2osoi_vol_col , & ! Input: [real(r8) (:,:) ] volumetric soil water (0<=h2osoi_vol<=watsat) [m3/m3] by F. Li and S. Levis
h2osoi_liq => waterstatebulk_inst%h2osoi_liq_col , & ! Input: [real(r8) (:,:) ] liquid water (kg/m2)
h2osoi_liqvol => waterdiagnosticbulk_inst%h2osoi_liqvol_col , & ! Output: [real(r8) (:,:) ] volumetric liquid water (v/v)
snocan => waterstatebulk_inst%snocan_patch , & ! Output: [real(r8) (:) ] canopy snow (mm H2O)
liqcan => waterstatebulk_inst%liqcan_patch , & ! Output: [real(r8) (:) ] canopy liquid (mm H2O)
q_ref2m => waterdiagnosticbulk_inst%q_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m height surface specific humidity (kg/kg)
rh_ref2m_r => waterdiagnosticbulk_inst%rh_ref2m_r_patch , & ! Output: [real(r8) (:) ] Rural 2 m height surface relative humidity (%)
rh_ref2m => waterdiagnosticbulk_inst%rh_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m height surface relative humidity (%)
rhaf => waterdiagnosticbulk_inst%rh_af_patch , & ! Output: [real(r8) (:) ] fractional humidity of canopy air [dimensionless]
vpd_ref2m => waterdiagnosticbulk_inst%vpd_ref2m_patch , & ! Output: [real(r8) (:) ] 2 m height surface vapor pressure deficit (Pa)
iwue_ln => waterdiagnosticbulk_inst%iwue_ln_patch , & ! Output: [real(r8) (:) ] local noon ecosystem-scale inherent water use efficiency (gC kgH2O-1 hPa)
qflx_tran_veg => waterfluxbulk_inst%qflx_tran_veg_patch , & ! Output: [real(r8) (:) ] vegetation transpiration (mm H2O/s) (+ = to atm)
qflx_evap_veg => waterfluxbulk_inst%qflx_evap_veg_patch , & ! Output: [real(r8) (:) ] vegetation evaporation (mm H2O/s) (+ = to atm)
qflx_evap_soi => waterfluxbulk_inst%qflx_evap_soi_patch , & ! Output: [real(r8) (:) ] soil evaporation (mm H2O/s) (+ = to atm)
qflx_ev_snow => waterfluxbulk_inst%qflx_ev_snow_patch , & ! Output: [real(r8) (:) ] evaporation flux from snow (mm H2O/s) [+ to atm]
qflx_ev_soil => waterfluxbulk_inst%qflx_ev_soil_patch , & ! Output: [real(r8) (:) ] evaporation flux from soil (mm H2O/s) [+ to atm]
qflx_ev_h2osfc => waterfluxbulk_inst%qflx_ev_h2osfc_patch , & ! Output: [real(r8) (:) ] evaporation flux from h2osfc (mm H2O/s) [+ to atm]
gs_mol_sun => photosyns_inst%gs_mol_sun_patch , & ! Input: [real(r8) (:) ] patch sunlit leaf stomatal conductance (umol H2O/m**2/s)
gs_mol_sha => photosyns_inst%gs_mol_sha_patch , & ! Input: [real(r8) (:) ] patch shaded leaf stomatal conductance (umol H2O/m**2/s)
rssun => photosyns_inst%rssun_patch , & ! Output: [real(r8) (:) ] leaf sunlit stomatal resistance (s/m) (output from Photosynthesis)
rssha => photosyns_inst%rssha_patch , & ! Output: [real(r8) (:) ] leaf shaded stomatal resistance (s/m) (output from Photosynthesis)
fpsn => photosyns_inst%fpsn_patch , & ! Input: [real(r8) (:) ] photosynthesis (umol CO2 /m**2 /s)
grnd_ch4_cond => ch4_inst%grnd_ch4_cond_patch , & ! Output: [real(r8) (:) ] tracer conductance for boundary layer [m/s]
htvp => energyflux_inst%htvp_col , & ! Input: [real(r8) (:) ] latent heat of evaporation (/sublimation) [J/kg] (constant)
btran => energyflux_inst%btran_patch , & ! Output: [real(r8) (:) ] transpiration wetness factor (0 to 1)
rresis => energyflux_inst%rresis_patch , & ! Output: [real(r8) (:,:) ] root resistance by layer (0-1) (nlevgrnd)
taux => energyflux_inst%taux_patch , & ! Output: [real(r8) (:) ] wind (shear) stress: e-w (kg/m/s**2)
tauy => energyflux_inst%tauy_patch , & ! Output: [real(r8) (:) ] wind (shear) stress: n-s (kg/m/s**2)
canopy_cond => energyflux_inst%canopy_cond_patch , & ! Output: [real(r8) (:) ] tracer conductance for canopy [m/s]
cgrnds => energyflux_inst%cgrnds_patch , & ! Output: [real(r8) (:) ] deriv. of soil sensible heat flux wrt soil temp [w/m2/k]
cgrndl => energyflux_inst%cgrndl_patch , & ! Output: [real(r8) (:) ] deriv. of soil latent heat flux wrt soil temp [w/m**2/k]
dlrad => energyflux_inst%dlrad_patch , & ! Output: [real(r8) (:) ] downward longwave radiation below the canopy [W/m2]
ulrad => energyflux_inst%ulrad_patch , & ! Output: [real(r8) (:) ] upward longwave radiation above the canopy [W/m2]
cgrnd => energyflux_inst%cgrnd_patch , & ! Output: [real(r8) (:) ] deriv. of soil energy flux wrt to soil temp [w/m2/k]
eflx_sh_snow => energyflux_inst%eflx_sh_snow_patch , & ! Output: [real(r8) (:) ] sensible heat flux from snow (W/m**2) [+ to atm]
eflx_sh_h2osfc => energyflux_inst%eflx_sh_h2osfc_patch , & ! Output: [real(r8) (:) ] sensible heat flux from soil (W/m**2) [+ to atm]
eflx_sh_soil => energyflux_inst%eflx_sh_soil_patch , & ! Output: [real(r8) (:) ] sensible heat flux from soil (W/m**2) [+ to atm]
eflx_sh_stem => energyflux_inst%eflx_sh_stem_patch , & ! Output: [real(r8) (:) ] sensible heat flux from stems (W/m**2) [+ to atm]
eflx_sh_veg => energyflux_inst%eflx_sh_veg_patch , & ! Output: [real(r8) (:) ] sensible heat flux from leaves (W/m**2) [+ to atm]
eflx_sh_grnd => energyflux_inst%eflx_sh_grnd_patch , & ! Output: [real(r8) (:) ] sensible heat flux from ground (W/m**2) [+ to atm]
rah1 => frictionvel_inst%rah1_patch , & ! Output: [real(r8) (:) ] aerodynamical resistance [s/m]
rah2 => frictionvel_inst%rah2_patch , & ! Output: [real(r8) (:) ] aerodynamical resistance [s/m]
raw1 => frictionvel_inst%raw1_patch , & ! Output: [real(r8) (:) ] aerodynamical resistance [s/m]
raw2 => frictionvel_inst%raw2_patch , & ! Output: [real(r8) (:) ] aerodynamical resistance [s/m]
ustar => frictionvel_inst%ustar_patch , & ! Output: [real(r8) (:) ] friction velocity [m/s]
um => frictionvel_inst%um_patch , & ! Output: [real(r8) (:) ] wind speed including the stablity effect [m/s]
uaf => frictionvel_inst%uaf_patch , & ! Output: [real(r8) (:) ] canopy air speed [m/s]
taf => frictionvel_inst%taf_patch , & ! Output: [real(r8) (:) ] canopy air temperature [K]
qaf => frictionvel_inst%qaf_patch , & ! Output: [real(r8) (:) ] canopy air humidity [kg/kg]
obu => frictionvel_inst%obu_patch , & ! Output: [real(r8) (:) ] Monin-Obukhov length [m]
zeta => frictionvel_inst%zeta_patch , & ! Output: [real(r8) (:) ] dimensionless stability parameter
vpd => frictionvel_inst%vpd_patch , & ! Output: [real(r8) (:) ] vapor pressure deficit [Pa]
num_iter => frictionvel_inst%num_iter_patch , & ! Output: [real(r8) (:) ] number of iterations
begp => bounds%begp , &
endp => bounds%endp , &
begg => bounds%begg , &
endg => bounds%endg &
)
if (use_hydrstress) then
bsun => energyflux_inst%bsun_patch ! Output: [real(r8) (:) ] sunlit canopy transpiration wetness factor (0 to 1)
bsha => energyflux_inst%bsha_patch ! Output: [real(r8) (:) ] sunlit canopy transpiration wetness factor (0 to 1)
end if
! Determine step size
dtime = get_step_size_real()
! Make a local copy of the exposedvegp filter. With the current implementation,
! this is needed because the filter is modified in the iteration loop.
!
! TODO(wjs, 2014-09-24) Determine if this is really needed. I suspect that we could
! do away with either this temporary fn/filterp, or the temporary fnorig/fporig,
! with one of these simply using the passed-in filter (num_exposedvegp /
! filter_exposedvegp)
fn = num_exposedvegp
filterp(1:fn) = filter_exposedvegp(1:fn)
! -----------------------------------------------------------------
! Time step initialization of photosynthesis variables
! -----------------------------------------------------------------
call photosyns_inst%TimeStepInit(bounds)
! -----------------------------------------------------------------
! Prep some IO variables and some checks on patch pointers if FATES
! is running.
! Filter explanation: The patch filter in this routine identifies all
! non-lake, non-urban patches that are not covered by ice. The
! filter is set over a few steps:
!
! 1a) for CN:
! clm_drv() ->
! bgc_vegetation_inst%EcosystemDynamicsPostDrainage() ->
! CNVegStructUpdate()
! if(elai(p)+esai(p)>0) frac_veg_nosno_alb(p) = 1
!
! 1b) for FATES:
! clm_drv() ->
! clm_fates%dynamics_driv() ->
! ed_clm_link() ->
! ed_clm_leaf_area_profile():
! if(elai(p)+esai(p)>0) frac_veg_nosno_alb(p) = 1
!
! 2) during clm_drv()->clm_drv_init():
! frac_veg_nosno_alb(p) is then combined with the active(p)
! flag via union to create frac_veg_nosno_patch(p)
! 3) immediately after, during clm_drv()->setExposedvegpFilter()
! the list used here "exposedvegp(fe)" is incremented if
! frac_veg_nosno_patch > 0
! -----------------------------------------------------------------
if (use_fates) then
call clm_fates%prep_canopyfluxes(nc, fn, filterp, photosyns_inst)
end if
! Initialize
do f = 1, fn
p = filterp(f)
del(p) = 0._r8 ! change in leaf temperature from previous iteration
efeb(p) = 0._r8 ! latent head flux from leaf for previous iteration
wtlq0(p) = 0._r8
wtalq(p) = 0._r8
wtgq(p) = 0._r8
wtaq0(p) = 0._r8
obuold(p) = 0._r8
btran(p) = btran0
dhsdt_canopy(p) = 0._r8
eflx_sh_stem(p) = 0._r8
end do
!
! Calculate biomass heat capacities
!
if(use_biomass_heat_storage) then
bioms: do f = 1, fn
p = filterp(f)
! fraction of stem receiving incoming radiation
frac_rad_abs_by_stem(p) = (esai(p))/(elai(p)+esai(p))
! when elai = 0, do not multiply by k_vert (i.e. frac_rad_abs_by_stem = 1)
if(elai(p) > 0._r8) frac_rad_abs_by_stem(p) = k_vert * frac_rad_abs_by_stem(p)
! if using Satellite Phenology mode, use values in parameter file
! otherwise calculate dbh from stem biomass
if(use_cn) then
if(stem_biomass(p) > 0._r8) then
dbh(p) = 2._r8 * sqrt(stem_biomass(p) * (1._r8 - fbw(patch%itype(p))) &
/ ( shr_const_pi * htop(p) * k_cyl_vol &
* nstem(patch%itype(p)) * wood_density(patch%itype(p))))
else
dbh(p) = 0._r8
endif
else
dbh(p) = dbh_param(patch%itype(p))
endif
! leaf and stem surface area
sa_leaf(p) = elai(p)
! double in spirit of full surface area for sensible heat
sa_leaf(p) = 2._r8*sa_leaf(p)
! Surface area for stem
sa_stem(p) = nstem(patch%itype(p))*(htop(p)*shr_const_pi*dbh(p))
! adjust for departure of cylindrical stem model
sa_stem(p) = k_cyl_area * sa_stem(p)
!
! only calculate separate leaf/stem heat capacity for trees
! and shrubs if dbh is greater than some minimum value
! (set surface area for stem, and fraction absorbed by stem to zero)
if(.not.(is_tree(patch%itype(p)) .or. is_shrub(patch%itype(p))) &
.or. dbh(p) < min_stem_diameter) then
frac_rad_abs_by_stem(p) = 0.0_r8
sa_stem(p) = 0.0_r8
endif
! if using Satellite Phenology mode, calculate leaf and stem biomass
if(.not. use_cn) then
! 2gbiomass/gC * (1/SLA) * 1e-3 = kg dry mass/m2(leaf)
leaf_biomass(p) = (1.e-3_r8*c_to_b/slatop(patch%itype(p))) &
* max(0.01_r8, 0.5_r8*sa_leaf(p)) &
/ (1._r8-fbw(patch%itype(p)))
! cross-sectional area of stems
carea_stem = shr_const_pi * (dbh(p)*0.5_r8)**2
stem_biomass(p) = carea_stem * htop(p) * k_cyl_vol &
* nstem(patch%itype(p)) * wood_density(patch%itype(p)) &
/(1._r8-fbw(patch%itype(p)))
endif
! internal longwave fluxes between leaf and stem
! (use same area of interaction i.e. ignore leaf <-> leaf)
sa_internal(p) = min(sa_leaf(p),sa_stem(p))
sa_internal(p) = k_internal * sa_internal(p)
! calculate specify heat capacity of vegetation
! as weighted averaged of dry biomass and water
! lma_dry has units of kg dry mass/m2 here
! (Appendix B of Bonan et al., GMD, 2018)
cp_leaf(p) = leaf_biomass(p) * (c_dry_biomass*(1._r8-fbw(patch%itype(p))) + (fbw(patch%itype(p)))*c_water)
! cp-stem will have units J/k/ground_area
cp_stem(p) = stem_biomass(p) * (c_dry_biomass*(1._r8-fbw(patch%itype(p))) + (fbw(patch%itype(p)))*c_water)
! adjust for departure from cylindrical stem model
cp_stem(p) = k_cyl_vol * cp_stem(p)
! resistance between internal stem temperature and canopy air
rstem(p) = rstem_per_dbh(patch%itype(p))*dbh(p)
enddo bioms
else
! Otherwise set biomass heat storage terms to zero
do f = 1, fn
p = filterp(f)
sa_leaf(p) = (elai(p)+esai(p))
frac_rad_abs_by_stem(p) = 0._r8
sa_stem(p) = 0._r8
sa_internal(p) = 0._r8
cp_leaf(p) = 0._r8
cp_stem(p) = 0._r8
rstem(p) = 0._r8
end do
end if
! calculate daylength control for Vcmax
do f = 1, fn
p=filterp(f)
g=patch%gridcell(p)
! calculate dayl_factor as the ratio of (current:max dayl)^2
! set a minimum of 0.01 (1%) for the dayl_factor
dayl_factor(p)=min(1._r8,max(0.01_r8,(dayl(g)*dayl(g))/(max_dayl(g)*max_dayl(g))))
end do
rb1(begp:endp) = 0._r8
!assign the temporary filter
do f = 1, fn
p = filterp(f)
filterc_tmp(f)=patch%column(p)
enddo
!compute effective soil porosity
call calc_effective_soilporosity(bounds, &
ubj = nlevgrnd, &
numf = fn, &
filter = filterc_tmp(1:fn), &
watsat = watsat(bounds%begc:bounds%endc, 1:nlevgrnd), &
h2osoi_ice = h2osoi_ice(bounds%begc:bounds%endc,1:nlevgrnd), &
denice = denice, &
eff_por=eff_porosity(bounds%begc:bounds%endc, 1:nlevgrnd) )
!compute volumetric liquid water content
jtop(bounds%begc:bounds%endc) = 1
call calc_volumetric_h2oliq(bounds, &
jtop = jtop(bounds%begc:bounds%endc), &
lbj = 1, &
ubj = nlevgrnd, &
numf = fn, &
filter = filterc_tmp(1:fn), &
eff_porosity = eff_porosity(bounds%begc:bounds%endc, 1:nlevgrnd), &
h2osoi_liq = h2osoi_liq(bounds%begc:bounds%endc, 1:nlevgrnd), &
denh2o = denh2o, &
vol_liq = h2osoi_liqvol(bounds%begc:bounds%endc, 1:nlevgrnd) )
!set up perchroot options
call set_perchroot_opt(perchroot, perchroot_alt)
! --------------------------------------------------------------------------
! if this is a FATES simulation
! ask fates to calculate btran functions and distribution of uptake
! this will require boundary conditions from CLM, boundary conditions which
! may only be available from a smaller subset of patches that meet the
! exposed veg.
! calc_root_moist_stress already calculated root soil water stress 'rresis'
! this is the input boundary condition to calculate the transpiration
! wetness factor btran and the root weighting factors for FATES. These
! values require knowledge of the belowground root structure.
! --------------------------------------------------------------------------
if(use_fates)then
call clm_fates%wrap_btran(nc, fn, filterc_tmp(1:fn), soilstate_inst, &
waterdiagnosticbulk_inst, temperature_inst, energyflux_inst, soil_water_retention_curve)
else
!calculate root moisture stress
call calc_root_moist_stress(bounds, &
nlevgrnd = nlevgrnd, &
fn = fn, &
filterp = filterp, &
active_layer_inst=active_layer_inst, &
energyflux_inst=energyflux_inst, &
soilstate_inst=soilstate_inst, &
temperature_inst=temperature_inst, &
waterstatebulk_inst=waterstatebulk_inst, &
waterdiagnosticbulk_inst=waterdiagnosticbulk_inst, &
soil_water_retention_curve=soil_water_retention_curve)
end if
!! Modify aerodynamic parameters for sparse/dense canopy (X. Zeng)
do f = 1, fn
p = filterp(f)
c = patch%column(p)
lt = min(elai(p)+esai(p), tlsai_crit)
egvf =(1._r8 - alpha_aero * exp(-lt)) / (1._r8 - alpha_aero * exp(-tlsai_crit))
displa(p) = egvf * displa(p)
z0mv(p) = exp(egvf * log(z0mv(p)) + (1._r8 - egvf) * log(z0mg(c)))
z0hv(p) = z0mv(p)
z0qv(p) = z0mv(p)
end do
found = .false.
do f = 1, fn
p = filterp(f)
c = patch%column(p)
g = patch%gridcell(p)
! Net absorbed longwave radiation by canopy and ground
! =air+bir*t_veg**4+cir*t_grnd(c)**4
air(p) = emv(p) * (1._r8+(1._r8-emv(p))*(1._r8-emg(c))) * forc_lwrad(c)
bir(p) = - (2._r8-emv(p)*(1._r8-emg(c))) * emv(p) * sb
cir(p) = emv(p)*emg(c)*sb
! Saturated vapor pressure, specific humidity, and their derivatives
! at the leaf surface
call QSat (t_veg(p), forc_pbot(c), qsatl(p), &
es = el(p), &
qsdT = qsatldT(p))
! Determine atmospheric co2 and o2
co2(p) = forc_pco2(g)
o2(p) = forc_po2(g)
if ( use_c13 ) then
c13o2(p) = forc_pc13o2(g)
end if
! Initialize flux profile
nmozsgn(p) = 0
taf(p) = (t_grnd(c) + thm(p))/2._r8
qaf(p) = (forc_q(c)+qg(c))/2._r8
ur(p) = max(params_inst%wind_min,sqrt(forc_u(g)*forc_u(g)+forc_v(g)*forc_v(g)))
dth(p) = thm(p)-taf(p)
dqh(p) = forc_q(c)-qaf(p)
delq(p) = qg(c) - qaf(p)
dthv(p) = dth(p)*(1._r8+0.61_r8*forc_q(c))+0.61_r8*forc_th(c)*dqh(p)
zldis(p) = forc_hgt_u_patch(p) - displa(p)
! Check to see if the forcing height is below the canopy height
if (zldis(p) < 0._r8) then
found = .true.
index = p
end if
end do
if (found) then
if ( .not. use_fates ) then
write(iulog,*)'Error: Forcing height is below canopy height for patch index '
call endrun(subgrid_index=index, subgrid_level=subgrid_level_patch, msg=errmsg(sourcefile, __LINE__))
end if
end if
do f = 1, fn
p = filterp(f)
c = patch%column(p)
! Initialize Monin-Obukhov length and wind speed
call frictionvel_inst%MoninObukIni(ur(p), thv(c), dthv(p), zldis(p), z0mv(p), um(p), obu(p))
num_iter(p) = 0
! Record initial veg/stem temperatures
tl_ini(p) = t_veg(p)
ts_ini(p) = t_stem(p)
end do
! Set counter for leaf temperature iteration (itlef)
itlef = 0
fnorig = fn
fporig(1:fn) = filterp(1:fn)
! Begin stability iteration
call t_startf('can_iter')
ITERATION : do while (itlef <= itmax_canopy_fluxes .and. fn > 0)
! Determine friction velocity, and potential temperature and humidity
! profiles of the surface boundary layer
call frictionvel_inst%FrictionVelocity (begp, endp, fn, filterp, &
displa(begp:endp), z0mv(begp:endp), z0hv(begp:endp), z0qv(begp:endp), &
obu(begp:endp), itlef+1, ur(begp:endp), um(begp:endp), ustar(begp:endp), &
temp1(begp:endp), temp2(begp:endp), temp12m(begp:endp), temp22m(begp:endp), fm(begp:endp))
do f = 1, fn
p = filterp(f)
c = patch%column(p)
g = patch%gridcell(p)
tlbef(p) = t_veg(p)
del2(p) = del(p)
! Determine aerodynamic resistances
ram1(p) = 1._r8/(ustar(p)*ustar(p)/um(p))
rah(p,above_canopy) = 1._r8/(temp1(p)*ustar(p))
raw(p,above_canopy) = 1._r8/(temp2(p)*ustar(p))
! Bulk boundary layer resistance of leaves
uaf(p) = um(p)*sqrt( 1._r8/(ram1(p)*um(p)) )
! empirical undercanopy wind speed
uuc(p) = min(0.4_r8,(0.03_r8*um(p)/ustar(p)))
! Use pft parameter for leaf characteristic width
! dleaf_patch if this is not an fates patch.
! Otherwise, the value has already been loaded
! during the FATES dynamics call
if(.not.patch%is_fates(p)) then
dleaf_patch(p) = dleaf(patch%itype(p))
end if
cf = params_inst%cv / (sqrt(uaf(p)) * sqrt(dleaf_patch(p)))
rb(p) = 1._r8/(cf*uaf(p))
rb1(p) = rb(p)