Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29238 Discussions

Run time check on extent of dummy array

abhimodak
New Contributor I
308 Views
Hi

In the snippet below the extent of dummy array B is larger than that of A. This violates standard. But the compiler does not complain. I believe this is because of j and JMAX are just initialized in the module and hence not compiler time 'constants'. (Although in a another sense these indeed remain constant at compiler time...)

If both the declarations are changed to "Integer, Parameter :: " then compiler (11.1.035 with VS2005 on Win64 XP) will trap the error.

Is there any way this error can be trapped at run-time?

Sincerely
Abhi

---
Module OM

Implicit None

Integer :: JMAX = 5
Integer :: j = 3


! The two lines instead of above two will trap the error as expected.
!Integer, Parameter :: JMAX = 5
!Integer, Parameter :: j = 3

Contains

Subroutine Method(B)

Implicit None

Real(8), Intent(INOUT) :: B(JMAX)

B = 3.0d0

End Subroutine Method

End Module OM

Program Test

Use OM

Implicit None

Real(8), Allocatable :: A(:)
Integer :: ial

Allocate(A(JMAX), stat=ial)

Call Method(A(1:j))

End Program Test
0 Kudos
1 Reply
Steven_L_Intel1
Employee
308 Views
Not that I can think of - the information to do so is not passed along with the call.
0 Kudos
Reply