You get the error message, because you issue an pointer assignment outside of any subroutines, where usually only declarations should occur. Putting the assignment in a subroutine (see below) shows, that things work perfectly, provided you make sure, the Legendre0()
function also use real*8 type in order to match the interface declaration (for testing purposes, I also put the Legendre function in the same module):
module pointer_mod
implicit none
interface
function func (z)
real*8 :: func
real*8, intent (in) :: z
end function func
end interface
type proc_ptr
procedure (func), pointer, nopass :: f_ptr
end type proc_ptr
type(proc_ptr), dimension(6) :: basis
contains
subroutine test()
basis(1)%f_ptr => Legendre0 ! or basis(1) % f_ptr => null()
end subroutine test
function Legendre0(x) result(y)
real*8, intent(in) :: x
real*8 :: y
y = 1
end function Legendre0
end module pointer_mod
As an additional comment: You should consider to declare your real variables like
integer, parameter :: dp = kind(1.0d0)
real(dp) :: whatever
instead of the real*8
notation, which is obsolate.