Okay, let's look at an example of what a "job contract" – more formally known as a job submission script – might look like. The syntax will vary slightly depending on the specific job scheduler being used (e.g., Slurm, PBS/Torque, LSF), but the concepts are very similar.
Slurm (Simple Linux Utility for Resource Management) is currently one of the most popular, so I'll use that for the example.
Here's a typical Slurm job script, often saved as a .sh or .slurm file (e.g., my_simulation_job.slurm):
bash
#!/bin/bash
#
#------------------------------------------------------------------
# SLURM JOB SUBMISSION SCRIPT
#------------------------------------------------------------------
#
# Request a human-readable job name
#SBATCH --job-name=MyProteinSim
# Specify the output and error files.
# %j will be replaced by the job ID. %N by the node name (for array jobs)
#SBATCH --output=protein_sim_output_%j.txt
#SBATCH --error=protein_sim_error_%j.txt
# Specify the "partition" (queue) to run on.
# Common names: debug, short, long, gpu, highmem
#SBATCH --partition=compute
# Specify the project account for billing/tracking (if applicable)
#SBATCH --account=physics-dept
#------------------------------------------------------------------
# RESOURCE REQUESTS ("The Contract" terms)
#------------------------------------------------------------------
#
# Number of nodes to use
#SBATCH --nodes=4
# Number of tasks (MPI processes) to run per node
#SBATCH --ntasks-per-node=32
# Number of CPU cores allocated per task (for multithreaded tasks, e.g., OpenMP)
# If your tasks are purely single-threaded MPI, this is often 1.
#SBATCH --cpus-per-task=1
# Memory requested per node (e.g., 100GB).
# Can also be --mem-per-cpu
#SBATCH --mem=100G
# OR
# #SBATCH --mem-per-cpu=4G
# Maximum wall-clock time for the job (DD-HH:MM:SS)
# If the job runs longer, the scheduler will kill it.
#SBATCH --time=02-12:00:00 # 2 days, 12 hours
# (Optional) Request specific features or constraints
# #SBATCH --constraint=intel # Only run on Intel nodes
# #SBATCH --gres=gpu:volta:2 # Request 2 GPUs of type Volta per node
# (Optional) Email notifications for job status
#SBATCH --mail-type=ALL # (NONE, BEGIN, END, FAIL, REQUEUE, ALL)
#SBATCH --mail-user=your_email@example.com
#------------------------------------------------------------------
# ENVIRONMENT SETUP & EXECUTION
#------------------------------------------------------------------
#
# Clear out any modules loaded by default, then load what we need
module purge
module load gcc/9.3.0
module load openmpi/4.0.5
module load gromacs/2023.1 # Example scientific application
echo "-----------------------------------------------------------------------"
echo "Job ID: $SLURM_JOB_ID"
echo "Job Name: $SLURM_JOB_NAME"
echo "Node List: $SLURM_JOB_NODELIST"
echo "Tasks per node: $SLURM_NTASKS_PER_NODE"
echo "CPUs per task: $SLURM_CPUS_PER_TASK"
echo "Submission Directory: $SLURM_SUBMIT_DIR"
echo "-----------------------------------------------------------------------"
# Change to the directory where you submitted the job (or where your input files are)
cd $SLURM_SUBMIT_DIR
# Or, specify a working directory:
# cd /path/to/my/simulation/input_files
# The actual command to run your simulation
# 'srun' is Slurm's command to launch parallel tasks across the allocated nodes.
# It automatically uses the resources requested above.
echo "Starting GROMACS simulation at $(date)"
srun gmx_mpi mdrun -s topol.tpr -deffnm my_sim_run
echo "GROMACS simulation finished at $(date)"
#------------------------------------------------------------------
# END OF SCRIPT
#------------------------------------------------------------------
How to "sign" and "submit" this contract:
You would save this script as a file (e.g., my_simulation_job.slurm) on the supercomputer's login node. Then, from the command line, you'd submit it using:
bash
sbatch my_simulation_job.slurm
The scheduler would respond with a job ID (e.g., Submitted batch job 12345).
Explanation of the "Contract" Terms (the #SBATCH lines):
#!/bin/bash: This is a "shebang," telling the system to execute the script with the Bash shell.
#SBATCH --job-name=MyProteinSim: Gives your job a name, making it easier to find in the queue.
#SBATCH --output=... & #SBATCH --error=...: Specifies where the standard output and standard error from your program should be written. %j is a placeholder for the unique job ID.
#SBATCH --partition=compute: Tells the scheduler which "queue" or "partition" of the supercomputer to use. Different partitions might have different hardware, time limits, or priorities.
#SBATCH --account=physics-dept: For systems that track usage by department or project (often for internal accounting or grant reporting).
#SBATCH --nodes=4: "I request 4 entire compute nodes."
#SBATCH --ntasks-per-node=32: "On each of those 4 nodes, I want to run 32 separate instances (tasks) of my program." This is typical for MPI (Message Passing Interface) applications. So, total tasks = 4 nodes * 32 tasks/node = 128 tasks.
#SBATCH --cpus-per-task=1: "Each of those 128 tasks will use 1 CPU core." If your tasks were multi-threaded (e.g., using OpenMP alongside MPI), you might request more CPUs per task.
#SBATCH --mem=100G: "Each of the 4 nodes needs to have at least 100 Gigabytes of RAM available for my job." Alternatively, --mem-per-cpu specifies memory per allocated CPU core.
#SBATCH --time=02-12:00:00: "My job will need a maximum of 2 days and 12 hours to run. If it goes over, please terminate it." This is crucial for the scheduler to plan and ensure resources don't get tied up indefinitely.
#SBATCH --gres=gpu:volta:2: (Optional) "I need 2 GPUs of the 'Volta' architecture on each of my 4 nodes." (Generic Resource scheduling).
#SBATCH --mail-type=ALL & #SBATCH --mail-user=...: Sends you emails when the job begins, ends, fails, etc.
The Execution Part:
module purge / module load ...: Supercomputers often have many versions of compilers, libraries, and software. The module system allows you to load the specific environment your application needs.
echo ...: Useful for logging information about the job environment.
cd $SLURM_SUBMIT_DIR: Changes to the directory where you ran the sbatch command.
srun gmx_mpi mdrun ...: This is the actual command that launches your scientific application (gmx_mpi mdrun in this GROMACS example). srun is the Slurm command that intelligently distributes your 128 tasks across the 4 allocated nodes, using the 32 cores per node as requested.
This "contract" allows the scheduler to understand exactly what your job needs, find the appropriate resources, and run it efficiently alongside potentially thousands of other jobs from other users. If you ask for too little (e.g., not enough memory), your job might crash. If you ask for too much (e.g., way more time than needed), your job might sit in the queue longer or prevent other jobs from running.