Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Sourced allocation problems in 15.0.1

Ferdinand_T_
New Contributor II
986 Views

Dear all,

the 15.0.1 ifort compiler produces errors on the following snippets. Are these errors still present in 15.0.2 ?

If someone can give advice, this would help me to decide whether I have to check / change all such "sourced allocation assignments" or just wait for our IT to upgrade the compiler.

Snippet 1:

  • Sourced allocation into polymorphic array
  • Source is allocated function result
program p
	implicit none 
	type :: t
		logical :: is_not_empty	! seg. fault without
	end type
	class(t), dimension(:), allocatable :: a

	allocate(a, source=make_alloc())
	print *, allocated(a)		! T
	print *, size(a)			! 0 (wrong)

contains
	function make_alloc() result(a)
		type(t), dimension(:), allocatable :: a

		allocate(a(5))
		print *, size(a)		! 5
	end function
end program

 

Snippet 2:

  • Derived type t has polymorphic component
  • Sourced allocation into array of type(t) fails
program p
	implicit none 
	type :: s
		logical :: is_not_empty
	end type
	type :: t
		! CLASS is the problem here
	    class(s), allocatable :: polymorphic_component
	end type
	type(t), dimension(:), allocatable :: a

	allocate(a, source=make_alloc())
	print *, allocated(a)		! T
	print *, size(a)			! 0 (wrong)
contains 
	function make_alloc() result(a)
		type(t), dimension(:), allocatable :: a

		allocate(a(1))
	end function
end program

 

Snippet 3:

  • Similar to snippet 2 but errorneous code is executed in subroutine
  • Runtime-error (different, though probably related to snippet 2)
module m
	type :: s
		logical :: is_not_empty
	end type
	type :: t
	    class(s), allocatable :: polymorphic_component
	end type

contains 
	subroutine main()
		implicit none
		type(t), dimension(:), allocatable :: a

		allocate(a, source=make_alloc())
		print *, allocated(a)		! T
		print *, size(a)			! 0 (wrong)

	end subroutine  

	function make_alloc() result(a)
		type(t), dimension(:), allocatable :: a

		allocate(a(1))
	end function
end module

program p
	use m
	implicit none 

	call main()  

	! forrtl: severe (153): allocatable array or pointer is not allocated
end program

 

An other question to Intel: On the new free-software page, for students / researchers (=me) non-commercial licenses are not offered for Fortran any more. How can I test features and report bugs in the latest compiler? (here, IT departments usually don't have the very latest version, for stability and maintainance reasons)

Thanks,

Ferdinand

0 Kudos
1 Solution
Steven_L_Intel1
Employee
986 Views

I can still reproduce these problems in 15.0.2 and will report them to the developers. Issue ID is DPD200367894.

You can continue to report issues here - if they are fixed in newer versions, we will let you know.

There is a limited return of non-commercial licenses - see https://software.intel.com/en-us/qualify-for-free-software - but Fortran is not currently included in the research or student offerings. This program is still evolving.

View solution in original post

0 Kudos
5 Replies
Ferdinand_T_
New Contributor II
986 Views

PS: I just noticed that the size is not specified in the allocation statements. In F2003-syntax, e.g. allocate(a(SIZE), source=...), the correct size will be printed in all snipptes, but accessing the array elements afterwards (even after correct initialization) fails with segmentation fault. Snippet 3 fails after correction with seg, fault even without any other changes.

0 Kudos
Steven_L_Intel1
Employee
987 Views

I can still reproduce these problems in 15.0.2 and will report them to the developers. Issue ID is DPD200367894.

You can continue to report issues here - if they are fixed in newer versions, we will let you know.

There is a limited return of non-commercial licenses - see https://software.intel.com/en-us/qualify-for-free-software - but Fortran is not currently included in the research or student offerings. This program is still evolving.

0 Kudos
Steven_L_Intel1
Employee
986 Views

By the way, according to the F2008 standard you don't have to specify the bounds for a in the ALLOCATE as they are taken from the source. F2003 still requires that the bounds be given and that the source be "conformable" with the object.

0 Kudos
Ferdinand_T_
New Contributor II
986 Views

Thank you for the valuable information and the bug report, Steve!

For now I will allocate with intent(out) in subroutines rather than allocatable function results.

0 Kudos
Steven_L_Intel1
Employee
986 Views

This turned out to be a simple bug when the source expression was a function result. I expect the fix to appear in Update 3 (May). Thanks for the nice test cases.

0 Kudos
Reply