Feat: add upper limit to nlayer to avoid run crashes#1206
Conversation
…ing SPARTACUS layers more than 15
nlayer to avoid run crashes
CI Build PlanChanged FilesPython source (2 files)
Documentation (2 files)
Build Configuration
Rationale
Updated by CI on each push. See path-filters.yml for category definitions. |
Preview Deployed
Note This preview is ephemeral. It will be lost when:
To restore, push any commit to this PR. |
|
hi @sunt05 - I discovered this last week while discussing with other users that are doing dev and runs with SPARTACUS. I checked again this week while working on SPARTACUS veg and we actually have a limit in fortran code at 15 - so I added that to Pydantic. Minimal change but still let me know if this sounds good to you! I will add the CHANGELOG after approval. |
|
This should tell the user they will need to change the Fortran if > 15. |
Co-authored-by: Ting Sun <ting.sun@ucl.ac.uk>
let me know if we are happy with the changes! |
| value_display = f" (value={nlayer_value})" if nlayer_value is not None else "" | ||
| report_lines.append(f"-- {path}{value_display}: {message}") | ||
| report_lines.append( | ||
| "Note: If you need nlayer>15 for your run, consider to change SPARTACUS Fortran code and Pydantic nlayer Field constraints to allow more layers." |
There was a problem hiding this comment.
We should probably frame this as a constraint rather than expecting the user to change the Fortran code, which doesn’t seem reasonable at this point, right?
There was a problem hiding this comment.
I agree. But shall we leave this as a NO ACTION NEEDED warning or enforce a proper stop/ACTION NEEDED?
I would suggest the first one, warning the user that the model will not run otherwise (as we also have an hard stop with the guard in Pydantic)
There was a problem hiding this comment.
Sounds good. Also please rephrase the warning message.
There was a problem hiding this comment.
We should probably frame this as a constraint rather than expecting the user to change the Fortran code, which doesn’t seem reasonable at this point, right?
-
15 stops the model - but if needed - as we have for some key tests - this can be adjusted in the FORTRAN - so we are not asking the user to do it - but is scientifically possible
There was a problem hiding this comment.
@sunt05 @suegrimmond what about something like:
nlayer={nlayer} exceeds the supported range [1, 15]. SUEWS will not run with this setting. Reduce nlayer to 15 or fewer layers; higher values are possible but need changes in the code.
Not sure if this phrasing would work. Otherwise, we can discuss this on Tue meeting :)
|
Thanks @dayantur for this - I've updated the warning message to be clearer - merging this now. |
At the moment, SPARTACUS has hardcoded dimension 15 for nlayer, and so that should be reflected in a upper limit in the nlayer input Pydantic class. This PR adds
leto Field ofnlayerinsurface.pyto prevent run crashes.