Hello,
I believe I found another nvfortran compiler bug although I haven’t tested it on the 26.5 yet.
The following module file below compiles and creates a .mod file but leads to NVFORTRAN-S-1257-Interface user_op must be declared when imported by another file. The position of the c_helper interface relative to the abstract interface seems to be triggering the issue. gfortran compiles without issue.
Thanks for your help,
Josh
Reproducer
bad_mod.f90
module repro_mod
use iso_c_binding, only : C_PTR, C_FUNPTR, c_f_pointer
implicit none
abstract interface
subroutine user_op(a_x)
real, intent(inout) :: a_x
end subroutine user_op
end interface
type :: op_holder
procedure(user_op), pointer, nopass :: fn => null()
end type op_holder
! Moving this block above the abstract interface makes the problem go away.
interface
subroutine c_helper(a_fn) bind(C, name="c_helper")
use iso_c_binding, only : C_PTR, C_FUNPTR
implicit none
type(C_FUNPTR), value :: a_fn
end subroutine c_helper
end interface
contains
subroutine set_op(o_holder, a_fn)
type(op_holder), intent(inout) :: o_holder
procedure(user_op) :: a_fn
o_holder%fn => a_fn
end subroutine set_op
end module repro_mod
user.f90
subroutine user()
use repro_mod
implicit none
end subroutine user
> nvfortran -c bad_mod.f90 && nvfortran -c user.f90
NVFORTRAN-S-1257-Interface user_op must be declared. (user.f90)
workaround
As the comment says, if you move c_helper above the abstract interface then there is no problem.