-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathInstall.sh
296 lines (248 loc) · 9.48 KB
/
Install.sh
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
## Install/unInstall package classes in LAMMPS
# Copies files from here to src/ or deletes those files in src/
# Recommended:
# - Install this package "make yes-USER-GFMD" after all other packages
# - Dont change the install flags while USER-GFMD package is installed
# mode = 0/1/2 for uninstall/install/update as set during LAMMPS' make-option command
mode=$1
## Hard-coded install flags (0/1) specify which optional aspects of USER-GFMD to install.
# These should NOT BE CHANGED while USER-GFMD is installed. Type make no-USER-GFMD first.
# (The concern: "make yes", then user turns off a flag, then later "make no" does not
# revert the patch for that component.)
fftw3=1
ncvar=0
manybody=0
usercuda=0
dynamic=0
## Four small functions are defined in this script, and then called below
# add_or_rm()
# dependency_check()
# toggle_patch()
# set_or_unset()
# function: add_or_rm arg1 [arg2]
# a wrapper for either 'rm' (if mode is 0) or 'cp' (if mode is 1 or 2)
# arg1 = file, arg2 = path to LAMMPS src/ dir
add_or_rm () {
file=`basename $1`
# src directory is ../ unless specified by arg2
srcdir=..
if (test -n "$2") then
srcdir=$2
fi
# Mode 0
if (test $mode = 0) then
if ((test -e $srcdir/$file) && (! cmp -s $1 $srcdir/$file)) then # These four lines help developers
echo " Almost removed a file that has changed. Moved instead to $file.del"
mv $srcdir/$file $srcdir/$file.del
fi
rm -f $srcdir/$file
fi
# Mode 1/2: Copy into src dir if identical file not already there
if (test $mode = 1 || test $mode = 2) then
if (! cmp -s $1 $srcdir/$file) then
cp $1 $srcdir -p
if (test $mode = 2) then
echo " Updating LAMMPS/src/$file"
fi
fi
fi
# Mode 3: Find files that have changed
if (test $mode = 3) then
diff -q $1 $srcdir/$file
fi
}
# function: dependency_check arg1 arg2 arg3
# change mode from 1 to -1 (or 2 to 0) if the file arg1 does not exist
# arg1 = name of file that should exist to proceed, arg2 = arg3 = strings for error message
dependency_check () {
if (! test -e $1) then
echo " Note: $2=1 in USER-GFMD/Install.sh, but dependency '"$3"' not installed ($1 not found)"
if (test $mode = 1) then
echo " so GFMD+"$2" will not be installed."
mode=-1
elif (test $mode = 2) then
echo " so any GFMD+"$2" files will be uninstalled."
mode=0
fi
fi
}
# function: toggle_patch arg1 arg2
# calls either patch -R (if mode is 0) or patch (if mode is 1 or 2)
# arg1 = filetopatch, arg2 = patchfile
toggle_patch () {
fn=$(readlink -f $1)
if ((test ! $mode = -1) && (test ! -e $1)) then
echo " Warning: USER-GFMD/Install.sh flag: Expected to un/patch file $1 which does not exist."
else
case $mode in
0)
patch -R $fn $2
;;
1)
patch $fn $2
;;
2)
echo "(If a warning about previously-applied patch prints next, this file was"
echo " already updated. Do [n]ot assume reversed, do [n]ot apply anyway.)"
patch $fn $2
;;
esac
fi
}
# function: set_or_unset arg1
# adds (or removes) "-Darg1" to the PKG_INC variable in Makefile.package if mode = 1 (or 0)
# This is standard in LAMMPS (eg USER-OMP/Install.sh) to control #ifdef statements in the .cpp files
# arg1 = macro name to define in Makefile.package for the compiler preprocessor
set_or_unset () {
if (test -e ../Makefile.package) then
if (test $mode = 1) then
sed -i -e 's/[^ \t]*'$1'[^ \t]* //' ../Makefile.package
sed -i -e 's|^PKG_INC =[ \t]*|&-D'$1' |' ../Makefile.package
elif (test $mode = 0) then
sed -i -e 's/[^ \t]*'$1'[^ \t]* //' ../Makefile.package
fi
fi
}
# Add/Remove .cpp files to/from src directory
add_or_rm src/main/atom_vec_gfmd.cpp
add_or_rm src/main/crystal_surface.cpp
add_or_rm src/main/fix_gfmd.cpp
add_or_rm src/main/force_constants.cpp
add_or_rm src/main/gfmd_misc.cpp
add_or_rm src/main/gfmd_solver.cpp
add_or_rm src/main/surface_stiffness.cpp
add_or_rm src/force_constants/fc_finite_differences.cpp
add_or_rm src/force_constants/fc_lj_cut.cpp
add_or_rm src/force_constants/fc_lj_cut_fd.cpp
add_or_rm src/force_constants/fc_lj_smooth.cpp
add_or_rm src/force_constants/fc_pair_potential.cpp
add_or_rm src/force_constants/pair_lj_cut_gf.cpp
add_or_rm src/mathutils/linearalgebra.cpp
add_or_rm src/mathutils/table2d.cpp
add_or_rm src/solvers/gfmd_solver_fft.cpp
add_or_rm src/solvers/gfmd_solver_static.cpp
add_or_rm src/stiffness_kernels/debug_stiffness.cpp
add_or_rm src/stiffness_kernels/geometry.cpp
add_or_rm src/stiffness_kernels/isotropic_stiffness.cpp
add_or_rm src/stiffness_kernels/li_berger.cpp
add_or_rm src/stiffness_kernels/fcc100_stiffness.cpp
add_or_rm src/stiffness_kernels/fcc100ft_stiffness.cpp
add_or_rm src/stiffness_kernels/ft_stiffness.cpp
add_or_rm src/stiffness_kernels/sc100_stiffness.cpp
add_or_rm src/surfaces/dia100_surface.cpp
add_or_rm src/surfaces/dia111_surface.cpp
add_or_rm src/surfaces/fcc100_surface.cpp
add_or_rm src/surfaces/fcc111_surface.cpp
add_or_rm src/surfaces/sc100_surface.cpp
add_or_rm src/extras/displace_xeq.cpp
add_or_rm src/extras/fix_contact_rigid.cpp
add_or_rm src/extras/fix_contact_sphere.cpp
add_or_rm src/extras/fix_addforce_dynamic.cpp
# add_or_rm src/extras/min_cg_gfmd.cpp These dont compile for me. Error is
# add_or_rm src/extras/min_tr_gfmd.cpp line (99): error: class "LAMMPS_NS::FixGFMD" has no member "prec_gradient"
add_or_rm src/extras/fix_wall_map.cpp
# Add/Remove .h files from src/ directory
add_or_rm src/main/atom_vec_gfmd.h
add_or_rm src/main/crystal_surface.h
add_or_rm src/main/fix_gfmd.h
add_or_rm src/main/force_constants.h
add_or_rm src/main/gfmd_misc.h
add_or_rm src/main/gfmd_solver.h
add_or_rm src/main/surface_stiffness.h
add_or_rm src/force_constants/fc_finite_differences.h
add_or_rm src/force_constants/fc_lj_cut.h
add_or_rm src/force_constants/fc_lj_cut_fd.h
add_or_rm src/force_constants/fc_lj_smooth.h
add_or_rm src/force_constants/fc_pair_potential.h
add_or_rm src/force_constants/pair_lj_cut_gf.h
add_or_rm src/mathutils/complexcomp.h
add_or_rm src/mathutils/linearalgebra.h
add_or_rm src/mathutils/mat.h
add_or_rm src/mathutils/table2d.h
add_or_rm src/mathutils/vec.h
add_or_rm src/solvers/gfmd_solver_fft.h
add_or_rm src/solvers/gfmd_solver_static.h
add_or_rm src/stiffness_kernels/sc100_stiffness.h
add_or_rm src/stiffness_kernels/debug_stiffness.h
add_or_rm src/stiffness_kernels/fcc100_stiffness.h
add_or_rm src/stiffness_kernels/fcc100ft_stiffness.h
add_or_rm src/stiffness_kernels/ft_stiffness.h
add_or_rm src/stiffness_kernels/geometry.h
add_or_rm src/stiffness_kernels/isotropic_stiffness.h
add_or_rm src/stiffness_kernels/li_berger.h
add_or_rm src/surfaces/dia100_surface.h
add_or_rm src/surfaces/dia111_surface.h
add_or_rm src/surfaces/fcc100_surface.h
add_or_rm src/surfaces/fcc111_surface.h
add_or_rm src/surfaces/sc100_surface.h
add_or_rm src/extras/displace_xeq.h
add_or_rm src/extras/fix_addforce_dynamic.h
add_or_rm src/extras/fix_contact_rigid.h
add_or_rm src/extras/fix_contact_sphere.h
add_or_rm src/extras/fix_wall_map.h
# add_or_rm src/folder/min_cg_gfmd.h These dont compile for me. Error is
# add_or_rm src/folder/min_tr_gfmd.h line (99): error: class "LAMMPS_NS::FixGFMD" has no member "prec_gradient"
# Apply the tiny patches that LAMMPS requires for new styles
toggle_patch ../atom.cpp src/main/atom.cpp.patch
toggle_patch ../atom.h src/main/atom.h.patch
toggle_patch ../pair.h src/main/pair.h.patch
toggle_patch ../pair_lj_smooth.h src/force_constants/pair_lj_smooth.h.patch
if (test -e ../pair_eam.h) then
echo "Enabling EAM"
set_or_unset GFMD_EAM
add_or_rm src/force_constants/fc_eam.cpp
add_or_rm src/force_constants/fc_eam_fd.cpp
add_or_rm src/force_constants/fc_eam.h
add_or_rm src/force_constants/fc_eam_fd.h
add_or_rm src/force_constants/pair_eam_gf.cpp
add_or_rm src/force_constants/pair_eam_alloy_gf.cpp
add_or_rm src/force_constants/pair_eam_gf.h
add_or_rm src/force_constants/pair_eam_alloy_gf.h
toggle_patch ../pair_eam.h src/force_constants/pair_eam.h.patch
fi
if (test -e ../pair_tersoff.h) then
echo "Enabling Tersoff"
set_or_unset GFMD_TERSOFF
add_or_rm src/force_constants/fc_tersoff.cpp
add_or_rm src/force_constants/fc_tersoff.h
add_or_rm src/force_constants/pair_tersoff_gf.cpp
add_or_rm src/force_constants/pair_tersoff_gf.h
toggle_patch ../pair_tersoff.h src/force_constants/pair_tersoff.h.patch
fi
if (test -e ../pair_atomistica.h) then
echo "Enabling Atomistica"
set_or_unset GFMD_ATOMISTICA
add_or_rm src/force_constants/fc_atomistica_fd.cpp
add_or_rm src/force_constants/fc_atomistica_fd.h
fi
if ((test $mode -ge 1) && (test ! -e ../fft3d_wrap.h)) then
echo " Warning: fft3d_wrap.h not found in src/, but GFMD requires 'make yes-KSPACE' before compile"
fi
#######################################################
# Optional aspects of USER-GFMD to install/ uninstall #
#######################################################
if (test $ncvar = 1) then
add_or_rm src/extras/gfmd_analyzer.cpp
add_or_rm src/extras/gfmd_analyzer.h
fi
if (test $manybody = 1) then
echo "Many body functionality not included"
fi
#
if (test $usercuda = 1) then
echo "User Cuda functionality not included"
fi
#
if (test $fftw3 = 1) then
echo "Enabling nonperiodic stiffness kernel"
set_or_unset GFMD_FFTW3
add_or_rm src/stiffness_kernels/nonperiodic_stiffness.cpp
add_or_rm src/stiffness_kernels/nonperiodic_stiffness.h
fi
#
if (test $dynamic = 1) then
echo "Enabling dynamic solver"
set_or_unset GFMD_DYNAMIC
add_or_rm src/solvers/gfmd_solver_dynamic.cpp
add_or_rm src/solvers/gfmd_solver_dynamic.h
fi