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

Get single point surface datasets from subset_data rather than mksurfdata #1812

Merged
merged 122 commits into from
Jan 26, 2023

Conversation

ekluzek
Copy link
Collaborator

@ekluzek ekluzek commented Jul 15, 2022

Description of changes

Get the single point surface datasets to be created using subset_data rather than mksurfdata.

Specific notes

Contributors other than yourself, if any: @negin513

CTSM Issues Fixed (include github issue #):
Fixes #1676
Fixes #1674
Fixes #1809
Fixes #1941
Fixes #1942
Fixes #1924

Are answers expected to change (and if so in what way)? Yes (for single point sites)

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

Testing performed, if any: just running make for single point dataset files in tools/mksurfdata_map

Add outputs for annual crop sowing and harvest dates

Added annual outputs of sowing and harvest dates (`SDATES` and `HDATES`,
respectively). This should simplify the determination of sowing and
harvest date for postprocessing.
- Sowing dates are on new dimension `mxgrowseas` (maximum number of
  growing seasons allowed to begin in a year; currently hard-coded to 1).
- Harvest dates are on new dimension `mxharvests` (maximum number of
  harvests allowed in a year), which is `mxgrowseas`+1. This is needed
  because in year Y you might harvest a field that was planted in year
  Y-1, then plant and harvest again.
- The lengths of these dimensions are public constants of `clm_varpar`.

Additionally, removed `cropplant` as discussed here:
<ESCOMP#1500 (comment)>.

The `mxharvests` concept enables the addition of more such outputs to
further simplify crop postprocessing—for example, yield per growing
season as a direct output rather than needing to cross-reference daily
grain mass against the day of harvest.

These changes involved some rework to the crop phenology code that
changes answers for crop phenology in some circumstances. All answer
changes were determined to be due to issues / oddities in the old code.
See discussion in ESCOMP#1616 for details
(especially see
ESCOMP#1616 (comment)). To
summarize briefly, some issues with the old code were:
- Non-winter-cereal patches that had live crops at the beginning of the
  year did not get planted later that year.
- There was some odd behavior for rice patches at exactly 0 deg latitude
- Crop root depth had unexpected values outside the growing season; now
  root depth is set to 0 outside the growing season
Fix accumulation variables when changing model time step

Accumulation variables (e.g., 1-day or 10-day averages) were writing and
reading their accumulation period (expressed in time steps) to the
restart file. This caused incorrect behavior when changing the model
time step relative to what was used to create the initial conditions
file (typically a 30-minute time step). So, for example, if you are
using a 15-minute time step with an initial conditions file that
originated from a run with a 30-minute time step (at some point in its
history), then an average that was supposed to be 10-day instead becomes
5-day; an average that was supposed to be 1-day becomes 12-hour, etc.
(The issue is that the number of time steps in the averaging period was
staying fixed rather than the actual amount of time staying fixed.)

For our out-of-the-box initial conditions files, this only impacts runs
that use something other than a 30-minute time step. Typically this
situation arises in configurations with an active atmospheric model that
is running at higher resolution than approximately 1 degree. It appears
that the biggest impacts are on VOC emissions and in BGC runs; we expect
the impact to be small (but still non-zero) in prescribed phenology (SP)
runs that don't use VOC emissions.

This tag fixes this issue by no longer writing or reading accumulation
variables' PERIOD to / from the restart file: this isn't actually needed
on the restart file.

See some discussion in ESCOMP#1789 for
more details, and see
ESCOMP#1802 (comment) for
some discussion of outstanding weirdness that can result for
accumulation variables when changing the model time step. The summary of
that comment is: There could be some weirdness at the start of a run,
but at least for a startup or hybrid run, that weirdness should work
itself out within about the first averaging period. A branch or restart
run could have some longer-term potential weirdness, so for now I think
we should recommend that people NOT change the time step on a branch or
restart run. With (significant?) additional work, we could probably
avoid this additional weirdness, but my feeling is that it isn't worth
the effort right now. In any case, I feel like my proposed fix will
bring things much closer to being correct than they currently are when
changing the time step.
Fix accumulation variables when changing model time step

Accumulation variables (e.g., 1-day or 10-day averages) were writing and
reading their accumulation period (expressed in time steps) to the
restart file. This caused incorrect behavior when changing the model
time step relative to what was used to create the initial conditions
file (typically a 30-minute time step). So, for example, if you are
using a 15-minute time step with an initial conditions file that
originated from a run with a 30-minute time step (at some point in its
history), then an average that was supposed to be 10-day instead becomes
5-day; an average that was supposed to be 1-day becomes 12-hour, etc.
(The issue is that the number of time steps in the averaging period was
staying fixed rather than the actual amount of time staying fixed.)

For our out-of-the-box initial conditions files, this only impacts runs
that use something other than a 30-minute time step. Typically this
situation arises in configurations with an active atmospheric model that
is running at higher resolution than approximately 1 degree. It appears
that the biggest impacts are on VOC emissions and in BGC runs; we expect
the impact to be small (but still non-zero) in prescribed phenology (SP)
runs that don't use VOC emissions.

This tag fixes this issue by no longer writing or reading accumulation
variables' PERIOD to / from the restart file: this isn't actually needed
on the restart file.

See some discussion in ESCOMP#1789 for
more details, and see
ESCOMP#1802 (comment) for
some discussion of outstanding weirdness that can result for
accumulation variables when changing the model time step. The summary of
that comment is: There could be some weirdness at the start of a run,
but at least for a startup or hybrid run, that weirdness should work
itself out within about the first averaging period. A branch or restart
run could have some longer-term potential weirdness, so for now I think
we should recommend that people NOT change the time step on a branch or
restart run. With (significant?) additional work, we could probably
avoid this additional weirdness, but my feeling is that it isn't worth
the effort right now. In any case, I feel like my proposed fix will
bring things much closer to being correct than they currently are when
changing the time step.
@ekluzek ekluzek added enhancement new capability or improved behavior of existing capability code health improving internal code structure to make easier to maintain (sustainability) labels Jul 15, 2022
@ekluzek ekluzek self-assigned this Jul 15, 2022
Minor changes to python scripts and usermod_dirs for NEON cases. Also update the lightning mesh file so that it goes with the
smaller lightning file. Have NEON use new use-cases for 2018 and 2018-PD conditions for CLM. Have NEON
Agricultural sites run with prognostic crop. Simple fix for warning about NaN's in import/export data from/to coupler.

Get NEON tests working on izumi, add --inputdata-dir to subset_data and modify_singlept_site_neon.py so they aren't tied
to only running on cheyenne.

Also update MOSART with fixed for direct_to_outlet option.

Add error checking in ParitionWoodFluxes.  Fix value of albgrd_col in SurfaceAlbefdoType.F90.
Previously, the wrong value (albgri_col) was being set in InitHistory

 Conflicts:
	Externals.cfg
This set of changes allows CTSM to continue API compatability with changes to the FATES API. FATES has updated its nutrient dynamics routine, and required a modification to the test environment, some minor updates to variable dimensions in the history, and a call to a new FATES history routine.  Implicitly, the updating of the FATES tag introduces new content in the FATES model since the last API update (mostly bug fixes).
… can be tested, fix some lint and black issues
…s always used, which will make it easier to remove the use of 16pft versions which we do want to do
This set of changes allows CTSM to continue API compatability with changes to the FATES API. FATES has updated its nutrient dynamics routine, and required a modification to the test environment, some minor updates to variable dimensions in the history, and a call to a new FATES history routine.  Implicitly, the updating of the FATES tag introduces new content in the FATES model since the last API update (mostly bug fixes).
@ekluzek
Copy link
Collaborator Author

ekluzek commented Jan 24, 2023

All testing is good other than the FSURDATMODIFYCTSM_D_Mmpi-serial_Ld1.5x5_amazon.I2000Clm50SpRs.cheyenne_intel test. There's an additional command line option that I need to give for it. I'm also working on it to make a failed test more obvious to debug.

I also found out that if you run once, it creates the output file and then aborts as it says the file is already created. So we should add an "--overwrite" option to overwrite the file if it already exists. I could add embedded code to remove the file if it exists, but the overwrite option would make it more obvious what it is doing.

@ekluzek
Copy link
Collaborator Author

ekluzek commented Jan 25, 2023

OK, tests that are the same as ctsm5.1.dev115 the previous tag are the following 39:

Note, that very few of these are BGC cases because the Maintenance Respiration difference will make a difference to most BGC cases. But, FATES and SP cases are more likely to be the same.

  • ERP_D_Ld5.f10_f10_mg37.I2000Clm50Vic.cheyenne_intel.clm-vrtlay
  • ERP_D_Ld5.f10_f10_mg37.IHistClm45Sp.cheyenne_intel.clm-decStart
  • ERP_Ld5.f10_f10_mg37.I2000Clm50Vic.cheyenne_gnu.clm-decStart
  • ERP_Ld9.f45_f45_mg37.I2000Clm50FatesRs.cheyenne_intel.clm-FatesColdAllVars
  • ERP_P144x2_Ld30.f45_f45_mg37.I2000Clm50FatesRs.cheyenne_intel.clm-mimicsFatesCold
  • ERP_P36x2_D.f10_f10_mg37.I2000Clm50SpRtmFl.cheyenne_intel.clm-default
  • ERP_P36x2_D_Ld5.f10_f10_mg37.I2000Clm45Sp.cheyenne_intel.clm-default
  • ERP_P36x2_Ld30.f45_f45_mg37.I2000Clm51FatesSpCruRsGs.cheyenne_intel.clm-FatesColdSatPhen
  • ERS_D_Ld3_PS.f09_g17.I2000Clm50FatesRs.cheyenne_intel.clm-FatesCold
  • ERS_D_Mmpi-serial_Ld5.5x5_amazon.I2000Clm50FatesRs.cheyenne_intel.clm-FatesCold
  • ERS_D_Mmpi-serial_Ld5.5x5_amazon.I2000Clm51FatesRs.cheyenne_intel.clm-FatesCold
  • ERS_Ld30.f45_f45_mg37.I2000Clm50FatesRs.cheyenne_intel.clm-FatesColdFixedBiogeo
  • ERS_Ld30.f45_f45_mg37.I2000Clm50FatesRs.cheyenne_intel.clm-FatesColdSizeAgeMort
  • ERS_Ld9.f10_f10_mg37.I2000Clm50FatesCruRsGs.cheyenne_intel.clm-FatesColdCH4Off
  • FSURDATMODIFYCTSM_D_Mmpi-serial_Ld1.5x5_amazon.I2000Clm50SpRs.cheyenne_intel
  • FUNITCTSM_P1x1.f10_f10_mg37.I2000Clm50Sp.cheyenne_intel
  • LILACSMOKE_D_Ld2.f10_f10_mg37.I2000Ctsm50NwpSpAsRs.cheyenne_intel.clm-lilac
  • PFS_Ld10_PS.f19_g17.I2000Clm50BgcCrop.cheyenne_intel
  • SMS.f45_f45_mg37.I2000Clm51FatesSpRsGs.cheyenne_nvhpc.clm-FatesColdSatPhen
  • SMS_D_Ld1_Mmpi-serial.f45_f45_mg37.I2000Clm50SpRs.cheyenne_intel.clm-ptsRLA
  • SMS_D_Ld5.f10_f10_mg37.I2000Clm45Fates.cheyenne_intel.clm-FatesCold
  • SMS_D_Ld5.f10_f10_mg37.I2000Clm50FatesRs.cheyenne_gnu.clm-FatesCold
  • SMS_D_Ld5.f10_f10_mg37.I2000Clm50FatesRs.cheyenne_intel.clm-FatesCold
  • SMS_D_Lm1_Mmpi-serial.CLM_USRDAT.I1PtClm50SpRs.cheyenne_intel.clm-USUMB_nuopc
  • SMS_D_Lm6_P144x1.f45_f45_mg37.I2000Clm50FatesRs.cheyenne_intel.clm-FatesCold
  • SMS_D_Vmct_Lm1_Mmpi-serial.CLM_USRDAT.I1PtClm50SpRs.cheyenne_intel.clm-USUMB_mct
  • SMS_Ld1_PS.nldas2_rnldas2_mnldas2.I2000Ctsm50NwpSpNldasRs.cheyenne_gnu.clm-default
  • SMS_Ld5.f10_f10_mg37.I2000Clm45Fates.cheyenne_intel.clm-FatesCold
  • SMS_Ld5.f10_f10_mg37.I2000Clm50FatesRs.cheyenne_intel.clm-FatesCold
  • SMS_Ld5_PS.f19_g17.I2000Clm50FatesRs.cheyenne_gnu.clm-FatesCold
    • ERS_Ld30.f45_f45_mg37.I2000Clm50FatesRs.izumi_intel.clm-FatesColdFixedBiogeo
  • SMS_D_Ld1_Mmpi-serial.f45_f45_mg37.I2000Clm50SpRs.izumi_gnu.clm-ptsRLA
  • SMS_D_Ld1_Mmpi-serial.f45_f45_mg37.I2000Clm50SpRs.izumi_gnu.clm-ptsROA
  • SMS_D_Ld1_Mmpi-serial.f45_f45_mg37.I2000Clm50SpRs.izumi_nag.clm-ptsRLA
  • SMS_D_Ld5.f10_f10_mg37.I2000Clm50FatesRs.izumi_nag.clm-FatesCold
  • SMS_D_Mmpi-serial.CLM_USRDAT.I1PtClm51Bgc.izumi_nag.clm-default--clm-NEON-NIWO
  • SMS_D_Mmpi-serial_Ld5.5x5_amazon.I2000Clm50FatesRs.izumi_nag.clm-FatesCold
  • SMS_Ld5.f10_f10_mg37.I2000Clm45Fates.izumi_intel.clm-FatesCold
  • SMS_Ld5.f10_f10_mg37.I2000Clm50FatesRs.izumi_intel.clm-FatesCold

The are all short (the longest is 6-months). The single point cases aren't in the list as expected. Most are older physics as only the CLM51 cases will feel the zetamaxstable change.

There are only four CLM51 tests that show a difference in answers. I'm guessing the grids are small enough and they are run short enough that the zetamaxstable difference just doesn't happen to show up.

  • ERP_P36x2_Ld30.f45_f45_mg37.I2000Clm51FatesSpCruRsGs.cheyenne_intel.clm-FatesColdSatPhen
  • ERS_D_Mmpi-serial_Ld5.5x5_amazon.I2000Clm51FatesRs.cheyenne_intel.clm-FatesCold
  • SMS.f45_f45_mg37.I2000Clm51FatesSpRsGs.cheyenne_nvhpc.clm-FatesColdSatPhen
  • SMS_D_Mmpi-serial.CLM_USRDAT.I1PtClm51Bgc.izumi_nag.clm-default--clm-NEON-NIWO

There's 35 total CLM51 tests, so 31 of them showed differences in answers.

@ekluzek ekluzek merged commit f10353e into ESCOMP:master Jan 26, 2023
@ekluzek ekluzek deleted the fsurdat_4_1x1_from_subset branch January 26, 2023 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment