Hi,
I wonder if pointers to global subroutines are available in CUDA Fortran.
I’m rewriting an MPI CPU code to CUDA and there are a few useful pointers to functions and subroutines there, used like this:
! Define an interface:
ABSTRACT INTERFACE
SUBROUTINE sub_bc(scheme)
IMPORT
CHARACTER(LEN=*) :: scheme
END SUBROUTINE sub_bc
END INTERFACE
! Declare the pointer
PROCEDURE(sub_bc), POINTER :: bc
! Somewhere in the main code assign the pointer to a subroutine:
bc => boundary_condition_close
I’ve tried similar thing in CUDA, but it looks it doesn’t work; the compiler message is (my pointer is gder_y):
NVFORTRAN-S-0084-Illegal use of symbol gder_y - attempt to CALL a non-SUBROUTINE
I found one old discussion on the topic here:
So have they been implemented and supported in CUDA?
Or should I use write some wrapper?
As you saw, I ran into a similar issue a while back when trying to use subroutine pointers in Fortran with different compilers. After some trial and error, I found a workaround that involved using a procedure pointer within a derived type instead of directly pointing to the subroutine. That approach resolved my compilation issues on pgf95
I’m not sure how this translates to CUDA Fortran specifically, but it might be worth trying out if CUDA’s Fortran implementation allows similar workarounds.
Hope this helps a bit, and best of luck with the MPI to CUDA rewrite!