- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Hi,
I have the following question/remark/bug(?). I work with derived types which have allocatable components, and use them as output arguments of subroutines. These subroutines do the work of allocation. En example code would be as follows:
!-----------------------------------!
module Module_Example
implicit none
type Array_Example
real, allocatable :: Values(:)
end type Array_Example
contains
!-----------------------------------!
subroutine Create_Array(Array)
type(Array_Example), intent(out) :: Array
allocate(Array%Values(1000))
end subroutine Create_Array
!-----------------------------------!
end module Module_Example
!-----------------------------------!
!-----------------------------------!
program Example
use Module_Example
integer :: i
type(Array_Example) :: Array
do i = 1, 1000000
call Create_Array(Array)
enddo
end program Example
!-----------------------------------!
The point is that since the argument to the subroutine Create_Array is declared as intent(out), one would expect that this works without problems (if one uses intent(inout), then the run-time error 151 happens). The behaviour I would expect is that the compiler deallocates Array before passing it to the subroutine.
Instead, no deallocation is being done leading to a constant increase in memory usage. Is this a bug or am I doing something wrong? If I deallocate by hand Array after the call to Create_Array, then no memory increase happens.
I'm using version 9.0.021 on debian testing (I cannot download version 9.0.026 from the premier support due to a http 500 error!?).
Thanks in advance and greetings from Spain,
Miguel
I have the following question/remark/bug(?). I work with derived types which have allocatable components, and use them as output arguments of subroutines. These subroutines do the work of allocation. En example code would be as follows:
!-----------------------------------!
module Module_Example
implicit none
type Array_Example
real, allocatable :: Values(:)
end type Array_Example
contains
!-----------------------------------!
subroutine Create_Array(Array)
type(Array_Example), intent(out) :: Array
allocate(Array%Values(1000))
end subroutine Create_Array
!-----------------------------------!
end module Module_Example
!-----------------------------------!
!-----------------------------------!
program Example
use Module_Example
integer :: i
type(Array_Example) :: Array
do i = 1, 1000000
call Create_Array(Array)
enddo
end program Example
!-----------------------------------!
The point is that since the argument to the subroutine Create_Array is declared as intent(out), one would expect that this works without problems (if one uses intent(inout), then the run-time error 151 happens). The behaviour I would expect is that the compiler deallocates Array before passing it to the subroutine.
Instead, no deallocation is being done leading to a constant increase in memory usage. Is this a bug or am I doing something wrong? If I deallocate by hand Array after the call to Create_Array, then no memory increase happens.
I'm using version 9.0.021 on debian testing (I cannot download version 9.0.026 from the premier support due to a http 500 error!?).
Thanks in advance and greetings from Spain,
Miguel
링크가 복사됨
4 응답
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
This is a bug we recently fixed. I think it is fixed in 026, when you're able to get it.
Hint - when posting code here, use HTML pre tags to enclose the code, unless you're using MSIE on Windows, in which case there's a "SRC" button you can use for the purpose.
Hint - when posting code here, use HTML pre tags to enclose the code, unless you're using MSIE on Windows, in which case there's a "SRC" button you can use for the purpose.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Thanks for the information. I will have to wait for the web page to get fixed to download 026.
Thanks also for the hint, but I don't know HTML. Wouldn't it be interesting to include a pair of buttons in the message writer to add these tags?
Thanks again,
Miguel
Thanks also for the hint, but I don't know HTML. Wouldn't it be interesting to include a pair of buttons in the message writer to add these tags?
Thanks again,
Miguel
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
The vendor we're using for these forums does provide such a button - if you're using MSIE. Otherwise, no. It is one of several issues I have raised to them.
