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 on one node, resubmitting
# itself until the job is finished. The termination condition is that
# a file will be created when the calculation is done. It's assumed
# that the program will create a file with state information, such that
# until the calculation is done the program can be restarted based on
# that file. It will be called "state_info" in this example.
#
# A PBS batch job script is simply like a shell script - except
# that PBS will pick up commands disguised as comments in the first
# block of comments in the script, as shown here.
#
# The next line requests on node to be used for this batch job.
#
#PBS -l nodes=1
#
# The next line requests that PBS sends an e-mail notification at the
# start of execution and at the end of execution.
#
#PBS -m be
#
# The next line, if one "#" is removed, will specify a maximum wall-clock
# limit of 190 hours (the maximum time for one iteration). If the time
# limit is exceeded the job will be terminated. The format is:
# HOURS:MINUTES:SECONDS.
#
##PBS -l walltime=190:00:00 
#
# The next line, if one "#" is removed, will specify that the job should be
# send to the 'workq' queue.
#
##PBS -q workq
#

#
# 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.
# Ignore the error if state_info does not exist because
# this is iteration number one.
#
cp a.out input state_info /scratch

#
# Change directory to /scratch - and run a.out. a.out is assumed to
# read the file 'input' and 'state_info' (if it exists). a.out 
# produces the files 'output' and 'state_info'. You are REQUIRED to
# use /scratch for temporary files.
#
# We are of course assuming that a.out is suitable parallelized
# to run on multi-core systems.
#
cd /scratch
./a.out

#
# a.out has finished - move the output to $PBS_O_WORKDIR.
# Files can also be moved to /wkspace1 or /wkspace2.
#
mv output state_info $PBS_O_WORKDIR

#
# The program 'a.out' will create a file called 'job_finished' when
# the calculation is done. This can be done assuming that the program
# source code is available and the following can be added at the end:
#
# C-program:
#    #include <stdlib.h>
#    ...
#    system("touch job-finished");
#
# Fortran:
#    CALL SYSTEM("touch job-finished")
#
# If your script file has a different name than "job_script",
# you *MUST* replace "job_script" with the correct name.
#
if ( ! -e job-finished ) then
  sleep 30
  cd $PBS_O_WORKDIR
  /usr/local/bin/qsub job_script
endif

#
# PBS will erase ALL files in /scratch after the job is done.
#