use f2py to connect python and Fortran language. f2py website https://docs.scipy.org/doc/numpy/f2py/
Fortran before used gfortran and pgfortran(PGI) integrate OpenMP both work.
makefile file is below
gfortran version
gfortran -c -fopenmp mod_readfile.f90 -lgomp
f2py -c mod_readfile.f90 --f90flags="-fopenmp" -lgomp -m mod_readfile
pgfortran version
pgfortran -c -mp mod_readfile.f90 -lgomp
f2py -c mod_readfile.f90 --fcompiler=pg --f90flags="-mp" -lgomp -m mod_readfile
then !$omp direvative in Fortran was recognized
I want to extend it to OpenAcc, and !$acc is also be recognized, but it fails, because openacc is incorporated in pgfortran(PGI), so I use makefile as below
pgfortran -c -acc mod_readfile.f90 -lcublas -lcudart -lgomp
f2py -c mod_readfile.f90 --fcompiler=pg --f90flags="-acc" -m mod_readfile -lcublas -lcudart -lgomp
before I checked that
pgfortran -c -acc mod_readfile.f90
works well separately. but when it manipulated as module of python it has some problem. also confused these flags(-lcublas -lcudart -lgomp), below doesn't work because lacking -lgomp flag
gfortran -c -fopenmp mod_readfile.f90
f2py -c mod_readfile.f90 --f90flags="-fopenmp" -m mod_readfile
after google find Using F2Py with OpenACC gives import error in Python compiled with acc (gfortran)and f2py, but I still want to know is it possible to have pgfortran with acc to connect with python? which compile flags should I use? thanks