MFC icon indicating copy to clipboard operation
MFC copied to clipboard

Switching to modern and modular precision declaration

Open sbryngelson opened this issue 3 years ago • 2 comments

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 avatar Nov 27 '22 16:11 sbryngelson

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 avatar Feb 04 '23 05:02 sbryngelson

Bump to top as the PR #119 was closed

sbryngelson avatar Jun 26 '24 12:06 sbryngelson