MFlowCode / MFC

Exascale simulation of multiphase/physics fluid dynamics
https://mflowcode.github.io
MIT License
131 stars 56 forks source link

Switching to modern and modular precision declaration #42

Open sbryngelson opened 1 year ago

sbryngelson commented 1 year ago

MFC is filled with lines like this:

https://github.com/MFlowCode/MFC/blob/a39962ca7378fab292380a0e8694cc953f38b7e9/src/simulation/m_hypoelastic.f90#L30-L32

where the precision is declared via kind(0d0). We also have a ton of this

https://github.com/MFlowCode/MFC/blob/a39962ca7378fab292380a0e8694cc953f38b7e9/src/simulation/m_riemann_solvers.fpp#L547-L556

where inline constants have precision declared in a "hard-coded" way.

What is better is declaring a separate constant that we can change as needed, like this example, though there are many others.

A fix for this issue would remove all cases of 0d0 and kind(0d0) and replace them with a constant declared in the common/ directory. I think this is a suitable task for @anshgupta1234 .

I realize one can force precision via compiler variables, but I believe we should avoid this because there is an established language standard.

sbryngelson commented 1 year ago

note this from the miniweather app:

https://github.com/mrnorman/miniWeather/blob/9869dcffb19c4b07bc88f2b8adf98ca9e95bb997/fortran/miniWeather_mpi_openacc.F90#L13-L20

an important thing to notice is that if one switches to single precision, you have to switch the MPI kind as well (notice all the MPI_DOUBLE_PRECISION business in m_mpi_proxy.f90).

Update: We would probably only update the precision for a few variables, so it seems rather unlikely to touch m_mpi_proxy or MPI types.

sbryngelson commented 6 days ago

Bump to top as the PR #119 was closed