Parallel Programming Guide for HP-UX Systems

Troubleshooting
Compiler assumptions
Chapter 9200
Compiler assumptions
Compiler assumptions can produce faulty optimized code when the
source code contains:
Iterations by zero
Trip counts that may overflow at optimization levels +O2 and above
Descriptions of, and methods for, avoiding the items listed above are in
the following sections.
Incrementing by zero
The compiler assumes that whenever a variable is being incremented on
each iteration of a loop, the variable is being incremented by a
loop-invariant amount other than zero. If the compiler parallelizes a loop
that increments a variable by zero on each trip, the loop can produce
incorrect answers or cause the program to abort. This error can occur
when a variable used as an incrementation value is accidentally set to
zero. If the compiler detects that the variable has been set to zero, the
compiler does not parallelize the loop. If the compiler cannot detect the
assignment, however, the symptoms described below occur.
The following Fortran code shows two loops that increment by zero:
CALL SUB1(0)
.
.
.
SUBROUTINE SUB1(IZR)
DIMENSION A(100), B(100), C(100)
J = 1
DO I = 1, 100, IZR ! INCREMENT VALUE OF 0 IS
! NON-STANDARD
A(I) = B(I)
ENDDO
PRINT *, A(11)
DO I = 1, 100
J = J + IZR
B(I) = A(J)
A(J) = C(I)