- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have downloaded 026 and I still get the same bug, so it must have been solved in a newer in-house version. Looking forward to the next official version.
Thanks,
Miguel
Thanks,
Miguel

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