Skip to main content

Run OpenFOAM codes on Curnagl

Script to run OpenFOAM code

You are using OpenFOAM on your computer and you need more ressources. Let’s go on Curnagl! 

OpenFOAM is usually using MPI. Here is a bash script to run your parallelized OpenFOAM code. NTASKS should be replaced by the number of processors you want to use into your OpenFOAM code.   It is good practice to put your OpenFOAM code in a bash file instead of calling OpenFOAM commands right into the sbatch file.
For instance, create in which you call your OpenFOAM code (replace commands with yours):

# First command
decomposepar ...
# Second command, if you are using a parallel command, CALL IT WITH SRUN COMMAND
srun snappyHexMesh -parallel ...

Then, create a sbatch file to run your OpenFOAM bash file on Curnagl:

#!/bin/bash -l 

#SBATCH --job-name openfoam  
#SBATCH --output openfoam.out 

#SBATCH --partition cpu 
#SBATCH --nodes 1  
#SBATCH --ntasks NTASKS 
#SBATCH --cpus-per-task 1 
#SBATCH --mem 8G  
#SBATCH --time 00:30:00
#SBATCH --export NONE

module purge
module load gcc/10.4.0 mvapich2/2.3.7 openfoam/2206 


bash ./

Please note that running your parallelized OpenFOAM code should not be performed via  mpirun but  srun.  For a complete MPI overview on Curnagl, please refer to compiling and running MPI codes wiki.

How do I transfer my OpenFOAM code to Curnagl ?

You can upload your OpenFOAM code thanks to FileZilla or copy and paste data to the cluster thanks to the scp command. 

Example: I want to copy to Curnagl. I run the following command:

scp <username>

Where YOUR_PATH_ON_CURNAGL is something like /users/username/work/my_folder.

In these commands, do not forget to change <username>  with yours.

This transfer can be done for any file type: .py, .csv, .h, images...

To copy a folder, use the command  scp -r.

For more details, refer to transfer files to/from Curnagl wiki.