I have an R package with Fortran and OpenMP than can't pass CRAN. I receive the following message:
Your package no longer installs on macOS with OpenMP issues.
My Makevars file is:
USE_FC_TO_LINK =
PKG_FFLAGS = $(SHLIB_OPENMP_FFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_FFLAGS)
C_OBJS = init.o
FT_OBJS = e_bottomup.o e_topdown.o check_nt.o
all:
@$(MAKE) $(SHLIB)
@rm -f *.o
$(SHLIB): $(FT_OBJS) $(C_OBJS)
init.o: e_bottomup.o e_topdown.o check_nt.o
How to solve this issue? Thanks.
Edit 1:
I tried adding the flag cpp:
USE_FC_TO_LINK =
PKG_FFLAGS = $(SHLIB_OPENMP_FFLAGS) *-cpp*
PKG_LIBS = $(SHLIB_OPENMP_FFLAGS)
to add the condition #ifdef _OPENMP on Fortran code before !omp...
But with R CMD Check I got the message:
Non-portable flags in variable 'PKG_FFLAGS': -cpp
The Makevars file is fine. The OMP directives must be commented !$, including the USE OMP.
For instance, I created an R package with Fortran and OMP to test (and play with it).
I included an R function to return the max number of threads in each machine:
The Fortran code is :
SUBROUTINE checkntf (nt)
!$ USE OMP_LIB
IMPLICIT NONE
INTEGER nt
!$ nt = OMP_GET_MAX_THREADS()
RETURN
END
The already install on Windows, Ubuntu and macOS as shown here