From b17a1aaf72400644cb3df2f7f779f62d46fda342 Mon Sep 17 00:00:00 2001 From: Bart Nijssen Date: Tue, 14 Jul 2015 10:59:09 -0600 Subject: [PATCH] reorganized makefile to put user-configurable elements at the top --- build/Makefile | 144 +++++++++++++++++++++++++------------------------ 1 file changed, 74 insertions(+), 70 deletions(-) diff --git a/build/Makefile b/build/Makefile index d3b141be9..d7a689b7b 100644 --- a/build/Makefile +++ b/build/Makefile @@ -4,15 +4,79 @@ # # To troubleshoot your paths and setup, type 'make check' # +# At a minimum you will need to set F_MASTER and FC. You will probably +# also have to specify the location of your netcdf and lapack libraries #======================================================================== -# PART 0: Define directory paths +# PART 0: User-configurable part #======================================================================== # Define core directory below which everything resides. This is the # parent directory of the 'build' directory F_MASTER = +# Define the Fortran Compiler. If you are using gfortran, then this needs +# to be version 4.8 or higher + +FC = + +# Define the NetCDF and LAPACK libraries and path to include files. Note +# that the defaults paths defined are those that work for our compilers +# and settings. If none of this makes sense, please talk to your system +# administrator. + +# gfortran compiler -- needs to be 4.8 or higher +# (works on Mac OS X with Macports) +ifeq "$(FC)" "gfortran-mp-4.8" + NCDF_PATH = /opt/local + LAPK_PATH = /opt/local + # define the lapack libraries + LIBLAPACK = -L$(LAPK_PATH)/lib -llapack -lblas -latlas +endif + +# Intel fortran compiler +ifeq "$(FC)" "ifort" + NCDF_PATH = /opt/netcdf-4.3.0+ifort-12.1 + LAPK_PATH = /usr + # define the lapack libraries + LIBLAPACK = -L$(LAPK_PATH)/lib -llapack +endif + +# Portland group compiler +ifeq "$(FC)" "pgf90" + NCDF_PATH = /usr/local/netcdf-4.3.0/pgi-13.8 + LAPK_PATH = /usr + # define the lapack libraries + LIBLAPACK = -L$(LAPK_PATH)/lib -llapack +endif + +LIBNETCDF = -L$(NCDF_PATH)/lib -lnetcdff +INCNETCDF = -I$(NCDF_PATH)/include + +# Define compiler flags. If you use a different compiler, +# you will need to figure out what the equivalent flags are +# and may need to update this section +ifeq "$(FC)" "gfortran-mp-4.8" + FLAGS_NOAH = -ffree-form -fdefault-real-8 -ffree-line-length-none -fmax-errors=0 -g -fbacktrace -Wno-unused -Wno-unused-dummy-argument + FLAGS_COMM = -g -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -Wno-unused -Wno-unused-dummy-argument + FLAGS_SUMMA = -g -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -Wno-unused -Wno-unused-dummy-argument +endif +ifeq "$(FC)" "ifort" + FLAGS_NOAH = -warn nounused -autodouble -noerror_limit -FR -O0 -auto -WB -traceback -g -fltconsistency + FLAGS_COMM = -debug -warn all -check all -FR -O0 -auto -WB -traceback -g -fltconsistency -fpe0 + FLAGS_SUMMA = -debug -warn all -check all -FR -O0 -auto -WB -traceback -g -fltconsistency -fpe0 +endif +ifeq "$(FC)" "pgf90" + FLAGS1 = -Mbackslash -g -Mchkptr -Mchkstk -Mpgicoff -Minform=inform -Ktrap=divz,inv -Mprof=lines,time + FLAGS_NOAH = -g -Mr8 -Mfree + FLAGS_COMM = -Mbackslash -g -Mchkptr -Mchkstk -Mpgicoff -Minform=inform -Ktrap=fp -traceback + FLAGS_SUMMA = -Mbackslash -g -Mbounds -Mchkptr -Mchkstk -Mpgicoff -Minform=inform -Ktrap=divz,inv,ovf -traceback +endif + +#======================================================================== +# PART 1: Define directory paths +#======================================================================== + # Core directory that contains source code F_KORE_DIR = $(F_MASTER)/build/source @@ -23,7 +87,7 @@ MOD_PATH = $(F_MASTER)/build EXE_PATH = $(F_MASTER)/bin #======================================================================== -# PART 1: Assemble all of the SUMMA sub-routines +# PART 2: Assemble all of the SUMMA sub-routines #======================================================================== # Define directories @@ -34,8 +98,8 @@ DSHARE_DIR = $(F_KORE_DIR)/dshare NUMREC_DIR = $(F_KORE_DIR)/numrec NOAHMP_DIR = $(F_KORE_DIR)/noah-mp ENGINE_DIR = $(F_KORE_DIR)/engine -# -# Numerical Recipes utilities + +# utilities SUMMA_NRUTIL= \ nrtype.f90 \ nr_utility.f90 @@ -54,7 +118,6 @@ SUMMA_HOOKUP= \ summaFileManager.f90 HOOKUP = $(patsubst %, $(HOOKUP_DIR)/%, $(SUMMA_HOOKUP)) - # Data modules SUMMA_DATAMS= \ var_lookup.f90 \ @@ -147,41 +210,6 @@ COMM_ALL = $(NRUTIL) $(NRPROC) $(HOOKUP) $(DATAMS) $(UTILMS) # ... stitch together SUMMA programs SUMMA_ALL = $(PRELIM) $(MODRUN) $(SOLVER) $(NETCDF) -#======================================================================== -# PART 2: Define the libraries, driver programs, and executables -#======================================================================== - -# Define the Fortran Compiler -FC = - -# Define the NetCDF libraries and path to include files -ifeq "$(FC)" "gfortran" - NCDF_PATH = /usr/local/netcdf-4.3.0/gcc-4.7.2 - LAPK_PATH = /usr - # define the lapack libraries - LIBLAPACK = -L$(LAPK_PATH)/lib -llapack -lblas -latlas -endif -ifeq "$(FC)" "gfortran-mp-4.8" - NCDF_PATH = /opt/local - LAPK_PATH = /opt/local - # define the lapack libraries - LIBLAPACK = -L$(LAPK_PATH)/lib -llapack -lblas -latlas -endif -ifeq "$(FC)" "ifort" - NCDF_PATH = /opt/netcdf-4.3.0+ifort-12.1 - LAPK_PATH = /usr - # define the lapack libraries - LIBLAPACK = -L$(LAPK_PATH)/lib -llapack -endif -ifeq "$(FC)" "pgf90" - NCDF_PATH = /usr/local/netcdf-4.3.0/pgi-13.8 - LAPK_PATH = /usr - # define the lapack libraries - LIBLAPACK = -L$(LAPK_PATH)/lib -llapack -endif -LIBNETCDF = -L$(NCDF_PATH)/lib -lnetcdff -INCNETCDF = -I$(NCDF_PATH)/include - # Define the driver routine SUMMA_DRIVER= \ multi_driver.f90 @@ -191,36 +219,8 @@ DRIVER = $(patsubst %, $(DRIVER_DIR)/%, $(SUMMA_DRIVER)) DRIVER__EX = summa.exe #======================================================================== -# PART 3: Compile the puppy -#======================================================================== - -# Define flags -ifeq "$(FC)" "gfortran" - FLAGS_NOAH = -ffree-form -fdefault-real-8 -ffree-line-length-none -fmax-errors=0 -g -fbacktrace -Wno-unused -Wno-unused-dummy-argument - FLAGS_COMM = -g -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -Wno-unused -Wno-unused-dummy-argument - FLAGS_SUMMA = -g -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -Wno-unused -Wno-unused-dummy-argument -endif -ifeq "$(FC)" "gfortran-mp-4.8" - FLAGS_NOAH = -ffree-form -fdefault-real-8 -ffree-line-length-none -fmax-errors=0 -g -fbacktrace -Wno-unused -Wno-unused-dummy-argument - FLAGS_COMM = -g -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -Wno-unused -Wno-unused-dummy-argument - FLAGS_SUMMA = -g -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -Wno-unused -Wno-unused-dummy-argument -endif -ifeq "$(FC)" "ifort" - FLAGS_NOAH = -warn nounused -autodouble -noerror_limit -FR -O0 -auto -WB -traceback -g -fltconsistency - FLAGS_COMM = -debug -warn all -check all -FR -O0 -auto -WB -traceback -g -fltconsistency -fpe0 - FLAGS_SUMMA = -debug -warn all -check all -FR -O0 -auto -WB -traceback -g -fltconsistency -fpe0 -endif -ifeq "$(FC)" "pgf90" - FLAGS1 = -Mbackslash -g -Mchkptr -Mchkstk -Mpgicoff -Minform=inform -Ktrap=divz,inv -Mprof=lines,time - FLAGS_NOAH = -g -Mr8 -Mfree - FLAGS_COMM = -Mbackslash -g -Mchkptr -Mchkstk -Mpgicoff -Minform=inform -Ktrap=fp -traceback - FLAGS_SUMMA = -Mbackslash -g -Mbounds -Mchkptr -Mchkstk -Mpgicoff -Minform=inform -Ktrap=divz,inv,ovf -traceback -endif - -#FLAGS = -O3 -W -v - -#.SUFFIXES: .f .o .f90 - +# PART 4: Checks +#====================================================================== # make sure that the paths are defined. These are just some high level checks ifndef F_MASTER $(error F_MASTER is undefined) @@ -235,6 +235,10 @@ ifndef NCDF_PATH $(error NCDF_PATH is undefined) endif +#======================================================================== +# PART 5: compilation +#====================================================================== + # Compile all: compile_noah compile_comm compile_summa link clean install