- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everybody!
I am confused because I wrote a little program which has a derived type:
type struc
integer :: n
integer, dimension(:), allocatable :: v
end type
I defined a variable in the program and gave it some values:
type(struc) :: s
s%n = 5
When I pass "s" to a subroutine where its corresponding dummy argument has intent(out), then "s%n" is set to 0 inside the subroutine! Is it normal? This does not happen if I erase the allocatable member "v" from "struc" type.
I am using version 9.1 of Intel compiler. I read that Fortran 95 standard is unclear about the intent attribute of derived types with pointer members, but I do not think it is connected to the previous problem...
Thanks a lot,
Paco
I am confused because I wrote a little program which has a derived type:
type struc
integer :: n
integer, dimension(:), allocatable :: v
end type
I defined a variable in the program and gave it some values:
type(struc) :: s
s%n = 5
When I pass "s" to a subroutine where its corresponding dummy argument has intent(out), then "s%n" is set to 0 inside the subroutine! Is it normal? This does not happen if I erase the allocatable member "v" from "struc" type.
I am using version 9.1 of Intel compiler. I read that Fortran 95 standard is unclear about the intent attribute of derived types with pointer members, but I do not think it is connected to the previous problem...
Thanks a lot,
Paco
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When a dummy argument has INTENT(OUT), it becomes undefined on entry to the routine. If there are allocatable components, they are deallocated at that time. The values of other components are undefined, so even asking what the value of N is constitutes undefined behavior.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I suppose the user could use INOUT.

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