Closed jcurtis2 closed 2 years ago
@mwest1066 if you could take a look at this warning in the Dockerfile.mpi build that is turning into an error in the build process with our compiler flags, I don't quite see why gfortran complains about it (after working through all the logic of that subroutine). It complains about the following lines:
saying "Error: Impure function 'pmc_mpi_allequal_real' at (1) might not be evaluated [-Werror=function-elimination".
There's a few ways to avoid this problem but I wasn't sure if I was missing something (we can split the if statement into two) or we can get the logicals separately and compare:
logical :: same_bin_min, same_bin_max
same_bin_min = pmc_mpi_allequal_real(val%edges(1))
same_bin_max = pmc_mpi_allequal_real(val%edges(bin_grid_size(val)))
if (bin_min .and. bin_max) then
pmc_mpi_allequal_bin_grid = .true.
else
pmc_mpi_allequal_bin_grid = .false.
end if
I think your solution with same_bin_min, same_bin_max
is good. Let's use that.
The reason that it's warning is:
pmc_mpi_allequal_real(val%edges(1))
is false.and.
pmc_mpi_allequal_real(val%edges(bin_grid_size(val)))
pmc_mpi_allequal_real()
is "impure" (that is, it is not marked as "pure")pmc_mpi_allequal_real()
wasn't having an important side-effectYour fix with same_bin_min, same_bin_max
solves this problem because it forces the code to always call pmc_mpi_allequal_real()
twice, avoiding the short-circuit .and.
. The nested-if solution can short-circuit (if the outside if
is false then it won't try the inner if
) but this is ok because it's explicitly in the code, so the compiler won't warn.
Github hardware is a currently a 2 core CPU so the MPI code was adjusted to 2 cores for now so tests pass.
Adding a dockerfile for testing of PartMC compiled with MPI.