Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug in cloud calculation #279

Merged
merged 2 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 75 additions & 71 deletions main/MOD_Forcing.F90
Original file line number Diff line number Diff line change
Expand Up @@ -525,82 +525,86 @@ SUBROUTINE read_forcing (idate, dir_forcing)
CALL flush_block_data (forc_xy_hgt_t, real(HEIGHT_T,r8))
CALL flush_block_data (forc_xy_hgt_q, real(HEIGHT_Q,r8))

IF (solarin_all_band) THEN

IF (trim(DEF_forcing%dataset) == 'QIAN') THEN
!---------------------------------------------------------------
! 04/2014, yuan: NOTE! codes from CLM4.5-CESM1.2.0
! relationship between incoming NIR or VIS radiation and ratio of
! direct to diffuse radiation calculated based on one year's worth of
! hourly CAM output from CAM version cam3_5_55
!---------------------------------------------------------------
DO iblkme = 1, gblock%nblkme
ib = gblock%xblkme(iblkme)
jb = gblock%yblkme(iblkme)

DO j = 1, gforc%ycnt(jb)
DO i = 1, gforc%xcnt(ib)

hsolar = forc_xy_solarin%blk(ib,jb)%val(i,j)*0.5_R8

! NIR (dir, diff)
ratio_rvrf = min(0.99_R8,max(0.29548_R8 + 0.00504_R8*hsolar &
-1.4957e-05_R8*hsolar**2 + 1.4881e-08_R8*hsolar**3,0.01_R8))
forc_xy_soll %blk(ib,jb)%val(i,j) = ratio_rvrf*hsolar
forc_xy_solld%blk(ib,jb)%val(i,j) = (1._R8 - ratio_rvrf)*hsolar

! VIS (dir, diff)
ratio_rvrf = min(0.99_R8,max(0.17639_R8 + 0.00380_R8*hsolar &
-9.0039e-06_R8*hsolar**2 + 8.1351e-09_R8*hsolar**3,0.01_R8))
forc_xy_sols %blk(ib,jb)%val(i,j) = ratio_rvrf*hsolar
forc_xy_solsd%blk(ib,jb)%val(i,j) = (1._R8 - ratio_rvrf)*hsolar
IF (solarin_all_band) THEN

IF (trim(DEF_forcing%dataset) == 'QIAN') THEN
!---------------------------------------------------------------
! 04/2014, yuan: NOTE! codes from CLM4.5-CESM1.2.0
! relationship between incoming NIR or VIS radiation and ratio of
! direct to diffuse radiation calculated based on one year's worth of
! hourly CAM output from CAM version cam3_5_55
!---------------------------------------------------------------
DO iblkme = 1, gblock%nblkme
ib = gblock%xblkme(iblkme)
jb = gblock%yblkme(iblkme)

DO j = 1, gforc%ycnt(jb)
DO i = 1, gforc%xcnt(ib)

hsolar = forc_xy_solarin%blk(ib,jb)%val(i,j)*0.5_R8

! NIR (dir, diff)
ratio_rvrf = min(0.99_R8,max(0.29548_R8 + 0.00504_R8*hsolar &
-1.4957e-05_R8*hsolar**2 + 1.4881e-08_R8*hsolar**3,0.01_R8))
forc_xy_soll %blk(ib,jb)%val(i,j) = ratio_rvrf*hsolar
forc_xy_solld%blk(ib,jb)%val(i,j) = (1._R8 - ratio_rvrf)*hsolar

! VIS (dir, diff)
ratio_rvrf = min(0.99_R8,max(0.17639_R8 + 0.00380_R8*hsolar &
-9.0039e-06_R8*hsolar**2 + 8.1351e-09_R8*hsolar**3,0.01_R8))
forc_xy_sols %blk(ib,jb)%val(i,j) = ratio_rvrf*hsolar
forc_xy_solsd%blk(ib,jb)%val(i,j) = (1._R8 - ratio_rvrf)*hsolar

ENDDO
ENDDO
ENDDO
ENDDO
ENDDO

ELSE
!---------------------------------------------------------------
! as the downward solar is in full band, an empirical expression
! will be used to divide fractions of band and incident
! (visible, near-infrad, dirct, diffuse)
! Julian calday (1.xx to 365.xx)
!---------------------------------------------------------------
DO iblkme = 1, gblock%nblkme
ib = gblock%xblkme(iblkme)
jb = gblock%yblkme(iblkme)

DO j = 1, gforc%ycnt(jb)
DO i = 1, gforc%xcnt(ib)

ilat = gforc%ydsp(jb) + j
ilon = gforc%xdsp(ib) + i
IF (ilon > gforc%nlon) ilon = ilon - gforc%nlon

a = forc_xy_solarin%blk(ib,jb)%val(i,j)
calday = calendarday(idate)
sunang = orb_coszen (calday, gforc%rlon(ilon), gforc%rlat(ilat))

cloud = (1160.*sunang-a)/(963.*sunang)
cloud = max(cloud,0.)
cloud = min(cloud,1.)
cloud = max(0.58,cloud)

difrat = 0.0604/(sunang-0.0223)+0.0683
IF(difrat.lt.0.) difrat = 0.
IF(difrat.gt.1.) difrat = 1.

difrat = difrat+(1.0-difrat)*cloud
vnrat = (580.-cloud*464.)/((580.-cloud*499.)+(580.-cloud*464.))

forc_xy_sols %blk(ib,jb)%val(i,j) = a*(1.0-difrat)*vnrat
forc_xy_soll %blk(ib,jb)%val(i,j) = a*(1.0-difrat)*(1.0-vnrat)
forc_xy_solsd%blk(ib,jb)%val(i,j) = a*difrat*vnrat
forc_xy_solld%blk(ib,jb)%val(i,j) = a*difrat*(1.0-vnrat)
ELSE
!---------------------------------------------------------------
! as the downward solar is in full band, an empirical expression
! will be used to divide fractions of band and incident
! (visible, near-infrad, dirct, diffuse)
! Julian calday (1.xx to 365.xx)
!---------------------------------------------------------------
DO iblkme = 1, gblock%nblkme
ib = gblock%xblkme(iblkme)
jb = gblock%yblkme(iblkme)

DO j = 1, gforc%ycnt(jb)
DO i = 1, gforc%xcnt(ib)

ilat = gforc%ydsp(jb) + j
ilon = gforc%xdsp(ib) + i
IF (ilon > gforc%nlon) ilon = ilon - gforc%nlon

a = forc_xy_solarin%blk(ib,jb)%val(i,j)
calday = calendarday(idate)
sunang = orb_coszen (calday, gforc%rlon(ilon), gforc%rlat(ilat))

IF (sunang .eq. 0)THEN
cloud = 0.
ELSE
cloud = (1160.*sunang-a)/(963.*sunang)
END IF
cloud = max(cloud,0.)
cloud = min(cloud,1.)
cloud = max(0.58,cloud)

difrat = 0.0604/(sunang-0.0223)+0.0683
IF(difrat.lt.0.) difrat = 0.
IF(difrat.gt.1.) difrat = 1.

difrat = difrat+(1.0-difrat)*cloud
vnrat = (580.-cloud*464.)/((580.-cloud*499.)+(580.-cloud*464.))

forc_xy_sols %blk(ib,jb)%val(i,j) = a*(1.0-difrat)*vnrat
forc_xy_soll %blk(ib,jb)%val(i,j) = a*(1.0-difrat)*(1.0-vnrat)
forc_xy_solsd%blk(ib,jb)%val(i,j) = a*difrat*vnrat
forc_xy_solld%blk(ib,jb)%val(i,j) = a*difrat*(1.0-vnrat)
ENDDO
ENDDO
ENDDO
ENDDO
ENDIF
ENDIF
ENDIF

! [GET ATMOSPHERE CO2 CONCENTRATION DATA]
Expand Down
2 changes: 1 addition & 1 deletion main/MOD_LeafTemperature.F90
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ SUBROUTINE LeafTemperature ( &
t_precip, &! snowfall/rainfall temperature [kelvin]
qintr_rain, &! rainfall interception (mm h2o/s)
qintr_snow, &! snowfall interception (mm h2o/s)
smp (1:nl_soil), &! precipitation sensible heat from canopy
smp (1:nl_soil), &! soil matrix potential
rootfr (1:nl_soil), &! root fraction
hksati (1:nl_soil), &! hydraulic conductivity at saturation [mm h2o/s]
hk (1:nl_soil) ! soil hydraulic conducatance
Expand Down
2 changes: 1 addition & 1 deletion main/MOD_PlantHydraulic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ SUBROUTINE PlantHydraulicStress_twoleaf (nl_soil ,nvegwcs ,z_soi ,&
cintsha ! scaling up from shaded leaf to canopy

real(r8),intent(in), dimension(nl_soil) :: &
smp, &! precipitation sensible heat from canopy
smp, &! soil matrix potential
rootfr, &! root fraction
hksati, &! hydraulic conductivity at saturation [mm h2o/s]
hk ! soil hydraulic conducatance [mm h2o/s]
Expand Down