I have a base type which contains a procedure that takes a user defined function as input. User defined functions are defined in extended types. The following compiles with ifort-13.1.3 but fails with gfortran-4.8.1:
module m
implicit none
type, abstract :: base
contains
procedure :: use_f
end type base
type, extends(base) :: extended
contains
procedure :: f
procedure :: test ! calls use_f which takes f as argument
end type extended
contains
subroutine f(this)
class(extended) :: this
end subroutine f
subroutine use_f(this, func)
class(base) :: this
interface
subroutine func(this)
import :: base
class(base) :: this
end subroutine func
end interface
end subroutine use_f
subroutine test(this)
class(extended) :: this
call this%use_f(f) ! This is the important part!
end subroutine test
end module m
program a
end program a
gfortran produces
call this%use_f(f)
1
Error: Interface mismatch in dummy procedure 'func' at (1): Type/rank mismatch in argument 'this'
I have also tried using procedure pointers, but still ifort compiles while gfortran fails. Now, if instead of an interface block I put
external func
into use_f the code compiles successfully with both ifort and gfortran. But isn't the EXTERNAL keyword becoming obsolescent? Is there a more standard-conforming approach that works?