I have a program that assigns an array out of bounds, and I expected a runtime error to be selected. However, no error occurs at all, and the program proceeds to write to undeclared memory. Is there a compiler option to protect against this? With the memory dump shown, it is clear that exceeding boundaries is real. Is there a way to declare variables or argument specifications to catch this? Obviously, this is a clear case, but when it is tasked with supporting thousands of lines of derived F77 code, it is not always clear (to me) if this could happen.
PROGRAM TEST_CODE
IMPLICIT NONE
INTEGER*4 :: R(5) ! Array of 5
CALL R_TEST(R, 10)
END PROGRAM
SUBROUTINE R_TEST(R, J)
IMPLICIT NONE
INTEGER*4, INTENT(INOUT) :: R(1) ! Dummy is array of 1
INTEGER*4, INTENT(IN) :: J
INTEGER*4 :: K
DO K=J-5,J+5 ! K=5..15
R(K) = K ! No Runtime Error
END DO
END SUBROUTINE
The compiler is Intel Fortran 2011 XE, and yes, I use the byte spec INTEGER*4because I know what I get with it.
.

