#----------------------------------------------------------------------- # This Makefile is for building the CCM on a CRAY, SGI or SUN. # # Note: If the NetCDF libraries and include files are not in /usr/local/lib # and /usr/local/include then define the environment variables # LIB_NETCDF and INC_NETCDF to point to the proper locations. # # Note: VPATH only looks in the current directory !!!! # Create file named Filepath for multiple search paths # #------------------------------------------------------------------------ # Set up special characters null := space := $(null) $(null) # Check for the NetCDF library and include directories ifeq ($(LIB_NETCDF),$(null)) LIB_NETCDF := /usr/local/lib endif ifeq ($(INC_NETCDF),$(null)) INC_NETCDF := /usr/local/include endif # Check for the MPI library and include directories ifeq ($(LIB_MPI),$(null)) LIB_MPI := /usr/local/mpich/build/LINUX/ch_p4/lib endif ifeq ($(INC_MPI),$(null)) INC_MPI := /usr/local/mpich/include endif # Check for directory in which to put executable ifeq ($(MODEL_EXEDIR),$(null)) MODEL_EXEDIR := . endif # Check for name of executable ifeq ($(EXENAME),$(null)) EXENAME := atm endif # Determine platform UNAMES := $(shell uname -s) UNAMEM := $(findstring CRAY,$(shell uname -m)) # Load dependency search path. dirs := . $(shell cat Filepath) # Set cpp search path, include netcdf cpp_dirs := $(dirs) $(INC_NETCDF) $(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)) # Get list of files and determine objects and dependency files FIND_FILES = $(wildcard $(dir)/*.c $(dir)/*.F) FILES = $(foreach dir, $(dirs),$(FIND_FILES)) SOURCES := $(sort $(notdir $(FILES))) OBJS := $(addsuffix .o, $(basename $(SOURCES))) DEPS := $(addsuffix .d, $(basename $(SOURCES))) all: $(MODEL_EXEDIR)/$(EXENAME) # Architecture-specific flags and rules # #------------------------------------------------------------------------ # Cray #------------------------------------------------------------------------ ifeq ($(UNAMEM),CRAY) CPP := cpp # # If libncaro.a exists in /usr/local/lib, add it as well as libecmfft.a # and libmss.a to LDFLAGS # NCARO_LIB := $(strip $(wildcard /usr/local/lib/libncaro.a)) LDFLAGS := -Wl"-f indef -L $(LIB_NETCDF) -l netcdf -M ,s" ifeq ($(NCARO_LIB),/usr/local/lib/libncaro.a) LDFLAGS := $(LDFLAGS) -Wl" -L /usr/local/lib -l ncaro,ecmfft,mss" endif FPPFLAGS := -N -P FC := f90 FFLAGS := -c -I$(INC_NETCDF) .SUFFIXES: .SUFFIXES: .F .c .o .F.o: cpp $(cpp_path) $(FPPFLAGS) $< > $*.f $(FC) $(FFLAGS) $*.f $(RM) $*.f .c.o: cc -c $(cpp_path) $< endif #------------------------------------------------------------------------ # SGI #------------------------------------------------------------------------ ifeq ($(UNAMES),IRIX64) CPP := /lib/cpp FC := f77 CFLAGS := $(cpp_path) -64 FFLAGS := $(cpp_path) -64 -r8 -i4 -O3 -c -mp -mpio SPEC_FFLAGS := $(cpp_path) -64 -r8 -i4 -O2 -c -mp -mpio LDFLAGS := -64 -mp -L$(LIB_NETCDF) -lnetcdf ifeq ($(SPMD),TRUE) FFLAGS := $(cpp_path) -64 -r8 -i4 -O3 -c -I$(INC_MPI) -col120 LDFLAGS := -64 -L$(LIB_NETCDF) -lnetcdf -L$(LIB_MPI) -lmpi endif .SUFFIXES: .SUFFIXES: .F .c .o radclw.o: radclw.F misc.h params.h implicit.h prgrid.h pagrid.h comlun.h comtim.h crdcon.h comctl.h coreiorad.h $(FC) $(SPEC_FFLAGS) $< .F.o: $(FC) $(FFLAGS) $< endif #------------------------------------------------------------------------ # SUN #------------------------------------------------------------------------ ifeq ($(UNAMES),SunOS) CPP := /usr/ccs/lib/cpp CFLAGS := $(cpp_path) FFLAGS := $(cpp_path) -r8 -i4 -fast -stackvar LDFLAGS := -L$(LIB_NETCDF) -lnetcdf ifeq ($(SPMD),TRUE) FFLAGS := $(FFLAGS) -I$(INC_MPI) LDFLAGS := $(LDFLAGS) -L$(LIB_MPI) -lmpi -lnsl -lsocket endif endif #------------------------------------------------------------------------ # Linux #------------------------------------------------------------------------ ifeq ($(UNAMES),Linux) CFLAGS := $(cpp_path) FC := pgf77 FFLAGS := $(cpp_path) -r8 -i4 -O2 -byteswapio -Mrecursive -Kieee -Mdalign -Mextend #LDFLAGS := -L$(LIB_NETCDF) -lnetcdf -L$(HOME)/lib -ltiming LDFLAGS := -L$(LIB_NETCDF) -lnetcdf #/usr/local/devel/netcdf/lib/libnetcdf.a ifeq ($(SPMD),TRUE) FFLAGS := $(cpp_path) -r8 -i4 -O2 -byteswapio -Mrecursive -Kieee -Mdalign -Mextend -Mdefaultunit -I$(INC_MPI) #LDFLAGS := /usr/local/devel/netcdf/lib/libnetcdf.a -L$(HOME)/lib -L$(LIB_MPI) -lmpich #LDFLAGS := /usr/local/devel/netcdf/lib/libnetcdf.a -L$(HOME)/lib $(LIB_MPI)/libmpich.a $(LIB_MPI)/libfmpich.a LDFLAGS := -L$(LIB_NETCDF) -lnetcdf -L$(LIB_MPI) -lmpich endif endif #------------------------------------------------------------------------ # Default rules #------------------------------------------------------------------------ $(MODEL_EXEDIR)/$(EXENAME): $(OBJS) $(FC) -o $@ $(OBJS) $(LDFLAGS) RM := rm clean: $(RM) -f *.o $(MODEL_EXEDIR)/$(EXENAME) realclean: $(RM) -f *.o *.d $(MODEL_EXEDIR)/$(EXENAME) #------------------------------------------------------------------------ #!!!!!!!!!!!!!!!!DO NOT EDIT BELOW THIS LINE.!!!!!!!!!!!!!!!!!!!!!!!!!!!! #------------------------------------------------------------------------ # These rules cause a dependency file to be generated (using cpp) # for each source file. Files contained in the ccm 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 a) above, remove any file dependencies for files not in the # ccm 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 #------------------------------------------------------------------------ ifeq ($(UNAMES),Linux) %.d : %.c @echo "Building dependency for $@" @ $(SHELL) -ec 'makedepend $(cpp_path) -f- $< \ | head -1 \ | sed -e '\''s/\/[^ ]*\///g'\''\ -e '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \ [ -s $@ ] || rm -f $@' %.d: %.F @ echo "Building dependency for $@" @ $(SHELL) -ec 'makedepend $(cpp_path) -f- $< \ | sed -e '\''s/\/[^ ]*\///g'\''\ -e '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \ [ -s $@ ] || rm -f $@' else %.d : %.c @echo "Building dependency for $@" @$(CPP) -M $(cpp_path) $< | head -1 | sed -e \ 's/\:.*\//:\ /' > $@ %.d : %.F @echo "Building dependency for $@" @$(CPP) -M $(cpp_path) $< | sed -e \ '/\/usr\/include\//d' -e 's/\:.*\//:\ /' -e 's/$*.o/& $@/g' > $@ endif # # 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