Table of Contents

Standard format for Wiki Scripts

It is suggested that example scripts on this wiki follow a certain standard format, so that they are kept consistent and easy to adapt to running in different environments. The main idea is that at the top of the script, a few standard bash variables and functions are defined for the things that are done differently at different supercomputer centers.

Standard Script Functions / Variables

The submit_job bash function

This is a bash function meant to declared at the top of the example script which takes a single parameter, <job_name>, which is the name of the job to be queued on the cluster. The script writes a cluster submit script as “<job_name>.q” and fills it with instructions read on stdin.

Note that this function should not take arguments for parameters like running time, number of CPUs or similar. These parameters are meant to be configured by editing the contents of this function. (This way you do not need to hunt around in the script updating every '2' → '4' when you want to run on 4 cpus instead on 2.) If your script need to submit jobs with more than one set of parameters, see “multiple submit_job functions” below.

Typically the script is invoked like this:

submit_job mytestjob <<EOF
echo "test job starts"
$RUN_VASP5
echo "test job ends"
EOF

The standard implementation to include in scripts on the wiki (which works on NSC):

function submit_job {
cat > "${1-job}.q" <<EOF
#!/bin/bash
#SBATCH -A liu1
#SBATCH -p green
#SBATCH -t 23:59:59
#SBATCH -N 2
#SBATCH -J ${1-job}

echo "RUN STARTS: \$(date)"
$(cat -)
echo "RUN ENDS: \$(date)"
EOF
sbatch "${1-job}.q"
}

Multiple submit_job for different types of jobs

Define each submit_job function as above. Keep the name of the submission function for “normal jobs” named “submit_job”, and name the alternatives according to this standard:

  1. submit_job_single: submit on only one node
  2. submit_job_short: submit with a shorter time limit
  3. submit_job_long: submit with a longer time limit

if you need something not covered here, give it a sensible name and edit this wiki page to add it.

Variables defining how to run codes

Alongside (right above) the declaration of the submit_job function a number of variables should be setup that specifies how a specific code is to be executed.

Typical implementation (which works on NSC):

RUN_VASP5="mpirun /path/to/vasp.5.2.12"

Standard names are:

  1. RUN_VASP5: Latest available vasp 5 version
  2. RUN_VASP4: Latest available vasp 4 version
  3. RUN_VASP5.2.12: Specific vasp 5 version
  4. RUN_EMTO: Latest available version of EMTO code
  5. RUN_EXCITING: Latest available version of exciting.

Simple Example Script

This is the most basic script you can do. It just simply runs vasp5 once.

#!/bin/bash

function submit_job {
cat > "${1-job}.q" <<EOF
#!/bin/bash
#SBATCH -A liu1
#SBATCH -p green
#SBATCH -N 2
#SBATCH -t 23:59:59
#SBATCH -J ${1-job}

echo "RUN STARTS: \$(date)"
$(cat -)
echo "RUN ENDS: \$(date)"
EOF
sbatch "${1-job}.q"
}

RUN_VASP5="mpirun ~/bin/pvasp.5.2.12.vdw.wannier.mkl"

submit_job testjob <<EOF
echo "test job starts"
$RUN_VASP5
echo "test job ends"
EOF

Scripting in Python

<WIKI-TODO: fill in how to make similar definitions in python scripts>

For advanced users, scripting framework

Advanced users can setup a helper script that automatically selects among several possible definitions of the standard functions above, removing the need of individually adapting each and every example script. One simply just replace the definition of the standard functions above with a call to a helper script:

. ~/bin/helpers/setup.sh

<WIKI-TODO: fill in info for definition of helper scripts>