A Small Update to simann.f90

October 2, 2013

Thomas Ruedas wrote to me some time ago regarding a typo in simann.f90, the simulated annealing module contained in the archive of Alan Miller’s Fortran Software that I host:

In function exprep, the condition of the second IF branch reads:

    ELSE IF (rdum < -180.+dp) THEN

whereas the correct form should be

    ELSE IF (rdum < -180._dp) THEN

signalling 180 as double precision (_dp), as defined earlier in the code. That would also correspond to the original (single prec.) formulation and, for instance, the first IF branch

    IF (rdum > 174._dp) THEN

The bug does not result in a compilation error, and does probably not affect the test case, at least not on my machine, but it may nonetheless lead to a wrong result in some circumstances.

My response to Dr. Ruedas was:

In the case you report, I agree with you that it’s clearly a bug. When I run Alan’s TO_F90 on the original Fortran 77 program, the _dp specifiers are not there, so he likely added them by hand. Of course, plus (+) is very close on the keyboard to the underscore (_), and both require pressing shift. There’s no compiler error unless you have type conversion warnings turned on, so it went unnoticed.

As I’ve mentioned previously, I have no plans to actively maintain Alan’s collection of algorithms. Even if I had time to do so, many of them fall outside my realm of expertise, so it would be imprudent of me to attempt to do so. However, in this case I am familiar with simulated annealing and this seems to be a clear typo, so I have updated the hosted version of simann.f90 accordingly. For reference, the previous last modified date on that file was August 3, 1997.