-
Notifications
You must be signed in to change notification settings - Fork 18
/
Makefile
134 lines (97 loc) · 3.49 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#================================================================
# TRACMASS MAKEFILE
#================================================================
# Project and case definition
PROJECT = Theoretical
CASE = Theoretical
RUNFILE = runtracmass
ARCH =
NETCDFLIBS = none
#================================================================
# Possible architectures:
# tetralith (Swedish HPC with intel)
# Possible netCDF settings:
# automatic (set by nc-config)
# automatic-44 (set by nf-config, for netCDF version >4.4)
# none (no netCDF library)
#================================================================
# ***************************************************************
#================================================================
# Read the project Makefile
PROJMAKE := $(wildcard projects/$(PROJECT)/Makefile.prj)
CASEMAKE := $(wildcard projects/$(PROJECT)/Makefile.prj)
ifneq ($(strip $(CASEMAKE)),)
include projects/$(PROJECT)/Makefile.prj
else
ifneq ($(strip $(PROJMAKE)),)
include projects/$(PROJECT)/Makefile.prj
endif
endif
PROJECT_FLAG = -DPROJECT_NAME=\'$(PROJECT)\'
CASE_FLAG = -DCASE_NAME=\'$(CASE)\'
#================================================================
# NetCDF libraries
ifeq ($(NETCDFLIBS),none)
LIB_DIR =
INC_DIR =
ORM_FLAGS += -Dno_netcdf
else ifeq ($(NETCDFLIBS),automatic)
LIB_DIR = $(shell nc-config --flibs)
INC_DIR = -I$(shell nc-config --includedir)
else ifeq ($(NETCDFLIBS),automatic-44)
LIB_DIR = $(shell nf-config --flibs)
INC_DIR = $(shell nf-config --cflags)
else
NCDF_ROOT = /usr
LIB_DIR = -L$(NCDF_ROOT)/lib -lnetcdf -lnetcdff
INC_DIR = -I$(NCDF_ROOT)/include
endif
# Fortran compiler and flags
ifeq ($(ARCH),tetralith)
FC = ifort
FF = -g -O3 -traceback -pg
else
FC = gfortran
FF = -g -O3 -fbacktrace -fbounds-check -Wall -Wno-maybe-uninitialized -Wno-unused-dummy-argument
endif
# Path to sources
VPATH = src:projects/$(PROJECT)
all: runfile
ifneq ($(strip $(CASE)),)
cp projects/$(PROJECT)/namelist_$(CASE).in namelist.in
else
ifneq ($(strip $(PROJECT)),)
cp projects/$(PROJECT)/namelist_$(PROJECT).in namelist.in
endif
endif
#================================================================
# Object definitions
OBJDIR := _build
objects := $(addprefix $(OBJDIR)/,mod_vars.o mod_subdomain.o mod_getfile.o mod_calendar.o \
mod_tracerf.o mod_tracers.o setup_grid.o kill_zones.o mod_vertvel.o mod_swap.o read_field.o mod_clock.o \
mod_write.o mod_error.o mod_seed.o mod_diffusion.o mod_divergence.o mod_stream.o \
mod_pos_tstep.o mod_pos_tanalytical.o mod_init.o mod_print.o mod_loop.o mod_postprocess.o TRACMASS.o)
$(OBJDIR)/%.o : %.F90
$(FC) $(FF) -c $(ORM_FLAGS) $(PROJECT_FLAG) $(CASE_FLAG) $(INC_DIR) $(LIB_DIR) $< -o $@
$(objects) : | $(OBJDIR)
$(OBJDIR):
mkdir -p $(OBJDIR)
#================================================================
runfile : $(objects)
$(FC) $(FF) $(ORM_FLAGS) -o $(RUNFILE) $(objects) $(INC_DIR) $(LIB_DIR)
test :
sed '42s~.*~NCDIR="$(LIB_DIR) $(INC_DIR)" ~' src/_funit/runtest.sh > runtest.sh
chmod +x runtest.sh
.PHONY : clean
clean:
-rm -rf *.o *.mod *.out *.dSYM *.csv fort.* *.x *.in
-rm -rf _build
test -s runtest.sh && rm runtest.sh || true
test -s $(RUNFILE) && rm $(RUNFILE) || true
.PHONY : help
help :
@echo
@echo "make : Generate TRACMASS runfile '$(RUNFILE).x'."
@echo "make test : Generate test-suite runscripts 'runtest.sh'."
@echo "make clean : Remove auto-generated files."
@echo