[4909] | 1 | #!/bin/bash |
---|
| 2 | # Test LMDZ compilation in various situations |
---|
| 3 | |
---|
| 4 | set -eu |
---|
| 5 | |
---|
[5037] | 6 | ## Params |
---|
| 7 | |
---|
| 8 | #submit_cmd="sbatch -A $(/usr/sbin/my_project.py -l 2>&1 | head -1 | cut -d " " -f 3- | cut -c 5-) --constraint=GENOA --time=00:15:00 -N 1 -n 1 -c 8" # to launch on Adastra /!\ Not working rn, since jobs don't have internet access |
---|
| 9 | submit_cmd="" # to launch directly |
---|
| 10 | #base_args="-arch_dir arch_local -arch local-gfortran" # to use local arch |
---|
| 11 | base_args="-arch local-gfortran-parallel" |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | ## End params |
---|
| 15 | |
---|
| 16 | local=$(pwd) |
---|
[4909] | 17 | mkdir -p test_logs |
---|
| 18 | |
---|
| 19 | function do_one_test { |
---|
| 20 | # Perform one test, if the log file doesn't already exist |
---|
| 21 | |
---|
| 22 | # Create test args |
---|
[5037] | 23 | local args="$base_args -rad $rad -parallel $parallel -netcdf 0 -veget $veget $xios $lmdzrev $cosp" |
---|
[4914] | 24 | # trim |
---|
| 25 | args=$(echo "$args" | xargs) |
---|
[4909] | 26 | |
---|
[5037] | 27 | local logfile="$local/test_logs/$args.out" |
---|
| 28 | if [[ -f $logfile ]]; then return; fi # ALready exists = test already ran |
---|
[4909] | 29 | echo "Testing $args" |
---|
| 30 | |
---|
[5037] | 31 | # Create temp folder |
---|
| 32 | mkdir -p "test_logs/${args// /_}_$$" && cd "test_logs/${args// /_}_$$" |
---|
| 33 | cp ../../install_lmdz.sh . |
---|
[4909] | 34 | |
---|
| 35 | # shellcheck disable=SC2086 |
---|
[5037] | 36 | local test_cmd="$submit_cmd ./install_lmdz.sh -name LMDZ $args" |
---|
| 37 | if ! $test_cmd > "$logfile" 2>&1; then |
---|
[4909] | 38 | # Check bench success if bench |
---|
| 39 | if (grep -q "EXECUTION DU BENCH" < "$logfile") && (! grep -q "Everything is cool" < "$logfile"); then |
---|
| 40 | echo "/!\\ Bench FAILED /!\\" |
---|
| 41 | else |
---|
| 42 | echo "/!\\ Install FAILED /!\\" |
---|
| 43 | fi |
---|
| 44 | fi |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | function run_all_tests { |
---|
[5037] | 48 | cd "$local" |
---|
[4909] | 49 | for parallel in "none" "mpi_omp"; do |
---|
[4929] | 50 | for rad in "oldrad" "rrtm" "ecrad"; do |
---|
[4909] | 51 | for veget in "none" "orch2.0" "orch2.2"; do |
---|
| 52 | for xios in "" "-xios"; do |
---|
[4929] | 53 | if [[ $xios = "-xios" && $parallel = "none" ]]; then continue; fi |
---|
[5037] | 54 | for lmdzrev in ""; do |
---|
[4929] | 55 | for cosp in "" "-cosp v1" "-cosp v2"; do |
---|
[4909] | 56 | do_one_test |
---|
| 57 | done |
---|
| 58 | done |
---|
| 59 | done |
---|
| 60 | done |
---|
[4914] | 61 | done |
---|
[4929] | 62 | done |
---|
[4909] | 63 | } |
---|
| 64 | |
---|
| 65 | function display_results { |
---|
[5037] | 66 | cd "$local/test_logs" |
---|
[4917] | 67 | echo "Success=o, Failure=XXX, non-breaking error=/!\\" |
---|
[4909] | 68 | echo "INSTALL BENCH NAME" |
---|
[5037] | 69 | for fname in *.out; do |
---|
[4909] | 70 | if [[ $(tail -n 1 -- "$fname") = " Everything is cool" ]]; then |
---|
[4917] | 71 | if grep -q "Error" < "$fname"; then |
---|
| 72 | echo " o /!\\ $fname" |
---|
| 73 | else |
---|
| 74 | echo " o o $fname" |
---|
| 75 | fi |
---|
[4909] | 76 | else |
---|
| 77 | if grep -q "EXECUTION DU BENCH" < "$fname"; then |
---|
| 78 | echo " o XXX $fname" |
---|
| 79 | else |
---|
| 80 | echo " XXX $fname" |
---|
| 81 | fi |
---|
| 82 | fi |
---|
| 83 | done |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | skip_tests="" |
---|
| 87 | while (($# > 0)); do |
---|
| 88 | case $1 in |
---|
| 89 | "-s") skip_tests="y"; shift;; |
---|
| 90 | esac |
---|
| 91 | done |
---|
| 92 | |
---|
| 93 | if [[ -z $skip_tests ]]; then run_all_tests; fi |
---|
| 94 | display_results |
---|