ESCOMP / CTSM

Community Terrestrial Systems Model (includes the Community Land Model of CESM)
http://www.cesm.ucar.edu/models/cesm2.0/land/
Other
301 stars 306 forks source link

fsurdat_modifier should fail if subgrid_fractions section is incomplete #2357

Open samsrabin opened 7 months ago

samsrabin commented 7 months ago

Presently, it's possible to have an fsurdat_modifier config file with this specification:

[modify_fsurdat_subgrid_fractions]
PCT_CROP    = 100.0
PCT_NATVEG  = 0.0
PCT_GLACIER = 0.0
PCT_LAKE    = 0.0
PCT_URBAN   = 0.0 0.0 0.0

fsurdat_modifier will happily set all those and leave the missing item, PCT_WETLAND, alone. If PCT_WETLAND is nonzero anywhere on the original file, this will eventually cause a "weights do not sum to 100" error in the CESM run.

fsurdat_modifier only checks that the provided PCT_ variables sum to 100. I think it would make more sense for it to also fail if any PCT_ variable is missing from the configuration file (if the modify_fsurdat_subgrid_fractions section is present, that is). Is there a reason this isn't the case?

For future-proofing, fsurdat_modifier could derive valid_list from the input surface dataset, rather than the list being hard-coded and needing an update with every CTSM version.

(This arose in @slevis-lmwg's testing of the RXCROPMATURITY SystemTest with CTSM5.2, which splits PCT_OCEAN out of PCT_WETLAND. As you can see, RXCROPMATURITY didn't include PCT_OCEAN.)

slevis-lmwg commented 7 months ago

@samsrabin thank you for tracking this down. For now I'm fixing the failing test by adding PCT_OCEAN where it was missing. I will address this better (as you proposed) at a later time.

samsrabin commented 6 months ago

From SE meeting 2024-02-15: Let's make it fail in such a case.