# Set up special characters null := space := $(null) $(null) # Check for directory in which to put executable ifeq ($(MODEL_EXEDIR),$(null)) MODEL_EXEDIR :=. endif # Check for name of executable ifeq ($(EXENAME),$(null)) EXENAME := ../gldas_model endif # Check if SPMD is defined in "misc.h" # Ensure that it is defined and not just "undef SPMD" set in file ifeq ($(SPMD),$(null)) SPMDSET := $(shell /bin/grep SPMD misc.h) ifneq (,$(findstring define,$(SPMDSET))) SPMD := TRUE else SPMD := FALSE endif endif LIB_MPI := INC_MPI := # Load dependency search path. dirs := . $(shell cat Filepathnoah) # Set cpp search path, include netcdf cpp_dirs := $(dirs) $(INC_MPI) cpp_path := $(foreach dir,$(cpp_dirs),-I$(dir)) # format for command line # Expand any tildes in directory names. Change spaces to colons. VPATH := $(foreach dir,$(cpp_dirs),$(wildcard $(dir))) VPATH := $(subst $(space),:,$(VPATH)) #------------------------------------------------------------------------ # Primary target: build the model #------------------------------------------------------------------------ all: $(MODEL_EXEDIR)/$(EXENAME) # Get list of files and determine objects and dependency files FIND_FILES = $(wildcard $(dir)/*.F $(dir)/*.f $(dir)/*.F90 $(dir)/*.c) FILES = $(foreach dir, $(dirs),$(FIND_FILES)) SOURCES := $(sort $(notdir $(FILES))) DEPS := $(addsuffix .d, $(basename $(SOURCES))) OBJS := $(addsuffix .o, $(basename $(SOURCES))) DOCS := $(addsuffix .tex, $(basename $(SOURCES))) $(MODEL_EXEDIR)/$(EXENAME): $(OBJS) $(FC) -o $@ $(OBJS) $(FOPTS) $(LDFLAGS) debug: $(OBJS) echo "FFLAGS: $(FFLAGS)" echo "LDFLAGS: $(LDFLAGS)" echo "OBJS: $(OBJS)" #*********************************************************************** #********** Architecture-specific flags and rules*********************** #*********************************************************************** #---------------------------------------------------------------- # ZEUS/GAEA/Eddy/Tide #---------------------------------------------------------------- ifeq ($(target),wcoss2) FC = ftn CC = cc else FC = mpiifort CC = mpiicc endif CPP = CPPFLAGS = -P # CFLAGS = $(cpp_path) -c -w -O -q64 -qcpluscmt CFLAGS = -DIRIX64 -c -O #FFLAGS = -free -c -O0 -g -traceback -check all -fpe0 -ftrapuv -CB -convert big_endian #FFLAGS1 = -c -O0 -g -traceback -check all -fpe0 -ftrapuv -CB -convert big_endian ## Fanglin Yang ##FFLAGS = -fp-model strict -free -c -O0 -convert big_endian ## Dell standard flags FFLAGS = -fp-model precise -ftz -fast-transcendentals -no-prec-div -no-prec-sqrt -align array64byte -free -c -O3 -convert big_endian FFLAGS1 = -fp-model precise -ftz -fast-transcendentals -no-prec-div -no-prec-sqrt -align array64byte -c -O3 -convert big_endian LDFLAGS = ${BACIO_LIB4} ${IP_LIB4} ${W3EMC_LIB4} ${W3NCO_LIB4} ${SP_LIB4} -qopenmp ifeq ($(target),s4) FFLAGS += -march=ivybridge FFLAGS1 += -march=ivybridge CFLAGS += -march=ivybridge endif ifeq ($(SPMD),TRUE) # FFLAGS -= -mp # # FFLAGS += -macro_expand # FFLAGS += -I$(INC_MPI) -macro_expand # # LDFLAGS += -L$(LIB_MPI) -lmpi else FFLAGS += -DHIDE_MPI endif .SUFFIXES: .f .f90 .F .F90 .c .o .F.o: $(FC) $(FFLAGS) $< .F90.o: $(FC) $(FFLAGS) $< .f.o: $(FC) $(FFLAGS1) $< .f90.o: $(FC) $(FFLAGS) $< .c.o: $(CC) $(cpp_path) $(CFLAGS) $< RM := rm clean: $(RM) -f *.o *.mod *.stb $(MODEL_EXEDIR)/$(EXENAME) install: mv $(MODEL_EXEDIR)/$(EXENAME) ../../../exec realclean: $(RM) -f *.o *.d *.mod *.stb $(MODEL_EXEDIR)/$(EXENAME) #------------------------------------------------------------------------ #!!!!!!!!!!!!!!!!DO NOT EDIT BELOW THIS LINE.!!!!!!!!!!!!!!!!!!!!!!!!!!!! #------------------------------------------------------------------------ # These rules cause a dependency file to be generated for each source # file. It is assumed that the tool "makdep" (provided with this # distribution in clm2/tools/makdep) has been built and is available in # the user's $PATH. Files contained in the clm2 distribution are the # only files which are considered in generating each dependency. The # following filters are applied to exclude any files which are not in # the distribution (e.g. system header files like stdio.h). # # 1) Remove full paths from dependencies. This means gnumake will not break # if new versions of files are created in the directory hierarchy # specified by VPATH. # # 2) Because of 1) above, remove any file dependencies for files not in the # clm2 source distribution. # # Finally, add the dependency file as a target of the dependency rules. This # is done so that the dependency file will automatically be regenerated # when necessary. # # i.e. change rule # make.o : make.c make.h # to: # make.o make.d : make.c make.h #------------------------------------------------------------------------ DEPGEN := ./MAKDEP/makdep -s F %.d : %.c @echo "Building dependency file $@" @$(DEPGEN) -f $(cpp_path) $< > $@ %.d : %.f @echo "Building dependency file $@" @$(DEPGEN) -f $(cpp_path) $< > $@ %.d : %.F90 @echo "Building dependency file $@" @$(DEPGEN) -f $(cpp_path) $< > $@ %.d : %.F @echo "Building dependency file $@" @$(DEPGEN) -f $(cpp_path) $< > $@ # # if goal is clean or realclean then don't include .d files # without this is a hack, missing dependency files will be created # and then deleted as part of the cleaning process # INCLUDE_DEPS=TRUE ifeq ($(MAKECMDGOALS), realclean) INCLUDE_DEPS=FALSE endif ifeq ($(MAKECMDGOALS), clean) INCLUDE_DEPS=FALSE endif ifeq ($(INCLUDE_DEPS), TRUE) -include $(DEPS) endif