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

first_year and last_year in stream definition should be more general #62

Open
billsacks opened this issue Mar 30, 2021 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@billsacks
Copy link
Member

I noticed that many (all?) of the stream_definition xml files define a first_year and last_year like this:

https://github.com/billsacks/CDEPS/blob/48a26e6e39a0a1dbfca506192fab089344f49725/datm/cime_config/stream_definition_datm.xml#L206

I see two problems with this:

  1. If you change the start & end years defined in config_component, you need to also change these years; it isn't obvious that you need to do this.
  2. I think this reduces flexibility for a user who may want to set custom start & end years for forcing data for their case.

A simple fix is to expand these years to have a ridiculously huge range, as I did in 48a26e6

I think a cleaner fix would involve making first_year and last_year optional here. From a quick glance through the code that parses this, it looks like these may currently be required.

@billsacks billsacks added the enhancement New feature or request label Mar 30, 2021
@billsacks
Copy link
Member Author

I did some testing that suggests that first_year and last_year are currently required for the list of stream files to be created correctly. This seems to be the responsible code:

if 'first_year' in child.xml_element.attrib and 'last_year' in child.xml_element.attrib:
value = child.xml_element.get('first_year')
value = self._resolve_values(case, value)
stream_year_first= int(value)
value = child.xml_element.get('last_year')
value = self._resolve_values(case, value)
stream_year_last = int(value)
year_first = max(stream_year_first, data_year_first)
year_last = min(stream_year_last, data_year_last)
stream_datafiles = self._sub_paths(stream_datafiles, year_first, year_last)
stream_datafiles = stream_datafiles.strip()

My initial thought on how to resolve this is:

  • Have separate conditionals for first_year and last_year (that way you can have open-ended ranges, such as: one range that goes from any start year up through 1999 and another range that goes from 2000 through any end year)
  • For each of these conditionals: if the attribute (e.g., 'first_year') is present, then use the current logic; but then add an else block for the attribute absent, where it simply sets year_first (or year_last) to data_year_first (or data_year_last)
  • Then the last two lines (setting stream_datafiles) should be done outside of any conditional

I haven't tested this.

@ekluzek
Copy link
Collaborator

ekluzek commented May 8, 2021

This is related somewhat to #82. @billsacks we should likely discussion this more...

uturuncoglu pushed a commit to uturuncoglu/CDEPS that referenced this issue Jul 15, 2024
* Adapt docn_datamode_cplhist for dice_datamode_cplhist

* Fix .or. and local  variables have different names in docn and dice

* Add Si_imask. Decide whether to have flds_i2o_per_cat for cplhist method.

* Copy sea ice stream fields to export state fields via dshr_dfield_add

* Switches So_t from C to K. Decide on which/add switch

* Overwrite missing value of 0 K in Si_t

* Handle So_t in C and K in docn_datamode_cplhist_mod.F90

Need model SST to be in K
if (minval(So_t) .LT. 100.0_r8), convert C-->K

* Only fill docn_datamode_cplhist export variables if associated. Handle units of So_t based on namelist input

* Default convert SST C to K (as currently). Then switch based on optional sst_constant_value

* Allow null return for taux too in dice/dice_datamode_cplhist_mod.F90

* Add doc for dice cplhist mode to dice.rst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

3 participants