DCSC logo
 
ABOUT-DCSC
DCSC/SDU
DCSC/AU
DCSC/AAU
DCSC/DTU
DCSC/KU
 
+Open all         -Close all
 
 
#!/bin/csh
#
# PBS jobscript example for running a job avoiding the problem
# of lost files due to runtime exceeding the wallclock request.
#
# The idea is to start a timer which will terminate the running
# program a set amount of time before PBS will terminate the 
# job, thus allowing the relevant "cp" or "mv" commands in the
# PBS script to be run.
#
# Please refer to the other PBS job script examples regarding
# #PBS directives (e.g. pbs_job_script.php).
#
#PBS -l nodes=1
#PBS -m be
#PBS -l walltime=1000 
#

#
# Set some variables used in "timer script".
#
# "timeout" is set to 100 seconds before walltime runs out in
# order to move output files. In this example: 1000 - 100.
#                ***ADJUST AS NEEDED***
#
# "my_program" is set to the name of the executable to be run.
# 
# If the program is a LAM or MPICH MPI program, "my_program"
# should also be set to the name of the executable.
#
# We are of course assuming that a.out is suitable parallelized
# to run on multi-core systems.
#
set my_program = "a.out"
set timeout = 900

#
# Change to the directory where the qsub command was issued.
#
cd $PBS_O_WORKDIR

#
# Copy all files to be used in the run to /scratch
#
cp $my_program input /scratch

#
# Change directory to /scratch.
#
cd /scratch

#
# Create "timer script". And background it.
#
echo '#\!/bin/csh' > timer.script
echo "/bin/sleep $timeout" >> timer.script
echo "/usr/bin/killall -TERM $my_program" >> timer.script
chmod u+x timer.script

./timer.script &

# 
# run $my_program - the program is assumed to read the file
# 'input' and produce 'output'. You are REQUIRED to use /scratch
# for temporary files.
#
./$my_program > output

#
# $my_program has finished (either by itself or killed by the
# timer script) - move the output to $PBS_O_WORKDIR.  Files can
# also be moved to /wkspace1 or /wkspace2. PBS will erase ALL files
# in /scratch after the job is done.
#
mv output $PBS_O_WORKDIR