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
連結已複製
2 回應
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.
