-
Notifications
You must be signed in to change notification settings - Fork 0
/
CanopyTurbulenceMod.F90
2456 lines (2026 loc) · 102 KB
/
CanopyTurbulenceMod.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 CanopyTurbulenceMod
!-----------------------------------------------------------------------
! !DESCRIPTION:
! Canopy turbulence, aeorodynamic conductances, and scalar profiles using above-
! and within-canopy coupling with a roughness sublayer (RSL) parameterization
!
! !USES:
use shr_kind_mod, only : r8 => shr_kind_r8
use abortutils, only : endrun
use decompMod , only : bounds_type
!
! !PUBLIC TYPES:
implicit none
!
! !PRIVATE TYPES:
real(r8), parameter :: zetam = -1.574_r8 ! CLM: transition point of flux-gradient relation (wind profile)
real(r8), parameter :: zetah = -0.465_r8 ! CLM: transition point of flux-gradient relation (temperature profile)
real(r8), parameter :: zetamaxstable = 2.0_r8 ! CLM: Maximum value for zeta under stable conditions
! real(r8), parameter :: zetamaxstable = 0.5_r8 ! CLM: Maximum value for zeta under stable conditions
real(r8), parameter :: cd = 0.25_r8 ! RSL leaf drag coefficient (dimensionless)
real(r8), parameter :: beta_neutral_max = 0.35_r8 ! RSL maximum value for beta in neutral conditions
real(r8), parameter :: cr = 0.3_r8 ! RSL parameter to calculate beta_neutral
real(r8), parameter :: c2 = 0.5_r8 ! RSL depth scale multiplier
!
! !PUBLIC MEMBER FUNCTIONS:
public :: CanopyTurbulenceDummy ! Canopy scalar profiles equal reference height values
public :: CanopyTurbulence ! Canopy turbulence and scalar profiles used RSL theory
public :: LookupPsihatINI ! Initialize the RSL psihat look-up tables
!
! !PRIVATE MEMBER FUNCTIONS:
private :: phim_monin_obukhov ! Monin-Obukhov phi stability function for momentum
private :: phic_monin_obukhov ! Monin-Obukhov phi stability function for scalars
private :: psim_monin_obukhov ! Monin-Obukhov psi stability function for momentum
private :: psic_monin_obukhov ! Monin-Obukhov psi stability function for scalars
private :: ObuFunc ! Function to solve for the Obukhov length
private :: GetBeta ! Calculate beta = u* / u(h)
private :: GetPrSc ! Turbulent Prandlt number (Pr) and Schmidt number (Sc) at canopy top
private :: GetPsiRSL ! RSL-modified stability functions
private :: LookupPsihat ! Determines the RSL function psihat as provided through a look-up table
private :: ScalarProfile ! Calculate scalar profile using implicit solution
private :: ScalarProfileIterative! Calculate scalar profile using iterative solution
private :: ObuFuncCLM ! Calculate the Obukhov length as in CLM
private :: MoninObukIniCLM ! CLM initialization of the Obukhov length
private :: FrictionVelocityCLM ! CLM friction velocity and stability dependent log-z functions
private :: GetPsiCLM ! CLM surface-layer stability functions
private :: StabilityFunc1 ! CLM Monin-Obukhov stability function for momentum
private :: StabilityFunc2 ! CLM Monin-Obukhov stability function for scalars
contains
!-----------------------------------------------------------------------
function phim_monin_obukhov (zeta) result(phi)
!
! !DESCRIPTION:
! Monin-Obukhov phi stability function for momentum
!
! !ARGUMENTS:
implicit none
real(r8), intent(in) :: zeta ! Monin-Obukhov stability parameter
!
! !LOCAL VARIABLES:
real(r8) :: phi ! phi for momentum
!---------------------------------------------------------------------
if (zeta < 0._r8) then ! --- unstable
phi = 1._r8 / sqrt(sqrt(1._r8 - 16._r8 * zeta))
else ! --- stable
phi = 1._r8 + 5._r8 * zeta
end if
end function phim_monin_obukhov
!-----------------------------------------------------------------------
function phic_monin_obukhov (zeta) result(phi)
!
! !DESCRIPTION:
! Monin-Obukhov phi stability function for scalars
!
! !ARGUMENTS:
implicit none
real(r8), intent(in) :: zeta ! Monin-Obukhov stability parameter
!
! !LOCAL VARIABLES:
real(r8) :: phi ! phi for scalars
!---------------------------------------------------------------------
if (zeta < 0._r8) then ! --- unstable
phi = 1._r8 / sqrt(1._r8 - 16._r8 * zeta)
else ! --- stable
phi = 1._r8 + 5._r8 * zeta
end if
end function phic_monin_obukhov
!-----------------------------------------------------------------------
function psim_monin_obukhov (zeta) result(psi)
!
! !DESCRIPTION:
! Monin-Obukhov psi stability function for momentum
!
! !USES:
use clm_varcon, only : pi => rpi
!
! !ARGUMENTS:
implicit none
real(r8), intent(in) :: zeta ! Monin-Obukhov stability parameter
!
! !LOCAL VARIABLES:
real(r8) :: x ! (1 - 16*zeta)**1/4
real(r8) :: psi ! psi for momentum
!---------------------------------------------------------------------
if (zeta < 0._r8) then ! --- unstable
x = sqrt(sqrt(1._r8 - 16._r8 * zeta))
psi = 2._r8 * log((1._r8+x)/2._r8) + log((1._r8+x*x)/2._r8) - 2._r8*atan(x) + pi * 0.5_r8
else ! --- stable
psi = -5._r8 * zeta
end if
end function psim_monin_obukhov
!-----------------------------------------------------------------------
function psic_monin_obukhov (zeta) result(psi)
!
! !DESCRIPTION:
! Monin-Obukhov psi stability function for scalars
!
! !ARGUMENTS:
implicit none
real(r8), intent(in) :: zeta ! Monin-Obukhov stability parameter
!
! !LOCAL VARIABLES:
real(r8) :: x ! (1 - 16*zeta)**1/4
real(r8) :: psi ! psi for scalars
!---------------------------------------------------------------------
if (zeta < 0._r8) then ! --- unstable
x = sqrt(sqrt(1._r8 - 16._r8 * zeta))
psi = 2._r8 * log((1._r8+x*x)/2._r8)
else ! --- stable
psi = -5._r8 * zeta
end if
end function psic_monin_obukhov
!-----------------------------------------------------------------------
subroutine CanopyTurbulenceDummy (p, mlcanopy_inst)
!
! !DESCRIPTION:
! Dummy canopy turbulence - canopy scalar profiles equal reference height values
!
! !USES:
use clm_varpar, only : isun, isha
use CanopyFluxesMultilayerType, only : mlcanopy_type
!
! !ARGUMENTS:
implicit none
integer, intent(in) :: p ! Patch index for CLM g/l/c/p hierarchy
type(mlcanopy_type), intent(inout) :: mlcanopy_inst
!
! !LOCAL VARIABLES:
integer :: ic ! Aboveground layer index
!---------------------------------------------------------------------
associate ( &
! *** Input ***
ncan => mlcanopy_inst%ncan , & ! Number of aboveground layers
dpai => mlcanopy_inst%dpai , & ! Layer plant area index (m2/m2)
uref => mlcanopy_inst%uref , & ! Wind speed at reference height (m/s)
tref => mlcanopy_inst%tref , & ! Air temperature at reference height (K)
eref => mlcanopy_inst%eref , & ! Vapor pressure at reference height (Pa)
co2ref => mlcanopy_inst%co2ref , & ! Atmospheric CO2 at reference height (umol/mol)
tleaf => mlcanopy_inst%tleaf , & ! Leaf temperature (K)
! *** Output ***
z0mg => mlcanopy_inst%z0mg , & ! Roughness length of ground (m)
Lc => mlcanopy_inst%Lc , & ! Canopy density length scale (m)
obu => mlcanopy_inst%obu , & ! Obukhov length (m)
obuold => mlcanopy_inst%obuold , & ! Obukhov length from previous iteration
nmozsgn => mlcanopy_inst%nmozsgn , & ! Number of times stability changes sign during iteration
ustar => mlcanopy_inst%ustar , & ! Friction velocity (m/s)
tstar => mlcanopy_inst%tstar , & ! Temperature scale (K)
qstar => mlcanopy_inst%qstar , & ! Water vapor scale (kg/kg)
PrSc => mlcanopy_inst%PrSc , & ! Prandtl (Schmidt) number at canopy top
zdisp => mlcanopy_inst%zdisp , & ! Displacement height (m)
uaf => mlcanopy_inst%uaf , & ! Wind speed at canopy top (m/s)
taf => mlcanopy_inst%taf , & ! Air temperature at canopy top (K)
eaf => mlcanopy_inst%eaf , & ! Vapor pressure at canopy top (Pa)
qaf => mlcanopy_inst%qaf , & ! Specific humidity at canopy top (kg/kg)
gah => mlcanopy_inst%gah , & ! Aerodynamic conductance for a scalar above canopy (mol/m2/s)
shair => mlcanopy_inst%shair , & ! Canopy air sensible heat flux (W/m2)
etair => mlcanopy_inst%etair , & ! Canopy air water vapor flux (mol H2O/m2/s)
stair => mlcanopy_inst%stair , & ! Canopy air storage heat flux (W/m2)
wind => mlcanopy_inst%wind , & ! Wind speed profile (m/s)
tair => mlcanopy_inst%tair , & ! Air temperature profile (K)
eair => mlcanopy_inst%eair , & ! Vapor pressure profile (Pa)
cair => mlcanopy_inst%cair , & ! Atmospheric CO2 profile (umol/mol)
tveg => mlcanopy_inst%tveg , & ! Vegetation temperature profile (K)
ga_prof => mlcanopy_inst%ga_prof , & ! Canopy layer aerodynamic conductance for scalars (mol/m2/s)
wind_most=> mlcanopy_inst%wind_most , & ! Wind speed profile from MOST (m/s)
tair_most=> mlcanopy_inst%tair_most & ! Air temperature profile from MOST (K)
)
z0mg(p) = 0._r8
Lc(p) = 0._r8
obu(p) = 0._r8
obuold(p) = 0._r8
nmozsgn(p) = 0
ustar(p) = uref(p) ! cannot be zero for analysis package to work
tstar(p) = 0._r8
qstar(p) = 0._r8
PrSc(p) = 0._r8
zdisp(p) = 0._r8
uaf(p) = 0._r8
taf(p) = 0._r8
eaf(p) = 0._r8
qaf(p) = 0._r8
gah(p) = 0._r8
do ic = 0, ncan(p)
wind(p,ic) = uref(p)
tair(p,ic) = tref(p)
eair(p,ic) = eref(p)
cair(p,ic) = co2ref(p)
ga_prof(p,ic) = (1._r8 / 10._r8) * 42.3_r8 ! Small non-zero resistance
wind_most(p,ic) = uref(p)
tair_most(p,ic) = tref(p)
end do
! For soil surface, use a large resistance to approximate bare ground and
! so that soil fluxes are small
ga_prof(p,0) = (1._r8 / 100._r8) * 42.3_r8
tveg(p,0,isun) = tref(p)
tveg(p,0,isha) = tref(p)
do ic = 1, ncan(p)
shair(p,ic) = 0._r8
etair(p,ic) = 0._r8
stair(p,ic) = 0._r8
if (dpai(p,ic) > 0._r8) then
tveg(p,ic,isun) = tleaf(p,ic,isun)
tveg(p,ic,isha) = tleaf(p,ic,isha)
else
tveg(p,ic,isun) = tref(p)
tveg(p,ic,isha) = tref(p)
end if
end do
end associate
end subroutine CanopyTurbulenceDummy
!-----------------------------------------------------------------------
subroutine CanopyTurbulence (p, niter, soilstate_inst, temperature_inst, &
energyflux_inst, waterflux_inst, mlcanopy_inst)
!
! !DESCRIPTION:
! Canopy turbulence, aeorodynamic conductances, and wind/temperature/water vapor
! profiles using above- and within-canopy coupling with a roughness sublayer
! (RSL) parameterization
!
! !USES:
use clm_varctl, only : turb_type, use_scalars
use clm_varcon, only : mmh2o, mmdry, vkc
use MathToolsMod, only : hybrid
use PatchType, only : patch
use SoilStateType, only : soilstate_type
use TemperatureType, only : temperature_type
use EnergyFluxType, only : energyflux_type
use WaterFluxType, only : waterflux_type
use CanopyFluxesMultilayerType, only : mlcanopy_type
use pftconMod, only : pftcon
!
! !ARGUMENTS:
implicit none
integer, intent(in) :: p ! Patch index for CLM g/l/c/p hierarchy
integer, intent(in) :: niter ! Iteration index
type(soilstate_type), intent(inout) :: soilstate_inst
type(temperature_type), intent(inout) :: temperature_inst
type(energyflux_type), intent(inout) :: energyflux_inst
type(waterflux_type), intent(inout) :: waterflux_inst
type(mlcanopy_type), intent(inout) :: mlcanopy_inst
!
! !LOCAL VARIABLES:
integer :: c ! Column index for CLM g/l/c/p hierarchy
integer :: ic ! Canopy layer index
integer :: il ! Sunlit (1) or shaded (2) leaf index
integer :: iterate ! CLM: 1 = iterate for Obukhov length. 0 = use specified Obukhov length
real(r8) :: dummy ! Dummy argument
real(r8) :: lm ! Length scale for momentum (m)
real(r8) :: beta ! Value of u*/u(h) at canopy top
real(r8) :: res ! Resistance (s/m)
real(r8) :: zu, zl ! Upper and lower heights for within canopy resistances (m)
real(r8) :: obu0, obu1 ! Initial estimates for Obukhov length (m)
real(r8) :: z0hg ! Roughness length of ground for sensible heat (m)
real(r8) :: zlog_m, zlog_c ! Log-profiles at ground
real(r8) :: ustar_g ! Friction velocity at ground (m/s)
real(r8) :: eta ! Used to limit value for beta/lm
real(r8) :: beta_over_lm ! beta/lm (1/m)
real(r8) :: tol ! Accuracy tolerance for Obukhov length (m)
real(r8) :: zeta ! (z - d)/L
real(r8) :: phic ! Flux-gradient relationship at (hc - d)/L
real(r8) :: kc_at_hc ! Scalar eddy diffusivity at canopy top (m2/s)
!!! NEW
real(r8) :: dt ! Height below canopy top (dt = ztop - zdisp)
real(r8) :: psim ! psi function for momentum
real(r8) :: psic ! psi function for scalars
real(r8) :: psim1, psim2
real(r8) :: psic1, psic2
real(r8) :: ga_add
real(r8) :: sumres
real(r8) :: zdisp_most, z0m_most, zeta_most, psim_most_z0m, psim_most, zlog_most, ustar_most
real(r8) :: z0c_most, sh_most, tstar_most, psic_most_z0c, psic_most, ts_most
!---------------------------------------------------------------------
associate ( &
! *** Input ***
ztop => mlcanopy_inst%ztop , & ! Canopy height (m)
ncan => mlcanopy_inst%ncan , & ! Number of aboveground layers
ntop => mlcanopy_inst%ntop , & ! Index for top leaf layer
lai => mlcanopy_inst%lai , & ! Leaf area index of canopy (m2/m2)
sai => mlcanopy_inst%sai , & ! Stem area index of canopy (m2/m2)
zs => mlcanopy_inst%zs , & ! Canopy height for scalar concentration and source (m)
co2ref => mlcanopy_inst%co2ref , & ! Atmospheric CO2 at reference height (umol/mol)
pref => mlcanopy_inst%pref , & ! Air pressure at reference height (Pa)
rhomol => mlcanopy_inst%rhomol , & ! Molar density at reference height (mol/m3)
eg => mlcanopy_inst%eg , & ! Soil surface vapor pressure (Pa)
tg => mlcanopy_inst%tg , & ! Soil surface temperature (K)
zref => mlcanopy_inst%zref , & ! Reference height (m)
uref => mlcanopy_inst%uref , & ! Wind speed at reference height (m/s)
thref => mlcanopy_inst%thref , & ! Atmospheric potential temperature (K)
cpair => mlcanopy_inst%cpair , & ! Specific heat of air at constant pressure, at reference height (J/mol/K)
z0mr => pftcon%z0mr , & ! Ratio of momentum roughness length to canopy top height
displar => pftcon%displar , & ! Ratio of displacement height to canopy top height
! *** Output ***
z0mg => mlcanopy_inst%z0mg , & ! Roughness length of ground (m)
Lc => mlcanopy_inst%Lc , & ! Canopy density length scale (m)
obu => mlcanopy_inst%obu , & ! Obukhov length (m)
obu_gah => mlcanopy_inst%obu_gah , & ! Obukhov length used for gah (m)
obuold => mlcanopy_inst%obuold , & ! Obukhov length from previous iteration
nmozsgn => mlcanopy_inst%nmozsgn , & ! Number of times stability changes sign during iteration
ustar => mlcanopy_inst%ustar , & ! Friction velocity (m/s)
tstar => mlcanopy_inst%tstar , & ! Temperature scale (K)
qstar => mlcanopy_inst%qstar , & ! Water vapor scale (kg/kg)
PrSc => mlcanopy_inst%PrSc , & ! Prandtl (Schmidt) number at canopy top
zdisp => mlcanopy_inst%zdisp , & ! Displacement height (m)
uaf => mlcanopy_inst%uaf , & ! Wind speed at canopy top (m/s)
taf => mlcanopy_inst%taf , & ! Air temperature at canopy top (K)
eaf => mlcanopy_inst%eaf , & ! Vapor pressure at canopy top (Pa)
qaf => mlcanopy_inst%qaf , & ! Specific humidity at canopy top (kg/kg)
wind => mlcanopy_inst%wind , & ! Wind speed profile (m/s)
wind_most=> mlcanopy_inst%wind_most , & ! Wind speed profile from MOST (m/s)
tair => mlcanopy_inst%tair , & ! Air temperature profile (K)
tair_most=> mlcanopy_inst%tair_most , & ! Air temperature profile from MOST (K)
eair => mlcanopy_inst%eair , & ! Vapor pressure profile (Pa)
cair => mlcanopy_inst%cair , & ! Atmospheric CO2 profile (umol/mol)
gah => mlcanopy_inst%gah , & ! Aerodynamic conductance for a scalar above canopy (mol/m2/s)
ga_prof => mlcanopy_inst%ga_prof & ! Canopy layer aerodynamic conductance for scalars (mol/m2/s)
)
c = patch%column(p)
! Initialization for first iteration
if (niter == 1) then
obuold(p) = 0._r8
nmozsgn(p) = 0
end if
! Set roughness length of ground
z0mg(p) = 0.01_r8
! Canopy density length scale
Lc(p) = ztop(p) / (cd * (lai(p) + sai(p)))
! These are not used, but are needed to pass into the hybrid root solver
ic = 0
il = 0
! Calculate Obukhov length (obu)
select case (turb_type)
case (1:3)
! Calculate Obukhov length (obu) using the function ObuFunc to iterate until
! the change in obu is < tol. Do not use the returned value (dummy), and
! instead use the value of obu calculated in the final call to ObuFunc.
obu0 = 100._r8 ! Initial estimate for Obukhov length (m)
obu1 = -100._r8 ! Initial estimate for Obukhov length (m)
tol = 0.1_r8 ! Accuracy tolerance for Obukhov length (m)
dummy = hybrid ('CanopyTurbulence', p, ic, il, mlcanopy_inst, ObuFunc, obu0, obu1, tol)
obu(p) = obu_gah(p)
case (4)
! Use CLM calculation of Obukhov length (obu)
iterate = 1
call ObuFuncCLM (p, iterate, mlcanopy_inst)
obu(p) = obu_gah(p)
end select
! Check to see if Obukhov length is changing signs between iterations.
! If too many changes in sign, set it to a near-neutral value.
if (obuold(p)*obu(p) < 0._r8) nmozsgn(p) = nmozsgn(p) + 1
obuold(p) = obu(p)
if (nmozsgn(p) >= 4) then
obu(p) = -1000._r8
select case (turb_type)
case (1:3)
dummy = ObuFunc (p, ic, il, mlcanopy_inst, obu(p))
obu(p) = obu_gah(p)
case (4)
iterate = 0
call ObuFuncCLM (p, iterate, mlcanopy_inst)
obu(p) = obu_gah(p)
end select
end if
! Above-canopy wind profile: wind speed is defined at zs
select case (turb_type)
case (1:3)
dt = ztop(p) - zdisp(p)
beta = ustar(p) / uaf(p)
do ic = ntop(p)+1, ncan(p)
zeta = (zs(p,ic) - zdisp(p)) / obu(p)
call GetPsiRSL (zs(p,ic), ztop(p), dt, beta, zeta, obu(p), PrSc(p), psim, psic)
zlog_m = log((zs(p,ic)-zdisp(p)) / (ztop(p)-zdisp(p)))
wind(p,ic) = ustar(p) / vkc * (zlog_m + psim)
end do
end select
! Above-canopy aerodynamic conductances: these are defined between
! zs(i) and zs(i+1). Note the special case for the top layer to the
! reference height.
select case (turb_type)
case (1:3)
do ic = ntop(p)+1, ncan(p)-1
zeta = (zs(p,ic) - zdisp(p)) / obu(p)
call GetPsiRSL (zs(p,ic), ztop(p), dt, beta, zeta, obu(p), PrSc(p), psim1, psic1)
zeta = (zs(p,ic+1) - zdisp(p)) / obu(p)
call GetPsiRSL (zs(p,ic+1), ztop(p), dt, beta, zeta, obu(p), PrSc(p), psim2, psic2)
! equivalent to: -psi_c_z2 + psi_c_z1 + psi_c_rsl_z2 - psi_c_rsl_z1
psic = psic2 - psic1
zlog_c = log((zs(p,ic+1)-zdisp(p)) / (zs(p,ic)-zdisp(p)))
ga_prof(p,ic) = rhomol(p) * vkc * ustar(p) / (zlog_c + psic)
end do
ic = ncan(p)
zeta = (zs(p,ic) - zdisp(p)) / obu(p)
call GetPsiRSL (zs(p,ic), ztop(p), dt, beta, zeta, obu(p), PrSc(p), psim1, psic1)
zeta = (zref(p) - zdisp(p)) / obu(p)
call GetPsiRSL (zref(p), ztop(p), dt, beta, zeta, obu(p), PrSc(p), psim2, psic2)
psic = psic2 - psic1
zlog_c = log((zref(p)-zdisp(p)) / (zs(p,ic)-zdisp(p)))
ga_prof(p,ic) = rhomol(p) * vkc * ustar(p) / (zlog_c + psic)
end select
! Within-canopy wind profile: wind speed is defined at zs
beta = ustar(p) / uaf(p)
lm = 2._r8 * beta**3 * Lc(p)
select case (turb_type)
case (1, 2)
! eta = min (beta/lm*ztop(p), 10._r8)
eta = min (beta/lm*ztop(p), 20._r8)
case (3, 4)
eta = 3._r8
end select
beta_over_lm = eta / ztop(p)
! beta_over_lm = beta / lm
do ic = 1, ntop(p)
wind(p,ic) = uaf(p) * exp((zs(p,ic) - ztop(p)) * beta_over_lm)
wind(p,ic) = max(wind(p,ic), 0.1_r8)
end do
! Scalar eddy diffusivity at canopy top
select case (turb_type)
case (1:3)
kc_at_hc = 2._r8 * beta**3 * Lc(p) * ustar(p) / PrSc(p)
case (4)
zeta = (ztop(p) - zdisp(p)) / obu(p)
if (zeta < zetah) then ! very unstable (zeta < zetah)
phic = 0.9 * vkc**1.333_r8 * (-zeta)**(-0.333_r8)
else if (zeta < 0._r8) then ! unstable (zetah <= zeta < 0)
phic = 1._r8 / sqrt(1._r8 - 16._r8 * zeta)
else if (zeta <= 1._r8) then ! stable (0 <= zeta <= 1)
phic = 1._r8 + 5._r8 * zeta
else ! very stable (zeta > 1)
phic = 5._r8 + zeta
end if
kc_at_hc = vkc * ustar(p) * (ztop(p) - zdisp(p)) / phic
end select
! Within-canopy aerodynamic conductances: these are defined between
! zs(i) and zs(i+1). Note the special case for the top layer to the
! canopy height.
do ic = 1, ntop(p)-1
zl = zs(p,ic) - ztop(p)
zu = zs(p,ic+1) - ztop(p)
! res = PrSc(p) / (beta * ustar(p)) * (exp(-zl*beta_over_lm) - exp(-zu*beta_over_lm))
res = 1._r8 / (kc_at_hc * beta_over_lm) * (exp(-zl*beta_over_lm) - exp(-zu*beta_over_lm))
ga_prof(p,ic) = rhomol(p) / res
end do
! Special case for top layer: conductance to top of canopy
ic = ntop(p)
zl = zs(p,ic) - ztop(p)
zu = ztop(p) - ztop(p)
! res = PrSc(p) / (beta * ustar(p)) * (exp(-zl*beta_over_lm) - exp(-zu*beta_over_lm))
res = 1._r8 / (kc_at_hc * beta_over_lm) * (exp(-zl*beta_over_lm) - exp(-zu*beta_over_lm))
ga_prof(p,ic) = rhomol(p) / res
! Now add additional resistance to first atmospheric layer
if (ncan(p) == ntop(p)) then
ga_add = gah(p)
else if (ncan(p) > ntop(p)) then
select case (turb_type)
case (1:3)
zeta = (ztop(p) - zdisp(p)) / obu(p)
call GetPsiRSL (ztop(p), ztop(p), dt, beta, zeta, obu(p), PrSc(p), psim1, psic1)
zeta = (zs(p,ic+1) - zdisp(p)) / obu(p)
call GetPsiRSL (zs(p,ic+1), ztop(p), dt, beta, zeta, obu(p), PrSc(p), psim2, psic2)
psic = psic2 - psic1
zlog_c = log((zs(p,ic+1)-zdisp(p)) / (ztop(p)-zdisp(p)))
ga_add = rhomol(p) * vkc * ustar(p) / (zlog_c + psic)
end select
end if
ga_prof(p,ic) = 1._r8 / (1._r8 / ga_prof(p,ic) + 1._r8 / ga_add)
! Make sure above-canopy aerodynamic resistances sum to 1/gah
sumres = 0._r8
do ic = ntop(p)+1, ncan(p)
sumres = sumres + 1._r8 / ga_prof(p,ic)
end do
sumres = sumres + 1._r8 / ga_add
if (abs(1._r8/sumres - gah(p)) > 1.e-06_r8) then
call endrun (msg=' ERROR: CanopyTurbulenceMod: above-canopy aerodynamic conductance error')
end if
! Resistance at ground
! zl = 0._r8 - ztop(p)
! zu = zs(p,1) - ztop(p)
! res = PrSc(p) / (beta * ustar(p)) * (exp(-zl*beta/lm) - exp(-zu*beta/lm))
! res = ga_prof(p,1)
z0hg = 0.1_r8 * z0mg(p)
zlog_m = log(zs(p,1)/z0mg(p))
zlog_c = log(zs(p,1)/z0hg)
ustar_g = wind(p,1) * vkc / zlog_m
ustar_g = max(ustar_g, 0.01_r8)
res = zlog_c / (vkc * ustar_g)
ga_prof(p,0) = rhomol(p) / res
if (zlog_m < 0._r8 .or. zlog_c < 0._r8) then
call endrun (msg=' ERROR: CanopyTurbulenceMod: soil roughness error')
end if
! Convert resistance (s/m) to conductance (mol/m2/s)
! Limit resistances to < 500 s/m
do ic = 0, ncan(p)
res = min (rhomol(p)/ga_prof(p,ic), 500._r8)
ga_prof(p,ic) = rhomol(p) / res
end do
! Values at ground
wind(p,0) = 0._r8
tair(p,0) = tg(p)
eair(p,0) = eg(p)
! Calculate within-canopy scalar profiles for temperature and vapor pressure
! using an implicit solution
call ScalarProfile (p, niter, soilstate_inst, temperature_inst, &
energyflux_inst, waterflux_inst, mlcanopy_inst)
! Calculate within-canopy scalar profiles for temperature, vapor pressure, and CO2
! using an iterative coupling
!
! Temperature: scalar is T*cp (J/mol) and flux is J/m2/s
! Water vapor: scalar is e/P (mol/mol) and flux is mol/m2/s
! CO2: scalar is c (umol/mol) and flux is umol/m2/s
! call ScalarProfileIterative (ncan(p), tref(p), ga_prof(p,:), sh_prof(p,:), &
! 1._r8/cpair(p), tair_old(p,:), tair(p,:))
! call ScalarProfileIterative (ncan(p), eref(p), ga_prof(p,:), et_prof(p,:), &
! pref(p), eair_old(p,:), eair(p,:))
! call ScalarProfileIterative (ncan(p), co2ref(p), ga_prof(p,:), fc_prof(p,:), &
! 1._r8, cair_old(p,:), cair(p,:))
do ic = 0, ncan(p)
cair(p,ic) = co2ref(p)
end do
if (.not. use_scalars) then
do ic = 1, ntop(p)
wind(p,ic) = wind(p,ntop(p))
tair(p,ic) = tair(p,ntop(p))
eair(p,ic) = eair(p,ntop(p))
end do
end if
taf(p) = tair(p,ntop(p))
eaf(p) = eair(p,ntop(p))
qaf(p) = mmh2o / mmdry * eaf(p) / (pref(p) - (1._r8 - mmh2o/mmdry) * eaf(p))
! Wind and temperature profiles using MOST
wind_most(p,0) = -999._r8
tair_most(p,0) = -999._r8
zdisp_most = displar(patch%itype(p)) * ztop(p)
z0m_most = z0mr(patch%itype(p)) * ztop(p)
z0c_most = z0m_most
zeta_most = (zref(p) - zdisp_most) / obu(p)
psim_most_z0m = psim_monin_obukhov(z0m_most/obu(p))
psim_most = -psim_monin_obukhov(zeta_most) + psim_most_z0m
zlog_most = log((zref(p)-zdisp_most) / z0m_most)
ustar_most = uref(p) * vkc / (zlog_most + psim_most)
sh_most = -cpair(p) * (tair(p,ntop(p)+1) - tair(p,ntop(p))) * ga_prof(p,ntop(p))
tstar_most = -sh_most / (rhomol(p) * cpair(p) * ustar_most)
psic_most_z0c = psic_monin_obukhov(z0c_most/obu(p))
psic_most = -psic_monin_obukhov(zeta_most) + psic_most_z0c
zlog_most = log((zref(p)-zdisp_most) / z0c_most)
ts_most = thref(p) - tstar_most / vkc * (zlog_most + psic_most)
do ic = ncan(p), 1, -1
if (zs(p,ic) > zdisp_most) then
zeta_most = (zs(p,ic) - zdisp_most) / obu(p)
psim_most = -psim_monin_obukhov(zeta_most) + psim_most_z0m
psic_most = -psic_monin_obukhov(zeta_most) + psic_most_z0c
zlog_most = log((zs(p,ic)-zdisp_most) / z0m_most)
wind_most(p,ic) = ustar_most / vkc * (zlog_most + psim_most)
zlog_most = log((zs(p,ic)-zdisp_most) / z0c_most)
tair_most(p,ic) = ts_most + tstar_most / vkc * (zlog_most + psic_most)
else
wind_most(p,ic) = -999._r8
tair_most(p,ic) = -999._r8
end if
end do
end associate
end subroutine CanopyTurbulence
!-----------------------------------------------------------------------
function ObuFunc (p, ic, il, mlcanopy_inst, obu_val) result(obu_dif)
!
! !DESCRIPTION:
! This is the function to solve for the Obukhov length (obu). For the current
! estimate of the Obukhov length (obu_val), calculate u* , T*, and q* and then
! the new length (obu). The function value is the change in Obukhov length and
! equals zero when the the Obukhov length does not change value between iterations.
!
! !USES:
use clm_varcon, only : grav, vkc
use clm_varctl, only : turb_type
use CanopyFluxesMultilayerType, only : mlcanopy_type
!
! !ARGUMENTS:
implicit none
integer, intent(in) :: p ! Patch index for CLM g/l/c/p hierarchy
integer, intent(in) :: ic ! Aboveground layer index
integer, intent(in) :: il ! Sunlit (1) or shaded (2) leaf index
real(r8), intent(in) :: obu_val ! Input value for Obukhov length (m)
type(mlcanopy_type), intent(inout) :: mlcanopy_inst
!
! !LOCAL VARIABLES:
real(r8) :: c1 ! Parameter to calculate beta_neutral
real(r8) :: beta_neutral ! Neutral value for beta = u*/u(h), ~0.3-0.5
real(r8) :: beta ! Value of u*/u(h) at canopy top
real(r8) :: dt ! Height below canopy top (dt = ztop - zdisp)
real(r8) :: zeta ! Monin-Obukhov stability parameter (z-d)/L
real(r8) :: psim ! psi function for momentum
real(r8) :: psic ! psi function for scalars
real(r8) :: zlog ! log((zref-zdisp)/(ztop-zdisp))
real(r8) :: tvstar ! Virtual potential temperature scale (K)
real(r8) :: obu_dif ! Difference in Obuhkov length (m)
!---------------------------------------------------------------------
associate ( &
! *** Input ***
ztop => mlcanopy_inst%ztop , & ! Canopy height (m)
z0mg => mlcanopy_inst%z0mg , & ! Roughness length of ground (m)
lai => mlcanopy_inst%lai , & ! Leaf area index of canopy (m2/m2)
sai => mlcanopy_inst%sai , & ! Stem area index of canopy (m2/m2)
Lc => mlcanopy_inst%Lc , & ! Canopy density length scale (m)
zref => mlcanopy_inst%zref , & ! Reference height (m)
uref => mlcanopy_inst%uref , & ! Wind speed at reference height (m/s)
rhomol => mlcanopy_inst%rhomol , & ! Molar density at reference height (mol/m3)
qref => mlcanopy_inst%qref , & ! Specific humidity at reference height (kg/kg)
qaf => mlcanopy_inst%qaf , & ! Specific humidity at canopy top (kg/kg)
thref => mlcanopy_inst%thref , & ! Atmospheric potential temperature (K)
thvref => mlcanopy_inst%thvref , & ! Atmospheric virtual potential temperature (K)
taf => mlcanopy_inst%taf , & ! Air temperature at canopy top (K)
! *** Output ***
ustar => mlcanopy_inst%ustar , & ! Friction velocity (m/s)
tstar => mlcanopy_inst%tstar , & ! Temperature scale (K)
qstar => mlcanopy_inst%qstar , & ! Water vapor scale (kg/kg)
gah => mlcanopy_inst%gah , & ! Aerodynamic conductance for a scalar above canopy (mol/m2/s)
obu => mlcanopy_inst%obu , & ! Obukhov length (m)
obu_gah => mlcanopy_inst%obu_gah , & ! Obukhov length used for gah (m)
PrSc => mlcanopy_inst%PrSc , & ! Prandtl (Schmidt) number at canopy top
zdisp => mlcanopy_inst%zdisp , & ! Displacement height (m)
uaf => mlcanopy_inst%uaf & ! Wind speed at canopy top (m/s)
)
! Use this current value of Obukhov length
obu(p) = obu_val
! Prevent near-zero value of Obukhov length
if (abs(obu(p)) <= 0.1_r8) obu(p) = 0.1_r8
! Determine neutral value of beta
select case (turb_type)
case (1, 3)
c1 = (vkc / log((ztop(p) + z0mg(p))/z0mg(p)))**2
beta_neutral = min( sqrt(c1 + cr*(lai(p)+sai(p))), beta_neutral_max)
case (2)
beta_neutral = vkc / 2._r8
end select
! Calculate beta = u* / u(h) for current Obukhov length
call GetBeta (beta_neutral, Lc(p)/obu(p), beta)
! Displacement height: dt is height below canopy top (dt = ztop - zdisp)
dt = beta**2 * Lc(p)
dt = dt * (1._r8 - exp(-0.25_r8*(lai(p)+sai(p))/beta**2))
dt = min(ztop(p), dt)
zdisp(p) = ztop(p) - dt
if ((zref(p) - zdisp(p)) < 0._r8) then
call endrun (msg=' ERROR: CanopyTurbulenceMod: ObuFunc error, zdisp height > zref')
end if
! Calculate turbulent Prandlt number (Pr) and Schmidt number (Sc) at canopy
! top for current Obukhov length. Only need Pr because Sc = Pr.
select case (turb_type)
case (1, 3)
call GetPrSc (beta_neutral, beta_neutral_max, Lc(p)/obu(p), PrSc(p))
case (2)
PrSc(p) = 1._r8
end select
! Calculate the stability functions psi for momentum and scalars. The
! returned function values (psim, psic) are the Monin-Obukhov psi functions
! and additionally include the roughness sublayer psi_hat functions.
! These are evaluated at the reference height and at the canopy height.
! Here, limit Obukhov length based on values of zeta so that extreme
! cases are excluded.
zeta = (zref(p) - zdisp(p)) / obu(p)
if (zeta >= 0._r8) then
zeta = min(1._r8, max(zeta,0.01_r8))
else
zeta = max(-2._r8, min(zeta,-0.01_r8))
end if
obu(p) = (zref(p) - zdisp(p)) / zeta
call GetPsiRSL (zref(p), ztop(p), dt, beta, zeta, obu(p), PrSc(p), psim, psic)
! Friction velocity
zlog = log((zref(p)-zdisp(p)) / (ztop(p)-zdisp(p)))
ustar(p) = uref(p) * vkc / (zlog + psim)
! Wind speed at canopy height
uaf(p) = ustar(p) / beta
! Temperature scale
tstar(p) = (thref(p) - taf(p)) * vkc / (zlog + psic)
! Water vapor scale - use units of specific humidity (kg/kg)
qstar(p) = (qref(p) - qaf(p)) * vkc / (zlog + psic)
! Aerodynamic conductance to canopy height
gah(p) = rhomol(p) * vkc * ustar(p) / (zlog + psic)
obu_gah(p) = obu(p)
! Calculate new Obukhov length (m)
tvstar = tstar(p) + 0.61_r8 * thref(p) * qstar(p)
obu(p) = ustar(p)**2 * thvref(p) / (vkc * grav * tvstar)
! Change in Obukhov length (m)
obu_dif = obu(p) - obu_val
end associate
end function ObuFunc
!-----------------------------------------------------------------------
subroutine GetBeta (beta_neutral, LcL, beta)
!
! !DESCRIPTION:
! Calculate beta = u* / u(h) for current Obukhov length
!
! !ARGUMENTS:
implicit none
real(r8), intent(in) :: beta_neutral ! Neutral value for beta = u*/u(h), ~0.3-0.5
real(r8), intent(in) :: LcL ! Canopy density scale (Lc) / Obukhov length (obu)
real(r8), intent(out) :: beta ! Value of u*/u(h) at canopy top
!
! !LOCAL VARIABLES:
real(r8) :: aa, bb, cc, dd, qq, rr ! Terms for quadratic or cubic solution
real(r8) :: LcL_val ! LcL with limits applied
!---------------------------------------------------------------------
LcL_val = LcL
if (LcL_val <= 0._r8) then
! Unstable case: quadratic equation for beta^2 at LcL_val
bb = 16._r8 * LcL_val * beta_neutral**4
beta = sqrt( 0.5_r8*(-bb + sqrt(bb**2 + 4._r8 * beta_neutral**4)) )
else
! Stable case: cubic equation for beta at LcL_val
aa = 5._r8 * LcL_val
bb = 0._r8
cc = 1._r8
dd = -beta_neutral
qq = (2._r8*bb**3 - 9._r8*aa*bb*cc + 27._r8*(aa**2)*dd)**2 - 4._r8*(bb**2 - 3._r8*aa*cc)**3
qq = sqrt(qq)
rr = 0.5_r8 * (qq + 2._r8*bb**3 - 9._r8*aa*bb*cc + 27._r8*(aa**2)*dd)
rr = rr**(1._r8/3._r8)
beta = -(bb+rr)/(3._r8*aa) - (bb**2 - 3._r8*aa*cc)/(3._r8*aa*rr)
end if
beta = min(0.50_r8, max(beta,0.20_r8))
end subroutine GetBeta
!-----------------------------------------------------------------------
subroutine GetPrSc (beta_neutral, beta_neutral_max, LcL, Pr)
!
! !DESCRIPTION:
! Calculate turbulent Prandlt number (Pr) and Schmidt number (Sc) at canopy
! top for current Obukhov length
!
! !ARGUMENTS:
implicit none
real(r8), intent(in) :: beta_neutral ! Neutral value for beta = u*/u(h), ~0.3-0.5
real(r8), intent(in) :: beta_neutral_max ! Maximum value for beta in neutral conditions
real(r8), intent(in) :: LcL ! Canopy density scale (Lc) / Obukhov length (obu)
real(r8), intent(out) :: Pr ! Prandtl number at canopy top
!
! !LOCAL VARIABLES:
real(r8), parameter :: Prn = 0.5_r8 ! Neutral value for Pr
real(r8), parameter :: Prvr = 0.3_r8 ! Magnitude of variation of Pr with stability
real(r8), parameter :: Prsc = 2.0_r8 ! Scale of variation of Pr with stability
real(r8) :: Sc ! Schmidt number at canopy top
real(r8), parameter :: Scn = Prn ! Neutral value for Sc
real(r8), parameter :: Scvr = Prvr ! Magnitude of variation of Sc with stability
real(r8), parameter :: Scsc = Prsc ! Scale of variation of Sc with stability
!---------------------------------------------------------------------
Pr = Prn + Prvr * tanh(Prsc*LcL)
Pr = (1._r8 - beta_neutral/beta_neutral_max) * 1._r8 + beta_neutral/beta_neutral_max*Pr
Sc = Scn + Scvr * tanh(Scsc*LcL)
Sc = (1._r8 - beta_neutral/beta_neutral_max) * 1._r8 + beta_neutral/beta_neutral_max*Sc
end subroutine GetPrSc
!-----------------------------------------------------------------------
subroutine GetPsiRSL (za, hc, dt, beta, zeta, obu, PrSc, psim, psic)
!
! !DESCRIPTION:
! Calculate the stability functions psi for momentum and scalars. The
! returned function values (psim, psic) are the Monin-Obukhov psi functions
! and additionally include the roughness sublayer psihat functions.
! These are evaluated between the height za and at the canopy height hc.
!
! !USES:
use clm_varctl, only : turb_type
use clm_varcon, only : vkc
use clm_varcon, only : dtLgridM, zdtgridM, psigridM, dtLgridH, zdtgridH, psigridH
!
! !ARGUMENTS:
implicit none
real(r8), intent(in) :: za ! Atmospheric height (m)
real(r8), intent(in) :: hc ! Canopy height (m)
real(r8), intent(in) :: dt ! Height below canopy top (dt = ztop - zdisp)
real(r8), intent(in) :: beta ! Value of u*/u(h) at canopy top
real(r8), intent(in) :: zeta ! Monin-Obukhov stability parameter (za-d)/L
real(r8), intent(in) :: obu ! Obukhov length (m)
real(r8), intent(in) :: PrSc ! Turbulent Prandtl (Schmidt) number at canopy top
real(r8), intent(out) :: psim ! psi function for momentum including RSL influence
real(r8), intent(out) :: psic ! psi function for scalars including RSL influence
!
! !LOCAL VARIABLES:
real(r8) :: phim ! Monin-Obukhov phi function for momentum at canopy top
real(r8) :: phic ! Monin-Obukhov phi function for scalars at canopy top
real(r8) :: c1 ! RSL magnitude multiplier
real(r8) :: psihat1 ! Multiply by c1 to get the RSL psihat function evaluated at za
real(r8) :: psihat2 ! Multiply by c1 to get the RSL psihat function evaluated at hc
!---------------------------------------------------------------------
! In the RSL theory, c1 and c2 represent the scaled magnitude and
! height over which the RSL theory modifies MOST via the psihat functions:
!
!
! z
! ^
! | . ___
! | . ^
! | . |
! | . |
! | . |
! | . |
! | . c2
! | . |
! | . |
! | . |
! | . |
! | . _\/_
! -------------------------------------------> u
! |<-------------- c1 --------------->|
! Evaluate the roughness sublayer psihat function for momentum at
! the height za and at the canopy height hc. Values for psihat are obtained
! from a look-up table. Here, heights are above the canopy for compatibility
! with the supplied look-up table. These heights are also scaled by dt = hc-d
! so that the look-up table uses (za-hc)/dt and (hc-hc)/dt. Also the term
! dt in the integration of psihat is scaled by the Obukhov length L (dt/obu).
! This means that the returned psihat value needs to be scaled (multiplied) by
! c1 before it fully represents psihat as it appears in the RSL equations.
select case (turb_type)
case (1, 3)
call LookupPsihat ((za-hc)/dt, dt/obu, zdtgridM, dtLgridM, psigridM, psihat1)
call LookupPsihat ((hc-hc)/dt, dt/obu, zdtgridM, dtLgridM, psigridM, psihat2)
case (2)
psihat1 = 0._r8
psihat2 = 0._r8
end select
phim = phim_monin_obukhov(dt/obu)
c1 = (1._r8 - vkc / (2._r8 * beta * phim)) * exp(0.5_r8*c2)
psim = -psim_monin_obukhov(zeta) + psim_monin_obukhov(dt/obu) + c1*(psihat1 - psihat2) + vkc / beta
! Now do the same for heat
select case (turb_type)
case (1, 3)