forked from SPECFEM/specfem3d_globe
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.travis.yml
203 lines (170 loc) · 6.35 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
# 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
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
# run default test (with > make tests)
- TEST="" TESTCOV=0 TESTMAKE=0
# run default (regional)
- TEST="" TESTCOV=0 TESTMAKE=1
# run vectorization (regional)
- TEST="--enable-vectorization" TESTCOV=0 TESTMAKE=1
# run vectorization & openmp (regional)
- TEST="--enable-vectorization --enable-openmp" TESTCOV=0 TESTMAKE=1
# run vectorization & openmp, using coverage flags (regional)
- TEST="--enable-vectorization" TESTCOV=1 TESTMAKE=1
# run example 2 (global)
- TEST="--enable-vectorization" TESTCOV=0 TESTMAKE=2
# run example 2 (global with openmp)
- TEST="--enable-vectorization --enable-openmp" TESTCOV=0 TESTMAKE=2
# run example with debug bounds checking (regional)
- TEST="--enable-debug" TESTCOV=0 TESTMAKE=3
before_install:
# informations on git
- |
git --version
git rev-parse --verify HEAD
git branch -a
# infos on commits
- |
echo "request: Branch($TRAVIS_BRANCH) Pull Request($TRAVIS_PULL_REQUEST) Tag($TRAVIS_TAG)"
echo "commit : Commit($TRAVIS_COMMIT) Range($TRAVIS_COMMIT_RANGE)"
# 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:
# fortran/openMPI compiler
- sudo apt-get install gfortran libgomp1 openmpi-bin libopenmpi-dev
# python script needs numpy
- sudo apt-get install -qq python-numpy #python-scipy
# 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_report(){
# report example
if [ -f OUTPUT_FILES/output_mesher.txt ]; then cat OUTPUT_FILES/output_mesher.txt; else exit 1; fi
if [ -f OUTPUT_FILES/output_solver.txt ]; then cat OUTPUT_FILES/output_solver.txt; else exit 1; fi
}
- |
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/
}
###########################################################
# configuration & compilation
###########################################################
# configuration
- |
if [ "$TESTCOV" == "1" ]; then
./configure FC=${FC} MPIFC=${MPIFC} CC=${CC} ${TEST} FLAGS_CHECK="-fprofile-arcs -ftest-coverage -O0"
else
./configure FC=${FC} MPIFC=${MPIFC} CC=${CC} ${TEST}
fi
# we need to output to console output, otherwise tests will fail by timeout
- sed -i "s:IMAIN .*:IMAIN = ISTANDARD_OUTPUT:" setup/constants.h
# compilation (only cleaning)
- make clean
###########################################################
# test examples
###########################################################
# testing small example (short & quick for all configurations)
- |
# chooses example directory
case "$TESTMAKE" in
0) dir=./ ;;
1) dir=EXAMPLES/regional_Greece_small/ ;;
2) dir=EXAMPLES/global_small/ ;;
3) dir=EXAMPLES/regional_Greece_small/ ;;
*) dir=EXAMPLES/regional_Greece_small/ ;;
esac
# runs test
echo "##########################################################"
echo "test directory: $dir"
echo "##########################################################"
# changes to example directory
cd $dir
if [ "$TESTMAKE" == "0" ]; then
# runs default tests
make tests
else
# limit number of time steps
sed -i "s:^RECORD_LENGTH_IN_MINUTES .*:RECORD_LENGTH_IN_MINUTES = 0.5:" DATA/Par_file
if [ "$TESTMAKE" == "2" ]; then
sed -i "s:^RECORD_LENGTH_IN_MINUTES .*:RECORD_LENGTH_IN_MINUTES = 0.1:" DATA/Par_file
fi
if [ "$TESTMAKE" == "3" ] || [ "$TESTCOV" == "1" ]; then
sed -i "s:^RECORD_LENGTH_IN_MINUTES .*:RECORD_LENGTH_IN_MINUTES = 0.0:" DATA/Par_file
fi
# default script
./run_this_example.sh
# compares seismograms
if [ ! "$TESTMAKE" == "3" ] && [ ! "$TESTCOV" == "1" ]; then
my_test
fi
cd $WORKDIR
fi
# additional code coverage testing
- |
if [ "$TESTCOV" == "1" ]; then
# we need to output to console output, otherwise tests will fail by timeout
sed -i "s:IMAIN .*:IMAIN = ISTANDARD_OUTPUT:" setup/constants.h
# changes to example directory
cd EXAMPLES/global_small/
sed -i "s:^RECORD_LENGTH_IN_MINUTES .*:RECORD_LENGTH_IN_MINUTES = 0.0:" DATA/Par_file
./run_this_example.sh
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