-
Notifications
You must be signed in to change notification settings - Fork 3
/
MetaMakefile
220 lines (163 loc) · 7.76 KB
/
MetaMakefile
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
##################
# This is a makefile to build VASP using its own makefiles but overriding values.
#
# VASP can't build in parallel due to some unspecified dependencies.
MAKE=make -j 1
CC =icc
F90 =ifort
MPIF90=mpif90
# Older versions of MKL require 'em64t' here - check $MKLROOT/lib/
INTEL_ARCH=intel64
SERIAL_LAPACK_FLAGS=-L$(MKLROOT)/lib/$(INTEL_ARCH) -mkl
SERIAL_BLAS_FLAGS=
SCALAPACK_LD_FLAGS=$(MKLROOT)/lib/$(INTEL_ARCH)/libmkl_scalapack_lp64.a $(MKLROOT)/lib/$(INTEL_ARCH)/libmkl_blacs_lp64.a
SCALAPACK_CPP_FLAGS=-DscaLAPACK
# The scalapack build variable exists but isn't included in any line by default, so we ram
# it in with the LAPACK ones.
MPI_LAPACK_FLAGS=-Wl,--start-group \
$(MKLROOT)/lib/$(INTEL_ARCH)/libmkl_intel_lp64.a \
$(MKLROOT)/lib/$(INTEL_ARCH)/libmkl_sequential.a \
$(MKLROOT)/lib/$(INTEL_ARCH)/libmkl_core.a \
$(SCALAPACK_LD_FLAGS) \
-Wl,--end-group \
-lm
MPI_BLAS_FLAGS=
# Different people seem to set different variables for these (or maybe it varies by version?).
# In any case, you can set them here.
USE_FFTW=TRUE
FFTW_LIB_DIR=$(FFTWDIR)
FFTW_INC_DIR=$(FFTWINCLUDE)
ifeq ($(USE_FFTW),TRUE)
SERIAL_FFT_OBJS=fftw3d.o fft3dlib.o $(FFTW_LIB_DIR)/libfftw3.a
MPI_FFT_OBJS =fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o $(FFTW_LIB_DIR)/libfftw3.a
F90 += -I$(FFTW_INC_DIR)
MPIF90 += -I$(FFTW_INC_DIR)
$(info Using FFTW from $(FFTW_LIB_DIR).)
else
SERIAL_FFT_OBJS=fft3dfurth.o fft3dlib.o
MPI_FFT_OBJS =fftmpi.o fftmpi_map.o fft3dfurth.o fft3dlib.o
$(info Using FFT library included in VASP.)
endif
# VASP doesn't really use a prefix for anything, so it's
# fine to build and then move later if you like.
#PREFIX=/opt/vasp-$(VASP_VER)
LIB_MAKEFILE =makefile.linux_ifc_P4
NONLIB_MAKEFILE=makefile.linux_ifc_P4
# The vasp.5.lib makefile actually seems to work except for needing FC replaced. (It comes set to 'ifc', as if that were still a thing.)
LIB_MAKEVARS=FC=$(F90)
#######################################################################################
# Probably shouldn't need to modify anything below this line.
#
## Capture version based on files in working directory
VASP_FILES_PRESENT=$(wildcard vasp.5.*.tar.gz)
VASP_VERSIONS_PRESENT=$(filter-out vasp.%.lib.tar.gz, $(VASP_FILES_PRESENT))
ifeq ($(words $(VASP_VERSIONS_PRESENT)), 0)
$(error "No VASP .tar.gz found in current directory -- please supply a vasp.x.x.x.tar.gz file.")
endif
VASP_SOURCE_FILE=$(lastword $(VASP_VERSIONS_PRESENT) )
EXTRACTED_VERSION=$(patsubst vasp.%.tar.gz,%,$(VASP_SOURCE_FILE))
SPLIT_VERSION=$(subst ., ,$(EXTRACTED_VERSION))
VER_MAJ=$(word 1,$(SPLIT_VERSION))
VER_MIN=$(word 2,$(SPLIT_VERSION))
VER_MIC=$(word 3,$(SPLIT_VERSION))
VASP_VER = $(VER_MAJ).$(VER_MIN).$(VER_MIC)
# Note: as a side effect, this also removes anything between the microversion and the .tar.gz
# such as the date inserted by our getvasp script. See the drama over the silent replacement of
# version 5.3.3 for the rationale behind this.
## Put together submake arguments
BASE_MAKEVARS =CPP='$$(CPP_) -DIFC -DCACHE_SIZE=12000 -DPGF90 -Davoidalloc -DHOST=\"LinuxIFC\" '
SERIAL_MAKEVARS =$(BASE_MAKEVARS) \
'FC=$(F90)' \
'BLAS=$(SERIAL_BLAS_FLAGS)' \
'LAPACK=$(SERIAL_LAPACK_FLAGS)' \
'FFT3D=$(SERIAL_FFT_OBJS)'
MPI_MAKEVARS =$(BASE_MAKEVARS) \
'FC=$(MPIF90)' \
CPP+=-DMPI \
'BLAS=$(MPI_BLAS_FLAGS)' \
'LAPACK=$(MPI_LAPACK_FLAGS)' \
'FFT3D=$(MPI_FFT_OBJS)' \
'CPP+=$(SCALAPACK_CPP_FLAGS)'
ifeq ($(WITH_SCALAPACK),"y")
MPI_MAKEVARS+="CPP+=$(SCALAPACK_CPP_FLAGS)" "SCA=$(SCALAPACK_LD_FLAGS)"
endif
SERIAL_NOCD_MAKEVARS =$(SERIAL_MAKEVARS)
SERIAL_CD_MAKEVARS =$(SERIAL_MAKEVARS) CPP+=-DNGXhalf
SERIAL_GAMMA_MAKEVARS=$(SERIAL_MAKEVARS) CPP+=-DwNGXhalf
MPI_NOCD_MAKEVARS =$(MPI_MAKEVARS)
MPI_CD_MAKEVARS =$(MPI_MAKEVARS) CPP+=-DNGZhalf
MPI_GAMMA_MAKEVARS =$(MPI_MAKEVARS) CPP+=-DwNGZhalf
# Vasp doesn't install any documentation, so I'm not sure the other things that
# usually go here are necessary. It might be worth expanding it to include an
# exec-prefix and the other one (the place for non-binary files) for PSP storage, though?
BUILD_DIR =./
EXE_DIR =$(BUILD_DIR)/exe
SERIAL_NOCD_DIR = $(BUILD_DIR)/$(VASP_VER)_src_serial_nocd
SERIAL_CD_DIR = $(BUILD_DIR)/$(VASP_VER)_src_serial_cd
SERIAL_GAMMA_DIR= $(BUILD_DIR)/$(VASP_VER)_src_serial_gamma
MPI_NOCD_DIR = $(BUILD_DIR)/$(VASP_VER)_src_mpi_nocd
MPI_CD_DIR = $(BUILD_DIR)/$(VASP_VER)_src_mpi_cd
MPI_GAMMA_DIR = $(BUILD_DIR)/$(VASP_VER)_src_mpi_gamma
SERIAL_NOCD_BIN =$(EXE_DIR)/vasp-$(VASP_VER)-serial_nocd
SERIAL_CD_BIN =$(EXE_DIR)/vasp-$(VASP_VER)-serial_cd
SERIAL_GAMMA_BIN=$(EXE_DIR)/vasp-$(VASP_VER)-serial_gamma
MPI_NOCD_BIN =$(EXE_DIR)/vasp-$(VASP_VER)-mpi_nocd
MPI_CD_BIN =$(EXE_DIR)/vasp-$(VASP_VER)-mpi_cd
MPI_GAMMA_BIN =$(EXE_DIR)/vasp-$(VASP_VER)-mpi_gamma
ALL_VERSIONS = \
$(SERIAL_NOCD_BIN) \
$(SERIAL_CD_BIN) \
$(SERIAL_GAMMA_BIN) \
$(MPI_NOCD_BIN) \
$(MPI_CD_BIN) \
$(MPI_GAMMA_BIN)
# Might also want to add VTST versions to the above.
# Not really necessary, but to remind me that it exists
.DEFAULT_GOAL := all
all: $(ALL_VERSIONS)
@:
.PHONY : all clean install test check distclean
install: $(ALL_VERSIONS)
$(info install target not implemented.)
@:
clean:
-'rm' -Rf $(EXE_DIR) $(SERIAL_NOCD_DIR) $(SERIAL_CD_DIR) $(SERIAL_GAMMA_DIR) $(MPI_NOCD_DIR) $(MPI_CD_DIR) $(MPI_GAMMA_DIR)
distclean: clean
@:
$(info distclean target not implemented.)
test check:
$(error If only VASP included tests.)
# Probably want to ask for a variable that does something like specify the queue submit commands, to test the MPI versions?
@:
$(SERIAL_NOCD_DIR) $(SERIAL_CD_DIR) $(SERIAL_GAMMA_DIR) $(MPI_NOCD_DIR) $(MPI_CD_DIR) $(MPI_GAMMA_DIR): $(VASP_SOURCE_FILE)
mkdir $@ && tar -xzf $(VASP_SOURCE_FILE) --strip-components 1 -C $@
$(SERIAL_NOCD_DIR)/vasp: vasp.5.lib/libdmy.a $(SERIAL_NOCD_DIR)
cd $(SERIAL_NOCD_DIR) && $(MAKE) -f $(NONLIB_MAKEFILE) $(SERIAL_NOCD_MAKEVARS)
$(SERIAL_CD_DIR)/vasp: vasp.5.lib/libdmy.a $(SERIAL_CD_DIR)
cd $(SERIAL_CD_DIR) && $(MAKE) -f $(NONLIB_MAKEFILE) $(SERIAL_CD_MAKEVARS)
$(SERIAL_GAMMA_DIR)/vasp: vasp.5.lib/libdmy.a $(SERIAL_GAMMA_DIR)
cd $(SERIAL_GAMMA_DIR) && $(MAKE) -f $(NONLIB_MAKEFILE) $(SERIAL_GAMMA_MAKEVARS)
$(MPI_NOCD_DIR)/vasp: vasp.5.lib/libdmy.a $(MPI_NOCD_DIR)
cd $(MPI_NOCD_DIR) && $(MAKE) -f $(NONLIB_MAKEFILE) $(MPI_NOCD_MAKEVARS)
$(MPI_CD_DIR)/vasp: vasp.5.lib/libdmy.a $(MPI_CD_DIR)
cd $(MPI_CD_DIR) && $(MAKE) -f $(NONLIB_MAKEFILE) $(MPI_CD_MAKEVARS)
$(MPI_GAMMA_DIR)/vasp: vasp.5.lib/libdmy.a $(MPI_GAMMA_DIR)
cd $(MPI_GAMMA_DIR) && $(MAKE) -f $(NONLIB_MAKEFILE) $(MPI_GAMMA_MAKEVARS)
$(SERIAL_NOCD_BIN): $(SERIAL_NOCD_DIR)/vasp $(EXE_DIR)
cp $(SERIAL_NOCD_DIR)/vasp $(SERIAL_NOCD_BIN)
$(SERIAL_CD_BIN): $(SERIAL_CD_DIR)/vasp $(EXE_DIR)
cp $(SERIAL_CD_DIR)/vasp $(SERIAL_CD_BIN)
$(SERIAL_GAMMA_BIN): $(SERIAL_GAMMA_DIR)/vasp $(EXE_DIR)
cp $(SERIAL_GAMMA_DIR)/vasp $(SERIAL_GAMMA_BIN)
$(MPI_NOCD_BIN): $(MPI_NOCD_DIR)/vasp $(EXE_DIR)
cp $(MPI_NOCD_DIR)/vasp $(MPI_NOCD_BIN)
$(MPI_CD_BIN): $(MPI_CD_DIR)/vasp $(EXE_DIR)
cp $(MPI_CD_DIR)/vasp $(MPI_CD_BIN)
$(MPI_GAMMA_BIN): $(MPI_GAMMA_DIR)/vasp $(EXE_DIR)
cp $(MPI_GAMMA_DIR)/vasp $(MPI_GAMMA_BIN)
vasp.$(VER_MAJ).lib/libdmy.a: $(BUILD_DIR)/vasp.5.lib
cd $(BUILD_DIR)/vasp.5.lib && $(MAKE) -f $(LIB_MAKEFILE) $(LIB_MAKEVARS)
vasp.$(VER_MAJ).lib: vasp.$(VER_MAJ).lib.tar.gz
tar -xzf vasp.$(VER_MAJ).lib.tar.gz
$(EXE_DIR):
mkdir $(EXE_DIR)