-
Notifications
You must be signed in to change notification settings - Fork 7
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
Physical constants #48
Comments
I'll take the easy one, 3. Just define it as hard-coded double rather than Real. Do that consistently in F90 and C++ when needing BFB tests. If implicit type conversion in the presence of multiple types is not the same in C++ and F90 by default, I believe you can add an F90 flag or flags to get it to be the same. |
Oof. BFB. Added item 5 to the discussion. |
I agree this stuff should live in EKAT. I agree with Andrew about making params double by default. I don't think we can be "forward thinking" by just doing this in C++ because of our BFB tests. I'd suggest just copying whatever E3SM uses for our initial version of this constants database (rather than matching NIST) in order to circumvent the BFB issue while still targeting C++ only. Then when we jettison F90, we can update our constants file with NIST values. One problem with what I just said is that E3SM may use different values for the same constant in different places in the code. And collecting E3SM values may be a hassle. |
It does. This means that there will be BFB problems no matter what we do.
It is, but I've already done this for MAM. It's not a particularly exciting day at work, but it's not too bad with some decent background music. |
Yes, Ekat already contains stuff that has nothing to do with Kokkos: yaml, parameter lists, units, std meta-utils,... I actually pondered on whether units should be in Ekat. Eventually I left them there, but I don't feel strongly either way. Regarding constants, I guess Ekat can be a reasonable place to put them. If they have to be used in the atm only, then
Imho, the latter is superior (app-side code can always do |
This is similar to our current approach in haero, but there we don't encapsulate the constants in a struct -- they're namespace variables like the ekat units instantiations.
If we decide to use structs instead, this means we would have multiple structs --- one for required double precision, one that has a template parameter to allow for single precision (which is ok, it's just something the ekat clients would have to know). edit: It's possible there are additional meta programming tricks that I'm currently unaware of. |
Are the constants required in DP always going to be needed in DP only? If so, then yes, you need 2 structs (one for DP only, one templated), otherwise you can just stuff everything in the templated one. |
I'm not sure how far this kind analysis has gone in the broader community... But here's an example:
Output: $ gfortran avogad.f90 -o avo So, a single-precision Avogadro constant represents ~2E19 fewer molecules per kmol than a double-precision version. Over every column, parameterzation, species, and model level, that adds up to a lot of molecules. |
This is an important point. In |
@pbosler only relative error matters. Your point about condition number is the important one. An absolute "big" or "small" number doesn't mean much. |
@ambrad I understand, and the absolute difference I mention primarily to point out the inconsistencies that exist in the code already. At the same time, I'm not sure we (as in the climate modeling community "we") understand well what is or is not ill-conditioned in the coupled model. |
I don't think anyone thinks we should pick up the challenge of making constants uniform across e3sm. Imho, scream could simply stuff them in I feel like Ekat is becoming more and more of a E3SM std library, with features across a wide range of topics. Maybe the name should be re-considered at this point. |
@bartgol I agree that we can't change E3SM without significant help from the core/infrastructure teams; EKAT and SCREAM are good opportunities to demonstrate these design principles so that, perhaps, they might be adopted later. It think it's enough (and certainly challenging enough) to try for a uniform treatment throughout scream. |
Question
What would be the best (or at least acceptable to a majority) way to handle physical constants in a consistent manner throughout scream?
This issue has come up in several recent discussions (e.g., @PeterCaldwell, @AaronDonahue ) and at least 2 issues:
haero issue #6 ( @jeff-cohere and @pbosler )
scream pr #579 (@tcclevenger, @ambrad)
For discussion:
Physical constants have nothing to do with Kokkos, but EKAT already contains other supporting features like
ekat::units
that are also unrelated to performance portability, but generally useful to everything in E3SM, so I'm inclined to put physical constants in EKAT (@bartgol).The text was updated successfully, but these errors were encountered: