Skip to content

Commit

Permalink
Added some example submission scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
schumakov committed Apr 30, 2009
1 parent e4b7627 commit 1dac9c4
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ Scalars' properties are specified in the *.in file in the table:

_______________________________________________________________________
LES MODE SWITCH les_mode
-----------------------------------------------------------------------
0 - no LES, perform straight DNS
1 - Smagorinsky model for velocity
2 - Dynamic Localization Model with constant coefficients, or Yoshizawa Model.



-----------------------------------------------------------------------
RUNNING THE CODE
-----------------------------------------------------------------------
The directory "scripts" provides some examples of the batch job submission files.

snapshot.gp a Gnuplot instruction file that creates two plots that
can get attached to the notification emails

wcr.sub Example script for WCR cluster at Center for
Turbuience Research, Stanford
15 changes: 15 additions & 0 deletions scripts/snapshot.gp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set term png color
set size 0.75

set out '1.png'
set title 'Reynolds number'
set xlabel 'time'
set ylabel 'Re_lambda'
pl 'stat1.gp' u 2:7 w lp

set out '2.png'
set title 'eta*kmax'
set ylabel 'eta * kmax'
pl 'stat2.gp' u 2:7 w lp


132 changes: 132 additions & 0 deletions scripts/wcr.sub
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#!/bin/bash

#PBS -N fit.256.00
#PBS -l nodes=8:ppn=8
#PBS -l walltime=10:00:00
#PBS -o out.txt -e err.txt

#----------------------------------------------------------------------
# setting the general parameters
#----------------------------------------------------------------------

# Resolution and the run number
RES=256
RUN=00

# Setting up the names
RUN_NAME=${RES}_${RUN}
RUN_DIR=$RES.$RUN

WORK_DIR=~/research/runs/$RUN_DIR
(( $RES < 1000 )) && RUN_TITLE=fit_${RES}_${RUN}
(( $RES >= 1000 )) && RUN_TITLE=fit${RES}_${RUN}

# Program name
PROGRAM=~/research/source/hit3d-read-only/hit3d.x
ITER_LAST=000000
ITER_MAX=999999
LOG=log.txt

# Loader-related stuff
LOADER=mpirun
NUMPROCS=$(cat $PBS_NODEFILE | wc -l)
LOADER_OPTS="-hostfile hosts.txt -v -mca mpi_preconnect_all 1 -mca mpi_preconnect_oob 1"

# Job number
JOBNUM=$(echo $PBS_JOBID | awk -F"." '{print $1}')

# --------------------------------------------------------------------
# The main script
# --------------------------------------------------------------------

# Go to working directory
cd $WORK_DIR

# Create the host file
cp $PBS_NODEFILE hosts.txt

# If there is a file "stop", remove it
[ -f stop ] && rm stop

echo '=============================================================='>>$LOG
echo "`date +'%D %R'` : JOB $JOBNUM started.">>$LOG
echo "`date +'%D %R'` : WORK_DIR : $WORK_DIR">>$LOG
echo "`date +'%D %R'` : RUN_TITLE : $RUN_TITLE">>$LOG

# Getting the last dump file number. If none, set to zero.
find_last_iter $RUN_TITLE
echo "`date +'%D %R'` : ITER_LAST : $ITER_LAST">>$LOG


# if the dump number is not smaller than the given iter_max, exit

if [ $ITER_LAST -ge $ITER_MAX ]; then
echo "The maximum iteration number ($ITER_MAX) is reached.">>$LOG
echo "Exiting.">>$LOG
exit 0
fi

# if the iter_max is not acheived, need to run the calculation.
# first change the ITMIN and ITMAX in the input file.

INFILE=${RUN_TITLE}.in
echo "`date +'%D %R'` : Changing the file $INFILE">>$LOG
sed "s/^\([0-9]\+\)\( \+\)\(ITMIN\)/$ITER_LAST\2\3/g" < $INFILE > tmp.$$;
sed "s/^\([0-9]\+\)\( \+\)\(ITMAX\)/$ITER_MAX\2\3/g" < tmp.$$ > $INFILE;
rm -f tmp.$$


# --- putting the job parameters in the file job_parameters.txt
#runlimit=$(bjobs -l $PBS_JOBID | grep ' min of ' | awk -F " " '{print $1}')
# --- since the startup takes immensly long time (about 10 minutes)
# --- we shorten the runlimit by 10 minutes
#echo "$runlimit - 10.0" | bc > job_parameters.txt
echo "600" > job_parameters.txt

# Mailing me that the job is about to start
line="[WCR] Job $JOBNUM <$RUN_TITLE> $ITER_LAST started (`date +'%D %R'`)"
mail [email protected] -s "$line" <<EOF
EOF

# running the program

echo "`date +'%D %R'` : Executing the program...">>$LOG
echo "`date +'%D %R'` : $LOADER $LOADER_OPTS $PROGRAM $RUN_TITLE">>$LOG

$LOADER $LOADER_OPTS $PROGRAM $RUN_TITLE

echo "`date +'%D %R'` : ...done.">>$LOG

# finding out how many iterations did it run

find_last_iter $RUN_TITLE

echo "`date +'%D %R'` : The last iteration now is $ITER_LAST.">>$LOG

# Mailing me that the job just ended
line="[WCR] Job $JOBNUM <$RUN_TITLE> $ITER_LAST ended (`date +'%D %R'`)"
(gnuplot snapshot.gp; uuencode 1.png 1.png; uuencode 2.png 2.png) | mail -s "$line" [email protected]

EOF

exit 0

#----------------------------------------------------------------------
# Function that finds the number of the last dump file
#----------------------------------------------------------------------
find_last_iter()
{
list_restart_files=( `/bin/ls -1 $1.64.?????? 2>/dev/null` )
n_files=${#list_restart_files[*]}
if [ $n_files -eq 0 ]
then
ITER_LAST=000000
else
restart_file=${list_restart_files[$n_files-1]}
ITER_LAST=`echo $restart_file | sed 's/.*\..*\.\(.*\)/\1/'`
fi

# ITER_LAST=$(/bin/ls -1 *.64.* | tail -n1 | awk -F"." '{print $NS}')
}

0 comments on commit 1dac9c4

Please sign in to comment.