Skip to content
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

Mersenne mind twister #324

Closed
climbfuji opened this issue Dec 9, 2020 · 9 comments
Closed

Mersenne mind twister #324

climbfuji opened this issue Dec 9, 2020 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@climbfuji
Copy link
Collaborator

climbfuji commented Dec 9, 2020

Description

@DusanJovic-NOAA reported an issue with running inline post on a generic Linux machine with the GNU compilers. This was tracked down to a multitude of mersenne twister random generators being used across the components of the ufs-weather-model, some of them compiled in single precision, some in double precision.

Whether the correct one is used or not depends on the compiler and how the build system generates the linker command for that compiler. Intel apparently doesn't have the problem reported here.

Thus far we identified:

  • one mersenne twister in w3emc
  • two mersenne twisters in CCPP physics (either coming from IPD physics or being added as part of the HWRF physics)
  • one mersenne twister in stochastic_physics
  • one mersenne twister in FMS

The FMS version seems to be somewhat similar to the HWRF version, but according to @DusanJovic-NOAA the module in which it resides in FMS is different from the others and thus doesn't pose a problem right now.

Proposed solution - open for discussion

  1. Identify if the different versions are really required or if one version, providing the interfaces for single and double precision (and potentially half / quadruple precision) is sufficient - after all, it is the same algorithm. Move this version/these versions into its own library (yet another NCEPLIB) and use it in all applications.

  2. Potential interim solution for post: replace mersenne twister with Fortran number generator, maybe only for GNU to avoid downstream effects on existing users until 1. has been completed.

To Reproduce:

Compile the ufs-weather-model on a Linux laptop/workstation with the GNU compiler using 32bit dynamics and run a test with inline post turned on. Create verbose output during the make step (VERBOSE=1) and check the final linker line.

Related issues

NCAR/ccpp-physics#529

@climbfuji
Copy link
Collaborator Author

One version of the Mersenne twister will be deleted in #331.

@arunchawla-NOAA
Copy link

I have not seen any discussion on this topic. Is this still an issue that needs to be addressed ? Are there plans to tackle this at this time or should this be moved to the icebox for later considerations?

@climbfuji
Copy link
Collaborator Author

I have not seen any discussion on this topic. Is this still an issue that needs to be addressed ? Are there plans to tackle this at this time or should this be moved to the icebox for later considerations?

icebox I guess. It's still the same, nobody has made efforts to consolidate the versions and find a good way to use them across repositories.

@pjpegion
Copy link
Collaborator

pjpegion commented Mar 8, 2022

I have plans to remove the one in stochastic physics later this year.

@BrianCurtis-NOAA
Copy link
Collaborator

The one for UPP looks like it was switched to use the Fortran RANDOM_NUMBER generator. Does FMS/Stochastic Phys/CCPP need a Mersenne twister or will the RANDOM_NUMBER do OK? I ask because I think it good to track these changes in upstream tickets and link here, but I wanted to know if there was a need or if the RANDOM_NUMBER generator in Fortran would suffice.

@climbfuji
Copy link
Collaborator Author

It's up to the scientists to weight in here. Some parts of the model, e.g. radiation, depend heavily on the random number generator, and you can't just swap them because they have characteristics that can really influence the model.

@BrianCurtis-NOAA
Copy link
Collaborator

Yes, I think they use different distribution types? If the scientists in each component can weigh in we can get the proper tickets created there, agreed. Thanks!

@SMoorthi-emc
Copy link
Contributor

SMoorthi-emc commented Jul 25, 2022 via email

@pjpegion
Copy link
Collaborator

I am ok with removing mersenne twister from the stochastic physics repo, but it will take a bit of coding and testing to switch to a different random number generator. The CA part of the code is no longer using mersenne twister, I just have not had the time to update the spectral pattern generator.

@climbfuji climbfuji closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

7 participants