The following code produces a floating point invalid error at run-time when using the flags -O2 -fpe0 -fltconsistency:
program example integer, parameter :: leng = 300 real (kind = 8), dimension(leng) :: errors integer :: i do i = 1, leng errors(i) = 1d-20 * sin(float(i)) end do print*, minval(errors) where(errors < 0) errors = -100.0_8 * errors / minval(errors) end program example
This occurs at the line beginning "where". This is also sometimes a problem for maxval, but it was easier to recreate with minval. If a new real(8) is created to hold the value of minval(errors) before the where, this fixes the problem. Also, removing the fltconsistency flag fixes the problem.
-Dave