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, &
272 ! Atmospheric model state inputs:
273 tg3, pgr, zlvl, gt0, prsi, phii, qvcurr, gu0, gv0, xlat_d, xlon_d, &
274 ch, cm, dlwsfci, dswsfci, oro_lakedepth, wind, tsfc, &
275 flag_iter, flag_lakefreeze, ISLTYP, rainncprv, raincprv, &
277 ! Feedback to atmosphere:
278 evap_wat, evap_ice, hflx_wat, hflx_ice, gflx_wat, gflx_ice, &
279 ep1d_water, ep1d_ice, tsurf_water, tsurf_ice, tsfc_wat, tisfc, &
280 weasdi, snodi, hice, qss_water, qss_ice, &
281 cmm_water, cmm_ice, chh_water, chh_ice, &
282 uustar_water, uustar_ice, lake_t_snow, albedo, zorlw, &
283 zorli, lake_t2m, lake_q2m, weasd, snowd, fice, &
286 ! Lake model internal state stored by caller:
288 salty, savedtke12d, snowdp2d, h2osno2d, snl2d, t_grnd2d, t_lake3d, &
289 lake_icefrac3d, t_soisno3d, h2osoi_ice3d, h2osoi_liq3d, h2osoi_vol3d, &
290 z3d, dz3d, zi3d, t1, qv1, prsl1, &
291 input_lakedepth, clm_lakedepth, cannot_freeze, &
307 LOGICAL ,
INTENT (IN) :: flag_restart
308 INTEGER ,
INTENT (IN) :: im,km,me,master
309 INTEGER,
INTENT(IN) :: idate(4), kdt
310 REAL(kind_phys),
INTENT(IN) :: fhour
311 INTEGER,
INTENT(IN) :: lkm
316 INTEGER,
INTENT(IN) :: iopt_lake, iopt_lake_clm
317 REAL(kind_phys),
INTENT(IN) :: min_lakeice, lakedepth_default, dtp
318 LOGICAL,
INTENT(IN) :: use_lakedepth
319 INTEGER,
DIMENSION(:),
INTENT(IN) :: use_lake_model
320 REAL(kind_phys),
INTENT(INOUT),
OPTIONAL :: clm_lake_initialized(:)
321 LOGICAL,
INTENT(IN) :: frac_grid, frac_ice
326 REAL(kind_phys),
DIMENSION(:),
INTENT(IN):: &
327 tg3, pgr, zlvl, qvcurr, xlat_d, xlon_d, ch, cm, &
328 dlwsfci, dswsfci, oro_lakedepth, wind, &
330 REAL(kind_phys),
DIMENSION(:),
INTENT(IN),
OPTIONAL :: &
332 REAL(kind_phys),
DIMENSION(:,:),
INTENT(in) :: gu0, gv0, prsi, gt0, phii
333 LOGICAL,
DIMENSION(:),
INTENT(IN) :: flag_iter
334 LOGICAL,
DIMENSION(:),
INTENT(INOUT) :: flag_lakefreeze
336 INTEGER,
DIMENSION(:),
INTENT(IN) :: isltyp
341 REAL(kind_phys),
DIMENSION(:),
INTENT(INOUT) :: &
342 evap_wat, evap_ice, hflx_wat, hflx_ice, gflx_wat, gflx_ice, &
343 ep1d_water, ep1d_ice, tsurf_water, tsurf_ice, tsfc_wat, tisfc, tsfc, &
344 weasdi, snodi, hice, qss_water, qss_ice, &
345 cmm_water, cmm_ice, chh_water, chh_ice, &
346 uustar_water, uustar_ice, zorlw, zorli, weasd, snowd, fice
347 REAL(kind_phys),
DIMENSION(:),
INTENT(INOUT) ,
OPTIONAL :: &
348 lake_t_snow,
albedo, lake_t2m, lake_q2m
349 LOGICAL,
INTENT(INOUT) :: icy(:)
354 INTEGER,
DIMENSION( : ),
INTENT(INOUT),
OPTIONAL :: salty
355 INTEGER,
DIMENSION( : ),
INTENT(INOUT),
OPTIONAL :: cannot_freeze
357 real(kind_phys),
dimension(: ),
OPTIONAL ,
intent(inout) :: savedtke12d, &
363 real(kind_phys),
dimension( :,: ),
OPTIONAL,
INTENT(inout) :: t_lake3d, &
365 real(kind_phys),
dimension( :,-nlevsnow+1: ) ,
INTENT(inout),
OPTIONAL :: t_soisno3d, &
371 real(kind_phys),
dimension( :,-nlevsnow+0: ) ,
INTENT(inout),
OPTIONAL :: zi3d
373 REAL(kind_phys),
DIMENSION( : ) ,
INTENT(INOUT),
OPTIONAL :: clm_lakedepth
374 REAL(kind_phys),
DIMENSION( : ) ,
INTENT(INOUT),
OPTIONAL :: input_lakedepth
379 INTEGER,
INTENT(OUT) :: errflg
380 CHARACTER(*),
INTENT(OUT) :: errmsg
388 REAL(kind_lake) :: sfctmp,pbot,psfc,q2k,lwdn,prcp,soldn,solnet,dtime
393 real(kind_lake) :: forc_t(1)
394 real(kind_lake) :: forc_pbot(1)
395 real(kind_lake) :: forc_psrf(1)
396 real(kind_lake) :: forc_hgt(1)
397 real(kind_lake) :: forc_hgt_q(1)
398 real(kind_lake) :: forc_hgt_t(1)
399 real(kind_lake) :: forc_hgt_u(1)
400 real(kind_lake) :: forc_q(1)
401 real(kind_lake) :: forc_u(1)
402 real(kind_lake) :: forc_v(1)
403 real(kind_lake) :: forc_lwrad(1)
404 real(kind_lake) :: prec(1)
405 real(kind_lake) :: sabg(1)
406 real(kind_lake) :: lat(1)
407 real(kind_lake) :: z_lake(1,nlevlake)
408 real(kind_lake) :: dz_lake(1,nlevlake)
410 real(kind_lake) :: lakedepth(1)
411 logical :: do_capsnow(1)
414 real(kind_lake) :: h2osoi_vol(1,-nlevsnow+1:nlevsoil)
415 real(kind_lake) :: t_grnd(1)
416 real(kind_lake) :: h2osno(1)
417 real(kind_lake) :: snowdp(1)
418 real(kind_lake) :: z(1,-nlevsnow+1:nlevsoil)
419 real(kind_lake) :: dz(1,-nlevsnow+1:nlevsoil)
420 real(kind_lake) :: t_soisno(1,-nlevsnow+1:nlevsoil)
421 real(kind_lake) :: t_lake(1,nlevlake)
423 real(kind_lake) :: h2osoi_liq(1,-nlevsnow+1:nlevsoil)
424 real(kind_lake) :: h2osoi_ice(1,-nlevsnow+1:nlevsoil)
425 real(kind_lake) :: savedtke1(1)
426 real(kind_lake) :: zi(1,-nlevsnow+0:nlevsoil)
427 real(kind_lake) :: lake_icefrac(1,nlevlake)
431 real(kind_lake) :: eflx_gnet(1)
432 real(kind_lake) :: eflx_lwrad_net(1)
433 real(kind_lake) :: eflx_sh_tot(1)
434 real(kind_lake) :: eflx_lh_tot(1)
435 real(kind_lake) :: t_ref2m(1)
436 real(kind_lake) :: q_ref2m(1)
437 real(kind_lake) :: taux(1)
438 real(kind_lake) :: tauy(1)
439 real(kind_lake) :: ram1(1)
442 real(kind_lake) :: z0mg(1)
443 real(kind_lake) :: qfx
445 real(kind_lake) :: ustar_out(1)
447 real(kind_lake) :: discard1, discard2, discard3
449 real(kind_lake) :: watsat(1,nlevsoil)
450 real(kind_lake) :: tksatu(1,nlevsoil)
451 real(kind_lake) :: tkmg(1,nlevsoil)
452 real(kind_lake) :: tkdry(1,nlevsoil)
453 real(kind_lake) :: csol(1,nlevsoil)
457 integer :: lake_points, snow_points, ice_points
458 character*255 :: message
459 logical,
parameter :: feedback_to_atmosphere = .true.
461 real(kind_lake) :: to_radians, lat_d, lon_d, qss, tkm, bd
462 real(kind_lake) :: rho0
464 integer :: month,num1,num2,day_of_month,isl
465 real(kind_lake) :: wght1,wght2,tclim,depthratio
467 logical salty_flag, cannot_freeze_flag
472 if(iopt_lake/=iopt_lake_clm .or. lkm==0 .or. all(use_lake_model==0))
then
479 call lakeini(kdt=kdt, isltyp=isltyp, gt0=gt0, snowd=snowd, weasd=weasd, &
480 lakedepth_default=lakedepth_default, fhour=fhour, &
481 oro_lakedepth=oro_lakedepth, savedtke12d=savedtke12d, snowdp2d=snowdp2d, &
482 h2osno2d=h2osno2d, snl2d=snl2d, t_grnd2d=t_grnd2d, t_lake3d=t_lake3d, &
483 lake_icefrac3d=lake_icefrac3d, &
484 t_soisno3d=t_soisno3d, h2osoi_ice3d=h2osoi_ice3d, h2osoi_liq3d=h2osoi_liq3d, &
485 h2osoi_vol3d=h2osoi_vol3d, z3d=z3d, dz3d=dz3d, zi3d=zi3d, &
486 fice=fice, hice=hice, min_lakeice=min_lakeice, &
488 use_lake_model=use_lake_model, use_lakedepth=use_lakedepth, &
489 im=im, prsi=prsi, xlat_d=xlat_d, xlon_d=xlon_d, &
490 clm_lake_initialized=clm_lake_initialized, input_lakedepth=input_lakedepth, &
491 tg3=tg3, clm_lakedepth=clm_lakedepth, km=km, me=me, master=master, &
492 errmsg=errmsg, errflg=errflg)
504 day_of_month = idate(3)
507 if(day_of_month>15)
then
512 wght2 = day_of_month/month_length(month)
513 if(wght2<0 .or. wght2>1)
then
515 write(0,*)
'Warning: wght2 is not 0..1: ',wght2
517 wght2 = max(0.0_kind_lake,min(1.0_kind_lake,wght2))
519 wght1 = 1.0_kind_lake - wght2
521 if(debug_print )
then
522 print *,
'month,num1,num2,wght1,wght2',month,num1,num2,wght1,wght2
525 lake_top_loop:
DO i = 1,im
527 if_lake_is_here:
if (flag_iter(i) .and. use_lake_model(i)/=0)
THEN
529 call is_salty(xlat_d(i),xlon_d(i),salty_flag,cannot_freeze_flag)
537 if(cannot_freeze_flag)
then
551 prcp = (raincprv(i)+rainncprv(i))/dtime
553 albedo(i) = ( 0.6 * lake_icefrac3d(i,1) ) + &
554 ( (1.0-lake_icefrac3d(i,1)) * 0.08)
555 solnet = soldn*(1.-
albedo(i))
558 lake_points = lake_points+1
560 call calculate_z_dz_lake(i,input_lakedepth,clm_lakedepth,z_lake(1,:),dz_lake(1,:))
563 z_lake(c,:) = z_lake(1,:)
564 dz_lake(c,:) = dz_lake(1,:)
569 if (isl == 0 ) isl = 14
570 if (isl == 14 ) isl = isl + 1
572 watsat = 0.489_kind_lake - 0.00126_kind_lake*sand(isl)
573 csol = (2.128_kind_lake*sand(isl)+2.385_kind_lake*clay(isl)) / (sand(isl)+clay(isl))*1.e6_kind_lake
574 tkm = (8.80_kind_lake*sand(isl)+2.92_kind_lake*clay(isl))/(sand(isl)+clay(isl))
575 bd = (1._kind_lake-watsat(1,1))*2.7e3_kind_lake
576 tkmg = tkm ** (1._kind_lake- watsat(1,1))
577 tkdry = (0.135_kind_lake*bd + 64.7_kind_lake) / (2.7e3_kind_lake - 0.947_kind_lake*bd)
578 tksatu = tkmg(1,1)*0.57_kind_lake**watsat(1,1)
585 forc_hgt(c) = zlvl(i)
586 forc_hgt_q(c) = zlvl(i)
587 forc_hgt_t(c) = zlvl(i)
588 forc_hgt_u(c) = zlvl(i)
595 lat(c) = xlat_d(i)*to_radians
596 do_capsnow(c) = .false.
598 lakedepth(c) = clm_lakedepth(i)
599 savedtke1(c) = savedtke12d(i)
600 snowdp(c) = snowdp2d(i)
601 h2osno(c) = h2osno2d(i)
603 t_grnd(c) = t_grnd2d(i)
605 t_lake(c,k) = t_lake3d(i,k)
606 lake_icefrac(c,k) = lake_icefrac3d(i,k)
608 do k = -nlevsnow+1,nlevsoil
609 t_soisno(c,k) = t_soisno3d(i,k)
610 h2osoi_ice(c,k) = h2osoi_ice3d(i,k)
611 h2osoi_liq(c,k) = h2osoi_liq3d(i,k)
612 h2osoi_vol(c,k) = h2osoi_vol3d(i,k)
616 do k = -nlevsnow+0,nlevsoil
621 eflx_lwrad_net = -9999
635 CALL lakemain(forc_t,forc_pbot,forc_psrf,forc_hgt,forc_hgt_q, &
636 forc_hgt_t,forc_hgt_u,forc_q, forc_u, &
637 forc_v,forc_lwrad,prec, sabg,lat, &
638 z_lake,dz_lake,lakedepth,do_capsnow, &
639 h2osno,snowdp,snl,z,dz,zi, &
640 h2osoi_vol,h2osoi_liq,h2osoi_ice, &
641 t_grnd,t_soisno,t_lake, &
642 savedtke1,lake_icefrac, &
643 eflx_lwrad_net,eflx_gnet, &
644 eflx_sh_tot,eflx_lh_tot, &
645 t_ref2m,q_ref2m, dtime, &
646 watsat, tksatu, tkmg, tkdry, csol, &
647 taux,tauy,ram1,z0mg,ustar_out,errmsg,errflg, &
652 if(cannot_freeze(i) == 1)
then
655 lake_icefrac(c,k) = 0._kind_lake
658 tclim = tfrz + wght1*saltlk_t(num1) &
659 + wght2*saltlk_t(num2)
660 if(debug_print) print *,
'GSL - Tclim,tsfc,t_lake3d',i,tclim,t_grnd(c),t_lake(c,:),t_soisno(c,:)
661 t_grnd(c) = min(tclim+3.0_kind_lake,(max(t_grnd(c),tclim-3.0_kind_lake)))
663 t_lake(c,k) = min(tclim+3.0_kind_lake,(max(t_lake(c,k),tclim-3.0_kind_lake)))
665 t_soisno(c,1) = min(tclim+3.0_kind_lake,(max(t_soisno(c,1),tclim-3.0_kind_lake)))
666 if(debug_print) print *,
'GSL - after Tclim,tsfc,t_lake3d',i,tclim,t_grnd(c),t_lake(c,:),t_soisno(c,:)
667 elseif(salty(i) == 1)
then
669 t_grnd(c) = max(tfrz-4.2_kind_lake,t_grnd(c))
671 lake_icefrac(c,k) = 0._kind_lake
672 t_lake(c,k) = max(tfrz-4.2_kind_lake,t_lake(c,k))
674 t_soisno(c,1) = max(tfrz-4.2_kind_lake,t_soisno(c,1))
675 if(debug_print) print *,
'Mono - tsfc,t_lake3d',i,t_grnd(c),t_lake(c,:),t_soisno(c,:)
678 savedtke12d(i) = savedtke1(c)
679 snowdp2d(i) = snowdp(c)
680 h2osno2d(i) = h2osno(c)
682 t_grnd2d(i) = t_grnd(c)
684 t_lake3d(i,k) = t_lake(c,k)
685 lake_icefrac3d(i,k) = lake_icefrac(c,k)
687 do k = -nlevsnow+1,nlevsoil
690 t_soisno3d(i,k) = t_soisno(c,k)
691 h2osoi_liq3d(i,k) = h2osoi_liq(c,k)
692 h2osoi_ice3d(i,k) = h2osoi_ice(c,k)
693 h2osoi_vol3d(i,k) = h2osoi_vol(c,k)
695 do k = -nlevsnow+0,nlevsoil
701 feedback:
if(feedback_to_atmosphere)
then
705 if( t_grnd(c) >= tfrz )
then
706 qfx = eflx_lh_tot(c)*invhvap
708 qfx = eflx_lh_tot(c)*invhsub
710 rho0 = prsl1(i) / (rair*t1(i)*(1.0 + con_fvirt*qv1(i)))
711 evap_wat(i) = qfx/rho0
712 hflx_wat(i) = eflx_sh_tot(c)/(rho0*cpair)
713 gflx_wat(i) = eflx_gnet(c)
714 ep1d_water(i) = eflx_lh_tot(c)
715 tsurf_water(i) = t_grnd(c)
716 tsurf_ice(i) = t_grnd(c)
717 tsfc_wat(i) = t_grnd(c)
720 lake_t2m(i) = t_ref2m(c)
721 lake_q2m(i) = q_ref2m(c)
722 albedo(i) = ( 0.6 * lake_icefrac3d(i,1) ) + &
723 ( (1.0-lake_icefrac3d(i,1)) * 0.08)
724 fice(i) = lake_icefrac3d(i,1)
738 call qsat(t_grnd(c),psfc,discard1,discard2,qss,discard3)
742 chh_water(i) = ch(i)*wind(i)*1.225
743 cmm_water(i) = cm(i)*wind(i)
745 ice_point:
if(fice(i)>=min_lakeice)
then
748 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
749 if(frac_ice .or. frac_grid)
then
750 evap_ice(i) = evap_wat(i)
751 hflx_ice(i) = hflx_wat(i)
752 gflx_ice(i) = gflx_wat(i)
753 ep1d_ice(i) = ep1d_water(i)
754 chh_ice(i) = chh_water(i)
755 cmm_ice(i) = cmm_water(i)
756 qss_ice(i) = qss_water(i)
760 tsurf_ice(i) = t_grnd(c)
763 weasdi(i) = h2osno(c)
764 snodi(i) = snowdp(c)*1.e3
769 if (.not. icy(i))
then
770 flag_lakefreeze(i)=.true.
775 ice_points = ice_points+1
782 if(lake_icefrac3d(i,k)>0)
then
783 hice(i) = hice(i) + dz_lake(c,k)
796 tsurf_ice(i) = tisfc(i)
804 lake_t_snow(i) = t_grnd(c)
805 tisfc(i) = lake_t_snow(i)
806 snow_points = snow_points+1
808 lake_t_snow(i) = -9999
813 endif if_lake_is_here
816 if(debug_print .and. lake_points>0 .and. (kdt<3 .or. mod(kdt,30)==3))
then
8173082
format(
'lake points processed in timestep ',i0,
' by rank ',i0,
' = ',i0,
' snow=',i0,
' ice=',i0)
818 print 3082,kdt,me,lake_points,snow_points,ice_points
824 SUBROUTINE lakemain(forc_t,forc_pbot,forc_psrf,forc_hgt,forc_hgt_q, & !I
825 forc_hgt_t,forc_hgt_u,forc_q, forc_u, &
826 forc_v,forc_lwrad,prec, sabg,lat, &
827 z_lake,dz_lake,lakedepth,do_capsnow, &
828 h2osno,snowdp,snl,z,dz,zi, & !H
829 h2osoi_vol,h2osoi_liq,h2osoi_ice, &
830 t_grnd,t_soisno,t_lake, &
831 savedtke1,lake_icefrac, &
832 eflx_lwrad_net,eflx_gnet, & !O
833 eflx_sh_tot,eflx_lh_tot, &
834 t_ref2m,q_ref2m, dtime, &
835 watsat, tksatu, tkmg, tkdry, csol, &
836 taux,tauy,ram1,z0mg,ustar_out,errmsg,errflg, xlat_d,xlon_d)
840 integer,
intent(inout) :: errflg
841 character(*),
intent(inout) :: errmsg
842 real(kind_lake),
intent(in) :: dtime
843 real(kind_lake),
intent(in) :: xlat_d, xlon_d
844 real(kind_lake),
intent(in) :: forc_t(1)
845 real(kind_lake),
intent(in) :: forc_pbot(1)
846 real(kind_lake),
intent(in) :: forc_psrf(1)
847 real(kind_lake),
intent(in) :: forc_hgt(1)
848 real(kind_lake),
intent(in) :: forc_hgt_q(1)
849 real(kind_lake),
intent(in) :: forc_hgt_t(1)
850 real(kind_lake),
intent(in) :: forc_hgt_u(1)
851 real(kind_lake),
intent(in) :: forc_q(1)
852 real(kind_lake),
intent(in) :: forc_u(1)
853 real(kind_lake),
intent(in) :: forc_v(1)
855 real(kind_lake),
intent(in) :: forc_lwrad(1)
856 real(kind_lake),
intent(in) :: prec(1)
857 real(kind_lake),
intent(in) :: sabg(1)
858 real(kind_lake),
intent(in) :: lat(1)
859 real(kind_lake),
intent(in) :: z_lake(1,nlevlake)
860 real(kind_lake),
intent(in) :: dz_lake(1,nlevlake)
861 real(kind_lake),
intent(out) :: ustar_out(1)
862 real(kind_lake),
intent(in) :: lakedepth(1)
866 logical ,
intent(in) :: do_capsnow(1)
867 real(kind_lake),
intent(in) :: watsat(1,nlevsoil)
868 real(kind_lake),
intent(in) :: tksatu(1,nlevsoil)
869 real(kind_lake),
intent(in) :: tkmg(1,nlevsoil)
870 real(kind_lake),
intent(in) :: tkdry(1,nlevsoil)
871 real(kind_lake),
intent(in) :: csol(1,nlevsoil)
876 real(kind_lake),
intent(inout) :: h2osoi_vol(1,-nlevsnow+1:nlevsoil)
877 real(kind_lake),
intent(inout) :: t_grnd(1)
878 real(kind_lake),
intent(inout) :: h2osno(1)
879 real(kind_lake),
intent(inout) :: snowdp(1)
880 real(kind_lake),
intent(inout) :: z(1,-nlevsnow+1:nlevsoil)
881 real(kind_lake),
intent(inout) :: dz(1,-nlevsnow+1:nlevsoil)
882 real(kind_lake),
intent(inout) :: t_soisno(1,-nlevsnow+1:nlevsoil)
883 real(kind_lake),
intent(inout) :: t_lake(1,nlevlake)
884 integer ,
intent(inout) :: snl(1)
885 real(kind_lake),
intent(inout) :: h2osoi_liq(1,-nlevsnow+1:nlevsoil)
886 real(kind_lake),
intent(inout) :: h2osoi_ice(1,-nlevsnow+1:nlevsoil)
887 real(kind_lake),
intent(inout) :: savedtke1(1)
888 real(kind_lake),
intent(inout) :: zi(1,-nlevsnow+0:nlevsoil)
889 real(kind_lake),
intent(inout) :: lake_icefrac(1,nlevlake)
893 real(kind_lake),
intent(out) :: eflx_gnet(1)
894 real(kind_lake),
intent(out) :: eflx_lwrad_net(1)
895 real(kind_lake),
intent(out) :: eflx_sh_tot(1)
896 real(kind_lake),
intent(out) :: eflx_lh_tot(1)
897 real(kind_lake),
intent(out) :: t_ref2m(1)
898 real(kind_lake),
intent(out) :: q_ref2m(1)
899 real(kind_lake),
intent(out) :: taux(1)
900 real(kind_lake),
intent(out) :: tauy(1)
901 real(kind_lake),
intent(out) :: ram1(1)
904 real(kind_lake),
intent(out) :: z0mg(1)
909 real(kind_lake) :: begwb(1)
910 real(kind_lake) :: t_veg(1)
911 real(kind_lake) :: eflx_soil_grnd(1)
912 real(kind_lake) :: eflx_lh_grnd(1)
913 real(kind_lake) :: eflx_sh_grnd(1)
914 real(kind_lake) :: eflx_lwrad_out(1)
915 real(kind_lake) :: qflx_evap_tot(1)
916 real(kind_lake) :: qflx_evap_soi(1)
917 real(kind_lake) :: qflx_prec_grnd(1)
918 real(kind_lake) :: forc_snow(1)
919 real(kind_lake) :: forc_rain(1)
920 real(kind_lake) :: ws(1)
921 real(kind_lake) :: ks(1)
922 real(kind_lake) :: qflx_snomelt(1)
923 integer :: imelt(1,-nlevsnow+1:nlevsoil)
924 real(kind_lake) :: endwb(1)
925 real(kind_lake) :: snowage(1)
926 real(kind_lake) :: snowice(1)
927 real(kind_lake) :: snowliq(1)
928 real(kind_lake) :: t_snow(1)
929 real(kind_lake) :: qflx_drain(1)
930 real(kind_lake) :: qflx_surf(1)
931 real(kind_lake) :: qflx_infl(1)
932 real(kind_lake) :: qflx_qrgwl(1)
933 real(kind_lake) :: qcharge(1)
934 real(kind_lake) :: qflx_snowcap(1)
935 real(kind_lake) :: qflx_snowcap_col(1)
936 real(kind_lake) :: qflx_snow_grnd_pft(1)
937 real(kind_lake) :: qflx_snow_grnd_col(1)
938 real(kind_lake) :: qflx_rain_grnd(1)
939 real(kind_lake) :: frac_iceold(1,-nlevsnow+1:nlevsoil)
940 real(kind_lake) :: qflx_evap_tot_col(1)
941 real(kind_lake) :: soilalpha(1)
942 real(kind_lake) :: zwt(1)
943 real(kind_lake) :: fcov(1)
944 real(kind_lake) :: rootr_column(1,1:nlevsoil)
945 real(kind_lake) :: qflx_evap_grnd(1)
946 real(kind_lake) :: qflx_sub_snow(1)
947 real(kind_lake) :: qflx_dew_snow(1)
948 real(kind_lake) :: qflx_dew_grnd(1)
949 real(kind_lake) :: qflx_rain_grnd_col(1)
954 if (prec(1)> 0.)
then
955 if ( forc_t(1) > (tfrz + tcrit))
then
956 forc_rain(1) = prec(1)
961 forc_snow(1) = prec(1)
976 CALL shallakefluxes(forc_t,forc_pbot,forc_psrf,forc_hgt,forc_hgt_q, &
977 forc_hgt_t,forc_hgt_u,forc_q, &
978 forc_u,forc_v,forc_lwrad,forc_snow, &
979 forc_rain,t_grnd,h2osno,snowdp,sabg,lat, &
980 dz,dz_lake,t_soisno,t_lake,snl,h2osoi_liq, &
981 h2osoi_ice,savedtke1, &
982 qflx_prec_grnd,qflx_evap_soi,qflx_evap_tot, &
983 eflx_sh_grnd,eflx_lwrad_out,eflx_lwrad_net, &
984 eflx_soil_grnd,eflx_sh_tot,eflx_lh_tot, &
985 eflx_lh_grnd,t_veg,t_ref2m,q_ref2m,taux,tauy, &
986 ram1,ws,ks,eflx_gnet,z0mg,ustar_out,errmsg,errflg,xlat_d,xlon_d)
991 CALL shallaketemperature(t_grnd,h2osno,sabg,dz,dz_lake,z,zi, &
992 z_lake,ws,ks,snl,eflx_gnet,lakedepth, &
993 lake_icefrac,snowdp, &
994 eflx_sh_grnd,eflx_sh_tot,eflx_soil_grnd, &
995 t_lake,t_soisno,h2osoi_liq, &
996 h2osoi_ice,savedtke1, &
997 watsat, tksatu, tkmg, tkdry, csol, dtime, &
998 frac_iceold,qflx_snomelt,imelt,errmsg,errflg,xlat_d,xlon_d)
1003 CALL shallakehydrology(dz_lake,forc_rain,forc_snow, &
1004 begwb,qflx_evap_tot,forc_t,do_capsnow, &
1005 t_grnd,qflx_evap_soi, &
1006 qflx_snomelt,imelt,frac_iceold, &
1007 z,dz,zi,snl,h2osno,snowdp,lake_icefrac,t_lake, &
1008 endwb,snowage,snowice,snowliq,t_snow, &
1009 t_soisno,h2osoi_ice,h2osoi_liq,h2osoi_vol, &
1010 qflx_drain,qflx_surf,qflx_infl,qflx_qrgwl, &
1011 qcharge,qflx_prec_grnd,qflx_snowcap, &
1012 qflx_snowcap_col,qflx_snow_grnd_pft, &
1013 qflx_snow_grnd_col,qflx_rain_grnd, &
1014 qflx_evap_tot_col,soilalpha,zwt,fcov, &
1015 rootr_column,qflx_evap_grnd,qflx_sub_snow, &
1016 qflx_dew_snow,qflx_dew_grnd,qflx_rain_grnd_col, &
1017 watsat, tksatu, tkmg, tkdry, csol, &
1018 dtime,errmsg,errflg)
1038SUBROUTINE shallakefluxes(forc_t,forc_pbot,forc_psrf,forc_hgt,forc_hgt_q, & !i
1039 forc_hgt_t,forc_hgt_u,forc_q, &
1040 forc_u,forc_v,forc_lwrad,forc_snow, &
1041 forc_rain,t_grnd,h2osno,snowdp,sabg,lat, &
1042 dz,dz_lake,t_soisno,t_lake,snl,h2osoi_liq, &
1043 h2osoi_ice,savedtke1, &
1044 qflx_prec_grnd,qflx_evap_soi,qflx_evap_tot, & !o
1045 eflx_sh_grnd,eflx_lwrad_out,eflx_lwrad_net, &
1046 eflx_soil_grnd,eflx_sh_tot,eflx_lh_tot, &
1047 eflx_lh_grnd,t_veg,t_ref2m,q_ref2m,taux,tauy, &
1048 ram1,ws,ks,eflx_gnet,z0mg,ustar_out,errmsg,errflg,xlat_d,xlon_d)
1062 integer,
intent(inout) :: errflg
1063 character(len=*),
intent(inout) :: errmsg
1064 real(kind_lake),
intent(in) :: xlat_d,xlon_d
1065 real(kind_lake),
intent(in) :: forc_t(1)
1066 real(kind_lake),
intent(in) :: forc_pbot(1)
1067 real(kind_lake),
intent(in) :: forc_psrf(1)
1068 real(kind_lake),
intent(in) :: forc_hgt(1)
1069 real(kind_lake),
intent(in) :: forc_hgt_q(1)
1070 real(kind_lake),
intent(in) :: forc_hgt_t(1)
1071 real(kind_lake),
intent(in) :: forc_hgt_u(1)
1072 real(kind_lake),
intent(in) :: forc_q(1)
1073 real(kind_lake),
intent(in) :: forc_u(1)
1074 real(kind_lake),
intent(in) :: forc_v(1)
1075 real(kind_lake),
intent(in) :: forc_lwrad(1)
1077 real(kind_lake),
intent(in) :: forc_snow(1)
1078 real(kind_lake),
intent(in) :: forc_rain(1)
1079 real(kind_lake),
intent(in) :: h2osno(1)
1080 real(kind_lake),
intent(in) :: snowdp(1)
1081 real(kind_lake),
intent(in) :: sabg(1)
1082 real(kind_lake),
intent(in) :: lat(1)
1083 real(kind_lake),
intent(in) :: dz(1,-nlevsnow+1:nlevsoil)
1084 real(kind_lake),
intent(in) :: dz_lake(1,nlevlake)
1085 real(kind_lake),
intent(in) :: t_soisno(1,-nlevsnow+1:nlevsoil)
1086 real(kind_lake),
intent(in) :: t_lake(1,nlevlake)
1087 integer ,
intent(in) :: snl(1)
1088 real(kind_lake),
intent(in) :: h2osoi_liq(1,-nlevsnow+1:nlevsoil)
1089 real(kind_lake),
intent(in) :: h2osoi_ice(1,-nlevsnow+1:nlevsoil)
1090 real(kind_lake),
intent(in) :: savedtke1(1)
1093 real(kind_lake),
intent(inout) :: t_grnd(1)
1095 real(kind_lake),
intent(out):: ustar_out(1)
1096 real(kind_lake),
intent(out):: qflx_prec_grnd(1)
1097 real(kind_lake),
intent(out):: qflx_evap_soi(1)
1098 real(kind_lake),
intent(out):: qflx_evap_tot(1)
1099 real(kind_lake),
intent(out):: eflx_sh_grnd(1)
1100 real(kind_lake),
intent(out):: eflx_lwrad_out(1)
1101 real(kind_lake),
intent(out):: eflx_lwrad_net(1)
1102 real(kind_lake),
intent(out):: eflx_soil_grnd(1)
1103 real(kind_lake),
intent(out):: eflx_sh_tot(1)
1104 real(kind_lake),
intent(out):: eflx_lh_tot(1)
1105 real(kind_lake),
intent(out):: eflx_lh_grnd(1)
1106 real(kind_lake),
intent(out):: t_veg(1)
1107 real(kind_lake),
intent(out):: t_ref2m(1)
1108 real(kind_lake),
intent(out):: q_ref2m(1)
1109 real(kind_lake),
intent(out):: taux(1)
1110 real(kind_lake),
intent(out):: tauy(1)
1111 real(kind_lake),
intent(out):: ram1(1)
1112 real(kind_lake),
intent(out):: ws(1)
1113 real(kind_lake),
intent(out):: ks(1)
1115 real(kind_lake),
intent(out):: eflx_gnet(1)
1117 real(kind_lake),
intent(out):: z0mg(1)
1123 integer ,
parameter :: islak = 2
1124 integer ,
parameter :: niters = 3
1125 real(kind_lake),
parameter :: beta1 = 1._kind_lake
1126 real(kind_lake),
parameter :: emg = 0.97_kind_lake
1127 real(kind_lake),
parameter :: zii = 1000._kind_lake
1128 real(kind_lake),
parameter :: tdmax = 277._kind_lake
1129 real(kind_lake) :: forc_th(1)
1130 real(kind_lake) :: forc_vp(1)
1131 real(kind_lake) :: forc_rho(1)
1132 integer :: i,fc,fp,g,c,p
1135 integer :: fpcopy(num_shlakep)
1137 integer :: nmozsgn(lbp:ubp)
1138 integer :: jtop(lbc:ubc)
1139 real(kind_lake) :: ax
1140 real(kind_lake) :: bx
1141 real(kind_lake) :: degdT
1142 real(kind_lake) :: dqh(lbp:ubp)
1143 real(kind_lake) :: dth(lbp:ubp)
1144 real(kind_lake) :: dthv
1145 real(kind_lake) :: dzsur(lbc:ubc)
1146 real(kind_lake) :: eg
1147 real(kind_lake) :: htvp(lbc:ubc)
1148 real(kind_lake) :: obu(lbp:ubp)
1149 real(kind_lake) :: obuold(lbp:ubp)
1150 real(kind_lake) :: qsatg(lbc:ubc)
1151 real(kind_lake) :: qsatgdT(lbc:ubc)
1152 real(kind_lake) :: qstar
1153 real(kind_lake) :: ram(lbp:ubp)
1154 real(kind_lake) :: rah(lbp:ubp)
1155 real(kind_lake) :: raw(lbp:ubp)
1156 real(kind_lake) :: stftg3(lbp:ubp)
1157 real(kind_lake) :: temp1(lbp:ubp)
1158 real(kind_lake) :: temp12m(lbp:ubp)
1159 real(kind_lake) :: temp2(lbp:ubp)
1160 real(kind_lake) :: temp22m(lbp:ubp)
1161 real(kind_lake) :: tgbef(lbc:ubc)
1162 real(kind_lake) :: thm(lbc:ubc)
1163 real(kind_lake) :: thv(lbc:ubc)
1164 real(kind_lake) :: thvstar
1165 real(kind_lake) :: tksur
1166 real(kind_lake) :: tsur
1167 real(kind_lake) :: tstar
1168 real(kind_lake) :: um(lbp:ubp)
1169 real(kind_lake) :: ur(lbp:ubp)
1170 real(kind_lake) :: ustar(lbp:ubp)
1171 real(kind_lake) :: wc
1172 real(kind_lake) :: zeta
1173 real(kind_lake) :: zldis(lbp:ubp)
1174 real(kind_lake) :: displa(lbp:ubp)
1176 real(kind_lake) :: z0hg(lbp:ubp)
1177 real(kind_lake) :: z0qg(lbp:ubp)
1178 real(kind_lake) :: u2m
1179 real(kind_lake) :: u10(1)
1180 real(kind_lake) :: fv(1)
1182 real(kind_lake) :: fm(lbp:ubp)
1183 real(kind_lake) :: bw
1184 real(kind_lake) :: t_grnd_temp
1185 real(kind_lake) :: betaprime(lbc:ubc)
1186 character*256 :: message
1188 real(kind_lake) :: tc, visc, ren
1195 real(kind_lake),
parameter :: beta(2) = &
1196 (/0.4_kind_lake, 0.4_kind_lake/)
1206 forc_th(1) = forc_t(1) * (forc_psrf(1)/ forc_pbot(1))**(rair/cpair)
1207 forc_vp(1) = forc_q(1) * forc_pbot(1)/ (con_eps + one_minus_con_eps * forc_q(1))
1208 forc_rho(1) = (forc_pbot(1) - one_minus_con_eps * forc_vp(1)) / (rair * forc_t(1))
1210 do fc = 1, num_shlakec
1211 c = filter_shlakec(fc)
1217 if (snl(c) > 0 .or. snl(c) < -5)
then
1218 errmsg=
'snl is not defined in ShalLakeFluxesMod; snl: out of range value'
1226 jtop(c) = snl(c) + 1
1229 if (snl(c) < 0)
then
1230 betaprime(c) = 1._kind_lake
1231 dzsur(c) = dz(c,jtop(c))*0.5_kind_lake
1233 betaprime(c) = beta(islak)
1234 dzsur(c) = dz_lake(c,1)*0.5_kind_lake
1241 call qsat(t_grnd(c), forc_pbot(g), eg, degdt, qsatg(c), qsatgdt(c))
1246 thm(c) = forc_t(g) + 0.0098_kind_lake*forc_hgt_t(g)
1247 thv(c) = forc_th(g)*(1._kind_lake+con_fvirt*forc_q(g))
1252 do fp = 1, num_shlakep
1253 p = filter_shlakep(fp)
1258 obuold(p) = 0._kind_lake
1259 displa(p) = 0._kind_lake
1273 if (t_grnd(c) >= tfrz)
then
1274 z0mg(p) = 0.001_kind_lake
1275 else if(snl(c) == 0 )
then
1278 z0mg(p) = 0.005_kind_lake
1280 z0mg(p) = 0.0024_kind_lake
1288 tc=forc_t(g)-273.15_kind_lake
1289 visc=1.326e-5_kind_lake*(1._kind_lake + 6.542e-3_kind_lake*tc + 8.301e-6_kind_lake*tc*tc &
1290 - 4.84e-9_kind_lake*tc*tc*tc)
1291 visc=max(1e-7_kind_lake, visc)
1293 ren = max(ustar(p)*z0mg(p)/visc, 0.1_kind_lake)
1294 z0hg(p) = (5.5e-5_kind_lake)*(ren**(-0.60_kind_lake))
1296 z0hg(p) = min(z0hg(p),1.0e-4_kind_lake)
1297 z0hg(p) = max(z0hg(p),2.0e-9_kind_lake)
1311 if (t_grnd(c) > tfrz)
then
1323 ur(p) = max(1.0_kind_lake,sqrt(forc_u(g)*forc_u(g)+forc_v(g)*forc_v(g)))
1324 dth(p) = thm(c)-t_grnd(c)
1325 dqh(p) = forc_q(g)-qsatg(c)
1326 dthv = dth(p)*(1._kind_lake+con_fvirt*forc_q(g))+con_fvirt*forc_th(g)*dqh(p)
1327 zldis(p) = forc_hgt_u(g) - 0._kind_lake
1331 call moninobukini(ur(p), thv(c), dthv, zldis(p), z0mg(p), um(p), obu(p))
1336 fncopy = num_shlakep
1337 fpcopy(1:num_shlakep) = filter_shlakep(1:num_shlakep)
1341 iteration :
do while (iter <= niters .and. fncopy > 0)
1346 call frictionvelocity(pgridcell,forc_hgt,forc_hgt_u, &
1347 forc_hgt_t,forc_hgt_q, &
1348 lbp, ubp, fncopy, fpcopy, &
1349 displa, z0mg, z0hg, z0qg, &
1350 obu, iter, ur, um, &
1351 ustar,temp1, temp2, temp12m, temp22m, &
1362 tgbef(c) = t_grnd(c)
1363 if (t_grnd(c) > tfrz .and. t_lake(c,1) > tfrz .and. snl(c) == 0)
then
1364 tksur = savedtke1(c)
1369 else if (snl(c) == 0)
then
1374 bw = (h2osoi_ice(c,jtop(c))+h2osoi_liq(c,jtop(c)))/dz(c,jtop(c))
1375 tksur = tkairc + (7.75e-5_kind_lake *bw + 1.105e-6_kind_lake*bw*bw)*(tkice-tkairc)
1376 tsur = t_soisno(c,jtop(c))
1381 ram(p) = 1._kind_lake/(ustar(p)*ustar(p)/um(p))
1382 rah(p) = 1._kind_lake/(temp1(p)*ustar(p))
1383 raw(p) = 1._kind_lake/(temp2(p)*ustar(p))
1388 stftg3(p) = emg*sb*tgbef(c)*tgbef(c)*tgbef(c)
1392 ax = betaprime(c)*sabg(p) + emg*forc_lwrad(g) + 3._kind_lake*stftg3(p)*tgbef(c) &
1393 + forc_rho(g)*cpair/rah(p)*thm(c) &
1394 - htvp(c)*forc_rho(g)/raw(p)*(qsatg(c)-qsatgdt(c)*tgbef(c) - forc_q(g)) &
1395 + tksur*tsur/dzsur(c)
1397 bx = 4._kind_lake*stftg3(p) + forc_rho(g)*cpair/rah(p) &
1398 + htvp(c)*forc_rho(g)/raw(p)*qsatgdt(c) + tksur/dzsur(c)
1403 if(.not.pergro)
then
1404 if (t_grnd(c) > tfrz)
then
1414 eflx_sh_grnd(p) = forc_rho(g)*cpair*(t_grnd(c)-thm(c))/rah(p)
1415 qflx_evap_soi(p) = forc_rho(g)*(qsatg(c)+qsatgdt(c)*(t_grnd(c)-tgbef(c))-forc_q(g))/raw(p)
1420 call qsat(t_grnd(c), forc_pbot(g), eg, degdt, qsatg(c), qsatgdt(c))
1422 dth(p)=thm(c)-t_grnd(c)
1423 dqh(p)=forc_q(g)-qsatg(c)
1425 tstar = temp1(p)*dth(p)
1426 qstar = temp2(p)*dqh(p)
1428 thvstar=tstar*(1._kind_lake+con_fvirt*forc_q(g)) + con_fvirt*forc_th(g)*qstar
1429 zeta=zldis(p)*vkc * grav*thvstar/(ustar(p)**2*thv(c))
1431 if (zeta >= 0._kind_lake)
then
1432 zeta = min(2._kind_lake,max(zeta,0.01_kind_lake))
1433 um(p) = max(ur(p),0.1_kind_lake)
1435 zeta = max(-100._kind_lake,min(zeta,-0.01_kind_lake))
1436 wc = beta1*(-grav*ustar(p)*thvstar*zii/thv(c))**0.333_kind_lake
1437 um(p) = sqrt(ur(p)*ur(p)+wc*wc)
1439 obu(p) = zldis(p)/zeta
1441 if (obuold(p)*obu(p) < 0._kind_lake) nmozsgn(p) = nmozsgn(p)+1
1448 if (iter <= niters )
then
1455 if (nmozsgn(p) < 3)
then
1466 do fp = 1, num_shlakep
1467 p = filter_shlakep(fp)
1481 if ( (h2osno(c) > 0.5_kind_lake .or. t_lake(c,1) <= tfrz) .and. t_grnd(c) > tfrz)
then
1482 t_grnd_temp = t_grnd(c)
1484 eflx_sh_grnd(p) = forc_rho(g)*cpair*(t_grnd(c)-thm(c))/rah(p)
1485 qflx_evap_soi(p) = forc_rho(g)*(qsatg(c)+qsatgdt(c)*(t_grnd(c)-t_grnd_temp) - forc_q(g))/raw(p)
1486 else if ( (t_lake(c,1) > t_grnd(c) .and. t_grnd(c) > tdmax) .or. &
1487 (t_lake(c,1) < t_grnd(c) .and. t_lake(c,1) > tfrz .and. t_grnd(c) < tdmax) )
then
1489 t_grnd_temp = t_grnd(c)
1490 t_grnd(c) = t_lake(c,1)
1491 eflx_sh_grnd(p) = forc_rho(g)*cpair*(t_grnd(c)-thm(c))/rah(p)
1492 qflx_evap_soi(p) = forc_rho(g)*(qsatg(c)+qsatgdt(c)*(t_grnd(c)-t_grnd_temp) - forc_q(g))/raw(p)
1496 if(.not.pergro)
then
1497 if (t_grnd(c) > tfrz)
then
1508 eflx_lwrad_out(p) = (1._kind_lake-emg)*forc_lwrad(g) + emg*sb*t_grnd(c)**4
1512 eflx_soil_grnd(p) = sabg(p) + forc_lwrad(g) - eflx_lwrad_out(p) - &
1513 eflx_sh_grnd(p) - htvp(c)*qflx_evap_soi(p)
1520 taux(p) = -forc_rho(g)*forc_u(g)/ram(p)
1521 tauy(p) = -forc_rho(g)*forc_v(g)/ram(p)
1523 eflx_sh_tot(p) = eflx_sh_grnd(p)
1524 qflx_evap_tot(p) = qflx_evap_soi(p)
1525 eflx_lh_tot(p) = htvp(c)*qflx_evap_soi(p)
1526 eflx_lh_grnd(p) = htvp(c)*qflx_evap_soi(p)
1527 if(debug_print)
then
15281604
format(
'CLM_Lake ShalLakeFluxes: c=',i0,
' sensible heat = ',f12.4,
' latent heat =',f12.4, &
1529 ' ground temp = ', f12.4,
' h2osno = ', f12.4,
' at xlat_d=',f10.3,
' xlon_d=',f10.3)
1530 print 1604, c, eflx_sh_tot(p), eflx_lh_tot(p), t_grnd(c), h2osno(c),xlat_d,xlon_d
1531 if (abs(eflx_sh_tot(p)) > 1500 .or. abs(eflx_lh_tot(p)) > 1500)
then
15323018
format(
'CLM_Lake ShalLakeFluxes: WARNING: SH=',f12.4,
' LH=',f12.4,
' at xlat_d=',f10.3,
' xlon_d=',f10.3)
1533 print 3018,eflx_sh_tot(p), eflx_lh_tot(p),xlat_d,xlon_d
1535 if (abs(eflx_sh_tot(p)) > 10000 .or. abs(eflx_lh_tot(p)) > 10000 &
1536 .or. abs(t_grnd(c)-288)>200 )
then
1537840
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)
1538 write(message,840) eflx_sh_tot(p),eflx_lh_tot(p),t_grnd(c),p,c,xlat_d,xlon_d
1541 write(0,
'(A)') trim(message)
1545 t_ref2m(p) = thm(c) + temp1(p)*dth(p)*(1._kind_lake/temp12m(p) - 1._kind_lake/temp1(p))
1548 q_ref2m(p) = forc_q(g) + temp2(p)*dqh(p)*(1._kind_lake/temp22m(p) - 1._kind_lake/temp2(p))
1558 eflx_gnet(p) = betaprime(c) * sabg(p) + forc_lwrad(g) - (eflx_lwrad_out(p) + &
1559 eflx_sh_tot(p) + eflx_lh_tot(p))
1567 u2m = max(0.1_kind_lake,ustar(p)/vkc*log(2._kind_lake/z0mg(p)))
1569 ws(c) = 1.2e-03_kind_lake * u2m
1570 ks(c) = 6.6_kind_lake*sqrt(abs(sin(lat(g))))*(u2m**(-1.84_kind_lake))
1581 do fp = 1, num_shlakep
1582 p = filter_shlakep(fp)
1588 t_veg(p) = t_grnd(c)
1589 eflx_lwrad_net(p) = eflx_lwrad_out(p) - forc_lwrad(g)
1590 qflx_prec_grnd(p) = forc_rain(g) + forc_snow(g)
1593 ustar_out(1) = ustar(1)
1598SUBROUTINE shallaketemperature(t_grnd,h2osno,sabg,dz,dz_lake,z,zi, & !i
1599 z_lake,ws,ks,snl,eflx_gnet,lakedepth, &
1600 lake_icefrac,snowdp, & !i&o
1601 eflx_sh_grnd,eflx_sh_tot,eflx_soil_grnd, & !o
1602 t_lake,t_soisno,h2osoi_liq, &
1603 h2osoi_ice,savedtke1, &
1604 watsat, tksatu, tkmg, tkdry, csol, dtime, &
1605 frac_iceold,qflx_snomelt,imelt,errmsg,errflg,xlat_d,xlon_d)
1693 real(kind_lake),
intent(in) :: xlat_d
1694 real(kind_lake),
intent(in) :: xlon_d
1695 integer,
intent(inout) :: errflg
1696 real(kind_lake),
intent(in) :: watsat(1,nlevsoil)
1697 real(kind_lake),
intent(in) :: tksatu(1,nlevsoil)
1698 real(kind_lake),
intent(in) :: tkmg(1,nlevsoil)
1699 real(kind_lake),
intent(in) :: tkdry(1,nlevsoil)
1700 real(kind_lake),
intent(in) :: csol(1,nlevsoil)
1701 character(*),
intent(inout) :: errmsg
1702 real(kind_lake),
intent(in) :: t_grnd(1)
1703 real(kind_lake),
intent(inout) :: h2osno(1)
1704 real(kind_lake),
intent(in) :: sabg(1)
1705 real(kind_lake),
intent(in) :: dz(1,-nlevsnow + 1:nlevsoil)
1706 real(kind_lake),
intent(in) :: dz_lake(1,nlevlake)
1707 real(kind_lake),
intent(in) :: z(1,-nlevsnow+1:nlevsoil)
1708 real(kind_lake),
intent(in) :: zi(1,-nlevsnow+0:nlevsoil)
1710 real(kind_lake),
intent(in) :: z_lake(1,nlevlake)
1711 real(kind_lake),
intent(in) :: ws(1)
1712 real(kind_lake),
intent(in) :: ks(1)
1714 integer ,
intent(in) :: snl(1)
1715 real(kind_lake),
intent(inout) :: eflx_gnet(1)
1716 real(kind_lake),
intent(in) :: lakedepth(1)
1719 real(kind_lake),
intent(inout) :: snowdp(1)
1720 real(kind_lake),
intent(in) :: dtime
1723 real(kind_lake),
intent(out) :: eflx_sh_grnd(1)
1724 real(kind_lake),
intent(out) :: eflx_sh_tot(1)
1725 real(kind_lake),
intent(out) :: eflx_soil_grnd(1)
1729 real(kind_lake),
intent(inout) :: t_lake(1,nlevlake)
1730 real(kind_lake),
intent(inout) :: t_soisno(1,-nlevsnow+1:nlevsoil)
1731 real(kind_lake),
intent(inout) :: h2osoi_liq(1,-nlevsnow+1:nlevsoil)
1732 real(kind_lake),
intent(inout) :: h2osoi_ice(1,-nlevsnow+1:nlevsoil)
1733 real(kind_lake),
intent(inout) :: lake_icefrac(1,nlevlake)
1734 real(kind_lake),
intent(out) :: savedtke1(1)
1735 real(kind_lake),
intent(out) :: frac_iceold(1,-nlevsnow+1:nlevsoil)
1736 real(kind_lake),
intent(out) :: qflx_snomelt(1)
1737 integer,
intent(out) :: imelt(1,-nlevsnow+1:nlevsoil)
1742 integer ,
parameter :: islak = 2
1743 real(kind_lake),
parameter :: p0 = 1._kind_lake
1744 integer :: i,j,fc,fp,g,c,p
1745 real(kind_lake) :: eta(2)
1746 real(kind_lake) :: cwat
1747 real(kind_lake) :: cice_eff
1749 real(kind_lake) :: cfus
1751 real(kind_lake) :: km
1752 real(kind_lake) :: tkice_eff
1753 real(kind_lake) :: a(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1754 real(kind_lake) :: b(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1755 real(kind_lake) :: c1(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1756 real(kind_lake) :: r(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1757 real(kind_lake) :: rhow(lbc:ubc,nlevlake)
1758 real(kind_lake) :: phi(lbc:ubc,nlevlake)
1759 real(kind_lake) :: kme(lbc:ubc,nlevlake)
1760 real(kind_lake) :: rsfin
1761 real(kind_lake) :: rsfout
1762 real(kind_lake) :: phi_soil(lbc:ubc)
1763 real(kind_lake) :: ri
1764 real(kind_lake) :: fin(lbc:ubc)
1765 real(kind_lake) :: ocvts(lbc:ubc)
1766 real(kind_lake) :: ncvts(lbc:ubc)
1767 real(kind_lake) :: ke
1768 real(kind_lake) :: zin
1769 real(kind_lake) :: zout
1770 real(kind_lake) :: drhodz
1771 real(kind_lake) :: n2
1772 real(kind_lake) :: num
1773 real(kind_lake) :: den
1774 real(kind_lake) :: tav_froz(lbc:ubc)
1775 real(kind_lake) :: tav_unfr(lbc:ubc)
1776 real(kind_lake) :: nav(lbc:ubc)
1777 real(kind_lake) :: phidum
1778 real(kind_lake) :: iceav(lbc:ubc)
1779 real(kind_lake) :: qav(lbc:ubc)
1780 integer :: jtop(lbc:ubc)
1781 real(kind_lake) :: cv (lbc:ubc,-nlevsnow+1:nlevsoil)
1782 real(kind_lake) :: tk (lbc:ubc,-nlevsnow+1:nlevsoil)
1784 real(kind_lake) :: cv_lake (lbc:ubc,1:nlevlake)
1785 real(kind_lake) :: tk_lake (lbc:ubc,1:nlevlake)
1786 real(kind_lake) :: cvx (lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1787 real(kind_lake) :: tkix(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1789 real(kind_lake) :: tx(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1790 real(kind_lake) :: tktopsoillay(lbc:ubc)
1791 real(kind_lake) :: fnx(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1792 real(kind_lake) :: phix(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1793 real(kind_lake) :: zx(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1794 real(kind_lake) :: dzm
1795 real(kind_lake) :: dzp
1797 real(kind_lake) :: factx(lbc:ubc,-nlevsnow+1:nlevlake+nlevsoil)
1798 real(kind_lake) :: t_lake_bef(lbc:ubc,1:nlevlake)
1799 real(kind_lake) :: t_soisno_bef(lbc:ubc,-nlevsnow+1:nlevsoil)
1800 real(kind_lake) :: lhabs(lbc:ubc)
1801 real(kind_lake) :: esum1(lbc:ubc)
1802 real(kind_lake) :: esum2(lbc:ubc)
1803 real(kind_lake) :: zsum(lbc:ubc)
1804 real(kind_lake) :: wsum(lbc:ubc)
1805 real(kind_lake) :: wsum_end(lbc:ubc)
1806 real(kind_lake) :: errsoi(1)
1807 real(kind_lake) :: eflx_snomelt(1)
1808 CHARACTER*256 :: message
1812 real(kind_lake),
parameter :: beta(2) = &
1813 (/0.4_kind_lake, 0.4_kind_lake/)
1814 real(kind_lake),
parameter :: za(2) = &
1815 (/0.6_kind_lake, 0.6_kind_lake/)
1829 cice_eff = cpice*denh2o
1832 tkice_eff = tkice * denice/denh2o
1839 do fc = 1, num_shlakec
1840 c = filter_shlakec(fc)
1844 ocvts(c) = 0._kind_lake
1845 ncvts(c) = 0._kind_lake
1846 esum1(c) = 0._kind_lake
1847 esum2(c) = 0._kind_lake
1856 do j = -nlevsnow+1,0
1859 do fc = 1, num_shlakec
1860 c = filter_shlakec(fc)
1861 if (j >= snl(c) + 1)
then
1862 frac_iceold(c,j) = h2osoi_ice(c,j)/(h2osoi_liq(c,j)+h2osoi_ice(c,j))
1871 do fc = 1, num_shlakec
1872 c = filter_shlakec(fc)
1873 if (j == 1) wsum(c) = 0._kind_lake
1874 wsum(c) = wsum(c) + h2osoi_ice(c,j) + h2osoi_liq(c,j)
1880 do fp = 1, num_shlakep
1881 p = filter_shlakep(fp)
1890 fin(c) = eflx_gnet(p)
1899 do fc = 1, num_shlakec
1900 c = filter_shlakec(fc)
1901 rhow(c,j) = (1._kind_lake - lake_icefrac(c,j)) * &
1902 1000._kind_lake*( 1.0_kind_lake - 1.9549e-05_kind_lake*(abs(t_lake(c,j)-277._kind_lake))**1.68_kind_lake ) &
1903 + lake_icefrac(c,j)*denice
1912 do j = 1, nlevlake-1
1916 do fc = 1, num_shlakec
1917 c = filter_shlakec(fc)
1918 drhodz = (rhow(c,j+1)-rhow(c,j)) / (z_lake(c,j+1)-z_lake(c,j))
1919 n2 = grav / rhow(c,j) * drhodz
1922 num = 40._kind_lake * n2 * (vkc*z_lake(c,j))**2
1923 den = max( (ws(c)**2) * exp(-2._kind_lake*ks(c)*z_lake(c,j)), 1.e-10_kind_lake )
1924 ri = ( -1._kind_lake + sqrt( max(1._kind_lake+num/den, 0._kind_lake) ) ) / 20._kind_lake
1925 if (t_grnd(c) > tfrz .and. t_lake(c,1) > tfrz .and. snl(c) == 0)
then
1928 if( t_lake(c,1) > 277.15_kind_lake )
then
1929 if (lakedepth(c) > 15.0 )
then
1930 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)
1932 ke = vkc*ws(c)*z_lake(c,j)/p0 * exp(-ks(c)*z_lake(c,j)) / (1._kind_lake+37._kind_lake*ri*ri)
1935 if (lakedepth(c) > 15.0 )
then
1936 if (lakedepth(c) > 150.0 )
then
1937 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)
1939 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)
1942 ke = vkc*ws(c)*z_lake(c,j)/p0 * exp(-ks(c)*z_lake(c,j)) / (1._kind_lake+37._kind_lake*ri*ri)
1947 tk_lake(c,j) = kme(c,j)*cwat
1953 tk_lake(c,j) = tkwat*tkice_eff / ( (1._kind_lake-lake_icefrac(c,j))*tkice_eff &
1954 + tkwat*lake_icefrac(c,j) )
1962 do fc = 1, num_shlakec
1963 c = filter_shlakec(fc)
1966 kme(c,nlevlake) = kme(c,nlevlake-1)
1968 if (t_grnd(c) > tfrz .and. t_lake(c,1) > tfrz .and. snl(c) == 0)
then
1969 tk_lake(c,j) = tk_lake(c,j-1)
1971 tk_lake(c,j) = tkwat*tkice_eff / ( (1._kind_lake-lake_icefrac(c,j))*tkice_eff &
1972 + tkwat*lake_icefrac(c,j) )
1976 savedtke1(c) = kme(c,1)*cwat
1978 jtop(c) = snl(c) + 1
1985 do fp = 1, num_shlakep
1986 p = filter_shlakep(fp)
1992 if(.not.use_etalake)
then
1993 eta(:) = 1.1925_kind_lake*lakedepth(c)**(-0.424)
1998 zin = z_lake(c,j) - 0.5_kind_lake*dz_lake(c,j)
1999 zout = z_lake(c,j) + 0.5_kind_lake*dz_lake(c,j)
2000 rsfin = exp( -eta(islak)*max( zin-za(islak),0._kind_lake ) )
2001 rsfout = exp( -eta(islak)*max( zout-za(islak),0._kind_lake ) )
2006 if (t_grnd(c) > tfrz .and. t_lake(c,1) > tfrz .and. snl(c) == 0)
then
2007 phidum = (rsfin-rsfout) * sabg(p) * (1._kind_lake-beta(islak))
2008 if (j == nlevlake)
then
2009 phi_soil(c) = rsfout * sabg(p) * (1._kind_lake-beta(islak))
2011 else if (j == 1 .and. snl(c) == 0)
then
2012 phidum = sabg(p) * (1._kind_lake-beta(islak))
2014 phidum = 0._kind_lake
2015 if (j == nlevlake) phi_soil(c) = 0._kind_lake
2028 do fc = 1, num_shlakec
2029 c = filter_shlakec(fc)
2031 cv_lake(c,j) = dz_lake(c,j) * (cwat*(1._kind_lake-lake_icefrac(c,j)) + cice_eff*lake_icefrac(c,j))
2036 call soilthermprop_lake (snl,dz,zi,z,t_soisno,h2osoi_liq,h2osoi_ice, &
2037 watsat, tksatu, tkmg, tkdry, csol, tk, cv, tktopsoillay,errmsg,errflg)
2050 do fc = 1, num_shlakec
2051 c = filter_shlakec(fc)
2054 ocvts(c) = ocvts(c) + cv_lake(c,j)*(t_lake(c,j)-tfrz) &
2055 + cfus*dz_lake(c,j)*(1._kind_lake-lake_icefrac(c,j))
2057 t_lake_bef(c,j) = t_lake(c,j)
2058 if(debug_print)
then
2059 if (abs(xlat_d-52.1152).lt.0.1 .and. &
2060 abs(xlon_d-260.405).lt.0.1)
then
2061 print *,
' ocvts(c) at xlat_d,xlon_d',xlat_d,xlon_d
2062 print *,
'j,dz_lake(c,j) ', j,dz_lake(c,j)
2063 print*,
'cv_lake(c,j),lake_icefrac(c,j),t_lake(c,j),cfus,ocvts(c)', &
2064 cv_lake(c,j),lake_icefrac(c,j),t_lake(c,j),cfus,ocvts(c)
2071 do j = -nlevsnow + 1, nlevsoil
2074 do fc = 1, num_shlakec
2075 c = filter_shlakec(fc)
2077 if (j >= jtop(c))
then
2079 ocvts(c) = ocvts(c) + cv(c,j)*(t_soisno(c,j)-tfrz) &
2080 + hfus*h2osoi_liq(c,j)
2082 if(debug_print)
then
2083 if (abs(xlat_d-52.1152).lt.0.1 .and. &
2084 abs(xlon_d-260.405).lt.0.1)
then
2085 print *,
' ocvts(c) at xlat_d,xlon_d',xlat_d,xlon_d
2086 print *,
' j,jtop(c)',j,jtop(c),
'h2osoi_liq(c,j) ',h2osoi_liq(c,j),
'h2osoi_ice(c,j)',h2osoi_ice(c,j)
2087 print *,
' cv(c,j),t_soisno(c,j),hfus,ocvts(c)',c,j,cv(c,j),t_soisno(c,j),hfus,ocvts(c)
2088 print *,
' h2osno(c)',h2osno(c)
2091 if (j == 1 .and. h2osno(c) > 0._kind_lake .and. j == jtop(c))
then
2092 ocvts(c) = ocvts(c) - h2osno(c)*hfus
2094 t_soisno_bef(c,j) = t_soisno(c,j)
2095 if(abs(t_soisno(c,j)-288) > 150)
then
209648
format(
'WARNING: At c=',i0,
' level=',i0,
' extreme t_soisno = ',f15.10)
2097 WRITE(message,48) c,j,t_soisno(c,j)
2100 write(0,
'(A)') trim(message)
2113 do j = -nlevsnow+1, nlevlake+nlevsoil
2117 do fc = 1,num_shlakec
2118 c = filter_shlakec(fc)
2120 jprime = j - nlevlake
2122 if (j >= jtop(c))
then
2126 phix(c,j) = 0._kind_lake
2127 tx(c,j) = t_soisno(c,j)
2128 else if (j <= nlevlake)
then
2129 zx(c,j) = z_lake(c,j)
2130 cvx(c,j) = cv_lake(c,j)
2131 phix(c,j) = phi(c,j)
2132 tx(c,j) = t_lake(c,j)
2134 zx(c,j) = zx(c,nlevlake) + dz_lake(c,nlevlake)*0.5_kind_lake + z(c,jprime)
2135 cvx(c,j) = cv(c,jprime)
2136 if (j == nlevlake + 1)
then
2137 phix(c,j) = phi_soil(c)
2139 phix(c,j) = 0._kind_lake
2141 tx(c,j) = t_soisno(c,jprime)
2150 do j = -nlevsnow+1, nlevlake+nlevsoil
2154 do fc = 1,num_shlakec
2155 c = filter_shlakec(fc)
2157 jprime = j - nlevlake
2159 if (j >= jtop(c))
then
2162 else if (j == 0)
then
2163 dzp = zx(c,j+1) - zx(c,j)
2164 tkix(c,j) = tk_lake(c,1)*tk(c,j)*dzp / &
2165 (tk(c,j)*z_lake(c,1) + tk_lake(c,1)*(-z(c,j)) )
2167 else if (j < nlevlake)
then
2168 tkix(c,j) = ( tk_lake(c,j)*tk_lake(c,j+1) * (dz_lake(c,j+1)+dz_lake(c,j)) ) &
2169 / ( tk_lake(c,j)*dz_lake(c,j+1) + tk_lake(c,j+1)*dz_lake(c,j) )
2170 else if (j == nlevlake)
then
2171 dzp = zx(c,j+1) - zx(c,j)
2172 tkix(c,j) = (tktopsoillay(c)*tk_lake(c,j)*dzp / &
2173 (tktopsoillay(c)*dz_lake(c,j)*0.5_kind_lake + tk_lake(c,j)*z(c,1) ) )
2176 tkix(c,j) = tk(c,jprime)
2188 do j = -nlevsnow+1, nlevlake+nlevsoil
2192 do fc = 1,num_shlakec
2193 c = filter_shlakec(fc)
2194 if (j >= jtop(c))
then
2195 if (j < nlevlake+nlevsoil)
then
2196 factx(c,j) = dtime/cvx(c,j)
2197 fnx(c,j) = tkix(c,j)*(tx(c,j+1)-tx(c,j))/(zx(c,j+1)-zx(c,j))
2199 factx(c,j) = dtime/cvx(c,j)
2200 fnx(c,j) = 0._kind_lake
2206 do j = -nlevsnow+1,nlevlake+nlevsoil
2210 do fc = 1,num_shlakec
2211 c = filter_shlakec(fc)
2212 if (j >= jtop(c))
then
2213 if (j == jtop(c))
then
2214 dzp = zx(c,j+1)-zx(c,j)
2215 a(c,j) = 0._kind_lake
2216 b(c,j) = 1+(1._kind_lake-cnfac)*factx(c,j)*tkix(c,j)/dzp
2217 c1(c,j) = -(1._kind_lake-cnfac)*factx(c,j)*tkix(c,j)/dzp
2218 r(c,j) = tx(c,j) + factx(c,j)*( fin(c) + phix(c,j) + cnfac*fnx(c,j) )
2219 else if (j < nlevlake+nlevsoil)
then
2220 dzm = (zx(c,j)-zx(c,j-1))
2221 dzp = (zx(c,j+1)-zx(c,j))
2222 a(c,j) = - (1._kind_lake-cnfac)*factx(c,j)* tkix(c,j-1)/dzm
2223 b(c,j) = 1._kind_lake+ (1._kind_lake-cnfac)*factx(c,j)*(tkix(c,j)/dzp + tkix(c,j-1)/dzm)
2224 c1(c,j) = - (1._kind_lake-cnfac)*factx(c,j)* tkix(c,j)/dzp
2225 r(c,j) = tx(c,j) + cnfac*factx(c,j)*( fnx(c,j) - fnx(c,j-1) ) + factx(c,j)*phix(c,j)
2227 dzm = (zx(c,j)-zx(c,j-1))
2228 a(c,j) = - (1._kind_lake-cnfac)*factx(c,j)*tkix(c,j-1)/dzm
2229 b(c,j) = 1._kind_lake+ (1._kind_lake-cnfac)*factx(c,j)*tkix(c,j-1)/dzm
2230 c1(c,j) = 0._kind_lake
2231 r(c,j) = tx(c,j) - cnfac*factx(c,j)*fnx(c,j-1)
2241 call tridiagonal(lbc, ubc, -nlevsnow + 1, nlevlake + nlevsoil, jtop, num_shlakec, filter_shlakec, &
2245 do j = -nlevsnow+1, nlevlake + nlevsoil
2248 do fc = 1, num_shlakec
2249 c = filter_shlakec(fc)
2251 jprime = j - nlevlake
2254 if (j >= jtop(c))
then
2256 t_soisno(c,j) = tx(c,j)
2257 else if (j <= nlevlake)
then
2258 t_lake(c,j) = tx(c,j)
2260 t_soisno(c,jprime) = tx(c,j)
2271 if_debug_energy:
if (lakedebug)
then
2275 do fc = 1, num_shlakec
2276 c = filter_shlakec(fc)
2278 esum1(c) = esum1(c) + (t_lake(c,j)-t_lake_bef(c,j))*cv_lake(c,j)
2279 esum2(c) = esum2(c) + (t_lake(c,j)-tfrz)*cv_lake(c,j)
2283 do j = -nlevsnow+1, nlevsoil
2286 do fc = 1, num_shlakec
2287 c = filter_shlakec(fc)
2289 if (j >= jtop(c))
then
2290 esum1(c) = esum1(c) + (t_soisno(c,j)-t_soisno_bef(c,j))*cv(c,j)
2291 esum2(c) = esum2(c) + (t_soisno(c,j)-tfrz)*cv(c,j)
2298 do fp = 1, num_shlakep
2299 p = filter_shlakep(fp)
2303 errsoi(c) = esum1(c)/dtime - eflx_soil_grnd(p)
2306 if(abs(errsoi(c)) > .001_kind_lake)
then
2307 WRITE( message,* )
'Primary soil energy conservation error in shlake &
2308 column during Tridiagonal Solution,',
'error (W/m^2):', c, errsoi(c)
2309 errmsg=trim(message)
2317 end if if_debug_energy
2322 call phasechange_lake (snl,h2osno,dz,dz_lake, &
2323 t_soisno,h2osoi_liq,h2osoi_ice, &
2324 lake_icefrac,t_lake, snowdp, &
2325 qflx_snomelt,eflx_snomelt,imelt, &
2337 if_debug_balance:
if (lakedebug)
then
2341 do fc = 1, num_shlakec
2342 c = filter_shlakec(fc)
2344 esum2(c) = esum2(c) - (t_lake(c,j)-tfrz)*cv_lake(c,j)
2348 do j = -nlevsnow+1, nlevsoil
2351 do fc = 1, num_shlakec
2352 c = filter_shlakec(fc)
2354 if (j >= jtop(c))
then
2355 esum2(c) = esum2(c) - (t_soisno(c,j)-tfrz)*cv(c,j)
2362 do fp = 1, num_shlakep
2363 p = filter_shlakep(fp)
2366 esum2(c) = esum2(c) - lhabs(c)
2367 errsoi(c) = esum2(c)/dtime
2368 if(abs(errsoi(c)) > 1.e-5_kind_lake)
then
2369 write(message,*)
'Primary soil energy conservation error in shlake column during Phase Change, error (W/m^2):', &
2371 errmsg=trim(message)
2382 do fc = 1, num_shlakec
2383 c = filter_shlakec(fc)
2384 if (j == 1) wsum_end(c) = 0._kind_lake
2385 wsum_end(c) = wsum_end(c) + h2osoi_ice(c,j) + h2osoi_liq(c,j)
2386 if (j == nlevsoil)
then
2387 if (abs(wsum(c)-wsum_end(c))>1.e-7_kind_lake)
then
2388 write(message,*)
'Soil water balance error during phase change in ShalLakeTemperature.', &
2389 'column, error (kg/m^2):', c, wsum_end(c)-wsum(c)
2390 errmsg=trim(message)
2398 endif if_debug_balance
2409 do fc = 1, num_shlakec
2410 c = filter_shlakec(fc)
2411 rhow(c,j) = (1._kind_lake - lake_icefrac(c,j)) * &
2412 1000._kind_lake*( 1.0_kind_lake - 1.9549e-05_kind_lake*(abs(t_lake(c,j)-277._kind_lake))**1.68_kind_lake ) &
2413 + lake_icefrac(c,j)*denice
2417 do j = 1, nlevlake-1
2420 do fc = 1, num_shlakec
2421 c = filter_shlakec(fc)
2422 qav(c) = 0._kind_lake
2423 nav(c) = 0._kind_lake
2424 iceav(c) = 0._kind_lake
2430 do fc = 1, num_shlakec
2431 c = filter_shlakec(fc)
2432 if (rhow(c,j) > rhow(c,j+1) .or. &
2433 (lake_icefrac(c,j) < 1._kind_lake .and. lake_icefrac(c,j+1) > 0._kind_lake) )
then
2434 if(debug_print)
then
2436 print *,
'Convective Ice Mixing in column ', c,
'lake_icefrac(c,j) ',lake_icefrac(c,j),lake_icefrac(c,j+1)
2439 qav(c) = qav(c) + dz_lake(c,i)*(t_lake(c,i)-tfrz) * &
2440 ((1._kind_lake - lake_icefrac(c,i))*cwat + lake_icefrac(c,i)*cice_eff)
2442 iceav(c) = iceav(c) + lake_icefrac(c,i)*dz_lake(c,i)
2443 nav(c) = nav(c) + dz_lake(c,i)
2450 do fc = 1, num_shlakec
2451 c = filter_shlakec(fc)
2452 if (rhow(c,j) > rhow(c,j+1) .or. &
2453 (lake_icefrac(c,j) < 1._kind_lake .and. lake_icefrac(c,j+1) > 0._kind_lake) )
then
2454 qav(c) = qav(c)/nav(c)
2455 iceav(c) = iceav(c)/nav(c)
2458 if (qav(c) > 0._kind_lake)
then
2459 tav_froz(c) = 0._kind_lake
2460 tav_unfr(c) = qav(c) / ((1._kind_lake - iceav(c))*cwat)
2461 else if (qav(c) < 0._kind_lake)
then
2462 tav_froz(c) = qav(c) / (iceav(c)*cice_eff)
2463 tav_unfr(c) = 0._kind_lake
2465 tav_froz(c) = 0._kind_lake
2466 tav_unfr(c) = 0._kind_lake
2474 do fc = 1, num_shlakec
2475 c = filter_shlakec(fc)
2476 if (nav(c) > 0._kind_lake)
then
2485 if (i == 1) zsum(c) = 0._kind_lake
2486 if ((zsum(c)+dz_lake(c,i))/nav(c) <= iceav(c))
then
2487 t_lake(c,i) = tav_froz(c) + tfrz
2491 else if (zsum(c)/nav(c) < iceav(c))
then
2493 lake_icefrac(c,i) = (iceav(c)*nav(c) - zsum(c)) / dz_lake(c,i)
2495 t_lake(c,i) = ( lake_icefrac(c,i)*tav_froz(c)*cice_eff &
2496 + (1._kind_lake - lake_icefrac(c,i))*tav_unfr(c)*cwat ) &
2497 / ( lake_icefrac(c,i)*cice_eff + (1-lake_icefrac(c,i))*cwat ) + tfrz
2500 lake_icefrac(c,i) = 0._kind_lake
2501 t_lake(c,i) = tav_unfr(c) + tfrz
2503 zsum(c) = zsum(c) + dz_lake(c,i)
2505 rhow(c,i) = (1._kind_lake - lake_icefrac(c,i)) * &
2506 1000._kind_lake*( 1.0_kind_lake - 1.9549e-05_kind_lake*(abs(t_lake(c,i)-277._kind_lake))**1.68_kind_lake ) &
2507 + lake_icefrac(c,i)*denice
2508 if (debug_print .and. lake_icefrac(c,j) > 0.)print *,
'rhow(c,i),lake_icefrac(c,i),t_lake(c,i)', &
2509 i,rhow(c,i),lake_icefrac(c,i),t_lake(c,i),denice
2521 do fc = 1, num_shlakec
2522 c = filter_shlakec(fc)
2524 cv_lake(c,j) = dz_lake(c,j) * (cwat*(1._kind_lake-lake_icefrac(c,j)) + cice_eff*lake_icefrac(c,j))
2525 if (debug_print .and. lake_icefrac(c,j) > 0.)
then
2526 print *,
'Lake Ice Fraction, c, level:', c, j, lake_icefrac(c,j)
2532 call soilthermprop_lake (snl,dz,zi,z,t_soisno,h2osoi_liq,h2osoi_ice, &
2533 watsat, tksatu, tkmg, tkdry, csol, tk, cv, tktopsoillay,errmsg,errflg)
2540 do fc = 1, num_shlakec
2541 c = filter_shlakec(fc)
2544 ncvts(c) = ncvts(c) + cv_lake(c,j)*(t_lake(c,j)-tfrz) &
2545 + cfus*dz_lake(c,j)*(1._kind_lake-lake_icefrac(c,j))
2547 fin(c) = fin(c) + phi(c,j)
2548 if(debug_print)
then
2549 if (abs(xlat_d-52.1152).lt.0.1 .and. &
2550 abs(xlon_d-260.405).lt.0.1)
then
2551 print *,
' ncvts(c) at xlat_d,xlon_d',xlat_d,xlon_d
2552 print *,
' new cv_lake(c,j),t_lake(c,j),cfus,lake_icefrac(c,j),ncvts(c),fin(c)', &
2553 j,cv_lake(c,j),t_lake(c,j),cfus,lake_icefrac(c,j),ncvts(c),fin(c)
2554 print *,
' new dz_lake(c,j),fin(c),phi(c,j)',c,dz_lake(c,j),fin(c),phi(c,j)
2560 do j = -nlevsnow + 1, nlevsoil
2563 do fc = 1, num_shlakec
2564 c = filter_shlakec(fc)
2566 if (j >= jtop(c))
then
2568 ncvts(c) = ncvts(c) + cv(c,j)*(t_soisno(c,j)-tfrz) &
2569 + hfus*h2osoi_liq(c,j)
2571 if(debug_print)
then
2572 if (abs(xlat_d-52.1152).lt.0.1 .and. &
2573 abs(xlon_d-260.405).lt.0.1)
then
2574 print *,
' ncvts(c) at xlat_d,xlon_d',xlat_d,xlon_d
2575 print *,
'new j,jtop(c)',j,jtop(c),
'h2osoi_liq(c,j) ',h2osoi_liq(c,j),
'h2osoi_ice(c,j)',h2osoi_ice(c,j)
2576 print *,
'new cv(c,j),t_soisno(c,j),hfus,ncvts(c)',c,j,cv(c,j),t_soisno(c,j),hfus,ncvts(c)
2577 print *,
'new h2osno(c)',h2osno(c)
2580 if (j == 1 .and. h2osno(c) > 0._kind_lake .and. j == jtop(c))
then
2581 ncvts(c) = ncvts(c) - h2osno(c)*hfus
2584 if (j == 1) fin(c) = fin(c) + phi_soil(c)
2591 do fp = 1, num_shlakep
2592 p = filter_shlakep(fp)
2594 errsoi(c) = (ncvts(c)-ocvts(c)) / dtime - fin(c)
2595 if(debug_print)
then
2596 if (abs(xlat_d-52.1152).lt.0.1 .and. &
2597 abs(xlon_d-260.405).lt.0.1)
then
2598 print *,
'xlat_d,xlon_d',xlat_d,xlon_d
2599 print *,
'errsoi(c),fin(c),ncvts(c),ocvts(c),dtime,lake_icefrac(c,:),h2osno(c)', &
2600 errsoi(c),fin(c),ncvts(c),ocvts(c),dtime,lake_icefrac(c,:),h2osno(c)
2603 if( .not.lakedebug )
then
2604 if (abs(errsoi(c)) < 10._kind_lake)
then
2605 eflx_sh_tot(p) = eflx_sh_tot(p) - errsoi(c)
2606 eflx_sh_grnd(p) = eflx_sh_grnd(p) - errsoi(c)
2607 eflx_soil_grnd(p) = eflx_soil_grnd(p) + errsoi(c)
2608 eflx_gnet(p) = eflx_gnet(p) + errsoi(c)
2609 if(debug_print)
then
2610 if (abs(errsoi(c)) > 1.e-1_kind_lake)
then
2611 print *,
'errsoi incorporated at xlat_d,xlon_d',xlat_d,xlon_d
2612 print *,
'errsoi incorporated into sensible heat in ShalLakeTemperature: c, (W/m^2):', c, errsoi(c)
2615 errsoi(c) = 0._kind_lake
2617 elseif ( lakedebug)
then
2618 if (abs(errsoi(c)) < 1._kind_lake)
then
2619 eflx_sh_tot(p) = eflx_sh_tot(p) - errsoi(c)
2620 eflx_sh_grnd(p) = eflx_sh_grnd(p) - errsoi(c)
2621 eflx_soil_grnd(p) = eflx_soil_grnd(p) + errsoi(c)
2622 eflx_gnet(p) = eflx_gnet(p) + errsoi(c)
2623 if (abs(errsoi(c)) > 1.e-1_kind_lake)
then
2624 print *,
'errsoi incorporated into sensible heat in ShalLakeTemperature: c, (W/m^2):', c, errsoi(c)
2626 errsoi(c) = 0._kind_lake
2628 print *,
'Soil Energy Balance Error at column, ', c,
'G, fintotal, column E tendency = ', &
2629 eflx_gnet(p), fin(c), (ncvts(c)-ocvts(c)) / dtime,
'xlat_d,xlon_d',xlat_d,xlon_d
2630 print *,
'errsoi(c),ncvts(c),ocvts(c)',errsoi(c),ncvts(c),ocvts(c),
'xlat_d,xlon_d',xlat_d,xlon_d
2631 print *,
'lake_icefrac(c,:),h2osno(c)', lake_icefrac(c,:),h2osno(c)
2632 print *,
't_lake(c,:),t_soisno(c,:)',t_lake(c,:),t_soisno(c,:)
2874 subroutine phasechange_lake (snl,h2osno,dz,dz_lake, & !i
2875 t_soisno,h2osoi_liq,h2osoi_ice, & !i&o
2876 lake_icefrac,t_lake, snowdp, & !i&o
2877 qflx_snomelt,eflx_snomelt,imelt, & !o
2894 integer ,
intent(in) :: snl(1)
2895 real(kind_lake),
intent(inout) :: h2osno(1)
2896 real(kind_lake),
intent(in) :: dz(1,-nlevsnow+1:nlevsoil)
2897 real(kind_lake),
intent(in) :: dz_lake(1,nlevlake)
2902 real(kind_lake),
intent(inout) :: snowdp(1)
2903 real(kind_lake),
intent(inout) :: t_soisno(1,-nlevsnow+1:nlevsoil)
2904 real(kind_lake),
intent(inout) :: h2osoi_liq(1,-nlevsnow+1:nlevsoil)
2905 real(kind_lake),
intent(inout) :: h2osoi_ice(1,-nlevsnow+1:nlevsoil)
2906 real(kind_lake),
intent(inout) :: lake_icefrac(1,nlevlake)
2907 real(kind_lake),
intent(inout) :: t_lake(1,nlevlake)
2910 real(kind_lake),
intent(out) :: qflx_snomelt(1)
2911 real(kind_lake),
intent(out) :: eflx_snomelt(1)
2912 integer,
intent(out) :: imelt(1,-nlevsnow+1:nlevsoil)
2914 real(kind_lake),
intent(inout) :: cv(lbc:ubc,-nlevsnow+1:nlevsoil)
2915 real(kind_lake),
intent(inout) :: cv_lake (lbc:ubc,1:nlevlake)
2916 real(kind_lake),
intent(out):: lhabs(lbc:ubc)
2923 real(kind_lake) :: heatavail
2924 real(kind_lake) :: heatrem
2925 real(kind_lake) :: melt
2926 real(kind_lake),
parameter :: smallnumber = 1.e-7_kind_lake
2927 logical :: dophasechangeflag
2934 do fc = 1,num_shlakec
2935 c = filter_shlakec(fc)
2937 qflx_snomelt(c) = 0._kind_lake
2938 eflx_snomelt(c) = 0._kind_lake
2939 lhabs(c) = 0._kind_lake
2942 do j = -nlevsnow+1,0
2945 do fc = 1,num_shlakec
2946 c = filter_shlakec(fc)
2948 if (j >= snl(c) + 1) imelt(c,j) = 0
2956 do fc = 1,num_shlakec
2957 c = filter_shlakec(fc)
2959 if (snl(c) == 0 .and. h2osno(c) > 0._kind_lake .and. t_lake(c,1) > tfrz)
then
2960 heatavail = (t_lake(c,1) - tfrz) * cv_lake(c,1)
2961 melt = min(h2osno(c), heatavail/hfus)
2962 heatrem = max(heatavail - melt*hfus, 0._kind_lake)
2964 t_lake(c,1) = tfrz + heatrem/(cv_lake(c,1))
2965 snowdp(c) = snowdp(c)*(1._kind_lake - melt/h2osno(c))
2966 h2osno(c) = h2osno(c) - melt
2967 lhabs(c) = lhabs(c) + melt*hfus
2968 qflx_snomelt(c) = qflx_snomelt(c) + melt
2970 if (h2osno(c) < smallnumber) h2osno(c) = 0._kind_lake
2971 if (snowdp(c) < smallnumber) snowdp(c) = 0._kind_lake
2980 do fc = 1,num_shlakec
2981 c = filter_shlakec(fc)
2983 dophasechangeflag = .false.
2984 if (t_lake(c,j) > tfrz .and. lake_icefrac(c,j) > 0._kind_lake)
then
2985 dophasechangeflag = .true.
2986 heatavail = (t_lake(c,j) - tfrz) * cv_lake(c,j)
2987 melt = min(lake_icefrac(c,j)*denh2o*dz_lake(c,j), heatavail/hfus)
2989 heatrem = max(heatavail - melt*hfus, 0._kind_lake)
2991 else if (t_lake(c,j) < tfrz .and. lake_icefrac(c,j) < 1._kind_lake)
then
2992 dophasechangeflag = .true.
2993 heatavail = (t_lake(c,j) - tfrz) * cv_lake(c,j)
2994 melt = max(-(1._kind_lake-lake_icefrac(c,j))*denh2o*dz_lake(c,j), heatavail/hfus)
2996 heatrem = min(heatavail - melt*hfus, 0._kind_lake)
3000 if (dophasechangeflag)
then
3001 lake_icefrac(c,j) = lake_icefrac(c,j) - melt/(denh2o*dz_lake(c,j))
3002 lhabs(c) = lhabs(c) + melt*hfus
3004 cv_lake(c,j) = cv_lake(c,j) + melt*(cpliq-cpice)
3005 t_lake(c,j) = tfrz + heatrem/cv_lake(c,j)
3007 if (lake_icefrac(c,j) > 1._kind_lake - smallnumber) lake_icefrac(c,j) = 1._kind_lake
3008 if (lake_icefrac(c,j) < smallnumber) lake_icefrac(c,j) = 0._kind_lake
3015 do j = -nlevsnow+1,nlevsoil
3018 do fc = 1,num_shlakec
3019 c = filter_shlakec(fc)
3020 dophasechangeflag = .false.
3022 if (j >= snl(c) + 1)
then
3024 if (t_soisno(c,j) > tfrz .and. h2osoi_ice(c,j) > 0._kind_lake)
then
3025 dophasechangeflag = .true.
3026 heatavail = (t_soisno(c,j) - tfrz) * cv(c,j)
3027 melt = min(h2osoi_ice(c,j), heatavail/hfus)
3028 heatrem = max(heatavail - melt*hfus, 0._kind_lake)
3032 qflx_snomelt(c) = qflx_snomelt(c) + melt
3034 else if (t_soisno(c,j) < tfrz .and. h2osoi_liq(c,j) > 0._kind_lake)
then
3035 dophasechangeflag = .true.
3036 heatavail = (t_soisno(c,j) - tfrz) * cv(c,j)
3037 melt = max(-h2osoi_liq(c,j), heatavail/hfus)
3038 heatrem = min(heatavail - melt*hfus, 0._kind_lake)
3042 qflx_snomelt(c) = qflx_snomelt(c) + melt
3049 if (dophasechangeflag)
then
3050 h2osoi_ice(c,j) = h2osoi_ice(c,j) - melt
3051 h2osoi_liq(c,j) = h2osoi_liq(c,j) + melt
3052 lhabs(c) = lhabs(c) + melt*hfus
3054 cv(c,j) = cv(c,j) + melt*(cpliq-cpice)
3055 t_soisno(c,j) = tfrz + heatrem/cv(c,j)
3057 if (h2osoi_ice(c,j) < smallnumber) h2osoi_ice(c,j) = 0._kind_lake
3058 if (h2osoi_liq(c,j) < smallnumber) h2osoi_liq(c,j) = 0._kind_lake
3068 do fc = 1,num_shlakec
3069 c = filter_shlakec(fc)
3070 eflx_snomelt(c) = qflx_snomelt(c)*hfus
3089 subroutine shallakehydrology(dz_lake,forc_rain,forc_snow, & !i
3090 begwb,qflx_evap_tot,forc_t,do_capsnow, &
3091 t_grnd,qflx_evap_soi, &
3092 qflx_snomelt,imelt,frac_iceold, & !i add by guhp
3093 z,dz,zi,snl,h2osno,snowdp,lake_icefrac,t_lake, & !i&o
3094 endwb,snowage,snowice,snowliq,t_snow, & !o
3095 t_soisno,h2osoi_ice,h2osoi_liq,h2osoi_vol, &
3096 qflx_drain,qflx_surf,qflx_infl,qflx_qrgwl, &
3097 qcharge,qflx_prec_grnd,qflx_snowcap, &
3098 qflx_snowcap_col,qflx_snow_grnd_pft, &
3099 qflx_snow_grnd_col,qflx_rain_grnd, &
3100 qflx_evap_tot_col,soilalpha,zwt,fcov, &
3101 rootr_column,qflx_evap_grnd,qflx_sub_snow, &
3102 qflx_dew_snow,qflx_dew_grnd,qflx_rain_grnd_col, &
3103 watsat, tksatu, tkmg, tkdry, csol, &
3104 dtime,errmsg,errflg)
3134 integer,
intent(inout) :: errflg
3135 character(*),
intent(inout) :: errmsg
3137 real(kind_lake) :: watsat(1,nlevsoil)
3138 real(kind_lake) :: tksatu(1,nlevsoil)
3139 real(kind_lake) :: tkmg(1,nlevsoil)
3140 real(kind_lake) :: tkdry(1,nlevsoil)
3141 real(kind_lake) :: csol(1,nlevsoil)
3145 real(kind_lake),
intent(in) :: dtime
3146 real(kind_lake),
intent(in) :: dz_lake(1,nlevlake)
3147 real(kind_lake),
intent(in) :: forc_rain(1)
3148 real(kind_lake),
intent(in) :: forc_snow(1)
3149 real(kind_lake),
intent(in) :: qflx_evap_tot(1)
3150 real(kind_lake),
intent(in) :: forc_t(1)
3154 logical ,
intent(in) :: do_capsnow(1)
3155 real(kind_lake),
intent(in) :: t_grnd(1)
3156 real(kind_lake),
intent(in) :: qflx_evap_soi(1)
3157 real(kind_lake),
intent(in) :: qflx_snomelt(1)
3158 integer,
intent(in) :: imelt(1,-nlevsnow+1:nlevsoil)
3162 real(kind_lake),
intent(inout) :: begwb(1)
3167 real(kind_lake),
intent(inout) :: z(1,-nlevsnow+1:nlevsoil)
3168 real(kind_lake),
intent(inout) :: dz(1,-nlevsnow+1:nlevsoil)
3169 real(kind_lake),
intent(inout) :: zi(1,-nlevsnow+0:nlevsoil)
3170 integer ,
intent(inout) :: snl(1)
3171 real(kind_lake),
intent(inout) :: h2osno(1)
3172 real(kind_lake),
intent(inout) :: snowdp(1)
3173 real(kind_lake),
intent(inout) :: lake_icefrac(1,nlevlake)
3174 real(kind_lake),
intent(inout) :: t_lake(1,nlevlake)
3176 real(kind_lake),
intent(inout) :: frac_iceold(1,-nlevsnow+1:nlevsoil)
3180 real(kind_lake),
intent(out) :: endwb(1)
3181 real(kind_lake),
intent(out) :: snowage(1)
3182 real(kind_lake),
intent(out) :: snowice(1)
3183 real(kind_lake),
intent(out) :: snowliq(1)
3184 real(kind_lake),
intent(out) :: t_snow(1)
3185 real(kind_lake),
intent(out) :: t_soisno(1,-nlevsnow+1:nlevsoil)
3186 real(kind_lake),
intent(out) :: h2osoi_ice(1,-nlevsnow+1:nlevsoil)
3187 real(kind_lake),
intent(out) :: h2osoi_liq(1,-nlevsnow+1:nlevsoil)
3188 real(kind_lake),
intent(out) :: h2osoi_vol(1,-nlevsnow+1:nlevsoil)
3189 real(kind_lake),
intent(out) :: qflx_drain(1)
3190 real(kind_lake),
intent(out) :: qflx_surf(1)
3191 real(kind_lake),
intent(out) :: qflx_infl(1)
3192 real(kind_lake),
intent(out) :: qflx_qrgwl(1)
3193 real(kind_lake),
intent(out) :: qcharge(1)
3194 real(kind_lake),
intent(out) :: qflx_prec_grnd(1)
3195 real(kind_lake),
intent(out) :: qflx_snowcap(1)
3196 real(kind_lake),
intent(out) :: qflx_snowcap_col(1)
3197 real(kind_lake),
intent(out) :: qflx_snow_grnd_pft(1)
3198 real(kind_lake),
intent(out) :: qflx_snow_grnd_col(1)
3199 real(kind_lake),
intent(out) :: qflx_rain_grnd(1)
3200 real(kind_lake),
intent(out) :: qflx_evap_tot_col(1)
3201 real(kind_lake) ,
intent(out) :: soilalpha(1)
3202 real(kind_lake),
intent(out) :: zwt(1)
3203 real(kind_lake),
intent(out) :: fcov(1)
3204 real(kind_lake),
intent(out) :: rootr_column(1,1:nlevsoil)
3205 real(kind_lake),
intent(out) :: qflx_evap_grnd(1)
3206 real(kind_lake),
intent(out) :: qflx_sub_snow(1)
3207 real(kind_lake),
intent(out) :: qflx_dew_snow(1)
3208 real(kind_lake),
intent(out) :: qflx_dew_grnd(1)
3209 real(kind_lake),
intent(out) :: qflx_rain_grnd_col(1)
3212 real(kind_lake),
pointer :: sucsat(:,:)
3213 real(kind_lake),
pointer :: bsw(:,:)
3214 real(kind_lake),
pointer :: bsw2(:,:)
3215 real(kind_lake),
pointer :: psisat(:,:)
3216 real(kind_lake),
pointer :: vwcsat(:,:)
3217 real(kind_lake),
pointer :: wf(:)
3218 real(kind_lake),
pointer :: soilpsi(:,:)
3222 integer :: p,fp,g,l,c,j,fc,jtop
3223 integer :: num_shlakesnowc
3224 integer :: filter_shlakesnowc(ubc-lbc+1)
3225 integer :: num_shlakenosnowc
3226 integer :: filter_shlakenosnowc(ubc-lbc+1)
3228 real(kind_lake) :: dz_snowf
3229 real(kind_lake) :: bifall
3230 real(kind_lake) :: fracsnow(lbp:ubp)
3231 real(kind_lake) :: fracrain(lbp:ubp)
3232 real(kind_lake) :: qflx_prec_grnd_snow(lbp:ubp)
3233 real(kind_lake) :: qflx_prec_grnd_rain(lbp:ubp)
3234 real(kind_lake) :: qflx_evap_soi_lim
3235 real(kind_lake) :: h2osno_temp
3236 real(kind_lake) :: sumsnowice(lbc:ubc)
3237 logical :: unfrozen(lbc:ubc)
3238 real(kind_lake) :: heatrem
3239 real(kind_lake) :: heatsum(lbc:ubc)
3240 real(kind_lake) :: qflx_top_soil(1)
3241 character*256 :: message
3243 real(kind_lake),
allocatable :: snow_water(:)
3252 do fc = 1, num_shlakec
3253 c = filter_shlakec(fc)
3254 begwb(c) = begwb(c) + h2osoi_ice(c,j) + h2osoi_liq(c,j)
3264 do fp = 1, num_shlakep
3265 p = filter_shlakep(fp)
3278 qflx_prec_grnd_snow(p) = forc_snow(g)
3279 qflx_prec_grnd_rain(p) = forc_rain(g)
3284 qflx_prec_grnd(p) = qflx_prec_grnd_snow(p) + qflx_prec_grnd_rain(p)
3286 if (do_capsnow(c))
then
3287 qflx_snowcap(p) = qflx_prec_grnd_snow(p) + qflx_prec_grnd_rain(p)
3288 qflx_snow_grnd_pft(p) = 0._kind_lake
3289 qflx_rain_grnd(p) = 0._kind_lake
3291 qflx_snowcap(p) = 0._kind_lake
3292 qflx_snow_grnd_pft(p) = qflx_prec_grnd_snow(p)
3293 qflx_rain_grnd(p) = qflx_prec_grnd_rain(p)
3296 qflx_snow_grnd_col(c) = qflx_snow_grnd_pft(p)
3297 qflx_rain_grnd_col(c) = qflx_rain_grnd(p)
3305 do fc = 1, num_shlakec
3306 c = filter_shlakec(fc)
3314 if (do_capsnow(c))
then
3315 dz_snowf = 0._kind_lake
3317 if (forc_t(g) > tfrz + 2._kind_lake)
then
3318 bifall=50._kind_lake + 1.7_kind_lake*(17.0_kind_lake)**1.5_kind_lake
3319 else if (forc_t(g) > tfrz - 15._kind_lake)
then
3320 bifall=50._kind_lake + 1.7_kind_lake*(forc_t(g) - tfrz + 15._kind_lake)**1.5_kind_lake
3322 bifall=50._kind_lake
3324 dz_snowf = qflx_snow_grnd_col(c)/bifall
3325 snowdp(c) = snowdp(c) + dz_snowf*dtime
3326 h2osno(c) = h2osno(c) + qflx_snow_grnd_col(c)*dtime
3341 if (snl(c) == 0 .and. qflx_snow_grnd_col(c) > 0.0_kind_lake .and. snowdp(c) >= 0.01_kind_lake)
then
3345 z(c,0) = -0.5_kind_lake*dz(c,0)
3347 snowage(c) = 0._kind_lake
3348 t_soisno(c,0) = min(tfrz, forc_t(g))
3349 h2osoi_ice(c,0) = h2osno(c)
3350 h2osoi_liq(c,0) = 0._kind_lake
3351 frac_iceold(c,0) = 1._kind_lake
3358 if (snl(c) < 0 .and. newnode == 0)
then
3359 h2osoi_ice(c,snl(c)+1) = h2osoi_ice(c,snl(c)+1)+dtime*qflx_snow_grnd_col(c)
3360 dz(c,snl(c)+1) = dz(c,snl(c)+1)+dz_snowf*dtime
3369 do fp = 1,num_shlakep
3370 p = filter_shlakep(fp)
3375 qflx_evap_grnd(c) = 0._kind_lake
3376 qflx_sub_snow(c) = 0._kind_lake
3377 qflx_dew_snow(c) = 0._kind_lake
3378 qflx_dew_grnd(c) = 0._kind_lake
3385 if (qflx_evap_soi(p) >= 0._kind_lake)
then
3390 qflx_evap_soi_lim = min(qflx_evap_soi(p), (h2osoi_liq(c,j)+h2osoi_ice(c,j))/dtime)
3391 if ((h2osoi_liq(c,j)+h2osoi_ice(c,j)) > 0._kind_lake)
then
3392 qflx_evap_grnd(c) = max(qflx_evap_soi_lim*(h2osoi_liq(c,j)/(h2osoi_liq(c,j)+h2osoi_ice(c,j))), 0._kind_lake)
3394 qflx_evap_grnd(c) = 0._kind_lake
3396 qflx_sub_snow(c) = qflx_evap_soi_lim - qflx_evap_grnd(c)
3398 if (t_grnd(c) < tfrz)
then
3399 qflx_dew_snow(c) = abs(qflx_evap_soi(p))
3401 qflx_dew_grnd(c) = abs(qflx_evap_soi(p))
3407 if (do_capsnow(c)) qflx_snowcap(p) = qflx_snowcap(p) + qflx_dew_snow(c) + qflx_dew_grnd(c)
3410 if (qflx_evap_soi(p) >= 0._kind_lake)
then
3413 qflx_sub_snow(c) = min(qflx_evap_soi(p), h2osno(c)/dtime)
3414 qflx_evap_grnd(c) = qflx_evap_soi(p) - qflx_sub_snow(c)
3416 if (t_grnd(c) < tfrz-0.1_kind_lake)
then
3417 qflx_dew_snow(c) = abs(qflx_evap_soi(p))
3419 qflx_dew_grnd(c) = abs(qflx_evap_soi(p))
3424 h2osno_temp = h2osno(c)
3425 if (do_capsnow(c))
then
3426 h2osno(c) = h2osno(c) - qflx_sub_snow(c)*dtime
3427 qflx_snowcap(p) = qflx_snowcap(p) + qflx_dew_snow(c) + qflx_dew_grnd(c)
3429 h2osno(c) = h2osno(c) + (-qflx_sub_snow(c)+qflx_dew_snow(c))*dtime
3431 if (h2osno_temp > 0._kind_lake)
then
3432 snowdp(c) = snowdp(c) * h2osno(c) / h2osno_temp
3434 snowdp(c) = h2osno(c)/snow_bd
3438 if (abs(h2osno(c)) < 1.e-10_kind_lake) h2osno(c) = 0._kind_lake
3440 h2osno(c) = max(h2osno(c), 0._kind_lake)
3445 qflx_snowcap_col(c) = qflx_snowcap(p)
3454 call buildsnowfilter(lbc, ubc, num_shlakec, filter_shlakec,snl, &
3455 num_shlakesnowc, filter_shlakesnowc, num_shlakenosnowc, filter_shlakenosnowc)
3459 call snowwater(lbc, ubc, num_shlakesnowc, filter_shlakesnowc, &
3460 num_shlakenosnowc, filter_shlakenosnowc, &
3461 snl,do_capsnow,qflx_snomelt,qflx_rain_grnd, &
3462 qflx_sub_snow,qflx_evap_grnd, &
3463 qflx_dew_snow,qflx_dew_grnd,dz,dtime, &
3464 h2osoi_ice,h2osoi_liq, &
3476 do fc = 1, num_shlakec
3477 c = filter_shlakec(fc)
3479 if (h2osoi_vol(c,j) < watsat(c,j))
then
3480 h2osoi_liq(c,j) = (watsat(c,j)*dz(c,j) - h2osoi_ice(c,j)/denice)*denh2o
3482 else if (h2osoi_liq(c,j) > watsat(c,j)*denh2o*dz(c,j))
then
3483 h2osoi_liq(c,j) = watsat(c,j)*denh2o*dz(c,j)
3495 call snowcompaction(lbc, ubc, num_shlakesnowc, filter_shlakesnowc, &
3496 snl,imelt,frac_iceold,t_soisno, &
3497 h2osoi_ice,h2osoi_liq,dtime, &
3502 call combinesnowlayers(lbc, ubc, &
3503 num_shlakesnowc, filter_shlakesnowc, &
3504 snl,h2osno,snowdp,dz,zi, &
3505 t_soisno,h2osoi_ice,h2osoi_liq, &
3511 call dividesnowlayers(lbc, ubc, &
3512 num_shlakesnowc, filter_shlakesnowc, &
3513 snl,dz,zi,t_soisno, &
3514 h2osoi_ice,h2osoi_liq, &
3520 do fc = 1, num_shlakesnowc
3521 c = filter_shlakesnowc(fc)
3522 h2osno(c) = 0._kind_lake
3524 do j = -nlevsnow+1,0
3525 do fc = 1, num_shlakesnowc
3526 c = filter_shlakesnowc(fc)
3527 if (j >= snl(c)+1)
then
3528 h2osno(c) = h2osno(c) + h2osoi_ice(c,j) + h2osoi_liq(c,j)
3542 do fc = 1, num_shlakec
3543 c = filter_shlakec(fc)
3545 if (t_lake(c,1) > tfrz .and. lake_icefrac(c,1) == 0._kind_lake .and. snl(c) < 0)
then
3546 unfrozen(c) = .true.
3548 unfrozen(c) = .false.
3552 do j = -nlevsnow+1,0
3555 do fc = 1, num_shlakec
3556 c = filter_shlakec(fc)
3558 if (unfrozen(c))
then
3559 if (j == -nlevsnow+1)
then
3560 sumsnowice(c) = 0._kind_lake
3561 heatsum(c) = 0._kind_lake
3563 if (j >= snl(c)+1)
then
3564 sumsnowice(c) = sumsnowice(c) + h2osoi_ice(c,j)
3565 heatsum(c) = heatsum(c) + h2osoi_ice(c,j)*cpice*(tfrz - t_soisno(c,j)) &
3566 + h2osoi_liq(c,j)*cpliq*(tfrz - t_soisno(c,j))
3574 do fc = 1, num_shlakec
3575 c = filter_shlakec(fc)
3577 if (unfrozen(c))
then
3578 heatsum(c) = heatsum(c) + sumsnowice(c)*hfus
3579 heatrem = (t_lake(c,1) - tfrz)*cpliq*denh2o*dz_lake(c,1) - heatsum(c)
3581 if (heatrem + denh2o*dz_lake(c,1)*hfus > 0._kind_lake)
then
3583 h2osno(c) = 0._kind_lake
3586 if (debug_print)
then
3587 print *,
'Snow layers removed above unfrozen lake for column, snowice:', &
3590 if (heatrem > 0._kind_lake)
then
3591 t_lake(c,1) = t_lake(c,1) - heatrem/(cpliq*denh2o*dz_lake(c,1))
3594 lake_icefrac(c,1) = -heatrem/(denh2o*dz_lake(c,1)*hfus)
3605 do fc = 1, num_shlakesnowc
3606 c = filter_shlakesnowc(fc)
3607 if (snl(c) == 0)
then
3608 snowage(c) = 0._kind_lake
3614 do j = -nlevsnow+1,0
3617 do fc = 1, num_shlakesnowc
3618 c = filter_shlakesnowc(fc)
3619 if (j <= snl(c) .and. snl(c) > -nlevsnow)
then
3620 h2osoi_ice(c,j) = 0._kind_lake
3621 h2osoi_liq(c,j) = 0._kind_lake
3622 t_soisno(c,j) = 0._kind_lake
3623 dz(c,j) = 0._kind_lake
3624 z(c,j) = 0._kind_lake
3625 zi(c,j-1) = 0._kind_lake
3632 call buildsnowfilter(lbc, ubc, num_shlakec, filter_shlakec, snl,&
3633 num_shlakesnowc, filter_shlakesnowc, num_shlakenosnowc, filter_shlakenosnowc)
3640 do fc = 1, num_shlakesnowc
3641 c = filter_shlakesnowc(fc)
3642 t_snow(c) = 0._kind_lake
3643 snowice(c) = 0._kind_lake
3644 snowliq(c) = 0._kind_lake
3648 do fc = 1, num_shlakenosnowc
3649 c = filter_shlakenosnowc(fc)
3655 do j = -nlevsnow+1, 0
3658 do fc = 1, num_shlakesnowc
3659 c = filter_shlakesnowc(fc)
3660 if (j >= snl(c)+1)
then
3661 t_snow(c) = t_snow(c) + t_soisno(c,j)
3662 snowice(c) = snowice(c) + h2osoi_ice(c,j)
3663 snowliq(c) = snowliq(c) + h2osoi_liq(c,j)
3672 do fc = 1, num_shlakec
3674 c = filter_shlakec(fc)
3675 if (snl(c) < 0) t_snow(c) = t_snow(c)/abs(snl(c))
3676 endwb(c) = h2osno(c)
3682 do fc = 1, num_shlakec
3683 c = filter_shlakec(fc)
3684 endwb(c) = endwb(c) + h2osoi_ice(c,j) + h2osoi_liq(c,j)
3685 h2osoi_vol(c,j) = h2osoi_liq(c,j)/(dz(c,j)*denh2o) + h2osoi_ice(c,j)/(dz(c,j)*denice)
3689 check_add_snow_water:
if(lakedebug)
then
3690 allocate(snow_water(lbc:ubc))
3692 do j = -nlevsnow+1,0
3695 do fc = 1, num_shlakec
3696 c = filter_shlakec(fc)
3699 if(j == jtop) snow_water(c) = 0._kind_lake
3701 snow_water(c) = snow_water(c) + h2osoi_ice(c,j) + h2osoi_liq(c,j)
3702 if(j == 0 .and. abs(snow_water(c)-h2osno(c))>1.e-7_kind_lake)
then
3703 write(message,*)
'h2osno does not equal sum of snow layers in ShalLakeHydrology:', &
3704 'column, h2osno, sum of snow layers =', c, h2osno(c), snow_water(c)
3707 write(0,
'(A)') trim(message)
3712 deallocate(snow_water)
3713 end if check_add_snow_water
3719 do fp = 1,num_shlakep
3720 p = filter_shlakep(fp)
3724 qflx_infl(c) = 0._kind_lake
3725 qflx_surf(c) = 0._kind_lake
3726 qflx_drain(c) = 0._kind_lake
3727 rootr_column(c,:) = spval
3728 soilalpha(c) = spval
3735 qflx_qrgwl(c) = forc_rain(g) + forc_snow(g) - qflx_evap_tot(p) - (endwb(c)-begwb(c))/dtime
3736 if (debug_print)
then
3737 print *,
'c, rain, snow, evap, endwb, begwb, qflx_qrgwl:', &
3738 c, forc_rain(g), forc_snow(g), qflx_evap_tot(p), endwb(c), begwb(c), qflx_qrgwl(c)
3742 qflx_evap_tot_col(c) = qflx_evap_tot(p)
4464 subroutine dividesnowlayers(lbc, ubc, & !i
4465 num_snowc, filter_snowc, & !i&o
4466 snl,dz,zi,t_soisno, & !i&o
4467 h2osoi_ice,h2osoi_liq, & !i&o
4487 integer,
intent(in) :: lbc, ubc
4491 integer,
intent(inout) :: num_snowc
4492 integer,
intent(inout) :: filter_snowc(ubc-lbc+1)
4493 integer ,
intent(inout) :: snl(1)
4494 real(kind_lake),
intent(inout) :: dz(1,-nlevsnow+1:nlevsoil)
4495 real(kind_lake),
intent(inout) :: zi(1,-nlevsnow+0:nlevsoil)
4496 real(kind_lake),
intent(inout) :: t_soisno(1,-nlevsnow+1:nlevsoil)
4497 real(kind_lake),
intent(inout) :: h2osoi_ice(1,-nlevsnow+1:nlevsoil)
4498 real(kind_lake),
intent(inout) :: h2osoi_liq(1,-nlevsnow+1:nlevsoil)
4502 real(kind_lake),
intent(out) :: z(1,-nlevsnow+1:nlevsoil)
4509 real(kind_lake) :: drr
4511 real(kind_lake) :: dzsno(lbc:ubc,nlevsnow)
4512 real(kind_lake) :: swice(lbc:ubc,nlevsnow)
4513 real(kind_lake) :: swliq(lbc:ubc,nlevsnow)
4514 real(kind_lake) :: tsno(lbc:ubc ,nlevsnow)
4515 real(kind_lake) :: zwice
4516 real(kind_lake) :: zwliq
4517 real(kind_lake) :: propor
4526 do fc = 1, num_snowc
4527 c = filter_snowc(fc)
4528 if (j <= abs(snl(c)))
then
4529 dzsno(c,j) = dz(c,j+snl(c))
4530 swice(c,j) = h2osoi_ice(c,j+snl(c))
4531 swliq(c,j) = h2osoi_liq(c,j+snl(c))
4532 tsno(c,j) = t_soisno(c,j+snl(c))
4539 do fc = 1, num_snowc
4540 c = filter_snowc(fc)
4546 if (dzsno(c,1) > 0.03)
then
4548 dzsno(c,1) = dzsno(c,1)*0.5
4549 swice(c,1) = swice(c,1)*0.5
4550 swliq(c,1) = swliq(c,1)*0.5
4551 dzsno(c,2) = dzsno(c,1)
4552 swice(c,2) = swice(c,1)
4553 swliq(c,2) = swliq(c,1)
4554 tsno(c,2) = tsno(c,1)
4559 if (dzsno(c,1) > 0.02)
then
4560 drr = dzsno(c,1) - 0.02
4561 propor = drr/dzsno(c,1)
4562 zwice = propor*swice(c,1)
4563 zwliq = propor*swliq(c,1)
4564 propor = 0.02/dzsno(c,1)
4565 swice(c,1) = propor*swice(c,1)
4566 swliq(c,1) = propor*swliq(c,1)
4569 call combo (dzsno(c,2), swliq(c,2), swice(c,2), tsno(c,2), drr, &
4570 zwliq, zwice, tsno(c,1))
4573 if (msno <= 2 .and. dzsno(c,2) > 0.07)
then
4575 dzsno(c,2) = dzsno(c,2)*0.5
4576 swice(c,2) = swice(c,2)*0.5
4577 swliq(c,2) = swliq(c,2)*0.5
4578 dzsno(c,3) = dzsno(c,2)
4579 swice(c,3) = swice(c,2)
4580 swliq(c,3) = swliq(c,2)
4581 tsno(c,3) = tsno(c,2)
4587 if (dzsno(c,2) > 0.05)
then
4588 drr = dzsno(c,2) - 0.05
4589 propor = drr/dzsno(c,2)
4590 zwice = propor*swice(c,2)
4591 zwliq = propor*swliq(c,2)
4592 propor = 0.05/dzsno(c,2)
4593 swice(c,2) = propor*swice(c,2)
4594 swliq(c,2) = propor*swliq(c,2)
4597 call combo (dzsno(c,3), swliq(c,3), swice(c,3), tsno(c,3), drr, &
4598 zwliq, zwice, tsno(c,2))
4601 if (msno <= 3 .and. dzsno(c,3) > 0.18)
then
4603 dzsno(c,3) = dzsno(c,3)*0.5
4604 swice(c,3) = swice(c,3)*0.5
4605 swliq(c,3) = swliq(c,3)*0.5
4606 dzsno(c,4) = dzsno(c,3)
4607 swice(c,4) = swice(c,3)
4608 swliq(c,4) = swliq(c,3)
4609 tsno(c,4) = tsno(c,3)
4615 if (dzsno(c,3) > 0.11)
then
4616 drr = dzsno(c,3) - 0.11
4617 propor = drr/dzsno(c,3)
4618 zwice = propor*swice(c,3)
4619 zwliq = propor*swliq(c,3)
4620 propor = 0.11/dzsno(c,3)
4621 swice(c,3) = propor*swice(c,3)
4622 swliq(c,3) = propor*swliq(c,3)
4625 call combo (dzsno(c,4), swliq(c,4), swice(c,4), tsno(c,4), drr, &
4626 zwliq, zwice, tsno(c,3))
4629 if (msno <= 4 .and. dzsno(c,4) > 0.41)
then
4631 dzsno(c,4) = dzsno(c,4)*0.5
4632 swice(c,4) = swice(c,4)*0.5
4633 swliq(c,4) = swliq(c,4)*0.5
4634 dzsno(c,5) = dzsno(c,4)
4635 swice(c,5) = swice(c,4)
4636 swliq(c,5) = swliq(c,4)
4637 tsno(c,5) = tsno(c,4)
4643 if (dzsno(c,4) > 0.23)
then
4644 drr = dzsno(c,4) - 0.23
4645 propor = drr/dzsno(c,4)
4646 zwice = propor*swice(c,4)
4647 zwliq = propor*swliq(c,4)
4648 propor = 0.23/dzsno(c,4)
4649 swice(c,4) = propor*swice(c,4)
4650 swliq(c,4) = propor*swliq(c,4)
4653 call combo (dzsno(c,5), swliq(c,5), swice(c,5), tsno(c,5), drr, &
4654 zwliq, zwice, tsno(c,4))
4662 do j = -nlevsnow+1,0
4665 do fc = 1, num_snowc
4666 c = filter_snowc(fc)
4667 if (j >= snl(c)+1)
then
4668 dz(c,j) = dzsno(c,j-snl(c))
4669 h2osoi_ice(c,j) = swice(c,j-snl(c))
4670 h2osoi_liq(c,j) = swliq(c,j-snl(c))
4671 t_soisno(c,j) = tsno(c,j-snl(c))
4676 do j = 0, -nlevsnow+1, -1
4679 do fc = 1, num_snowc
4680 c = filter_snowc(fc)
4681 if (j >= snl(c)+1)
then
4682 z(c,j) = zi(c,j) - 0.5*dz(c,j)
4683 zi(c,j-1) = zi(c,j) - dz(c,j)
4823subroutine frictionvelocity(pgridcell,forc_hgt,forc_hgt_u, & !i
4824 forc_hgt_t,forc_hgt_q, & !i
4825 lbp, ubp, fn, filterp, & !i
4826 displa, z0m, z0h, z0q, & !i
4827 obu, iter, ur, um, & !i
4828 ustar,temp1, temp2, temp12m, temp22m, & !o
4850 integer ,
intent(in) :: pgridcell(1)
4851 real(kind_lake),
intent(in) :: forc_hgt(1)
4852 real(kind_lake),
intent(in) :: forc_hgt_u(1)
4853 real(kind_lake),
intent(in) :: forc_hgt_t(1)
4854 real(kind_lake),
intent(in) :: forc_hgt_q(1)
4855 integer ,
intent(in) :: lbp, ubp
4856 integer ,
intent(in) :: fn
4857 integer ,
intent(in) :: filterp(fn)
4858 real(kind_lake),
intent(in) :: displa(lbp:ubp)
4859 real(kind_lake),
intent(in) :: z0m(lbp:ubp)
4860 real(kind_lake),
intent(in) :: z0h(lbp:ubp)
4861 real(kind_lake),
intent(in) :: z0q(lbp:ubp)
4862 real(kind_lake),
intent(in) :: obu(lbp:ubp)
4863 integer,
intent(in) :: iter
4864 real(kind_lake),
intent(in) :: ur(lbp:ubp)
4865 real(kind_lake),
intent(in) :: um(lbp:ubp)
4869 real(kind_lake),
intent(out) :: ustar(lbp:ubp)
4870 real(kind_lake),
intent(out) :: temp1(lbp:ubp)
4871 real(kind_lake),
intent(out) :: temp12m(lbp:ubp)
4872 real(kind_lake),
intent(out) :: temp2(lbp:ubp)
4873 real(kind_lake),
intent(out) :: temp22m(lbp:ubp)
4874 real(kind_lake),
intent(out) :: u10(1)
4875 real(kind_lake),
intent(out) :: fv(1)
4878 real(kind_lake),
intent(inout) :: fm(lbp:ubp)
4882 real(kind_lake),
parameter :: zetam = 1.574_kind_lake
4883 real(kind_lake),
parameter :: zetat = 0.465_kind_lake
4887 real(kind_lake):: zldis(lbp:ubp)
4888 real(kind_lake):: zeta(lbp:ubp)
4895 if_not_pergro:
if(.not.pergro)
then
4905 zldis(p) = forc_hgt_u(g)-displa(p)
4906 zeta(p) = zldis(p)/obu(p)
4907 if (zeta(p) < -zetam)
then
4908 ustar(p) = vkc*um(p)/(log(-zetam*obu(p)/z0m(p))&
4909 - stabilityfunc1(-zetam) &
4910 + stabilityfunc1(z0m(p)/obu(p)) &
4911 + 1.14_kind_lake*((-zeta(p))**0.333_kind_lake-(zetam)**0.333_kind_lake))
4912 else if (zeta(p) < 0._kind_lake)
then
4913 ustar(p) = vkc*um(p)/(log(zldis(p)/z0m(p))&
4914 - stabilityfunc1(zeta(p))&
4915 + stabilityfunc1(z0m(p)/obu(p)))
4916 else if (zeta(p) <= 1._kind_lake)
then
4917 ustar(p) = vkc*um(p)/(log(zldis(p)/z0m(p)) + 5._kind_lake*zeta(p) -5._kind_lake*z0m(p)/obu(p))
4919 ustar(p) = vkc*um(p)/(log(obu(p)/z0m(p))+5._kind_lake-5._kind_lake*z0m(p)/obu(p) &
4920 +(5._kind_lake*log(zeta(p))+zeta(p)-1._kind_lake))
4925 zldis(p) = forc_hgt_t(g)-displa(p)
4926 zeta(p) = zldis(p)/obu(p)
4927 if (zeta(p) < -zetat)
then
4928 temp1(p) = vkc/(log(-zetat*obu(p)/z0h(p))&
4929 - stabilityfunc2(-zetat) &
4930 + stabilityfunc2(z0h(p)/obu(p)) &
4931 + 0.8_kind_lake*((zetat)**(-0.333_kind_lake)-(-zeta(p))**(-0.333_kind_lake)))
4932 else if (zeta(p) < 0._kind_lake)
then
4933 temp1(p) = vkc/(log(zldis(p)/z0h(p)) &
4934 - stabilityfunc2(zeta(p)) &
4935 + stabilityfunc2(z0h(p)/obu(p)))
4936 else if (zeta(p) <= 1._kind_lake)
then
4937 temp1(p) = vkc/(log(zldis(p)/z0h(p)) + 5._kind_lake*zeta(p) - 5._kind_lake*z0h(p)/obu(p))
4939 temp1(p) = vkc/(log(obu(p)/z0h(p)) + 5._kind_lake - 5._kind_lake*z0h(p)/obu(p) &
4940 + (5._kind_lake*log(zeta(p))+zeta(p)-1._kind_lake))
4945 if (forc_hgt_q(g) == forc_hgt_t(g) .and. z0q(p) == z0h(p))
then
4948 zldis(p) = forc_hgt_q(g)-displa(p)
4949 zeta(p) = zldis(p)/obu(p)
4950 if (zeta(p) < -zetat)
then
4951 temp2(p) = vkc/(log(-zetat*obu(p)/z0q(p)) &
4952 - stabilityfunc2(-zetat) &
4953 + stabilityfunc2(z0q(p)/obu(p)) &
4954 + 0.8_kind_lake*((zetat)**(-0.333_kind_lake)-(-zeta(p))**(-0.333_kind_lake)))
4955 else if (zeta(p) < 0._kind_lake)
then
4956 temp2(p) = vkc/(log(zldis(p)/z0q(p)) &
4957 - stabilityfunc2(zeta(p)) &
4958 + stabilityfunc2(z0q(p)/obu(p)))
4959 else if (zeta(p) <= 1._kind_lake)
then
4960 temp2(p) = vkc/(log(zldis(p)/z0q(p)) + 5._kind_lake*zeta(p)-5._kind_lake*z0q(p)/obu(p))
4962 temp2(p) = vkc/(log(obu(p)/z0q(p)) + 5._kind_lake - 5._kind_lake*z0q(p)/obu(p) &
4963 + (5._kind_lake*log(zeta(p))+zeta(p)-1._kind_lake))
4969 zldis(p) = 2.0_kind_lake + z0h(p)
4970 zeta(p) = zldis(p)/obu(p)
4971 if (zeta(p) < -zetat)
then
4972 temp12m(p) = vkc/(log(-zetat*obu(p)/z0h(p))&
4973 - stabilityfunc2(-zetat) &
4974 + stabilityfunc2(z0h(p)/obu(p)) &
4975 + 0.8_kind_lake*((zetat)**(-0.333_kind_lake)-(-zeta(p))**(-0.333_kind_lake)))
4976 else if (zeta(p) < 0._kind_lake)
then
4977 temp12m(p) = vkc/(log(zldis(p)/z0h(p)) &
4978 - stabilityfunc2(zeta(p)) &
4979 + stabilityfunc2(z0h(p)/obu(p)))
4980 else if (zeta(p) <= 1._kind_lake)
then
4981 temp12m(p) = vkc/(log(zldis(p)/z0h(p)) + 5._kind_lake*zeta(p) - 5._kind_lake*z0h(p)/obu(p))
4983 temp12m(p) = vkc/(log(obu(p)/z0h(p)) + 5._kind_lake - 5._kind_lake*z0h(p)/obu(p) &
4984 + (5._kind_lake*log(zeta(p))+zeta(p)-1._kind_lake))
4989 if (z0q(p) == z0h(p))
then
4990 temp22m(p) = temp12m(p)
4992 zldis(p) = 2.0_kind_lake + z0q(p)
4993 zeta(p) = zldis(p)/obu(p)
4994 if (zeta(p) < -zetat)
then
4995 temp22m(p) = vkc/(log(-zetat*obu(p)/z0q(p)) - &
4996 stabilityfunc2(-zetat) + stabilityfunc2(z0q(p)/obu(p)) &
4997 + 0.8_kind_lake*((zetat)**(-0.333_kind_lake)-(-zeta(p))**(-0.333_kind_lake)))
4998 else if (zeta(p) < 0._kind_lake)
then
4999 temp22m(p) = vkc/(log(zldis(p)/z0q(p)) - &
5000 stabilityfunc2(zeta(p))+stabilityfunc2(z0q(p)/obu(p)))
5001 else if (zeta(p) <= 1._kind_lake)
then
5002 temp22m(p) = vkc/(log(zldis(p)/z0q(p)) + 5._kind_lake*zeta(p)-5._kind_lake*z0q(p)/obu(p))
5004 temp22m(p) = vkc/(log(obu(p)/z0q(p)) + 5._kind_lake - 5._kind_lake*z0q(p)/obu(p) &
5005 + (5._kind_lake*log(zeta(p))+zeta(p)-1._kind_lake))
5012if_pergro:
if (pergro)
then
5024 zldis(p) = forc_hgt_u(g)-displa(p)
5025 zeta(p) = zldis(p)/obu(p)
5026 if (zeta(p) < -zetam)
then
5027 ustar(p) = vkc * um(p) / log(-zetam*obu(p)/z0m(p))
5028 else if (zeta(p) < 0._kind_lake)
then
5029 ustar(p) = vkc * um(p) / log(zldis(p)/z0m(p))
5030 else if (zeta(p) <= 1._kind_lake)
then
5031 ustar(p)=vkc * um(p)/log(zldis(p)/z0m(p))
5033 ustar(p)=vkc * um(p)/log(obu(p)/z0m(p))
5036 zldis(p) = forc_hgt_t(g)-displa(p)
5037 zeta(p) = zldis(p)/obu(p)
5038 if (zeta(p) < -zetat)
then
5039 temp1(p)=vkc/log(-zetat*obu(p)/z0h(p))
5040 else if (zeta(p) < 0._kind_lake)
then
5041 temp1(p)=vkc/log(zldis(p)/z0h(p))
5042 else if (zeta(p) <= 1._kind_lake)
then
5043 temp1(p)=vkc/log(zldis(p)/z0h(p))
5045 temp1(p)=vkc/log(obu(p)/z0h(p))
5048 zldis(p) = forc_hgt_q(g)-displa(p)
5049 zeta(p) = zldis(p)/obu(p)
5050 if (zeta(p) < -zetat)
then
5051 temp2(p)=vkc/log(-zetat*obu(p)/z0q(p))
5052 else if (zeta(p) < 0._kind_lake)
then
5053 temp2(p)=vkc/log(zldis(p)/z0q(p))
5054 else if (zeta(p) <= 1._kind_lake)
then
5055 temp2(p)=vkc/log(zldis(p)/z0q(p))
5057 temp2(p)=vkc/log(obu(p)/z0q(p))
5060 zldis(p) = 2.0_kind_lake + z0h(p)
5061 zeta(p) = zldis(p)/obu(p)
5062 if (zeta(p) < -zetat)
then
5063 temp12m(p)=vkc/log(-zetat*obu(p)/z0h(p))
5064 else if (zeta(p) < 0._kind_lake)
then
5065 temp12m(p)=vkc/log(zldis(p)/z0h(p))
5066 else if (zeta(p) <= 1._kind_lake)
then
5067 temp12m(p)=vkc/log(zldis(p)/z0h(p))
5069 temp12m(p)=vkc/log(obu(p)/z0h(p))
5072 zldis(p) = 2.0_kind_lake + z0q(p)
5073 zeta(p) = zldis(p)/obu(p)
5074 if (zeta(p) < -zetat)
then
5075 temp22m(p)=vkc/log(-zetat*obu(p)/z0q(p))
5076 else if (zeta(p) < 0._kind_lake)
then
5077 temp22m(p)=vkc/log(zldis(p)/z0q(p))
5078 else if (zeta(p) <= 1._kind_lake)
then
5079 temp22m(p)=vkc/log(zldis(p)/z0q(p))
5081 temp22m(p)=vkc/log(obu(p)/z0q(p))
5347 SUBROUTINE lakeini(kdt, ISLTYP, gt0, snowd, & !i
5348 weasd, lakedepth_default, fhour, &
5349 oro_lakedepth, savedtke12d, snowdp2d, h2osno2d, & !o
5350 snl2d, t_grnd2d, t_lake3d, lake_icefrac3d, &
5351 t_soisno3d, h2osoi_ice3d, &
5352 h2osoi_liq3d, h2osoi_vol3d, z3d, dz3d, &
5354 fice, hice, min_lakeice, tsfc, &
5355 use_lake_model, use_lakedepth, &
5357 xlat_d, xlon_d, clm_lake_initialized, &
5358 input_lakedepth, tg3, clm_lakedepth, &
5359 km, me, master, errmsg, errflg)
5376 INTEGER,
INTENT(OUT) :: errflg
5377 CHARACTER(*),
INTENT(OUT) :: errmsg
5379 INTEGER ,
INTENT (IN) :: im, me, master, km, kdt
5380 REAL(KIND_PHYS),
INTENT(IN) :: min_lakeice, fhour
5381 REAL(KIND_PHYS),
DIMENSION(IM),
INTENT(INOUT):: FICE, hice
5382 REAL(KIND_PHYS),
DIMENSION(IM),
INTENT(IN):: TG3, xlat_d, xlon_d
5383 REAL(KIND_PHYS),
DIMENSION(IM),
INTENT(IN):: tsfc
5384 REAL(KIND_PHYS),
DIMENSION(IM) ,
INTENT(INOUT) :: clm_lake_initialized
5385 integer,
dimension(IM),
intent(in) :: use_lake_model
5388 LOGICAL,
INTENT (IN) :: use_lakedepth
5390 INTEGER,
DIMENSION(IM),
INTENT(IN) :: ISLTYP
5391 REAL(KIND_PHYS),
DIMENSION(IM),
INTENT(INOUT) :: snowd,weasd
5392 REAL(kind_phys),
DIMENSION(IM,KM),
INTENT(IN) :: gt0, prsi
5393 real(kind_phys),
intent(in) :: lakedepth_default
5395 real(kind_phys),
dimension(IM),
intent(inout) :: clm_lakedepth
5396 real(kind_phys),
dimension(IM),
intent(inout) :: input_lakedepth
5397 real(kind_phys),
dimension(IM),
intent(in) :: oro_lakedepth
5398 real(kind_phys),
dimension(IM),
intent(out) :: savedtke12d
5399 real(kind_phys),
dimension(IM),
intent(out) :: snowdp2d, &
5404 real(kind_phys),
dimension(IM,nlevlake),
INTENT(out) :: t_lake3d, &
5406 real(kind_phys),
dimension(IM,-nlevsnow+1:nlevsoil ),
INTENT(out) :: t_soisno3d, &
5413 real(kind_phys),
dimension( IM,-nlevsnow+0:nlevsoil ),
INTENT(out) :: zi3d
5418 integer :: n,i,j,k,ib,lev,bottom
5419 real(kind_lake),
dimension(1:im ) :: bd2d
5420 real(kind_lake),
dimension(1:im ) :: tkm2d
5421 real(kind_lake),
dimension(1:im ) :: xksat2d
5422 real(kind_lake),
dimension(1:im ) :: depthratio2d
5424 logical,
parameter :: arbinit = .false.
5425 real(kind_lake),
parameter :: defval = -999.0
5428 character*256 :: message
5429 real(kind_lake) :: ht
5430 real(kind_lake) :: rhosn
5431 real(kind_lake) :: depth, lakedepth
5433 logical :: climatology_limits
5435 real(kind_lake) :: z_lake(nlevlake)
5436 real(kind_lake) :: dz_lake(nlevlake)
5438 integer,
parameter :: xcheck=38
5439 integer,
parameter :: ycheck=92
5441 integer :: used_lakedepth_default, init_points, month, julday
5442 integer :: mon, iday, num2, num1, juld, day2, day1, wght1, wght2
5443 real(kind_lake) :: Tclim, watsat
5445 used_lakedepth_default=0
5454 if(use_lake_model(i)==0 .or. clm_lake_initialized(i)>0)
then
5459 if ( use_lakedepth )
then
5460 if (oro_lakedepth(i) == 10.0 .or. oro_lakedepth(i) <= 0.)
then
5462 clm_lakedepth(i) = lakedepth_default
5463 used_lakedepth_default = used_lakedepth_default+1
5465 clm_lakedepth(i) = oro_lakedepth(i)
5469 clm_lakedepth(i) = lakedepth_default
5470 used_lakedepth_default = used_lakedepth_default+1
5473 if(clm_lake_initialized(i)>0)
then
5477 input_lakedepth=clm_lakedepth
5480 do k = -nlevsnow+1,nlevsoil
5481 h2osoi_liq3d(i,k) = defval
5482 h2osoi_ice3d(i,k) = defval
5483 h2osoi_vol3d(i,k) = defval
5484 t_soisno3d(i,k) = defval
5489 t_lake3d(i,k) = defval
5490 lake_icefrac3d(i,k) = defval
5493 if (use_lake_model(i) == 1)
then
5498 h2osoi_liq3d(i,:) = 0.0
5499 h2osoi_ice3d(i,:) = 0.0
5500 lake_icefrac3d(i,:) = 0.0
5501 h2osoi_vol3d(i,:) = 0.0
5504 if(fice(i)>min_lakeice)
then
5505 lake_icefrac3d(i,1) = fice(i)
5506 snowdp2d(i) = snowd(i)*1e-3
5507 h2osno2d(i) = weasd(i)
5518 if (isl == 0 ) isl = 14
5519 if (isl == 14 ) isl = isl + 1
5521 call calculate_z_dz_lake(i,input_lakedepth,clm_lakedepth,z_lake,dz_lake)
5523 z3d(i,1:nlevsoil) = zsoi(1:nlevsoil)
5524 zi3d(i,0:nlevsoil) = zisoi(0:nlevsoil)
5525 dz3d(i,1:nlevsoil) = dzsoi(1:nlevsoil)
5526 savedtke12d(i) = tkwat
5529 if (snowdp2d(i) < 0.01_kind_lake)
then
5531 dz3d(i,-nlevsnow+1:0) = 0._kind_lake
5532 z3d(i,-nlevsnow+1:0) = 0._kind_lake
5533 zi3d(i,-nlevsnow+0:0) = 0._kind_lake
5535 if ((snowdp2d(i) >= 0.01_kind_lake) .and. (snowdp2d(i) <= 0.03_kind_lake))
then
5537 dz3d(i,0) = snowdp2d(i)
5538 else if ((snowdp2d(i) > 0.03_kind_lake) .and. (snowdp2d(i) <= 0.04_kind_lake))
then
5540 dz3d(i,-1) = snowdp2d(i)*0.5_kind_lake
5541 dz3d(i, 0) = dz3d(i,-1)
5542 else if ((snowdp2d(i) > 0.04_kind_lake) .and. (snowdp2d(i) <= 0.07_kind_lake))
then
5544 dz3d(i,-1) = 0.02_kind_lake
5545 dz3d(i, 0) = snowdp2d(i) - dz3d(i,-1)
5546 else if ((snowdp2d(i) > 0.07_kind_lake) .and. (snowdp2d(i) <= 0.12_kind_lake))
then
5548 dz3d(i,-2) = 0.02_kind_lake
5549 dz3d(i,-1) = (snowdp2d(i) - 0.02_kind_lake)*0.5_kind_lake
5550 dz3d(i, 0) = dz3d(i,-1)
5551 else if ((snowdp2d(i) > 0.12_kind_lake) .and. (snowdp2d(i) <= 0.18_kind_lake))
then
5553 dz3d(i,-2) = 0.02_kind_lake
5554 dz3d(i,-1) = 0.05_kind_lake
5555 dz3d(i, 0) = snowdp2d(i) - dz3d(i,-2) - dz3d(i,-1)
5556 else if ((snowdp2d(i) > 0.18_kind_lake) .and. (snowdp2d(i) <= 0.29_kind_lake))
then
5558 dz3d(i,-3) = 0.02_kind_lake
5559 dz3d(i,-2) = 0.05_kind_lake
5560 dz3d(i,-1) = (snowdp2d(i) - dz3d(i,-3) - dz3d(i,-2))*0.5_kind_lake
5561 dz3d(i, 0) = dz3d(i,-1)
5562 else if ((snowdp2d(i) > 0.29_kind_lake) .and. (snowdp2d(i) <= 0.41_kind_lake))
then
5564 dz3d(i,-3) = 0.02_kind_lake
5565 dz3d(i,-2) = 0.05_kind_lake
5566 dz3d(i,-1) = 0.11_kind_lake
5567 dz3d(i, 0) = snowdp2d(i) - dz3d(i,-3) - dz3d(i,-2) - dz3d(i,-1)
5568 else if ((snowdp2d(i) > 0.41_kind_lake) .and. (snowdp2d(i) <= 0.64_kind_lake))
then
5570 dz3d(i,-4) = 0.02_kind_lake
5571 dz3d(i,-3) = 0.05_kind_lake
5572 dz3d(i,-2) = 0.11_kind_lake
5573 dz3d(i,-1) = (snowdp2d(i) - dz3d(i,-4) - dz3d(i,-3) - dz3d(i,-2))*0.5_kind_lake
5574 dz3d(i, 0) = dz3d(i,-1)
5575 else if (snowdp2d(i) > 0.64_kind_lake)
then
5577 dz3d(i,-4) = 0.02_kind_lake
5578 dz3d(i,-3) = 0.05_kind_lake
5579 dz3d(i,-2) = 0.11_kind_lake
5580 dz3d(i,-1) = 0.23_kind_lake
5581 dz3d(i, 0)=snowdp2d(i)-dz3d(i,-4)-dz3d(i,-3)-dz3d(i,-2)-dz3d(i,-1)
5585 do k = 0, nint(snl2d(i)+1), -1
5586 z3d(i,k) = zi3d(i,k) - 0.5_kind_lake*dz3d(i,k)
5587 zi3d(i,k-1) = zi3d(i,k) - dz3d(i,k)
5593 if(tsfc(i)<160)
then
5594 write(errmsg,
'(A,F20.12,A)')
'Invalid tsfc value ',tsfc(i),
' found. Was tsfc not initialized?'
5595 write(0,
'(A)') trim(errmsg)
5600 if(lake_icefrac3d(i,1) > 0.)
then
5603 depth = depth + dz_lake(k)
5604 if(hice(i) >= depth)
then
5605 lake_icefrac3d(i,k) = max(0.,lake_icefrac3d(i,1)+(0.-lake_icefrac3d(i,1))/z_lake(nlevlake)*depth)
5607 lake_icefrac3d(i,k) = 0.
5612 t_lake3d(i,1) = tsfc(i)
5613 t_grnd2d(i) = tsfc(i)
5614 if (lake_icefrac3d(i,1) <= 0.)
then
5615 t_lake3d(i,1) = max(tfrz,tsfc(i))
5616 t_grnd2d(i) = max(tfrz,tsfc(i))
5619 if(z_lake(k).le.depth_c)
then
5620 t_lake3d(i,k) = tsfc(i)+(277.2_kind_lake-tsfc(i))/depth_c*z_lake(k)
5622 t_lake3d(i,k) = 277.2_kind_lake
5624 if (lake_icefrac3d(i,k) <= 0.)
then
5625 t_lake3d(i,k) = max(tfrz,t_lake3d(i,k))
5631 if(snowdp2d(i) > 0.)
then
5632 do k = snl2d(i)+1, 0
5633 t_soisno3d(i,k) =min(tfrz,tsfc(i))
5638 t_soisno3d(i,1) = t_lake3d(i,nlevlake)
5639 t_soisno3d(i,nlevsoil) = tg3(i)
5640 do k = 2, nlevsoil-1
5641 t_soisno3d(i,k)=t_soisno3d(i,1)+(t_soisno3d(i,nlevsoil)-t_soisno3d(i,1))*dzsoi(k)
5644 if (snl2d(i) < 0)
then
5645 do k = nint(snl2d(i)+1), 0
5648 if(t_soisno3d(i,k) > 300 .or. t_soisno3d(i,k) < 200) t_soisno3d(i,k) = min(tfrz,tsfc(i))
5653 h2osoi_vol3d(i,k) = 1.0_kind_lake
5654 watsat = 0.489_kind_lake - 0.00126_kind_lake*sand(isl)
5655 h2osoi_vol3d(i,k) = min(h2osoi_vol3d(i,k),watsat)
5658 if (t_soisno3d(i,k) <= tfrz)
then
5659 h2osoi_ice3d(i,k) = dz3d(i,k)*denice*h2osoi_vol3d(i,k)
5660 h2osoi_liq3d(i,k) = 0._kind_lake
5662 h2osoi_ice3d(i,k) = 0._kind_lake
5663 h2osoi_liq3d(i,k) = dz3d(i,k)*denh2o*h2osoi_vol3d(i,k)
5671 if(h2osno2d(i).gt.0. .and. snowdp2d(i).gt.0.)
then
5672 rhosn = h2osno2d(i)/snowdp2d(i)
5678 do k = -nlevsnow+1, 0
5679 if (k > snl2d(i))
then
5680 h2osoi_ice3d(i,k) = dz3d(i,k)*snow_bd
5681 h2osoi_liq3d(i,k) = 0._kind_lake
5685 clm_lake_initialized(i) = 1
5691 if(debug_print .and. init_points>0)
then
5692 print *,
'points initialized in clm_lake',init_points