Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29280 Discussions

No deallocation of derived types

mhermanns
Beginner
1,043 Views
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
0 Kudos
4 Replies
Steven_L_Intel1
Employee
1,043 Views
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.
0 Kudos
mhermanns
Beginner
1,043 Views
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
0 Kudos
Steven_L_Intel1
Employee
1,043 Views
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.
0 Kudos
mhermanns
Beginner
1,043 Views
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
0 Kudos
Reply