Many old Fortran 77 programs declare a large workspace array in the main program and hand off segments of that array to subroutines as arguments. The actual argument for each such workspace array segment appears to be an array element, but the corresponding dummy variable in the called subroutine is an array of 1, 2, etc. dimensions. The Fortran 95 standard provides for this in section 12.4.1.4 'Sequence Association', in which the third sentence of the first paragraph says: If the actual argument is an array element designator, the element sequence consists of that array element and each element that follows it in array element order.
It is not clear to me what rules are followed by FTN95 when such a program is compiled and run with /check. Here is a test program which runs without error when compiled and run with other compilers with those compilers' subscript checking options turned on, but aborts when compiled and run with FTN95 /check.
program subbug
implicit none
integer, parameter :: ndim=20, nrp1=11
integer iwksp(100), i, j
!
do i=1,ndim; do j=1,5
iwksp((j-1)*ndim+i) = 10*i+j
end do; end do
call vaddp(ndim, iwksp(ndim+nrp1))
end program
subroutine vaddp(ndimi, ja)
implicit none
integer ndimi, ja(ndimi,*)
!
print *, ja(1,4)
return
end subroutine
When compiled with /check and run inside SDBG up to line 16, the array JA is displayed as having dimensions (20,3). My question is regarding the second upper bound of 3, which is more restrictive than what is allowed by the sequence association rule that I quoted above.
The first column of JA corresponds to WKSP(31:50), the second column of JA to WKSP(51:70), the third column of JA to WKSP(71:90), and JA(1:10, 4) to WKSP(91:100). References to JA(i,4) with i > 10 would be out of bounds, but using JA(1,4) should not cause an error, it seems to me.
The test program as well as the larger program from which it was derived work fine when neither /check nor /undef is specified when compiling.