-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
154 lines (109 loc) · 3.79 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
INSTALL_DIR = /usr/local/bin
GIT_VERSION := $(shell git describe --abbrev=7 --dirty --always --tags)
#FC = /opt/intel/fc/10.0.026/bin/ifort -vec-report0
#FC = /opt/intel/bin/ifort
#FC = /opt/pgi/linux86-64/8.0-4/bin/pgf90 # c101
FC = /usr/local/bin/mpif90
#FC = gfortran
# Following are needed for building parallel version
# Comment out if compiling with mpif90
# or if making serial version.
# MPICH
#LIBS = -lmpich -lpthread -lmpl
#LIBS = -L/usr/local/lib -lmpich -lpthread -lmpl
# Open MPI
#LIBS = -L/usr/lib64/mpi/gcc/openmpi/lib64 -lopen-rte -lmpi
# when using Open MPI
#INCLUDE = /usr/lib64/mpi/gcc/openmpi/include
# when using MPICH
INCLUDE = /usr/local/lib
INCLUDE = /usr/local/include
# Compiler flags
DBUGFLAGS = -g -traceback -check # debug version
#FCFLAGS = -traceback -O3 -I$(INCLUDE) # release version ifort
FCFLAGS = -O3 -I$(INCLUDE) # release version gfortran
# note use flag -fpe:0 to handle floating point exceptions
# Linker flags (gfortran on OSX)
#LDFLAGS = -static-libgfortran -static-libgcc
SERIALFN = mendel_serial
# executable name
TARGET = mendel
MODULES = sort.o random_pkg.o inputs.o genome.o profile.o polygenic.o \
init.o selection.o
OTHERS = $(MODULES) mutation.o mating.o fileio.o
POBJECTS = $(OTHERS) diagnostics.o mendel.o migration.o
SOBJECTS = $(OTHERS) $(SERIALFN).o init_serial.o
TOBJECTS = $(OTHERS) diagnostics.o test.o migration.o
##########################################
# build rules
##########################################
all: release
debug: FCFLAGS = $(DBUGFLAGS)
debug: $(POBJECTS)
$(FC) $(DBUGFLAGS) $(LDFLAGS) -o $(TARGET) $(POBJECTS) $(LIBS)
test: $(TOBJECTS)
$(FC) $(FCFLAGS) $(LDFLAGS) -o test $(TOBJECTS) $(LIBS)
pre-build:
sed -i.bak 's/VERSION.*VERSION/VERSION >>> $(GIT_VERSION) <<< VERSION/' init.f90
release: pre-build $(POBJECTS)
$(FC) $(FCFLAGS) $(LDFLAGS) -o $(TARGET) $(POBJECTS) $(LIBS)
# in order to build the serial version, first
# run "make preserial", then "make serial"
parallel: release
serial: $(SOBJECTS)
$(FC) $(FCFLAGS) $(LDFLAGS) -o $(SERIALFN) $(SOBJECTS) $(LIBS)
install:
install $(TARGET) $(INSTALL_DIR)
uninstall:
echo "removing file $(INSTALL_DIR)/$(TARGET)"
rm $(INSTALL_DIR)/$(TARGET)
preserial:
cp mendel.f90 $(SERIALFN).f90
cat diagnostics.f90 >> $(SERIALFN).f90
cp init.f90 init_serial.f90
sed -i.bak '/START_MPI/,/END_MPI/d' init_serial.f90
sed -i.bak '/START_MPI/,/END_MPI/d' $(SERIALFN).f90
cln:
\rm -f mendel.o migration.o mendel
clean:
\rm -f *.o *.mod $(TARGET) test0* *_serial.f90 *.f90-e a.out\
success mendel_serial
###########################################
# dependencies
###########################################
sort.o: sort.f90
$(FC) $(FCFLAGS) -c sort.f90
random_pkg.o: random_pkg.f90
$(FC) $(FCFLAGS) -c random_pkg.f90
mendel.o: mendel.f90 common.h
$(FC) $(FCFLAGS) -c mendel.f90
init.o: init.f90 common.h
$(FC) $(FCFLAGS) -c init.f90
init_serial.o: init_serial.f90 common.h
$(FC) $(FCFLAGS) -c init_serial.f90
diagnostics.o: diagnostics.f90 common.h
$(FC) $(FCFLAGS) -c diagnostics.f90
fileio.o: fileio.f90 common.h
$(FC) $(FCFLAGS) -c fileio.f90
selection.o: selection.f90 common.h
$(FC) $(FCFLAGS) -c selection.f90
mating.o: mating.f90
$(FC) $(FCFLAGS) -c mating.f90
mutation.o: mutation.f90
$(FC) $(FCFLAGS) -c mutation.f90
migration.o: migration.f90 common.h
$(FC) $(FCFLAGS) -c migration.f90
mendel_serial.o: mendel_serial.f90 common.h
$(FC) $(FCFLAGS) -c mendel_serial.f90
migration_serial.o: migration_serial.f90 common.h
$(FC) $(FCFLAGS) -c migration_serial.f90
polygenic.o: polygenic.f90
$(FC) $(FCFLAGS) -c polygenic.f90
test.o: test.f90
$(FC) $(FCFLAGS) -c test.f90
profile.o: profile.f90
$(FC) $(FCFLAGS) -c profile.f90
inputs.o: inputs.f90
$(FC) $(FCFLAGS) -c inputs.f90
genome.o: genome.f90
$(FC) $(FCFLAGS) -c genome.f90