Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

Implementation of irrigation stream file #2102

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

YiYaoVUB
Copy link

Description of changes

In this pull request, we added the irrigation stream file where you can customize the irrigation-related parameters.
Before: Most of the irrigation-related parameters apply to all crops and all gridcells. You just need to set them in user namelist files
After: Now you can give different values to irrigation-related files for different crops and different gridcells.

Specific notes

Please note that this pull request is replacing the pull request #2026

Contributors other than yourself, if any:
@swensosc @samsrabin

CTSM Issues Fixed (include github issue #):
#2026
It does not only fix the issue but also grants users more flexibility. In next steps, a default irrigation stream files or its generation tools may be given

Are answers expected to change (and if so in what way)?

Any User Interface Changes (namelist or namelist defaults changes)?
yes. in the namelist we can add if use_irrigation_stream is true or wrong

Testing performed, if any:
(List what testing you did to show your changes worked as expected)
(This can be manual testing or running of the different test suites)
(Documentation on system testing is here: https://github.com/ESCOMP/ctsm/wiki/System-Testing-Guide)
(aux_clm on cheyenne for intel/gnu and izumi for intel/gnu/nag/pgi is the standard for tags on master)

NOTE: Be sure to check your coding style against the standard
(https://github.com/ESCOMP/ctsm/wiki/CTSM-coding-guidelines) and review
the list of common problems to watch out for
(https://github.com/ESCOMP/CTSM/wiki/List-of-common-problems).

@YiYaoVUB YiYaoVUB changed the title Irr stream file Implementation of irrigation stream file Aug 14, 2023
@samsrabin samsrabin self-assigned this Aug 16, 2023
@samsrabin samsrabin added enhancement new capability or improved behavior of existing capability tag: enh - new science labels Aug 16, 2023
@samsrabin samsrabin self-requested a review August 16, 2023 20:18
Copy link
Collaborator

@samsrabin samsrabin left a comment

Choose a reason for hiding this comment

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

Thanks for doing the work to convert your previous PR into one that works with stream files! It enables much more flexibility in future experiments.

I have a few questions, comments, and suggestions that I've added to the code in this PR. In addition:

Finally, there are various minor issues (like whitespace, typos, etc.) that I didn't bother noting.

I've "requested changes," but I don't think it'd be right for me to ask you to do these yourself as—although they're simple—I know how busy the last part of your PhD is. The best way to handle this moving forward, I think, would be for you to give me collaborator access to your repository. I would then be able to work on your branch directly. If you're not comfortable with that, I could instead submit pull requests—whichever you prefer.

Comment on lines 492 to 493
if (h2osfc(c) > 100) then
qflx_h2osfc_surf(c) = (h2osfc(c) - 100) / dtime
Copy link
Collaborator

@samsrabin samsrabin Aug 16, 2023

Choose a reason for hiding this comment

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

  • Instead of hard-coding 100, have surface_water_ponding_column be a value in mm and use it here.

Comment on lines 481 to 482
if (irrigation_inst%surface_water_ponding_column(c) > 0) then
frac_infclust=0.0_r8
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • frac_infclust does not seem to be used if surface water ponding is on, suggesting that this change can be reverted.

character(len=CL) :: irrig_tintalgo = 'nearest' ! Time interpolation alogrithm
character(len=CL) :: stream_mapalgo = 'nn'
real(r8) :: stream_dtlimit = 15._r8
character(len=CL) :: stream_taxmode = 'cycle'
Copy link
Collaborator

@samsrabin samsrabin Aug 16, 2023

Choose a reason for hiding this comment

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

cycle makes sense if, for instance, you're providing irrigation amounts for every day in just one year. extend would make more sense in the context of Yao et al. (2022), where you're providing irrigation techniques for what may be a limited number of years.

  • Make it so irrigation stream file's stream_taxmode can be set as namelist parameter.
  • Ensure that default value corresponds to what should happen for default streams file.

<stream_year_last_irrig >1850</stream_year_last_irrig>
<model_year_align_irrig >1850</model_year_align_irrig>

<stream_fldfilename_irrig hgrid="0.9x1.25">lnd/clm2/prescribed_data/LFMIP-pdLC-SST.H2OSOI.0.9x1.25.20levsoi.natveg.1980-2014.MONS_climo.c190716.nc</stream_fldfilename_irrig>
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • stream_fldfilename_irrig default should be removed, as it points to a soil moisture file. Alternatively, you could provide a file to use. (I'll need that file anyway for testing, but we may not want to provide that as a default dataset.)

<stream_fldfilename_irrig hgrid="0.9x1.25">lnd/clm2/prescribed_data/LFMIP-pdLC-SST.H2OSOI.0.9x1.25.20levsoi.natveg.1980-2014.MONS_climo.c190716.nc</stream_fldfilename_irrig>

<irrig_mapalgo>nn</irrig_mapalgo>
<irrig_tintalgo>nearest</irrig_tintalgo>
Copy link
Collaborator

@samsrabin samsrabin Aug 16, 2023

Choose a reason for hiding this comment

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

  • irrig_tintalgo and irrig_mapalgo must always be nearest/nn for categorical variables like irrig_method_patch, for which interpolation isn't meaningful. Options to fix:
  • Remove these as something that can be changed
  • Silently use nearest/nn to affect categorical variables
  • Fail if something other than nearest/nn is used but categorical variables are read from the streams file

Copy link
Collaborator

Choose a reason for hiding this comment

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

From conversation with @swensosc: For now, I will leave irrig_tintalgo and irrig_mapalgo as namelist parameters, but only allow nearest/nn. This will provide the framework for eventually adding other options if users request them.


<stream_fldfilename_irrig hgrid="0.9x1.25">lnd/clm2/prescribed_data/LFMIP-pdLC-SST.H2OSOI.0.9x1.25.20levsoi.natveg.1980-2014.MONS_climo.c190716.nc</stream_fldfilename_irrig>

<irrig_mapalgo>nn</irrig_mapalgo>
Copy link
Collaborator

@samsrabin samsrabin Aug 16, 2023

Choose a reason for hiding this comment

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

  • irrig_mapalgo appears in XML files but not Fortran or CLMBuildNamelist.pm. Add code to handle it.

Comment on lines 383 to 394
case ('irrig_longitude')
allocate(irrig_lon(bounds%begg:bounds%endg,num_irrig_cft))
do g = bounds%begg, bounds%endg
ig = g_to_ig(g)
irrig_lon(g,:) = dataptr2d(:,ig)
enddo
case ('irrig_latitude')
allocate(irrig_lat(bounds%begg:bounds%endg,num_irrig_cft))
do g = bounds%begg, bounds%endg
ig = g_to_ig(g)
irrig_lat(g,:) = dataptr2d(:,ig)
enddo
Copy link
Collaborator

@samsrabin samsrabin Aug 16, 2023

Choose a reason for hiding this comment

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

  • Make it so that irrig_longitude and irrig_latitude, intended to allow running a global grid with a regional irrigation stream file, are actually used.

@@ -202,6 +210,7 @@ module IrrigationMod
procedure, private :: InitAllocate => IrrigationInitAllocate
procedure, private :: InitHistory => IrrigationInitHistory
procedure, private :: InitCold => IrrigationInitCold
procedure, private :: UpdateTargetSMP => IrrigationUpdateTargetSMP
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • IrrigationUpdateTargetSMP doesn't need the UpdateTargetSMP alias.

integer :: dtime ! land model time step (sec)
integer :: irrig_nsteps_per_day ! number of time steps per day in which we irrigate
integer :: dtime ! land model time step (sec)
integer, pointer :: irrig_nsteps_per_day (:) ! number of time steps per day in which we irrigate [col]
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • irrig_nsteps_per_day needs _column suffix.

@@ -235,6 +244,9 @@ module IrrigationMod
integer, parameter, public :: irrig_method_drip = 1
! Sprinkler is applied directly to canopy
integer, parameter, public :: irrig_method_sprinkler = 2
! Flood is applied to soil surface
!(currently, the only difference between drip and flood is the target soil water, which can be implemented in Irrigation stream files. We leave it here in case future changes)
Copy link
Collaborator

@samsrabin samsrabin Aug 16, 2023

Choose a reason for hiding this comment

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

  • Could you elaborate on this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Basically, we may not need a separate irrig_method_flood, because that behavior will be entirely controlled by the stream file values. The difference between drip and sprinkler here is just whether water is applied above or below canopy.

  • Get rid of irrig_method_flood.

Copy link
Author

Choose a reason for hiding this comment

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

Yes it is true but I am still wondering in the future, the drip irrigation shall be re-designed. In the current version of the code, the drip irrigation would also cause many runoff, which is not very realistic. Just some thoughts: like applying water into the soil directly?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good point—there might eventually be a true "drip" irrigation that's distinct from a below-canopy sprinkler. @swensosc, what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I see now that your comment about crop_fsat_equals_zero was intended for this discussion. I'm not sure I understand what you're saying, though.

Comment on lines 1672 to 1683
! if using irrigation streams, do not set these two variables
! TODO: determine volr limited rate based on prescribed input rates rather than soil moisture based irrigation rates
! if (.not. use_irrigation_streams) then
! Convert units from mm to mm/sec
this%sfc_irrig_rate_patch(p) = deficit_volr_limited(c) / &
(this%dtime*this%irrig_nsteps_per_day(c))
this%irrig_rate_demand_patch(p) = deficit(c) / &
(this%dtime*this%irrig_nsteps_per_day(c))
! else
! this%sfc_irrig_rate_patch(p) = 0._r8
! this%irrig_rate_demand_patch(p) = 0._r8
! endif
Copy link
Collaborator

@samsrabin samsrabin Aug 16, 2023

Choose a reason for hiding this comment

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

  • Is the if (.not. use_irrigation_streams) and else stuff meant to be commented out? It seems like it might have been intended to ensure that the fallback settings are used where these variables aren't on the stream file (or there is no stream file). Check that this is handled correctly.
  • Ensure that behavior is correct when prescribing irrigation rate but also limiting based on available river water.

Comment on lines 56 to 58
logical :: irrig_ignore_data_if_missing ! If should ignore overridding a point with soil moisture data
! from the streams file, if the streams file shows that point
! as missing (namelist item)
Copy link
Collaborator

@samsrabin samsrabin Aug 16, 2023

Choose a reason for hiding this comment

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

irrig_ignore_data_if_missing is currently unused.

  • Look at soil moisture streams to see how they used irrig_ignore_data_if_missing. Decide if it should be deleted or used.

@samsrabin
Copy link
Collaborator

samsrabin commented Aug 18, 2023

Some additional things upon further inspection/testing/discussion with @swensosc (some of which solve issues that predate this PR):

  • In QflxH2osfcSurf(), move the setting of qflx_h2osfc_surf(c)= 0._r8 to in front of the if loop.
  • Get rid of sprinkler and drip names; just use above/below canopy, for consistency and disambiguation.
  • sfc_irrig_rate_patch should probably just be irrig_rate_patch
  • To improve code readability, try to minimize the number of places that things are set. E.g. sfc_irrig_rate_patch should not be set in both IrrigationMod and IrrigationStreamMod.
  • Where things are in column loops, change them to patch loops followed by p2c() calls. This will allow flexibility in case we ever have multiple irrigated PFTs on a single column, at the cost of more memory usage.
  • Add option, set on stream file, to prevent drainage for irrigated crops.
  • Unit testing: Get test_irrigation.pf to compile. Done with 6a4de49.
  • Unit testing: Get test_irrigation_suite to pass.
  • Add new unit tests?
  • Add system testing.

All unit test results seem to be zero. This happens with soil_water_retention_curve uninitialized in calculateIrrigation(), as in this commit, as well as with it initialized. Making it pointer instead of allocatable makes no difference in either case.
@YiYaoVUB YiYaoVUB closed this Aug 20, 2023
@YiYaoVUB
Copy link
Author

Sorry Sam I may close it accidently.

@YiYaoVUB YiYaoVUB reopened this Aug 20, 2023
@swensosc
Copy link
Contributor

swensosc commented Aug 21, 2023 via email

@swensosc
Copy link
Contributor

swensosc commented Aug 22, 2023 via email

@ekluzek
Copy link
Collaborator

ekluzek commented Jan 19, 2024

There is more work to be done here. So I'm changing it to a draft. It's still important that just helps us to see what is ready to go now and what is a work in progress.

@ekluzek ekluzek marked this pull request as draft January 19, 2024 18:18
@samsrabin samsrabin added science Enhancement to or bug impacting science and removed enh - new science labels Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new capability or improved behavior of existing capability science Enhancement to or bug impacting science
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants