f90wrap icon indicating copy to clipboard operation
f90wrap copied to clipboard

Unable to wrap open mp code

Open Walkerqmc opened this issue 5 years ago • 1 comments
trafficstars

Hi,

I would like to use open mp in code I'm wrapping with f90wrap. The make seems to succeed but when I run the code from python I get an error that says:

ImportError: /home/john/Desktop/Project/Python Fortran/_ExampleDerivedTypes.so: undefined symbol: GOMP_parallel

I wrapped my code by modifying an example on here. I don't understand the make process that well, but I tried adding -fopenmp to the "additional flags" part of the makefile without success, as is shown below (I use gfortran). Any advice would be much appreciated.

#=======================================================================

additional flags

#=======================================================================

ifeq ($(F90),gfortran) FPP = gfortran -E PAR_FLAG = -fopenmp FPP_F90FLAGS = -x f95-cpp-input -fPIC
F90FLAGS = -fPIC -fopenmp -lgomp FCOMP = gfortran LIBS = endif

ifeq ($(F90),ifort)

FPP      = gfortran -E # gfortran f90wrap temp files only. not compilation
FPP_F90FLAGS = -x f95-cpp-input -fPIC           
F90FLAGS = -fpscomp logicals -fPIC              
FCOMP    = intelem # for f2py
LIBS =

endif

CFLAGS = -fPIC # ==> universal for ifort, gfortran, pgi

Walkerqmc avatar Jan 17 '20 20:01 Walkerqmc

This should work fine, I have wrapped OpenMP Fortran code with f90wrap in several projects. You just need to ensure the -fopenmp option gets to the linker as well as the Fortran compiler, e.g. by passing --f90flags="-fopenmp" -lgomp to f2py-f90wrap in the final stage of compilation. There's a complete Makefile that does this which you can hopefully adapt to your use case here

https://github.com/libAtoms/QUIP/blob/public/quippy/Makefile#L96

jameskermode avatar Jan 21 '20 09:01 jameskermode