# # On Input: # File Srcfiles contains list of source files # File $(MAKE_MACHINE) (e.g. generic_hao64) contains compiler specific Make vars # F90: f90 compiler (e.g., pgf90, ifort, etc) # MPIF90: f90 compiler for MPI jobs (e.g., mpif90) # FFLAGS: compiler flags (e.g., -r8) # OPTIM: optimization flag (e.g., -O3) # DBGFLAGS: Debug flags # INC_NETCDF: Include directory for netcdf # LIB_NETCDF: Library directory for netcdf # File Make.env contains additional information from the job script # MAKE_MACHINE: File containing machine-specific compiler flags, etc # DIRS: List of source-code directories (in Make.env) # MPI: TRUE or FALSE # EXECNAME: Name of executable to make # DEBUG: TRUE or FALSE # SHELL = /bin/sh all: Depends prereq include Make.env # made by job script before gmake include $(MAKE_MACHINE) # machine-specific file with compiler/make info null := comma := $(null),$(null) space := $(null) $(null) OS := $(shell uname -s) VPATH := $(subst $(space),:,$(DIRS)) INC_DIRS := $(foreach dir,$(DIRS),-I$(dir)) -I$(INC_NETCDF) SOURCES := $(shell cat Srcfiles) OBJS := $(addsuffix .o, $(basename $(SOURCES))) # LIBS may be specified in Make.machine file, so append here LIBS += -L$(LIB_NETCDF) -lnetcdf COUPLING := NO FC := $(F90) Depends:: @echo "OS =$(OS)" @echo "MAKE_MACHINE =$(MAKE_MACHINE)" @echo "DIRS =$(DIRS)" @echo "INC_DIRS =$(INC_DIRS)" @echo "VPATH =$(VPATH)" @echo "FC =$(FC)" @echo "MPI =$(MPI)" @echo "LIB_NETCDF =$(LIB_NETCDF)" @echo "INC_NETCDF =$(INC_NETCDF)" @echo "EXECNAME =$(EXECNAME)" @echo "DEBUG =$(DEBUG)" perl mkdepends $(DIRS) $(MAKE) $(EXECNAME) # # When creating a release, this should be hard-coded # to the SVN repository release number svn_version.inc: @echo "Making svn_version.inc: svn_version = ${SVN_VERSION}" @echo "! This file is auto-generated by the TIEGCM build process" >$@ @echo " character(len=8) :: svn_version = '${SVN_VERSION}'" >>$@ nchist.F: $(shell rm -f svn_version.inc) svn_version.inc $(EXECNAME): $(OBJS) $(FC) -o $@ $(OBJS) $(LIBS) $(LDFLAGS) ifeq ($(MPI),TRUE) CPPFLAGS += -DMPI FC := $(MPIF90) endif ifeq ($(COUPLING), INTERCOMM) CPPFLAGS += -DINTERCOMM endif ifeq ($(COUPLING), ADHOC) CPPFLAGS += -DCISMAH endif ifeq ($(DEBUG),TRUE) CPPFLAGS += -DDEBUG OPTIM := -g else DBGFLAGS := $(null) endif ifeq ($(OS),Linux) CPPFLAGS := -DLINUX $(CPPFLAGS) endif ifeq ($(OS),AIX) CPPFLAGS := -WF -DAIX $(CPPFLAGS) CPPFLAGS := $(subst $(space),$(comma),$(CPPFLAGS)) endif FFLAGS += $(INC_DIRS) $(OPTIM) $(DBGFLAGS) clean: rm -f Depends Srcfiles *.o *.mod $(EXECNAME) veryclean: rm -f Depends Srcfiles *.o *.mod $(EXECNAME) Makefile Make.env $(MAKE_MACHINE) machines.ini mkdepends defs.h cwd fort* include Depends