Makefile 8.1 KB
Newer Older
1
SHELL=/bin/sh
vtenishe's avatar
vtenishe committed
2

3
DEFAULT_TARGET : amps
vtenishe's avatar
vtenishe committed
4

5
6
7
# These definitions may be overwritten by Makefile.def
SOURCES=src
WSD=srcTemp
8
SPICE=nospice
9
OPENMP=off
10

11
#extra compiler options can be defined in Makefile.local
12
EXTRACOMPILEROPTIONS= 
13

14
#extra linker options specific for fortran and c++ linker
15
16
EXTRALINKEROPTIONS_F=
EXTRALINKEROPTIONS_CPP=
17

18
19
#Compiling with the CCMC's Kameleon
KAMELEON=nokameleon
judithsz's avatar
judithsz committed
20
BOOST=noboost
21
BATL=nobatl
22
TESTMODE=off
23
INTERFACE=off
24

25
26
27
#Link the SWMF' shared library
LINK_SWMF_SHARED_LIB=off

28
29
30
#use AVX instructions in the calculations 
AVXMODE=off

vtenishe's avatar
vtenishe committed
31
include Makefile.conf
32
include Makefile.def
vtenishe's avatar
vtenishe committed
33

34

35
#include the local $(MAKE)file (defined the AMPS' compiling variables)  
vtenishe's avatar
vtenishe committed
36
37
include Makefile.local

38
#the default value of the c++ compiler flags
39
SEARCH_C=-DMPI_ON -LANG:std -I${CWD}/${WSD}/pic -I${CWD}/${WSD}/main -I${CWD}/srcInterface -I${CWD}/${WSD}/meshAMR -I${CWD}/${WSD}/interface -I${CWD}/${WSD}/general -I${CWD}/${WSD}/models/electron_impact -I${CWD}/${WSD}/models/sputtering -I${CWD}/${WSD}/models/dust -I${CWD}/${WSD}/models/charge_exchange -I${CWD}/${WSD}/models/photolytic_reactions -I${CWD}/${WSD}/species -I${CWD}/${WSD}/models/exosphere -I${CWD}/${WSD}/models/surface -I${SPICE}/include -I${BOOST}/include -I${KAMELEON}/src -I${CWD}/utility/PostProcess -I${SHAREDIR}  -I${CWD}
40

41
42
SEARCH_C+=${EXTRACOMPILEROPTIONS}

43
SEARCH_C_GENERAL=-LANG:std ${EXTRACOMPILEROPTIONS} 
44

45
46
#define the "compile kameleon' flag only when KAMELEON is used (to exclude including of the KAMELEON headers on machimes where KAMELEON is not installed) 
ifneq ($(KAMELEON),nokameleon)   
vtenishe's avatar
vtenishe committed
47
	SEARCH_C+=-D _PIC_COMPILE__KAMELEON_ 
48
49
else
	SEARCH_C+=-D _NO_KAMELEON_CALLS_
50
endif
51

52
53
54
55
56
#define _NO_SPICE_CALLS_ when SPICE library is not intended to be linked
ifeq ($(SPICE),nospice)
	SEARCH_C+=-D _NO_SPICE_CALLS_
endif

Tenishev's avatar
Tenishev committed
57
58
59
ifeq ($(SPICE),)
	SEARCH_C+=-D _NO_SPICE_CALLS_
endif
60

61
#the additional argument string for the fortran compiler
62
63
SEARCH_F=
#-fdefault-real-8 
64

65
66
# These definitions are inherited from Makefile.def and Makefile.conf
CC=${COMPILE.mpicxx}
67
68
AMPSLINKER=${CC}

69
70
71
72
73
#set linker when nvcc is used to compile the code
ifeq ($(COMPILE.mpicxx),nvcc)
	AMPSLINKER=mpicxx
endif

74
75
CWD=${MYDIR}

76
AMPSLINKLIB= 
77

78
EXTRALINKEROPTIONS=
dborovik's avatar
dborovik committed
79

80
81
82
83
84
ifeq ($(LINK_SWMF_SHARED_LIB),on)
	AMPSLINKER=${LINK.f90}
	AMPSLINKLIB+=./share/lib/libSHARE.a
endif

85
#include AVX instruction flag when compile with Intel or GCC compilers
86
ifeq ($(AVXMODE),on)
87
88
89
90
91
92

#NVCC: pass the AVX flags to the host compiler 
ifeq ($(COMPILE.mpicxx),nvcc)
	SEARCH_C+=-Xcompiler \"
endif

93
#Intel compiler
94
ifeq ($(COMPILE.c),icc)
95
ifeq ($(AVXTYPE),512)
96
        SEARCH_C+= -xCore-AVX512 -march=skylake-avx512 
97
98
99
100
else
        SEARCH_C+= -march=core-avx2
endif

101
#GCC compiler
102
else ifeq ($(COMPILE.c),gcc)
103
	SEARCH_C+= -mavx2 -mfma -march=native 
104
ifeq ($(AVXTYPE),512)
105
	SEARCH_C+= -march=skylake-avx512  
106
endif
107

108
109
110
#PGI compiler
else ifeq ($(COMPILE.c),pgcc)
	SEARCH_C+= -mavx2 -mfma
111
endif
112
113
114
115
116

#NVCC: pass the AVX flags to the host compiler
ifeq ($(COMPILE.mpicxx),nvcc)
	SEARCH_C+=\"
endif
117
endif
118

119
#include BATL-related libraries for linking
120
121
ifneq ($(BATL),nobatl)	
	AMPSLINKLIB+=${BATL}/lib/libREADAMR.a
122
	AMPSLINKLIB+=${BATL}/lib/libSHARE.a
123
	AMPSLINKER=${LINK.f90}
124

vtenishe's avatar
vtenishe committed
125
ifeq ($(COMPILE.f90),gfortran)  
126
	SEARCH_F+= -J${BATL}/share/include 
vtenishe's avatar
vtenishe committed
127
else ifeq ($(COMPILE.f90),mpif90)
128
	SEARCH_F+= -I${BATL}/share/include
129
130
else ifeq ($(COMPILE.f90),pgf90)
	SEARCH_F+= -module ${BATL}/share/include
vtenishe's avatar
vtenishe committed
131
else ifeq  ($(COMPILE.f90),ifort)
132
	SEARCH_F+= -module ${BATL}/share/include
133
else ifeq  ($(COMPILE.f90),nagfor)
134
	SEARCH_F+= -I${BATL}/share/include
135
136
endif

137
endif
138

139
140
141
142
143
# include interface with external FORTRAN subroutines
ifeq ($(INTERFACE),on)
	AMPSLINKER=${LINK.f90}
endif 

144
145
#when OpenMP is used add the appropriate compiler flag and library
ifeq ($(OPENMP),on)
146
147
148
149
150
151

#NVCC: pass the OpenMP flags to the host compiler
ifeq ($(COMPILE.mpicxx),nvcc)
	SEARCH_C+=-Xcompiler \"
endif

152
153
154
155
156
ifeq ($(COMPILE.c),pgcc)
	SEARCH_C+=-mp
	SEARCH_C_GENERAL+=-mp
	AMPSLINKLIB+=-mp
else
vtenishe's avatar
vtenishe committed
157
158
159
	SEARCH_C+=-fopenmp
	SEARCH_C_GENERAL+=-fopenmp
	AMPSLINKLIB+=-fopenmp
160
endif
161
162
163
164
165

#NVCC: pass the OpenMP flags to the host compiler
ifeq ($(COMPILE.mpicxx),nvcc)
	SEARCH_C+=\"
endif
166
endif
167

168

169
170
171
172
# when linking mixed C/C++ and FORTRAN code mpif90 is used for linking
# certain compilers (Intel, PGI) require an additional flag
# if main() subroutine is written in C/C++

173
174
ifeq (${AMPSLINKER},${LINK.f90})

175
ifeq ($(COMPILE.f90),${LINK.f90})
176
	AMPSLINKER=mpif90  
177
178
endif

179
ifeq ($(COMPILE.f90),pgf90)
180
	AMPSLINKLIB+= -Mnomain 
181
else ifeq  ($(COMPILE.f90),ifort)
182
	AMPSLINKLIB+= -nofor-main  
183
else ifeq  ($(COMPILE.f90),gfortran)
184
	AMPSLINKLIB+= 
185
endif
186
endif
187

188
189
190
191
192
193
194
#add liker options that are apecific cor c++ cortran linkers 
ifeq (${AMPSLINKER},mpif90) 
  AMPSLINKLIB+=${EXTRALINKEROPTIONS_F} 
else 
  AMPSLINKLIB+=${EXTRALINKEROPTIONS_CPP} 
endif 

195

196
#add KAMELEON to the list of the linked libraries
197
ifneq ($(KAMELEON),nokameleon)
198
	AMPSLINKLIB+=/Users/ccmc/miniconda2/envs/kameleon/lib/ccmc/libccmc.dylib  
199
200
endif

201
#add SPICE to the list of the linked libraries 
202
203
204
ifneq ($(SPICE),nospice)
	AMPSLINKLIB+=${SPICE}/lib/cspice.a
endif
205

206
#set the nightly test flag
vtenishe's avatar
vtenishe committed
207
ifeq ($(TESTMODE),on)  
208
	SEARCH_C+=-D _PIC_NIGHTLY_TEST_MODE_=_PIC_MODE_ON_
209
210
endif

211
install:
212
213
	rm -f output
	ln -s data/output output
214
215
216
	@echo "AMPS installed"


vtenishe's avatar
vtenishe committed
217
218
219
distclean:
	./Config.pl -uninstall

220
allclean: clean
221
222
	rm -rf main srcTemp *.input* amps Makefile.local Makefile.test \
		.amps.conf .general.conf
223
	rm -f output
224
	rm -f AMPS.pdf
vtenishe's avatar
vtenishe committed
225
226

rundir:
227
228
229
230
	mkdir -p ${RUNDIR}/${COMPONENT}
	cd ${RUNDIR}/${COMPONENT}; mkdir restartIN restartOUT plots; \
		ln -s ${BINDIR}/PostIDL.exe .; \
		cp    ${SCRIPTDIR}/pIDL .;
231

vtenishe's avatar
vtenishe committed
232
233
EXE=amps

234
235
LIB_AMPS = ${WSD}/libAMPS.a

236
237
238
PDF:
	cd doc; make PDF

239
clean:
240
241
	rm -rf ${LIB_AMPS} ${WSD}
	@(if [ -d srcInterface ]; then cd srcInterface; $(MAKE) clean; fi);
242
	cd doc; $(MAKE) clean
vtenishe's avatar
vtenishe committed
243
244
245
246
247
248

tar:
	cd ../pic-tower/sources/general; rm -f *.o *.a
	cd ../pic-tower/sources/dsmc; rm -f *.o *.a
	tar -cvf sources.tar sources

249
${WSD}:
250
	./ampsConfig.pl -input ${InputFileAMPS} -no-compile 
251
	./utility/CheckMacro.pl ${WSD} -in-place
252

253
254
LIB: 
	@(if [ -d ${WSD} ]; then rm -rf ${WSD}; fi)
255
	$(MAKE) ${WSD}
256
	$(MAKE) LIB_after_build
257
	cd srcInterface; $(MAKE) LIB SEARCH_C="${SEARCH_C}"
258

259
LIB_after_build: 
260
ifeq ($(INTERFACE),on)
261
	cd ${WSD}/interface; $(MAKE) SEARCH_C="${SEARCH_C}" SEARCH="${SEARCH_F}" 
262
endif
263
	cd ${WSD}/general;                     $(MAKE) SEARCH_C="${SEARCH_C}" 
264
265
266
267
268
269
270
271
272
	cd ${WSD}/meshAMR;                     $(MAKE) SEARCH_C="${SEARCH_C}" 
	cd ${WSD}/pic;                         $(MAKE) SEARCH_C="${SEARCH_C}" SEARCH="${SEARCH_F}" 
	cd ${WSD}/species;                     $(MAKE) SEARCH_C="${SEARCH_C}"
	cd ${WSD}/models/exosphere;            $(MAKE) SEARCH_C="${SEARCH_C}"
	cd ${WSD}/models/surface;              $(MAKE) SEARCH_C="${SEARCH_C}"
	cd ${WSD}/models/electron_impact;      $(MAKE) SEARCH_C="${SEARCH_C}"
	cd ${WSD}/models/sputtering;           $(MAKE) SEARCH_C="${SEARCH_C}"
	cd ${WSD}/models/dust;                 $(MAKE) SEARCH_C="${SEARCH_C}"
	cd ${WSD}/models/charge_exchange;      $(MAKE) SEARCH_C="${SEARCH_C}"
273
	cd ${WSD}/models/photolytic_reactions; $(MAKE) SEARCH_C="${SEARCH_C}" 
274
	cd ${WSD}/main; $(MAKE) SEARCH_C="${SEARCH_C}"
275
	cp -f ${WSD}/main/mainlib.a ${WSD}/libAMPS.a
276

277
ifeq ($(SPICE),nospice)
278
	cd ${WSD}; ${AR} libAMPS.a general/*.o meshAMR/*.o pic/*.o species/*.o models/exosphere/*.o models/surface/*.o models/electron_impact/*.o models/sputtering/*.o models/dust/*.o models/charge_exchange/*.o models/photolytic_reactions/*.o
279
280
281
282
283
else
	rm -rf ${WSD}/tmpSPICE
	mkdir ${WSD}/tmpSPICE
	cp ${SPICE}/lib/cspice.a ${WSD}/tmpSPICE
	cd ${WSD}/tmpSPICE; ar -x cspice.a
284
	cd ${WSD}; ${AR} libAMPS.a general/*.o meshAMR/*.o pic/*.o species/*.o models/exosphere/*.o models/surface/*.o models/electron_impact/*.o models/sputtering/*.o models/dust/*.o models/charge_exchange/*.o models/photolytic_reactions/*.o tmpSPICE/*.o
285
endif
286

287
288
289
290
ifeq ($(INTERFACE),on)
	cd ${WSD}; ${AR} libAMPS.a interface/*.o
endif

291
292
.PHONY: amps
amps:
293
	@(if [ -d ${WSD} ]; then rm -rf ${WSD}; fi)
294
	$(MAKE) $(WSD)
295
296
	$(MAKE) amps_after_build

297
amps_after_build: LIB_after_build 
vtenishe's avatar
vtenishe committed
298
	@rm -f amps
299
300
	cd ${WSD}/main; $(MAKE) amps SEARCH_C="${SEARCH_C}"
	$(MAKE) amps_link
301

302
303
amps_link:
	${AMPSLINKER} -o amps srcTemp/main/main.a srcTemp/libAMPS.a \
dborovik's avatar
dborovik committed
304
		${CPPLIB} ${AMPSLINKLIB} ${EXTRALINKEROPTIONS}
vtenishe's avatar
vtenishe committed
305

306
.PHONY: test
vtenishe's avatar
vtenishe committed
307
test:
308
	echo "Use make test_all to run the AMPS tests"