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

New compiler options and updates of top-level makefile #1087

Merged
merged 5 commits into from
Nov 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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.


gfortran-clang: 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.
88 changes: 80 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,36 @@ ifort:
"CXXFLAGS_OPT = -O3" \
"LDFLAGS_OPT = -O3" \
"FFLAGS_DEBUG = -g -convert big_endian -FR -CU -CB -check all -fpe0 -traceback" \
"CFLAGS_DEBUG = -g -fpe0 -traceback" \
"CXXFLAGS_DEBUG = -g -fpe0 -traceback" \
"CFLAGS_DEBUG = -g -traceback" \
"CXXFLAGS_DEBUG = -g -traceback" \
"LDFLAGS_DEBUG = -g -fpe0 -traceback" \
"FFLAGS_OMP = -openmp" \
"CFLAGS_OMP = -openmp" \
"FFLAGS_OMP = -qopenmp" \
"CFLAGS_OMP = -qopenmp" \
"CORE = $(CORE)" \
"DEBUG = $(DEBUG)" \
"USE_PAPI = $(USE_PAPI)" \
"OPENMP = $(OPENMP)" \
"CPPFLAGS = $(MODEL_FORMULATION) -D_MPI -DUNDERSCORE" )

ifort-scorep:
( $(MAKE) all \
"FC_PARALLEL = scorep --compiler mpif90" \
"CC_PARALLEL = scorep --compiler mpicc" \
"CXX_PARALLEL = scorep --compiler mpicxx" \
"FC_SERIAL = ifort" \
"CC_SERIAL = icc" \
"CXX_SERIAL = icpc" \
"FFLAGS_PROMOTION = -real-size 64" \
"FFLAGS_OPT = -O3 -g -convert big_endian -FR" \
"CFLAGS_OPT = -O3 -g" \
"CXXFLAGS_OPT = -O3 -g" \
"LDFLAGS_OPT = -O3 -g" \
"FFLAGS_DEBUG = -g -convert big_endian -FR -CU -CB -check all -fpe0 -traceback" \
"CFLAGS_DEBUG = -g -traceback" \
"CXXFLAGS_DEBUG = -g -traceback" \
"LDFLAGS_DEBUG = -g -fpe0 -traceback" \
"FFLAGS_OMP = -qopenmp" \
"CFLAGS_OMP = -qopenmp" \
"CORE = $(CORE)" \
"DEBUG = $(DEBUG)" \
"USE_PAPI = $(USE_PAPI)" \
Expand All @@ -177,7 +202,7 @@ ifort-gcc:
"CFLAGS_DEBUG = -g" \
"CXXFLAGS_DEBUG = -g" \
"LDFLAGS_DEBUG = -g -fpe0 -traceback" \
"FFLAGS_OMP = -openmp" \
"FFLAGS_OMP = -qopenmp" \
"CFLAGS_OMP = -fopenmp" \
"CORE = $(CORE)" \
"DEBUG = $(DEBUG)" \
Expand Down Expand Up @@ -210,6 +235,31 @@ gfortran:
"OPENMP = $(OPENMP)" \
"CPPFLAGS = $(MODEL_FORMULATION) -D_MPI -DUNDERSCORE" )

gfortran-clang:
( $(MAKE) all \
"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" \
"FFLAGS_OMP = -fopenmp" \
"CFLAGS_OMP = -fopenmp" \
"CORE = $(CORE)" \
"DEBUG = $(DEBUG)" \
"USE_PAPI = $(USE_PAPI)" \
"OPENMP = $(OPENMP)" \
"CPPFLAGS = $(MODEL_FORMULATION) -D_MPI -DUNDERSCORE" )

g95:
( $(MAKE) all \
"FC_PARALLEL = mpif90" \
Expand Down Expand Up @@ -309,8 +359,8 @@ intel-nersc:
"CFLAGS_OPT = -O3" \
"CXXFLAGS_OPT = -O3" \
"LDFLAGS_OPT = -O3" \
"FFLAGS_OMP = -openmp" \
"CFLAGS_OMP = -openmp" \
"FFLAGS_OMP = -qopenmp" \
"CFLAGS_OMP = -qopenmp" \
"FFLAGS_DEBUG = -real-size 64 -g -convert big_endian -FR -CU -CB -check all -gen-interfaces -warn interfaces -traceback" \
"CFLAGS_DEBUG = -g -traceback" \
"CXXFLAGS_DEBUG = -g -traceback" \
Expand Down Expand Up @@ -386,6 +436,11 @@ ifneq "$(NETCDF)" ""
ifneq ($(wildcard $(NETCDF)/lib/libnetcdff.*), ) # CHECK FOR NETCDF4
LIBS += $(NCLIBF)
endif # CHECK FOR NETCDF4
ifneq "$(NETCDFF)" ""
FCINCLUDES += -I$(NETCDFF)/include
LIBS += -L$(NETCDFF)/lib
LIBS += $(NCLIBF)
endif
LIBS += $(NCLIB)
endif

Expand Down Expand Up @@ -610,7 +665,24 @@ endif
endif


mpas_main:
compiler_test:
ifeq "$(OPENMP)" "true"
@echo "Testing compiler for OpenMP support"
@echo "#include <omp.h>" > conftest.c; echo "int main() { int n = omp_get_num_threads(); 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 "#include <omp.h>" > conftest.c; echo "int main() { int n = omp_get_num_threads(); 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 "#include <omp.h>" > conftest.cpp; echo "int main() { int n = omp_get_num_threads(); 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; use omp_lib; integer n; n = OMP_GET_NUM_THREADS(); 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; use omp_lib; integer n; n = OMP_GET_NUM_THREADS(); 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