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

Switching to modern and modular precision declaration #42

Open
sbryngelson opened this issue Nov 27, 2022 · 1 comment · May be fixed by #119
Open

Switching to modern and modular precision declaration #42

sbryngelson opened this issue Nov 27, 2022 · 1 comment · May be fixed by #119
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@sbryngelson
Copy link
Member

MFC is filled with lines like this:

real(kind(0d0)), allocatable, dimension(:, :, :) :: du_dx, du_dy, du_dz
real(kind(0d0)), allocatable, dimension(:, :, :) :: dv_dx, dv_dy, dv_dz
real(kind(0d0)), allocatable, dimension(:, :, :) :: dw_dx, dw_dy, dw_dz

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

rho_L = 0d0
gamma_L = 0d0
pi_inf_L = 0d0
rho_R = 0d0
gamma_R = 0d0
pi_inf_R = 0d0
alpha_L_sum = 0d0
alpha_R_sum = 0d0

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 sbryngelson added the enhancement New feature or request label Nov 27, 2022
@sbryngelson
Copy link
Member Author

sbryngelson commented Feb 4, 2023

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.

@belericant belericant linked a pull request Mar 10, 2023 that will close this issue
@henryleberre henryleberre linked a pull request Mar 11, 2023 that will close this issue
@sbryngelson sbryngelson assigned wilfonba and unassigned belericant May 8, 2023
@sbryngelson sbryngelson added help wanted Extra attention is needed good first issue Good for newcomers labels May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Development

Successfully merging a pull request may close this issue.

5 participants