forked from SPECFEM/specfem2d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
427 lines (382 loc) · 15 KB
/
.travis.yml
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
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
# Travis configuration
#
# Note: building Fortran code is not supported (yet): see https://docs.travis-ci.com/user/language-specific/
# this is using C as a base and installs gfortran in the test environment
language: c
dist: trusty
sudo: required
os: linux
compiler: gcc
env:
global:
- FC=gfortran
- MPIFC=mpif90
- CC=gcc
- OMP_NUM_THREADS=2
- WORKDIR=`pwd`
matrix:
# for test cases, we use
# TEST - flags used for configuration
# TESTCOV - determines whether or not (0/1) code coverage flags are used
# CUDA - flag for compilation with CUDA
# CUDA_VERSION - specifies CUDA toolkit version
# code coverage: vectorization & mpi, using code coverage flags
- TEST="--enable-vectorization --with-mpi" TESTCOV=1 TESTMAKE=1 CUDA=false
# default test with make tests
- TEST="" TESTCOV=0 TESTMAKE=0 CUDA=false
# compilation w/ CUDA
- TEST="--with-cuda=cuda5 --without-mpi" TESTCOV=0 TESTMAKE=1 CUDA=true CUDA_VERSION=6.5-14
# compilation w/ CUDA and MPI
- TEST="--with-cuda=cuda5 --with-mpi" TESTCOV=0 TESTMAKE=1 CUDA=true CUDA_VERSION=6.5-14
# debug flags
- TEST="--enable-debug" TESTCOV=0 TESTMAKE=1 CUDA=false
# debug & double precision
- TEST="--enable-double-precision --enable-debug" TESTCOV=0 TESTMAKE=1 CUDA=false
# vectorization
- TEST="--enable-vectorization --without-mpi" TESTCOV=0 TESTMAKE=1 CUDA=false
# example w/ PML
- TEST="--enable-vectorization --with-mpi" TESTCOV=0 TESTMAKE=2 CUDA=false
# example w/ MPI and Stacey
- TEST="--enable-vectorization --with-mpi" TESTCOV=0 TESTMAKE=3 CUDA=false
# example w/ kernel calculation
- TEST="--enable-vectorization --with-mpi" TESTCOV=0 TESTMAKE=4 CUDA=false
# example w/ poroelastic/acoustic media
- TEST="--enable-vectorization --with-mpi" TESTCOV=0 TESTMAKE=5 CUDA=false
# example w/ noise
- TEST="--enable-vectorization --with-mpi" TESTCOV=0 TESTMAKE=6 CUDA=false
# example w/ axisymmetric & attenuation
- TEST="--enable-vectorization --with-mpi" TESTCOV=0 TESTMAKE=7 CUDA=false
# example w/ PML and MPI
- TEST="--enable-vectorization --with-mpi" TESTCOV=0 TESTMAKE=8 CUDA=false
# example w/ MPI and SEP format
- TEST="--enable-vectorization --with-mpi" TESTCOV=0 TESTMAKE=9 CUDA=false
# example w/ initialfield Rayleigh wave
- TEST="--enable-vectorization --with-mpi" TESTCOV=0 TESTMAKE=10 CUDA=false
# example w/ initialfield Rayleigh wave and manual crack
- TEST="--enable-vectorization --with-mpi" TESTCOV=0 TESTMAKE=11 CUDA=false
# example w/ SH waves and checkerboard model
- TEST="--without-mpi" TESTCOV=0 TESTMAKE=12 CUDA=false
before_install:
# informations on git
- |
git --version
git rev-parse --verify HEAD
git branch -a
# checks if changes occurred in folders src/ or setup/
- |
echo "request: Branch($TRAVIS_BRANCH) Pull Request($TRAVIS_PULL_REQUEST) Tag($TRAVIS_TAG)"
echo "commit : Commit($TRAVIS_COMMIT) Range($TRAVIS_COMMIT_RANGE)"
# not working yet:
# git produces error:
# `fatal: ambiguous argument. .. unknown revision or path not in the working tree.`
#
# so far, we have no simple way yet to check where the changes occurred for this build
# and if we have to actually perform code testing or not :(
#
# to skip testing: the commit message must contain [ci skip]
#
# this fails...
#git rev-list --oneline $TRAVIS_COMMIT_RANGE
## fixes triple-dot to double-dot range (see: https://github.com/travis-ci/travis-ci/issues/4596)
#if [[ $TRAVIS_COMMIT_RANGE =~ "..." ]]; then
# RANGE=${TRAVIS_COMMIT_RANGE/.../..}
#else
# RANGE=$TRAVIS_COMMIT_RANGE
#fi
##RANGE1=`echo "$TRAVIS_COMMIT_RANGE" | awk '{n=split($1,a,".");print a[1]}'`
##RANGE2=`echo "$TRAVIS_COMMIT_RANGE" | awk '{n=split($1,a,".");print a[n]}'`
#echo "request makes changes: $RANGE"
#git diff-tree --name-only $RANGE
#CHANGE=`git diff-tree --name-only $RANGE | grep -E 'src|setup'`
#echo "check for change: $CHANGE"
#if [ "$CHANGE" == "" ]; then
# echo "no changes in src/ or setup/ folder, skipping code testing..."
# exit 0
#fi
# recommended for MPI projects to unset CC: see https://docs.travis-ci.com/user/languages/c
#- test -n $CC && unset CC
# updates repository
- sudo apt-get update
install:
# installs the CUDA toolkit
- |
if [ "$CUDA" == "true" ]; then
echo "Installing CUDA library"
# remove old nvidia-cuda packages
#sudo apt-get remove nvidia-cuda-* ;
# gets packages
## distribution trusty: from ubuntu 14.04
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_${CUDA_VERSION}_amd64.deb;
sudo dpkg -i cuda-repo-ubuntu1404_${CUDA_VERSION}_amd64.deb;
## distribution precise: from ubuntu 12.04
#wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1204/x86_64/cuda-repo-ubuntu1204_${CUDA_VERSION}_amd64.deb;
#sudo dpkg -i cuda-repo-ubuntu1204_${CUDA_VERSION}_amd64.deb;
# update
sudo apt-get update -qq;
dpkg -l | grep cuda ;
export CUDA_APT=${CUDA_VERSION:0:3};
export CUDA_APT=${CUDA_APT/./-};
# installs packages
# CUDA_PACKAGES="cuda-drivers cuda-core-${CUDA_APT} cuda-cudart-dev-${CUDA_APT} cuda-cufft-dev-${CUDA_APT}";
CUDA_PACKAGES="cuda-drivers cuda-core-${CUDA_APT} cuda-cudart-dev-${CUDA_APT}";
echo "Installing ${CUDA_PACKAGES}"
sudo apt-get install -y ${CUDA_PACKAGES};
sudo apt-get clean;
export CUDA_HOME=/usr/local/cuda-${CUDA_VERSION:0:3};
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH};
export PATH=${CUDA_HOME}/bin:${PATH};
echo "";
echo "exports:"
export ;
echo "";
nvcc --version
fi
# fortran/openMPI compiler
- sudo apt-get install gfortran libgomp1 openmpi-bin libopenmpi-dev
# python script needs numpy
- |
echo "Python on path: `which python`"
echo "pip on path: $(which pip)"
# for distribution precise
#sudo apt-get install -qq python-numpy #python-scipy
# trusty:
# (Sep2017 update: adding flag --user : see https://github.com/travis-ci/travis-ci/issues/8382)
pip install --user --upgrade pip setuptools wheel
pip install --user --only-binary=numpy numpy
# version info
python --version
# version infos
- |
echo "compiler versions:" ${FC} ${MPIFC} ${CC}
${FC} --version
${MPIFC} --version
${CC} --version
script:
###########################################################
# setup
###########################################################
# info
- |
echo $TRAVIS_BUILD_DIR
echo $WORKDIR
echo "configuration test:" ${TEST} ${TESTFLAGS}
# bash function for checking seismogram output with reference solutions
- |
my_test(){
echo "testing seismograms:"
ln -s $WORKDIR/utils/compare_seismogram_correlations.py
./compare_seismogram_correlations.py OUTPUT_FILES/ REF_SEIS/
if [[ $? -ne 0 ]]; then exit 1; fi
./compare_seismogram_correlations.py OUTPUT_FILES/ REF_SEIS/ | grep min/max | cut -d \| -f 3 | awk '{print "correlation:",$1; if ($1 < 0.9 ){print $1,"failed"; exit 1;}else{ print $1,"good"; exit 0;}}'
if [[ $? -ne 0 ]]; then exit 1; fi
rm -rf OUTPUT_FILES/
}
- |
my_test_kernel(){
echo "testing kernels:"
ln -s $WORKDIR/utils/compare_kernel_correlations.py
./compare_kernel_correlations.py OUTPUT_FILES/proc000000_rhop_alpha_beta_kernel.dat REF_KERNEL/proc000000_rhop_alpha_beta_kernel.dat
if [[ $? -ne 0 ]]; then exit 1; fi
./compare_kernel_correlations.py OUTPUT_FILES/proc000000_rhop_alpha_beta_kernel.dat REF_KERNEL/proc000000_rhop_alpha_beta_kernel.dat | grep min/max | cut -d \| -f 3 | awk '{print "correlation:",$1; if ($1 < 0.9 ){print $1,"failed"; exit 1;}else{ print $1,"good"; exit 0;}}'
if [[ $? -ne 0 ]]; then exit 1; fi
rm -rf OUTPUT_FILES/
}
###########################################################
# configuration & compilation
###########################################################
# configuration
- |
if [ "$TESTCOV" == "1" ]; then
echo "configuration: for coverage"
./configure FC=${FC} MPIFC=${MPIFC} CC=${CC} ${TEST} FLAGS_CHECK="-fprofile-arcs -ftest-coverage -O0"
else
if [ "$CUDA" == "true" ]; then
echo "configuration: for cuda"
./configure FC=${FC} MPIFC=${MPIFC} CC=${CC} ${TEST} CUDA_LIB="${CUDA_HOME}/lib64" CUDA_INC="${CUDA_HOME}/include" CUDA_FLAGS="-Xcompiler -Wall,-Wno-unused-function,-Wno-unused-const-variable,-Wfatal-errors -g -G"
else
echo "configuration: default"
./configure FC=${FC} MPIFC=${MPIFC} CC=${CC} ${TEST}
fi
fi
# specific example setup
- |
if [ "$TESTMAKE" == "11" ]; then
sed -i "s:FAST_NUMBERING .*:FAST_NUMBERING = .false.:" setup/constants.h
sed -i "s:ADD_A_SMALL_CRACK_IN_THE_MEDIUM .*:ADD_A_SMALL_CRACK_IN_THE_MEDIUM = .true.:" setup/constants.h
fi
# compilation
- make clean; make -j2 all
###########################################################
# test examples
###########################################################
# testing internal mesher example (short & quick for all configuration)
- |
# chooses example directory
case "$TESTMAKE" in
0) dir=./ ;;
1) dir=EXAMPLES/simple_topography_and_also_a_simple_fluid_layer/ ;;
2) dir=EXAMPLES/semi_infinite_homogeneous/ ;;
3) dir=EXAMPLES/Gmsh_example_Stacey_MPI/ ;;
4) dir=EXAMPLES/Tromp2005_kernel/ ;;
5) dir=EXAMPLES/poroelastic_acoustic/ ;;
6) dir=EXAMPLES/noise_uniform/ ;;
7) dir=EXAMPLES/axisymmetric_case_AXISYM_option/ ;;
8) dir=EXAMPLES/simple_topography_and_also_a_simple_fluid_layer/ ;;
9) dir=EXAMPLES/Industrial_Format_SEP/ ;;
10) dir=EXAMPLES/Rayleigh_wave_no_crack/ ;;
11) dir=EXAMPLES/Rayleigh_wave_with_crack/ ;;
12) dir=EXAMPLES/Tape2007/ ;;
*) dir=EXAMPLES/simple_topography_and_also_a_simple_fluid_layer/ ;;
esac
# runs test
echo "##########################################################"
echo "test directory: $dir"
echo "##########################################################"
cd $dir
if [ "$TESTMAKE" == "0" ]; then
# runs default tests
make tests
else
# limit time steps for testing in coverage run
if [ "$TESTCOV" == "1" ]; then
sed -i "s:^NSTEP .*:NSTEP = 400:" DATA/Par_file
fi
# specific example settings needed for testing
if [ "$TESTMAKE" == "5" ]; then
sed -i "s:^NSTEP .*:NSTEP = 1000:" DATA/Par_file
fi
if [ "$TESTMAKE" == "7" ]; then
sed -i "s:^NPROC .*:NPROC = 2:" DATA/Par_file
sed -i "s:^NSTEP .*:NSTEP = 1400:" DATA/Par_file
fi
if [ "$TESTMAKE" == "9" ]; then
sed -i "s:^NPROC .*:NPROC = 2:" DATA/Par_file
sed -i "s:^NSTEP .*:NSTEP = 3000:" DATA/Par_file
fi
# default
if [ "$TESTMAKE" == "4" ]; then
# kernel script
./run_this_example_kernel.sh
my_test_kernel
else
# default script
./run_this_example.sh
my_test
fi
cd $WORKDIR
fi
# code coverage: https://codecov.io/gh/geodynamics/specfem2d/
- |
if [ "$TESTCOV" == "1" ]; then
##
## testing example with pml (longer testing only together with mpi and code coverage)
##
cd EXAMPLES/semi_infinite_homogeneous/
sed -i "s:^NPROC .*:NPROC = 2:" DATA/Par_file
sed -i "s:^NSTEP .*:NSTEP = 500:" DATA/Par_file
./run_this_example.sh
my_test
cd $WORKDIR
##
## testing external mesher example with mpi and stacey
##
cd EXAMPLES/Gmsh_example_Stacey_MPI/
sed -i "s:^NSTEP .*:NSTEP = 500:" DATA/Par_file
./run_this_example.sh
# tests mesh quality output
awk '{if(NR==1){dy=sqrt(($2-13.3242693)^2);if(dy>1.e-5){print $0,"failed",dy;exit 1;}else{print $0,"good",dy;exit 0;}}}' OUTPUT_FILES/mesh_quality_histogram.txt
if [[ $? -ne 0 ]]; then exit 1; fi
my_test
cd $WORKDIR
##
## testing kernel example
##
cd EXAMPLES/Tromp2005_kernel/
sed -i "s:^NSTEP .*:NSTEP = 500:" DATA/Par_file
./run_this_example_kernel.sh
# no kernel value testing: only execution failure
#my_test_kernel
cd $WORKDIR
##
## testing poroelastic example
##
cd EXAMPLES/poroelastic_acoustic/
sed -i "s:^NSTEP .*:NSTEP = 10:" DATA/Par_file
./run_this_example.sh
# only for coverage, comparison would fail: my_test
cd $WORKDIR
##
## testing noise example
##
cd EXAMPLES/noise_uniform/
sed -i "s:^NSTEP .*:NSTEP = 10:" DATA/Par_file_noise_1
./run_this_example.sh
# only for coverage, comparison would fail: my_test
cd $WORKDIR
##
## testing axisymmetric example
##
cd EXAMPLES/axisymmetric_case_AXISYM_option/
sed -i "s:^NPROC .*:NPROC = 2:" DATA/Par_file
sed -i "s:^NSTEP .*:NSTEP = 10:" DATA/Par_file
./run_this_example.sh
# only for coverage, comparison would fail: my_test
cd $WORKDIR
##
## testing PML & MPI example
##
cd EXAMPLES/simple_topography_and_also_a_simple_fluid_layer/
sed -i "s:^NSTEP .*:NSTEP = 10:" DATA/Par_file
./run_this_example.sh
# only for coverage, comparison would fail: my_test
cd $WORKDIR
##
## testing MPI, SEP example
##
cd EXAMPLES/Industrial_Format_SEP/
sed -i "s:^NSTEP .*:NSTEP = 10:" DATA/Par_file
./run_this_example.sh
# only for coverage, comparison would fail: my_test
cd $WORKDIR
##
## testing plane wave example
##
cd EXAMPLES/Rayleigh_wave_no_crack/
sed -i "s:^NSTEP .*:NSTEP = 10:" DATA/Par_file
# coarser resolution
sed -i "s:60:15:g" DATA/Par_file
sed -i "s:28:7:g" DATA/Par_file
sed -i "s:28:7:g" DATA/interfaces_Rayleigh_flat.dat
./run_this_example.sh
# only for coverage, comparison would fail: my_test
cd $WORKDIR
##
## testing Tape2007 example
##
cd EXAMPLES/Tape2007/
sed -i "s:^NSTEP .*:NSTEP = 10:" DATA/Par_file
./run_this_example.sh
# only for coverage, comparison would fail: my_test
cd $WORKDIR
fi
# done
- echo `pwd`
after_success:
###########################################################
# code coverage
###########################################################
- |
if [ "$TESTCOV" == "1" ]; then
gcov --version
echo `pwd`
ls -al obj/
fi
# produces coverage reports (done manually because of different naming for source & object files)
- |
if [ "$TESTCOV" == "1" ]; then
find obj/ -iname '*.o' | sort | awk '{print "gcov -o obj/ "$1;}'
# executes gcov-commands
find obj/ -iname '*.o' | sort | awk '{print "gcov -o obj/ "$1;}' | sh
fi
# code coverage: see example https://github.com/codecov/example-fortran/blob/master/.travis.yml
- if [ "$TESTCOV" == "1" ]; then bash <(curl -s https://codecov.io/bash) -X gcov; fi