Icon nesting error

This doesn’t quite work.
Assuming the program does a perfect job of rounding (something not guaranteed by the Fortran Standard), no such look-at-ASCII-strings test works, as I have written extensively elsewhere. See NOTE below.

What is really is needed is to measure the relative error: how big is the difference when compared to the original numbers – something like
ABS( B-A)/(0.5*A + 0.5*B) < TOLERANCE
(or various other relative-error formulations like those found in DBLERR from ioapi/chkfil3.f90 (which is what the author of this code should have used anyway).

NOTE

DOUBLE PRECISION, PARAMETER :: A = 1.234565D0
DOUBLE PRECISION, PARAMETER :: E = 1.0D-15
DOUBLE PRECISION, PARAMETER :: X = A - E
DOUBLE PRECISION, PARAMETER :: Y = A + E

X and Y are incredibly close; however (assuming perfect rounding), they fail the ICON-code test, which treats X as 1.23456 and Y as 1.23457 for purposes of its comparison.
Making matters worse, the ICON code reports the numbers to the log using a different format than it does for the comparison…

1 Like