- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not that I can think of - the information to do so is not passed along with the call.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page