GOMC-WSU/GOMC

Use standard library abs

LSchwiebert opened this issue · 1 comments

Describe the bug

Different compilers interpret abs(double) differently, so better to use std::abs() or std::fabs() for doubles.

To Reproduce

The GNU compilers interpret abs(double) as a call to double abs(double). The intel compilers interpret abs(double) as a call to int abs(int) and apparently use abs((int) double) to return an int. This causes problems in some places in the code, such as the Particle::Read function in FFSetup.cpp.

Expected behavior

We want the absolute value of a double to remain a double.

Screenshots

N/A

Input files

Any input file with an epsilon value < 1.0 will demonstrate the problem.

Please complete the following information:

The problem shows up on the current development branch.

Additional context

Went ahead and patched all the other places in the code where we were using abs() instead of std::abs().

Just want to mention that this problem appears to go away with the Intel 2021.8.0 compiler, but shows up in older versions of the Intel C/C++ compiler.