Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Procedure pointer initialization

60 views
Skip to first unread message

James Van Buskirk

unread,
May 22, 2022, 3:54:45 AM5/22/22
to
I think my example is a syntactically correct instance of procedure
pointer initialization but both gfortran and an old version of ifort
error out on it:

module funcs
implicit none
interface
subroutine a() bind(C,name='a1')
implicit none
end subroutine a
subroutine b() bind(C,name='a2')
implicit none
end subroutine b
end interface
end module funcs

program start
use funcs
implicit none
type has_fun
procedure(a), pointer, nopass :: fun
end type has_fun
type(has_fun) :: lots(2) = [has_fun(a),has_fun(b)]
procedure(a), pointer :: stuff => b
end program start

subroutine c() bind(C,name='a1')
implicit none
end subroutine c

subroutine d() bind(C,name='a2')
implicit none
end subroutine d

JRR

unread,
May 23, 2022, 4:53:02 AM5/23/22
to
Hi James,
indeed, the code looks standard-conforming to me. The problem is the
initialization of lots, using of array of objects built by structure
constructors. gfortran and ifort complain that they don't know what
a is, so they can't resolve the interfaces from module funcs, nagfor
compiles without complaints. If you use
type(has_fun), dimension(2) :: lots
[...]
lots = [has_fun(a), has_fun(b)]

gfortran compiles this as well, while ifort 2021.5.0 produces an ICE.
You should report this to gfortran and Intel.
Cheers,
JRR

Am 22.05.22 um 09:54 schrieb James Van Buskirk:
--
Juergen Reuter
Theoretical Particle Physics
Deutsches Elektronen-Synchrotron (DESY)
Hamburg, Germany
0 new messages