CICE-Consortium / Icepack

Development repository for sea-ice column physics
Other
25 stars 131 forks source link

Refactor optional argument implementation for isotopes, snwgrain, therm1 and therm2 #423

Closed apcraig closed 1 year ago

apcraig commented 1 year ago

PR checklist

apcraig commented 1 year ago

This refactors the isotope implementation using the newer design, passing optional arguments down the calling tree and using the argcheck design. If this seems reasonable, I will refactor other Icepack features in a similar way where reasonable. Do we want a PR for each feature refactor or just one (or a few) PRs to cover multiple feature refactors? Would like to get some feedback before moving forward.

This should be bit-for-bit and has no impact on the public interfaces. Will run comprehensive tests to confirm TBD.

eclare108213 commented 1 year ago

Do we want a PR for each feature refactor or just one (or a few) PRs to cover multiple feature refactors?

One or a few to cover multiple features would be fine, but if something is particularly complicated, then just do that by itself. E.g. I imagine that the thermodynamics will be complicated, since there are many options that feed into it.

apcraig commented 1 year ago

I think it may be worth reviewing and merging this now. Most of the therm1 and therm2 optional arguments have been refactored. Still waiting on some additional insight about meltsliq, but that can be done in a separate PR.

apcraig commented 1 year ago

Icepack and CICE test suites are bit-for-bit.

phil-blain commented 1 year ago

This refactors the isotope implementation using the newer design, passing optional arguments down the calling tree and using the argcheck design. If this seems reasonable, I will refactor other Icepack features in a similar way where reasonable.

I think this is a nice clean up, it improves readability, I think. Also, gotta love a PR that removes more lines of code than it adds ;)

Do we want a PR for each feature refactor or just one (or a few) PRs to cover multiple feature refactors? Would like to get some feedback before moving forward.

If I were doing it, I think I would probably do it that way:

This would be very much more pleasant to review, at least for me :)

Also I would avoid changing the order of the variables attributes (like moving optional to be the last attributes, with no other changes). This adds a lot of noise to the diffs. If we want to make such changes, that's OK, but I'd prefer if it were done in separate commits.

Thanks a lot for starting the work on this! :)

apcraig commented 1 year ago

Just a few comments and questions -

I do worry a bit about Phil's comment here, regarding non-Fortran codes being able to use Icepack with Fortran keywords and optional arguments. What should we do about that?

One option is for the non-Fortran interfaces to NOT adopt the optional arguments in their interfaces/uses. So non-Fortran might pass all arguments even if they are not needed. I don't actually know whether that will work for all languages, but we should explore as an appropriate time. I think for now, we should continue to add optional arguments moving forward. It provide backwards compatibility in the current community. If at some point in the future, we decide to not have optional arguments in icepack, we just remove the optional attribute on the Icepack interfaces and then update any interfaces in CICE/Icepack that do not conform. Everyone in the community would have to do the same, also anytime Icepacks is updated with any new arguments. That's the downside overall. I don't think we should abandon optional arguments until there is a clear reason to do so.

eclare108213 commented 1 year ago

Just a few comments and questions - I do worry a bit about Phil's comment here, regarding non-Fortran codes being able to use Icepack with Fortran keywords and optional arguments. What should we do about that?

One option is for the non-Fortran interfaces to NOT adopt the optional arguments in their interfaces/uses. So non-Fortran might pass all arguments even if they are not needed. I don't actually know whether that will work for all languages, but we should explore as an appropriate time. I think for now, we should continue to add optional arguments moving forward. It provide backwards compatibility in the current community. If at some point in the future, we decide to not have optional arguments in icepack, we just remove the optional attribute on the Icepack interfaces and then update any interfaces in CICE/Icepack that do not conform. Everyone in the community would have to do the same, also anytime Icepacks is updated with any new arguments. That's the downside overall. I don't think we should abandon optional arguments until there is a clear reason to do so.

The voice of reason - sounds good to me.

eclare108213 commented 1 year ago

Looks like there are just a few minor changes that could be made here. @apcraig let us know when you're ready to merge.

apcraig commented 1 year ago

cheyenne was down this week and i'm away from home, should be able to make progress next few days. will update conversation when updates are ready.

apcraig commented 1 year ago

I've updated the PR and running a full test suite now. Added icepack_chkoptargflag logical function and cleaned up a few other things associated with comments above. Feel free to review, will report updated results in the next day or so.

apcraig commented 1 year ago

CICE testing is complete with latest changes and everything looks good.