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

ICE when using a type defined by an allocatable array and a procedure function that has a defined type as a result

kostas85
Beginner
423 Views
Hello all,

The following code produces ice and there are three cases that compilation won't produce ice :

module mytypes

type mytype
real(kind(0.d0)) :: a
end type mytype

type mytype1
real(kind(0.d0)), dimension(:), allocatable :: a ! fixing the dimension won't produce ice
procedure(fun), pointer, nopass :: proc
end type mytype1

contains

type(mytype) function fun(a) result(res) ! declaring the function as real(kind(0.d0)) or changing the function to a subroutine
implicit none ! won't produce ice
real(kind(0.d0)), intent(in) :: a
res%a=a**2
end function fun

end module mytypes

program check_ice
use mytypes
implicit none

type(mytype1) :: mt

mt%proc => fun

end program check_ice

Running the program I get:

g1@G1:~/Programming/checks$ ifort check_ice.F90
check_ice.F90(22): catastrophic error: **Internal compiler error: internal abort** Please report this error along with the circumstances in which it occurred in a Software Problem Report. Note: File and line given may not be explicit cause of this error.
compilation aborted for check_ice.F90 (code 1)

Changing the module as explained above, say :

1 . Fixing the dimension of array " a " doesn't produce ice

module mytypes

type mytype
real(kind(0.d0)) :: a
end type mytype

type mytype1
real(kind(0.d0)), dimension(3) :: a ! <-- This changed
procedure(fun), pointer, nopass :: proc
end type mytype1

contains

type(mytype) function fun(a) result(res)
implicit none
real(kind(0.d0)), intent(in) :: a
res%a=a**2
end function fun

end module mytypes

program check_ice
use mytypes
implicit none

type(mytype1) :: mt

mt%proc => fun

end program check_ice


2. Using an implicit type for the function result doesn't produce ice

module mytypes

type mytype
real(kind(0.d0)) :: a
end type mytype

type mytype1
real(kind(0.d0)), dimension(:), allocatable :: a
procedure(fun), pointer, nopass :: proc
end type mytype1

contains

real(kind(0.d0)) function fun(a) result(res) ! <-- This changed
implicit none
real(kind(0.d0)), intent(in) :: a
res=a**2
end function fun

end module mytypes

program check_ice
use mytypes
implicit none

type(mytype1) :: mt

mt%proc => fun

end program check_ice

3. The procedure fun is a subroutine and not a function :

module mytypes

type mytype
real(kind(0.d0)) :: a
end type mytype

type mytype1
real(kind(0.d0)), dimension(:), allocatable :: a
procedure(fun), pointer, nopass :: proc
end type mytype1

contains

subroutine fun(a,res) ! <-- This changed
implicit none
type(mytype), intent(out) :: res
real(kind(0.d0)), intent(in) :: a
res%a=a**2
end subroutine fun

end module mytypes

program check_ice
use mytypes
implicit none

type(mytype1) :: mt

mt%proc => fun

end program check_ice


Check it. Thank you.

Note ::

g1@G1:~/Programming/checks$ ifort -v
Version 12.0.0


0 Kudos
1 Reply
Xiaoping_D_Intel
Employee
423 Views

Thanks for reporting the compiler error. I have submitted a bug report on it.

Thanks,
Xiaoping Duan
Intel Customer Support

0 Kudos
Reply