forked from enzo-project/enzo-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestart.sh
executable file
·69 lines (52 loc) · 1.49 KB
/
restart.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
#!/bin/sh
# Initial parameter file. Will change after restarts
AMRFILE=nBody.RunParamFile
# Set to 1 if the initial run is a restart
INIT_RESTART=0
# Redirection of output (doesn't work ...)
OUTPUT=""
#OUTPUT=">& estd.out"
# MPI call
MPI=mpirun
# Number of processors
NPROCS=1
# Enzo executable
EXE=/Users/jwise/codes/EnzoWOC/week-of-code/src/enzo/enzo.exe
# These shouldn't be changed as they're (for now) hard-coded into enzo
RESTART_FILE=RestartParamFile
FINISH_FILE=RunFinished
########################################################################
########################################################################
# Remove restarting and stopping flag files
if [ -e $RESTART_FILE ]; then
rm -f $RESTART_FILE
fi
if [ -e $FINISH_FILE ]; then
rm -f $FINISH_FILE
fi
if [ $INIT_RESTART -eq 1 ]; then
RESTART_FLAG="-r"
else
RESTART_FLAG=""
fi
# Loop until the run is finished. Restarting when found the restart flag.
FIRST_TIME=1
while [ ! -f $FINISH_FILE ]; do
echo "$MPI -np $NPROCS $EXE -d $RESTART_FLAG $AMRFILE $OUTPUT"
$MPI -np $NPROCS $EXE -d $RESTART_FLAG $AMRFILE $OUTPUT
# Exit if an error code is returned
if [ "$?" -ne "0" ]; then
exit 1;
fi
# Get restart parameter file from RESTART_FILE
if [ -f $RESTART_FILE ]; then
# If this isn't the first loop, erase the previous restart dump
DIR=${AMRFILE%%/*}
if [ -d $DIR -a $FIRST_TIME -eq 0 ]; then
rm -r $DIR
fi
AMRFILE=`cat $RESTART_FILE`
RESTART_FLAG="-r"
FIRST_TIME=0
fi
done