############################################################################### ## ## This is the top-level makefile for building a JULES executable. ## ## This makefile is maintained to be compliant with the GNU make utility ONLY, ## although it will most probably work with other make utilities. The GNU make ## utility is available free-of-charge from http://www.gnu.org/software/make/, ## but most Unix/Linux systems have it lurking somewhere anyway. (Type ## 'gmake -v' or 'which gmake' to check.) ## ## To build, you will need to set the following three variables to point to ## the directory in which you are building JULES (most probably the one ## containing this makefile) and the location of the pre-compiled netCDF ## Fortran interface. The netCDF interface library is available free-of-charge ## from Unidata at http://www.unidata.ucar.edu/software/netcdf/. Note that ## this makefile does NOT build the netCDF library, that must be done ## beforehand as a separate process. ## ## CDF_LIB_PATH should point to the directory containing the netCDF library ## archive (e.g. libnetcdf.a). ## CDF_MOD_PATH should point to the directory containing the netCDF Fortran 90 ## module file (e.g. netcdf.mod). ## ## There are two options for the build that can be passed to the makefile from ## the command line. The variable COMPILER allows the user to tell the make ## which compiler they are using and the makefile will pick up compiler-specific ## variables from the separate text files, e.g. Makefile.comp.sun, that come ## with this distribution. Currently, there are four allowed values for ## COMPILER: sun, intel, g95, nag. ## ## The variable BUILD allows the user to maintain several JULES libraries and ## executables built with different compiler flags. This is particularly useful ## when making any modifications to the JULES source code, as it allows the user ## to switch to a debugging version of the model without having to recompile ## all of the source code or edit any makefiles. This makefile is set up to ## build a "normal" version, a debugging version and an optimised/fast version. ## Currently, there are 3 allowed values for BUILD: run, debug, fast. ## ## These two options can be specified from the command line, e.g., ## ## make BUILD=run COMPILER=sun ## ## KNOWN BUGS. ## * Using Intel compiler on Linux, GNU make sometimes returns root "/" from ## $(PWD) command. Get around this by specifying JULESDIR=/home/jules on ## the command line. ## * Using Intel compiler on Linux, GNU make does not move the .mod files to ## MOD_DIR after each sub-make completes. Get around this by adding ## -module $(JULESDIR)/MODS to FF_* variables in Makefile.comp.intel. ## ############################################################################### JULESDIR=$(PWD) CDF_LIB_PATH=/usr/lib/ CDF_MOD_PATH=/usr/include/ ## The user is advised not to modify code below this line. ## ###################################### ## Make some decisions about the ## ## netCDF library. ## ###################################### CDFDUMMY=false OBJ_CDF_DUMMY= ifeq ($(CDFDUMMY),true) DIR_CDF_DUMMY=$(JULESDIR)/UTILS/netcdf_dummy CDF_MOD_PATH=$(DIR_CDF_DUMMY) CDF_LIB_PATH=$(DIR_CDF_DUMMY) OBJ_CDF_DUMMY=$(DIR_CDF_DUMMY)/JULES_NETCDF_DUMMY.o endif ifndef CDF_LIB_PATH $(error You need to set the variable CDF_LIB_PATH either in the JULES Makefile or from the command line) endif ifndef CDF_MOD_PATH $(error You need to set the variable CDF_MOD_PATH either in the JULES Makefile or from the command line) endif ###################################### ## Rules for making library archive ## ## members from source files. ## ###################################### include $(JULESDIR)/Makefile.common.mk ###################################### ## Choose compiler. ## ###################################### ## Set default values for these variables else you can get ## some nasty "rm -f *" commands issued during a clean. FC=f90 CC=cc LIB_INC=-L LIB_PRE=-l LIB_FPRE=lib LIB_FSUF=.a LINKER=$(FC) MOD_INC=-M MOD_FSUF=.mod COMPILER= ifndef COMPILER $(error You need to set the variable COMPILER either in the JULES Makefile or from the command line) endif ifeq ($(COMPILER),sun) include $(JULESDIR)/Makefile.comp.sun endif ifeq ($(COMPILER),g95) include $(JULESDIR)/Makefile.comp.g95 endif ifeq ($(COMPILER),gfortran) include $(JULESDIR)/Makefile.comp.gfortran endif ifeq ($(COMPILER),nag) include $(JULESDIR)/Makefile.comp.nag endif ifeq ($(COMPILER),intel) include $(JULESDIR)/Makefile.comp.intel endif ifeq ($(COMPILER),pgf) include $(JULESDIR)/Makefile.comp.pgf endif ifeq ($(COMPILER),misc) include $(JULESDIR)/Makefile.comp.misc endif ifeq ($(COMPILER)$(FC),misc@@) $(error You can only use COMPILER misc if you have set the variables in Makefile.comp.misc) endif ###################################### ## Construct an number of useful ## ## variables based on user/compiler ## ## options. ## ###################################### EXENAME=jules$(LIB_SPECIAL).exe JULESLIBNOM=$(LIB_FPRE)jules$(LIB_SPECIAL)$(LIB_FSUF) JULESLIB=$(JULESDIR)/$(JULESLIBNOM) ARC=$(JULESLIB) MAINOBJNOM=JULES.o MAINOBJ=$(JULESDIR)/$(MAINOBJNOM) HEADMAKE=$(JULESDIR)/Makefile $(JULESDIR)/Makefile.common.mk MOD_DIR=$(JULESDIR)/MODS LIB_PATH = $(LIB_INC)$(JULESDIR) LIB_PATH += $(LIB_INC)$(CDF_LIB_PATH) LIB_LIBS = $(LIB_PRE)jules$(LIB_SPECIAL) ifeq ($(CDFDUMMY),false) LIB_LIBS += $(LIB_PRE)netcdf endif MOD_PATH = $(MOD_PUT)$(MOD_DIR) MOD_PATH += $(MOD_INC)$(MOD_DIR) MOD_PATH += $(MOD_INC)$(CDF_MOD_PATH) CFLAGS= FFLAGS=$(FF_RUN) LDFLAGS=$(LIB_PATH) $(LIB_LIBS) ###################################### ## Start of compilation/library ## ## options. ## ###################################### BUILD=debug # Options are run, debug, fast, condor. LIB_SPECIAL= ifeq ($(BUILD),debug) LIB_SPECIAL=_debug FFLAGS=$(FF_DBG) LINKER=$(FC) endif ifeq ($(BUILD),fast) LIB_SPECIAL=_fast FFLAGS=$(FF_FAST) LINKER=$(FC) endif ifeq ($(BUILD),condor) LIB_SPECIAL=_condor FFLAGS=$(FF_CON) LINKER=condor_compile $(FC) endif ###################################### ## Make these variables available to## ## the sub-makes. ## ###################################### export FC export MOD_FSUF export MOD_DIR export CFLAGS export FFLAGS export MOD_PATH export LIB_PATH export LIB_LIBS export JULESDIR export ARC ###################################### ## Variables for executing the ## ## recursive build and clean. ## ###################################### SRC_DIRS = SOURCE/MODULES/PARAMS \ SOURCE/MODULES/CONTROL \ SOURCE/SUBROUTINES/VEGETATION \ SOURCE/SUBROUTINES/CONTROL \ SOURCE/SUBROUTINES/INITIALISATION \ SOURCE/SUBROUTINES/RADIATION \ SOURCE/SUBROUTINES/SOIL \ SOURCE/SUBROUTINES/SURFACE CLEAN_SRC_DIRS=$(SRC_DIRS:%=clean_%) MAKE_SRC_DIRS=$(SRC_DIRS:%=make_%) ###################################### ## Dependencies for building library## ## and executable. ## ###################################### all : $(EXENAME) .PHONY : all $(EXENAME) : $(JULESLIB) $(MAINOBJ) $(OBJ_CDF_DUMMY) $(HEADMAKE) $(LINKER) -o $(EXENAME) $(MAINOBJ) \ $(OBJ_CDF_DUMMY) \ $(LIB_PATH) \ $(MOD_PATH) \ $(LIB_LIBS) $(JULESLIB) : $(OBJ_CDF_DUMMY) $(MAKE_SRC_DIRS) touch $(JULESLIB) $(MAINOBJ) : $(JULESLIB) $(EXTRACT) $(JULESLIB) $(MAINOBJNOM) $(OBJ_CDF_DUMMY) : $(HEADMAKE) @$(MAKE) -C $(DIR_CDF_DUMMY) $(MAKE_SRC_DIRS) : make_% : $(HEADMAKE) @$(MAKE) -C $* ###################################### ## Dependencies for cleaning. ## ###################################### .PHONY : clean clean: $(CLEAN_SRC_DIRS) $(RM) $(JULESLIB) $(EXENAME) $(MOD_DIR)/*$(MOD_FSUF) $(MAINOBJ) $(CLEAN_SRC_DIRS) : clean_% : @$(MAKE) clean -C $* ## End of file.