Bugfix: IEEE invalid operation when checking for central body collision #18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi all,
I sometimes stumble across the following warning message when running Mercury:
Note: The following floating-point exceptions are signalling: IEEE_INVALID_FLAG
With not much more to go on, I added the gfortran compiler flag
-ffpe-trap=invalid
to find the problem: calling acos() for a value less than -1, for which acos is not defined. Here is the part (line 963 in mercury6_2.for):u0 = sign (acos((1.d0 - r0/a )/e), rv0)
I assumed that it was a rounding issue, since the values I got when checking were -1.0000000000288831 and -1.0000000002232341 (all at high e), but I don't understand all of the variabls exactly so I can't be 100% sure. I therefore added a check for the value before passing it on to acos, and setting the boundary values when a value is outside the (-1, 1) range. I also added the compiler flags to the Makefile to make sure people will catch more of these bugs when/if they occur.
Hope that helps someone!
Cheers