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

Bug fixes for energy imbalance associated with surface water and lakes #307

Merged
merged 12 commits into from
Mar 8, 2018

Conversation

olyson
Copy link
Contributor

@olyson olyson commented Feb 27, 2018

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

@olyson olyson added tag: bug - critical big problems in important configurations priority: high High priority task to fix soon, e.g., because it is a problem in important configurations labels Feb 27, 2018
@olyson olyson requested a review from ekluzek February 27, 2018 16:43
@billsacks
Copy link
Member

@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.

Copy link
Member

@billsacks billsacks left a 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

@@ -21,6 +21,9 @@ module EnergyFluxType
type, public :: energyflux_type

! Fluxes
!scs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to remove comment lines like this, and other similar comments (scs comments and other commented-out lines).

@swensosc and @olyson - for the future, it makes code reviews easier if you can remove these commented-out things and commented initials before submitting the PR.

if (subgridflag == 0) then
! if (subgridflag == 0) then
!scs
if (subgridflag == 0 .or. lun%itype(l) == istdlak) then
Copy link
Member

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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))
Copy link
Member

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
Copy link
Member

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

@swensosc
Copy link
Contributor

swensosc commented Feb 27, 2018 via email

@billsacks
Copy link
Member

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 (?)

Yes, that's fine, too

olyson and others added 4 commits February 28, 2018 12:52
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
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's fine.

@ekluzek
Copy link
Contributor

ekluzek commented Mar 3, 2018

The following change allows the model to get past the divide by zero issue:

diff --git a/src/biogeophys/SoilTemperatureMod.F90 b/src/biogeophys/SoilTemperatureMod.F90
index ef650abb..582a0312 100644
--- a/src/biogeophys/SoilTemperatureMod.F90
+++ b/src/biogeophys/SoilTemperatureMod.F90
@@ -342,7 +342,7 @@ subroutine SoilTemperature(bounds, num_urbanl, filter_urbanl, num_nolakec, filte
 !         dz_h2osfc(c) = max(1.0e-6_r8,1.0e-3*h2osfc(c))
 !         c_h2osfc(c)  = cpliq*denh2o*dz_h2osfc(c) !"areametric" heat capacity [J/K/m^2]
 !scs
-         if (h2osfc(c) > 0._r8) then 
+         if ( (h2osfc(c) > 1.0e-6_r8) .and. (frac_h2osfc(c) > 1.e-6_r8) ) then 
             c_h2osfc(c)  = max(1.0e-6_r8,cpliq*h2osfc(c)/frac_h2osfc(c))
             dz_h2osfc(c) = max(1.0e-6_r8,1.0e-3*h2osfc(c)/frac_h2osfc(c))
          else

@swensosc
Copy link
Contributor

swensosc commented Mar 5, 2018 via email

@ekluzek
Copy link
Contributor

ekluzek commented Mar 5, 2018

The change I made to get past the divide by zero, does change answers. So I will need to rerun testing at minimum.

@olyson
Copy link
Contributor Author

olyson commented Mar 6, 2018

The divide by zero fix looks ok to me, Erik.

@billsacks
Copy link
Member

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
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment above.

@ekluzek
Copy link
Contributor

ekluzek commented Mar 8, 2018

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.

@ekluzek ekluzek merged commit 97cdc7d into ESCOMP:master Mar 8, 2018
bishtgautam pushed a commit to E3SM-Project/E3SM that referenced this pull request Mar 19, 2018
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]
bishtgautam pushed a commit to E3SM-Project/E3SM that referenced this pull request Mar 19, 2018
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]
bishtgautam pushed a commit to E3SM-Project/E3SM that referenced this pull request Mar 19, 2018
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]
wlin7 added a commit to E3SM-Project/E3SM that referenced this pull request Mar 28, 2018
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]
bishtgautam pushed a commit to E3SM-Project/E3SM that referenced this pull request Mar 29, 2018
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]
bishtgautam pushed a commit to E3SM-Project/E3SM that referenced this pull request Mar 29, 2018
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]
billsacks pushed a commit to billsacks/ctsm that referenced this pull request Feb 22, 2019
Bug fixes for energy imbalance associated with surface water and lakes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high High priority task to fix soon, e.g., because it is a problem in important configurations tag: bug - critical big problems in important configurations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants