Skip to content

Commit

Permalink
Accidently uploaded the wrong script!
Browse files Browse the repository at this point in the history
--HG--
branch : week-of-code
  • Loading branch information
John Wise committed Jul 16, 2009
1 parent 6f86e52 commit bf32a9d
Showing 1 changed file with 63 additions and 12 deletions.
75 changes: 63 additions & 12 deletions input/restart.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,69 @@
#!/bin/sh

NPROCS=$1
AMRFILE=$2
# 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

# Extract data dump number
NCHARS=`echo $AMRFILE | wc -c | gawk '{printf "%d", $1}'`
C1=`expr $NCHARS - 4`
C2=`expr $NCHARS - 5`
NUM=`echo $AMRFILE | cut -c${C1}- | gawk '{printf "%d", $1}'`
PREFIX=`echo $AMRFILE | cut -c1-${C2}`
# 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

pwd
date
fi

echo "mpirun -np $NPROCS $EXE -d -r $AMRFILE"
mpirun -np $NPROCS $EXE -d -r $AMRFILE &
done

0 comments on commit bf32a9d

Please sign in to comment.