- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I take it that the problem has been solved then.
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
------
Wendy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
that is good to hear.
Regards,
Arjen
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page