-
Notifications
You must be signed in to change notification settings - Fork 137
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
Help with mixed-precision FMS (in GEOS) #1621
Comments
@mathomp4 - It sure looks like a bug since |
@bensonr I did some Fortran overloading (lots of things r became r4 and r8) and I got past the above. (I can share my changes if you like.) I'm now at a new one:
which is interesting because I might mention @marshallward (as he's who I think of when I think MOM6) as maybe he might know why it's reacting like this... |
yep this is a bug, I would work on getting a fix in. Thanks for letting us know! |
|
I'd recommend compiling FMS with default reals defined to be 64-bit (kind=8) quantities. In that way, constants_mod will default to (kind=8) versions and constantsR4_mod will have the (kind=4) complements. You will need to update your dynamical core to choose the correct constants module for proper precision at compile time. The current top of the trunk contains ifdefs for the constants use statements. |
@bensonr Do you mean this PR: NOAA-GFDL/GFDL_atmos_cubed_sphere#360 As you know our FV3 has sort of diverged from the mothership as @wmputman makes changes. But if that PR is all that's needed, shouldn't be too hard to port over and test. Though, of course, if you've made other changes to FV3 to support mixed precision we don't have, then it could be just as bad in that direction. Time to experiment! |
@mathomp4 - that will get you a good chunk of the way towards your goal, though there may be a few constants declarations already in place prior to the FMS mixed-precision work. |
I reckon MOM6 should also be converting It might help things to go more smoothly. It might also expose more serious r4/r8 issues. 🤷 |
@bensonr Hooboy. I might have to try and go the other direction (using fms_r4). Using fms_r8 I've now hit the changes due to fms2_io_mod (I'm guessing I need something a la NOAA-GFDL/GFDL_atmos_cubed_sphere#74). That said, eventually we'll need to move, so I'll try and see if I can get those in. I'm guessing they are nicely separate from any changes @wmputman made (since they don't seem to affect physics much) |
@mathomp4 - there might have also been some fixes beyond the initial fms2-io -> FV3 PR applied to address inconsistencies found as time went on |
I have an update. Choosing the path of "least resistance", I decided to do this:
#ifdef CONSTANTSR8
use constantsr8_mod, only : HLV, HLF
#else
use constants_mod, only : HLV, HLF
#endif where I now use my new Good news! Our non-coupled run is zero-diff → Huzzah! Bad news! Our coupled run with MOM6 is non-zero-diff → Confusing! As far as I can tell, all MOM6 cares about (from FMS constants) are Stock:
Mixed:
I suppose the questions now are:
I mean, I suppose for the latter to be really complete you could do: #if defined(CONSTANTSR8)
use constantsr8_mod, only : HLV, HLF
#elif defined(CONSTANTSR4)
use constantsr4_mod, only : HLV, HLF
#else
use constants_mod, only : HLV, HLF
#endif and then every weird case could be covered. (Though I think I remember Santha or someone telling me once the ocean almost needs r8 to work, so maybe no one runs MOM6 at r4?) |
We have merged a PR which converts If that's not an option, then you could explicitly set them in If neither of those work for you, then you should attend next week's MOM6 meeting so that we can work out a solution.
Yes, MOM6 only works with r8. There are too many residual calculations that require more than 7 digits of accuracy. There may be some way to do mixed precision, but no has as yet determined exactly which parts requires r8. |
@marshallward Oohh. Even better if I don't need to touch MOM6 code. I should not go near it save "Hey, you misspelled this word" 😄 . So then, I will back off my MOM6 change and then try your new one. I also see that @uramirez8707 has a change as well for FMS in #1625 . Maybe with your powers combined, I'm Captain Plan...I mean, I will need to change nothing. :) |
Update: If I use the changes from @marshallward in NOAA-GFDL/MOM6#768 with my changes to |
In GEOS, we've always done rather crazy things to support our use of FMS because we build our FV3 core at r4 but MOM6 requires r8. So we've built both fms_r4 and fms_r8 and then done CMake include and link shenanigans to get things working.
Since FMS has been working on mixed-precision support, I decided to try it out with GEOS. And I hit a build issue but I'm not sure if it's "You built FMS wrong" or "An interface is missing". I'm suspecting the latter, but it can easily be the former.1
First, I built FMS using (less the netcdf bits):
and that gave me a libfms_r4 library. This seemed to be what I want to do, right?
If so, when I go to build GEOS I get:
Now, since I compile MOM6 as r8, then everything going into that routine would be r8 as well and from my reading of that routine in FMS:
FMS/diag_manager/diag_manager.F90
Lines 369 to 377 in 899ea6e
is that it doesn't have r4 and r8 variants of the real routines. But again, I might be building wrong.
Any advice/criticism is greatly appreciated.
Footnotes
It could also be "You are building MOM6 wrong" as well. I see they have an
OVERLOAD_R8
in MOM_diag_manager_infra.F90, but since we are explicitly compiling at r8, that wouldn't be necessary. (I did try it and got an ambiguous interface as expected.) ↩The text was updated successfully, but these errors were encountered: