From bf32a9d7f18ba428a8ea04f59b36eaa2a51b3d03 Mon Sep 17 00:00:00 2001 From: John Wise Date: Thu, 16 Jul 2009 00:11:59 -0400 Subject: [PATCH] Accidently uploaded the wrong script! --HG-- branch : week-of-code --- input/restart.sh | 75 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 12 deletions(-) diff --git a/input/restart.sh b/input/restart.sh index f5f1559ac..863febc4e 100755 --- a/input/restart.sh +++ b/input/restart.sh @@ -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 \ No newline at end of file