Source

asyncplot / .makefiles / platform.mk

Full commit
## -*- mode: Makefile; fill-column: 80 -*-
## Platform detection and flag setting.

# These are default values that may be overwritten later
mmfhome ?= $(wildcard ~mforbes)
boost_dir ?= $(mmfhome)/usr/apps/boost/current

# Compilers
CPP = cpp
CC = mpicc
CXX = mpic++
FC = mpif90

# Setup the hostname for platform specific information and should be largely
# independent of the project.
HOSTNAME = $(shell hostname -a 2> /dev/null || hostname)
host := UNKNOWN
host := $(if $(findstring jaguar, $(HOSTNAME)),JAGUAR,$(host))
host := $(if $(findstring athena, $(HOSTNAME)),ATHENA,$(host))
host := $(if $(findstring freedom, $(HOSTNAME)),NERSC,$(host))
host := $(if $(findstring franklin, $(HOSTNAME)),NERSC,$(host))
host := $(if $(findstring hyak, $(HOSTNAME)),HYAK,$(host))
uname = $(shell uname)
host := $(if $(findstring Darwin, $(uname)),MACBOOK,$(host))
host := $(if $(findstring Medtner, $(uname)),MACBOOK,$(host))

###### athena specific modifications
ifeq ($(host), ATHENA)
  kennyhome = /share/home/rochekj
  mmfhome = /share/home/mforbes
  ifeq ($(use_fft), true)
    ifeq ($(use_pthread), true)
      include_dirs += $(kennyhome)/fftw312-pt/include/
      lib_dirs += $(kennyhome)/fftw312-pt/lib/
      LDLIBS += -lfftw3_threads
    else
      include_dirs += $(kennyhome)/fftw312/include/
      lib_dirs += $(kennyhome)/fftw312/lib/
      LDLIBS += -lfftw3
    endif
  endif
  gsl_inc_dir ?= $(mmfhome)/usr/apps/gsl/current/include/
  gsl_lib_dir ?= $(mmfhome)/usr/apps/gsl/current/lib/

  include_dirs += $(mmfhome)/usr/apps/boost/current/include/

  include_dirs += /opt/intel/mkl/10.0.1.014/include
  lib_dirs += /opt/intel/cmkl/10.0.1.014/lib/em64t

  FFLAGS += -cxxlib 
endif

###### hyak specific modifications
ifeq ($(host), HYAK)
  # Source intel compiler variables.
  #. /sw/intel/Compiler/prod/bin/iccvars.sh intel64
  #. /sw/intel/Compiler/prod/bin/ifortvars.sh intel64
  #. /sw/intel/impi/prod/bin64/mpivars.sh intel64
  #export PATH=/sw/mpich_intel/bin:${PATH}
  #export LD_LIBRARY_PATH=/sw/mpich_intel/lib:${LD_LIBRARY_PATH}

  #mpif90 -c  -I/sw/intel/Compiler/11.1/072/mkl/include
  #-I/gscratch/bkrs/roche/include -I/sw/mpich
  #_intel/include/ td-slda-nuclear-solver-read-gp-cio.f90 ;
  #mpif90 -o xtdslda td-slda-nuclear-solver-read-gp-cio.o extra-io.o
  #liberf.o f-betim.o get-rnd-wf
  #.o fposio-wf.o -L/gscratch/bkrs/roche/lib -lfftw3
  #-L/sw/intel/Compiler/11.1/072/mkl/lib/em64t -
  #lmkl_scalapack_lp64 -lmkl_blacs_intelmpi_lp64 -lmkl_intel_lp64
  #-Wl,--start-group -lmkl_sequenti
  #al -lmkl_core -Wl,--end-group -lmpich -lpthread -lm

  kennyhome ?= /usr/lusers/k8r
  mmfhome ?= /usr/lusers/mforbes
  ifeq ($(use_fft), true)
    include_dirs += $(kennyhome)/fftw322-pt-intl-6gb-icc/include/
    lib_dirs += $(kennyhome)/fftw322-pt-intl-6gb-icc/lib/
    ifeq ($(use_pthread), true)
      LDLIBS += -lfftw3_threads
    else
      LDLIBS += -lfftw3
    endif
  endif

  ifeq ($(use_gsl), true)
    include_dirs += $(mmfhome)/usr/apps/gsl/current/include/
    lib_dirs += $(mmfhome)/usr/apps/gsl/current/lib/
    LDLIBS += -lgsl
  endif

  #lib_dirs += /gscratch/bkrs/roche/lib/
  #include_dirs += /gscratch/bkrs/roche/include/

  ifeq ($(use_boost), true)
    include_dirs += $(mmfhome)/usr/apps/boost/current/include/
  endif

  #include_dirs += /opt/intel/mkl/10.0.1.014/include
  #lib_dirs += /opt/intel/cmkl/10.0.1.014/lib/em64t

  #FFLAGS += -cxxlib 

  #CC = mpicxx
  #CXX = mpicxx
endif

###### Jaguar specific modifications
# Be sure to load the following before making:
#   module load gsl
ifeq ($(host), JAGUAR)
  proj_dir = /ccs/proj/csc053/mforbes/usr
  boost_dir = $(proj_dir)/apps/boost/current
  CC = CC
  CXX = CC
  FC = ftn
  compiler_family ?= PORTLAND
  warning_flags ?=
  LDLIBS += -lsci -pgcpplibs
  gsl_inc_dir ?= $(GSL_DIR)/include
  gsl_lib_dir ?= $(GSL_DIR)/lib
  gsl_lib ?= $(GSL_LIB)
  boost_inc_dir ?= $(boost_dir)/include
  boost_lib ?= $(BOOST_CLIB)
endif

###### NERSC specific modifications
# Be sure to load the following before making:
#   module load gsl
ifeq ($(host), NERSC)
  mmfhome ?= /global/homes/m/mforbes
  CC = CC
  CXX = CC
  FC = ftn
  compiler_family = PORTLAND
  warning_flags = 
  gsl_inc_dir ?= $(GSL_DIR)/include
  gsl_lib_dir ?= $(GSL_DIR)/lib
  gsl_lib ?= $(GSL_LIB)
  boost_inc_dir ?= $(boost_dir)/include
endif

###### Michael's MacBook Pro specific modifications
ifeq ($(host), MACBOOK)
  mmfhome=/Users/mforbes

  # Compilers
  CPP = cpp
  CC = gcc
  CXX = g++
  FC = gfortran

  gsl_dir ?= /opt/local
  LOADLIBES += -lgcc -framework veclib
  gsl_lib_dir ?= $(gsl_dir)/lib
  gsl_inc_dir ?= $(gsl_dir)/include
  boost_inc_dir ?= $(boost_dir)/include
endif

ifndef compiler_family
  compiler_family = UNKNOWN
  compiler_family := $(strip $(if $(findstring ICC,$(shell $(CC) --version)),\
                               INTEL, $(compiler_family)))
  compiler_family := $(strip $(if $(findstring GCC,$(shell $(CC) --version)),\
                               GCC, $(compiler_family)))
endif

##### Intel specific compile flags.  We disable some remarks here.
# remark #1418: external function definition with no prior declaration
#  - This will affect all template functions spuriously
# remark #981: operands are evaluated in unspecified order
#  - Recommended to be disabled for C++ compilation. 
ifeq ($(compiler_family), INTEL)
  ifndef WALL			# Use "make WALL=1" to include these
    warning_flags += -wd1418
    warning_flags += -wd981

    # These are probably harmless but should still be cleaned up later.
    warning_flags += -wd1419
    warning_flags += -wd593
    warning_flags += -wd869
    warning_flags += -wd383
    warning_flags += -wd2089 # definition of base class type not completed yet
  else
    MAKEOVERRIDES := $(filter-out WALL=%,$(MAKEOVERRIDES))
  endif

  # These are the mkl libraries.
  # Notes: Ordering is important... (don't grok exactly why yet.)
  # -lmkl_scalapack must precede -lmkl_blacs_openmpi_lp64.  Also
  # -lmkl_intel* needs to come before scalapack etc.
  LDLIBS += -lmkl_intel_lp64                      \
            -lmkl_sequential                      \
            -lmkl_core                            \
            -lmpich

  ifeq ($(use_blacs), true)
    LDLIBS += -lmkl_blacs_intelmpi_lp64
  endif
  ifeq ($(use_scalapack), true)
    LDLIBS += -lmkl_scalapack_lp64
  endif
endif

ifeq ($(compiler_family), GCC)
  # Ignore icc warning pragmas. 
  cwarning_flags += -Wno-unknown-pragmas
endif

ifeq ($(use_pthread), true)
  LDLIBS += -lpthread
endif

ifeq ($(use_lapack), true)
  LDLIBS += -llapack
endif

use_math ?= true
ifeq ($(use_math), true)
  LDLIBS += -lm
endif

ifeq ($(use_armadillo), true)
  include_dirs += $(mmfhome)/usr/apps/armadillo/current/include/
  ifneq ($(use_lapack), true)
    # If you have lapack libraries, you don't need the armadillo library.
    lib_dirs += $(mmfhome)/usr/apps/armadillo/current/lib/
    LDLIBS += -larmadillo
  endif
endif