-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
146 lines (114 loc) · 3.17 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
#executable name
exec = main
main = main.o
#test if ifort is present
wres = $(shell which flang > /dev/null; echo $$?)
wres2 = $(shell which ifort > /dev/null; echo $$?)
ifeq "$(wres)" "0"
fc = flang
switchOPT = -O3 -march=znver2 -mavx -flto -funroll-loops -fremap-arrays
else ifeq "$(wres2)" "0"
fc = ifort
switchOPT = -O3 -ipo -ip -unroll -xHost -g
switchOPT = -O3 -ipo -ipo-jobs10 -unroll -axAVX -xSSE4.1 -g -traceback
switchDBG = -O0 -check all -warn all
switchDBG += -fpe0 -u -traceback -warn nounused -g
switchDBG += -init=snan,zero,arrays
switchOMP = $(switchOPT) -qopenmp
nowarn = -nowarn
else
fc = gfortran
switchOPT = -ffree-line-length-none -O3 -g -fallow-argument-mismatch
switchDBG = -fbacktrace -g
switchDBG += -ffpe-trap=zero,overflow,invalid
switchDBG += -fbounds-check -ffree-line-length-none -O3
nowarn = -w
endif
#NPROCS = $(shell sysctl hw.ncpu | grep -o '[0-9]\+')
NPROCS = 4
MAKEFLAGS = -j$(NPROCS)
#default switch
switch = $(switchOPT)
#objects
objs = opkda2.o
objs += opkda1.o
objs += opkdmain.o
objs += kemimo_commons.o
objs += kemimo_sticking.o
objs += kemimo_reactionarray.o
objs += kemimo_gas_rates.o
objs += kemimo_dust_rates.o
objs += kemimo_rates.o
objs += kemimo_flux.o
objs += kemimo_ode.o
objs += kemimo.o
#lib = -I/usr/include/python2.7 -lpython2.7
#default target
all: main
main: $(objs) $(main)
$(fc) $(objs) $(main) -o $(exec) $(switch) $(lib)
########################
## For parallel execution, explicit dependencies:
opkda2.o: opkda2.f
$(fc) $(switch) $(nowarn) -c $< -o $@
objs2 = opkda2.o
opkda1.o: opkda1.f $(opjs2)
$(fc) $(switch) $(nowarn) -c $< -o $@
objs2 += opkda1.o
opkdmain.o: opkdmain.f $(objs2)
$(fc) $(switch) $(nowarn) -c $< -o $@
objs2 += opkdmain.o
kemimo_commons.o: kemimo_commons.f90 $(objs2)
$(fc) $(switch) -c $< -o $@
objs2 += kemimo_commons.o
kemimo_sticking.o: kemimo_sticking.f90 $(objs2)
$(fc) $(switch) -c $< -o $@
objs2 += kemimo_sticking.o
kemimo_reactionarray.o: kemimo_reactionarray.f90 $(objs2)
$(fc) $(switch) -c $< -o $@
objs2 += kemimo_reactionarray.o
kemimo_gas_rates.o: kemimo_gas_rates.f90 $(objs2)
$(fc) $(switch) -c $< -o $@
kemimo_dust_rates.o: kemimo_dust_rates.f90 $(objs2)
$(fc) $(switch) -c $< -o $@
objs2 += kemimo_gas_rates.o
objs2 += kemimo_dust_rates.o
kemimo_rates.o: kemimo_rates.f90 $(objs2)
$(fc) $(switch) -c $< -o $@
objs2 += kemimo_rates.o
kemimo_flux.o: kemimo_flux.f90 $(objs2)
$(fc) $(switch) -c $< -o $@
objs2 += kemimo_flux.o
kemimo_ode.o: kemimo_ode.f90 $(objs2)
$(fc) $(switch) -c $< -o $@
objs2 += kemimo_ode.o
kemimo.o: kemimo.f90 $(objs2)
$(fc) $(switch) -c $< -o $@
main.o: main.f90 $(objs)
$(fc) $(switch) -c $< -o $@
########################
#full debug target
debug: switch = $(switchDBG)
debug: all
#openmp target
omp: switch = $(switchOMP)
omp: all
#openmp target alias
openmp: omp
#shared library target
sharedlib: switch += -fPIC
sharedlib: $(objs)
$(fc) $(objs) -o libkemimo.so $(switch) -shared $(lib)
#clean target
clean:
rm -f *.o *.mod *__genmod.f90 *~ $(exec) libkemimo.so
.PHONY: clean
#rule for f90
%.o:%.f90
$(fc) $(switch) -c $^ -o $@
#rule for f
%.o:%.f
$(fc) $(switch) $(nowarn) -c $^ -o $@
#rule for c
%.o:%.c
$(cc) $(cswitch) $(lib) -c $^ -o $@