optados-developers / optados

Official Repository of the Optados code
http://www.optados.org
20 stars 22 forks source link

Arithmetic error in calculating refraction #49

Open ajm143 opened 2 years ago

ajm143 commented 2 years ago

Describe the bug Arithmetic error in calculating refraction for a metal

To Reproduce Use NAG compiler on testopt_optics_drude without -ieee=full flag

Expected behavior Unclear. I'd like to check what sort of error it is, NaN or Infinity, and check that that's expected behaviour.

Screenshots

Runtime Error: *** Arithmetic exception: Floating invalid operation - aborting
optics.f90, line 778: Error occurred in OD_OPTICS:CALC_REFRACT
optics.f90, line 135: Called by OD_OPTICS:OPTICS_CALCULATE
optados.f90, line 191: Called by OPTADOS
Aborted

Desktop (please complete the following information):

jryates commented 2 years ago

From a quick look at the line in the code, I can see that there are possibilities for an arithmetic error - it could be divide by zero, or root of a negative numbers (signed zero?). Do we have a view on the intrinsic sqrt vs **0.5_dp. I would have assumed the intrinsic would be faster (although a optimising compiler might replace the power with the intrinsic). But I was wondering if the error message from the intrinsic might be nicer?

ajm143 commented 2 years ago

I think the intrinsic would be nicer.

I flagged it because, when I get a minute, I also want to check the maths/algorithm behind it i.e. should the function go to Infinity / NaN etc... Sure I can make the code compile and run by setting the -ieee flag, but I'd like to check that's ok.