-
Notifications
You must be signed in to change notification settings - Fork 296
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
Bug fixes for energy imbalance associated with surface water and lakes #307
Conversation
@olyson - I know the distinction between assignee and reviewer is a bit unclear. Typically it works best to have a single assignee and multiple reviewers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See a few inline comments
src/biogeophys/EnergyFluxType.F90
Outdated
@@ -21,6 +21,9 @@ module EnergyFluxType | |||
type, public :: energyflux_type | |||
|
|||
! Fluxes | |||
!scs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (subgridflag == 0) then | ||
! if (subgridflag == 0) then | ||
!scs | ||
if (subgridflag == 0 .or. lun%itype(l) == istdlak) then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swensosc There is one other occurrence of subgridflag, on line 763 of this module. Should that one also check if the landunit type is istdlak?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed this change to the branch
|
||
! mass of water converted from liquid to ice | ||
xm(c) = hm(c)*dtime/hfus | ||
temp1 = h2osfc(c) + xm(c) | ||
|
||
! compute change in cv due to additional ice | ||
dcv(c)=cpice*min(abs(xm(c)),h2osfc(c)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also remove the declaration of this no-longer-used local variable, dcv
/(c1 + c2) | ||
|
||
eflx_h2osfc_to_snow_col(c) =(t_h2osfc(c)-t_soisno(c,0))*c2/dtime | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this else
block is exactly the same as the above else if
block, except that here there is no dhsdT
in the calculation of c1
. To reduce this code duplication, can you do something like this?:
if (snl(c) == 0) then
!initialize for next time step
t_soisno(c,0) = t_h2osfc(c)
eflx_h2osfc_to_snow_col(c) = 0.
else
if (snl(c) == -1) then
somevar = dhsdT(c)
else
somevar = 0._r8
end if
c1=frac_sno(c)*(dtime/fact(c,0) - somevar*dtime)
! Rest of the code here
or:
c1=frac_sno(c)*(dtime/fact(c,0)
if (snl(c) == -1) c1 = c1 - frac_sno(c)*dhsdT(c)*dtime
then no need for additional variable (?)
…On Tue, Feb 27, 2018 at 3:00 PM, Bill Sacks ***@***.***> wrote:
***@***.**** requested changes on this pull request.
See a few inline comments
------------------------------
In src/biogeophys/EnergyFluxType.F90
<#307 (comment)>:
> @@ -21,6 +21,9 @@ module EnergyFluxType
type, public :: energyflux_type
! Fluxes
+!scs
Need to remove comment lines like this, and other similar comments (scs
comments and other commented-out lines).
@swensosc <https://github.com/swensosc> and @olyson
<https://github.com/olyson> - for the future, it makes code reviews
easier if you can remove these commented-out things and commented initials
before submitting the PR.
------------------------------
In src/biogeophys/SurfaceRadiationMod.F90
<#307 (comment)>:
> @@ -664,7 +666,9 @@ subroutine SurfaceRadiation(bounds, num_nourbanp, filter_nourbanp, &
sabg_soil(p) = sabg(p)
endif
! if no subgrid fluxes, make sure to set both components equal to weighted average
- if (subgridflag == 0) then
+! if (subgridflag == 0) then
+!scs
+ if (subgridflag == 0 .or. lun%itype(l) == istdlak) then
@swensosc <https://github.com/swensosc> There is one other occurrence of
subgridflag, on line 763 of this module. Should that one also check if the
landunit type is istdlak?
------------------------------
In src/biogeophys/SoilTemperatureMod.F90
<#307 (comment)>:
>
! mass of water converted from liquid to ice
xm(c) = hm(c)*dtime/hfus
temp1 = h2osfc(c) + xm(c)
- ! compute change in cv due to additional ice
- dcv(c)=cpice*min(abs(xm(c)),h2osfc(c))
Should also remove the declaration of this no-longer-used local variable,
dcv
------------------------------
In src/biogeophys/SoilTemperatureMod.F90
<#307 (comment)>:
> + !initialize for next time step
+ t_soisno(c,0) = t_h2osfc(c)
+ eflx_h2osfc_to_snow_col(c) = 0.
+ else if (snl(c) == -1) then
+ c1=frac_sno(c)*(dtime/fact(c,0) - dhsdT(c)*dtime)
+ if ( frac_h2osfc(c) /= 0.0_r8 )then
+! c2=frac_h2osfc(c)*(-cpliq*xm(c))
+ c2=(-cpliq*xm(c))
+ else
+ c2=0.0_r8
+ end if
+ t_soisno(c,0) = (c1*t_soisno(c,0)+ c2*t_h2osfc(c)) &
+ /(c1 + c2)
+
+ eflx_h2osfc_to_snow_col(c) =(t_h2osfc(c)-t_soisno(c,0))*c2/dtime
+ else
It looks like this else block is exactly the same as the above else if
block, except that here there is no dhsdT in the calculation of c1. To
reduce this code duplication, can you do something like this?:
if (snl(c) == 0) then
!initialize for next time step
t_soisno(c,0) = t_h2osfc(c)
eflx_h2osfc_to_snow_col(c) = 0.
else
if (snl(c) == -1) then
somevar = dhsdT(c)
else
somevar = 0._r8
end if
c1=frac_sno(c)*(dtime/fact(c,0) - somevar*dtime)
! Rest of the code here
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#307 (review)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AaLe_LdVsmyxKzoj7fzOp1193VJ2ZKDJks5tZHsRgaJpZM4SVQzI>
.
|
Yes, that's fine, too |
Add some land ice diagnostic vars needed for CMIP6 Add some diagnostic variables needed for analyzing land ice that have been requested by some of the MIPs in CMIP6 (especially ISMIP). Also, fixes c2l_scale_type to fix urban scaling for SNOWICE, SNOWLIQ Some changes from Leo van Kampenhout.
/(c1 + c2) | ||
|
||
eflx_h2osfc_to_snow_col(c) =(t_h2osfc(c)-t_soisno(c,0))*c2/dtime | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also note that there is a division by "fact" that isn't being checked for. Can fact be small or zero?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I did more looking at the code. It looks like based on ComputeHeatDiffFluxAndFactor, fact shouldn't ever be zero. But, it could possibly be small. We possibly should do an assert check in ComputeHeatDiffFluxAndFactor that fact isn't identically zero (which would only be done in DEBUG mode). But, I also wonder about checking for it being small.
else | ||
hm(c,j) = frac_sno_eff(c)*(dhsdT(c)*tinc(c,j) - tinc(c,j)/fact(c,j)) | ||
endif | ||
!scs | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More divides by fact without checking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the comment above.
else | ||
cv(c,j) = 1.0e-6_r8 | ||
endif | ||
!scs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should check for frac_sno > small value rather than greater than zero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are probably right but I think Sean should weigh in on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's fine.
The following change allows the model to get past the divide by zero issue:
|
I think fact will always be nonzero. It is basically the soil moisture,
multiplied by a couple of constants.
…On Fri, Mar 2, 2018 at 12:07 PM, Erik Kluzek ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/biogeophys/SoilTemperatureMod.F90
<#307 (comment)>:
> + !initialize for next time step
+ t_soisno(c,0) = t_h2osfc(c)
+ eflx_h2osfc_to_snow_col(c) = 0.
+ else if (snl(c) == -1) then
+ c1=frac_sno(c)*(dtime/fact(c,0) - dhsdT(c)*dtime)
+ if ( frac_h2osfc(c) /= 0.0_r8 )then
+! c2=frac_h2osfc(c)*(-cpliq*xm(c))
+ c2=(-cpliq*xm(c) - frac_h2osfc(c)*dhsdT(c)*dtime)
+ else
+ c2=0.0_r8
+ end if
+ t_soisno(c,0) = (c1*t_soisno(c,0)+ c2*t_h2osfc(c)) &
+ /(c1 + c2)
+
+ eflx_h2osfc_to_snow_col(c) =(t_h2osfc(c)-t_soisno(c,0))*c2/dtime
+ else
Also note that there is a division by "fact" that isn't being checked for.
Can fact be small or zero?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#307 (review)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AaLe_Bb3FvT6h7c9HSUjXF0sXAeS7qVnks5taZiEgaJpZM4SVQzI>
.
|
The change I made to get past the divide by zero, does change answers. So I will need to rerun testing at minimum. |
The divide by zero fix looks ok to me, Erik. |
…into energy_imbalance_fix
…eclaration of variables that aren't used
Thanks for doing this cleanup, @ekluzek . It looks like most of my comments are addressed now; the one remaining one is #307 (comment) . However, given the time-criticality of this, I'll go ahead and mark this as accepted - and if it doesn't get resolved this time around, we can come back to it later. |
/(c1 + c2) | ||
|
||
eflx_h2osfc_to_snow_col(c) =(t_h2osfc(c)-t_soisno(c,0))*c2/dtime | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I did more looking at the code. It looks like based on ComputeHeatDiffFluxAndFactor, fact shouldn't ever be zero. But, it could possibly be small. We possibly should do an assert check in ComputeHeatDiffFluxAndFactor that fact isn't identically zero (which would only be done in DEBUG mode). But, I also wonder about checking for it being small.
else | ||
hm(c,j) = frac_sno_eff(c)*(dhsdT(c)*tinc(c,j) - tinc(c,j)/fact(c,j)) | ||
endif | ||
!scs | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the comment above.
I'm having a bunch of problems fully completing testing on cheyenne. But, I'm only see expected fails, and testing is complete on hobart. So going to bring this to master and complete testing afterwards. |
Incorporates bug fixes from CLM5 associated with surface water and lakes. The bug fixes incoporated here includes: - Bug fix incoporated in clm4_5_1_r087, and - ESCOMP/CTSM#307 [non-BFB]
Incorporates bug fixes from CLM5 associated with surface water and lakes. The bug fixes incoporated here from CLM include: - clm4_5_1_r087, and - ESCOMP/CTSM#307 [non-BFB]
Incorporates bug fixes from CLM5 associated with surface water and lakes. The bug fixes incoporated here from CLM include: - clm4_5_1_r087, and - ESCOMP/CTSM#307 [non-BFB]
This is based on bishtgautam/lnd/radiation-fix, with CPP directive APPLY_POST_DECK_BUGFIXES added to allow using CONFIG options to turn on/off the fixes. It incorporates bug fixes from CLM5 associated with surface water and lakes. The bug fixes incoporated here from CLM include: - clm4_5_1_r087, and - ESCOMP/CTSM#307 modified: components/clm/src/biogeophys/BalanceCheckMod.F90 modified: components/clm/src/biogeophys/CanopyHydrologyMod.F90 modified: components/clm/src/biogeophys/EnergyFluxType.F90 modified: components/clm/src/biogeophys/SnowHydrologyMod.F90 modified: components/clm/src/biogeophys/SoilFluxesMod.F90 modified: components/clm/src/biogeophys/SoilTemperatureMod.F90 modified: components/clm/src/biogeophys/SurfaceAlbedoMod.F90 modified: components/clm/src/biogeophys/SurfaceRadiationMod.F90 [non-BFB]
Incorporates bug fixes from CLM5 associated with surface water and lakes. The bug fixes incorporated here are from CLM include: - clm4_5_1_r087, and - ESCOMP/CTSM#307 The bug fixes are added with CPP directive APPLY_POST_DECK_BUGFIXES [BFB]
Incorporates bug fixes from CLM5 associated with surface water and lakes. The bug fixes incorporated here are from CLM include: - clm4_5_1_r087, and - ESCOMP/CTSM#307 The bug fixes are added with CPP directive APPLY_POST_DECK_BUGFIXES [BFB]
Bug fixes for energy imbalance associated with surface water and lakes
These are bug fixes for the land energy imbalance over land as determined by coupler diagnostics. They include bug fixes for surface water phase change and lake/snow interactions developed by Sean Swenson and Keith Oleson.
The following modules have been modified:
src/biogeophys/EnergyFluxType.F90
src/biogeophys/SoilFluxesMod.F90
src/biogeophys/SoilTemperatureMod.F90
src/biogeophys/SurfaceAlbedoMod.F90
src/biogeophys/SurfaceRadiationMod.F90
Diagnostics compared to an offline control are here:
http://webext.cgd.ucar.edu/I1850/clm50_r272_1deg_GSWP3V1_iso_h2osfclakefix_1850/lnd/clm50_r272_1deg_GSWP3V1_iso_h2osfclakefix_1850.1443_1461-clm50_r272_1deg_GSWP3V1_iso_1850.1443_1461/setsIndex.html