Skip to content

Instantly share code, notes, and snippets.

@fxcoudert
Created January 23, 2017 21:29
Show Gist options
  • Save fxcoudert/53ff62c24a56cf8fa6b80a21b716dd6b to your computer and use it in GitHub Desktop.
Save fxcoudert/53ff62c24a56cf8fa6b80a21b716dd6b to your computer and use it in GitHub Desktop.
Patch for cp2k's macOS arch files
Modernizing the CP2K arch files for macOS:
* the -Y linker option is obsolete (and was only used to debug missing symbols at link time,
so not entirely clear why it was in the arch file to begin with)
* all compilers on macOS accept the -framework options without the -Wl wrapping (since at least 2008 for GCC)
* __GFORTRAN is not used anymore in cp2k
* -march=native is not particularly useful, especially for debugging
* lgcc_eh is linked in automatically whenever needed (and it should not be needed here anyway)
I also suggest adding arch files for popt and psmp build (which rely an MPI compiler and scalapack)
Index: cp2k/arch/Darwin-IntelMacintosh-gfortran.sdbg
===================================================================
--- cp2k/arch/Darwin-IntelMacintosh-gfortran.sdbg (revision 17701)
+++ cp2k/arch/Darwin-IntelMacintosh-gfortran.sdbg (working copy)
@@ -1,12 +1,11 @@
-CC = cc
+# With GCC 4.9 or later, for gcc and gfortran
+CC = gcc
CPP =
FC = gfortran
LD = gfortran
AR = ar -r
RANLIB = ranlib
-DFLAGS = -D__GFORTRAN -D__FFTSG -D__NO_STATM_ACCESS
-FCFLAGS = -O0 -g -march=native -ffree-form $(DFLAGS)
+DFLAGS = -D__NO_STATM_ACCESS
+FCFLAGS = -O0 -g -ffree-form $(DFLAGS)
LDFLAGS = $(FCFLAGS)
-LIBS = -Wl,-framework -Wl,Accelerate -Wl,-Y -Wl,10
-
-
+LIBS = -framework Accelerate
Index: cp2k/arch/Darwin-IntelMacintosh-gfortran.sopt
===================================================================
--- cp2k/arch/Darwin-IntelMacintosh-gfortran.sopt (revision 17701)
+++ cp2k/arch/Darwin-IntelMacintosh-gfortran.sopt (working copy)
@@ -1,6 +1,4 @@
-#Using gcc49 package from MacPorts for gcc and fortran
-#port select --set gcc mp-gcc49
-
+# With GCC 4.9 or later, for gcc and gfortran
CC = gcc
CPP =
FC = gfortran
@@ -10,6 +8,4 @@ RANLIB = ranlib
DFLAGS = -D__NO_STATM_ACCESS
FCFLAGS = -O2 -ffast-math -funroll-loops -ftree-vectorize -ffree-form $(DFLAGS)
LDFLAGS = $(FCFLAGS)
-LIBS = -Wl,-framework -Wl,Accelerate -Wl,-Y -Wl,10
-
-
+LIBS = -framework Accelerate
Index: cp2k/arch/Darwin-IntelMacintosh-gfortran.ssmp
===================================================================
--- cp2k/arch/Darwin-IntelMacintosh-gfortran.ssmp (revision 17701)
+++ cp2k/arch/Darwin-IntelMacintosh-gfortran.ssmp (working copy)
@@ -1,6 +1,4 @@
-#Using gcc49 package from MacPorts for gcc and fortran
-#port select --set gcc mp-gcc49
-
+# With GCC 4.9 or later, for gcc and gfortran
CC = gcc
CPP =
FC = gfortran
@@ -10,6 +8,4 @@ RANLIB = ranlib
DFLAGS = -D__NO_STATM_ACCESS
FCFLAGS = -fopenmp -ffast-math -funroll-loops -ftree-vectorize -ffree-form -O2 $(DFLAGS)
LDFLAGS = $(FCFLAGS)
-LIBS = -Wl,-framework -Wl,Accelerate -Wl,-Y -Wl,10 -lgcc_eh
-
-
+LIBS = -framework Accelerate
Index: cp2k/arch/Darwin-IntelMacintosh-gfortran.popt
===================================================================
--- cp2k/arch/Darwin-IntelMacintosh-gfortran.popt (nonexistent)
+++ cp2k/arch/Darwin-IntelMacintosh-gfortran.popt (working copy)
@@ -0,0 +1,12 @@
+# With GCC 4.9 or later, for gcc and gfortran
+# With a recent OpenMPI and scalapack installed
+CC = gcc
+CPP =
+FC = mpif90
+LD = mpif90
+AR = ar -r
+RANLIB = ranlib
+DFLAGS = -D__MPI_VERSION=3 -D__parallel -D__SCALAPACK -D__NO_STATM_ACCESS
+FCFLAGS = -O2 -ffast-math -funroll-loops -ftree-vectorize -ffree-form $(DFLAGS)
+LDFLAGS = $(FCFLAGS)
+LIBS = -framework Accelerate -lscalapack
Index: cp2k/arch/Darwin-IntelMacintosh-gfortran.psmp
===================================================================
--- cp2k/arch/Darwin-IntelMacintosh-gfortran.psmp (nonexistent)
+++ cp2k/arch/Darwin-IntelMacintosh-gfortran.psmp (working copy)
@@ -0,0 +1,12 @@
+# With GCC 4.9 or later, for gcc and gfortran
+# With a recent OpenMPI and scalapack installed
+CC = gcc
+CPP =
+FC = mpif90
+LD = mpif90
+AR = ar -r
+RANLIB = ranlib
+DFLAGS = -fopenmp -D__MPI_VERSION=3 -D__parallel -D__SCALAPACK -D__NO_STATM_ACCESS
+FCFLAGS = -O2 -ffast-math -funroll-loops -ftree-vectorize -ffree-form $(DFLAGS)
+LDFLAGS = $(FCFLAGS)
+LIBS = -framework Accelerate -lscalapack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment