Skip to content

Commit

Permalink
Add build time error for missing OpenMP
Browse files Browse the repository at this point in the history
  • Loading branch information
oschuett committed Dec 28, 2020
1 parent 7c2fe69 commit 7e00210
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions arch/Linux-x86-64-gfortran.dumpast
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ AR = ar -r

DFLAGS =
FCFLAGS = -O0 -fstrict-aliasing -fbacktrace -g -fbounds-check -ffree-form -fdump-fortran-original -fopenmp $(DFLAGS)
CFLAGS = -fopenmp $(DFLAGS)
LDFLAGS = $(FCFLAGS)
LIBS = -llapack -lblas

Expand Down
4 changes: 4 additions & 0 deletions src/base/base_uses.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
timeset,&
timestop

! Check for OpenMP early on - ideally before the compiler fails with a cryptic message.
#if !defined(_OPENMP)
"OpenMP is required. Please add -fopenmp to your Fortran compiler flags."
#endif

! Dangerous: Full path can be arbitrarily long and might overflow Fortran line.
#if !defined(__SHORT_FILE__)
Expand Down
4 changes: 4 additions & 0 deletions src/grid/common/grid_library.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ static grid_library_config config = {.backend = GRID_BACKEND_AUTO,
.apply_cutoff = false,
.queue_length = 8192};

#if !defined(_OPENMP)
#error "OpenMP is required. Please add -fopenmp to your C compiler flags."
#endif

/*******************************************************************************
* \brief Initializes the grid library.
* \author Ole Schuett
Expand Down
2 changes: 1 addition & 1 deletion tools/conventions/analyze_src.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

flag_exceptions_re = re.compile(
r"__COMPILE_REVISION|__COMPILE_DATE|__COMPILE_ARCH|__COMPILE_HOST|CUDA_VERSION|"
r"__INTEL_COMPILER|__cplusplus|\$\{.*\}\$|__.*__"
r"__INTEL_COMPILER|__cplusplus|_OPENMP|\$\{.*\}\$|__.*__"
)

portable_filename_re = re.compile(r"^[a-zA-Z0-9._/#~=+-]*$")
Expand Down

0 comments on commit 7e00210

Please sign in to comment.