#----------------------------------------------------------------------- # Makefile template for building CAM on various platforms. # # This makefile assumes the existence the file: # # Filepath The directories, listed one per line, that contain the source # code required to build CAM. This list is used to set the # VPATH variable which is used by GNU make to search for # dependencies (after it looks in the directory from which # it was invoked). This list of directories, prepended with ./, # is also used to construct the list of search directories # used by the preprocessor (as specified by -I command-line options). # # The following macros are set by CAM's configure script. They should only be hand edited # by experts. # # UNAMES Result of the "uname -s" command on the target platform. # ROOTDIR Root directory for the CAM source distribution. # EXENAME Name of the executable. # MODEL_EXEDIR Directory to build the executable in. # INC_NETCDF Directory containing the NetCDF include files. # LIB_NETCDF Directory containing the NetCDF library. # MOD_NETCDF Directory containing the NetCDF module files. # INC_MPI Directory containing the MPI include files. # LIB_MPI Directory containing the MPI library. # MPI_LIB_NAME Name of MPI library. # LAPACK_LIBDIR Directory containing the LAPACK library. # ESMF_LIBDIR Directory containing the ESMF library (for use with external library only). # DEBUG Set to TRUE to turn on compiler debugging options. Default: FALSE # SPMD Whether to build in SPMD mode or not. [values TRUE FALSE] # SMP Set to TRUE to enable building in SMP mode (uses OpenMP). # FC Fortran compiler # FC_TYPE Type of Fortran compiler invoked by generic wrapper script such as mpif90. # CC C compiler # USER_LINKER Allow user to override the default linker specified in Makefile. # USER_CPPDEFS Additional CPP defines. # USER_CFLAGS Additional C compiler flags that the user wishes to set. # USER_FFLAGS Additional Fortran compiler flags that the user wishes to set. # USER_LDLAGS Additional load flags that the user wishes to set. # F_OPTIMIZATION_OVERRIDE # Use this to replace default Fortran compiler optimization. # COSP_LIBDIR Directory where COSP library will be built. # MCT_LIBDIR Directory where MCT library will be built. # # Note: An internal implementation of the ESMF time-manager interface is provided # with the sequential CCSM distribution in models/utils/esmf_wrf_timemgr. # #------------------------------------------------------------------------ # Set up special characters null := space := $(null) $(null) comma := $(null),$(null) # Initialize macros that allow a user override. # Set user override of default Fortran compiler optimizations ifneq ($(strip $(F_OPTIMIZATION_OVERRIDE)),) FORTRAN_OPTIMIZATION := $(F_OPTIMIZATION_OVERRIDE) endif # Set user specified linker ifneq ($(strip $(USER_LINKER)),) LINKER := $(USER_LINKER) endif # Load dependency search path. dirs := . $(shell cat Filepath) # Set cpp search path, include netcdf cpp_dirs := $(dirs) $(INC_NETCDF) $(INC_MPI) $(INC_PNETCDF) 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 #------------------------------------------------------------------------ #touch filepath to ensure Depends and Srcfiles are regenerated all: $(MODEL_EXEDIR)/$(EXENAME) touch_filepath touch_filepath: touch $(CURDIR)/Filepath # Get list of files and build dependency file for all .o files # using perl scripts mkSrcfiles and mkDepends SOURCES := $(shell cat Srcfiles) # Newer makes set the CURDIR variable. CURDIR := $(shell pwd) $(CURDIR)/Depends: $(CURDIR)/Srcfiles $(CURDIR)/Filepath $(ROOTDIR)/models/atm/cam/bld/mkDepends Filepath Srcfiles > $@ $(CURDIR)/Srcfiles: $(CURDIR)/Filepath $(ROOTDIR)/models/atm/cam/bld/mkSrcfiles > $@ OBJS := $(addsuffix .o, $(basename $(SOURCES))) CPPDEF := -DNO_SHR_VMATH -DSEQ_MCT $(USER_CPPDEFS) ifeq ($(SPMD),TRUE) CPPDEF += -DSPMD endif ifneq ($(strip $(LIB_PNETCDF)),) CPPDEF += -D_PNETCDF -DUSEMPIIO #dont use LDFLAGS here, it will be overwritten below USER_LDFLAGS += -L$(LIB_PNETCDF) -lpnetcdf endif $(MODEL_EXEDIR)/$(EXENAME): $(OBJS) $(LINKER) -o $@ $(OBJS) -L$(LIB_NETCDF) -lnetcdf $(LDFLAGS) ifneq ($(strip $(COSP_LIBDIR)),) # Rules to build COSP in its own library. Add abortutils dependency so # cosp code can make use of subroutine endrun. $(COSP_LIBDIR)/libcosp.a: abortutils.o $(MAKE) -C $(COSP_LIBDIR) cospsimulator_intr.o: $(COSP_LIBDIR)/libcosp.a endif # Rules to build MCT in its own library. $(MCT_LIBDIR)/mct/libmct.a: $(MAKE) -C $(MCT_LIBDIR) shr_kind_mod.o: $(MCT_LIBDIR)/mct/libmct.a perf_utils.o: $(MCT_LIBDIR)/mct/libmct.a pio_kinds.o: $(MCT_LIBDIR)/mct/libmct.a RtmSpmd.o: $(MCT_LIBDIR)/mct/libmct.a # Compilation rules: .SUFFIXES: .SUFFIXES: .F .F90 .f90 .c .s .o .F.o: $(FC) -c $(FIXEDFLAGS) $(FFLAGS) $< .F90.o: $(FC) -c $(FREEFLAGS) $(FFLAGS) $< .f90.o: $(FC) -c $(FREEFLAGS) $(FFLAGS) $< .c.o: $(CC) -c $(CFLAGS) $< .s.o: $(AS) -m $< # Rules used for the tests run by "configure -test" test_fc: test_fc.o $(LINKER) -o $@ $(FFLAGS) test_fc.o test_nc: test_nc.o $(LINKER) -o $@ $(FFLAGS) test_nc.o -L$(LIB_NETCDF) -lnetcdf -lnetcdff -Wl,-rpath=$(LIB_NETCDF) MPI_LINK_TEST := ifneq ($(strip $(LIB_MPI)),) MPI_LINK_TEST += -L$(LIB_MPI) -l$(MPI_LIB_NAME) endif test_mpi: test_mpi.o $(LINKER) -o $@ $(FFLAGS) test_mpi.o $(MPI_LINK_TEST) ESMF_LINK_TEST := ifneq ($(strip $(ESMF_LIBDIR)),) ESMF_LINK_TEST += $(ESMF_F90LINKPATHS) $(ESMF_F90LINKRPATHS) $(ESMF_F90ESMFLINKLIBS) endif test_esmf: test_esmf.o $(LINKER) -o $@ $(FFLAGS) test_esmf.o $(ESMF_LINK_TEST) debug: $(OBJS) echo "FC: $(FC)" echo "FFLAGS: $(FFLAGS)" echo "LINKER: $(LINKER)" echo "LDFLAGS: $(LDFLAGS)" echo "OBJS: $(OBJS)" clean: $(RM) $(MODEL_EXEDIR)/$(EXENAME) $(OBJS) #------------------------------------------------------------------------ # AIX #------------------------------------------------------------------------ ifeq ($(UNAMES),AIX) CPPDEF += -DAIX -DCPRIBM ifeq ($(SMP),TRUE) # THREADED_OMP is used by the timing library CPPDEF += -DTHREADED_OMP endif cpre = $(null)-WF,-D$(null) FPPFLAGS := $(patsubst -D%,$(cpre)%,$(CPPDEF)) CFLAGS := -q64 $(cpp_path) $(CPPDEF) mod_path := -I$(MOD_NETCDF) -I$(MCT_LIBDIR)/mct -I$(MCT_LIBDIR)/mpeu ifeq ($(SPMD),FALSE) mod_path += -I$(MCT_LIBDIR)/mpi-serial endif ifneq ($(strip $(COSP_LIBDIR)),) mod_path += -I$(COSP_LIBDIR) endif FC_FLAGS := -q64 -qarch=auto -qspillsize=2500 -g -qfullpath FC_FLAGS_NOOPT := $(FC_FLAGS) FREEFLAGS := -qsuffix=f=f90:cpp=F90 FIXEDFLAGS := -qfixed=132 LDFLAGS := -q64 -lmassv -bdatapsize:64k -bstackpsize:64k -btextpsize:32k ifeq ($(SMP),TRUE) FC_FLAGS_NOOPT += -qsmp=omp:noopt # -qsmp implicitly turns on -O2. Explicitly disable this for debugging. ifeq ($(DEBUG),TRUE) FC_FLAGS += -qsmp=omp:noopt CFLAGS += -qsmp=omp:noopt LDFLAGS += -qsmp=omp:noopt else FC_FLAGS += -qsmp=omp CFLAGS += -qsmp=omp LDFLAGS += -qsmp=omp endif endif ifeq ($(SPMD),TRUE) LDFLAGS += -lmpi_r else FPPFLAGS += -WF,-DHIDE_MPI,-D_MPISERIAL,-DNO_MPIMOD,-DNO_MPI2 endif ifeq ($(DEBUG),TRUE) # Bounds checking is unreliable on the IBM. # Sometimes you can get it to go if you turn threading off. # Only turn float-trapping on for debug mode as it's a 20% performance hit. FC_FLAGS += -qinitauto=7FF7FFFF -qflttrap=ov:zero:inv:en # As of Apr/15/2003 cam2_0_2_dev18 xlfrte8.1.0.3 using -lmass causes the code to core-dump # when using DEBUG compiler options. else # Check for override of default Fortran compiler optimizations ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null)) # Inline when not debugging FORTRAN_OPTIMIZATION := -O2 -qstrict -Q endif FC_FLAGS += $(FORTRAN_OPTIMIZATION) CFLAGS += -O2 LDFLAGS += -lmass endif ifneq ($(strip $(LAPACK_LIBDIR)),) LDFLAGS += -L$(LAPACK_LIBDIR) -llapack -lblas endif FFLAGS := $(cpp_path) $(mod_path) $(FPPFLAGS) $(FC_FLAGS) FFLAGS_NOOPT := $(cpp_path) $(mod_path) $(FPPFLAGS) $(FC_FLAGS_NOOPT) FC_AUTO_R8 := -qrealsize=8 # These RRTMG files take an extraordinarily long time to compile with optimization. # Until mods are made to read the data from files, just remove optimization from # their compilation. rrtmg_lw_k_g.o: rrtmg_lw_k_g.f90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< rrtmg_sw_k_g.o: rrtmg_sw_k_g.f90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< endif #------------------------------------------------------------------------ # Linux #------------------------------------------------------------------------ ifeq ($(UNAMES),Linux) CPPDEF += -DLINUX ifeq ($(SMP),TRUE) # THREADED_OMP is used by the timing library CPPDEF += -DTHREADED_OMP endif CFLAGS = $(cpp_path) $(CPPDEF) # Set search path for module files for external libraries. mod_path := -I$(MOD_NETCDF) -I$(MCT_LIBDIR)/mct -I$(MCT_LIBDIR)/mpeu ifeq ($(SPMD),FALSE) mod_path += -I$(MCT_LIBDIR)/mpi-serial endif ifneq ($(strip $(COSP_LIBDIR)),) mod_path += -I$(COSP_LIBDIR) endif # PGI ifeq ($(FC_TYPE),pgi) CPPDEF += -DNO_R16 -DCPRPGI CFLAGS += -O2 -Mvect=nosse FC_FLAGS := -i4 -Mdalign -Mextend -byteswapio FC_FLAGS_NOOPT:= $(FC_FLAGS) FREEFLAGS := -Mfree FIXEDFLAGS := -Mfixed LDFLAGS := -Wl,-rpath=$(LIB_NETCDF) ifeq ($(DEBUG),TRUE) FC_FLAGS += -g -Ktrap=fp -Mbounds -Kieee else # Check for override of default Fortran compiler optimizations ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null)) FORTRAN_OPTIMIZATION := -gopt -O2 -Mvect=nosse -Kieee endif FC_FLAGS += $(FORTRAN_OPTIMIZATION) endif ifeq ($(SMP),TRUE) FC_FLAGS += -mp FC_FLAGS_NOOPT += -mp CFLAGS += -mp LDFLAGS += -mp endif FFLAGS := $(cpp_path) $(mod_path) $(CPPDEF) $(FC_FLAGS) FFLAGS_NOOPT := $(cpp_path) $(mod_path) $(CPPDEF) $(FC_FLAGS_NOOPT) FC_AUTO_R8 := -r8 # These RRTMG files cause a compiler error when using optimization. # Until mods are made to read the data from files, just remove optimization from # their compilation. rrtmg_lw_k_g.o: rrtmg_lw_k_g.f90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< rrtmg_sw_k_g.o: rrtmg_sw_k_g.f90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< endif # Lahey ifeq ($(FC_TYPE),lahey) FC_FLAGS := --wide FC_FLAGS_NOOPT:= $(FC_FLAGS) FREEFLAGS := FIXEDFLAGS := --fix LDFLAGS := --staticlink -Wl,-rpath=$(LIB_NETCDF) ifeq ($(DEBUG),TRUE) # --trace produces a call traceback on abort # --trap causes code to stop on divide by zero or overflow exceptions # --pca prevents overwriting constant arguments, but it overrides the # action of --chk a. So don't specify both. # --chk for basic compiler checking (a,e,s,u,x) #TBH: this works FFLAGS += -g --chk --pca #TBH: this FAILS FFLAGS += -g --chk a,e,s,u,x --pca FC_FLAGS += -g --chk a,e,s,u --trace --trap else # Check for override of default Fortran compiler optimizations ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null)) FORTRAN_OPTIMIZATION := -O endif FC_FLAGS += $(FORTRAN_OPTIMIZATION) # Threading only works by putting thread memory on the heap rather than the stack (--threadheap). # As of lf95 version 6.2 the thread stacksize limits are (still) too small to run even small # resolution problems (FV at 10x15 res fails). ifeq ($(SMP),TRUE) FC_FLAGS += --openmp --threadheap 4096 FC_FLAGS_NOOPT += --openmp --threadheap 4096 CFLAGS += -fstack-check LDFLAGS += --openmp --threadheap 4096 endif endif FFLAGS := $(cpp_path) $(mod_path) $(CPPDEF) $(FC_FLAGS) FFLAGS_NOOPT := $(cpp_path) $(mod_path) $(CPPDEF) $(FC_FLAGS_NOOPT) FC_AUTO_R8 := -CcdRR8 binary_io.o: binary_io.F90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< wrap_nf.o: wrap_nf.F90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< wrap_mpi.o: wrap_mpi.F90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< apex_subs.o: apex_subs.F90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< endif # Intel ifeq ($(FC_TYPE),intel) CPPDEF += -DCPRINTEL FC_FLAGS := -ftz -convert big_endian -fp-model precise FC_FLAGS_NOOPT:= -ftz -convert big_endian -O0 FREEFLAGS := FIXEDFLAGS := -fixed -132 LDFLAGS := -static-intel ifeq ($(DEBUG),TRUE) FC_FLAGS += -check all -fpe0 -g -traceback else # Check for override of default Fortran compiler optimizations ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null)) FORTRAN_OPTIMIZATION := -O2 endif FC_FLAGS += $(FORTRAN_OPTIMIZATION) endif ifeq ($(SMP),TRUE) FC_FLAGS += -openmp FC_FLAGS_NOOPT += -openmp CFLAGS += -openmp LDFLAGS += -openmp endif FFLAGS := $(cpp_path) $(mod_path) $(CPPDEF) $(FC_FLAGS) FFLAGS_NOOPT:= $(cpp_path) $(mod_path) $(CPPDEF) $(FC_FLAGS_NOOPT) FC_AUTO_R8 := -autodouble # These RRTMG files take an extraordinarily long time to compile with optimization. # Until mods are made to read the data from files, just remove optimization from # their compilation. rrtmg_lw_k_g.o: rrtmg_lw_k_g.f90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< rrtmg_sw_k_g.o: rrtmg_sw_k_g.f90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< shr_scam_mod.o: shr_scam_mod.F90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< endif # Pathscale ifeq ($(FC_TYPE),pathscale) CPPDEF += -DNO_R16 -DCPRPATHSCALE FC_FLAGS := -extend_source -ftpp -fno-second-underscore FC_FLAGS_NOOPT:= $(FC_FLAGS) -O0 FREEFLAGS := FIXEDFLAGS := LDFLAGS := ifeq ($(SMP),TRUE) FC_FLAGS += -mp FC_FLAGS_NOOPT += -mp CFLAGS += -mp LDFLAGS += -mp endif ifeq ($(DEBUG),TRUE) FC_FLAGS += -g -trapuv -Wuninitialized else # Check for override of default Fortran compiler optimizations ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null)) FORTRAN_OPTIMIZATION := -O endif FC_FLAGS += $(FORTRAN_OPTIMIZATION) endif FFLAGS := $(cpp_path) $(mod_path) $(CPPDEF) $(FC_FLAGS) FFLAGS_NOOPT := $(cpp_path) $(mod_path) $(CPPDEF) $(FC_FLAGS_NOOPT) FC_AUTO_R8 := -r8 # These RRTMG files take an extraordinarily long time to compile with optimization. # Until mods are made to read the data from files, just remove optimization from # their compilation. rrtmg_lw_k_g.o: rrtmg_lw_k_g.f90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< rrtmg_sw_k_g.o: rrtmg_sw_k_g.f90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< endif # gfortran ifeq ($(FC_TYPE),gnu) CPPDEF += -DNO_R16 FC_FLAGS := -fno-range-check -fcray-pointer FC_FLAGS_NOOPT:= $(FC_FLAGS) -O0 FREEFLAGS := -ffree-form -ffree-line-length-none FIXEDFLAGS := -ffixed-form -ffixed-line-length-132 LDFLAGS := ifeq ($(SMP),TRUE) FC_FLAGS += -fopenmp FC_FLAGS_NOOPT += -fopenmp CFLAGS += -fopenmp LDFLAGS += -fopenmp endif ifeq ($(DEBUG),TRUE) FC_FLAGS += -g -ggdb else # Check for override of default Fortran compiler optimizations ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null)) FORTRAN_OPTIMIZATION := -O endif FC_FLAGS += $(FORTRAN_OPTIMIZATION) endif FFLAGS := $(cpp_path) $(mod_path) $(CPPDEF) $(FC_FLAGS) FFLAGS_NOOPT := $(cpp_path) $(mod_path) $(CPPDEF) $(FC_FLAGS_NOOPT) FC_AUTO_R8 := -fdefault-real-8 -fdefault-double-8 # These RRTMG files take an extraordinarily long time to compile with optimization. # Until mods are made to read the data from files, just remove optimization from # their compilation. rrtmg_lw_k_g.o: rrtmg_lw_k_g.f90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< rrtmg_sw_k_g.o: rrtmg_sw_k_g.f90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< endif # CCE ifeq ($(FC_TYPE),cray) CPPDEF += -DNO_R16 -DCPRCRAY CFLAGS += -O1,vector0 FC_FLAGS := -e m -N 255 FC_FLAGS_NOOPT:= $(FC_FLAGS) FREEFLAGS := -f free FIXEDFLAGS := -f fixed LDFLAGS := ifeq ($(DEBUG),TRUE) FC_FLAGS += -g else # Check for override of default Fortran compiler optimizations ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null)) FORTRAN_OPTIMIZATION := -O2,vector1,fp1 endif FC_FLAGS += $(FORTRAN_OPTIMIZATION) endif ifeq ($(SMP),TRUE) FC_FLAGS += -O omp FC_FLAGS_NOOPT += -O omp CFLAGS += -O omp LDFLAGS += -O omp endif FFLAGS := $(cpp_path) $(mod_path) $(CPPDEF) $(FC_FLAGS) FFLAGS_NOOPT := $(cpp_path) $(mod_path) $(CPPDEF) $(FC_FLAGS_NOOPT) # These RRTMG files cause a compiler error when using optimization. # Until mods are made to read the data from files, just remove optimization from # their compilation. rrtmg_lw_k_g.o: rrtmg_lw_k_g.f90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< rrtmg_sw_k_g.o: rrtmg_sw_k_g.f90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< endif # Flags common to all compilers ifneq ($(strip $(LAPACK_LIBDIR)),) LDFLAGS += -L$(LAPACK_LIBDIR) -llapack -lblas endif ifeq ($(SPMD),TRUE) FFLAGS += ifneq ($(strip $(LIB_MPI)),) LDFLAGS += -L$(LIB_MPI) -l$(MPI_LIB_NAME) endif else FFLAGS += -DHIDE_MPI -D_MPISERIAL -DNO_MPIMOD -DNO_MPI2 -DNO_SIZEOF endif endif #------------------------------------------------------------------------ # Darwin # PowerPC = XLF compiler (serial only, no MPI multi-tasking or OpenMP threading) # Intel = Intel Fortran Compiler # # For MPI, assumes that MPICH2 has been installed. #------------------------------------------------------------------------ ifeq ($(UNAMES),Darwin) #---------------------------------------------------------------------- # Common stuff #---------------------------------------------------------------------- CPPDEF += -DSYSDARWIN ifeq ($(NESTED_OMP),TRUE) CPPDEF += -DNESTED_PAR -DSYSDARWIN endif #-------------------------------------------------------------------- # ifort #-------------------------------------------------------------------- ifeq ($(findstring ifort,$(FC)),ifort) # ADDRESS := Q32 ADDRESS := Q64 ifeq ($(ADDRESS),Q32) QCMP := endif ifeq ($(ADDRESS),Q64) QCMP := -m64 QLDR := -m64 endif CPPDEF += -DLINUX -DDarwin CFLAGS := $(cpp_path) $(CPPDEF) -O2 $(QCMP) -gdwarf-2 mod_path := -I$(MOD_NETCDF) -I$(MCT_LIBDIR)/mct -I$(MCT_LIBDIR)/mpeu ifeq ($(SPMD),FALSE) mod_path += -I$(MCT_LIBDIR)/mpi-serial endif # NOTE: use-asm is require to work with Xcode 3.2.2 and ifort 11.1.088. Perhaps this # will not be needed with future versions. FFLAGS := $(cpp_path) $(mod_path) $(CPPDEF) -ftz -g -traceback -fp-model precise -use-asm -convert big_endian LDFLAGS := -Xlinker -map -Xlinker ./cam_map.txt FREEFLAGS := -FR FIXEDFLAGS := -132 ifeq ($(SMP),TRUE) FFLAGS += -openmp LDFLAGS += -openmp endif ifeq ($(SPMD),TRUE) # Works with MPICH2-1.1.1p1 # LDFLAGS += -L$(LIB_MPI) -l$(MPI_LIB_NAME)f90 -lp$(MPI_LIB_NAME) -l$(MPI_LIB_NAME) # Updated for MPICH2-1.4.1p1, which has an extra library. LDFLAGS += -L$(LIB_MPI) -l$(MPI_LIB_NAME)f90 -lp$(MPI_LIB_NAME) -l$(MPI_LIB_NAME) -lmpl else FFLAGS += -DHIDE_MPI -D_MPISERIAL -DNO_MPIMOD -DNO_MPI2 endif ifeq ($(DEBUG),TRUE) FFLAGS_NOCHK = $(FFLAGS) -O0 # FFLAGS += -fp-stack-check -check bounds -check pointers -check uninit -O0 -fpe0 -debug -ftrapuv FFLAGS += -fp-stack-check -check bounds -check uninit -O0 -fpe0 -ftrapuv # To work with idb on Lion ... LDFLAGS += -no_pie FFLAGS_NOOPT := $(FFLAGS) else # Check for override of default Fortran compiler optimizations ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null)) FORTRAN_OPTIMIZATION := -O2 endif FFLAGS_NOOPT := $(FFLAGS) -O0 FFLAGS += $(FORTRAN_OPTIMIZATION) FFLAGS_NOCHK = $(FFLAGS) endif # For OSX 10.7 to stop address-space layout randomization (ASLR) LDFLAGS += -no_pie endif #-------------------------------------------------------------------- # xlf #-------------------------------------------------------------------- ifeq ($(findstring xlf,$(FC)),xlf) CPPDEF += -DAIX -DDarwin CFLAGS := $(cpp_path) $(CPPDEF) -O2 mod_path := -I$(MOD_NETCDF) -I$(MCT_LIBDIR)/mct -I$(MCT_LIBDIR)/mpeu ifeq ($(SPMD),FALSE) mod_path += -I$(MCT_LIBDIR)/mpi-serial endif FFLAGS := $(cpp_path) $(mod_path) $(FPPFLAGS) -qspillsize=2500 FREEFLAGS := -qsuffix=f=f90:cpp=F90 FIXEDFLAGS := -qfixed=132 ifeq ($(SPMD),TRUE) LDFLAGS += -L$(LIB_MPI) -l$(MPI_LIB_NAME)f90 -lp$(MPI_LIB_NAME) -l$(MPI_LIB_NAME) else FFLAGS += -WF -DHIDE_MPI -D_MPISERIAL -DNO_MPIMOD -DNO_MPI2 endif ifeq ($(DEBUG),TRUE) # Only turn float-trapping on for debug mode as it's a performance hit. FFLAGS += -qinitauto=FF911299 -qflttrap=ov:zero:inv:en -C -qfullpath -qhalt=e ifeq ($(NESTED_OMP),TRUE) FFLAGS += -qsmp=omp:noopt:nested_par LDFLAGS += -qsmp=omp:noopt:nested_par else FFLAGS += -qsmp=omp:noopt LDFLAGS += -qsmp=omp:noopt endif FFLAGS_NOOPT := $(FFLAGS) else # Check for override of default Fortran compiler optimizations ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null)) FORTRAN_OPTIMIZATION := -O3 -qstrict endif FFLAGS_NOOPT := $(FFLAGS) -O0 FFLAGS += $(FORTRAN_OPTIMIZATION) ifeq ($(NESTED_OMP),TRUE) FFLAGS += -qsmp=omp:nested_par LDFLAGS += -qsmp=omp:nested_par else FFLAGS += -qsmp=omp LDFLAGS += -qsmp=omp endif endif endif #---------------------------------------------------------------------- # Common stuff #---------------------------------------------------------------------- # No longer needed as of OSX Lion # LDFLAGS += -lSystemStubs -lSystemStubs_profile ifeq ($(SMP),TRUE) # THREADED_PTHREADS is used by the timing library CFLAGS += -DTHREADED_PTHREADS endif # These RRTMG files take an extraordinarily long time to compile with optimization. # Until mods are made to read the data from files, just remove optimization from # their compilation. rrtmg_lw_k_g.o: rrtmg_lw_k_g.f90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< rrtmg_sw_k_g.o: rrtmg_sw_k_g.f90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< shr_scam_mod.o: shr_scam_mod.F90 $(FC) -c $(FREEFLAGS) $(FFLAGS) -O1 $< # Work around problem for debug errors in ifort with -chem none mo_gas_phase_chemdr.o: mo_gas_phase_chemdr.F90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOCHK) $< mo_waccm_hrates.o: mo_waccm_hrates.F90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOCHK) $< # Work around a compiler bug in ifort 12.1 update 7 (optimization problem) setupgkern.o: setupgkern.F90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< endif #------------------------------------------------------------------------ # BGL #------------------------------------------------------------------------ ifeq ($(UNAMES),BGL) CPPDEF += -DAIX -DBGL BGLPATH=/bgl/BlueLight/ppcfloor/bglsys cpre = $(null)-WF,-D$(null) FPPFLAGS := $(patsubst -D%,$(cpre)%,$(CPPDEF)) CFLAGS := $(cpp_path) $(CPPDEF) -O2 \ -I$(BGLPATH)/include mod_path := -I$(MOD_NETCDF) -I$(MCT_LIBDIR)/mct -I$(MCT_LIBDIR)/mpeu ifeq ($(SPMD),FALSE) mod_path += -I$(MCT_LIBDIR)/mpi-serial endif FFLAGS := -I$(BGLPATH)/include \ $(cpp_path) $(mod_path) $(FPPFLAGS) -qarch=440 \ -qspillsize=2500 -g -qfullpath FREEFLAGS := -qsuffix=f=f90:cpp=F90 FIXEDFLAGS := -qfixed=132 LDFLAGS := -L$(BGLPATH)/lib -lmpich.rts -lmsglayer.rts \ -lrts.rts -ldevices.rts ifeq ($(DEBUG),TRUE) FFLAGS += -qinitauto=FF911299 -qflttrap=ov:zero:inv:en else # Check for override of default Fortran compiler optimizations ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null)) # Inline when not debugging FORTRAN_OPTIMIZATION := -O3 -qstrict -Q endif FFLAGS += $(FORTRAN_OPTIMIZATION) endif ifneq ($(strip $(LAPACK_LIBDIR)),) LDFLAGS += -L$(LAPACK_LIBDIR) -llapack -lblas endif endif #------------------------------------------------------------------------ # BGP #------------------------------------------------------------------------ ifeq ($(UNAMES),BGP) CPPDEF += -DAIX -DBGP ifeq ($(SMP),TRUE) # THREADED_OMP is used by the timing library CPPDEF += -DTHREADED_OMP endif cpp_path += -I/bgsys/drivers/ppcfloor/arch/include cpre = $(null)-WF,-D$(null) FPPFLAGS := $(patsubst -D%,$(cpre)%,$(CPPDEF)) CFLAGS := $(cpp_path) $(CPPDEF) -O2 mod_path := -I$(MOD_NETCDF) -I$(MCT_LIBDIR)/mct -I$(MCT_LIBDIR)/mpeu ifeq ($(SPMD),FALSE) mod_path += -I$(MCT_LIBDIR)/mpi-serial endif FFLAGS := $(cpp_path) $(mod_path) $(FPPFLAGS) \ -qspillsize=2500 -g -qfullpath FFLAGS_NOOPT := $(FFLAGS) FREEFLAGS := -qsuffix=f=f90:cpp=F90 FIXEDFLAGS := -qfixed=132 LDFLAGS := $(FFLAGS) -Wl,--relax ifeq ($(SMP),TRUE) FFLAGS_NOOPT += -qsmp=omp:noopt # -qsmp implicitly turns on -O2. Explicitly disable this for debugging. ifeq ($(DEBUG),TRUE) FFLAGS += -qsmp=omp:noopt CFLAGS += -qsmp=omp:noopt LDFLAGS += -qsmp=omp:noopt else FFLAGS += -qsmp=omp CFLAGS += -qsmp=omp LDFLAGS += -qsmp=omp endif endif ifeq ($(DEBUG),TRUE) FFLAGS += -O0 -qinitauto=7FF7FFFF -qflttrap=ov:zero:inv:en FFLAGS_NOOPT += -O0 -qinitauto=7FF7FFFF -qflttrap=ov:zero:inv:en else # Check for override of default Fortran compiler optimizations ifeq ($(F_OPTIMIZATION_OVERRIDE),$(null)) # Inline when not debugging FORTRAN_OPTIMIZATION := -qarch=450 -O3 -Q -qstrict endif FFLAGS += $(FORTRAN_OPTIMIZATION) endif ifneq ($(strip $(LAPACK_LIBDIR)),) LDFLAGS += -L$(LAPACK_LIBDIR) -llapack -lblas endif # Compile these RRTMG files without optim # Until mods are made to read the data from files, just remove optimization from # their compilation. rrtmg_lw_k_g.o: rrtmg_lw_k_g.f90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< rrtmg_sw_k_g.o: rrtmg_sw_k_g.f90 $(FC) -c $(FREEFLAGS) $(FFLAGS_NOOPT) $< endif #------------------------------------------------------------------------ # Default linker is the Fortran compiler ifeq ($(strip $(LINKER)),) LINKER := $(FC) endif # For compiling and linking with external ESMF. # If linking to external ESMF library then include esmf.mk to provide the macros: # ESMF_F90COMPILEPATHS # ESMF_F90LINKPATHS # ESMF_F90LINKRPATHS # ESMF_F90ESMFLINKLIBS ifneq ($(strip $(ESMF_LIBDIR)),) include $(ESMF_LIBDIR)/esmf.mk FFLAGS += $(ESMF_F90COMPILEPATHS) LDFLAGS += $(ESMF_F90LINKPATHS) $(ESMF_F90LINKRPATHS) $(ESMF_F90ESMFLINKLIBS) #override default linker with ESMF recommendation unless user has set linker ifeq ($(strip $(USER_LINKER)),) LINKER = $(ESMF_F90LINKER) endif endif # Append user defined compiler and load flags to Makefile defaults CFLAGS += $(USER_CFLAGS) FFLAGS += $(USER_FFLAGS) LDFLAGS += $(USER_LDFLAGS) # export variables needed by sub-Make export FC export FC_FLAGS export FC_AUTO_R8 export FREEFLAGS export FIXEDFLAGS include $(CURDIR)/Depends