test.sh 2.47 KB
Newer Older
Rainer Weinberger's avatar
Rainer Weinberger committed
1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash            # this line only there to enable syntax highlighting in this file
## shell script for code testing

#################################
## perform predefined examples ##
#################################

## Number of cores to compile and run the problem on
## use NUMBER_OF_TASKS=1 for 1d test problems!
NUMBER_OF_TASKS=1

Rainer Weinberger's avatar
Rainer Weinberger committed
12
## choose your examples
Rainer Weinberger's avatar
Rainer Weinberger committed
13
TESTS=""
Rainer Weinberger's avatar
Rainer Weinberger committed
14
15

## available 1d examples
Rainer Weinberger's avatar
Rainer Weinberger committed
16
TESTS+="wave_1d "
Rainer Weinberger's avatar
Rainer Weinberger committed
17
TESTS+="shocktube_1d "
18
TESTS+="interacting_blastwaves_1d "
19
TESTS+="mhd_shocktube_1d "
20
TESTS+="polytrope_1d_spherical "
Rainer Weinberger's avatar
Rainer Weinberger committed
21

Rainer Weinberger's avatar
Rainer Weinberger committed
22
## available 2d examples
Rainer Weinberger's avatar
Rainer Weinberger committed
23
TESTS+="gresho_2d "
Rainer Weinberger's avatar
Rainer Weinberger committed
24
TESTS+="noh_2d "
Rainer Weinberger's avatar
Rainer Weinberger committed
25
26
TESTS+="yee_2d "

Rainer Weinberger's avatar
Rainer Weinberger committed
27
28
## available 3d examples
TESTS+="noh_3d "
29
TESTS+="cosmo_box_gravity_only_3d "
30
TESTS+="cosmo_box_star_formation_3d "
31
#TESTS+="cosmo_zoom_gravity_only_3d "
32
TESTS+="galaxy_merger_star_formation_3d "
33
TESTS+="isolated_galaxy_collisionless_3d "
Rainer Weinberger's avatar
Rainer Weinberger committed
34

Rainer Weinberger's avatar
Rainer Weinberger committed
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
## loop over all tests
for TEST in $TESTS
do
  DIR="./examples/"${TEST}"/"
  RUNDIR="./run/examples/"${TEST}"/"
  
  ## clean up 
  rm -rf ./run

  ## create run directory
  mkdir ./run
  mkdir ./run/examples
  mkdir ${RUNDIR}
  
  ## create ICs in run directory
  echo ${DIR}
  python ${DIR}/create.py ${RUNDIR}
  ((return_value=$?))    ## get return value
  if [ $return_value != 0 ]    ## check return value
  then echo "ERROR: test.sh:\t" $DIR "\t python create.py failed!"
  exit $return_value
  fi
  
  ## copy Config and parameter file to run directory
  cp ${DIR}/Config.sh ${RUNDIR}
  cp ${DIR}/param.txt ${RUNDIR}

  ## compile Arepo
  make -j ${NUMBER_OF_TASKS} CONFIG=${RUNDIR}/Config.sh BUILD_DIR=${RUNDIR}/build EXEC=${RUNDIR}/Arepo
  ((return_value=$?))    ## get return value
  if [ $return_value != 0 ]    ## check return value
  then echo "ERROR: test.sh:\t" $DIR "\t make failed!"
  exit $return_value
  fi
  
  ## execute test simulation
  mpiexec -np ${NUMBER_OF_TASKS} ${RUNDIR}/Arepo ${RUNDIR}/param.txt
  ((return_value=$?))    ## get return value
  if [ $return_value != 0 ]    ## check return value
  then echo "ERROR: test.sh:\t" $DIR "\t execution failed!"
  exit $return_value
  fi
  
  ## check result in example directory, this also creates some check plots
  python ${DIR}/check.py ${RUNDIR}
  ((return_value=$?))    ## get return value
  if [ $return_value != 0 ]    ## check return value
  then echo "ERROR: test.sh: test failed!"
  exit $return_value
  else echo "test.sh:\t" $DIR "\t test passed!"
  echo "cleaning up..."
  fi
  
  ## clean up
  rm -rf ./run
done

echo "tests"
echo ${TESTS}
echo "passed!"

exit ${return_value}