I am trying to write a generic type-bound procedure that performs various callback functions as parameters. When compiling the following code (with ifort 12.1.3), I get the following warning:
module test type :: a_type contains procedure :: t_s => at_s procedure :: t_d => at_d generic :: t => t_s,t_d end type a_type abstract interface integer function cb_s(arg) real(4) :: arg end function cb_s integer function cb_d(arg) real(8) :: arg end function cb_d end interface contains subroutine at_s(this,cb) class(a_type) :: this procedure(cb_s) :: cb end subroutine subroutine at_d(this,cb) class(a_type) :: this procedure(cb_d) :: cb end subroutine end module test
A warning:
compileme.f(27): warning
It seems that the compiler does not distinguish between different functional interfaces when using procedures as arguments ...
My question is: why are these types not checked and what is the correct, clean way to write generic procedures with a type binding with procedures or procedure pointers as arguments?
Possible Solution
As Vladimir F pointed out, only the return arguments to the callback function are checked by type. In my case, it is normal to slightly change the function interfaces:
abstract interface real(4) function cb_s(arg) real(4) :: arg end function cb_s real(8) function cb_d(arg) real(8) :: arg end function cb_d end interface
source share