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

Problem with procedure pointers: matching arguments

Arjen_Markus
Honored Contributor II
2,340 Views
Hello,

I am trying to use procedure pointers to makea program more flexible, but I ran into a
nasty little compiler error. The following program causes the compiler to complain about
the pointer assignment:

error #8178: The procedure pointer and the procedure target must have matching arguments.

If I put the code in the module "implementations" into the module "abstract", the error goes
away.

Any suggestions (besides creating a humongous module)?

Regards,

Arjen

----

! chk_abstract.f90 --

! Investigate a problem with abstract interfaces

! and procedure pointers

!

module implementations

implicit none

abstract interface

subroutine zfunc_evaluation( param_value, zvalue )

real, dimension(:), intent(in) :: param_value

real, intent(out) :: zvalue

end subroutine

end interface

contains

subroutine zfunc( param, zvalue )

real, dimension(:), intent(in) :: param

real, intent(out) :: zvalue

zvalue = param(2) - param(1)

end subroutine

end module implementations

module abstract

use implementations

contains

subroutine select( name, implementation )

character(len=*) :: name

procedure(zfunc_evaluation), pointer :: implementation

select case( name )

case ( 'Z' )

implementation => zfunc

case default

write(*,*) 'Unknown implementation: ', trim(name)

stop

end select

end subroutine select

end module

0 Kudos
11 Replies
mecej4
Honored Contributor III
2,340 Views
Adding the following lines to round out your code into a complete program
[fortran]program tst
use abstract
procedure(zfunc_evaluation), pointer :: impl
impl => zfunc
call select('Z', impl)
call select('Any rose ', impl)
end program tst[/fortran]
and compiling, I found that the program runs as expected, using 11.1.069 (Windows) and 11.1.072 (Linux).

Which version of the compiler did you use?
0 Kudos
Arjen_Markus
Honored Contributor II
2,340 Views
I am using Intel Fortran 11.1.054 (still - my sysadmin is hunting down the newer version for me).

I take it that the problem has been solved then.

Regards,

Arjen
0 Kudos
Wendy_Doerner__Intel
Valued Contributor I
2,340 Views
Some relevant fixes we included between these releases and it sounds like it is fixed in 11.1. Let us know if you still see it after upgrading?

------

Wendy

Attaching or including files in a post

0 Kudos
Arjen_Markus
Honored Contributor II
2,340 Views
I will do that.

Meanwhile here is another nasty problem:

module computation_data

implicit none

type computation_method

character(len=40) :: name ! Name of the mechanism

procedure(compute_routine), pointer, nopass :: compute ! Pointer to the compute subroutine

end type

abstract interface

subroutine compute_routine( param_value, zfunc, probability )

real, dimension(:), intent(in) :: param_value

procedure(compute_routine) :: zfunc

real, intent(in) :: probability

end subroutine

end interface

end module computation_data


The error message I get with 11.1_054 is:

fit_lookup: Line_seq_number 000000000 was not found
forcom: Fatal: There has been an internal compiler error (C000005)

I had to stare very hard at the code to find the problem (you may see it rightaway). When I fix it, all
is fine;)

Regards,

Arjen

0 Kudos
Arjen_Markus
Honored Contributor II
2,340 Views

The original problem is solved with 11.1_065. So now I can proceed with this program.
(The nasty problem I reported yesterday still exists though)

Regards,

Arjen

0 Kudos
Wendy_Doerner__Intel
Valued Contributor I
2,340 Views
Arjen,

Thanks for the internal compiler error report. I have reproduced and reported to engineering with number: DPD200159494. I will update this thread when we have a compiler which resolves the error or a workaround for it.

------

Wendy

Attaching or including files in a post

0 Kudos
Arjen_Markus
Honored Contributor II
2,340 Views
You're welcome. Mind you, I am not sure if the code as such is legal (I have my doubts it can be given a consistent interpretation, given the self-reference). It had me puzzled for a long while.

Regards,

Arjen
0 Kudos
Wendy_Doerner__Intel
Valued Contributor I
2,340 Views
Arjen,

Whether or not it is legal code the compiler should never fail (it should give an error message if illegal). I will update this thread with engineerings findings.

------

Wendy

Attaching or including files in a post

0 Kudos
Arjen_Markus
Honored Contributor II
2,340 Views
Hello Wendy,

yes, I know and that is the reason I posted this example. (Robert Corbett from Sun assures me in the c.l.f thread I started on this subject that it is legal. But whether it is useful, I am not sure.) Anyway the main
point is indeed the compiler error, not the code.

Regards,

Arjen
0 Kudos
Wendy_Doerner__Intel
Valued Contributor I
2,340 Views
Arjen,

The 12.0 Update 2 compiler no longer emits an internal compiler error for this test case. Engineering considers it fixed by some changes they made to address other issues.

------

Wendy

Attaching or including files in a post

0 Kudos
Arjen_Markus
Honored Contributor II
2,340 Views
Wendy,

that is good to hear.

Regards,

Arjen
0 Kudos
Reply