|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# runs additional coverage examples |
| 4 | +# |
| 5 | + |
| 6 | +set -euo pipefail |
| 7 | + |
| 8 | +# getting updated environment (CUDA_HOME, PATH, ..) |
| 9 | +if [ -f $HOME/.tmprc ]; then source $HOME/.tmprc; fi |
| 10 | + |
| 11 | +WORKDIR=$(pwd) |
| 12 | +TESTID=${TESTID:-} |
| 13 | +TESTCOV=${TESTCOV:-} |
| 14 | + |
| 15 | +if [ "$TESTCOV" != "true" ]; then |
| 16 | + echo "TESTCOV=${TESTCOV} (not coverage), skipping run_coverage.sh" |
| 17 | + exit 0 |
| 18 | +fi |
| 19 | + |
| 20 | +run_simple() { |
| 21 | + local rel_dir="$1" |
| 22 | + local nstep="$2" |
| 23 | + local model="${3:-}" |
| 24 | + |
| 25 | + echo "##################################################################" |
| 26 | + echo "${rel_dir}" |
| 27 | + echo |
| 28 | + |
| 29 | + cd "${WORKDIR}/${rel_dir}" |
| 30 | + |
| 31 | + # setup |
| 32 | + cp -v DATA/Par_file DATA/Par_file.org |
| 33 | + sed -i "s:^NSTEP .*:NSTEP = ${nstep}:" DATA/Par_file |
| 34 | + |
| 35 | + # noise |
| 36 | + if [ "${rel_dir}" == "EXAMPLES/applications/noise_tomography/" ]; then |
| 37 | + sed -i '10,$ d' NOISE_TOMOGRAPHY/S_squared # truncates file, deletes all lines from line 10 till end |
| 38 | + fi |
| 39 | + # socal1D |
| 40 | + if [ "${rel_dir}" == "EXAMPLES/applications/meshfem3D_examples/socal1D/" ]; then |
| 41 | + if [ "$model" = "1d_socal" ]; then |
| 42 | + sed -i "s:^MODEL .*:MODEL = 1d_socal:" DATA/Par_file |
| 43 | + rm -f REF_SEIS |
| 44 | + ln -s REF_SEIS.1d_socal REF_SEIS |
| 45 | + elif [ "$model" = "1d_prem" ]; then |
| 46 | + sed -i "s:^MODEL .*:MODEL = 1d_prem:" DATA/Par_file |
| 47 | + rm -f REF_SEIS |
| 48 | + ln -s REF_SEIS.1d_prem REF_SEIS |
| 49 | + elif [ "$model" = "1d_cascadia" ]; then |
| 50 | + sed -i "s:^MODEL .*:MODEL = 1d_cascadia:" DATA/Par_file |
| 51 | + rm -f REF_SEIS |
| 52 | + ln -s REF_SEIS.1d_cascadia REF_SEIS |
| 53 | + fi |
| 54 | + fi |
| 55 | + |
| 56 | + # run |
| 57 | + ./run_this_example.sh |
| 58 | + if [[ $? -ne 0 ]]; then exit 1; fi |
| 59 | + mv -v DATA/Par_file.org DATA/Par_file |
| 60 | + cd "$WORKDIR" |
| 61 | +} |
| 62 | + |
| 63 | +run_kernel() { |
| 64 | + local rel_dir="$1" |
| 65 | + local nstep="$2" |
| 66 | + |
| 67 | + echo "##################################################################" |
| 68 | + echo "${rel_dir} (kernel coverage)" |
| 69 | + echo |
| 70 | + |
| 71 | + cd "${WORKDIR}/${rel_dir}" |
| 72 | + |
| 73 | + # setup |
| 74 | + cp -v DATA/Par_file DATA/Par_file.org |
| 75 | + sed -i "s:^NSTEP .*:NSTEP = ${nstep}:" DATA/Par_file |
| 76 | + |
| 77 | + if [ "${rel_dir}" == "EXAMPLES/applications/homogeneous_acoustic/" ]; then |
| 78 | + sed -i "s:300:${nstep}:" run_this_example_kernel.sh |
| 79 | + sed -i "s:^t_start.*:t_start=-6.0:" create_adjoint_sources.sh |
| 80 | + sed -i "s:^t_end.*:t_end=-5.55:" create_adjoint_sources.sh |
| 81 | + fi |
| 82 | + |
| 83 | + # run |
| 84 | + ./run_this_example_kernel.sh |
| 85 | + if [[ $? -ne 0 ]]; then exit 1; fi |
| 86 | + mv -v DATA/Par_file.org DATA/Par_file |
| 87 | + cd "$WORKDIR" |
| 88 | +} |
| 89 | + |
| 90 | + |
| 91 | +run_serial() { |
| 92 | + local rel_dir="$1" |
| 93 | + local nstep="$2" |
| 94 | + |
| 95 | + echo "##################################################################" |
| 96 | + echo "${rel_dir} (serial)" |
| 97 | + echo |
| 98 | + |
| 99 | + cd "${WORKDIR}/${rel_dir}" |
| 100 | + |
| 101 | + # setup |
| 102 | + cp -f DATA/Par_file DATA/Par_file.org |
| 103 | + sed -i "s:^NPROC .*:NPROC = 1:" DATA/Par_file |
| 104 | + sed -i "s:^NSTEP .*:NSTEP = ${nstep}:" DATA/Par_file |
| 105 | + |
| 106 | + # meshfem setup |
| 107 | + if [ -e DATA/meshfem3D_files/Mesh_Par_file ]; then |
| 108 | + cp -f DATA/meshfem3D_files/Mesh_Par_file DATA/meshfem3D_files/Mesh_Par_file.org |
| 109 | + sed -i "s:^NPROC_XI .*:NPROC_XI = 1:" DATA/meshfem3D_files/Mesh_Par_file |
| 110 | + sed -i "s:^NPROC_ETA .*:NPROC_ETA = 1:" DATA/meshfem3D_files/Mesh_Par_file |
| 111 | + fi |
| 112 | + |
| 113 | + # run |
| 114 | + ./run_this_example.sh |
| 115 | + if [[ $? -ne 0 ]]; then exit 1; fi |
| 116 | + mv -v DATA/Par_file.org DATA/Par_file |
| 117 | + if [ -e DATA/meshfem3D_files/Mesh_Par_file.org ]; then mv -v DATA/meshfem3D_files/Mesh_Par_file.org DATA/meshfem3D_files/Mesh_Par_file; fi |
| 118 | + cd "$WORKDIR" |
| 119 | +} |
| 120 | + |
| 121 | +echo |
| 122 | +echo "coverage run: TESTID=${TESTID}" |
| 123 | +echo "work directory: ${WORKDIR}" |
| 124 | +echo |
| 125 | + |
| 126 | +# additional example tests (after base to avoid repeating code setup/configuration/compilation) |
| 127 | +case "$TESTID" in |
| 128 | + 0) # serial bunch |
| 129 | + run_serial "EXAMPLES/applications/homogeneous_halfspace/" 5 |
| 130 | + run_serial "EXAMPLES/applications/meshfem3D_examples/simple_model/" 5 |
| 131 | + run_serial "EXAMPLES/applications/Gmsh_simple_box_hex27/" 5 |
| 132 | + ;; |
| 133 | + 1) # parallel bunch 1 |
| 134 | + run_simple "EXAMPLES/applications/homogeneous_halfspace_HEX27_elastic_no_absorbing/" 5 |
| 135 | + run_simple "EXAMPLES/applications/homogeneous_poroelastic/" 5 |
| 136 | + run_kernel "EXAMPLES/applications/homogeneous_acoustic/" 5 |
| 137 | + ;; |
| 138 | + 2) # parallel bunch 2 |
| 139 | + run_simple "EXAMPLES/applications/CPML_examples/homogeneous_halfspace_HEX8_acoustic_absorbing_CPML_5sides/" 5 |
| 140 | + run_simple "EXAMPLES/applications/CPML_examples/homogeneous_halfspace_HEX8_elastic_absorbing_CPML_5sides/" 5 |
| 141 | + run_simple "EXAMPLES/applications/noise_tomography/" 5 |
| 142 | + run_simple "EXAMPLES/applications/tomographic_model/" 5 |
| 143 | + run_simple "EXAMPLES/applications/layered_halfspace/" 5 |
| 144 | + run_simple "EXAMPLES/applications/waterlayered_halfspace/" 5 |
| 145 | + run_simple "EXAMPLES/applications/waterlayered_poroelastic/" 5 |
| 146 | + ;; |
| 147 | + 3) # parallel bunch 3 |
| 148 | + run_simple "EXAMPLES/applications/fault_examples/tpv5/" 5 |
| 149 | + run_simple "EXAMPLES/applications/small_example_coupling_FK_specfem/" 5 |
| 150 | + run_simple "EXAMPLES/applications/Gmsh_simple_lddrk/" 5 |
| 151 | + run_simple "EXAMPLES/applications/decompose_mesh_MPI/" 5 |
| 152 | + run_simple "EXAMPLES/applications/small_adjoint_multiple_sources/" 5 |
| 153 | + run_simple "EXAMPLES/applications/LTS_homogeneous_halfspace_HEX8/" 50 |
| 154 | + ;; |
| 155 | + 4) # parallel bunch 4 |
| 156 | + run_simple "EXAMPLES/applications/meshfem3D_examples/socal1D/" 5 "1d_socal" |
| 157 | + run_simple "EXAMPLES/applications/meshfem3D_examples/socal1D/" 5 "1d_prem" |
| 158 | + run_simple "EXAMPLES/applications/meshfem3D_examples/socal1D/" 5 "1d_cascadia" |
| 159 | + run_simple "EXAMPLES/applications/meshfem3D_examples/cavity/" 5 |
| 160 | + run_simple "EXAMPLES/applications/meshfem3D_examples/sep_bathymetry/" 5 |
| 161 | + run_simple "EXAMPLES/applications/meshfem3D_examples/regular_element_mesh/" 5 |
| 162 | + ;; |
| 163 | + 5) # inversion |
| 164 | + echo "TESTID=4: no additional coverage examples (base inversion run already executed)" |
| 165 | + ;; |
| 166 | + 6) # NGLL 6 |
| 167 | + echo "TESTID=5: no additional coverage examples (base run already executed)" |
| 168 | + ;; |
| 169 | + *) |
| 170 | + echo "TESTID=${TESTID}: no additional coverage examples configured" |
| 171 | + ;; |
| 172 | +esac |
| 173 | + |
| 174 | +echo |
| 175 | +echo "coverage examples done" |
| 176 | +echo "$(date)" |
| 177 | +echo |
0 commit comments