Submit a job for the serial version of the project
This section put everything that has been discussed previously together in order to submit a job running the serial version of the project.
Prepare your environment
Once we are logged in to NIC5, we will load the module that set up the
environment for the project. The module name Info0939Tools and we load it with
Loading this module gives us access to the get_info0939_project command. We
can use this command to get starting point source code and example inputs for
the project.
Next, we use the cd command to move to the project_info0939 directory.
Compile your code
Now that we have the source code, we can compile it to produce an executable.
Here, we will put the executable in a directory with name bin. For that,
we create a directory with mkdir and then we use gcc to compile the code.
In the table below, a summary of the options used and their meaning.
| Meaning | |
|---|---|
-O3 |
enable optimization at the O3 level |
-Wall |
enable all compiler warnings |
-o bin/fdtd |
specify the name and location of the executable after compilation |
fdtd.c |
the source file |
-lm |
link with the math library (libm) |
Submit a job
Now that we have an executable, we will create a directory from which we will submit a job.
Good practice
It's considered good practice to create a new directory for each job you submit.
To submit the job, we will create a text file with name fdtd_serial.sh
and copy the content of the code block below.
#!/bin/bash
#SBATCH --job-name="fdtd serial"
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --time=05:00
#SBATCH --output=fdtd_serial_%j.out
# define some variables
PROJECT_DIR="${HOME}/project_info0939"
EXEC_DIR="${PROJECT_DIR}/bin"
# move to the directory from which we submitted the job
cd ${SLURM_SUBMIT_DIR}
# run the simulation
${EXEC_DIR}/fdtd 1
To save the changes to the file, press the Ctrl+X keys then press Y to confirm you want to save the change and finally, press Enter to confirm the name of the file you want to write.
Additional details about the job batch script
-
The following line for the Slurm output specification:
means that the job ID will be inserted in the name of the output file.
%jwill be automatically replaced by Slurm and set to the job ID. -
In the script we use variables to define various paths. A variable is defined with
Once a variable is defined it can be used using
$VARIABLE_NAMEor${VARIABLE_NAME}. -
In the script, we use the
the output will be the path to your home directory.HOMEenvironment variable. The value of the variable is the path to your home directory. If run the following command
The next step is to submit the job to the queue
and check the status of the job using the squeue command
$ squeue --me
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
7721015 batch fdtd ser olouant R 0:30 1 nic5-w070
Once the job is finished, the output should contain