test.sh 2.51 KB
Newer Older
Rainer Weinberger's avatar
Rainer Weinberger committed
1
2
3
4
5
6
7
8
9
10
#!/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
11
PLOT=False # create plots? True/False
Rainer Weinberger's avatar
Rainer Weinberger committed
12

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

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

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

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

Rainer Weinberger's avatar
Rainer Weinberger committed
37
38
39
40
41
42
43
44
45
46
## loop over all tests
for TEST in $TESTS
do
  DIR="./examples/"${TEST}"/"
  RUNDIR="./run/examples/"${TEST}"/"
  
  ## clean up 
  rm -rf ./run

  ## create run directory
47
48
49
  mkdir -p ${RUNDIR}

  ## copy Config and parameter file to run directory
50
  cp -r ${DIR}/* ${RUNDIR}
Rainer Weinberger's avatar
Rainer Weinberger committed
51
52
53
  
  ## create ICs in run directory
  echo ${DIR}
54
  python ${RUNDIR}/create.py ${RUNDIR}
Rainer Weinberger's avatar
Rainer Weinberger committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  ((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

  ## 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
  
69
70
  ## change to RUNDIR in subshell and execute test simulation
  (cd ${RUNDIR} && mpiexec -np ${NUMBER_OF_TASKS} ./Arepo ./param.txt)
Rainer Weinberger's avatar
Rainer Weinberger committed
71
72
73
74
75
76
77
  ((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
78
  python ${RUNDIR}/check.py ${RUNDIR} ${PLOT}
Rainer Weinberger's avatar
Rainer Weinberger committed
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
  ((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}