Compiling and Running a Job on Beskow
Compiling and Allocating Compute Nodes
To compile C programs, the cc
command (small c) should be used. To compile C+++ programs, the CC
command (big C) should be used.
The salloc
command allocates an interactive node. The srun
command will then launch programs on that node. Assuming the name of the binary is hello.out
, to execute this binary on an interactive node, run the following:
$ cd /cfs/klemming/nobackup/u/username
$ salloc --nodes=1 -t 01:00:00 -A edu21.DD2356
$ srun -n 1 ./hello.out
Where --nodes
specifies the number of nodes to be allocated, -t
specifies the duration of allocation and -A
specifies the allocation code which can be found with projinfo
command. In this case, we ran one process interactively through srun
.
There are two kinds of nodes on Beskow that use Haswell and Broadwell processors respectively. If you would like to specifically use Haswell nodes, you can explicitly specify it during salloc
, using -C Haswell
. For example,
$ salloc --nodes=1 -t 01:00:00 -A edu21.DD2356 -C Haswell
Running Jobs
We might also want to submit a batch job with this binary, below follows an example (assuming that we've already compiled the binary with cc
).
First, we'll create a simple script that will go to the right directory in CFS and will execute hello.out
. Create a file named myjob.sh
in your /cfs/klemming/nobackup/<first letter of username>/<username>
directory, containing:
#!/bin/bash -l
# The -l above is required to get the full environment with modules
# The name of the script is myjob
#SBATCH -J myjob
# Only 1 hour wall-clock time will be given to this job
#SBATCH -t 1:00:00
#SBATCH -A edu21.DD2356
# Number of nodes
#SBATCH --nodes=1
#SBATCH -e error_file.e
# Run the executable file
# and write the output into my_output_file
srun -n 1 ./hello.out > hello_output
We can now submit the job.
$ sbatch ./myjob.sh
By using squeue
, we can monitor the job in the queue:
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
----------------------------------------------------------------------
252 main myjob username R 0:01 1 t01n34
After the job has finished, you will find a file named "hello_output" in the same directory as you submitted the job that contains execution results.
$ cat hello_output
Hello World!
Changing Compiler and Compilation Environment
In order to change the compilation environment, we need to load a specific module for a given compiler