- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
(The ifort compiler I'm using is Version 10.1, on Linux 64bit.)
I have subroutine SubName with a pointer to an array among the dummy arguments:
subroutine SubName( ..., pointerToArray,...)
integer, dimension(:), pointer, intent(inout)&
:: pointerToArray
...
end subroutine
The pointerToArray occurs in the code of this subroutine in three usages:
(1) allocation of the the array (if not jet associated)
(2) changes to array elements
(3) as an actual argument of a subroutine (again with an intent(inout) attribute for the corresponding dummy argument)
When trying to compile the code, I get an error message. There are no complains about (1) or (2). For the line containing (3) I get
"A pointer dummy argument with the INTENT(IN) attribute shall not appear as an actual argument if the associated dummy argument has the INTENT(OUT) or INTENT(INOUT) attribute"
and refering to the pointerToArray argument. I completely agree that an intent(in) would not allow a call as done in (3). However, I have an intent(inout) attribute which is not what the compiler seems to think for some reason (even so (1) and (2) pass without error).
When I change the intent(inout) attribute to intent(out) in the subroutine SubName, it compiles. Though that's definitely not what I want.
So, do I grasp the concept of intent attributes for pointers introduced in Fortran2003 wrongly or does it more looks like a bug? Any help is greatly appreciated!
Thanks.
I have subroutine SubName with a pointer to an array among the dummy arguments:
subroutine SubName( ..., pointerToArray,...)
integer, dimension(:), pointer, intent(inout)&
:: pointerToArray
...
end subroutine
The pointerToArray occurs in the code of this subroutine in three usages:
(1) allocation of the the array (if not jet associated)
(2) changes to array elements
(3) as an actual argument of a subroutine (again with an intent(inout) attribute for the corresponding dummy argument)
When trying to compile the code, I get an error message. There are no complains about (1) or (2). For the line containing (3) I get
"A pointer dummy argument with the INTENT(IN) attribute shall not appear as an actual argument if the associated dummy argument has the INTENT(OUT) or INTENT(INOUT) attribute"
and refering to the pointerToArray argument. I completely agree that an intent(in) would not allow a call as done in (3). However, I have an intent(inout) attribute which is not what the compiler seems to think for some reason (even so (1) and (2) pass without error).
When I change the intent(inout) attribute to intent(out) in the subroutine SubName, it compiles. Though that's definitely not what I want.
So, do I grasp the concept of intent attributes for pointers introduced in Fortran2003 wrongly or does it more looks like a bug? Any help is greatly appreciated!
Thanks.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'd feel more confident in responding if I saw an actual and complete test case rather than a paraphrase of what you think the code says. I've been burned too many times by incorrect paraphrasing. Specifically, I'd want to see whether or how an explicit interface for the called routine appears.
FWIW, the INTENT attribute, as it applies to pointers, is for the pointer itself and not the data it points to.
FWIW, the INTENT attribute, as it applies to pointers, is for the pointer itself and not the data it points to.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, I have boiled it down to this short module. The compiler is invoked by:
ifort -c -free -auto -warn all SubModule.f90
The Module is:
MODULE SubModule
PUBLIC f
PRIVATE
CONTAINS
subroutine f(ptr)
integer, POINTER, intent(inout) :: ptr
call g(ptr)
end subroutine
!------------------
subroutine g(ptr)
integer, POINTER, intent(inout) :: ptr
if (associated(ptr)) then
write(*,*) 'hello'
end if
end subroutine
END MODULE
The error message remains the same, refering to the argument ptr in the call of g.
ifort -c -free -auto -warn all SubModule.f90
The Module is:
MODULE SubModule
PUBLIC f
PRIVATE
CONTAINS
subroutine f(ptr)
integer, POINTER, intent(inout) :: ptr
call g(ptr)
end subroutine
!------------------
subroutine g(ptr)
integer, POINTER, intent(inout) :: ptr
if (associated(ptr)) then
write(*,*) 'hello'
end if
end subroutine
END MODULE
The error message remains the same, refering to the argument ptr in the call of g.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the concise and complete example. I can reproduce the problem - it's a bug. If you report this to Intel Premier Support, please reference T82717-CP. A workaround is to remove the INTENT attribute from "f".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It turns out that another user reported this problem earlier and the bug has been fixed for a future release.

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