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/shallow |
specify the name and location of the executable after compilation |
shallow.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 shallow_serial.sh
and copy the content of the code block below.
#!/bin/bash
#SBATCH --job-name="shallow serial"
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --time=05:00
#SBATCH --output=shallow_serial_%j.out
# define some variables
PROJECT_DIR="${HOME}/project_info0939"
EXEC_DIR="${PROJECT_DIR}/bin"
INPUT_DIR="${PROJECT_DIR}/example_inputs/simple"
PARAM_FILE="param_simple.txt"
# copy all files from the input directory to
# the directory from which we submitted the job
cp ${INPUT_DIR}/* ${SLURM_SUBMIT_DIR}
# move to the directory from which we submitted the job
cd ${SLURM_SUBMIT_DIR}
# run the simulation
${EXEC_DIR}/shallow ${PARAM_FILE}
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.
%j
will 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_NAME
or${VARIABLE_NAME}
. -
In the script, we use the
the output will be the path to your home directory.HOME
environment variable. The value of the variable is the path to your home directory. If run the following command -
The expression
${INPUT_DIR}/*
use a wildcard. In the context of our script, the wildcard (*
) means "match any files". If we usethen, the expression will match any file starting with
in_
.
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 shallow olouant R 0:30 1 nic5-w070
Once the job is finished, the output should contain
$ cat shallow_serial_7721015.out
Parameters:
- grid spacing (dx, dy): 5 m, 5 m
- time step (dt): 0.05 s
- maximum time (max_t): 200 s
- gravitational acceleration (g): 9.81 m/s^2
- dissipation coefficient (gamma): 2e-05 1/s
- source type: 1
- sampling rate: 40
- input bathymetry (h) file: 'h_simple.dat'
- output elevation (eta) file: 'eta_simple'
- output velocity (u, v) files: 'u_simple', 'v_simple'
- grid size: 4000 m x 4000 m (800 x 800 = 640000 grid points)
- number of time steps: 4000
Computing step 3600/4000 (ETA: 9.46492 seconds)
Done: 95.0937 seconds (26.9208 MUpdates/s)