24 use machine,
only: kind_phys, kind_dbl_prec
30 public :: clm_lake_run, clm_lake_init, lakedebug
36 integer,
parameter,
public :: kind_lake = kind_dbl_prec
38 logical :: LAKEDEBUG = .false.
39 logical :: DEBUG_PRINT = .false.
41 logical,
parameter :: PERGRO = .false.
43 logical,
parameter :: USE_ETALAKE = .false.
44 real(kind_lake),
parameter :: ETALAKE = 1.1925*50**(-0.424)
47 integer,
parameter :: nlevsoil = 10
48 integer,
parameter :: nlevlake = 10
49 integer,
parameter :: nlevsnow = 5
50 real(kind_lake),
parameter :: scalez = 0.025_kind_lake
52 integer,
parameter :: lbp = 1
53 integer,
parameter :: ubp = 1
54 integer,
parameter :: lbc = 1
55 integer,
parameter :: ubc = 1
56 integer,
parameter :: num_shlakec = 1
57 integer,
parameter :: filter_shlakec(1) = 1
58 integer,
parameter :: num_shlakep = 1
59 integer,
parameter :: filter_shlakep(1) = 1
60 integer,
parameter :: pcolumn(1) = 1
61 integer,
parameter :: pgridcell(1) = 1
62 integer,
parameter :: cgridcell(1) = 1
63 integer,
parameter :: clandunit(1) = 1
65 integer,
parameter :: begg = 1
66 integer,
parameter :: endg = 1
67 integer,
parameter :: begl = 1
68 integer,
parameter :: endl = 1
69 integer,
parameter :: begc = 1
70 integer,
parameter :: endc = 1
71 integer,
parameter :: begp = 1
72 integer,
parameter :: endp = 1
74 integer,
parameter :: column =1
75 logical,
parameter :: lakpoi(1) = .true.
78 real(kind_lake),
parameter :: tcrit = 2.5
79 real(kind_lake),
parameter :: tkwat = 0.6
80 real(kind_lake),
parameter :: tkice = 2.290
81 real(kind_lake),
parameter :: tkairc = 0.023
82 real(kind_lake),
parameter :: snow_bd = 250
86 real(kind_lake) :: vkc
87 real(kind_lake) :: grav
89 real(kind_lake) :: tfrz
90 real(kind_lake) :: denh2o
91 real(kind_lake) :: denice
92 real(kind_lake) :: cpice
93 real(kind_lake) :: cpliq
94 real(kind_lake) :: hfus
95 real(kind_lake) :: hvap
96 real(kind_lake) :: hsub
97 real(kind_lake) :: invhvap
98 real(kind_lake) :: invhsub
99 real(kind_lake) :: rair
100 real(kind_lake) :: cpair
101 real(kind_lake) :: con_eps
102 real(kind_lake) :: one_minus_con_eps
103 real(kind_lake) :: con_fvirt
105 real(kind_lake),
public,
parameter :: spval = 1.e36
106 real(kind_lake),
parameter :: depth_c = 50.
107 real(kind_lake),
parameter :: zero_h2o = 1e-12
110 real(kind_lake),
parameter :: wimp = 0.05
111 real(kind_lake),
parameter :: ssi = 0.033
112 real(kind_lake),
parameter :: cnfac = 0.5
115 integer,
parameter :: istsoil = 1
118 real(kind_lake),
parameter :: sand(19) = &
119 (/92.,80.,66.,20.,5.,43.,60.,10.,32.,51., 6.,22.,39.7,0.,100.,54.,17.,100.,92./)
122 real(kind_lake),
parameter :: clay(19) = &
123 (/ 3., 5.,10.,15.,5.,18.,27.,33.,33.,41.,47.,58.,14.7,0., 0., 8.5,54., 0., 3./)
126 real(kind_lake) :: zlak(1:nlevlake)
127 real(kind_lake) :: dzlak(1:nlevlake)
128 real(kind_lake) :: zsoi(1:nlevsoil)
129 real(kind_lake) :: dzsoi(1:nlevsoil)
130 real(kind_lake) :: zisoi(0:nlevsoil)
132 real,
parameter :: saltlk_t(1:25) = (/ 0.5, 0.,-0.5, 3., 4., 7., 8., 12., 13., 16., 19., 21., &
133 23.5, 25., 26.,24.,23.,20.5,18., 15., 11.5, 8., 4., 1., 0.5/)
134 real,
parameter :: month_length(12) = (/ 31, 29, 31, 30, 31, 30, 31, 30, 30, 31, 30, 31 /)
135 logical,
parameter :: include_all_salty_locations = .false.
141 logical function limit_temperature_by_climatology(xlat_d,xlon_positive)
143 real(kind_phys),
intent(in) :: xlat_d, xlon_positive
144 real(kind_phys) :: xlon_d
146 xlon_d = xlon_positive
147 if(xlon_d>180) xlon_d = xlon_d - 360
149 limit_temperature_by_climatology=.false.
160 if ((xlon_d.gt.-117.7 .and. xlon_d.lt.-111.5) .and. &
162 .not. (xlon_d.gt.-112.104 .and. xlon_d.lt.-112.100))
then
164 if(xlat_d.gt.39.5 .and. xlat_d.lt.41.22)
then
166 print *,
'The Great Salt Lake south of 41.22 N, lat,lon',xlat_d,xlon_d
168 limit_temperature_by_climatology = .true.
170 elseif(( xlat_d.ge.41.22 .and. xlat_d.lt.42.) .and. .not. &
172 (xlat_d.gt.41.352 .and. xlat_d.lt.41.354))
then
174 print *,
'The Great Salt Lake north of 41.22 N xlat_d,xlon_d ',xlat_d,xlon_d
177 limit_temperature_by_climatology = .true.
185 end function limit_temperature_by_climatology
189 subroutine is_salty(xlat_d,xlon_positive, cannot_freeze, salty)
191 real(kind_phys),
intent(in) :: xlat_d, xlon_positive
192 logical,
intent(inout) :: cannot_freeze, salty
193 real(kind_phys) :: xlon_d
195 xlon_d = xlon_positive
196 if(xlon_d>180) xlon_d = xlon_d - 360
199 cannot_freeze = limit_temperature_by_climatology(xlat_d,xlon_d)
200 salty = cannot_freeze
204 if (xlon_d.gt.-119.3.and. xlon_d.lt.-118.8)
then
205 if(xlat_d.gt.37.9 .and. xlat_d.lt.38.2)
then
208 print *,
'Salty Mono Lake, i,j',xlat_d,xlon_d
213 other_locations:
if(include_all_salty_locations)
then
215 if ( xlat_d>36.5_kind_phys .and. xlat_d<47.1_kind_phys .and. xlon_d>46.8_kind_phys .and. xlon_d<55.0_kind_phys )
then
217 print *,
'Salty Caspian Sea ',xlat_d,xlon_d
221 if ( xlon_d>35.3 .and. xlon_d<35.6 .and. xlat_d>31.3 .and. xlat_d<31.8)
then
223 print *,
'Salty Dead Sea ',xlat_d,xlon_d
227 endif other_locations
229 end subroutine is_salty
233 subroutine calculate_z_dz_lake(i,input_lakedepth,clm_lakedepth,z_lake,dz_lake)
235 integer,
intent(in) :: i
236 real(kind_phys),
intent(inout) :: clm_lakedepth(:)
237 real(kind_phys),
intent(in) :: input_lakedepth(:)
238 real(kind_lake) :: z_lake(nlevlake)
239 real(kind_lake) :: dz_lake(nlevlake)
240 real(kind_lake) :: depthratio
242 if (input_lakedepth(i) == spval .or. input_lakedepth(i) < 0.1)
then
246 clm_lakedepth(i) = zlak(nlevlake) + 0.5_kind_lake*dzlak(nlevlake)
247 z_lake(1:nlevlake) = zlak(1:nlevlake)
248 dz_lake(1:nlevlake) = dzlak(1:nlevlake)
250 depthratio = input_lakedepth(i) / (zlak(nlevlake) + 0.5_kind_lake*dzlak(nlevlake))
252 dz_lake(1) = dzlak(1)
253 dz_lake(2:nlevlake) = dzlak(2:nlevlake)*depthratio
254 z_lake(2:nlevlake) = zlak(2:nlevlake)*depthratio + dz_lake(1)*(1._kind_lake - depthratio)
257 end subroutine calculate_z_dz_lake
264 SUBROUTINE clm_lake_run( &
265 ! Model time and metadata:
266 flag_restart, im, km, me, master, fhour, IDATE, kdt, &
268 ! Configuration and initialization:
269 iopt_lake, iopt_lake_clm, min_lakeice, lakedepth_default, use_lakedepth, &
270 dtp, use_lake_model, clm_lake_initialized, frac_grid, frac_ice, lkm, &
271 use_cdeps_data, mask_dat, &
273 ! Atmospheric model state inputs:
274 tg3, pgr, zlvl, gt0, prsi, phii, qvcurr, gu0, gv0, xlat_d, xlon_d, &
275 ch, cm, dlwsfci, dswsfci, oro_lakedepth, wind, tsfc, &
276 flag_iter, flag_lakefreeze, ISLTYP, rainncprv, raincprv, &
278 ! Feedback to atmosphere:
279 evap_wat, evap_ice, hflx_wat, hflx_ice, gflx_wat, gflx_ice, &
280 ep1d_water, ep1d_ice, tsurf_water, tsurf_ice, tsfc_wat, tisfc, &
281 weasdi, snodi, hice, qss_water, qss_ice, &
282 cmm_water, cmm_ice, chh_water, chh_ice, &
283 uustar_water, uustar_ice, lake_t_snow, albedo, zorlw, &
284 zorli, lake_t2m, lake_q2m, weasd, snowd, fice, &
287 ! Lake model internal state stored by caller:
289 salty, savedtke12d, snowdp2d, h2osno2d, snl2d, t_grnd2d, t_lake3d, &
290 lake_icefrac3d, t_soisno3d, h2osoi_ice3d, h2osoi_liq3d, h2osoi_vol3d, &
291 z3d, dz3d, zi3d, t1, qv1, prsl1, &
292 input_lakedepth, clm_lakedepth, cannot_freeze, &
308 LOGICAL ,
INTENT (IN) :: flag_restart
309 INTEGER ,
INTENT (IN) :: im,km,me,master
310 INTEGER,
INTENT(IN) :: idate(4), kdt
311 REAL(kind_phys),
INTENT(IN) :: fhour
312 INTEGER,
INTENT(IN) :: lkm
317 INTEGER,
INTENT(IN) :: iopt_lake, iopt_lake_clm
318 REAL(kind_phys),
INTENT(IN) :: min_lakeice, lakedepth_default, dtp
319 LOGICAL,
INTENT(IN) :: use_lakedepth
320 INTEGER,
DIMENSION(:),
INTENT(IN) :: use_lake_model
321 REAL(kind_phys),
INTENT(INOUT) :: clm_lake_initialized(:)
322 LOGICAL,
INTENT(IN) :: frac_grid, frac_ice, use_cdeps_data
323 REAL(kind_phys),
INTENT(IN),
OPTIONAL :: mask_dat(:)
329 REAL(kind_phys),
DIMENSION(:),
INTENT(IN):: &
330 tg3, pgr, zlvl, qvcurr, xlat_d, xlon_d, ch, cm, &
331 dlwsfci, dswsfci, oro_lakedepth, wind, &
333 REAL(kind_phys),
DIMENSION(:),
INTENT(IN) :: &
335 REAL(kind_phys),
DIMENSION(:,:),
INTENT(in) :: gu0, gv0, prsi, gt0, phii
336 LOGICAL,
DIMENSION(:),
INTENT(IN) :: flag_iter
337 LOGICAL,
DIMENSION(:),
INTENT(INOUT) :: flag_lakefreeze
339 INTEGER,
DIMENSION(:),
INTENT(IN) :: isltyp
344 REAL(kind_phys),
DIMENSION(:),
INTENT(INOUT) :: &
345 evap_wat, evap_ice, hflx_wat, hflx_ice, gflx_wat, gflx_ice, &
346 ep1d_water, ep1d_ice, tsurf_water, tsurf_ice, tsfc_wat, tisfc, tsfc, &
347 weasdi, snodi, hice, qss_water, qss_ice, &
348 cmm_water, cmm_ice, chh_water, chh_ice, &
349 uustar_water, uustar_ice, zorlw, zorli, weasd, snowd, fice
350 REAL(kind_phys),
DIMENSION(:),
INTENT(INOUT) :: &
351 lake_t_snow, albedo, lake_t2m, lake_q2m
352 LOGICAL,
INTENT(INOUT) :: icy(:)
357 INTEGER,
DIMENSION( : ),
INTENT(INOUT) :: salty
358 INTEGER,
DIMENSION( : ),
INTENT(INOUT) :: cannot_freeze
360 real(kind_phys),
dimension(: ) ,
intent(inout) :: savedtke12d, &
366 real(kind_phys),
dimension( :,: ),
INTENT(inout) :: t_lake3d, &
368 real(kind_phys),
dimension( :,-nlevsnow+1: ) ,
INTENT(inout) :: t_soisno3d, &
374 real(kind_phys),
dimension( :,-nlevsnow+0: ) ,
INTENT(inout) :: zi3d
376 REAL(kind_phys),
DIMENSION( : ) ,
INTENT(INOUT) :: clm_lakedepth
377 REAL(kind_phys),
DIMENSION( : ) ,
INTENT(INOUT) :: input_lakedepth
382 INTEGER,
INTENT(OUT) :: errflg
383 CHARACTER(*),
INTENT(OUT) :: errmsg
391 REAL(kind_lake) :: sfctmp,pbot,psfc,q2k,lwdn,prcp,soldn,solnet,dtime
396 real(kind_lake) :: forc_t(1)
397 real(kind_lake) :: forc_pbot(1)
398 real(kind_lake) :: forc_psrf(1)
399 real(kind_lake) :: forc_hgt(1)
400 real(kind_lake) :: forc_hgt_q(1)
401 real(kind_lake) :: forc_hgt_t(1)
402 real(kind_lake) :: forc_hgt_u(1)
403 real(kind_lake) :: forc_q(1)
404 real(kind_lake) :: forc_u(1)
405 real(kind_lake) :: forc_v(1)
406 real(kind_lake) :: forc_lwrad(1)
407 real(kind_lake) :: prec(1)
408 real(kind_lake) :: sabg(1)
409 real(kind_lake) :: lat(1)
410 real(kind_lake) :: z_lake(1,nlevlake)
411 real(kind_lake) :: dz_lake(1,nlevlake)
413 real(kind_lake) :: lakedepth(1)
414 logical :: do_capsnow(1)
417 real(kind_lake) :: h2osoi_vol(1,-nlevsnow+1:nlevsoil)
418 real(kind_lake) :: t_grnd(1)
419 real(kind_lake) :: h2osno(1)
420 real(kind_lake) :: snowdp(1)
421 real(kind_lake) :: z(1,-nlevsnow+1:nlevsoil)
422 real(kind_lake) :: dz(1,-nlevsnow+1:nlevsoil)
423 real(kind_lake) :: t_soisno(1,-nlevsnow+1:nlevsoil)
424 real(kind_lake) :: t_lake(1,nlevlake)
426 real(kind_lake) :: h2osoi_liq(1,-nlevsnow+1:nlevsoil)
427 real(kind_lake) :: h2osoi_ice(1,-nlevsnow+1:nlevsoil)
428 real(kind_lake) :: savedtke1(1)
429 real(kind_lake) :: zi(1,-nlevsnow+0:nlevsoil)
430 real(kind_lake) :: lake_icefrac(1,nlevlake)
434 real(kind_lake) :: eflx_gnet(1)
435 real(kind_lake) :: eflx_lwrad_net(1)
436 real(kind_lake) :: eflx_sh_tot(1)
437 real(kind_lake) :: eflx_lh_tot(1)
438 real(kind_lake) :: t_ref2m(1)
439 real(kind_lake) :: q_ref2m(1)
440 real(kind_lake) :: taux(1)
441 real(kind_lake) :: tauy(1)
442 real(kind_lake) :: ram1(1)
445 real(kind_lake) :: z0mg(1)
446 real(kind_lake) :: qfx
448 real(kind_lake) :: ustar_out(1)
450 real(kind_lake) :: discard1, discard2, discard3
452 real(kind_lake) :: watsat(1,nlevsoil)
453 real(kind_lake) :: tksatu(1,nlevsoil)
454 real(kind_lake) :: tkmg(1,nlevsoil)
455 real(kind_lake) :: tkdry(1,nlevsoil)
456 real(kind_lake) :: csol(1,nlevsoil)
460 integer :: lake_points, snow_points, ice_points
461 character*255 :: message
462 logical,
parameter :: feedback_to_atmosphere = .true.
464 real(kind_lake) :: to_radians, lat_d, lon_d, qss, tkm, bd
465 real(kind_lake) :: rho0
467 integer :: month,num1,num2,day_of_month,isl
468 real(kind_lake) :: wght1,wght2,tclim,depthratio
470 logical salty_flag, cannot_freeze_flag
475 if(iopt_lake/=iopt_lake_clm .or. lkm==0 .or. all(use_lake_model==0))
then
482 call lakeini(kdt=kdt, isltyp=isltyp, gt0=gt0, snowd=snowd, weasd=weasd, &
483 lakedepth_default=lakedepth_default, fhour=fhour, &
484 oro_lakedepth=oro_lakedepth, savedtke12d=savedtke12d, snowdp2d=snowdp2d, &
485 h2osno2d=h2osno2d, snl2d=snl2d, t_grnd2d=t_grnd2d, t_lake3d=t_lake3d, &
486 lake_icefrac3d=lake_icefrac3d, &
487 t_soisno3d=t_soisno3d, h2osoi_ice3d=h2osoi_ice3d, h2osoi_liq3d=h2osoi_liq3d, &
488 h2osoi_vol3d=h2osoi_vol3d, z3d=z3d, dz3d=dz3d, zi3d=zi3d, &
489 fice=fice, hice=hice, min_lakeice=min_lakeice, &
491 use_lake_model=use_lake_model, use_lakedepth=use_lakedepth, &
492 im=im, prsi=prsi, xlat_d=xlat_d, xlon_d=xlon_d, &
493 clm_lake_initialized=clm_lake_initialized, input_lakedepth=input_lakedepth, &
494 tg3=tg3, clm_lakedepth=clm_lakedepth, km=km, me=me, master=master, &
495 errmsg=errmsg, errflg=errflg)
507 day_of_month = idate(3)
510 if(day_of_month>15)
then
515 wght2 = day_of_month/month_length(month)
516 if(wght2<0 .or. wght2>1)
then
518 write(0,*)
'Warning: wght2 is not 0..1: ',wght2
520 wght2 = max(0.0_kind_lake,min(1.0_kind_lake,wght2))
522 wght1 = 1.0_kind_lake - wght2
524 if(debug_print )
then
525 print *,
'month,num1,num2,wght1,wght2',month,num1,num2,wght1,wght2
528 lake_top_loop:
DO i = 1,im
530 if_lake_is_here:
if (flag_iter(i) .and. use_lake_model(i)/=0)
THEN
532 call is_salty(xlat_d(i),xlon_d(i),salty_flag,cannot_freeze_flag)
540 if(cannot_freeze_flag)
then
554 prcp = (raincprv(i)+rainncprv(i))/dtime
556 albedo(i) = ( 0.6 * lake_icefrac3d(i,1) ) + &
557 ( (1.0-lake_icefrac3d(i,1)) * 0.08)
558 solnet = soldn*(1.-albedo(i))
561 lake_points = lake_points+1
563 call calculate_z_dz_lake(i,input_lakedepth,clm_lakedepth,z_lake(1,:),dz_lake(1,:))
566 z_lake(c,:) = z_lake(1,:)
567 dz_lake(c,:) = dz_lake(1,:)
572 if (isl == 0 ) isl = 14
573 if (isl == 14 ) isl = isl + 1
575 watsat = 0.489_kind_lake - 0.00126_kind_lake*sand(isl)
576 csol = (2.128_kind_lake*sand(isl)+2.385_kind_lake*clay(isl)) / (sand(isl)+clay(isl))*1.e6_kind_lake
577 tkm = (8.80_kind_lake*sand(isl)+2.92_kind_lake*clay(isl))/(sand(isl)+clay(isl))
578 bd = (1._kind_lake-watsat(1,1))*2.7e3_kind_lake
579 tkmg = tkm ** (1._kind_lake- watsat(1,1))
580 tkdry = (0.135_kind_lake*bd + 64.7_kind_lake) / (2.7e3_kind_lake - 0.947_kind_lake*bd)
581 tksatu = tkmg(1,1)*0.57_kind_lake**watsat(1,1)
588 forc_hgt(c) = zlvl(i)
589 forc_hgt_q(c) = zlvl(i)
590 forc_hgt_t(c) = zlvl(i)
591 forc_hgt_u(c) = zlvl(i)
598 lat(c) = xlat_d(i)*to_radians
599 do_capsnow(c) = .false.
601 lakedepth(c) = clm_lakedepth(i)
602 savedtke1(c) = savedtke12d(i)
603 snowdp(c) = snowdp2d(i)
604 h2osno(c) = h2osno2d(i)
606 t_grnd(c) = t_grnd2d(i)
608 t_lake(c,k) = t_lake3d(i,k)
609 lake_icefrac(c,k) = lake_icefrac3d(i,k)
611 do k = -nlevsnow+1,nlevsoil
612 t_soisno(c,k) = t_soisno3d(i,k)
613 h2osoi_ice(c,k) = h2osoi_ice3d(i,k)
614 h2osoi_liq(c,k) = h2osoi_liq3d(i,k)
615 h2osoi_vol(c,k) = h2osoi_vol3d(i,k)
619 do k = -nlevsnow+0,nlevsoil
624 eflx_lwrad_net = -9999
638 CALL lakemain(forc_t,forc_pbot,forc_psrf,forc_hgt,forc_hgt_q, &
639 forc_hgt_t,forc_hgt_u,forc_q, forc_u, &
640 forc_v,forc_lwrad,prec, sabg,lat, &
641 z_lake,dz_lake,lakedepth,do_capsnow, &
642 h2osno,snowdp,snl,z,dz,zi, &
643 h2osoi_vol,h2osoi_liq,h2osoi_ice, &
644 t_grnd,t_soisno,t_lake, &
645 savedtke1,lake_icefrac, &
646 eflx_lwrad_net,eflx_gnet, &
647 eflx_sh_tot,eflx_lh_tot, &
648 t_ref2m,q_ref2m, dtime, &
649 watsat, tksatu, tkmg, tkdry, csol, &
650 taux,tauy,ram1,z0mg,ustar_out,errmsg,errflg, &
655 if(cannot_freeze(i) == 1)
then
658 lake_icefrac(c,k) = 0._kind_lake
661 tclim = tfrz + wght1*saltlk_t(num1) &
662 + wght2*saltlk_t(num2)
663 if(debug_print) print *,
'GSL - Tclim,tsfc,t_lake3d',i,tclim,t_grnd(c),t_lake(c,:),t_soisno(c,:)
664 t_grnd(c) = min(tclim+3.0_kind_lake,(max(t_grnd(c),tclim-3.0_kind_lake)))
666 t_lake(c,k) = min(tclim+3.0_kind_lake,(max(t_lake(c,k),tclim-3.0_kind_lake)))
668 t_soisno(c,1) = min(tclim+3.0_kind_lake,(max(t_soisno(c,1),tclim-3.0_kind_lake)))
669 if(debug_print) print *,
'GSL - after Tclim,tsfc,t_lake3d',i,tclim,t_grnd(c),t_lake(c,:),t_soisno(c,:)
670 elseif(salty(i) == 1)
then
672 t_grnd(c) = max(tfrz-4.2_kind_lake,t_grnd(c))
674 lake_icefrac(c,k) = 0._kind_lake
675 t_lake(c,k) = max(tfrz-4.2_kind_lake,t_lake(c,k))
677 t_soisno(c,1) = max(tfrz-4.2_kind_lake,t_soisno(c,1))
678 if(debug_print) print *,
'Mono - tsfc,t_lake3d',i,t_grnd(c),t_lake(c,:),t_soisno(c,:)
681 savedtke12d(i) = savedtke1(c)
682 snowdp2d(i) = snowdp(c)
683 h2osno2d(i) = h2osno(c)
685 t_grnd2d(i) = t_grnd(c)
687 t_lake3d(i,k) = t_lake(c,k)
688 lake_icefrac3d(i,k) = lake_icefrac(c,k)
690 do k = -nlevsnow+1,nlevsoil
693 t_soisno3d(i,k) = t_soisno(c,k)
694 h2osoi_liq3d(i,k) = h2osoi_liq(c,k)
695 h2osoi_ice3d(i,k) = h2osoi_ice(c,k)
696 h2osoi_vol3d(i,k) = h2osoi_vol(c,k)
698 do k = -nlevsnow+0,nlevsoil
704 feedback:
if(feedback_to_atmosphere)
then
708 if( t_grnd(c) >= tfrz )
then
709 qfx = eflx_lh_tot(c)*invhvap
711 qfx = eflx_lh_tot(c)*invhsub
713 rho0 = prsl1(i) / (rair*t1(i)*(1.0 + con_fvirt*qv1(i)))
714 evap_wat(i) = qfx/rho0
715 hflx_wat(i) = eflx_sh_tot(c)/(rho0*cpair)
716 gflx_wat(i) = eflx_gnet(c)
717 ep1d_water(i) = eflx_lh_tot(c)
719 if (use_cdeps_data)
then
720 if (mask_dat(i) <= 0.0)
then
721 tsfc_wat(i) = t_grnd(c)
723 fice(i) = lake_icefrac3d(i,1)
724 tsurf_water(i) = t_grnd(c)
725 tsurf_ice(i) = t_grnd(c)
728 tsfc_wat(i) = t_grnd(c)
730 fice(i) = lake_icefrac3d(i,1)
731 tsurf_water(i) = t_grnd(c)
732 tsurf_ice(i) = t_grnd(c)
735 lake_t2m(i) = t_ref2m(c)
736 lake_q2m(i) = q_ref2m(c)
737 albedo(i) = ( 0.6 * lake_icefrac3d(i,1) ) + &
738 ( (1.0-lake_icefrac3d(i,1)) * 0.08)
752 call qsat(t_grnd(c),psfc,discard1,discard2,qss,discard3)
756 chh_water(i) = ch(i)*wind(i)*1.225
757 cmm_water(i) = cm(i)*wind(i)
759 ice_point:
if(fice(i)>=min_lakeice)
then
762 if(debug_print) print *,
'Icy xlat_d(i),xlon_d(i),frac_ice,frac_grid ',xlat_d(i),xlon_d(i),frac_ice,frac_grid
763 if(frac_ice .or. frac_grid)
then
764 evap_ice(i) = evap_wat(i)
765 hflx_ice(i) = hflx_wat(i)
766 gflx_ice(i) = gflx_wat(i)
767 ep1d_ice(i) = ep1d_water(i)
768 chh_ice(i) = chh_water(i)
769 cmm_ice(i) = cmm_water(i)
770 qss_ice(i) = qss_water(i)
775 if (use_cdeps_data)
then
776 if (mask_dat(i) <= 0.0)
then
778 tsurf_ice(i) = t_grnd(c)
782 tsurf_ice(i) = t_grnd(c)
785 weasdi(i) = h2osno(c)
786 snodi(i) = snowdp(c)*1.e3
791 if (.not. icy(i))
then
792 flag_lakefreeze(i)=.true.
797 ice_points = ice_points+1
803 if (use_cdeps_data)
then
804 if (mask_dat(i) <= 0.0)
then
807 if(lake_icefrac3d(i,k)>0)
then
808 hice(i) = hice(i) + dz_lake(c,k)
815 if(lake_icefrac3d(i,k)>0)
then
816 hice(i) = hice(i) + dz_lake(c,k)
831 if (use_cdeps_data)
then
832 if (mask_dat(i) <= 0.0)
then
834 tsurf_ice(i) = tisfc(i)
838 tsurf_ice(i) = tisfc(i)
842 if (use_cdeps_data)
then
843 if (mask_dat(i) <= 0.0)
then
855 lake_t_snow(i) = t_grnd(c)
857 if (use_cdeps_data)
then
858 if (mask_dat(i) <= 0.0)
then
859 tisfc(i) = lake_t_snow(i)
862 tisfc(i) = lake_t_snow(i)
864 snow_points = snow_points+1
866 lake_t_snow(i) = -9999
871 endif if_lake_is_here
874 if(debug_print .and. lake_points>0 .and. (kdt<3 .or. mod(kdt,30)==3))
then
8753082
format(
'lake points processed in timestep ',i0,
' by rank ',i0,
' = ',i0,
' snow=',i0,
' ice=',i0)
876 print 3082,kdt,me,lake_points,snow_points,ice_points
879 END SUBROUTINE clm_lake_run
882 SUBROUTINE lakemain(forc_t,forc_pbot,forc_psrf,forc_hgt,forc_hgt_q, & !I
883 forc_hgt_t,forc_hgt_u,forc_q, forc_u, &
884 forc_v,forc_lwrad,prec, sabg,lat, &
885 z_lake,dz_lake,lakedepth,do_capsnow, &
886 h2osno,snowdp,snl,z,dz,zi, & !H
887 h2osoi_vol,h2osoi_liq,h2osoi_ice, &
888 t_grnd,t_soisno,t_lake, &
889 savedtke1,lake_icefrac, &
890 eflx_lwrad_net,eflx_gnet, & !O
891 eflx_sh_tot,eflx_lh_tot, &
892 t_ref2m,q_ref2m, dtime, &
893 watsat, tksatu, tkmg, tkdry, csol, &
894 taux,tauy,ram1,z0mg,ustar_out,errmsg,errflg, xlat_d,xlon_d)
898 integer,
intent(inout) :: errflg
899 character(*),
intent(inout) :: errmsg
900 real(kind_lake),
intent(in) :: dtime
901 real(kind_lake),
intent(in) :: xlat_d, xlon_d
902 real(kind_lake),
intent(in) :: forc_t(1)
903 real(kind_lake),
intent(in) :: forc_pbot(1)
904 real(kind_lake),
intent(in) :: forc_psrf(1)
905 real(kind_lake),
intent(in) :: forc_hgt(1)
906 real(kind_lake),
intent(in) :: forc_hgt_q(1)
907 real(kind_lake),
intent(in) :: forc_hgt_t(1)
908 real(kind_lake),
intent(in) :: forc_hgt_u(1)
909 real(kind_lake),
intent(in) :: forc_q(1)
910 real(kind_lake),
intent(in) :: forc_u(1)
911 real(kind_lake),
intent(in) :: forc_v(1)
913 real(kind_lake),
intent(in) :: forc_lwrad(1)
914 real(kind_lake),
intent(in) :: prec(1)
915 real(kind_lake),
intent(in) :: sabg(1)
916 real(kind_lake),
intent(in) :: lat(1)
917 real(kind_lake),
intent(in) :: z_lake(1,nlevlake)
918 real(kind_lake),
intent(in) :: dz_lake(1,nlevlake)
919 real(kind_lake),
intent(out) :: ustar_out(1)
920 real(kind_lake),
intent(in) :: lakedepth(1)
924 logical ,
intent(in) :: do_capsnow(1)
925 real(kind_lake),
intent(in) :: watsat(1,nlevsoil)
926 real(kind_lake),
intent(in) :: tksatu(1,nlevsoil)
927 real(kind_lake),
intent(in) :: tkmg(1,nlevsoil)
928 real(kind_lake),
intent(in) :: tkdry(1,nlevsoil)
929 real(kind_lake),
intent(in) :: csol(1,nlevsoil)
934 real(kind_lake),
intent(inout) :: h2osoi_vol(1,-nlevsnow+1:nlevsoil)
935 real(kind_lake),
intent(inout) :: t_grnd(1)
936 real(kind_lake),
intent(inout) :: h2osno(1)
937 real(kind_lake),
intent(inout) :: snowdp(1)
938 real(kind_lake),
intent(inout) :: z(1,-nlevsnow+1:nlevsoil)
939 real(kind_lake),
intent(inout) :: dz(1,-nlevsnow+1:nlevsoil)
940 real(kind_lake),
intent(inout) :: t_soisno(1,-nlevsnow+1:nlevsoil)
941 real(kind_lake),
intent(inout) :: t_lake(1,nlevlake)
942 integer ,
intent(inout) :: snl(1)
943 real(kind_lake),
intent(inout) :: h2osoi_liq(1,-nlevsnow+1:nlevsoil)
944 real(kind_lake),
intent(inout) :: h2osoi_ice(1,-nlevsnow+1:nlevsoil)
945 real(kind_lake),
intent(inout) :: savedtke1(1)
946 real(kind_lake),
intent(inout) :: zi(1,-nlevsnow+0:nlevsoil)
947 real(kind_lake),
intent(inout) :: lake_icefrac(1,nlevlake)
951 real(kind_lake),
intent(out) :: eflx_gnet(1)
952 real(kind_lake),
intent(out) :: eflx_lwrad_net(1)
953 real(kind_lake),
intent(out) :: eflx_sh_tot(1)
954 real(kind_lake),
intent(out) :: eflx_lh_tot(1)
955 real(kind_lake),
intent(out) :: t_ref2m(1)
956 real(kind_lake),
intent(out) :: q_ref2m(1)
957 real(kind_lake),
intent(out) :: taux(1)
958 real(kind_lake),
intent(out) :: tauy(1)
959 real(kind_lake),
intent(out) :: ram1(1)
962 real(kind_lake),
intent(out) :: z0mg(1)
967 real(kind_lake) :: begwb(1)
968 real(kind_lake) :: t_veg(1)
969 real(kind_lake) :: eflx_soil_grnd(1)
970 real(kind_lake) :: eflx_lh_grnd(1)
971 real(kind_lake) :: eflx_sh_grnd(1)
972 real(kind_lake) :: eflx_lwrad_out(1)
973 real(kind_lake) :: qflx_evap_tot(1)
974 real(kind_lake) :: qflx_evap_soi(1)
975 real(kind_lake) :: qflx_prec_grnd(1)
976 real(kind_lake) :: forc_snow(1)
977 real(kind_lake) :: forc_rain(1)
978 real(kind_lake) :: ws(1)
979 real(kind_lake) :: ks(1)
980 real(kind_lake) :: qflx_snomelt(1)
981 integer :: imelt(1,-nlevsnow+1:nlevsoil)
982 real(kind_lake) :: endwb(1)
983 real(kind_lake) :: snowage(1)
984 real(kind_lake) :: snowice(1)
985 real(kind_lake) :: snowliq(1)
986 real(kind_lake) :: t_snow(1)
987 real(kind_lake) :: qflx_drain(1)
988 real(kind_lake) :: qflx_surf(1)
989 real(kind_lake) :: qflx_infl(1)
990 real(kind_lake) :: qflx_qrgwl(1)
991 real(kind_lake) :: qcharge(1)
992 real(kind_lake) :: qflx_snowcap(1)
993 real(kind_lake) :: qflx_snowcap_col(1)
994 real(kind_lake) :: qflx_snow_grnd_pft(1)
995 real(kind_lake) :: qflx_snow_grnd_col(1)
996 real(kind_lake) :: qflx_rain_grnd(1)
997 real(kind_lake) :: frac_iceold(1,-nlevsnow+1:nlevsoil)
998 real(kind_lake) :: qflx_evap_tot_col(1)
999 real(kind_lake) :: soilalpha(1)
1000 real(kind_lake) :: zwt(1)
1001 real(kind_lake) :: fcov(1)
1002 real(kind_lake) :: rootr_column(1,1:nlevsoil)
1003 real(kind_lake) :: qflx_evap_grnd(1)
1004 real(kind_lake) :: qflx_sub_snow(1)
1005 real(kind_lake) :: qflx_dew_snow(1)
1006 real(kind_lake) :: qflx_dew_grnd(1)
1007 real(kind_lake) :: qflx_rain_grnd_col(1)
1012 if (prec(1)> 0.)
then
1013 if ( forc_t(1) > (tfrz + tcrit))
then
1014 forc_rain(1) = prec(1)
1019 forc_snow(1) = prec(1)
1034 CALL shallakefluxes(forc_t,forc_pbot,forc_psrf,forc_hgt,forc_hgt_q, &
1035 forc_hgt_t,forc_hgt_u,forc_q, &
1036 forc_u,forc_v,forc_lwrad,forc_snow, &
1037 forc_rain,t_grnd,h2osno,snowdp,sabg,lat, &
1038 dz,dz_lake,t_soisno,t_lake,snl,h2osoi_liq, &
1039 h2osoi_ice,savedtke1, &
1040 qflx_prec_grnd,qflx_evap_soi,qflx_evap_tot, &
1041 eflx_sh_grnd,eflx_lwrad_out,eflx_lwrad_net, &
1042 eflx_soil_grnd,eflx_sh_tot,eflx_lh_tot, &
1043 eflx_lh_grnd,t_veg,t_ref2m,q_ref2m,taux,tauy, &
1044 ram1,ws,ks,eflx_gnet,z0mg,ustar_out,errmsg,errflg,xlat_d,xlon_d)
1049 CALL shallaketemperature(t_grnd,h2osno,sabg,dz,dz_lake,z,zi, &
1050 z_lake,ws,ks,snl,eflx_gnet,lakedepth, &
1051 lake_icefrac,snowdp, &
1052 eflx_sh_grnd,eflx_sh_tot,eflx_soil_grnd, &
1053 t_lake,t_soisno,h2osoi_liq, &
1054 h2osoi_ice,savedtke1, &
1055 watsat, tksatu, tkmg, tkdry, csol, dtime, &
1056 frac_iceold,qflx_snomelt,imelt,errmsg,errflg,xlat_d,xlon_d)
1061 CALL shallakehydrology(dz_lake,forc_rain,forc_snow, &
1062 begwb,qflx_evap_tot,forc_t,do_capsnow, &
1063 t_grnd,qflx_evap_soi, &
1064 qflx_snomelt,imelt,frac_iceold, &
1065 z,dz,zi,snl,h2osno,snowdp,lake_icefrac,t_lake, &
1066 endwb,snowage,snowice,snowliq,t_snow, &
1067 t_soisno,h2osoi_ice,h2osoi_liq,h2osoi_vol, &
1068 qflx_drain,qflx_surf,qflx_infl,qflx_qrgwl, &
1069 qcharge,qflx_prec_grnd,qflx_snowcap, &
1070 qflx_snowcap_col,qflx_snow_grnd_pft, &
1071 qflx_snow_grnd_col,qflx_rain_grnd, &
1072 qflx_evap_tot_col,soilalpha,zwt,fcov, &
1073 rootr_column,qflx_evap_grnd,qflx_sub_snow, &
1074 qflx_dew_snow,qflx_dew_grnd,qflx_rain_grnd_col, &
1075 watsat, tksatu, tkmg, tkdry, csol, &
1076 dtime,errmsg,errflg)
1086 END SUBROUTINE lakemain
1096SUBROUTINE shallakefluxes(forc_t,forc_pbot,forc_psrf,forc_hgt,forc_hgt_q, & !i
1097 forc_hgt_t,forc_hgt_u,forc_q, &
1098 forc_u,forc_v,forc_lwrad,forc_snow, &
1099 forc_rain,t_grnd,h2osno,snowdp,sabg,lat, &
1100 dz,dz_lake,t_soisno,t_lake,snl,h2osoi_liq, &
1101 h2osoi_ice,savedtke1, &
1102 qflx_prec_grnd,qflx_evap_soi,qflx_evap_tot, & !o
1103 eflx_sh_grnd,eflx_lwrad_out,eflx_lwrad_net, &
1104 eflx_soil_grnd,eflx_sh_tot,eflx_lh_tot, &
1105 eflx_lh_grnd,t_veg,t_ref2m,q_ref2m,taux,tauy, &
1106 ram1,ws,ks,eflx_gnet,z0mg,ustar_out,errmsg,errflg,xlat_d,xlon_d)
1120 integer,
intent(inout) :: errflg
1121 character(len=*),
intent(inout) :: errmsg
1122 real(kind_lake),
intent(in) :: xlat_d,xlon_d
1123 real(kind_lake),
intent(in) :: forc_t(1)
1124 real(kind_lake),
intent(in) :: forc_pbot(1)
1125 real(kind_lake),
intent(in) :: forc_psrf(1)
1126 real(kind_lake),
intent(in) :: forc_hgt(1)
1127 real(kind_lake),
intent(in) :: forc_hgt_q(1)
1128 real(kind_lake),
intent(in) :: forc_hgt_t(1)
1129 real(kind_lake),
intent(in) :: forc_hgt_u(1)
1130 real(kind_lake),
intent(in) :: forc_q(1)
1131 real(kind_lake),
intent(in) :: forc_u(1)
1132 real(kind_lake),
intent(in) :: forc_v(1)
1133 real(kind_lake),
intent(in) :: forc_lwrad(1)
1135 real(kind_lake),
intent(in) :: forc_snow(1)
1136 real(kind_lake),
intent(in) :: forc_rain(1)
1137 real(kind_lake),
intent(in) :: h2osno(1)
1138 real(kind_lake),
intent(in) :: snowdp(1)
1139 real(kind_lake),
intent(in) :: sabg(1)
1140 real(kind_lake),
intent(in) :: lat(1)
1141 real(kind_lake),
intent(in) :: dz(1,-nlevsnow+1:nlevsoil)
1142 real(kind_lake),
intent(in) :: dz_lake(1,nlevlake)
1143 real(kind_lake),
intent(in) :: t_soisno(1,-nlevsnow+1:nlevsoil)
1144 real(kind_lake),
intent(in) :: t_lake(1,nlevlake)
1145 integer ,
intent(in) :: snl(1)
1146 real(kind_lake),
intent(in) :: h2osoi_liq(1,-nlevsnow+1:nlevsoil)
1147 real(kind_lake),
intent(in) :: h2osoi_ice(1,-nlevsnow+1:nlevsoil)
1148 real(kind_lake),
intent(in) :: savedtke1(1)
1151 real(kind_lake),
intent(inout) :: t_grnd(1)
1153 real(kind_lake),
intent(out):: ustar_out(1)
1154 real(kind_lake),
intent(out):: qflx_prec_grnd(1)
1155 real(kind_lake),
intent(out):: qflx_evap_soi(1)
1156 real(kind_lake),
intent(out):: qflx_evap_tot(1)
1157 real(kind_lake),
intent(out):: eflx_sh_grnd(1)
1158 real(kind_lake),
intent(out):: eflx_lwrad_out(1)
1159 real(kind_lake),
intent(out):: eflx_lwrad_net(1)
1160 real(kind_lake),
intent(out):: eflx_soil_grnd(1)
1161 real(kind_lake),
intent(out):: eflx_sh_tot(1)
1162 real(kind_lake),
intent(out):: eflx_lh_tot(1)
1163 real(kind_lake),
intent(out):: eflx_lh_grnd(1)
1164 real(kind_lake),
intent(out):: t_veg(1)
1165 real(kind_lake),
intent(out):: t_ref2m(1)
1166 real(kind_lake),
intent(out):: q_ref2m(1)
1167 real(kind_lake),
intent(out):: taux(1)
1168 real(kind_lake),
intent(out):: tauy(1)
1169 real(kind_lake),
intent(out):: ram1(1)
1170 real(kind_lake),
intent(out):: ws(1)
1171 real(kind_lake),
intent(out):: ks(1)
1173 real(kind_lake),
intent(out):: eflx_gnet(1)
1175 real(kind_lake),
intent(out):: z0mg(1)
1181 integer ,
parameter :: islak = 2
1182 integer ,
parameter :: niters = 3
1183 real(kind_lake),
parameter :: beta1 = 1._kind_lake
1184 real(kind_lake),
parameter :: emg = 0.97_kind_lake
1185 real(kind_lake),
parameter :: zii = 1000._kind_lake
1186 real(kind_lake),
parameter :: tdmax = 277._kind_lake
1187 real(kind_lake) :: forc_th(1)
1188 real(kind_lake) :: forc_vp(1)
1189 real(kind_lake) :: forc_rho(1)
1190 integer :: i,fc,fp,g,c,p
1193 integer :: fpcopy(num_shlakep)
1195 integer :: nmozsgn(lbp:ubp)
1196 integer :: jtop(lbc:ubc)
1197 real(kind_lake) :: ax
1198 real(kind_lake) :: bx
1199 real(kind_lake) :: degdt
1200 real(kind_lake) :: dqh(lbp:ubp)
1201 real(kind_lake) :: dth(lbp:ubp)
1202 real(kind_lake) :: dthv
1203 real(kind_lake) :: dzsur(lbc:ubc)
1204 real(kind_lake) :: eg
1205 real(kind_lake) :: htvp(lbc:ubc)
1206 real(kind_lake) :: obu(lbp:ubp)
1207 real(kind_lake) :: obuold(lbp:ubp)
1208 real(kind_lake) :: qsatg(lbc:ubc)
1209 real(kind_lake) :: qsatgdt(lbc:ubc)
1210 real(kind_lake) :: qstar
1211 real(kind_lake) :: ram(lbp:ubp)
1212 real(kind_lake) :: rah(lbp:ubp)
1213 real(kind_lake) :: raw(lbp:ubp)
1214 real(kind_lake) :: stftg3(lbp:ubp)
1215 real(kind_lake) :: temp1(lbp:ubp)
1216 real(kind_lake) :: temp12m(lbp:ubp)
1217 real(kind_lake) :: temp2(lbp:ubp)
1218 real(kind_lake) :: temp22m(lbp:ubp)
1219 real(kind_lake) :: tgbef(lbc:ubc)
1220 real(kind_lake) :: thm(lbc:ubc)
1221 real(kind_lake) :: thv(lbc:ubc)
1222 real(kind_lake) :: thvstar
1223 real(kind_lake) :: tksur
1224 real(kind_lake) :: tsur
1225 real(kind_lake) :: tstar
1226 real(kind_lake) :: um(lbp:ubp)
1227 real(kind_lake) :: ur(lbp:ubp)
1228 real(kind_lake) :: ustar(lbp:ubp)
1229 real(kind_lake) :: wc
1230 real(kind_lake) :: zeta
1231 real(kind_lake) :: zldis(lbp:ubp)
1232 real(kind_lake) :: displa(lbp:ubp)
1234 real(kind_lake) :: z0hg(lbp:ubp)
1235 real(kind_lake) :: z0qg(lbp:ubp)
1236 real(kind_lake) :: u2m
1237 real(kind_lake) :: u10(1)
1238 real(kind_lake) :: fv(1)
1240 real(kind_lake) :: fm(lbp:ubp)
1241 real(kind_lake) :: bw
1242 real(kind_lake) :: t_grnd_temp
1243 real(kind_lake) :: betaprime(lbc:ubc)
1244 character*256 :: message
1246 real(kind_lake) :: tc, visc, ren
1253 real(kind_lake),
parameter :: beta(2) = &
1254 (/0.4_kind_lake, 0.4_kind_lake/)
1264 forc_th(1) = forc_t(1) * (forc_psrf(1)/ forc_pbot(1))**(rair/cpair)
1265 forc_vp(1) = forc_q(1) * forc_pbot(1)/ (con_eps + one_minus_con_eps * forc_q(1))
1266 forc_rho(1) = (forc_pbot(1) - one_minus_con_eps * forc_vp(1)) / (rair * forc_t(1))
1268 do fc = 1, num_shlakec
1269 c = filter_shlakec(fc)
1275 if (snl(c) > 0 .or. snl(c) < -5)
then
1276 errmsg=
'snl is not defined in ShalLakeFluxesMod; snl: out of range value'
1284 jtop(c) = snl(c) + 1
1287 if (snl(c) < 0)
then
1288 betaprime(c) = 1._kind_lake
1289 dzsur(c) = dz(c,jtop(c))*0.5_kind_lake
1291 betaprime(c) = beta(islak)
1292 dzsur(c) = dz_lake(c,1)*0.5_kind_lake
1299 call qsat(t_grnd(c), forc_pbot(g), eg, degdt, qsatg(c), qsatgdt(c))
1304 thm(c) = forc_t(g) + 0.0098_kind_lake*forc_hgt_t(g)
1305 thv(c) = forc_th(g)*(1._kind_lake+con_fvirt*forc_q(g))
1310 do fp = 1, num_shlakep
1311 p = filter_shlakep(fp)
1316 obuold(p) = 0._kind_lake
1317 displa(p) = 0._kind_lake
1331 if (t_grnd(c) >= tfrz)
then
1332 z0mg(p) = 0.001_kind_lake
1333 else if(snl(c) == 0 )
then
1336 z0mg(p) = 0.005_kind_lake
1338 z0mg(p) = 0.0024_kind_lake
1346 tc=forc_t(g)-273.15_kind_lake
1347 visc=1.326e-5_kind_lake*(1._kind_lake + 6.542e-3_kind_lake*tc + 8.301e-6_kind_lake*tc*tc &
1348 - 4.84e-9_kind_lake*tc*tc*tc)
1349 visc=max(1e-7_kind_lake, visc)
1351 ren = max(ustar(p)*z0mg(p)/visc, 0.1_kind_lake)
1352 z0hg(p) = (5.5e-5_kind_lake)*(ren**(-0.60_kind_lake))
1354 z0hg(p) = min(z0hg(p),1.0e-4_kind_lake)
1355 z0hg(p) = max(z0hg(p),2.0e-9_kind_lake)
1369 if (t_grnd(c) > tfrz)
then
1381 ur(p) = max(1.0_kind_lake,sqrt(forc_u(g)*forc_u(g)+forc_v(g)*forc_v(g)))
1382 dth(p) = thm(c)-t_grnd(c)
1383 dqh(p) = forc_q(g)-qsatg(c)
1384 dthv = dth(p)*(1._kind_lake+con_fvirt*forc_q(g))+con_fvirt*forc_th(g)*dqh(p)
1385 zldis(p) = forc_hgt_u(g) - 0._kind_lake
1389 call moninobukini(ur(p), thv(c), dthv, zldis(p), z0mg(p), um(p), obu(p))
1394 fncopy = num_shlakep
1395 fpcopy(1:num_shlakep) = filter_shlakep(1:num_shlakep)
1399 iteration :
do while (iter <= niters .and. fncopy > 0)
1404 call frictionvelocity(pgridcell,forc_hgt,forc_hgt_u, &
1405 forc_hgt_t,forc_hgt_q, &
1406 lbp, ubp, fncopy, fpcopy, &
1407 displa, z0mg, z0hg, z0qg, &
1408 obu, iter, ur, um, &
1409 ustar,temp1, temp2, temp12m, temp22m, &
1420 tgbef(c) = t_grnd(c)
1421 if (t_grnd(c) > tfrz .and. t_lake(c,1) > tfrz .and. snl(c) == 0)
then
1422 tksur = savedtke1(c)
1427 else if (snl(c) == 0)
then
1432 bw = (h2osoi_ice(c,jtop(c))+h2osoi_liq(c,jtop(c)))/dz(c,jtop(c))
1433 tksur = tkairc + (7.75e-5_kind_lake *bw + 1.105e-6_kind_lake*bw*bw)*(tkice-tkairc)
1434 tsur = t_soisno(c,jtop(c))
1439 ram(p) = 1._kind_lake/(ustar(p)*ustar(p)/um(p))
1440 rah(p) = 1._kind_lake/(temp1(p)*ustar(p))
1441 raw(p) = 1._kind_lake/(temp2(p)*ustar(p))
1446 stftg3(p) = emg*sb*tgbef(c)*tgbef(c)*tgbef(c)
1450 ax = betaprime(c)*sabg(p) + emg*forc_lwrad(g) + 3._kind_lake*stftg3(p)*tgbef(c) &
1451 + forc_rho(g)*cpair/rah(p)*thm(c) &
1452 - htvp(c)*forc_rho(g)/raw(p)*(qsatg(c)-qsatgdt(c)*tgbef(c) - forc_q(g)) &
1453 + tksur*tsur/dzsur(c)
1455 bx = 4._kind_lake*stftg3(p) + forc_rho(g)*cpair/rah(p) &
1456 + htvp(c)*forc_rho(g)/raw(p)*qsatgdt(c) + tksur/dzsur(c)
1461 if(.not.pergro)
then
1462 if (t_grnd(c) > tfrz)
then
1472 eflx_sh_grnd(p) = forc_rho(g)*cpair*(t_grnd(c)-thm(c))/rah(p)
1473 qflx_evap_soi(p) = forc_rho(g)*(qsatg(c)+qsatgdt(c)*(t_grnd(c)-tgbef(c))-forc_q(g))/raw(p)
1478 call qsat(t_grnd(c), forc_pbot(g), eg, degdt, qsatg(c), qsatgdt(c))
1480 dth(p)=thm(c)-t_grnd(c)
1481 dqh(p)=forc_q(g)-qsatg(c)
1483 tstar = temp1(p)*dth(p)
1484 qstar = temp2(p)*dqh(p)
1486 thvstar=tstar*(1._kind_lake+con_fvirt*forc_q(g)) + con_fvirt*forc_th(g)*qstar
1487 zeta=zldis(p)*vkc * grav*thvstar/(ustar(p)**2*thv(c))
1489 if (zeta >= 0._kind_lake)
then
1490 zeta = min(2._kind_lake,max(zeta,0.01_kind_lake))
1491 um(p) = max(ur(p),0.1_kind_lake)
1493 zeta = max(-100._kind_lake,min(zeta,-0.01_kind_lake))
1494 wc = beta1*(-grav*ustar(p)*thvstar*zii/thv(c))**0.333_kind_lake
1495 um(p) = sqrt(ur(p)*ur(p)+wc*wc)
1497 obu(p) = zldis(p)/zeta
1499 if (obuold(p)*obu(p) < 0._kind_lake) nmozsgn(p) = nmozsgn(p)+1
1506 if (iter <= niters )
then
1513 if (nmozsgn(p) < 3)
then
1524 do fp = 1, num_shlakep
1525 p = filter_shlakep(fp)
1539 if ( (h2osno(c) > 0.5_kind_lake .or. t_lake(c,1) <= tfrz) .and. t_grnd(c) > tfrz)
then
1540 t_grnd_temp = t_grnd(c)
1542 eflx_sh_grnd(p) = forc_rho(g)*cpair*(t_grnd(c)-thm(c))/rah(p)
1543 qflx_evap_soi(p) = forc_rho(g)*(qsatg(c)+qsatgdt(c)*(t_grnd(c)-t_grnd_temp) - forc_q(g))/raw(p)
1544 else if ( (t_lake(c,1) > t_grnd(c) .and. t_grnd(c) > tdmax) .or. &
1545 (t_lake(c,1) < t_grnd(c) .and. t_lake(c,1) > tfrz .and. t_grnd(c) < tdmax) )
then
1547 t_grnd_temp = t_grnd(c)
1548 t_grnd(c) = t_lake(c,1)
1549 eflx_sh_grnd(p) = forc_rho(g)*cpair*(t_grnd(c)-thm(c))/rah(p)
1550 qflx_evap_soi(p) = forc_rho(g)*(qsatg(c)+qsatgdt(c)*(t_grnd(c)-t_grnd_temp) - forc_q(g))/raw(p)
1554 if(.not.pergro)
then
1555 if (t_grnd(c) > tfrz)
then
1566 eflx_lwrad_out(p) = (1._kind_lake-emg)*forc_lwrad(g) + emg*sb*t_grnd(c)**4
1570 eflx_soil_grnd(p) = sabg(p) + forc_lwrad(g) - eflx_lwrad_out(p) - &
1571 eflx_sh_grnd(p) - htvp(c)*qflx_evap_soi(p)
1578 taux(p) = -forc_rho(g)*forc_u(g)/ram(p)
1579 tauy(p) = -forc_rho(g)*forc_v(g)/ram(p)
1581 eflx_sh_tot(p) = eflx_sh_grnd(p)
1582 qflx_evap_tot(p) = qflx_evap_soi(p)
1583 eflx_lh_tot(p) = htvp(c)*qflx_evap_soi(p)
1584 eflx_lh_grnd(p) = htvp(c)*qflx_evap_soi(p)
1585 if(debug_print)
then
15861604
format(
'CLM_Lake ShalLakeFluxes: c=',i0,
' sensible heat = ',f12.4,
' latent heat =',f12.4, &
1587 ' ground temp = ', f12.4,
' h2osno = ', f12.4,
' at xlat_d=',f10.3,
' xlon_d=',f10.3)
1588 print 1604, c, eflx_sh_tot(p), eflx_lh_tot(p), t_grnd(c), h2osno(c),xlat_d,xlon_d
1589 if (abs(eflx_sh_tot(p)) > 1500 .or. abs(eflx_lh_tot(p)) > 1500)
then
15903018
format(
'CLM_Lake ShalLakeFluxes: WARNING: SH=',f12.4,
' LH=',f12.4,
' at xlat_d=',f10.3,
' xlon_d=',f10.3)
1591 print 3018,eflx_sh_tot(p), eflx_lh_tot(p),xlat_d,xlon_d
1593 if (abs(eflx_sh_tot(p)) > 10000 .or. abs(eflx_lh_tot(p)) > 10000 &
1594 .or. abs(t_grnd(c)-288)>200 )
then
1595840
format(
'CLM_Lake ShalLakeFluxes: t_grnd is out of range: eflx_sh_tot(p)=',g20.12,
' eflx_lh_tot(p)=',g20.12,
' t_grnd(c)=',g20.12,
' at p=',i0,
' c=',i0,
' xlat_d=',f10.3,
' xlon_d=',f10.3)
1596 write(message,840) eflx_sh_tot(p),eflx_lh_tot(p),t_grnd(c),p,c,xlat_d,xlon_d
1599 write(0,
'(A)') trim(message)
1603 t_ref2m(p) = thm(c) + temp1(p)*dth(p)*(1._kind_lake/temp12m(p) - 1._kind_lake/temp1(p))
1606 q_ref2m(p) = forc_q(g) + temp2(p)*dqh(p)*(1._kind_lake/temp22m(p) - 1._kind_lake/temp2(p))
1616 eflx_gnet(p) = betaprime(c) * sabg(p) + forc_lwrad(g) - (eflx_lwrad_out(p) + &
1617 eflx_sh_tot(p) + eflx_lh_tot(p))
1625 u2m = max(0.1_kind_lake,ustar(p)/vkc*log(2._kind_lake/z0mg(p)))
1627 ws(c) = 1.2e-03_kind_lake * u2m
1628 ks(c) = 6.6_kind_lake*sqrt(abs(sin(lat(g))))*(u2m**(-1.84_kind_lake))
1639 do fp = 1, num_shlakep
1640 p = filter_shlakep(fp)
1646 t_veg(p) = t_grnd(c)
1647 eflx_lwrad_net(p) = eflx_lwrad_out(p) - forc_lwrad(g)
1648 qflx_prec_grnd(p) = forc_rain(g) + forc_snow(g)
1651 ustar_out(1) = ustar(1)
1654END SUBROUTINE shallakefluxes
1656SUBROUTINE shallaketemperature(t_grnd,h2osno,sabg,dz,dz_lake,z,zi, & !i
1657 z_lake,ws,ks,snl,eflx_gnet,lakedepth, &
1658 lake_icefrac,snowdp, & !i&o
1659 eflx_sh_grnd,eflx_sh_tot,eflx_soil_grnd, & !o
1660 t_lake,t_soisno,h2osoi_liq, &
1661 h2osoi_ice,savedtke1, &
1662 watsat, tksatu, tkmg, tkdry, csol, dtime, &
1663 frac_iceold,qflx_snomelt,imelt,errmsg,errflg,xlat_d,xlon_d)
1751 real(kind_lake),
intent(in) :: xlat_d
1752 real(kind_lake),
intent(in) :: xlon_d
1753 integer,
intent(inout) :: errflg
1754 real(kind_lake),
intent(in) :: watsat(1,nlevsoil)
1755 real(kind_lake),
intent(in) :: tksatu(1,nlevsoil)
1756 real(kind_lake),
intent(in) :: tkmg(1,nlevsoil)
1757 real(kind_lake),
intent(in) :: tkdry(1,nlevsoil)
1758 real(kind_lake),
intent(in) :: csol(1,nlevsoil)
1759 character(*),
intent(inout) :: errmsg
1760 real(kind_lake),
intent(in) :: t_grnd(1)
1761 real(kind_lake),
intent(inout) :: h2osno(1)
1762 real(kind_lake),
intent(in) :: sabg(1)
1763 real(kind_lake),
intent(in) :: dz(1,-nlevsnow + 1:nlevsoil)
1764 real(kind_lake),
intent(in) :: dz_lake(1,nlevlake)
1765 real(kind_lake),
intent(in) :: z(1,-nlevsnow+1:nlevsoil)
1766 real(kind_lake),
intent(in) :: zi(1,-nlevsnow+0:nlevsoil)
1768 real(kind_lake),
intent(in) :: z_lake(1,nlevlake)
1769 real(kind_lake),
intent(in) :: ws(1)
1770 real(kind_lake),
intent(in) :: ks(1)
1772 integer ,
intent(in) :: snl(1)
1773 real(kind_lake),
intent(inout) :: eflx_gnet(1)
1774 real(kind_lake),
intent(in) :: lakedepth(1)
1777 real(kind_lake),
intent(inout) :: snowdp(1)
1778 real(kind_lake),
intent(in) :: dtime
1781 real(kind_lake),
intent(out) :: eflx_sh_grnd(1)
1782 real(kind_lake),
intent(out) :: eflx_sh_tot(1)
1783 real(kind_lake),
intent(out) :: eflx_soil_grnd(1)
1787 real(kind_lake),
intent(inout) :: t_lake(1,nlevlake)
1788 real(kind_lake),
intent(inout) :: t_soisno(1,-nlevsnow+1:nlevsoil)
1789 real(kind_lake),
intent(inout) :: h2osoi_liq(1,-nlevsnow+1:nlevsoil)
1790 real(kind_lake),
intent(inout) :: h2osoi_ice(1,-nlevsnow+1:nlevsoil)
1791 real(kind_lake),
intent(inout) :: lake_icefrac(1,nlevlake)
1792 real(kind_lake),
intent(out) :: savedtke1(1)
1793 real(kind_lake),
intent(out) :: frac_iceold(1,-nlevsnow+1:nlevsoil)
1794 real(kind_lake),
intent(out) :: qflx_snomelt(1)
1795 integer,
intent(out) :: imelt(1,-nlevsnow+1:nlevsoil)
1800 integer ,
parameter :: islak = 2
1801 real(kind_lake),
parameter :: p0 = 1._kind_lake
1802 integer :: i,j,fc,fp,g,c,p
1803 real(kind_lake) :: eta(2)
1804 real(kind_lake) :: cwat
1805 real(kind_lake) :: cice_eff
1807 real(kind_lake) :: cfus
1809 real(kind_lake) :: km
1810 real(kind_lake) :: tkice_eff
1811 real(kind_lake) :: a(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1812 real(kind_lake) :: b(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1813 real(kind_lake) :: c1(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1814 real(kind_lake) :: r(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1815 real(kind_lake) :: rhow(lbc:ubc,nlevlake)
1816 real(kind_lake) :: phi(lbc:ubc,nlevlake)
1817 real(kind_lake) :: kme(lbc:ubc,nlevlake)
1818 real(kind_lake) :: rsfin
1819 real(kind_lake) :: rsfout
1820 real(kind_lake) :: phi_soil(lbc:ubc)
1821 real(kind_lake) :: ri
1822 real(kind_lake) :: fin(lbc:ubc)
1823 real(kind_lake) :: ocvts(lbc:ubc)
1824 real(kind_lake) :: ncvts(lbc:ubc)
1825 real(kind_lake) :: ke
1826 real(kind_lake) :: zin
1827 real(kind_lake) :: zout
1828 real(kind_lake) :: drhodz
1829 real(kind_lake) :: n2
1830 real(kind_lake) :: num
1831 real(kind_lake) :: den
1832 real(kind_lake) :: tav_froz(lbc:ubc)
1833 real(kind_lake) :: tav_unfr(lbc:ubc)
1834 real(kind_lake) :: nav(lbc:ubc)
1835 real(kind_lake) :: phidum
1836 real(kind_lake) :: iceav(lbc:ubc)
1837 real(kind_lake) :: qav(lbc:ubc)
1838 integer :: jtop(lbc:ubc)
1839 real(kind_lake) :: cv (lbc:ubc,-nlevsnow+1:nlevsoil)
1840 real(kind_lake) :: tk (lbc:ubc,-nlevsnow+1:nlevsoil)
1842 real(kind_lake) :: cv_lake (lbc:ubc,1:nlevlake)
1843 real(kind_lake) :: tk_lake (lbc:ubc,1:nlevlake)
1844 real(kind_lake) :: cvx (lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1845 real(kind_lake) :: tkix(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1847 real(kind_lake) :: tx(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1848 real(kind_lake) :: tktopsoillay(lbc:ubc)
1849 real(kind_lake) :: fnx(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1850 real(kind_lake) :: phix(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1851 real(kind_lake) :: zx(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1852 real(kind_lake) :: dzm
1853 real(kind_lake) :: dzp
1855 real(kind_lake) :: factx(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1856 real(kind_lake) :: t_lake_bef(lbc:ubc,1:nlevlake)
1857 real(kind_lake) :: t_soisno_bef(lbc:ubc,-nlevsnow+1:nlevsoil)
1858 real(kind_lake) :: lhabs(lbc:ubc)
1859 real(kind_lake) :: esum1(lbc:ubc)
1860 real(kind_lake) :: esum2(lbc:ubc)
1861 real(kind_lake) :: zsum(lbc:ubc)
1862 real(kind_lake) :: wsum(lbc:ubc)
1863 real(kind_lake) :: wsum_end(lbc:ubc)
1864 real(kind_lake) :: errsoi(1)
1865 real(kind_lake) :: eflx_snomelt(1)
1866 CHARACTER*256 :: message
1870 real(kind_lake),
parameter :: beta(2) = &
1871 (/0.4_kind_lake, 0.4_kind_lake/)
1872 real(kind_lake),
parameter :: za(2) = &
1873 (/0.6_kind_lake, 0.6_kind_lake/)
1887 cice_eff = cpice*denh2o
1890 tkice_eff = tkice * denice/denh2o
1897 do fc = 1, num_shlakec
1898 c = filter_shlakec(fc)
1902 ocvts(c) = 0._kind_lake
1903 ncvts(c) = 0._kind_lake
1904 esum1(c) = 0._kind_lake
1905 esum2(c) = 0._kind_lake
1914 do j = -nlevsnow+1,0
1917 do fc = 1, num_shlakec
1918 c = filter_shlakec(fc)
1919 if (j >= snl(c) + 1)
then
1920 frac_iceold(c,j) = h2osoi_ice(c,j)/(h2osoi_liq(c,j)+h2osoi_ice(c,j))
1929 do fc = 1, num_shlakec
1930 c = filter_shlakec(fc)
1931 if (j == 1) wsum(c) = 0._kind_lake
1932 wsum(c) = wsum(c) + h2osoi_ice(c,j) + h2osoi_liq(c,j)
1938 do fp = 1, num_shlakep
1939 p = filter_shlakep(fp)
1948 fin(c) = eflx_gnet(p)
1957 do fc = 1, num_shlakec
1958 c = filter_shlakec(fc)
1959 rhow(c,j) = (1._kind_lake - lake_icefrac(c,j)) * &
1960 1000._kind_lake*( 1.0_kind_lake - 1.9549e-05_kind_lake*(abs(t_lake(c,j)-277._kind_lake))**1.68_kind_lake ) &
1961 + lake_icefrac(c,j)*denice
1970 do j = 1, nlevlake-1
1974 do fc = 1, num_shlakec
1975 c = filter_shlakec(fc)
1976 drhodz = (rhow(c,j+1)-rhow(c,j)) / (z_lake(c,j+1)-z_lake(c,j))
1977 n2 = grav / rhow(c,j) * drhodz
1980 num = 40._kind_lake * n2 * (vkc*z_lake(c,j))**2
1981 den = max( (ws(c)**2) * exp(-2._kind_lake*ks(c)*z_lake(c,j)), 1.e-10_kind_lake )
1982 ri = ( -1._kind_lake + sqrt( max(1._kind_lake+num/den, 0._kind_lake) ) ) / 20._kind_lake
1983 if (t_grnd(c) > tfrz .and. t_lake(c,1) > tfrz .and. snl(c) == 0)
then
1986 if( t_lake(c,1) > 277.15_kind_lake )
then
1987 if (lakedepth(c) > 15.0 )
then
1988 ke = 1.e+2_kind_lake*vkc*ws(c)*z_lake(c,j)/p0 * exp(-ks(c)*z_lake(c,j)) / (1._kind_lake+37._kind_lake*ri*ri)
1990 ke = vkc*ws(c)*z_lake(c,j)/p0 * exp(-ks(c)*z_lake(c,j)) / (1._kind_lake+37._kind_lake*ri*ri)
1993 if (lakedepth(c) > 15.0 )
then
1994 if (lakedepth(c) > 150.0 )
then
1995 ke = 1.e+5_kind_lake*vkc*ws(c)*z_lake(c,j)/p0 * exp(-ks(c)*z_lake(c,j)) / (1._kind_lake+37._kind_lake*ri*ri)
1997 ke =1.e+4_kind_lake*vkc*ws(c)*z_lake(c,j)/p0 * exp(-ks(c)*z_lake(c,j)) / (1._kind_lake+37._kind_lake*ri*ri)
2000 ke = vkc*ws(c)*z_lake(c,j)/p0 * exp(-ks(c)*z_lake(c,j)) / (1._kind_lake+37._kind_lake*ri*ri)
2005 tk_lake(c,j) = kme(c,j)*cwat
2011 tk_lake(c,j) = tkwat*tkice_eff / ( (1._kind_lake-lake_icefrac(c,j))*tkice_eff &
2012 + tkwat*lake_icefrac(c,j) )
2020 do fc = 1, num_shlakec
2021 c = filter_shlakec(fc)
2024 kme(c,nlevlake) = kme(c,nlevlake-1)
2026 if (t_grnd(c) > tfrz .and. t_lake(c,1) > tfrz .and. snl(c) == 0)
then
2027 tk_lake(c,j) = tk_lake(c,j-1)
2029 tk_lake(c,j) = tkwat*tkice_eff / ( (1._kind_lake-lake_icefrac(c,j))*tkice_eff &
2030 + tkwat*lake_icefrac(c,j) )
2034 savedtke1(c) = kme(c,1)*cwat
2036 jtop(c) = snl(c) + 1
2043 do fp = 1, num_shlakep
2044 p = filter_shlakep(fp)
2050 if(.not.use_etalake)
then
2051 eta(:) = 1.1925_kind_lake*lakedepth(c)**(-0.424)
2056 zin = z_lake(c,j) - 0.5_kind_lake*dz_lake(c,j)
2057 zout = z_lake(c,j) + 0.5_kind_lake*dz_lake(c,j)
2058 rsfin = exp( -eta(islak)*max( zin-za(islak),0._kind_lake ) )
2059 rsfout = exp( -eta(islak)*max( zout-za(islak),0._kind_lake ) )
2064 if (t_grnd(c) > tfrz .and. t_lake(c,1) > tfrz .and. snl(c) == 0)
then
2065 phidum = (rsfin-rsfout) * sabg(p) * (1._kind_lake-beta(islak))
2066 if (j == nlevlake)
then
2067 phi_soil(c) = rsfout * sabg(p) * (1._kind_lake-beta(islak))
2069 else if (j == 1 .and. snl(c) == 0)
then
2070 phidum = sabg(p) * (1._kind_lake-beta(islak))
2072 phidum = 0._kind_lake
2073 if (j == nlevlake) phi_soil(c) = 0._kind_lake
2086 do fc = 1, num_shlakec
2087 c = filter_shlakec(fc)
2089 cv_lake(c,j) = dz_lake(c,j) * (cwat*(1._kind_lake-lake_icefrac(c,j)) + cice_eff*lake_icefrac(c,j))
2094 call soilthermprop_lake (snl,dz,zi,z,t_soisno,h2osoi_liq,h2osoi_ice, &
2095 watsat, tksatu, tkmg, tkdry, csol, tk, cv, tktopsoillay,errmsg,errflg)
2108 do fc = 1, num_shlakec
2109 c = filter_shlakec(fc)
2112 ocvts(c) = ocvts(c) + cv_lake(c,j)*(t_lake(c,j)-tfrz) &
2113 + cfus*dz_lake(c,j)*(1._kind_lake-lake_icefrac(c,j))
2115 t_lake_bef(c,j) = t_lake(c,j)
2116 if(debug_print)
then
2117 if (abs(xlat_d-52.1152).lt.0.1 .and. &
2118 abs(xlon_d-260.405).lt.0.1)
then
2119 print *,
' ocvts(c) at xlat_d,xlon_d',xlat_d,xlon_d
2120 print *,
'j,dz_lake(c,j) ', j,dz_lake(c,j)
2121 print*,
'cv_lake(c,j),lake_icefrac(c,j),t_lake(c,j),cfus,ocvts(c)', &
2122 cv_lake(c,j),lake_icefrac(c,j),t_lake(c,j),cfus,ocvts(c)
2129 do j = -nlevsnow + 1, nlevsoil
2132 do fc = 1, num_shlakec
2133 c = filter_shlakec(fc)
2135 if (j >= jtop(c))
then
2137 ocvts(c) = ocvts(c) + cv(c,j)*(t_soisno(c,j)-tfrz) &
2138 + hfus*h2osoi_liq(c,j)
2140 if(debug_print)
then
2141 if (abs(xlat_d-52.1152).lt.0.1 .and. &
2142 abs(xlon_d-260.405).lt.0.1)
then
2143 print *,
' ocvts(c) at xlat_d,xlon_d',xlat_d,xlon_d
2144 print *,
' j,jtop(c)',j,jtop(c),
'h2osoi_liq(c,j) ',h2osoi_liq(c,j),
'h2osoi_ice(c,j)',h2osoi_ice(c,j)
2145 print *,
' cv(c,j),t_soisno(c,j),hfus,ocvts(c)',c,j,cv(c,j),t_soisno(c,j),hfus,ocvts(c)
2146 print *,
' h2osno(c)',h2osno(c)
2149 if (j == 1 .and. h2osno(c) > 0._kind_lake .and. j == jtop(c))
then
2150 ocvts(c) = ocvts(c) - h2osno(c)*hfus
2152 t_soisno_bef(c,j) = t_soisno(c,j)
2153 if(abs(t_soisno(c,j)-288) > 150)
then
215448
format(
'WARNING: At c=',i0,
' level=',i0,
' extreme t_soisno = ',f15.10)
2155 WRITE(message,48) c,j,t_soisno(c,j)
2158 write(0,
'(A)') trim(message)
2171 do j = -nlevsnow+1, nlevlake+nlevsoil
2175 do fc = 1,num_shlakec
2176 c = filter_shlakec(fc)
2178 jprime = j - nlevlake
2180 if (j >= jtop(c))
then
2184 phix(c,j) = 0._kind_lake
2185 tx(c,j) = t_soisno(c,j)
2186 else if (j <= nlevlake)
then
2187 zx(c,j) = z_lake(c,j)
2188 cvx(c,j) = cv_lake(c,j)
2189 phix(c,j) = phi(c,j)
2190 tx(c,j) = t_lake(c,j)
2192 zx(c,j) = zx(c,nlevlake) + dz_lake(c,nlevlake)*0.5_kind_lake + z(c,jprime)
2193 cvx(c,j) = cv(c,jprime)
2194 if (j == nlevlake + 1)
then
2195 phix(c,j) = phi_soil(c)
2197 phix(c,j) = 0._kind_lake
2199 tx(c,j) = t_soisno(c,jprime)
2208 do j = -nlevsnow+1, nlevlake+nlevsoil
2212 do fc = 1,num_shlakec
2213 c = filter_shlakec(fc)
2215 jprime = j - nlevlake
2217 if (j >= jtop(c))
then
2220 else if (j == 0)
then
2221 dzp = zx(c,j+1) - zx(c,j)
2222 tkix(c,j) = tk_lake(c,1)*tk(c,j)*dzp / &
2223 (tk(c,j)*z_lake(c,1) + tk_lake(c,1)*(-z(c,j)) )
2225 else if (j < nlevlake)
then
2226 tkix(c,j) = ( tk_lake(c,j)*tk_lake(c,j+1) * (dz_lake(c,j+1)+dz_lake(c,j)) ) &
2227 / ( tk_lake(c,j)*dz_lake(c,j+1) + tk_lake(c,j+1)*dz_lake(c,j) )
2228 else if (j == nlevlake)
then
2229 dzp = zx(c,j+1) - zx(c,j)
2230 tkix(c,j) = (tktopsoillay(c)*tk_lake(c,j)*dzp / &
2231 (tktopsoillay(c)*dz_lake(c,j)*0.5_kind_lake + tk_lake(c,j)*z(c,1) ) )
2234 tkix(c,j) = tk(c,jprime)
2246 do j = -nlevsnow+1, nlevlake+nlevsoil
2250 do fc = 1,num_shlakec
2251 c = filter_shlakec(fc)
2252 if (j >= jtop(c))
then
2253 if (j < nlevlake+nlevsoil)
then
2254 factx(c,j) = dtime/cvx(c,j)
2255 fnx(c,j) = tkix(c,j)*(tx(c,j+1)-tx(c,j))/(zx(c,j+1)-zx(c,j))
2257 factx(c,j) = dtime/cvx(c,j)
2258 fnx(c,j) = 0._kind_lake
2264 do j = -nlevsnow+1,nlevlake+nlevsoil
2268 do fc = 1,num_shlakec
2269 c = filter_shlakec(fc)
2270 if (j >= jtop(c))
then
2271 if (j == jtop(c))
then
2272 dzp = zx(c,j+1)-zx(c,j)
2273 a(c,j) = 0._kind_lake
2274 b(c,j) = 1+(1._kind_lake-cnfac)*factx(c,j)*tkix(c,j)/dzp
2275 c1(c,j) = -(1._kind_lake-cnfac)*factx(c,j)*tkix(c,j)/dzp
2276 r(c,j) = tx(c,j) + factx(c,j)*( fin(c) + phix(c,j) + cnfac*fnx(c,j) )
2277 else if (j < nlevlake+nlevsoil)
then
2278 dzm = (zx(c,j)-zx(c,j-1))
2279 dzp = (zx(c,j+1)-zx(c,j))
2280 a(c,j) = - (1._kind_lake-cnfac)*factx(c,j)* tkix(c,j-1)/dzm
2281 b(c,j) = 1._kind_lake+ (1._kind_lake-cnfac)*factx(c,j)*(tkix(c,j)/dzp + tkix(c,j-1)/dzm)
2282 c1(c,j) = - (1._kind_lake-cnfac)*factx(c,j)* tkix(c,j)/dzp
2283 r(c,j) = tx(c,j) + cnfac*factx(c,j)*( fnx(c,j) - fnx(c,j-1) ) + factx(c,j)*phix(c,j)
2285 dzm = (zx(c,j)-zx(c,j-1))
2286 a(c,j) = - (1._kind_lake-cnfac)*factx(c,j)*tkix(c,j-1)/dzm
2287 b(c,j) = 1._kind_lake+ (1._kind_lake-cnfac)*factx(c,j)*tkix(c,j-1)/dzm
2288 c1(c,j) = 0._kind_lake
2289 r(c,j) = tx(c,j) - cnfac*factx(c,j)*fnx(c,j-1)
2299 call tridiagonal(lbc, ubc, -nlevsnow + 1, nlevlake + nlevsoil, jtop, num_shlakec, filter_shlakec, &
2303 do j = -nlevsnow+1, nlevlake + nlevsoil
2306 do fc = 1, num_shlakec
2307 c = filter_shlakec(fc)
2309 jprime = j - nlevlake
2312 if (j >= jtop(c))
then
2314 t_soisno(c,j) = tx(c,j)
2315 else if (j <= nlevlake)
then
2316 t_lake(c,j) = tx(c,j)
2318 t_soisno(c,jprime) = tx(c,j)
2329 if_debug_energy:
if (lakedebug)
then
2333 do fc = 1, num_shlakec
2334 c = filter_shlakec(fc)
2336 esum1(c) = esum1(c) + (t_lake(c,j)-t_lake_bef(c,j))*cv_lake(c,j)
2337 esum2(c) = esum2(c) + (t_lake(c,j)-tfrz)*cv_lake(c,j)
2341 do j = -nlevsnow+1, nlevsoil
2344 do fc = 1, num_shlakec
2345 c = filter_shlakec(fc)
2347 if (j >= jtop(c))
then
2348 esum1(c) = esum1(c) + (t_soisno(c,j)-t_soisno_bef(c,j))*cv(c,j)
2349 esum2(c) = esum2(c) + (t_soisno(c,j)-tfrz)*cv(c,j)
2356 do fp = 1, num_shlakep
2357 p = filter_shlakep(fp)
2361 errsoi(c) = esum1(c)/dtime - eflx_soil_grnd(p)
2364 if(abs(errsoi(c)) > .001_kind_lake)
then
2365 WRITE( message,* )
'Primary soil energy conservation error in shlake &
2366 &column during Tridiagonal Solution,',
'error (W/m^2):', c, errsoi(c)
2367 errmsg=trim(message)
2375 end if if_debug_energy
2380 call phasechange_lake (snl,h2osno,dz,dz_lake, &
2381 t_soisno,h2osoi_liq,h2osoi_ice, &
2382 lake_icefrac,t_lake, snowdp, &
2383 qflx_snomelt,eflx_snomelt,imelt, &
2395 if_debug_balance:
if (lakedebug)
then
2399 do fc = 1, num_shlakec
2400 c = filter_shlakec(fc)
2402 esum2(c) = esum2(c) - (t_lake(c,j)-tfrz)*cv_lake(c,j)
2406 do j = -nlevsnow+1, nlevsoil
2409 do fc = 1, num_shlakec
2410 c = filter_shlakec(fc)
2412 if (j >= jtop(c))
then
2413 esum2(c) = esum2(c) - (t_soisno(c,j)-tfrz)*cv(c,j)
2420 do fp = 1, num_shlakep
2421 p = filter_shlakep(fp)
2424 esum2(c) = esum2(c) - lhabs(c)
2425 errsoi(c) = esum2(c)/dtime
2426 if(abs(errsoi(c)) > 1.e-5_kind_lake)
then
2427 write(message,*)
'Primary soil energy conservation error in shlake column during Phase Change, error (W/m^2):', &
2429 errmsg=trim(message)
2440 do fc = 1, num_shlakec
2441 c = filter_shlakec(fc)
2442 if (j == 1) wsum_end(c) = 0._kind_lake
2443 wsum_end(c) = wsum_end(c) + h2osoi_ice(c,j) + h2osoi_liq(c,j)
2444 if (j == nlevsoil)
then
2445 if (abs(wsum(c)-wsum_end(c))>1.e-7_kind_lake)
then
2446 write(message,*)
'Soil water balance error during phase change in ShalLakeTemperature.', &
2447 'column, error (kg/m^2):', c, wsum_end(c)-wsum(c)
2448 errmsg=trim(message)
2456 endif if_debug_balance
2467 do fc = 1, num_shlakec
2468 c = filter_shlakec(fc)
2469 rhow(c,j) = (1._kind_lake - lake_icefrac(c,j)) * &
2470 1000._kind_lake*( 1.0_kind_lake - 1.9549e-05_kind_lake*(abs(t_lake(c,j)-277._kind_lake))**1.68_kind_lake ) &
2471 + lake_icefrac(c,j)*denice
2475 do j = 1, nlevlake-1
2478 do fc = 1, num_shlakec
2479 c = filter_shlakec(fc)
2480 qav(c) = 0._kind_lake
2481 nav(c) = 0._kind_lake
2482 iceav(c) = 0._kind_lake
2488 do fc = 1, num_shlakec
2489 c = filter_shlakec(fc)
2490 if (rhow(c,j) > rhow(c,j+1) .or. &
2491 (lake_icefrac(c,j) < 1._kind_lake .and. lake_icefrac(c,j+1) > 0._kind_lake) )
then
2492 if(debug_print)
then
2494 print *,
'Convective Ice Mixing in column ', c,
'lake_icefrac(c,j) ',lake_icefrac(c,j),lake_icefrac(c,j+1)
2497 qav(c) = qav(c) + dz_lake(c,i)*(t_lake(c,i)-tfrz) * &
2498 ((1._kind_lake - lake_icefrac(c,i))*cwat + lake_icefrac(c,i)*cice_eff)
2500 iceav(c) = iceav(c) + lake_icefrac(c,i)*dz_lake(c,i)
2501 nav(c) = nav(c) + dz_lake(c,i)
2508 do fc = 1, num_shlakec
2509 c = filter_shlakec(fc)
2510 if (rhow(c,j) > rhow(c,j+1) .or. &
2511 (lake_icefrac(c,j) < 1._kind_lake .and. lake_icefrac(c,j+1) > 0._kind_lake) )
then
2512 qav(c) = qav(c)/nav(c)
2513 iceav(c) = iceav(c)/nav(c)
2516 if (qav(c) > 0._kind_lake)
then
2517 tav_froz(c) = 0._kind_lake
2518 tav_unfr(c) = qav(c) / ((1._kind_lake - iceav(c))*cwat)
2519 else if (qav(c) < 0._kind_lake)
then
2520 tav_froz(c) = qav(c) / (iceav(c)*cice_eff)
2521 tav_unfr(c) = 0._kind_lake
2523 tav_froz(c) = 0._kind_lake
2524 tav_unfr(c) = 0._kind_lake
2532 do fc = 1, num_shlakec
2533 c = filter_shlakec(fc)
2534 if (nav(c) > 0._kind_lake)
then
2543 if (i == 1) zsum(c) = 0._kind_lake
2544 if ((zsum(c)+dz_lake(c,i))/nav(c) <= iceav(c))
then
2545 t_lake(c,i) = tav_froz(c) + tfrz
2549 else if (zsum(c)/nav(c) < iceav(c))
then
2551 lake_icefrac(c,i) = (iceav(c)*nav(c) - zsum(c)) / dz_lake(c,i)
2553 t_lake(c,i) = ( lake_icefrac(c,i)*tav_froz(c)*cice_eff &
2554 + (1._kind_lake - lake_icefrac(c,i))*tav_unfr(c)*cwat ) &
2555 / ( lake_icefrac(c,i)*cice_eff + (1-lake_icefrac(c,i))*cwat ) + tfrz
2558 lake_icefrac(c,i) = 0._kind_lake
2559 t_lake(c,i) = tav_unfr(c) + tfrz
2561 zsum(c) = zsum(c) + dz_lake(c,i)
2563 rhow(c,i) = (1._kind_lake - lake_icefrac(c,i)) * &
2564 1000._kind_lake*( 1.0_kind_lake - 1.9549e-05_kind_lake*(abs(t_lake(c,i)-277._kind_lake))**1.68_kind_lake ) &
2565 + lake_icefrac(c,i)*denice
2566 if (debug_print .and. lake_icefrac(c,j) > 0.)print *,
'rhow(c,i),lake_icefrac(c,i),t_lake(c,i)', &
2567 i,rhow(c,i),lake_icefrac(c,i),t_lake(c,i),denice
2579 do fc = 1, num_shlakec
2580 c = filter_shlakec(fc)
2582 cv_lake(c,j) = dz_lake(c,j) * (cwat*(1._kind_lake-lake_icefrac(c,j)) + cice_eff*lake_icefrac(c,j))
2583 if (debug_print .and. lake_icefrac(c,j) > 0.)
then
2584 print *,
'Lake Ice Fraction, c, level:', c, j, lake_icefrac(c,j)
2590 call soilthermprop_lake (snl,dz,zi,z,t_soisno,h2osoi_liq,h2osoi_ice, &
2591 watsat, tksatu, tkmg, tkdry, csol, tk, cv, tktopsoillay,errmsg,errflg)
2598 do fc = 1, num_shlakec
2599 c = filter_shlakec(fc)
2602 ncvts(c) = ncvts(c) + cv_lake(c,j)*(t_lake(c,j)-tfrz) &
2603 + cfus*dz_lake(c,j)*(1._kind_lake-lake_icefrac(c,j))
2605 fin(c) = fin(c) + phi(c,j)
2606 if(debug_print)
then
2607 if (abs(xlat_d-52.1152).lt.0.1 .and. &
2608 abs(xlon_d-260.405).lt.0.1)
then
2609 print *,
' ncvts(c) at xlat_d,xlon_d',xlat_d,xlon_d
2610 print *,
' new cv_lake(c,j),t_lake(c,j),cfus,lake_icefrac(c,j),ncvts(c),fin(c)', &
2611 j,cv_lake(c,j),t_lake(c,j),cfus,lake_icefrac(c,j),ncvts(c),fin(c)
2612 print *,
' new dz_lake(c,j),fin(c),phi(c,j)',c,dz_lake(c,j),fin(c),phi(c,j)
2618 do j = -nlevsnow + 1, nlevsoil
2621 do fc = 1, num_shlakec
2622 c = filter_shlakec(fc)
2624 if (j >= jtop(c))
then
2626 ncvts(c) = ncvts(c) + cv(c,j)*(t_soisno(c,j)-tfrz) &
2627 + hfus*h2osoi_liq(c,j)
2629 if(debug_print)
then
2630 if (abs(xlat_d-52.1152).lt.0.1 .and. &
2631 abs(xlon_d-260.405).lt.0.1)
then
2632 print *,
' ncvts(c) at xlat_d,xlon_d',xlat_d,xlon_d
2633 print *,
'new j,jtop(c)',j,jtop(c),
'h2osoi_liq(c,j) ',h2osoi_liq(c,j),
'h2osoi_ice(c,j)',h2osoi_ice(c,j)
2634 print *,
'new cv(c,j),t_soisno(c,j),hfus,ncvts(c)',c,j,cv(c,j),t_soisno(c,j),hfus,ncvts(c)
2635 print *,
'new h2osno(c)',h2osno(c)
2638 if (j == 1 .and. h2osno(c) > 0._kind_lake .and. j == jtop(c))
then
2639 ncvts(c) = ncvts(c) - h2osno(c)*hfus
2642 if (j == 1) fin(c) = fin(c) + phi_soil(c)
2649 do fp = 1, num_shlakep
2650 p = filter_shlakep(fp)
2652 errsoi(c) = (ncvts(c)-ocvts(c)) / dtime - fin(c)
2653 if(debug_print)
then
2654 if (abs(xlat_d-52.1152).lt.0.1 .and. &
2655 abs(xlon_d-260.405).lt.0.1)
then
2656 print *,
'xlat_d,xlon_d',xlat_d,xlon_d
2657 print *,
'errsoi(c),fin(c),ncvts(c),ocvts(c),dtime,lake_icefrac(c,:),h2osno(c)', &
2658 errsoi(c),fin(c),ncvts(c),ocvts(c),dtime,lake_icefrac(c,:),h2osno(c)
2661 if( .not.lakedebug )
then
2662 if (abs(errsoi(c)) < 10._kind_lake)
then
2663 eflx_sh_tot(p) = eflx_sh_tot(p) - errsoi(c)
2664 eflx_sh_grnd(p) = eflx_sh_grnd(p) - errsoi(c)
2665 eflx_soil_grnd(p) = eflx_soil_grnd(p) + errsoi(c)
2666 eflx_gnet(p) = eflx_gnet(p) + errsoi(c)
2667 if(debug_print)
then
2668 if (abs(errsoi(c)) > 1.e-1_kind_lake)
then
2669 print *,
'errsoi incorporated at xlat_d,xlon_d',xlat_d,xlon_d
2670 print *,
'errsoi incorporated into sensible heat in ShalLakeTemperature: c, (W/m^2):', c, errsoi(c)
2673 errsoi(c) = 0._kind_lake
2675 elseif ( lakedebug)
then
2676 if (abs(errsoi(c)) < 1._kind_lake)
then
2677 eflx_sh_tot(p) = eflx_sh_tot(p) - errsoi(c)
2678 eflx_sh_grnd(p) = eflx_sh_grnd(p) - errsoi(c)
2679 eflx_soil_grnd(p) = eflx_soil_grnd(p) + errsoi(c)
2680 eflx_gnet(p) = eflx_gnet(p) + errsoi(c)
2681 if (abs(errsoi(c)) > 1.e-1_kind_lake)
then
2682 print *,
'errsoi incorporated into sensible heat in ShalLakeTemperature: c, (W/m^2):', c, errsoi(c)
2684 errsoi(c) = 0._kind_lake
2686 print *,
'Soil Energy Balance Error at column, ', c,
'G, fintotal, column E tendency = ', &
2687 eflx_gnet(p), fin(c), (ncvts(c)-ocvts(c)) / dtime,
'xlat_d,xlon_d',xlat_d,xlon_d
2688 print *,
'errsoi(c),ncvts(c),ocvts(c)',errsoi(c),ncvts(c),ocvts(c),
'xlat_d,xlon_d',xlat_d,xlon_d
2689 print *,
'lake_icefrac(c,:),h2osno(c)', lake_icefrac(c,:),h2osno(c)
2690 print *,
't_lake(c,:),t_soisno(c,:)',t_lake(c,:),t_soisno(c,:)
2696 end subroutine shallaketemperature
2720 subroutine soilthermprop_lake (snl,dz,zi,z,t_soisno,h2osoi_liq,h2osoi_ice, &
2721 watsat, tksatu, tkmg, tkdry, csol, tk, cv, tktopsoillay,errmsg,errflg)
2726 integer,
intent(inout) :: errflg
2727 character(*),
intent(inout) :: errmsg
2728 integer ,
intent(in) :: snl(1)
2730 real(kind_lake),
intent(in) :: watsat(1,nlevsoil)
2731 real(kind_lake),
intent(in) :: tksatu(1,nlevsoil)
2732 real(kind_lake),
intent(in) :: tkmg(1,nlevsoil)
2733 real(kind_lake),
intent(in) :: tkdry(1,nlevsoil)
2734 real(kind_lake),
intent(in) :: csol(1,nlevsoil)
2735 real(kind_lake),
intent(in) :: dz(1,-nlevsnow+1:nlevsoil)
2736 real(kind_lake),
intent(in) :: zi(1,-nlevsnow+0:nlevsoil)
2737 real(kind_lake),
intent(in) :: z(1,-nlevsnow+1:nlevsoil)
2738 real(kind_lake),
intent(in) :: t_soisno(1,-nlevsnow+1:nlevsoil)
2739 real(kind_lake),
intent(in) :: h2osoi_liq(1,-nlevsnow+1:nlevsoil)
2740 real(kind_lake),
intent(in) :: h2osoi_ice(1,-nlevsnow+1:nlevsoil)
2743 real(kind_lake),
intent(out) :: cv(lbc:ubc,-nlevsnow+1:nlevsoil)
2744 real(kind_lake),
intent(out) :: tk(lbc:ubc,-nlevsnow+1:nlevsoil)
2745 real(kind_lake),
intent(out) :: tktopsoillay(lbc:ubc)
2772 real(kind_lake) :: bw
2773 real(kind_lake) :: dksat
2774 real(kind_lake) :: dke
2775 real(kind_lake) :: fl
2776 real(kind_lake) :: satw
2777 real(kind_lake) :: thk(lbc:ubc,-nlevsnow+1:nlevsoil)
2778 character*256 :: message
2780 real(kind_lake) :: denom
2784 do j = -nlevsnow+1,nlevsoil
2787 do fc = 1, num_shlakec
2788 c = filter_shlakec(fc)
2798 satw = (h2osoi_liq(c,j)/denh2o + h2osoi_ice(c,j)/denice)/(dz(c,j)*watsat(c,j))
2800 if (satw < 0.999_kind_lake)
then
2801 write(message,*)
'WARNING: soil layer unsaturated in SoilThermProp_Lake, satw, j = ', satw, j
2804 write(0,
'(A)') trim(message)
2811 denom = (h2osoi_ice(c,j)+h2osoi_liq(c,j))
2812 if(denom>zero_h2o)
then
2813 fl = h2osoi_liq(c,j)/denom
2815 write(message,
'(A,I0)')
'WARNING: zero h2osoi_ice+h2osoi_liq at j = ', j
2819 write(0,
'(A)') trim(message)
2821 if (t_soisno(c,j) >= tfrz)
then
2822 dke = max(0._kind_lake, log10(satw) + 1.0_kind_lake)
2826 dksat = tkmg(c,j)*0.249_kind_lake**(fl*watsat(c,j))*2.29_kind_lake**watsat(c,j)
2828 thk(c,j) = dke*dksat + (1._kind_lake-dke)*tkdry(c,j)
2837 if (snl(c)+1 < 1 .AND. (j >= snl(c)+1) .AND. (j <= 0))
then
2838 bw = (h2osoi_ice(c,j)+h2osoi_liq(c,j))/dz(c,j)
2839 thk(c,j) = tkairc + (7.75e-5_kind_lake *bw + 1.105e-6_kind_lake*bw*bw)*(tkice-tkairc)
2851 do j = -nlevsnow+1,nlevsoil
2854 do fc = 1,num_shlakec
2855 c = filter_shlakec(fc)
2856 if (j >= snl(c)+1 .AND. j <= nlevsoil-1 .AND. j /= 0)
then
2857 tk(c,j) = thk(c,j)*thk(c,j+1)*(z(c,j+1)-z(c,j)) &
2858 /(thk(c,j)*(z(c,j+1)-zi(c,j))+thk(c,j+1)*(zi(c,j)-z(c,j)))
2859 else if (j == 0)
then
2861 else if (j == nlevsoil)
then
2862 tk(c,j) = 0._kind_lake
2865 if (j == 1) tktopsoillay(c) = thk(c,j)
2874 do fc = 1,num_shlakec
2875 c = filter_shlakec(fc)
2878 cv(c,j) = csol(c,j)*(1-watsat(c,j))*dz(c,j) + &
2879 (h2osoi_ice(c,j)*cpice + h2osoi_liq(c,j)*cpliq)
2894 do j = -nlevsnow+1,0
2897 do fc = 1,num_shlakec
2898 c = filter_shlakec(fc)
2899 if (snl(c)+1 < 1 .and. j >= snl(c)+1)
then
2900 cv(c,j) = cpliq*h2osoi_liq(c,j) + cpice*h2osoi_ice(c,j)
2905 end subroutine soilthermprop_lake
2932 subroutine phasechange_lake (snl,h2osno,dz,dz_lake, & !i
2933 t_soisno,h2osoi_liq,h2osoi_ice, & !i&o
2934 lake_icefrac,t_lake, snowdp, & !i&o
2935 qflx_snomelt,eflx_snomelt,imelt, & !o
2952 integer ,
intent(in) :: snl(1)
2953 real(kind_lake),
intent(inout) :: h2osno(1)
2954 real(kind_lake),
intent(in) :: dz(1,-nlevsnow+1:nlevsoil)
2955 real(kind_lake),
intent(in) :: dz_lake(1,nlevlake)
2960 real(kind_lake),
intent(inout) :: snowdp(1)
2961 real(kind_lake),
intent(inout) :: t_soisno(1,-nlevsnow+1:nlevsoil)
2962 real(kind_lake),
intent(inout) :: h2osoi_liq(1,-nlevsnow+1:nlevsoil)
2963 real(kind_lake),
intent(inout) :: h2osoi_ice(1,-nlevsnow+1:nlevsoil)
2964 real(kind_lake),
intent(inout) :: lake_icefrac(1,nlevlake)
2965 real(kind_lake),
intent(inout) :: t_lake(1,nlevlake)
2968 real(kind_lake),
intent(out) :: qflx_snomelt(1)
2969 real(kind_lake),
intent(out) :: eflx_snomelt(1)
2970 integer,
intent(out) :: imelt(1,-nlevsnow+1:nlevsoil)
2972 real(kind_lake),
intent(inout) :: cv(lbc:ubc,-nlevsnow+1:nlevsoil)
2973 real(kind_lake),
intent(inout) :: cv_lake (lbc:ubc,1:nlevlake)
2974 real(kind_lake),
intent(out):: lhabs(lbc:ubc)
2981 real(kind_lake) :: heatavail
2982 real(kind_lake) :: heatrem
2983 real(kind_lake) :: melt
2984 real(kind_lake),
parameter :: smallnumber = 1.e-7_kind_lake
2985 logical :: dophasechangeflag
2992 do fc = 1,num_shlakec
2993 c = filter_shlakec(fc)
2995 qflx_snomelt(c) = 0._kind_lake
2996 eflx_snomelt(c) = 0._kind_lake
2997 lhabs(c) = 0._kind_lake
3000 do j = -nlevsnow+1,0
3003 do fc = 1,num_shlakec
3004 c = filter_shlakec(fc)
3006 if (j >= snl(c) + 1) imelt(c,j) = 0
3014 do fc = 1,num_shlakec
3015 c = filter_shlakec(fc)
3017 if (snl(c) == 0 .and. h2osno(c) > 0._kind_lake .and. t_lake(c,1) > tfrz)
then
3018 heatavail = (t_lake(c,1) - tfrz) * cv_lake(c,1)
3019 melt = min(h2osno(c), heatavail/hfus)
3020 heatrem = max(heatavail - melt*hfus, 0._kind_lake)
3022 t_lake(c,1) = tfrz + heatrem/(cv_lake(c,1))
3023 snowdp(c) = snowdp(c)*(1._kind_lake - melt/h2osno(c))
3024 h2osno(c) = h2osno(c) - melt
3025 lhabs(c) = lhabs(c) + melt*hfus
3026 qflx_snomelt(c) = qflx_snomelt(c) + melt
3028 if (h2osno(c) < smallnumber) h2osno(c) = 0._kind_lake
3029 if (snowdp(c) < smallnumber) snowdp(c) = 0._kind_lake
3038 do fc = 1,num_shlakec
3039 c = filter_shlakec(fc)
3041 dophasechangeflag = .false.
3042 if (t_lake(c,j) > tfrz .and. lake_icefrac(c,j) > 0._kind_lake)
then
3043 dophasechangeflag = .true.
3044 heatavail = (t_lake(c,j) - tfrz) * cv_lake(c,j)
3045 melt = min(lake_icefrac(c,j)*denh2o*dz_lake(c,j), heatavail/hfus)
3047 heatrem = max(heatavail - melt*hfus, 0._kind_lake)
3049 else if (t_lake(c,j) < tfrz .and. lake_icefrac(c,j) < 1._kind_lake)
then
3050 dophasechangeflag = .true.
3051 heatavail = (t_lake(c,j) - tfrz) * cv_lake(c,j)
3052 melt = max(-(1._kind_lake-lake_icefrac(c,j))*denh2o*dz_lake(c,j), heatavail/hfus)
3054 heatrem = min(heatavail - melt*hfus, 0._kind_lake)
3058 if (dophasechangeflag)
then
3059 lake_icefrac(c,j) = lake_icefrac(c,j) - melt/(denh2o*dz_lake(c,j))
3060 lhabs(c) = lhabs(c) + melt*hfus
3062 cv_lake(c,j) = cv_lake(c,j) + melt*(cpliq-cpice)
3063 t_lake(c,j) = tfrz + heatrem/cv_lake(c,j)
3065 if (lake_icefrac(c,j) > 1._kind_lake - smallnumber) lake_icefrac(c,j) = 1._kind_lake
3066 if (lake_icefrac(c,j) < smallnumber) lake_icefrac(c,j) = 0._kind_lake
3073 do j = -nlevsnow+1,nlevsoil
3076 do fc = 1,num_shlakec
3077 c = filter_shlakec(fc)
3078 dophasechangeflag = .false.
3080 if (j >= snl(c) + 1)
then
3082 if (t_soisno(c,j) > tfrz .and. h2osoi_ice(c,j) > 0._kind_lake)
then
3083 dophasechangeflag = .true.
3084 heatavail = (t_soisno(c,j) - tfrz) * cv(c,j)
3085 melt = min(h2osoi_ice(c,j), heatavail/hfus)
3086 heatrem = max(heatavail - melt*hfus, 0._kind_lake)
3090 qflx_snomelt(c) = qflx_snomelt(c) + melt
3092 else if (t_soisno(c,j) < tfrz .and. h2osoi_liq(c,j) > 0._kind_lake)
then
3093 dophasechangeflag = .true.
3094 heatavail = (t_soisno(c,j) - tfrz) * cv(c,j)
3095 melt = max(-h2osoi_liq(c,j), heatavail/hfus)
3096 heatrem = min(heatavail - melt*hfus, 0._kind_lake)
3100 qflx_snomelt(c) = qflx_snomelt(c) + melt
3107 if (dophasechangeflag)
then
3108 h2osoi_ice(c,j) = h2osoi_ice(c,j) - melt
3109 h2osoi_liq(c,j) = h2osoi_liq(c,j) + melt
3110 lhabs(c) = lhabs(c) + melt*hfus
3112 cv(c,j) = cv(c,j) + melt*(cpliq-cpice)
3113 t_soisno(c,j) = tfrz + heatrem/cv(c,j)
3115 if (h2osoi_ice(c,j) < smallnumber) h2osoi_ice(c,j) = 0._kind_lake
3116 if (h2osoi_liq(c,j) < smallnumber) h2osoi_liq(c,j) = 0._kind_lake
3126 do fc = 1,num_shlakec
3127 c = filter_shlakec(fc)
3128 eflx_snomelt(c) = qflx_snomelt(c)*hfus
3132 end subroutine phasechange_lake
3147 subroutine shallakehydrology(dz_lake,forc_rain,forc_snow, & !i
3148 begwb,qflx_evap_tot,forc_t,do_capsnow, &
3149 t_grnd,qflx_evap_soi, &
3150 qflx_snomelt,imelt,frac_iceold, & !i add by guhp
3151 z,dz,zi,snl,h2osno,snowdp,lake_icefrac,t_lake, & !i&o
3152 endwb,snowage,snowice,snowliq,t_snow, & !o
3153 t_soisno,h2osoi_ice,h2osoi_liq,h2osoi_vol, &
3154 qflx_drain,qflx_surf,qflx_infl,qflx_qrgwl, &
3155 qcharge,qflx_prec_grnd,qflx_snowcap, &
3156 qflx_snowcap_col,qflx_snow_grnd_pft, &
3157 qflx_snow_grnd_col,qflx_rain_grnd, &
3158 qflx_evap_tot_col,soilalpha,zwt,fcov, &
3159 rootr_column,qflx_evap_grnd,qflx_sub_snow, &
3160 qflx_dew_snow,qflx_dew_grnd,qflx_rain_grnd_col, &
3161 watsat, tksatu, tkmg, tkdry, csol, &
3162 dtime,errmsg,errflg)
3192 integer,
intent(inout) :: errflg
3193 character(*),
intent(inout) :: errmsg
3195 real(kind_lake) :: watsat(1,nlevsoil)
3196 real(kind_lake) :: tksatu(1,nlevsoil)
3197 real(kind_lake) :: tkmg(1,nlevsoil)
3198 real(kind_lake) :: tkdry(1,nlevsoil)
3199 real(kind_lake) :: csol(1,nlevsoil)
3203 real(kind_lake),
intent(in) :: dtime
3204 real(kind_lake),
intent(in) :: dz_lake(1,nlevlake)
3205 real(kind_lake),
intent(in) :: forc_rain(1)
3206 real(kind_lake),
intent(in) :: forc_snow(1)
3207 real(kind_lake),
intent(in) :: qflx_evap_tot(1)
3208 real(kind_lake),
intent(in) :: forc_t(1)
3212 logical ,
intent(in) :: do_capsnow(1)
3213 real(kind_lake),
intent(in) :: t_grnd(1)
3214 real(kind_lake),
intent(in) :: qflx_evap_soi(1)
3215 real(kind_lake),
intent(in) :: qflx_snomelt(1)
3216 integer,
intent(in) :: imelt(1,-nlevsnow+1:nlevsoil)
3220 real(kind_lake),
intent(inout) :: begwb(1)
3225 real(kind_lake),
intent(inout) :: z(1,-nlevsnow+1:nlevsoil)
3226 real(kind_lake),
intent(inout) :: dz(1,-nlevsnow+1:nlevsoil)
3227 real(kind_lake),
intent(inout) :: zi(1,-nlevsnow+0:nlevsoil)
3228 integer ,
intent(inout) :: snl(1)
3229 real(kind_lake),
intent(inout) :: h2osno(1)
3230 real(kind_lake),
intent(inout) :: snowdp(1)
3231 real(kind_lake),
intent(inout) :: lake_icefrac(1,nlevlake)
3232 real(kind_lake),
intent(inout) :: t_lake(1,nlevlake)
3234 real(kind_lake),
intent(inout) :: frac_iceold(1,-nlevsnow+1:nlevsoil)
3238 real(kind_lake),
intent(out) :: endwb(1)
3239 real(kind_lake),
intent(out) :: snowage(1)
3240 real(kind_lake),
intent(out) :: snowice(1)
3241 real(kind_lake),
intent(out) :: snowliq(1)
3242 real(kind_lake),
intent(out) :: t_snow(1)
3243 real(kind_lake),
intent(out) :: t_soisno(1,-nlevsnow+1:nlevsoil)
3244 real(kind_lake),
intent(out) :: h2osoi_ice(1,-nlevsnow+1:nlevsoil)
3245 real(kind_lake),
intent(out) :: h2osoi_liq(1,-nlevsnow+1:nlevsoil)
3246 real(kind_lake),
intent(out) :: h2osoi_vol(1,-nlevsnow+1:nlevsoil)
3247 real(kind_lake),
intent(out) :: qflx_drain(1)
3248 real(kind_lake),
intent(out) :: qflx_surf(1)
3249 real(kind_lake),
intent(out) :: qflx_infl(1)
3250 real(kind_lake),
intent(out) :: qflx_qrgwl(1)
3251 real(kind_lake),
intent(out) :: qcharge(1)
3252 real(kind_lake),
intent(out) :: qflx_prec_grnd(1)
3253 real(kind_lake),
intent(out) :: qflx_snowcap(1)
3254 real(kind_lake),
intent(out) :: qflx_snowcap_col(1)
3255 real(kind_lake),
intent(out) :: qflx_snow_grnd_pft(1)
3256 real(kind_lake),
intent(out) :: qflx_snow_grnd_col(1)
3257 real(kind_lake),
intent(out) :: qflx_rain_grnd(1)
3258 real(kind_lake),
intent(out) :: qflx_evap_tot_col(1)
3259 real(kind_lake) ,
intent(out) :: soilalpha(1)
3260 real(kind_lake),
intent(out) :: zwt(1)
3261 real(kind_lake),
intent(out) :: fcov(1)
3262 real(kind_lake),
intent(out) :: rootr_column(1,1:nlevsoil)
3263 real(kind_lake),
intent(out) :: qflx_evap_grnd(1)
3264 real(kind_lake),
intent(out) :: qflx_sub_snow(1)
3265 real(kind_lake),
intent(out) :: qflx_dew_snow(1)
3266 real(kind_lake),
intent(out) :: qflx_dew_grnd(1)
3267 real(kind_lake),
intent(out) :: qflx_rain_grnd_col(1)
3270 real(kind_lake),
pointer :: sucsat(:,:)
3271 real(kind_lake),
pointer :: bsw(:,:)
3272 real(kind_lake),
pointer :: bsw2(:,:)
3273 real(kind_lake),
pointer :: psisat(:,:)
3274 real(kind_lake),
pointer :: vwcsat(:,:)
3275 real(kind_lake),
pointer :: wf(:)
3276 real(kind_lake),
pointer :: soilpsi(:,:)
3280 integer :: p,fp,g,l,c,j,fc,jtop
3281 integer :: num_shlakesnowc
3282 integer :: filter_shlakesnowc(ubc-lbc+1)
3283 integer :: num_shlakenosnowc
3284 integer :: filter_shlakenosnowc(ubc-lbc+1)
3286 real(kind_lake) :: dz_snowf
3287 real(kind_lake) :: bifall
3288 real(kind_lake) :: fracsnow(lbp:ubp)
3289 real(kind_lake) :: fracrain(lbp:ubp)
3290 real(kind_lake) :: qflx_prec_grnd_snow(lbp:ubp)
3291 real(kind_lake) :: qflx_prec_grnd_rain(lbp:ubp)
3292 real(kind_lake) :: qflx_evap_soi_lim
3293 real(kind_lake) :: h2osno_temp
3294 real(kind_lake) :: sumsnowice(lbc:ubc)
3295 logical :: unfrozen(lbc:ubc)
3296 real(kind_lake) :: heatrem
3297 real(kind_lake) :: heatsum(lbc:ubc)
3298 real(kind_lake) :: qflx_top_soil(1)
3299 character*256 :: message
3301 real(kind_lake),
allocatable :: snow_water(:)
3310 do fc = 1, num_shlakec
3311 c = filter_shlakec(fc)
3312 begwb(c) = begwb(c) + h2osoi_ice(c,j) + h2osoi_liq(c,j)
3322 do fp = 1, num_shlakep
3323 p = filter_shlakep(fp)
3336 qflx_prec_grnd_snow(p) = forc_snow(g)
3337 qflx_prec_grnd_rain(p) = forc_rain(g)
3342 qflx_prec_grnd(p) = qflx_prec_grnd_snow(p) + qflx_prec_grnd_rain(p)
3344 if (do_capsnow(c))
then
3345 qflx_snowcap(p) = qflx_prec_grnd_snow(p) + qflx_prec_grnd_rain(p)
3346 qflx_snow_grnd_pft(p) = 0._kind_lake
3347 qflx_rain_grnd(p) = 0._kind_lake
3349 qflx_snowcap(p) = 0._kind_lake
3350 qflx_snow_grnd_pft(p) = qflx_prec_grnd_snow(p)
3351 qflx_rain_grnd(p) = qflx_prec_grnd_rain(p)
3354 qflx_snow_grnd_col(c) = qflx_snow_grnd_pft(p)
3355 qflx_rain_grnd_col(c) = qflx_rain_grnd(p)
3363 do fc = 1, num_shlakec
3364 c = filter_shlakec(fc)
3372 if (do_capsnow(c))
then
3373 dz_snowf = 0._kind_lake
3375 if (forc_t(g) > tfrz + 2._kind_lake)
then
3376 bifall=50._kind_lake + 1.7_kind_lake*(17.0_kind_lake)**1.5_kind_lake
3377 else if (forc_t(g) > tfrz - 15._kind_lake)
then
3378 bifall=50._kind_lake + 1.7_kind_lake*(forc_t(g) - tfrz + 15._kind_lake)**1.5_kind_lake
3380 bifall=50._kind_lake
3382 dz_snowf = qflx_snow_grnd_col(c)/bifall
3383 snowdp(c) = snowdp(c) + dz_snowf*dtime
3384 h2osno(c) = h2osno(c) + qflx_snow_grnd_col(c)*dtime
3399 if (snl(c) == 0 .and. qflx_snow_grnd_col(c) > 0.0_kind_lake .and. snowdp(c) >= 0.01_kind_lake)
then
3403 z(c,0) = -0.5_kind_lake*dz(c,0)
3405 snowage(c) = 0._kind_lake
3406 t_soisno(c,0) = min(tfrz, forc_t(g))
3407 h2osoi_ice(c,0) = h2osno(c)
3408 h2osoi_liq(c,0) = 0._kind_lake
3409 frac_iceold(c,0) = 1._kind_lake
3416 if (snl(c) < 0 .and. newnode == 0)
then
3417 h2osoi_ice(c,snl(c)+1) = h2osoi_ice(c,snl(c)+1)+dtime*qflx_snow_grnd_col(c)
3418 dz(c,snl(c)+1) = dz(c,snl(c)+1)+dz_snowf*dtime
3427 do fp = 1,num_shlakep
3428 p = filter_shlakep(fp)
3433 qflx_evap_grnd(c) = 0._kind_lake
3434 qflx_sub_snow(c) = 0._kind_lake
3435 qflx_dew_snow(c) = 0._kind_lake
3436 qflx_dew_grnd(c) = 0._kind_lake
3443 if (qflx_evap_soi(p) >= 0._kind_lake)
then
3448 qflx_evap_soi_lim = min(qflx_evap_soi(p), (h2osoi_liq(c,j)+h2osoi_ice(c,j))/dtime)
3449 if ((h2osoi_liq(c,j)+h2osoi_ice(c,j)) > 0._kind_lake)
then
3450 qflx_evap_grnd(c) = max(qflx_evap_soi_lim*(h2osoi_liq(c,j)/(h2osoi_liq(c,j)+h2osoi_ice(c,j))), 0._kind_lake)
3452 qflx_evap_grnd(c) = 0._kind_lake
3454 qflx_sub_snow(c) = qflx_evap_soi_lim - qflx_evap_grnd(c)
3456 if (t_grnd(c) < tfrz)
then
3457 qflx_dew_snow(c) = abs(qflx_evap_soi(p))
3459 qflx_dew_grnd(c) = abs(qflx_evap_soi(p))
3465 if (do_capsnow(c)) qflx_snowcap(p) = qflx_snowcap(p) + qflx_dew_snow(c) + qflx_dew_grnd(c)
3468 if (qflx_evap_soi(p) >= 0._kind_lake)
then
3471 qflx_sub_snow(c) = min(qflx_evap_soi(p), h2osno(c)/dtime)
3472 qflx_evap_grnd(c) = qflx_evap_soi(p) - qflx_sub_snow(c)
3474 if (t_grnd(c) < tfrz-0.1_kind_lake)
then
3475 qflx_dew_snow(c) = abs(qflx_evap_soi(p))
3477 qflx_dew_grnd(c) = abs(qflx_evap_soi(p))
3482 h2osno_temp = h2osno(c)
3483 if (do_capsnow(c))
then
3484 h2osno(c) = h2osno(c) - qflx_sub_snow(c)*dtime
3485 qflx_snowcap(p) = qflx_snowcap(p) + qflx_dew_snow(c) + qflx_dew_grnd(c)
3487 h2osno(c) = h2osno(c) + (-qflx_sub_snow(c)+qflx_dew_snow(c))*dtime
3489 if (h2osno_temp > 0._kind_lake)
then
3490 snowdp(c) = snowdp(c) * h2osno(c) / h2osno_temp
3492 snowdp(c) = h2osno(c)/snow_bd
3496 if (abs(h2osno(c)) < 1.e-10_kind_lake) h2osno(c) = 0._kind_lake
3498 h2osno(c) = max(h2osno(c), 0._kind_lake)
3503 qflx_snowcap_col(c) = qflx_snowcap(p)
3512 call buildsnowfilter(lbc, ubc, num_shlakec, filter_shlakec,snl, &
3513 num_shlakesnowc, filter_shlakesnowc, num_shlakenosnowc, filter_shlakenosnowc)
3517 call snowwater(lbc, ubc, num_shlakesnowc, filter_shlakesnowc, &
3518 num_shlakenosnowc, filter_shlakenosnowc, &
3519 snl,do_capsnow,qflx_snomelt,qflx_rain_grnd, &
3520 qflx_sub_snow,qflx_evap_grnd, &
3521 qflx_dew_snow,qflx_dew_grnd,dz,dtime, &
3522 h2osoi_ice,h2osoi_liq, &
3534 do fc = 1, num_shlakec
3535 c = filter_shlakec(fc)
3537 if (h2osoi_vol(c,j) < watsat(c,j))
then
3538 h2osoi_liq(c,j) = (watsat(c,j)*dz(c,j) - h2osoi_ice(c,j)/denice)*denh2o
3540 else if (h2osoi_liq(c,j) > watsat(c,j)*denh2o*dz(c,j))
then
3541 h2osoi_liq(c,j) = watsat(c,j)*denh2o*dz(c,j)
3553 call snowcompaction(lbc, ubc, num_shlakesnowc, filter_shlakesnowc, &
3554 snl,imelt,frac_iceold,t_soisno, &
3555 h2osoi_ice,h2osoi_liq,dtime, &
3560 call combinesnowlayers(lbc, ubc, &
3561 num_shlakesnowc, filter_shlakesnowc, &
3562 snl,h2osno,snowdp,dz,zi, &
3563 t_soisno,h2osoi_ice,h2osoi_liq, &
3569 call dividesnowlayers(lbc, ubc, &
3570 num_shlakesnowc, filter_shlakesnowc, &
3571 snl,dz,zi,t_soisno, &
3572 h2osoi_ice,h2osoi_liq, &
3578 do fc = 1, num_shlakesnowc
3579 c = filter_shlakesnowc(fc)
3580 h2osno(c) = 0._kind_lake
3582 do j = -nlevsnow+1,0
3583 do fc = 1, num_shlakesnowc
3584 c = filter_shlakesnowc(fc)
3585 if (j >= snl(c)+1)
then
3586 h2osno(c) = h2osno(c) + h2osoi_ice(c,j) + h2osoi_liq(c,j)
3600 do fc = 1, num_shlakec
3601 c = filter_shlakec(fc)
3603 if (t_lake(c,1) > tfrz .and. lake_icefrac(c,1) == 0._kind_lake .and. snl(c) < 0)
then
3604 unfrozen(c) = .true.
3606 unfrozen(c) = .false.
3610 do j = -nlevsnow+1,0
3613 do fc = 1, num_shlakec
3614 c = filter_shlakec(fc)
3616 if (unfrozen(c))
then
3617 if (j == -nlevsnow+1)
then
3618 sumsnowice(c) = 0._kind_lake
3619 heatsum(c) = 0._kind_lake
3621 if (j >= snl(c)+1)
then
3622 sumsnowice(c) = sumsnowice(c) + h2osoi_ice(c,j)
3623 heatsum(c) = heatsum(c) + h2osoi_ice(c,j)*cpice*(tfrz - t_soisno(c,j)) &
3624 + h2osoi_liq(c,j)*cpliq*(tfrz - t_soisno(c,j))
3632 do fc = 1, num_shlakec
3633 c = filter_shlakec(fc)
3635 if (unfrozen(c))
then
3636 heatsum(c) = heatsum(c) + sumsnowice(c)*hfus
3637 heatrem = (t_lake(c,1) - tfrz)*cpliq*denh2o*dz_lake(c,1) - heatsum(c)
3639 if (heatrem + denh2o*dz_lake(c,1)*hfus > 0._kind_lake)
then
3641 h2osno(c) = 0._kind_lake
3644 if (debug_print)
then
3645 print *,
'Snow layers removed above unfrozen lake for column, snowice:', &
3648 if (heatrem > 0._kind_lake)
then
3649 t_lake(c,1) = t_lake(c,1) - heatrem/(cpliq*denh2o*dz_lake(c,1))
3652 lake_icefrac(c,1) = -heatrem/(denh2o*dz_lake(c,1)*hfus)
3663 do fc = 1, num_shlakesnowc
3664 c = filter_shlakesnowc(fc)
3665 if (snl(c) == 0)
then
3666 snowage(c) = 0._kind_lake
3672 do j = -nlevsnow+1,0
3675 do fc = 1, num_shlakesnowc
3676 c = filter_shlakesnowc(fc)
3677 if (j <= snl(c) .and. snl(c) > -nlevsnow)
then
3678 h2osoi_ice(c,j) = 0._kind_lake
3679 h2osoi_liq(c,j) = 0._kind_lake
3680 t_soisno(c,j) = 0._kind_lake
3681 dz(c,j) = 0._kind_lake
3682 z(c,j) = 0._kind_lake
3683 zi(c,j-1) = 0._kind_lake
3690 call buildsnowfilter(lbc, ubc, num_shlakec, filter_shlakec, snl,&
3691 num_shlakesnowc, filter_shlakesnowc, num_shlakenosnowc, filter_shlakenosnowc)
3698 do fc = 1, num_shlakesnowc
3699 c = filter_shlakesnowc(fc)
3700 t_snow(c) = 0._kind_lake
3701 snowice(c) = 0._kind_lake
3702 snowliq(c) = 0._kind_lake
3706 do fc = 1, num_shlakenosnowc
3707 c = filter_shlakenosnowc(fc)
3713 do j = -nlevsnow+1, 0
3716 do fc = 1, num_shlakesnowc
3717 c = filter_shlakesnowc(fc)
3718 if (j >= snl(c)+1)
then
3719 t_snow(c) = t_snow(c) + t_soisno(c,j)
3720 snowice(c) = snowice(c) + h2osoi_ice(c,j)
3721 snowliq(c) = snowliq(c) + h2osoi_liq(c,j)
3730 do fc = 1, num_shlakec
3732 c = filter_shlakec(fc)
3733 if (snl(c) < 0) t_snow(c) = t_snow(c)/abs(snl(c))
3734 endwb(c) = h2osno(c)
3740 do fc = 1, num_shlakec
3741 c = filter_shlakec(fc)
3742 endwb(c) = endwb(c) + h2osoi_ice(c,j) + h2osoi_liq(c,j)
3743 h2osoi_vol(c,j) = h2osoi_liq(c,j)/(dz(c,j)*denh2o) + h2osoi_ice(c,j)/(dz(c,j)*denice)
3747 check_add_snow_water:
if(lakedebug)
then
3748 allocate(snow_water(lbc:ubc))
3750 do j = -nlevsnow+1,0
3753 do fc = 1, num_shlakec
3754 c = filter_shlakec(fc)
3757 if(j == jtop) snow_water(c) = 0._kind_lake
3759 snow_water(c) = snow_water(c) + h2osoi_ice(c,j) + h2osoi_liq(c,j)
3760 if(j == 0 .and. abs(snow_water(c)-h2osno(c))>1.e-7_kind_lake)
then
3761 write(message,*)
'h2osno does not equal sum of snow layers in ShalLakeHydrology:', &
3762 'column, h2osno, sum of snow layers =', c, h2osno(c), snow_water(c)
3765 write(0,
'(A)') trim(message)
3770 deallocate(snow_water)
3771 end if check_add_snow_water
3777 do fp = 1,num_shlakep
3778 p = filter_shlakep(fp)
3782 qflx_infl(c) = 0._kind_lake
3783 qflx_surf(c) = 0._kind_lake
3784 qflx_drain(c) = 0._kind_lake
3785 rootr_column(c,:) = spval
3786 soilalpha(c) = spval
3793 qflx_qrgwl(c) = forc_rain(g) + forc_snow(g) - qflx_evap_tot(p) - (endwb(c)-begwb(c))/dtime
3794 if (debug_print)
then
3795 print *,
'c, rain, snow, evap, endwb, begwb, qflx_qrgwl:', &
3796 c, forc_rain(g), forc_snow(g), qflx_evap_tot(p), endwb(c), begwb(c), qflx_qrgwl(c)
3800 qflx_evap_tot_col(c) = qflx_evap_tot(p)
3803 end subroutine shallakehydrology
3808 subroutine qsat (T, p, es, esdT, qs, qsdT)
3818 real(kind_lake),
intent(in) :: t
3819 real(kind_lake),
intent(in) :: p
3820 real(kind_lake),
intent(out) :: es
3821 real(kind_lake),
intent(out) :: esdt
3822 real(kind_lake),
intent(out) :: qs
3823 real(kind_lake),
intent(out) :: qsdt
3838 real(kind_lake) :: t_limit
3839 real(kind_lake) :: td,vp,vp1,vp2
3843 real(kind_lake),
parameter :: a0 = 6.11213476
3844 real(kind_lake),
parameter :: a1 = 0.444007856
3845 real(kind_lake),
parameter :: a2 = 0.143064234e-01
3846 real(kind_lake),
parameter :: a3 = 0.264461437e-03
3847 real(kind_lake),
parameter :: a4 = 0.305903558e-05
3848 real(kind_lake),
parameter :: a5 = 0.196237241e-07
3849 real(kind_lake),
parameter :: a6 = 0.892344772e-10
3850 real(kind_lake),
parameter :: a7 = -0.373208410e-12
3851 real(kind_lake),
parameter :: a8 = 0.209339997e-15
3855 real(kind_lake),
parameter :: b0 = 0.444017302
3856 real(kind_lake),
parameter :: b1 = 0.286064092e-01
3857 real(kind_lake),
parameter :: b2 = 0.794683137e-03
3858 real(kind_lake),
parameter :: b3 = 0.121211669e-04
3859 real(kind_lake),
parameter :: b4 = 0.103354611e-06
3860 real(kind_lake),
parameter :: b5 = 0.404125005e-09
3861 real(kind_lake),
parameter :: b6 = -0.788037859e-12
3862 real(kind_lake),
parameter :: b7 = -0.114596802e-13
3863 real(kind_lake),
parameter :: b8 = 0.381294516e-16
3867 real(kind_lake),
parameter :: c0 = 6.11123516
3868 real(kind_lake),
parameter :: c1 = 0.503109514
3869 real(kind_lake),
parameter :: c2 = 0.188369801e-01
3870 real(kind_lake),
parameter :: c3 = 0.420547422e-03
3871 real(kind_lake),
parameter :: c4 = 0.614396778e-05
3872 real(kind_lake),
parameter :: c5 = 0.602780717e-07
3873 real(kind_lake),
parameter :: c6 = 0.387940929e-09
3874 real(kind_lake),
parameter :: c7 = 0.149436277e-11
3875 real(kind_lake),
parameter :: c8 = 0.262655803e-14
3879 real(kind_lake),
parameter :: d0 = 0.503277922
3880 real(kind_lake),
parameter :: d1 = 0.377289173e-01
3881 real(kind_lake),
parameter :: d2 = 0.126801703e-02
3882 real(kind_lake),
parameter :: d3 = 0.249468427e-04
3883 real(kind_lake),
parameter :: d4 = 0.313703411e-06
3884 real(kind_lake),
parameter :: d5 = 0.257180651e-08
3885 real(kind_lake),
parameter :: d6 = 0.133268878e-10
3886 real(kind_lake),
parameter :: d7 = 0.394116744e-13
3887 real(kind_lake),
parameter :: d8 = 0.498070196e-16
3891 if (t_limit > 100.0) t_limit=100.0
3892 if (t_limit < -75.0) t_limit=-75.0
3896 es = a0 + td*(a1 + td*(a2 + td*(a3 + td*(a4 &
3897 + td*(a5 + td*(a6 + td*(a7 + td*a8)))))))
3898 esdt = b0 + td*(b1 + td*(b2 + td*(b3 + td*(b4 &
3899 + td*(b5 + td*(b6 + td*(b7 + td*b8)))))))
3901 es = c0 + td*(c1 + td*(c2 + td*(c3 + td*(c4 &
3902 + td*(c5 + td*(c6 + td*(c7 + td*c8)))))))
3903 esdt = d0 + td*(d1 + td*(d2 + td*(d3 + td*(d4 &
3904 + td*(d5 + td*(d6 + td*(d7 + td*d8)))))))
3910 vp = 1.0 / (p - one_minus_con_eps*es)
3915 qsdt = esdt * vp2 * p
3920 subroutine tridiagonal (lbc, ubc, lbj, ubj, jtop, numf, filter, &
3928 integer ,
intent(in) :: lbc, ubc
3929 integer ,
intent(in) :: lbj, ubj
3930 integer ,
intent(in) :: jtop(lbc:ubc)
3931 integer ,
intent(in) :: numf
3932 integer ,
intent(in) :: filter(1:numf)
3933 real(kind_lake),
intent(in) :: a(lbc:ubc, lbj:ubj)
3934 real(kind_lake),
intent(in) :: b(lbc:ubc, lbj:ubj)
3935 real(kind_lake),
intent(in) :: c(lbc:ubc, lbj:ubj)
3936 real(kind_lake),
intent(in) :: r(lbc:ubc, lbj:ubj)
3937 real(kind_lake),
intent(inout) :: u(lbc:ubc, lbj:ubj)
3954 real(kind_lake) :: gam(lbc:ubc,lbj:ubj)
3955 real(kind_lake) :: bet(lbc:ubc)
3964 bet(ci) = b(ci,jtop(ci))
3973 if (j >= jtop(ci))
then
3974 if (j == jtop(ci))
then
3975 u(ci,j) = r(ci,j) / bet(ci)
3977 gam(ci,j) = c(ci,j-1) / bet(ci)
3978 bet(ci) = b(ci,j) - a(ci,j) * gam(ci,j)
3979 u(ci,j) = (r(ci,j) - a(ci,j)*u(ci,j-1)) / bet(ci)
3993 if (j >= jtop(ci))
then
3994 u(ci,j) = u(ci,j) - gam(ci,j+1) * u(ci,j+1)
3999 end subroutine tridiagonal
4013 subroutine snowwater(lbc, ubc, num_snowc, filter_snowc, & !i
4014 num_nosnowc, filter_nosnowc, & !i
4015 snl,do_capsnow,qflx_snomelt,qflx_rain_grnd, & !i
4016 qflx_sub_snow,qflx_evap_grnd, & !i
4017 qflx_dew_snow,qflx_dew_grnd,dz,dtime, & !i
4018 h2osoi_ice,h2osoi_liq, & !i&o
4033 integer,
intent(in) :: lbc, ubc
4034 integer,
intent(in) :: num_snowc
4035 integer,
intent(in) :: filter_snowc(ubc-lbc+1)
4036 integer,
intent(in) :: num_nosnowc
4037 integer,
intent(in) :: filter_nosnowc(ubc-lbc+1)
4039 integer ,
intent(in) :: snl(1)
4040 logical ,
intent(in) :: do_capsnow(1)
4041 real(kind_lake),
intent(in) :: dtime
4042 real(kind_lake),
intent(in) :: qflx_snomelt(1)
4043 real(kind_lake),
intent(in) :: qflx_rain_grnd(1)
4044 real(kind_lake),
intent(in) :: qflx_sub_snow(1)
4045 real(kind_lake),
intent(in) :: qflx_evap_grnd(1)
4046 real(kind_lake),
intent(in) :: qflx_dew_snow(1)
4047 real(kind_lake),
intent(in) :: qflx_dew_grnd(1)
4048 real(kind_lake),
intent(in) :: dz(1,-nlevsnow+1:nlevsoil)
4053 real(kind_lake),
intent(inout) :: h2osoi_ice(1,-nlevsnow+1:nlevsoil)
4054 real(kind_lake),
intent(inout) :: h2osoi_liq(1,-nlevsnow+1:nlevsoil)
4058 real(kind_lake),
intent(out) :: qflx_top_soil(1)
4064 real(kind_lake) :: qin(lbc:ubc)
4065 real(kind_lake) :: qout(lbc:ubc)
4066 real(kind_lake) :: wgdif
4067 real(kind_lake) :: vol_liq(lbc:ubc,-nlevsnow+1:0)
4068 real(kind_lake) :: vol_ice(lbc:ubc,-nlevsnow+1:0)
4069 real(kind_lake) :: eff_porosity(lbc:ubc,-nlevsnow+1:0)
4077 c = filter_snowc(fc)
4078 if (do_capsnow(c))
then
4079 wgdif = h2osoi_ice(c,snl(c)+1) - qflx_sub_snow(c)*dtime
4080 h2osoi_ice(c,snl(c)+1) = wgdif
4081 if (wgdif < 0.)
then
4082 h2osoi_ice(c,snl(c)+1) = 0.
4083 h2osoi_liq(c,snl(c)+1) = h2osoi_liq(c,snl(c)+1) + wgdif
4085 h2osoi_liq(c,snl(c)+1) = h2osoi_liq(c,snl(c)+1) - qflx_evap_grnd(c) * dtime
4087 wgdif = h2osoi_ice(c,snl(c)+1) + (qflx_dew_snow(c) - qflx_sub_snow(c)) * dtime
4088 h2osoi_ice(c,snl(c)+1) = wgdif
4089 if (wgdif < 0.)
then
4090 h2osoi_ice(c,snl(c)+1) = 0.
4091 h2osoi_liq(c,snl(c)+1) = h2osoi_liq(c,snl(c)+1) + wgdif
4093 h2osoi_liq(c,snl(c)+1) = h2osoi_liq(c,snl(c)+1) + &
4094 (qflx_rain_grnd(c) + qflx_dew_grnd(c) - qflx_evap_grnd(c)) * dtime
4096 h2osoi_liq(c,snl(c)+1) = max(0._kind_lake, h2osoi_liq(c,snl(c)+1))
4101 do j = -nlevsnow+1, 0
4104 do fc = 1, num_snowc
4105 c = filter_snowc(fc)
4106 if (j >= snl(c)+1)
then
4107 vol_ice(c,j) = min(1._kind_lake, h2osoi_ice(c,j)/(dz(c,j)*denice))
4108 eff_porosity(c,j) = 1. - vol_ice(c,j)
4109 vol_liq(c,j) = min(eff_porosity(c,j),h2osoi_liq(c,j)/(dz(c,j)*denh2o))
4122 qin(:) = 0._kind_lake
4124 do j = -nlevsnow+1, 0
4127 do fc = 1, num_snowc
4128 c = filter_snowc(fc)
4129 if (j >= snl(c)+1)
then
4130 h2osoi_liq(c,j) = h2osoi_liq(c,j) + qin(c)
4133 if (eff_porosity(c,j) < wimp .OR. eff_porosity(c,j+1) < wimp)
then
4134 qout(c) = 0._kind_lake
4136 qout(c) = max(0._kind_lake,(vol_liq(c,j)-ssi*eff_porosity(c,j))*dz(c,j))
4137 qout(c) = min(qout(c),(1.-vol_ice(c,j+1)-vol_liq(c,j+1))*dz(c,j+1))
4140 qout(c) = max(0._kind_lake,(vol_liq(c,j) - ssi*eff_porosity(c,j))*dz(c,j))
4142 qout(c) = qout(c)*1000.
4143 h2osoi_liq(c,j) = h2osoi_liq(c,j) - qout(c)
4151 do fc = 1, num_snowc
4152 c = filter_snowc(fc)
4154 qflx_top_soil(c) = qout(c) / dtime
4159 do fc = 1, num_nosnowc
4160 c = filter_nosnowc(fc)
4161 qflx_top_soil(c) = qflx_rain_grnd(c) + qflx_snomelt(c)
4164 end subroutine snowwater
4173 subroutine snowcompaction(lbc, ubc, num_snowc, filter_snowc, &!i
4174 snl,imelt,frac_iceold,t_soisno, &!i
4175 h2osoi_ice,h2osoi_liq,dtime, &!i
4195 integer,
intent(in) :: lbc, ubc
4196 integer,
intent(in) :: num_snowc
4197 integer,
intent(in) :: filter_snowc(ubc-lbc+1)
4198 integer,
intent(in) :: snl(1)
4199 integer,
intent(in) :: imelt(1,-nlevsnow+1:nlevsoil)
4200 real(kind_lake),
intent(in) :: dtime
4201 real(kind_lake),
intent(in) :: frac_iceold(1,-nlevsnow+1:nlevsoil)
4202 real(kind_lake),
intent(in) :: t_soisno(1,-nlevsnow+1:nlevsoil)
4203 real(kind_lake),
intent(in) :: h2osoi_ice(1,-nlevsnow+1:nlevsoil)
4204 real(kind_lake),
intent(in) :: h2osoi_liq(1,-nlevsnow+1:nlevsoil)
4208 real(kind_lake),
intent(inout) :: dz(1,-nlevsnow+1:nlevsoil)
4213 real(kind_lake),
parameter :: c2 = 23.e-3
4214 real(kind_lake),
parameter :: c3 = 2.777e-6
4215 real(kind_lake),
parameter :: c4 = 0.04
4216 real(kind_lake),
parameter :: c5 = 2.0
4217 real(kind_lake),
parameter :: dm = 100.0
4218 real(kind_lake),
parameter :: eta0 = 9.e+5
4219 real(kind_lake) :: burden(lbc:ubc)
4220 real(kind_lake) :: ddz1
4221 real(kind_lake) :: ddz2
4222 real(kind_lake) :: ddz3
4223 real(kind_lake) :: dexpf
4224 real(kind_lake) :: fi
4225 real(kind_lake) :: td
4226 real(kind_lake) :: pdzdtc
4227 real(kind_lake) :: void
4228 real(kind_lake) :: wx
4229 real(kind_lake) :: bi
4236 burden(:) = 0._kind_lake
4238 do j = -nlevsnow+1, 0
4241 do fc = 1, num_snowc
4242 c = filter_snowc(fc)
4243 if (j >= snl(c)+1)
then
4245 wx = h2osoi_ice(c,j) + h2osoi_liq(c,j)
4246 void = 1. - (h2osoi_ice(c,j)/denice + h2osoi_liq(c,j)/denh2o) / dz(c,j)
4249 if (void > 0.001 .and. h2osoi_ice(c,j) > .1)
then
4250 bi = h2osoi_ice(c,j) / dz(c,j)
4251 fi = h2osoi_ice(c,j) / wx
4252 td = tfrz-t_soisno(c,j)
4258 if (bi > dm) ddz1 = ddz1*exp(-46.0e-3*(bi-dm))
4262 if (h2osoi_liq(c,j) > 0.01*dz(c,j)) ddz1=ddz1*c5
4266 ddz2 = -burden(c)*exp(-0.08*td - c2*bi)/eta0
4270 if (imelt(c,j) == 1)
then
4271 ddz3 = - 1./dtime * max(0._kind_lake,(frac_iceold(c,j) - fi)/frac_iceold(c,j))
4278 pdzdtc = ddz1 + ddz2 + ddz3
4282 dz(c,j) = dz(c,j) * (1.+pdzdtc*dtime)
4287 burden(c) = burden(c) + wx
4293 end subroutine snowcompaction
4298 subroutine combinesnowlayers(lbc, ubc, & !i
4299 num_snowc, filter_snowc, & !i&o
4300 snl,h2osno,snowdp,dz,zi, & !i&o
4301 t_soisno,h2osoi_ice,h2osoi_liq, & !i&o
4323 integer,
intent(in) :: lbc, ubc
4328 integer,
intent(inout) :: num_snowc
4329 integer,
intent(inout) :: filter_snowc(ubc-lbc+1)
4330 integer ,
intent(inout) :: snl(1)
4331 real(kind_lake),
intent(inout) :: h2osno(1)
4332 real(kind_lake),
intent(inout) :: snowdp(1)
4333 real(kind_lake),
intent(inout) :: dz(1,-nlevsnow+1:nlevsoil)
4334 real(kind_lake),
intent(inout) :: zi(1,-nlevsnow+0:nlevsoil)
4335 real(kind_lake),
intent(inout) :: t_soisno(1,-nlevsnow+1:nlevsoil)
4336 real(kind_lake),
intent(inout) :: h2osoi_ice(1,-nlevsnow+1:nlevsoil)
4337 real(kind_lake),
intent(inout) :: h2osoi_liq(1,-nlevsnow+1:nlevsoil)
4341 real(kind_lake),
intent(out) :: z(1,-nlevsnow+1:nlevsoil)
4350 integer :: msn_old(lbc:ubc)
4351 integer :: mssi(lbc:ubc)
4353 real(kind_lake):: zwice(lbc:ubc)
4354 real(kind_lake):: zwliq (lbc:ubc)
4355 real(kind_lake),
parameter :: dzmin(5) = &
4356 (/0.010, 0.015, 0.025, 0.055, 0.115/)
4364 do fc = 1, num_snowc
4365 c = filter_snowc(fc)
4371 do fc = 1, num_snowc
4372 c = filter_snowc(fc)
4374 do j = msn_old(c)+1,0
4375 if (h2osoi_ice(c,j) <= .1)
then
4380 h2osoi_liq(c,j+1) = h2osoi_liq(c,j+1) + h2osoi_liq(c,j)
4381 h2osoi_ice(c,j+1) = h2osoi_ice(c,j+1) + h2osoi_ice(c,j)
4385 if (j > snl(c)+1 .and. snl(c) < -1)
then
4386 do i = j, snl(c)+2, -1
4387 t_soisno(c,i) = t_soisno(c,i-1)
4388 h2osoi_liq(c,i) = h2osoi_liq(c,i-1)
4389 h2osoi_ice(c,i) = h2osoi_ice(c,i-1)
4400 do fc = 1, num_snowc
4401 c = filter_snowc(fc)
4402 h2osno(c) = 0._kind_lake
4403 snowdp(c) = 0._kind_lake
4404 zwice(c) = 0._kind_lake
4405 zwliq(c) = 0._kind_lake
4408 do j = -nlevsnow+1,0
4411 do fc = 1, num_snowc
4412 c = filter_snowc(fc)
4413 if (j >= snl(c)+1)
then
4414 h2osno(c) = h2osno(c) + h2osoi_ice(c,j) + h2osoi_liq(c,j)
4415 snowdp(c) = snowdp(c) + dz(c,j)
4416 zwice(c) = zwice(c) + h2osoi_ice(c,j)
4417 zwliq(c) = zwliq(c) + h2osoi_liq(c,j)
4427 do fc = 1, num_snowc
4428 c = filter_snowc(fc)
4430 if (snowdp(c) < 0.01 .and. snowdp(c) > 0.)
then
4432 h2osno(c) = zwice(c)
4433 if (h2osno(c) <= 0.) snowdp(c) = 0._kind_lake
4441 do fc = 1, num_snowc
4442 c = filter_snowc(fc)
4446 if (snl(c) < -1)
then
4451 do i = msn_old(c)+1,0
4452 if (dz(c,i) < dzmin(mssi(c)))
then
4454 if (i == snl(c)+1)
then
4457 else if (i == 0)
then
4463 if ((dz(c,i-1)+dz(c,i)) < (dz(c,i+1)+dz(c,i))) neibor = i-1
4467 if (neibor > i)
then
4475 call combo (dz(c,j), h2osoi_liq(c,j), h2osoi_ice(c,j), &
4476 t_soisno(c,j), dz(c,l), h2osoi_liq(c,l), h2osoi_ice(c,l), t_soisno(c,l) )
4479 if (j-1 > snl(c)+1)
then
4480 do k = j-1, snl(c)+2, -1
4481 t_soisno(c,k) = t_soisno(c,k-1)
4482 h2osoi_ice(c,k) = h2osoi_ice(c,k-1)
4483 h2osoi_liq(c,k) = h2osoi_liq(c,k-1)
4490 if (snl(c) >= -1)
EXIT
4495 mssi(c) = mssi(c) + 1
4506 do j = 0, -nlevsnow+1, -1
4509 do fc = 1, num_snowc
4510 c = filter_snowc(fc)
4511 if (j >= snl(c) + 1)
then
4512 z(c,j) = zi(c,j) - 0.5*dz(c,j)
4513 zi(c,j-1) = zi(c,j) - dz(c,j)
4518 end subroutine combinesnowlayers
4522 subroutine dividesnowlayers(lbc, ubc, & !i
4523 num_snowc, filter_snowc, & !i&o
4524 snl,dz,zi,t_soisno, & !i&o
4525 h2osoi_ice,h2osoi_liq, & !i&o
4545 integer,
intent(in) :: lbc, ubc
4549 integer,
intent(inout) :: num_snowc
4550 integer,
intent(inout) :: filter_snowc(ubc-lbc+1)
4551 integer ,
intent(inout) :: snl(1)
4552 real(kind_lake),
intent(inout) :: dz(1,-nlevsnow+1:nlevsoil)
4553 real(kind_lake),
intent(inout) :: zi(1,-nlevsnow+0:nlevsoil)
4554 real(kind_lake),
intent(inout) :: t_soisno(1,-nlevsnow+1:nlevsoil)
4555 real(kind_lake),
intent(inout) :: h2osoi_ice(1,-nlevsnow+1:nlevsoil)
4556 real(kind_lake),
intent(inout) :: h2osoi_liq(1,-nlevsnow+1:nlevsoil)
4560 real(kind_lake),
intent(out) :: z(1,-nlevsnow+1:nlevsoil)
4567 real(kind_lake) :: drr
4569 real(kind_lake) :: dzsno(lbc:ubc,nlevsnow)
4570 real(kind_lake) :: swice(lbc:ubc,nlevsnow)
4571 real(kind_lake) :: swliq(lbc:ubc,nlevsnow)
4572 real(kind_lake) :: tsno(lbc:ubc ,nlevsnow)
4573 real(kind_lake) :: zwice
4574 real(kind_lake) :: zwliq
4575 real(kind_lake) :: propor
4584 do fc = 1, num_snowc
4585 c = filter_snowc(fc)
4586 if (j <= abs(snl(c)))
then
4587 dzsno(c,j) = dz(c,j+snl(c))
4588 swice(c,j) = h2osoi_ice(c,j+snl(c))
4589 swliq(c,j) = h2osoi_liq(c,j+snl(c))
4590 tsno(c,j) = t_soisno(c,j+snl(c))
4597 do fc = 1, num_snowc
4598 c = filter_snowc(fc)
4604 if (dzsno(c,1) > 0.03)
then
4606 dzsno(c,1) = dzsno(c,1)*0.5
4607 swice(c,1) = swice(c,1)*0.5
4608 swliq(c,1) = swliq(c,1)*0.5
4609 dzsno(c,2) = dzsno(c,1)
4610 swice(c,2) = swice(c,1)
4611 swliq(c,2) = swliq(c,1)
4612 tsno(c,2) = tsno(c,1)
4617 if (dzsno(c,1) > 0.02)
then
4618 drr = dzsno(c,1) - 0.02
4619 propor = drr/dzsno(c,1)
4620 zwice = propor*swice(c,1)
4621 zwliq = propor*swliq(c,1)
4622 propor = 0.02/dzsno(c,1)
4623 swice(c,1) = propor*swice(c,1)
4624 swliq(c,1) = propor*swliq(c,1)
4627 call combo (dzsno(c,2), swliq(c,2), swice(c,2), tsno(c,2), drr, &
4628 zwliq, zwice, tsno(c,1))
4631 if (msno <= 2 .and. dzsno(c,2) > 0.07)
then
4633 dzsno(c,2) = dzsno(c,2)*0.5
4634 swice(c,2) = swice(c,2)*0.5
4635 swliq(c,2) = swliq(c,2)*0.5
4636 dzsno(c,3) = dzsno(c,2)
4637 swice(c,3) = swice(c,2)
4638 swliq(c,3) = swliq(c,2)
4639 tsno(c,3) = tsno(c,2)
4645 if (dzsno(c,2) > 0.05)
then
4646 drr = dzsno(c,2) - 0.05
4647 propor = drr/dzsno(c,2)
4648 zwice = propor*swice(c,2)
4649 zwliq = propor*swliq(c,2)
4650 propor = 0.05/dzsno(c,2)
4651 swice(c,2) = propor*swice(c,2)
4652 swliq(c,2) = propor*swliq(c,2)
4655 call combo (dzsno(c,3), swliq(c,3), swice(c,3), tsno(c,3), drr, &
4656 zwliq, zwice, tsno(c,2))
4659 if (msno <= 3 .and. dzsno(c,3) > 0.18)
then
4661 dzsno(c,3) = dzsno(c,3)*0.5
4662 swice(c,3) = swice(c,3)*0.5
4663 swliq(c,3) = swliq(c,3)*0.5
4664 dzsno(c,4) = dzsno(c,3)
4665 swice(c,4) = swice(c,3)
4666 swliq(c,4) = swliq(c,3)
4667 tsno(c,4) = tsno(c,3)
4673 if (dzsno(c,3) > 0.11)
then
4674 drr = dzsno(c,3) - 0.11
4675 propor = drr/dzsno(c,3)
4676 zwice = propor*swice(c,3)
4677 zwliq = propor*swliq(c,3)
4678 propor = 0.11/dzsno(c,3)
4679 swice(c,3) = propor*swice(c,3)
4680 swliq(c,3) = propor*swliq(c,3)
4683 call combo (dzsno(c,4), swliq(c,4), swice(c,4), tsno(c,4), drr, &
4684 zwliq, zwice, tsno(c,3))
4687 if (msno <= 4 .and. dzsno(c,4) > 0.41)
then
4689 dzsno(c,4) = dzsno(c,4)*0.5
4690 swice(c,4) = swice(c,4)*0.5
4691 swliq(c,4) = swliq(c,4)*0.5
4692 dzsno(c,5) = dzsno(c,4)
4693 swice(c,5) = swice(c,4)
4694 swliq(c,5) = swliq(c,4)
4695 tsno(c,5) = tsno(c,4)
4701 if (dzsno(c,4) > 0.23)
then
4702 drr = dzsno(c,4) - 0.23
4703 propor = drr/dzsno(c,4)
4704 zwice = propor*swice(c,4)
4705 zwliq = propor*swliq(c,4)
4706 propor = 0.23/dzsno(c,4)
4707 swice(c,4) = propor*swice(c,4)
4708 swliq(c,4) = propor*swliq(c,4)
4711 call combo (dzsno(c,5), swliq(c,5), swice(c,5), tsno(c,5), drr, &
4712 zwliq, zwice, tsno(c,4))
4720 do j = -nlevsnow+1,0
4723 do fc = 1, num_snowc
4724 c = filter_snowc(fc)
4725 if (j >= snl(c)+1)
then
4726 dz(c,j) = dzsno(c,j-snl(c))
4727 h2osoi_ice(c,j) = swice(c,j-snl(c))
4728 h2osoi_liq(c,j) = swliq(c,j-snl(c))
4729 t_soisno(c,j) = tsno(c,j-snl(c))
4734 do j = 0, -nlevsnow+1, -1
4737 do fc = 1, num_snowc
4738 c = filter_snowc(fc)
4739 if (j >= snl(c)+1)
then
4740 z(c,j) = zi(c,j) - 0.5*dz(c,j)
4741 zi(c,j-1) = zi(c,j) - dz(c,j)
4746 end subroutine dividesnowlayers
4750 subroutine combo(dz, wliq, wice, t, dz2, wliq2, wice2, t2)
4763 real(kind_lake),
intent(in) :: dz2
4764 real(kind_lake),
intent(in) :: wliq2
4765 real(kind_lake),
intent(in) :: wice2
4766 real(kind_lake),
intent(in) :: t2
4767 real(kind_lake),
intent(inout) :: dz
4768 real(kind_lake),
intent(inout) :: wliq
4769 real(kind_lake),
intent(inout) :: wice
4770 real(kind_lake),
intent(inout) :: t
4785 real(kind_lake) :: dzc
4786 real(kind_lake) :: wliqc
4787 real(kind_lake) :: wicec
4788 real(kind_lake) :: tc
4789 real(kind_lake) :: h
4790 real(kind_lake) :: h2
4791 real(kind_lake) :: hc
4795 wicec = (wice+wice2)
4796 wliqc = (wliq+wliq2)
4797 h = (cpice*wice+cpliq*wliq) * (t-tfrz)+hfus*wliq
4798 h2= (cpice*wice2+cpliq*wliq2) * (t2-tfrz)+hfus*wliq2
4802 tc = tfrz + hc/(cpice*wicec + cpliq*wliqc)
4803 else if (hc.le.hfus*wliqc)
then
4806 tc = tfrz + (hc - hfus*wliqc) / (cpice*wicec + cpliq*wliqc)
4814 end subroutine combo
4817 subroutine buildsnowfilter(lbc, ubc, num_nolakec, filter_nolakec,snl, & !i
4818 num_snowc, filter_snowc, & !o
4819 num_nosnowc, filter_nosnowc)
4829 integer,
intent(in) :: lbc, ubc
4830 integer,
intent(in) :: num_nolakec
4831 integer,
intent(in) :: filter_nolakec(ubc-lbc+1)
4832 integer,
intent(in) :: snl(1)
4833 integer,
intent(out) :: num_snowc
4834 integer,
intent(out) :: filter_snowc(ubc-lbc+1)
4835 integer,
intent(out) :: num_nosnowc
4836 integer,
intent(out) :: filter_nosnowc(ubc-lbc+1)
4860 do fc = 1, num_nolakec
4861 c = filter_nolakec(fc)
4862 if (snl(c) < 0)
then
4863 num_snowc = num_snowc + 1
4864 filter_snowc(num_snowc) = c
4866 num_nosnowc = num_nosnowc + 1
4867 filter_nosnowc(num_nosnowc) = c
4871 end subroutine buildsnowfilter
4881subroutine frictionvelocity(pgridcell,forc_hgt,forc_hgt_u, & !i
4882 forc_hgt_t,forc_hgt_q, & !i
4883 lbp, ubp, fn, filterp, & !i
4884 displa, z0m, z0h, z0q, & !i
4885 obu, iter, ur, um, & !i
4886 ustar,temp1, temp2, temp12m, temp22m, & !o
4908 integer ,
intent(in) :: pgridcell(1)
4909 real(kind_lake),
intent(in) :: forc_hgt(1)
4910 real(kind_lake),
intent(in) :: forc_hgt_u(1)
4911 real(kind_lake),
intent(in) :: forc_hgt_t(1)
4912 real(kind_lake),
intent(in) :: forc_hgt_q(1)
4913 integer ,
intent(in) :: lbp, ubp
4914 integer ,
intent(in) :: fn
4915 integer ,
intent(in) :: filterp(fn)
4916 real(kind_lake),
intent(in) :: displa(lbp:ubp)
4917 real(kind_lake),
intent(in) :: z0m(lbp:ubp)
4918 real(kind_lake),
intent(in) :: z0h(lbp:ubp)
4919 real(kind_lake),
intent(in) :: z0q(lbp:ubp)
4920 real(kind_lake),
intent(in) :: obu(lbp:ubp)
4921 integer,
intent(in) :: iter
4922 real(kind_lake),
intent(in) :: ur(lbp:ubp)
4923 real(kind_lake),
intent(in) :: um(lbp:ubp)
4927 real(kind_lake),
intent(out) :: ustar(lbp:ubp)
4928 real(kind_lake),
intent(out) :: temp1(lbp:ubp)
4929 real(kind_lake),
intent(out) :: temp12m(lbp:ubp)
4930 real(kind_lake),
intent(out) :: temp2(lbp:ubp)
4931 real(kind_lake),
intent(out) :: temp22m(lbp:ubp)
4932 real(kind_lake),
intent(out) :: u10(1)
4933 real(kind_lake),
intent(out) :: fv(1)
4936 real(kind_lake),
intent(inout) :: fm(lbp:ubp)
4940 real(kind_lake),
parameter :: zetam = 1.574_kind_lake
4941 real(kind_lake),
parameter :: zetat = 0.465_kind_lake
4945 real(kind_lake):: zldis(lbp:ubp)
4946 real(kind_lake):: zeta(lbp:ubp)
4953 if_not_pergro:
if(.not.pergro)
then
4963 zldis(p) = forc_hgt_u(g)-displa(p)
4964 zeta(p) = zldis(p)/obu(p)
4965 if (zeta(p) < -zetam)
then
4966 ustar(p) = vkc*um(p)/(log(-zetam*obu(p)/z0m(p))&
4967 - stabilityfunc1(-zetam) &
4968 + stabilityfunc1(z0m(p)/obu(p)) &
4969 + 1.14_kind_lake*((-zeta(p))**0.333_kind_lake-(zetam)**0.333_kind_lake))
4970 else if (zeta(p) < 0._kind_lake)
then
4971 ustar(p) = vkc*um(p)/(log(zldis(p)/z0m(p))&
4972 - stabilityfunc1(zeta(p))&
4973 + stabilityfunc1(z0m(p)/obu(p)))
4974 else if (zeta(p) <= 1._kind_lake)
then
4975 ustar(p) = vkc*um(p)/(log(zldis(p)/z0m(p)) + 5._kind_lake*zeta(p) -5._kind_lake*z0m(p)/obu(p))
4977 ustar(p) = vkc*um(p)/(log(obu(p)/z0m(p))+5._kind_lake-5._kind_lake*z0m(p)/obu(p) &
4978 +(5._kind_lake*log(zeta(p))+zeta(p)-1._kind_lake))
4983 zldis(p) = forc_hgt_t(g)-displa(p)
4984 zeta(p) = zldis(p)/obu(p)
4985 if (zeta(p) < -zetat)
then
4986 temp1(p) = vkc/(log(-zetat*obu(p)/z0h(p))&
4987 - stabilityfunc2(-zetat) &
4988 + stabilityfunc2(z0h(p)/obu(p)) &
4989 + 0.8_kind_lake*((zetat)**(-0.333_kind_lake)-(-zeta(p))**(-0.333_kind_lake)))
4990 else if (zeta(p) < 0._kind_lake)
then
4991 temp1(p) = vkc/(log(zldis(p)/z0h(p)) &
4992 - stabilityfunc2(zeta(p)) &
4993 + stabilityfunc2(z0h(p)/obu(p)))
4994 else if (zeta(p) <= 1._kind_lake)
then
4995 temp1(p) = vkc/(log(zldis(p)/z0h(p)) + 5._kind_lake*zeta(p) - 5._kind_lake*z0h(p)/obu(p))
4997 temp1(p) = vkc/(log(obu(p)/z0h(p)) + 5._kind_lake - 5._kind_lake*z0h(p)/obu(p) &
4998 + (5._kind_lake*log(zeta(p))+zeta(p)-1._kind_lake))
5003 if (forc_hgt_q(g) == forc_hgt_t(g) .and. z0q(p) == z0h(p))
then
5006 zldis(p) = forc_hgt_q(g)-displa(p)
5007 zeta(p) = zldis(p)/obu(p)
5008 if (zeta(p) < -zetat)
then
5009 temp2(p) = vkc/(log(-zetat*obu(p)/z0q(p)) &
5010 - stabilityfunc2(-zetat) &
5011 + stabilityfunc2(z0q(p)/obu(p)) &
5012 + 0.8_kind_lake*((zetat)**(-0.333_kind_lake)-(-zeta(p))**(-0.333_kind_lake)))
5013 else if (zeta(p) < 0._kind_lake)
then
5014 temp2(p) = vkc/(log(zldis(p)/z0q(p)) &
5015 - stabilityfunc2(zeta(p)) &
5016 + stabilityfunc2(z0q(p)/obu(p)))
5017 else if (zeta(p) <= 1._kind_lake)
then
5018 temp2(p) = vkc/(log(zldis(p)/z0q(p)) + 5._kind_lake*zeta(p)-5._kind_lake*z0q(p)/obu(p))
5020 temp2(p) = vkc/(log(obu(p)/z0q(p)) + 5._kind_lake - 5._kind_lake*z0q(p)/obu(p) &
5021 + (5._kind_lake*log(zeta(p))+zeta(p)-1._kind_lake))
5027 zldis(p) = 2.0_kind_lake + z0h(p)
5028 zeta(p) = zldis(p)/obu(p)
5029 if (zeta(p) < -zetat)
then
5030 temp12m(p) = vkc/(log(-zetat*obu(p)/z0h(p))&
5031 - stabilityfunc2(-zetat) &
5032 + stabilityfunc2(z0h(p)/obu(p)) &
5033 + 0.8_kind_lake*((zetat)**(-0.333_kind_lake)-(-zeta(p))**(-0.333_kind_lake)))
5034 else if (zeta(p) < 0._kind_lake)
then
5035 temp12m(p) = vkc/(log(zldis(p)/z0h(p)) &
5036 - stabilityfunc2(zeta(p)) &
5037 + stabilityfunc2(z0h(p)/obu(p)))
5038 else if (zeta(p) <= 1._kind_lake)
then
5039 temp12m(p) = vkc/(log(zldis(p)/z0h(p)) + 5._kind_lake*zeta(p) - 5._kind_lake*z0h(p)/obu(p))
5041 temp12m(p) = vkc/(log(obu(p)/z0h(p)) + 5._kind_lake - 5._kind_lake*z0h(p)/obu(p) &
5042 + (5._kind_lake*log(zeta(p))+zeta(p)-1._kind_lake))
5047 if (z0q(p) == z0h(p))
then
5048 temp22m(p) = temp12m(p)
5050 zldis(p) = 2.0_kind_lake + z0q(p)
5051 zeta(p) = zldis(p)/obu(p)
5052 if (zeta(p) < -zetat)
then
5053 temp22m(p) = vkc/(log(-zetat*obu(p)/z0q(p)) - &
5054 stabilityfunc2(-zetat) + stabilityfunc2(z0q(p)/obu(p)) &
5055 + 0.8_kind_lake*((zetat)**(-0.333_kind_lake)-(-zeta(p))**(-0.333_kind_lake)))
5056 else if (zeta(p) < 0._kind_lake)
then
5057 temp22m(p) = vkc/(log(zldis(p)/z0q(p)) - &
5058 stabilityfunc2(zeta(p))+stabilityfunc2(z0q(p)/obu(p)))
5059 else if (zeta(p) <= 1._kind_lake)
then
5060 temp22m(p) = vkc/(log(zldis(p)/z0q(p)) + 5._kind_lake*zeta(p)-5._kind_lake*z0q(p)/obu(p))
5062 temp22m(p) = vkc/(log(obu(p)/z0q(p)) + 5._kind_lake - 5._kind_lake*z0q(p)/obu(p) &
5063 + (5._kind_lake*log(zeta(p))+zeta(p)-1._kind_lake))
5070if_pergro:
if (pergro)
then
5082 zldis(p) = forc_hgt_u(g)-displa(p)
5083 zeta(p) = zldis(p)/obu(p)
5084 if (zeta(p) < -zetam)
then
5085 ustar(p) = vkc * um(p) / log(-zetam*obu(p)/z0m(p))
5086 else if (zeta(p) < 0._kind_lake)
then
5087 ustar(p) = vkc * um(p) / log(zldis(p)/z0m(p))
5088 else if (zeta(p) <= 1._kind_lake)
then
5089 ustar(p)=vkc * um(p)/log(zldis(p)/z0m(p))
5091 ustar(p)=vkc * um(p)/log(obu(p)/z0m(p))
5094 zldis(p) = forc_hgt_t(g)-displa(p)
5095 zeta(p) = zldis(p)/obu(p)
5096 if (zeta(p) < -zetat)
then
5097 temp1(p)=vkc/log(-zetat*obu(p)/z0h(p))
5098 else if (zeta(p) < 0._kind_lake)
then
5099 temp1(p)=vkc/log(zldis(p)/z0h(p))
5100 else if (zeta(p) <= 1._kind_lake)
then
5101 temp1(p)=vkc/log(zldis(p)/z0h(p))
5103 temp1(p)=vkc/log(obu(p)/z0h(p))
5106 zldis(p) = forc_hgt_q(g)-displa(p)
5107 zeta(p) = zldis(p)/obu(p)
5108 if (zeta(p) < -zetat)
then
5109 temp2(p)=vkc/log(-zetat*obu(p)/z0q(p))
5110 else if (zeta(p) < 0._kind_lake)
then
5111 temp2(p)=vkc/log(zldis(p)/z0q(p))
5112 else if (zeta(p) <= 1._kind_lake)
then
5113 temp2(p)=vkc/log(zldis(p)/z0q(p))
5115 temp2(p)=vkc/log(obu(p)/z0q(p))
5118 zldis(p) = 2.0_kind_lake + z0h(p)
5119 zeta(p) = zldis(p)/obu(p)
5120 if (zeta(p) < -zetat)
then
5121 temp12m(p)=vkc/log(-zetat*obu(p)/z0h(p))
5122 else if (zeta(p) < 0._kind_lake)
then
5123 temp12m(p)=vkc/log(zldis(p)/z0h(p))
5124 else if (zeta(p) <= 1._kind_lake)
then
5125 temp12m(p)=vkc/log(zldis(p)/z0h(p))
5127 temp12m(p)=vkc/log(obu(p)/z0h(p))
5130 zldis(p) = 2.0_kind_lake + z0q(p)
5131 zeta(p) = zldis(p)/obu(p)
5132 if (zeta(p) < -zetat)
then
5133 temp22m(p)=vkc/log(-zetat*obu(p)/z0q(p))
5134 else if (zeta(p) < 0._kind_lake)
then
5135 temp22m(p)=vkc/log(zldis(p)/z0q(p))
5136 else if (zeta(p) <= 1._kind_lake)
then
5137 temp22m(p)=vkc/log(zldis(p)/z0q(p))
5139 temp22m(p)=vkc/log(obu(p)/z0q(p))
5145 end subroutine frictionvelocity
5150 real(kind_lake) function stabilityfunc1(zeta)
5161 real(kind_lake),
intent(in) :: zeta
5174 real(kind_lake) :: chik, chik2
5177 chik2 = sqrt(1._kind_lake-16._kind_lake*zeta)
5179 stabilityfunc1 = 2._kind_lake*log((1._kind_lake+chik)*0.5_kind_lake) &
5182 + log((1._kind_lake+chik2)*0.5_kind_lake)-2._kind_lake*atan(chik)+pi*0.5_kind_lake
5184 end function stabilityfunc1
5192 real(kind_lake) function stabilityfunc2(zeta)
5203 real(kind_lake),
intent(in) :: zeta
5216 real(kind_lake) :: chik2
5219 chik2 = sqrt(1._kind_lake-16._kind_lake*zeta)
5220 stabilityfunc2 = 2._kind_lake*log((1._kind_lake+chik2)*0.5_kind_lake)
5222 end function stabilityfunc2
5230 subroutine moninobukini (ur, thv, dthv, zldis, z0m, um, obu)
5243 real(kind_lake),
intent(in) :: ur
5244 real(kind_lake),
intent(in) :: thv
5245 real(kind_lake),
intent(in) :: dthv
5246 real(kind_lake),
intent(in) :: zldis
5247 real(kind_lake),
intent(in) :: z0m
5248 real(kind_lake),
intent(out) :: um
5249 real(kind_lake),
intent(out) :: obu
5265 real(kind_lake) :: wc
5266 real(kind_lake) :: rib
5267 real(kind_lake) :: zeta
5268 real(kind_lake) :: ustar
5273 ustar=0.06_kind_lake
5275 if (dthv >= 0._kind_lake)
then
5276 um=max(ur,0.1_kind_lake)
5278 um=sqrt(ur*ur+wc*wc)
5281 rib=grav*zldis*dthv/(thv*um*um)
5286 if (rib >= 0._kind_lake)
then
5287 zeta = rib*log(zldis/z0m)/(1._kind_lake-5._kind_lake*min(rib,0.19_kind_lake))
5288 zeta = min(2._kind_lake,max(zeta,0.01_kind_lake ))
5290 zeta=rib*log(zldis/z0m)
5291 zeta = max(-100._kind_lake,min(zeta,-0.01_kind_lake ))
5296 end subroutine moninobukini
5301 subroutine clm_lake_init(con_pi,karman,con_g,con_sbc,con_t0c,rhowater,con_csol,con_cliq, &
5302 con_hfus,con_hvap,con_rd,con_cp,rholakeice,clm_lake_debug, &
5303 clm_debug_print,con_eps_model,con_fvirt_model,errmsg,errflg)
5305 real(kind_phys),
intent(in) :: con_pi,karman,con_g,con_sbc,con_t0c, &
5306 rhowater,con_csol,con_cliq, con_hfus,con_hvap,con_rd,con_cp, &
5307 rholakeice,con_eps_model,con_fvirt_model
5308 INTEGER,
INTENT(OUT) :: errflg
5309 CHARACTER(*),
INTENT(OUT) :: errmsg
5310 logical,
intent(in) :: clm_lake_debug,clm_debug_print
5313 lakedebug = clm_lake_debug
5314 debug_print = clm_debug_print
5315 if(debug_print)
then
5316 write(0,*)
'clm_lake_init'
5333 hsub = con_hfus+con_hvap
5334 invhvap = 1._kind_lake/hvap
5335 invhsub = 1._kind_lake/hsub
5338 con_eps = con_eps_model
5339 con_fvirt = con_fvirt_model
5340 one_minus_con_eps = 1.0_kind_lake - con_eps
5363 dzlak(1) = 0.1_kind_lake
5364 dzlak(2) = 0.1_kind_lake
5365 dzlak(3) = 0.1_kind_lake
5366 dzlak(4) = 0.1_kind_lake
5367 dzlak(5) = 0.1_kind_lake
5368 dzlak(6) = 0.1_kind_lake
5369 dzlak(7) = 0.1_kind_lake
5370 dzlak(8) = 0.1_kind_lake
5371 dzlak(9) = 0.1_kind_lake
5372 dzlak(10)= 0.1_kind_lake
5374 zlak(1) = 0.05_kind_lake
5375 zlak(2) = 0.15_kind_lake
5376 zlak(3) = 0.25_kind_lake
5377 zlak(4) = 0.35_kind_lake
5378 zlak(5) = 0.45_kind_lake
5379 zlak(6) = 0.55_kind_lake
5380 zlak(7) = 0.65_kind_lake
5381 zlak(8) = 0.75_kind_lake
5382 zlak(9) = 0.85_kind_lake
5383 zlak(10)= 0.95_kind_lake
5388 zsoi(j) = scalez*(exp(0.5_kind_lake*(j-0.5_kind_lake))-1._kind_lake)
5391 dzsoi(1) = 0.5_kind_lake*(zsoi(1)+zsoi(2))
5393 dzsoi(j)= 0.5_kind_lake*(zsoi(j+1)-zsoi(j-1))
5395 dzsoi(nlevsoil) = zsoi(nlevsoil)-zsoi(nlevsoil-1)
5397 zisoi(0) = 0._kind_lake
5398 do j = 1, nlevsoil-1
5399 zisoi(j) = 0.5_kind_lake*(zsoi(j)+zsoi(j+1))
5401 zisoi(nlevsoil) = zsoi(nlevsoil) + 0.5_kind_lake*dzsoi(nlevsoil)
5403 end subroutine clm_lake_init
5405 SUBROUTINE lakeini(kdt, ISLTYP, gt0, snowd, & !i
5406 weasd, lakedepth_default, fhour, &
5407 oro_lakedepth, savedtke12d, snowdp2d, h2osno2d, & !o
5408 snl2d, t_grnd2d, t_lake3d, lake_icefrac3d, &
5409 t_soisno3d, h2osoi_ice3d, &
5410 h2osoi_liq3d, h2osoi_vol3d, z3d, dz3d, &
5412 fice, hice, min_lakeice, tsfc, &
5413 use_lake_model, use_lakedepth, &
5415 xlat_d, xlon_d, clm_lake_initialized, &
5416 input_lakedepth, tg3, clm_lakedepth, &
5417 km, me, master, errmsg, errflg)
5434 INTEGER,
INTENT(OUT) :: errflg
5435 CHARACTER(*),
INTENT(OUT) :: errmsg
5437 INTEGER ,
INTENT (IN) :: im, me, master, km, kdt
5438 REAL(kind_phys),
INTENT(IN) :: min_lakeice, fhour
5439 REAL(kind_phys),
DIMENSION(:),
INTENT(INOUT):: fice, hice
5440 REAL(kind_phys),
DIMENSION(:),
INTENT(IN):: tg3, xlat_d, xlon_d
5441 REAL(kind_phys),
DIMENSION(:),
INTENT(IN):: tsfc
5442 REAL(kind_phys),
DIMENSION(:) ,
INTENT(INOUT) :: clm_lake_initialized
5443 integer,
dimension(:),
intent(in) :: use_lake_model
5444 LOGICAL,
INTENT (IN) :: use_lakedepth
5446 INTEGER,
DIMENSION(:),
INTENT(IN) :: isltyp
5447 REAL(kind_phys),
DIMENSION(:),
INTENT(INOUT) :: snowd,weasd
5448 REAL(kind_phys),
DIMENSION(:,:),
INTENT(IN) :: gt0
5449 REAL(kind_phys),
DIMENSION(:,:),
INTENT(IN) :: prsi
5450 real(kind_phys),
intent(in) :: lakedepth_default
5452 real(kind_phys),
dimension(:),
intent(inout) :: clm_lakedepth
5453 real(kind_phys),
dimension(:),
intent(inout) :: input_lakedepth
5454 real(kind_phys),
dimension(:),
intent(in) :: oro_lakedepth
5455 real(kind_phys),
dimension(:),
intent(out) :: savedtke12d
5456 real(kind_phys),
dimension(:),
intent(out) :: snowdp2d, &
5461 real(kind_phys),
dimension(:,:),
INTENT(out) :: t_lake3d, &
5463 real(kind_phys),
dimension(:,-nlevsnow+1:),
INTENT(out) :: t_soisno3d, &
5470 real(kind_phys),
dimension(:,-nlevsnow+0:),
INTENT(out) :: zi3d
5473 integer :: n,i,j,k,ib,lev,bottom
5474 real(kind_lake),
dimension(1:im ) :: bd2d
5475 real(kind_lake),
dimension(1:im ) :: tkm2d
5476 real(kind_lake),
dimension(1:im ) :: xksat2d
5477 real(kind_lake),
dimension(1:im ) :: depthratio2d
5479 logical,
parameter :: arbinit = .false.
5480 real(kind_lake),
parameter :: defval = -999.0
5483 character*256 :: message
5484 real(kind_lake) :: ht
5485 real(kind_lake) :: rhosn
5486 real(kind_lake) :: depth, lakedepth
5488 logical :: climatology_limits
5490 real(kind_lake) :: z_lake(nlevlake)
5491 real(kind_lake) :: dz_lake(nlevlake)
5493 integer,
parameter :: xcheck=38
5494 integer,
parameter :: ycheck=92
5496 integer :: used_lakedepth_default, init_points, month, julday
5497 integer :: mon, iday, num2, num1, juld, day2, day1, wght1, wght2
5498 real(kind_lake) :: tclim, watsat
5500 used_lakedepth_default=0
5509 if(use_lake_model(i)==0 .or. clm_lake_initialized(i)>0)
then
5514 if ( use_lakedepth )
then
5515 if (oro_lakedepth(i) == 10.0 .or. oro_lakedepth(i) <= 0.)
then
5517 clm_lakedepth(i) = lakedepth_default
5518 used_lakedepth_default = used_lakedepth_default+1
5520 clm_lakedepth(i) = oro_lakedepth(i)
5524 clm_lakedepth(i) = lakedepth_default
5525 used_lakedepth_default = used_lakedepth_default+1
5528 if(clm_lake_initialized(i)>0)
then
5532 input_lakedepth=clm_lakedepth
5535 do k = -nlevsnow+1,nlevsoil
5536 h2osoi_liq3d(i,k) = defval
5537 h2osoi_ice3d(i,k) = defval
5538 h2osoi_vol3d(i,k) = defval
5539 t_soisno3d(i,k) = defval
5544 t_lake3d(i,k) = defval
5545 lake_icefrac3d(i,k) = defval
5548 if (use_lake_model(i) == 1)
then
5553 h2osoi_liq3d(i,:) = 0.0
5554 h2osoi_ice3d(i,:) = 0.0
5555 lake_icefrac3d(i,:) = 0.0
5556 h2osoi_vol3d(i,:) = 0.0
5559 if(fice(i)>min_lakeice)
then
5560 lake_icefrac3d(i,1) = fice(i)
5561 snowdp2d(i) = snowd(i)*1e-3
5562 h2osno2d(i) = weasd(i)
5573 if (isl == 0 ) isl = 14
5574 if (isl == 14 ) isl = isl + 1
5576 call calculate_z_dz_lake(i,input_lakedepth,clm_lakedepth,z_lake,dz_lake)
5578 z3d(i,1:nlevsoil) = zsoi(1:nlevsoil)
5579 zi3d(i,0:nlevsoil) = zisoi(0:nlevsoil)
5580 dz3d(i,1:nlevsoil) = dzsoi(1:nlevsoil)
5581 savedtke12d(i) = tkwat
5584 if (snowdp2d(i) < 0.01_kind_lake)
then
5586 dz3d(i,-nlevsnow+1:0) = 0._kind_lake
5587 z3d(i,-nlevsnow+1:0) = 0._kind_lake
5588 zi3d(i,-nlevsnow+0:0) = 0._kind_lake
5590 if ((snowdp2d(i) >= 0.01_kind_lake) .and. (snowdp2d(i) <= 0.03_kind_lake))
then
5592 dz3d(i,0) = snowdp2d(i)
5593 else if ((snowdp2d(i) > 0.03_kind_lake) .and. (snowdp2d(i) <= 0.04_kind_lake))
then
5595 dz3d(i,-1) = snowdp2d(i)*0.5_kind_lake
5596 dz3d(i, 0) = dz3d(i,-1)
5597 else if ((snowdp2d(i) > 0.04_kind_lake) .and. (snowdp2d(i) <= 0.07_kind_lake))
then
5599 dz3d(i,-1) = 0.02_kind_lake
5600 dz3d(i, 0) = snowdp2d(i) - dz3d(i,-1)
5601 else if ((snowdp2d(i) > 0.07_kind_lake) .and. (snowdp2d(i) <= 0.12_kind_lake))
then
5603 dz3d(i,-2) = 0.02_kind_lake
5604 dz3d(i,-1) = (snowdp2d(i) - 0.02_kind_lake)*0.5_kind_lake
5605 dz3d(i, 0) = dz3d(i,-1)
5606 else if ((snowdp2d(i) > 0.12_kind_lake) .and. (snowdp2d(i) <= 0.18_kind_lake))
then
5608 dz3d(i,-2) = 0.02_kind_lake
5609 dz3d(i,-1) = 0.05_kind_lake
5610 dz3d(i, 0) = snowdp2d(i) - dz3d(i,-2) - dz3d(i,-1)
5611 else if ((snowdp2d(i) > 0.18_kind_lake) .and. (snowdp2d(i) <= 0.29_kind_lake))
then
5613 dz3d(i,-3) = 0.02_kind_lake
5614 dz3d(i,-2) = 0.05_kind_lake
5615 dz3d(i,-1) = (snowdp2d(i) - dz3d(i,-3) - dz3d(i,-2))*0.5_kind_lake
5616 dz3d(i, 0) = dz3d(i,-1)
5617 else if ((snowdp2d(i) > 0.29_kind_lake) .and. (snowdp2d(i) <= 0.41_kind_lake))
then
5619 dz3d(i,-3) = 0.02_kind_lake
5620 dz3d(i,-2) = 0.05_kind_lake
5621 dz3d(i,-1) = 0.11_kind_lake
5622 dz3d(i, 0) = snowdp2d(i) - dz3d(i,-3) - dz3d(i,-2) - dz3d(i,-1)
5623 else if ((snowdp2d(i) > 0.41_kind_lake) .and. (snowdp2d(i) <= 0.64_kind_lake))
then
5625 dz3d(i,-4) = 0.02_kind_lake
5626 dz3d(i,-3) = 0.05_kind_lake
5627 dz3d(i,-2) = 0.11_kind_lake
5628 dz3d(i,-1) = (snowdp2d(i) - dz3d(i,-4) - dz3d(i,-3) - dz3d(i,-2))*0.5_kind_lake
5629 dz3d(i, 0) = dz3d(i,-1)
5630 else if (snowdp2d(i) > 0.64_kind_lake)
then
5632 dz3d(i,-4) = 0.02_kind_lake
5633 dz3d(i,-3) = 0.05_kind_lake
5634 dz3d(i,-2) = 0.11_kind_lake
5635 dz3d(i,-1) = 0.23_kind_lake
5636 dz3d(i, 0)=snowdp2d(i)-dz3d(i,-4)-dz3d(i,-3)-dz3d(i,-2)-dz3d(i,-1)
5640 do k = 0, nint(snl2d(i)+1), -1
5641 z3d(i,k) = zi3d(i,k) - 0.5_kind_lake*dz3d(i,k)
5642 zi3d(i,k-1) = zi3d(i,k) - dz3d(i,k)
5648 if(tsfc(i)<160)
then
5649 write(errmsg,
'(A,F20.12,A)')
'Invalid tsfc value ',tsfc(i),
' found. Was tsfc not initialized?'
5650 write(0,
'(A)') trim(errmsg)
5655 if(lake_icefrac3d(i,1) > 0.)
then
5658 depth = depth + dz_lake(k)
5659 if(hice(i) >= depth)
then
5660 lake_icefrac3d(i,k) = max(0.,lake_icefrac3d(i,1)+(0.-lake_icefrac3d(i,1))/z_lake(nlevlake)*depth)
5662 lake_icefrac3d(i,k) = 0.
5667 t_lake3d(i,1) = tsfc(i)
5668 t_grnd2d(i) = tsfc(i)
5669 if (lake_icefrac3d(i,1) <= 0.)
then
5670 t_lake3d(i,1) = max(tfrz,tsfc(i))
5671 t_grnd2d(i) = max(tfrz,tsfc(i))
5674 if(z_lake(k).le.depth_c)
then
5675 t_lake3d(i,k) = tsfc(i)+(277.2_kind_lake-tsfc(i))/depth_c*z_lake(k)
5677 t_lake3d(i,k) = 277.2_kind_lake
5679 if (lake_icefrac3d(i,k) <= 0.)
then
5680 t_lake3d(i,k) = max(tfrz,t_lake3d(i,k))
5686 if(snowdp2d(i) > 0.)
then
5687 do k = nint(snl2d(i))+1, 0
5688 t_soisno3d(i,k) =min(tfrz,tsfc(i))
5693 t_soisno3d(i,1) = t_lake3d(i,nlevlake)
5694 t_soisno3d(i,nlevsoil) = tg3(i)
5695 do k = 2, nlevsoil-1
5696 t_soisno3d(i,k)=t_soisno3d(i,1)+(t_soisno3d(i,nlevsoil)-t_soisno3d(i,1))*dzsoi(k)
5699 if (snl2d(i) < 0)
then
5700 do k = nint(snl2d(i)+1), 0
5703 if(t_soisno3d(i,k) > 300 .or. t_soisno3d(i,k) < 200) t_soisno3d(i,k) = min(tfrz,tsfc(i))
5708 h2osoi_vol3d(i,k) = 1.0_kind_lake
5709 watsat = 0.489_kind_lake - 0.00126_kind_lake*sand(isl)
5710 h2osoi_vol3d(i,k) = min(h2osoi_vol3d(i,k),watsat)
5713 if (t_soisno3d(i,k) <= tfrz)
then
5714 h2osoi_ice3d(i,k) = dz3d(i,k)*denice*h2osoi_vol3d(i,k)
5715 h2osoi_liq3d(i,k) = 0._kind_lake
5717 h2osoi_ice3d(i,k) = 0._kind_lake
5718 h2osoi_liq3d(i,k) = dz3d(i,k)*denh2o*h2osoi_vol3d(i,k)
5726 if(h2osno2d(i).gt.0. .and. snowdp2d(i).gt.0.)
then
5727 rhosn = h2osno2d(i)/snowdp2d(i)
5733 do k = -nlevsnow+1, 0
5734 if (k > snl2d(i))
then
5735 h2osoi_ice3d(i,k) = dz3d(i,k)*snow_bd
5736 h2osoi_liq3d(i,k) = 0._kind_lake
5740 clm_lake_initialized(i) = 1
5746 if(debug_print .and. init_points>0)
then
5747 print *,
'points initialized in clm_lake',init_points
5750END SUBROUTINE lakeini
This module contains the CLM Lake model.