Fortran · Runtime error

Error 138: Array index out of bounds

What does Error 138: Array index out of bounds mean in Fortran?

A subscript expression evaluated to a value outside the array's declared dimensions.

Error 138: Array index out of boundsIntel Fortran · gfortran

Condition

A subscript expression evaluated to a value outside the array's declared dimensions.

Fix

Recompile with bounds checking enabled during development, gfortran's -fcheck=bounds or Intel Fortran's /check:bounds, since this class of error is otherwise silent in an optimized build and can corrupt memory instead of reporting cleanly. Note that this check does not always catch every case, particularly a size mismatch on an allocatable array assignment rather than a literal out-of-range subscript, since compile-time shape checking cannot see the runtime size on either side.

Pending source verification. Not yet checked against official documentation.

Related runtime error