Open semi-h opened 6 months ago
This is not the correct way to do it - dp = kind(0.0d0)
(or something similar) will be compiler-specific, and not necessarily aligned with the MPI library. Something equivalent to
#ifdef DOUBLE_PREC
integer, parameter :: MPI_FP_PREC = MPI_DOUBLE_PRECISION
#else
integer, parameter :: MPI_FP_PREC = MPI_REAL
#endif
is what should be used (could also do with functions, but then can't make it constant)
it might also be worth looking into MPI_F08 - this is a better module than the default MPI one, however it isn't very well supported and tends to break tools so I haven't really used it... But it is a bit better on the type safety side of things.
Parameter is actually very simple way of implementing this, and probably most robust. I think we can go ahead with it.
There is the compile time seleciton mechanism for the precision in the code base, however the MPI modules are currently hardcoded for
MPI_DOUBLE_PRECISION
. We need to figure out a way to fix this so that we can run single precision simulations.A very incomplete attemt is here (albeit the wrong place, it should be in base backend) https://github.com/xcompact3d/x3d2/blob/85246f3b27fecee0095559029dbc4faadb7b5731/src/cuda/backend.f90#L26 Then based on the
dp
parameterMPI_FP_PREC
can be set and used everywhere afterwards. This probably will require convertingmpi_sendrecv
modules into classes, so that they can be instantiated at the backends with theMPI_FP_PREC
Thanks @JamieJQuinn for pointing out this in #67.