stardis-solver

Solve coupled heat transfers
git clone git://git.meso-star.fr/stardis-solver.git
Log | Files | Refs | README | LICENSE

make.sh (1797B)


      1 #!/bin/sh
      2 
      3 # Copyright (C) 2016-2024 |Méso|Star> (contact@meso-star.com)
      4 #
      5 # This program is free software: you can redistribute it and/or modify
      6 # it under the terms of the GNU General Public License as published by
      7 # the Free Software Foundation, either version 3 of the License, or
      8 # (at your option) any later version.
      9 #
     10 # This program is distributed in the hope that it will be useful,
     11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     13 # GNU General Public License for more details.
     14 #
     15 # You should have received a copy of the GNU General Public License
     16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
     17 
     18 set -e
     19 
     20 config_test()
     21 {
     22   for i in "$@"; do
     23     test=$(basename "${i}" ".c")
     24     test_list="${test_list} ${test}"
     25     printf "%s: %s\n" "${test}" "src/${test}.o"
     26   done
     27   printf "test_bin: %s\n" "${test_list}"
     28 }
     29 
     30 check()
     31 {
     32   name="$1"
     33   prog="$2"
     34   shift 2
     35 
     36   printf "%s " "${name}"
     37   if PATH=./:"${PATH}" "${prog}" "$@" > /dev/null 2>&1; then
     38     printf "\033[1;32mOK\033[m\n"
     39   else
     40     printf "\033[1;31mError\033[m\n"
     41   fi 2> /dev/null
     42 }
     43 
     44 run_test()
     45 {
     46   for i in "$@"; do
     47     prog="$(basename "${i}" ".c")"
     48     check "${prog}" "${prog}"
     49   done
     50 }
     51 
     52 run_test_mpi()
     53 {
     54   for i in "$@"; do
     55     test="$(basename "${i}" ".c")"
     56     check "${test}_mpi_on" mpirun -n 2 "${test}" mpi
     57     check "${test}_no_mpi" "${test}"
     58   done
     59 }
     60 
     61 clean_test()
     62 {
     63   for i in "$@"; do
     64     rm -f "$(basename "${i}" ".c")"
     65   done
     66 }
     67 
     68 install()
     69 {
     70   prefix=$1
     71   shift 1
     72 
     73   mkdir -p "${prefix}"
     74 
     75   for i in "$@"; do
     76     dst="${prefix}/${i##*/}"
     77 
     78     if cmp -s "${i}" "${dst}"; then
     79       printf "Up to date %s\n" "${dst}"
     80     else
     81       printf "Installing %s\n" "${dst}"
     82       cp "${i}" "${prefix}"
     83     fi
     84   done
     85 }
     86 
     87 "$@"