-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
403 lines (380 loc) · 14.6 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
#=================================================================================
#=================================================================================
# Compiler?
#Possible values: (Empty: gfortran)
# gfortran (version: 9.0 linux and osx)
# F90 = mpifort
FC = gfortran
#
# Optimize? Empty: default No optimization; 0: No Optimization; 1 Optimzation
OPT = 1
## OpenMP? Empty: default with OpenMP; 0: No OpenMP; 1 with OpenMP
OMP = 1
## Lapack/blas/mkl? Empty: default with Lapack; 0: without Lapack; 1 with Lapack
LAPACK = 1
## Arpack? Empty: default No Arpack; 0: without Arpack; 1 with Arpack
ARPACK = 0
## force the default integer (without kind) during the compillation.
## default 4: , INT=8 (for kind=8)
INT = 4
## extension for the "sub_system." file. Possible values: f; f90
extf = f
#
## how to get external libraries; "loc" (default): from local zip file, Empty or something else (v0.5): from github
EXTLIB_TYPE = loc
#=================================================================================
#=================================================================================
ifeq ($(FC),)
FFC := gfortran
else
FFC := $(FC)
endif
ifeq ($(OPT),)
OOPT := 1
else
OOPT := $(OPT)
endif
ifeq ($(OMP),)
OOMP := 1
else
OOMP := $(OMP)
endif
ifeq ($(LAPACK),)
LLAPACK := 1
else
LLAPACK := $(LAPACK)
endif
ifeq ($(ARPACK),)
AARPACK := 0
else
AARPACK := $(ARPACK)
endif
#===============================================================================
#
# Operating system, OS? automatic using uname:
OS :=$(shell uname)
#
# about EVRT, path, versions ...:
MAIN_path:= $(shell pwd)
#
#===============================================================================
# We cannot use ARPACK without lapack
ifeq ($(LLAPACK),0)
AARPACK = 0
endif
#===============================================================================
# turn off ARPACK when using pgf90
ifeq ($(F90),pgf90)
AARPACK = 0
endif
#===============================================================================
# setup for mpifort
ifeq ($(FFC),mpifort)
## MPI compiled with: gfortran or ifort
MPICORE := $(shell ompi_info | grep 'Fort compiler:' | awk '{print $3}')
OOMP = 0
ifeq ($(INT),8)
AARPACK = 0 ## temp here, disable ARPACK for 64-bit case
endif
endif
# Extension for the object directory and the library
ext_obj:=_$(FFC)_opt$(OOPT)_omp$(OOMP)_lapack$(LLAPACK)_int$(INT)
ifeq ($(FFC),mpifort)
extlibwi_obj:=_$(FFC)_$(MPICORE)_opt$(OOPT)_omp$(OOMP)_lapack$(LLAPACK)_int$(INT)
else
extlibwi_obj:=$(ext_obj)
endif
OBJ_DIR = obj/obj$(extlibwi_obj)
$(info ***********OBJ_DIR: $(OBJ_DIR))
$(shell [ -d $(OBJ_DIR) ] || mkdir -p $(OBJ_DIR))
MOD_DIR=$(OBJ_DIR)
#
# library name
LIBA=libEVR$(extlibwi_obj).a
#=================================================================================
#
#===============================================================================
# external lib : QDUtilLib AD_dnSVM ConstPhys QuantumModelLib nDindex EVRT_dnSVM FOR_EVRT
ifeq ($(ExtLibDIR),)
ExtLibDIR := $(MAIN_path)/Ext_Lib
endif
$(shell [ -d $(ExtLibDIR) ] || (echo $(ExtLibDIR) "does not exist" ; exit 1))
QD_DIR = $(ExtLibDIR)/QDUtilLib
QDMOD_DIR = $(QD_DIR)/OBJ/obj$(ext_obj)
QDLIBA = $(QD_DIR)/libQD$(ext_obj).a
AD_DIR = $(ExtLibDIR)/AD_dnSVM
ADMOD_DIR = $(AD_DIR)/OBJ/obj$(ext_obj)
ADLIBA = $(AD_DIR)/libAD_dnSVM$(ext_obj).a
CONSTPHYS_DIR = $(ExtLibDIR)/ConstPhys
CONSTPHYSMOD_DIR = $(CONSTPHYS_DIR)/obj/obj$(extlibwi_obj)
CONSTPHYSLIBA = $(CONSTPHYS_DIR)/libPhysConst$(extlibwi_obj).a
QML_DIR = $(ExtLibDIR)/QuantumModelLib
QMLMOD_DIR = $(QML_DIR)/OBJ/obj$(ext_obj)
QMLLIBA = $(QML_DIR)/libQMLib$(ext_obj).a
nDindex_DIR = $(ExtLibDIR)/nDindex
nDindexMOD_DIR = $(nDindex_DIR)/obj/obj$(ext_obj)
nDindexLIBA = $(nDindex_DIR)/libnDindex$(ext_obj).a
EVRTdnSVM_DIR = $(ExtLibDIR)/EVRT_dnSVM
EVRTdnSVMMOD_DIR = $(EVRTdnSVM_DIR)/obj/obj$(ext_obj)
EVRTdnSVMLIBA = $(EVRTdnSVM_DIR)/libEVRT_dnSVM$(ext_obj).a
FOREVRT_DIR = $(ExtLibDIR)/FOR_EVRT
FOREVRTMOD_DIR = $(FOREVRT_DIR)/obj/obj$(extlibwi_obj)
FOREVRTLIBA = $(FOREVRT_DIR)/libFOR_EVRT$(extlibwi_obj).a
TNUMTANA_DIR = $(ExtLibDIR)/Tnum-Tana
TNUMTANAMOD_DIR = $(TNUMTANA_DIR)/obj/obj$(extlibwi_obj)
TNUMTANALIBA = $(TNUMTANA_DIR)/libTnum-Tana$(extlibwi_obj).a
# AARPACK library
ARPACK_DIR = $(ExtLibDIR)/ARPACK_EVR
ifeq ($(AARPACK),1)
ARPACKLIBA = $(ARPACK_DIR)/libarpack$(extlibwi_obj).a
else
ARPACKLIBA =
endif
#EXTLib_pot = /Users/lauvergn/trav/ElVibRot-work/exa_work/exa_C2H3p/TEST_EVRT/Lauvergnat_PA/tests/libpotFull.a
EXTLib_pot =
#
EXTLib = $(EXTLib_pot) $(ARPACKLIBA) \
$(TNUMTANALIBA) $(CONSTPHYSLIBA) \
$(FOREVRTLIBA) $(EVRTdnSVMLIBA) $(nDindexLIBA) \
$(QMLLIBA) $(ADLIBA) $(QDLIBA)
EXTMod = -I$(TNUMTANAMOD_DIR) -I$(CONSTPHYSMOD_DIR) -I$(FOREVRTMOD_DIR) -I$(nDindexMOD_DIR) \
-I$(EVRTdnSVMMOD_DIR) -I$(QMLMOD_DIR) -I$(ADMOD_DIR) -I$(QDMOD_DIR)
#=================================================================================
#
#=================================================================================
# To deal with external compilers.mk file
CompilersDIR = $(MAIN_path)
ifeq ($(CompilersDIR),)
include compilers.mk
else
include $(CompilersDIR)/compilers.mk
endif
#=================================================================================
# cpp preprocessing
EVR_ver:=$(shell awk '/EVR/ {print $$3}' $(MAIN_path)/version-EVR)
ArpackFLAGS := $(FFLAGS)
ArpackFLAGS += -fallow-argument-mismatch
FFLAGS += -D__COMPILE_DATE="\"$(shell date +"%a %e %b %Y - %H:%M:%S")\"" \
-D__COMPILE_HOST="\"$(shell hostname -s)\"" \
-D__EVRTPATH="'$(MAIN_path)'" \
-D__EVR_VER="'$(EVR_ver)'" \
-D__ARPACK="$(AARPACK)"
#
#===============================================================================
#===============================================================================
$(info ************************************************************************)
$(info ***********OS: $(OS))
$(info ***********COMPILER: $(FFC))
$(info ***********OPTIMIZATION: $(OOPT))
$(info ***********COMPILER VERSION: $(FC_VER))
ifeq ($(FFC),mpifort)
$(info ***********COMPILED with: $(MPICORE))
endif
$(info ***********OpenMP: $(OOMP))
$(info ***********Lapack: $(LLAPACK))
$(info ***********Arpack: $(AARPACK))
$(info ***********Arpack lib: $(ARPACKLIBA))
#$(info ***********Arpack flags: $(ArpackFLAGS))
$(info ***********ExtLibDIR: $(ExtLibDIR))
$(info ***********extf [sub_system]:$(extf))
$(info ************************************************************************)
$(info ************************************************************************)
#==========================================
VPATH = APP SRC SRC/sub_Basis SRC/sub_Basis/sub_Basis_SG4 \
SRC/sub_Basis/sub_ReducedDensity SRC/sub_Basis/sub_SymAbelian \
SRC/sub_CRP SRC/sub_GWP SRC/sub_Operator \
SRC/sub_Optimization SRC/sub_Smolyak_test SRC/sub_WP \
SRC/sub_active SRC/sub_analysis SRC/sub_data_initialisation SRC/sub_inactive \
SRC/sub_main SRC/sub_propagation SRC/sub_rotation sub_pot sub_operator_T
#SRCFILES= $(basis_SRCFILES) $(main_SRCFILES) $(EVR-Mod_SRCFILES)
include ./fortranlist.mk
OBJ0=${SRCFILES:.f90=.o}
OBJ0 += QMRPACK_lib.o
OBJ=$(addprefix $(OBJ_DIR)/, $(OBJ0))
#$(info ************ OBJ: $(OBJ))
#
OBJ0_EXT= read_para.o sub_system.o calc_f2_f1Q.o Sub_X_TO_Q_ana.o Calc_Tab_dnQflex.o
OBJ_EXT=$(addprefix $(OBJ_DIR)/, $(OBJ0_EXT))
#$(info ************ OBJ_EXT: $(OBJ_EXT))
#
#===============================================
#============= Several mains ===================
#===============================================
#===============================================
#==============================================
#ElVibRot:
VIBEXE = vib.exe
VIBMAIN = EVR-T
#make all : EVR
.PHONY: all evr EVR libEVR libevr lib
evr EVR all :obj vib $(VIBEXE)
@echo "EVR OK"
lib libEVR libevr: $(LIBA)
@echo $(LIBA) " OK"
#
# vib script
.PHONY: vib
vib:
@echo "make vib script"
./scripts/make_vib.sh $(MAIN_path) $(FFC) $(extf)
chmod a+x vib
#
$(VIBEXE): $(OBJ_DIR)/$(VIBMAIN).o $(OBJ_EXT) $(LIBA) | $(EXTLib)
$(FFC) $(FFLAGS) -o $(VIBEXE) $(OBJ_DIR)/$(VIBMAIN).o $(LIBA) $(OBJ_EXT) $(EXTLib) $(FLIB)
@echo EVR-T
#===============================================
#============= TESTS ===========================
#===============================================
.PHONY: ut UT
ut Ut:
@echo "Unitary test"
@cd UnitTests/HCN-WP_UT ; ./run_tests
@cd UnitTests/HCN_UT ; ./run_tests
@cd UnitTests/HNO3_UT ; ./run_tests
#===============================================
#============= Library: lib_FOR_EVRT.a ========
#===============================================
$(LIBA): $(OBJ) | $(EXTLib)
@echo " LIBA from OBJ files"
ar -cr $(LIBA) $(OBJ)
@echo " done Library: "$(LIBA)
#
#===============================================
#============= make sub_system =================
#============= with the .f or .f90 extention ==
#===============================================
sub_pot/sub_system.$(extf): sub_pot/sub_system_save.$(extf)
@echo "cp sub_system.... from sub_pot"
cp sub_pot/sub_system_save.$(extf) sub_pot/sub_system.$(extf)
#
#===============================================
#============= compilation =====================
#===============================================
$(OBJ_DIR)/%.o: %.f90
@echo " compile: " $<
$(FFC) $(FFLAGS) -o $@ -c $<
$(OBJ_DIR)/%.o: %.f
@echo " compile: " $<
$(FFC) $(FFLAGS) -o $@ -c $<
$(OBJ_DIR)/sub_system.o: sub_pot/sub_system.$(extf)
@echo " compile: " $<
$(FFC) $(FFLAGS) -o $@ -c $<
#===============================================
#================ cleaning =====================
.PHONY: clean cleanall
clean:
rm -f $(OBJ_DIR)/*.o
rm -f *.log
rm -f vib.exe
@echo " done cleaning"
cleanall : clean clean_extlib
rm -fr obj/* build
rm -f lib*.a
rm -f *.exe
rm -f TESTS/res* TESTS/*log
cd UnitTests ; ./clean
cd Examples ; ./clean
cd Working_tests ; ./clean
cd $(ARPACK_DIR) ; make clean
@echo " done all cleaning"
#===============================================
#================ zip and copy the directory ===
ExtLibSAVEDIR := /Users/lauvergn/git/Ext_Lib
BaseName := EVR
.PHONY: zip
zip: cleanall
test -d $(ExtLibSAVEDIR) || (echo $(ExtLibDIR) "does not exist" ; exit 1)
$(ExtLibSAVEDIR)/makezip.sh $(BaseName)
@echo " done zip"
#===============================================
#=== external libraries ========================
# QDUtilLib AD_dnSVM ConstPhys QuantumModelLib nDindex EVRT_dnSVM FOR_EVRT
#===============================================
#
DEV=
.PHONY: getlib
getlib:
cd $(ExtLibDIR) ; ./get_Lib.sh QDUtilLib $(DEV)
cd $(ExtLibDIR) ; ./get_Lib.sh AD_dnSVM $(DEV)
cd $(ExtLibDIR) ; ./get_Lib.sh ConstPhys $(DEV)
cd $(ExtLibDIR) ; ./get_Lib.sh QuantumModelLib $(DEV)
cd $(ExtLibDIR) ; ./get_Lib.sh nDindex $(DEV)
cd $(ExtLibDIR) ; ./get_Lib.sh EVRT_dnSVM $(DEV)
cd $(ExtLibDIR) ; ./get_Lib.sh FOR_EVRT $(DEV)
cd $(ExtLibDIR) ; ./get_Lib.sh Tnum-Tana $(DEV)
#
$(QDLIBA):
cd $(ExtLibDIR) ; ./get_Lib.sh QDUtilLib $(DEV)
cd $(ExtLibDIR)/QDUtilLib ; make lib FC=$(FFC) OPT=$(OOPT) OMP=$(OOMP) LAPACK=$(LLAPACK) INT=$(INT) ExtLibDIR=$(ExtLibDIR) CompilersDIR=$(CompilersDIR)
@test -f $(QDLIBA) || (echo $(QDLIBA) "does not exist" ; exit 1)
@echo " done " $(QDLIBA) " in "$(BaseName)
#
$(ADLIBA):
cd $(ExtLibDIR) ; ./get_Lib.sh AD_dnSVM $(DEV)
cd $(ExtLibDIR)/AD_dnSVM ; make lib FC=$(FFC) OPT=$(OOPT) OMP=$(OOMP) LAPACK=$(LLAPACK) INT=$(INT) ExtLibDIR=$(ExtLibDIR) CompilersDIR=$(CompilersDIR)
@test -f $(ADLIBA) || (echo $(ADLIBA) "does not exist" ; exit 1)
@echo " done " $(ADLIBA) " in "$(BaseName)
#
$(CONSTPHYSLIBA):
cd $(ExtLibDIR) ; ./get_Lib.sh ConstPhys $(DEV)
cd $(ExtLibDIR)/ConstPhys ; make lib FC=$(FFC) OPT=$(OOPT) OMP=$(OOMP) LAPACK=$(LLAPACK) INT=$(INT) ExtLibDIR=$(ExtLibDIR) CompilersDIR=$(CompilersDIR)
@test -f $(CONSTPHYSLIBA) || (echo $(CONSTPHYSLIBA) "does not exist" ; exit 1)
@echo " done " $(CONSTPHYSLIBA) " in "$(BaseName)
#
$(QMLLIBA):
cd $(ExtLibDIR) ; ./get_Lib.sh QuantumModelLib $(DEV)
cd $(ExtLibDIR)/QuantumModelLib ; make lib FC=$(FFC) OPT=$(OOPT) OMP=$(OOMP) LAPACK=$(LLAPACK) INT=$(INT) ExtLibDIR=$(ExtLibDIR) CompilersDIR=$(CompilersDIR)
@test -f $(QMLLIBA) || (echo $(QMLLIBA) "does not exist" ; exit 1)
@echo " done " $(QMLLIBA) " in "$(BaseName)
#
$(nDindexLIBA):
cd $(ExtLibDIR) ; ./get_Lib.sh nDindex $(DEV)
cd $(ExtLibDIR)/nDindex ; make lib FC=$(FFC) OPT=$(OOPT) OMP=$(OOMP) LAPACK=$(LLAPACK) INT=$(INT) ExtLibDIR=$(ExtLibDIR) CompilersDIR=$(CompilersDIR)
@test -f $(nDindexLIBA) || (echo $(nDindexLIBA) "does not exist" ; exit 1)
@echo " done " $(nDindexLIBA) " in "$(BaseName)
#
$(EVRTdnSVMLIBA):
cd $(ExtLibDIR) ; ./get_Lib.sh EVRT_dnSVM $(DEV)
cd $(ExtLibDIR)/EVRT_dnSVM ; make lib FC=$(FFC) OPT=$(OOPT) OMP=$(OOMP) LAPACK=$(LLAPACK) INT=$(INT) ExtLibDIR=$(ExtLibDIR) CompilersDIR=$(CompilersDIR)
@test -f $(EVRTdnSVMLIBA) || (echo $(EVRTdnSVMLIBA) "does not exist" ; exit 1)
@echo " done " $(EVRTdnSVMLIBA) " in "$(BaseName)
#
$(FOREVRTLIBA):
cd $(ExtLibDIR) ; ./get_Lib.sh FOR_EVRT $(DEV)
cd $(ExtLibDIR)/FOR_EVRT ; make lib FC=$(FFC) OPT=$(OOPT) OMP=$(OOMP) LAPACK=$(LLAPACK) INT=$(INT) ExtLibDIR=$(ExtLibDIR) CompilersDIR=$(CompilersDIR)
@test -f $(FOREVRTLIBA) || (echo $(FOREVRTLIBA) "does not exist" ; exit 1)
@echo " done " $(FOREVRTLIBA) " in "$(BaseName)
#
$(TNUMTANALIBA):
cd $(ExtLibDIR) ; ./get_Lib.sh Tnum-Tana $(DEV)
cd $(ExtLibDIR)/Tnum-Tana ; make lib FC=$(FFC) OPT=$(OOPT) OMP=$(OOMP) LAPACK=$(LLAPACK) INT=$(INT) ExtLibDIR=$(ExtLibDIR) CompilersDIR=$(CompilersDIR)
@test -f $(TNUMTANALIBA) || (echo $(TNUMTANALIBA) "does not exist" ; exit 1)
@echo " done " $(TNUMTANALIBA) " in "$(BaseName)#
# ARPACK is needed
$(ARPACKLIBA):
@test -d $(ARPACK_DIR) || (echo $(ARPACK_DIR) "does not exist", exit 1)
cd $(ARPACK_DIR) ; make lib home=$(ARPACK_DIR) FC=$(FFC) LIBEXT=$(ext_obj) FFLAGS="$(ArpackFLAGS)"
#
.PHONY: clean_extlib
clean_extlib:
echo cleanlib, DIR=$(ExtLibDIR)
cd $(ExtLibDIR) ; ./cleanlib
#
#=======================================================================================
.PHONY: fpm
fpm: getlib
##
#=======================================================================================
#=======================================================================================
#add dependence for parallelization
# @echo "OBJ with EXTLib"
$(OBJ) : | $(EXTLib)
#===============================================
#===============================================
#============= make dependencies =============
#===============================================
.PHONY: dep
dependencies.mk fortranlist.mk dep:
./scripts/dependency.sh
#===============================================
include ./dependencies.mk