Topic: Translate FORTRAN to C++ for CUDA

Hello All,

Its been a couple of years since last post and I haven't seen this topic in the the forum and apologize if I missed it.

I have my OpenMP FORTRAN simulation that I am thinking about converting to use multi-processing capabilities of CUDA cores. I would like to continue to use Windows as my development and runtime platform. I have done a cursory look at this and this seems possible. However, I don't want to rewrite the entire code into C++. I think SF (never attempted this) supports C++ subroutines called from FORTRAN, would it be possible to create CUDA C++ subroutines called from in my SF FORTRAN compile and link?

Thanks in advance,
Rod

Re: Translate FORTRAN to C++ for CUDA

Rod,

You'll want to use the ISO_C_BINDING intrinsic module for calling C++ routines. You will need to create a C interface to your C++ routines, though, but that issue is common to many C++ libraries that expose their API.  Fortran has no concept of C++ classes, so they'll appear as opaque type(c_ptr) arguments in Fortran.

You'll want to look at the ISO_C_BINDING module and the section on interoperability with C as a starting point, at least.  If you plan on really getting into this, you might consider a book on modern Fortran that would explain using ISO_C_BINDING.

EDIT: You'll also likely run into linking issues.  What your purporting to do isn't particularly easy or straightforward as you'll be using an additional compiler for all the CUDA code.

Jeff Armstrong
Approximatrix, LLC