Skip to content
This repository has been archived by the owner on Oct 23, 2020. It is now read-only.

Commit

Permalink
Added a simple compiler test to check if openmp is supported by the c…
Browse files Browse the repository at this point in the history
…ompiler when requested.
  • Loading branch information
climbfuji committed Nov 2, 2016
1 parent ea4067d commit 6a386b4
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
58 changes: 58 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Installing MPAS
====

For general information on how to install MPAS, see https://mpas-dev.github.io.
Additional notes on building MPAS on specific architectures are summarized here.

Compiling MPAS on MacOSX (10.11 El Capitan - 10.12 Sierra)
----------
MPAS should compile out of the box on MacOSX with the standard (OS) clang compiler
and the gfortran compiler. The gfortran compiler can be installed using homebrew
(http://brew.sh), or using pre-compiled binaries from the MacOSX HPC website
(http://hpc.soureforge.net), or it can be compiled by the user from the GNU sources.

The standard clang compiler does not support OpenMP. Users wanting to compile MPAS
with OpenMP support on MacOSX will have to install the LLVM clang compiler, which is
accomplished easiest with homebrew. Since this alternative clang compiler is not in
the standard search/library path, the user will have to modify the call to the clang
and clang++ executable and add the library path to the compiler flags. Example:

...
"FC_PARALLEL = mpif90" \
"CC_PARALLEL = mpicc -cc=clang" \
"CXX_PARALLEL = mpicxx -cxx=clang++" \
"FC_SERIAL = gfortran" \
"CC_SERIAL = clang" \
"CXX_SERIAL = clang++" \
"FFLAGS_PROMOTION = -fdefault-real-8 -fdefault-double-8" \
"FFLAGS_OPT = -O3 -m64 -ffree-line-length-none -fconvert=big-endian -ffree-form" \
"CFLAGS_OPT = -O3 -m64" \
"CXXFLAGS_OPT = -O3 -m64" \
"LDFLAGS_OPT = -O3 -m64" \
"FFLAGS_DEBUG = -g -m64 -ffree-line-length-none -fconvert=big-endian -ffree-form -fbounds-check -fbacktrace -ffpe-trap=invalid,zero,overflow" \
"CFLAGS_DEBUG = -g -m64" \
"CXXFLAGS_DEBUG = -O3 -m64" \
"LDFLAGS_DEBUG = -g -m64" \
...

would become

...
"FC_PARALLEL = mpif90" \
"CC_PARALLEL = mpicc -cc=/usr/local/opt/llvm/bin/clang" \
"CXX_PARALLEL = mpicxx -cxx=/usr/local/opt/llvm/bin/clang++" \
"FC_SERIAL = gfortran" \
"CC_SERIAL = /usr/local/opt/llvm/bin/clang" \
"CXX_SERIAL = /usr/local/opt/llvm/bin/clang++" \
"FFLAGS_PROMOTION = -fdefault-real-8 -fdefault-double-8" \
"FFLAGS_OPT = -O3 -m64 -ffree-line-length-none -fconvert=big-endian -ffree-form -L/usr/local/opt/llvm/lib" \
"CFLAGS_OPT = -O3 -m64 -L/usr/local/opt/llvm/lib" \
"CXXFLAGS_OPT = -O3 -m64 -L/usr/local/opt/llvm/lib" \
"LDFLAGS_OPT = -O3 -m64 -L/usr/local/opt/llvm/lib" \
"FFLAGS_DEBUG = -g -m64 -L/usr/local/opt/llvm/lib -ffree-line-length-none -fconvert=big-endian -ffree-form -fbounds-check -fbacktrace -ffpe-trap=invalid,zero,overflow" \
"CFLAGS_DEBUG = -g -m64 -L/usr/local/opt/llvm/lib" \
"CXXFLAGS_DEBUG = -O3 -m64 -L/usr/local/opt/llvm/lib" \
"LDFLAGS_DEBUG = -g -m64 -L/usr/local/opt/llvm/lib" \
...

assuming that the LLVM clang compiler is installed in /usr/local/opt/llvm.
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,24 @@ endif
endif


mpas_main:
compiler_test:
ifeq "$(OPENMP)" "true"
@echo "Testing compiler for OpenMP support"
@echo "int main() { return 0; }" > conftest.c; $(SCC) $(CFLAGS) -o conftest.out conftest.c || \
(echo "$(SCC) does not support OpenMP - see INSTALL in top-level directory for more information"; rm -fr conftest.*; exit 1)
@echo "int main() { return 0; }" > conftest.c; $(CC) $(CFLAGS) -o conftest.out conftest.c || \
(echo "$(CC) does not support OpenMP - see INSTALL in top-level directory for more information"; rm -fr conftest.*; exit 1)
@echo "int main() { return 0; }" > conftest.cpp; $(CXX) $(CFLAGS) -o conftest.out conftest.cpp || \
(echo "$(CXX) does not support OpenMP - see INSTALL in top-level directory for more information"; rm -fr conftest.*; exit 1)
@echo "program test; stop 0; end program" > conftest.f90; $(SFC) $(FFLAGS) -o conftest.out conftest.f90 || \
(echo "$(SFC) does not support OpenMP - see INSTALL in top-level directory for more information"; rm -fr conftest.*; exit 1)
@echo "program test; stop 0; end program" > conftest.f90; $(FC) $(FFLAGS) -o conftest.out conftest.f90 || \
(echo "$(FC) does not support OpenMP - see INSTALL in top-level directory for more information"; rm -fr conftest.*; exit 1)
@rm -fr conftest.*
endif


mpas_main: compiler_test
ifeq "$(AUTOCLEAN)" "true"
$(RM) .mpas_core_*
endif
Expand Down

0 comments on commit 6a386b4

Please sign in to comment.