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

Optionally base GDD20 on per-gridcell windows, not per-hemisphere #2593

Merged

Conversation

samsrabin
Copy link
Collaborator

@samsrabin samsrabin commented Jun 9, 2024

Description of changes

In the existing code, when using the default CLM crop calendars, gddmaturity (maturity requirement; the number of growing degree-days it takes for a crop to mature and be harvested) can vary within some bounds based on climate over the past 20 years. Specifically, CLM looks at some annual "warm period" which differs between the northern and southern hemispheres, which I call the "GDD20 season." This variation allows "farmers" to adapt the "cultivars" (varieties) they grow based on recent climate.

When prescribing maturity requirement, though—with input file stream_fldFileName_cultivar_gdds—it's currently not allowed to vary over time. Instead, it's locked in to what's provided in the input file: the mean GDD accumulation in the GGCMI growing period over the 1980-2009 growing seasons.

We want this variation to allow "farmers" to adapt the "varieties" they grow based on whether the recent climate has been warmer or cooler than that baseline 1980-2009 period.

This PR represents the second step toward adding that ability. I'm breaking this work up into separate PRs to keep them manageable:

  1. (Allow prescribed gddmaturity to vary based on recent climate (initial work, v2) #2560) Define "recent climate" based on the same "warm period" currently used by default CLM.
  2. (This PR) Define "recent climate" based on the GGCMI growing seasons.
  3. Restrict adapted gddmaturity values to a realistic range.

Specific notes

Other features/changes

  • Adds "Cidadinho" test site (like Smallville but in the Southern Hemisphere)
  • Fixes PEM test failures resulting from ambiguous nearest neighbors
  • Fixes PEM test failures resulting from bad reset of sowing_reason_perharv_patch
  • Adds RXCROPMATURITYSKIPGEN SystemTest, which is like RXCROPMATURITY but doesn't actually generate GDDs. Allows short testing with existing GDD inputs. Included in aux_clm as RXCROPMATURITYSKIPGEN_Ld1097.f10_f10_mg37.IHistClm50BgcCrop.derecho_intel.clm-cropMonthOutput.
  • Adds various crop calendar testmods, with some added to aux_clm and crop_calendars test suites.
  • Adds output variables GDD20_BASELINE, GDD20_SEASON_START, GDD20_SEASON_END

Contributors other than yourself, if any: None

CTSM Issues Fixed:

Are answers expected to change (and if so in what way)? Not unless enabling this new, experimental feature.

Any User Interface Changes (namelist or namelist defaults changes)?

  • Adds namelist logical stream_gdd20_seasons (default false). Enabling this automatically sets the relevant input files (see below) to the half-degree GGCMI growing seasons.
  • Adds input files stream_fldFileName_gdd20_season_start and _end (default '', unless stream_gdd20_seasons is true, in which case the GGCMI sowing and harvest dates are used). Providing either file but stream_gdd20_seasons = .true. will cause an error in the build namelist step.
  • Adds namelist logical flush_gdd20 (default false), which if true causes the accumulated GDD20 variables to be reset as soon as possible.
  • Adds namelist logical allow_invalid_gdd20_season_inputs (default false), which if false will cause a failure upon reading a value in stream_fldFileName_gdd20_season_start or _end outside the range [1, 365] (or 366 in leap years).

Does this create a need to change or add documentation? Did you do so? Documentation will need to be updated when all the PRs in my plan are merged and this feature is considered ready for use. But at this point, things are preliminary enough that I'd have to rewrite whatever docs I added in this PR. So no: I'm adding no documentation here.

Testing performed, if any:

  • As of 2274263: aux_clm results are bit-for-bit identical with ctsm5.2.005, although there was a build failure in one nag compiler test.
  • In a 1958-2010 run at f19 resolution, using the GGCMI-based GDD20 seasons made little difference in most crops. Rice and cotton, however, were decimated. I'm not 100% sure why, so I will plan to include this only as an option, not a default.

Previously, TemperatureType%flush_gdd20 would get set to true upon restart unless it was read and false. This change makes it so that:
- If TemperatureType%flush_gdd20 isn't read from the restart file, it falls back to the flush_gdd20 from clm_varctl.
- If TemperatureType%flush_gdd20 IS read from the restart file, it is set to true if it's true on the restart file OR if the flush_gdd20 from clm_varctl is true.
Not directly, at least. Instead, rely on TemperatureType%flush_gdd20 having been set correctly.
Having that alongside flush_gdd20 from clm_varctl means that they can disagree when restarting, and it's not obvious which should win.

Note that the user being able to request a flush at all is dangerous. If they start a run with it true, they might continue that run without setting it to false. Instead, the restart decision should be made by the model---if a gridcell has different prescribed gdd20 season from what its restart file says, then that gridcell should be flushed.
@samsrabin
Copy link
Collaborator Author

@slevis-lmwg In 827632e, I resolved the "two flush_gdd20s" question by removing the one that was a member of TemperatureType. Having that alongside flush_gdd20 from clm_varctl meant that they could disagree when restarting, and it's not obvious which should win.

Note that the user being able to request a flush at all is dangerous. If they start a run with it true, they might continue that run without setting it to false. Instead, the restart decision should be made by the model—if a gridcell has different prescribed GDD20 season from what its restart file says, then that gridcell should be flushed.

I will plan to make that change in a future update, post-code-freeze. It only affects things when streaming GDD20 seasons, which will not be a default behavior, so I think it's okay to leave things as they are now.

SMS_P128x1_Lm25.f10_f10_mg37.IHistClm60BgcCrop.izumi_nag.clm-RxCropCalsAdaptGGCMI
@samsrabin
Copy link
Collaborator Author

samsrabin commented Jul 25, 2024

For some reason I'm getting an unexpected change in ERP_D_P128x1_Ld26.f10_f10_mg37.IHistClm60BgcCrop.derecho_intel.clm-midDecStart--clm-RxCropCalsAdaptGGCMI and its PEM version.

ERP_D_P128x1_Ld26.f10_f10_mg37.IHistClm60BgcCrop.derecho_intel.clm-midDecStart--clm-RxCropCalsAdaptGGCMI
2024-07-24 18:33:49: NLCOMP
Comparison failed between '/glade/derecho/scratch/samrabin/tests_0724-183247de/ERP_D_P128x1_Ld26.f10_f10_mg37.IHistClm60BgcCrop.derecho_intel.clm-midDecStart--clm-RxCropCalsAdaptGGCMI.GC.0724-183247de_int/CaseDocs/lnd_in' with '/glade/campaign/cgd/tss/ctsm_baselines/scale-mat-reqs-pr2-ggcmiseas.22742634/ERP_D_P128x1_Ld26.f10_f10_mg37.IHistClm60BgcCrop.derecho_intel.clm-midDecStart--clm-RxCropCalsAdaptGGCMI/CaseDocs/lnd_in'
  BASE: stream_fldfilename_gdd20_baseline = gdd20bl.copied_from.gdds_20230829_161011.v2.tweaked_latlons.nc'
  COMP: stream_fldfilename_gdd20_baseline = 20230714_cropcals_pr2_1deg.actually2deg.1980-2009.from_GDDB20.interpd_halfdeg.tweaked_latlons.nc'

stream_fldfilename_gdd20_baseline should not have changed. In the baseline (2274263), the relevant bit of namelist_defaults_ctsm.xml looked like this:

<stream_fldFileName_gdd20_baseline cropcals_rx_adapt=".true.">lnd/clm2/cropdata/calendars/processed/gdd20bl.copied_from.gdds_20230829_161011.v2.tweaked_latlons.nc</stream_fldFileName_gdd20_baseline>

And in the latest test (aeb4182) it looked like this:

<stream_fldFileName_gdd20_baseline cropcals_rx_adapt=".true." stream_gdd20_seasons=".false.">lnd/clm2/cropdata/calendars/processed/20230714_cropcals_pr2_1deg.actually2deg.1980-2009.from_GDDB20.interpd_halfdeg.tweaked_latlons.nc</stream_fldFileName_gdd20_baseline>
<stream_fldFileName_gdd20_baseline cropcals_rx_adapt=".true." stream_gdd20_seasons=".true.">lnd/clm2/cropdata/calendars/processed/gdd20bl.copied_from.gdds_20230829_161011.v2.tweaked_latlons.nc</stream_fldFileName_gdd20_baseline>

These two tests have cropcals_rx_adapt and stream_gdd20_seasons both true, but it's like CLMBuildNamelist.pm doesn't know about the latter.

This issue still exists as of 388c7ed.

  • Resolve this!

@mvdebolskiy
Copy link
Contributor

mvdebolskiy commented Jul 25, 2024

I think the issue is here:

add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldFileName_gdd20_baseline');

does not get the seasons var at all.
Try:

add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldFileName_gdd20_baseline', "stream_gdd20_seasons"=>$stream_gdd20_seasons->as_string() );

Alternatively, set_value(stream_gdd20_seasons) for can be used before adding default for stream_fld....

@samsrabin
Copy link
Collaborator Author

That's it! The exact diff needed, for posterity:

diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm
index 5202717d7..04d2ee37b 100755
--- a/bld/CLMBuildNamelist.pm
+++ b/bld/CLMBuildNamelist.pm
@@ -4211,7 +4211,7 @@ sub setup_logic_cropcal_streams {
     add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldFileName_swindow_end');
     add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldfilename_cultivar_gdds');
     if ( &value_is_true($cropcals_rx_adapt) ) {
-      add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldFileName_gdd20_baseline');
+      add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldFileName_gdd20_baseline', 'stream_gdd20_seasons'=>$stream_gdd20_seasons);
     }
   }

Thanks, @mvdebolskiy!!

@samsrabin
Copy link
Collaborator Author

@slevis-lmwg So as to not have to redo the test suites I have in progress, I will NOT bring in Matvey's fix here or in the next PR (where I merge the latest CTSM master into my dev branch). Instead, I'll bring it in as the first thing on the PR where I enable cropcals_rx_adapt by default.

@samsrabin
Copy link
Collaborator Author

@slevis-lmwg This is ready for re-review.

@slevis-lmwg
Copy link
Contributor

@samsrabin I just wanted to confirm that you will track the items left pending from this PR, such as these:
#2593 (comment)
#2593 (comment)

@samsrabin
Copy link
Collaborator Author

Good thinking. I've made the first one into issue #2660. I'm fixing the second as we speak, so I won't make a separate issue for that.

@samsrabin samsrabin merged commit 4b18928 into ESCOMP:scale-maturity-reqs Jul 25, 2024
2 checks passed
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
Projects
Status: Ready to eat (Done!)
Status: Done (non release/external)
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants