-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathMakefile
143 lines (117 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
135
136
137
138
139
140
141
142
143
#CAMB Makefile
#Set FISHER=Y to compile bispectrum fisher matrix code
FISHER=
#Set FORUTILSPATH to the path where the libforutils.a file can be found.
#The OUTPUT_DIR will be appended.
ifneq "$(wildcard ../forutils)" ""
FORUTILSPATH ?= $(shell pwd)/../forutils
else
ifneq "$(wildcard ../../forutils)" ""
FORUTILSPATH ?= $(shell pwd)/../../forutils
else
ifneq "$(wildcard ../../../forutils)" ""
FORUTILSPATH ?= $(shell pwd)/../../../forutils
endif
endif
endif
ifeq ($(FORUTILSPATH),)
$(error Use git clone --recurse-submodules, install forutils from https://github.com/cmbant/forutils, or set FORUTILSPATH variable)
endif
#native optimization does not work on Mac gfortran or heterogeneous clusters
CLUSTER_SAFE ?= 0
ifneq ($(CLUSTER_SAFE), 0)
NONNATIVE = 1
endif
#Will detect ifort/gfortran or edit for your compiler
ifneq ($(COMPILER),gfortran)
ifortErr = $(shell which ifort >/dev/null 2>&1; echo $$?)
else
ifortErr = 1
endif
ifeq "$(ifortErr)" "0"
#Intel compiler
F90C = ifort
ifortVer_major = $(shell ifort -v 2>&1 | cut -d " " -f 3 | cut -d. -f 1)
compiler_ver = $(shell ifort -v 2>&1)
#other tests will be done by forutils
ifeq ($(shell test $(ifortVer_major) -lt 18; echo $$?),0)
$(warning ** ifort version lower than 18.0.1 may not work with the Python wrapper **)
endif
ifeq ($(shell test $(ifortVer_major) -gt 15; echo $$?),0)
COMMON_FFLAGS = -fpp -qopenmp
else
COMMON_FFLAGS = -fpp -openmp
endif
COMMON_FFLAGS += -gen-dep=$$*.d
FFLAGS = -fp-model precise -W0 -WB $(COMMON_FFLAGS)
DEBUGFLAGS = -g -check all -check noarg_temp_created -traceback -fpe0 $(COMMON_FFLAGS)
ifeq ($(shell uname -s),Darwin)
SFFLAGS = -dynamiclib #-fpic
else
SFFLAGS = -shared -fpic
endif
ifdef NONNATIVE
FFLAGS+=-O3 -ipo -axCORE-AVX2
else
FFLAGS+=-fast
endif
## This is flag is passed to the Fortran compiler allowing it to link C++ if required (not usually):
F90CRLINK = -cxxlib
ifneq "$(ifortVer_major)" "14"
F90CRLINK += -qopt-report=0 -qopt-report-phase=vec
else
F90CRLINK += -vec_report0
endif
MODOUT = -module $(OUTPUT_DIR)
AR = xiar
SMODOUT = -module $(DLL_DIR)
ifneq ($(FISHER),)
FFLAGS += -mkl
endif
else
gfortErr = $(shell which gfortran >/dev/null; echo $$?)
ifeq "$(gfortErr)" "0"
#Gfortran compiler (version 6+):
compiler_ver = $(shell gfortran -dumpversion 2>&1)
COMPILER = gfortran
F90C = gfortran
COMMON_FFLAGS = -MMD -cpp -ffree-line-length-none -fmax-errors=4 -fopenmp
# Using -ffast-math causes differences between Debug and Release configurations.
FFLAGS = -O3 $(COMMON_FFLAGS)
DEBUGFLAGS = -g -fbacktrace -ffpe-trap=invalid,overflow,zero -fbounds-check $(COMMON_FFLAGS)
ifeq ($(shell uname -s),Darwin)
SFFLAGS = -dynamiclib #-fpic
ifneq ($(shell echo $(compiler_ver) | awk '{print ($$1 >= 14.0)}'),0)
SFFLAGS += -static-libgfortran -static-libgcc -static-libquadmath
endif
else
SFFLAGS = -shared -fpic
endif
MODOUT = -J$(OUTPUT_DIR)
SMODOUT = -J$(DLL_DIR)
ifneq ($(FISHER),)
F90CRLINK += -lblas -llapack
endif
ifeq ($(shell uname -s),Darwin)
NONNATIVE = 1
endif
ifndef NONNATIVE
#Note this seems to make code slightly slower in some cases, use CLUSTER_SAFE=1 to test without
FFLAGS+=-march=native
endif
endif
endif
IFLAG = -I
#Settings for building camb_fits
#Location of FITSIO and name of library
FITSDIR ?= /usr/local/lib
FITSLIB = cfitsio
#Location of HEALPIX for building camb_fits
HEALPIXDIR ?= /usr/local/healpix
ifneq ($(FISHER),)
# Its dependencies are all meet by the libutils.a which always added.
FFLAGS += -DFISHER
endif
DEBUGFLAGS ?= $(FFLAGS)
Debug: FFLAGS = $(DEBUGFLAGS)
include ./Makefile_main