Rules.make 4.94 KB
Newer Older
1
#$Id: Rules.make,v 1.12 2005-09-23 11:27:10 kbk Exp $
gotm's avatar
gotm committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#
# This file contains rules which are shared between multiple Makefiles.
# This file is quite complicated - all compilation options are set in this
# file and included in all other Makefiles.
# Here you set the fortran compiler and the compilation mode (debug,prof,prod)
# Presently, reasonable values for the NAG Fortran 95 and the Compaq Fortran
# compilers are included.
# If you want to include info for a new compiler - please know what you are 
# doing.
#

SHELL   = /bin/sh

# The compilation mode is obtained from $COMPILATION_MODE
# default production - else debug or profiling
ifndef COMPILATION_MODE
compilation=production
else
compilation=$(COMPILATION_MODE)
endif

23 24 25 26 27 28 29 30 31 32 33
DEFINES =

ifeq ($(GETM_NO_3D),true)
DEFINES += -DNO_3D
export GETM_NO_BAROCLINIC=true
endif

ifeq ($(GETM_NO_BAROCLINIC),true)
DEFINES += -DNO_BAROCLINIC
endif

kbk's avatar
kbk committed
34 35
ifeq ($(GETM_SPM),true)
DEFINES += -DSPM
36 37
endif

38 39 40 41
ifeq ($(GETM_BIO),true)
DEFINES += -DGETM_BIO
endif

42 43 44 45
# The compilation mode is obtained from $COMPILATION_MODE
# default production - else debug or profiling
ifndef GETM_PARALLEL
parallel=false
46
set par=ser
47 48
else
parallel=true
49
set par=par
50 51
endif

gotm's avatar
gotm committed
52 53 54 55 56 57 58
turbulence=
turbulence=gotm

CPP	= /lib/cpp

# Here you can put defines for the [c|f]pp - some will also be set depending
# on compilation mode - if STATIC is defined be careful.
59 60 61 62
#DEFINES = -DHAIDVOGEL_TEST
ifdef INPUT_DIR
DEFINES += -DINPUT_DIR="'$(INPUT_DIR)/'"
endif
gotm's avatar
gotm committed
63 64 65 66 67 68
#DEFINES += -DSPHERICAL
#DEFINES += -DCURVILINEAR
#DEFINES += -DNO_BOTTFRIC
#DEFINES += -DNO_ADVECT
#DEFINES += -DNO_SLR
#DEFINES += -DNEW_CORI
kbk's avatar
kbk committed
69
#DEFINES += -DCONSTANT_VISCOSITY
gotm's avatar
gotm committed
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
#DEFINES += -DPARABOLIC_VISCOSITY
#DEFINES += -DNEW_METHOD_KBK
#DEFINES += -DMIN_VEL_DEPTH
#DEFINES += -DPRESS_GRAD_Z
#DEFINES += -DITERATE_VERT_ADV
#DEFINES += -DSUBSTR_INI_PRESS
#DEFINES += -DSONG_WRIGHT
#DEFINES += -DUV_TVD
#DEFINES += -ECMWF_FRV
#DEFINES += -HIRLAM_FRV
#DEFINES += -SETTING_LON_LAN
ifdef STATIC
else
endif

# Directory related settings.

# Top of this version of getm.
ifndef GETMDIR
89
GETMDIR  = $(HOME)/getm-src
gotm's avatar
gotm committed
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
endif

ifndef BINDIR
BINDIR	= $(GETMDIR)/bin
endif

ifndef LIBDIR
LIBDIR  = $(GETMDIR)/lib/$(FORTRAN_COMPILER)
endif

ifndef MODDIR
MODDIR	= $(GETMDIR)/modules/$(FORTRAN_COMPILER)
endif

INCDIRS		= -I$(GETMDIR)/include -I$(MODDIR)
LINKDIRS	= -L$(LIBDIR)
EXTRA_LIBS	=

108 109 110 111
ifeq ($(GETM_BIO),true)
EXTRA_LIBS += -lbio$(buildtype)
endif

gotm's avatar
gotm committed
112
ifeq ($(turbulence),gotm)
gotm's avatar
gotm committed
113
ifndef GOTMDIR
114
GOTMDIR = $(HOME)/gotm
gotm's avatar
gotm committed
115 116
endif
GOTMLIBDIR	= $(GOTMDIR)/lib/$(FORTRAN_COMPILER)
gotm's avatar
gotm committed
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
LINKDIRS	+= -L$(GOTMLIBDIR)
EXTRA_LIBS	+= -lturbulence$(buildtype) -lutil$(buildtype) 
INCDIRS		+= -I$(GOTMDIR)/modules/$(FORTRAN_COMPILER)
else
DEFINES		+= -DOLD_TURBULENCE
EXTRA_LIBS	+= -lturb$(buildtype)
endif

# Where does the NetCDF include file and library reside.
ifdef NETCDFINC
INCDIRS		+= -I$(NETCDFINC)
endif
ifdef NETCDFLIBNAME
NETCDFLIB	= $(NETCDFLIBNAME)
else
NETCDFLIB	= -lnetcdf
ifdef NETCDFLIBDIR
134
LINKDIRS	+= -L$(NETCDFLIBDIR)
gotm's avatar
gotm committed
135 136 137 138 139 140
endif
endif
EXTRA_LIBS	+= $(NETCDFLIB)


# Where does the MPI library reside.
141 142
ifeq ($(parallel),true)
DEFINES += -DPARALLEL
gotm's avatar
gotm committed
143 144 145 146 147 148
ifdef MPIINC
INCDIRS		+= -I$(MPIINC)
endif
ifdef MPIMOD
INCDIRS		+= -I$(MPIMOD)
endif
frv-bjb's avatar
frv-bjb committed
149 150 151
ifdef MPILIBFILE
MPILIB		= $(MPILIBFILE)
else
gotm's avatar
gotm committed
152 153 154 155
ifdef MPILIBNAME
MPILIB		= $(MPILIBNAME)
else
MPILIB		= -lmpich
frv-bjb's avatar
frv-bjb committed
156
endif
gotm's avatar
gotm committed
157
ifdef MPILIBDIR
frv-bjb's avatar
frv-bjb committed
158
LDFLAGS		+= -L$(MPILIBDIR)
gotm's avatar
gotm committed
159 160 161 162
LINKDIRS	+= -L$(MPILIBDIR)
endif
endif
EXTRA_LIBS	+= $(MPILIB)
163
endif
gotm's avatar
gotm committed
164

165

gotm's avatar
gotm committed
166 167 168 169 170 171 172 173 174 175 176
DOCDIR		= $(GETMDIR)/doc

# Information about which Fortran compiler to use is 
# obtained from $(FORTRAN_COMPILER) - environment variable.

# Normaly this should not be changed - unless you want something very specific.

# The Fortran compiler is determined from the EV FORTRAN_COMPILER - options 
# sofar NAG(linux), FUJITSU(Linux), DECF90 (OSF1 and likely Linux on alpha),
# SunOS, PGF90 - Portland Group Fortran Compiler (on Intel Linux).

177
include $(GETMDIR)/compilers/compiler.$(FORTRAN_COMPILER)
gotm's avatar
gotm committed
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234

DEFINES += -DREAL_4B=$(REAL_4B)

# Sets options for debug compilation
ifeq ($(compilation),debug)
buildtype = _debug
DEFINES += -DDEBUG $(STATIC)
FLAGS   = $(DEBUG_FLAGS) 
endif

# Sets options for profiling compilation
ifeq ($(compilation),profiling)
buildtype = _prof
DEFINES += -DPROFILING $(STATIC)
FLAGS   = $(PROF_FLAGS) 
endif

# Sets options for production compilation
ifeq ($(compilation),production)
buildtype = _prod
DEFINES += -DPRODUCTION $(STATIC)
FLAGS   = $(PROD_FLAGS) 
endif

# For making the source code documentation.
PROTEX	= protex -b -n -s

# It should not be necessary to change anything below this line - kbk

#
# False targets.
#
.PHONY: dummy

.SUFFIXES:
.SUFFIXES: .F90


CPPFLAGS	= $(DEFINES) $(INCDIRS)
FFLAGS  	= $(DEFINES) $(FLAGS) $(MODULES) $(INCDIRS) $(EXTRAS)
F90FLAGS  	= $(FFLAGS)
LDFLAGS		= $(FFLAGS) $(LINKDIRS)

#
# Special variables which should not be exported
#
unexport SUBDIRS

#
# Common rules
#

ifeq  ($(can_do_F90),true)
%.o: %.F90
	$(FC) $(F90FLAGS) $(EXTRA_FFLAGS) -c $<
else
%.f90: %.F90
235 236
	$(F90_to_f90)
#	$(CPP) $(CPPFLAGS) $< -o $@
gotm's avatar
gotm committed
237 238 239 240 241

%.o: %.f90
	$(FC) $(F90FLAGS) $(EXTRA_FFLAGS) -c $< -o $@
endif