Installation and Run¶
SWAN can be installed and run on various platforms, including Windows, Linux, and macOS. The installation process typically involves downloading the SWAN source code or pre-compiled binaries from the official SWAN website or repository, followed by setting up the necessary environment variables. User can access the materials from following link and download the suitable version for their operating system.
Windows¶
-
Download the Windows installer from the SWAN website.
-
Run the installer and follow the on-screen instructions to complete the installation.
-
Set up environment variables if necessary.
-
Important note = SWAN on Windows usually works in serial mode (only using one CPU core). For parallel simulation, consider using Linux or WSL2.
Linux¶
- Install supporting libraries and compilers (e.g., gfortran).
- Choose compilers
- Download desired SWAN version
- Extract and navigate to the extracted directory
- Build using OMP (OpenMP) for parallel processing
- Start compiling
-
Compiling OMP
-
During the installation process, users may encounter an issue in the compilation step (make config).
-
This issue can be resolved by modifying the macros.inc to include the flag -fallow-argument-mismatch in the FFLAGS section. This flag allows for more flexibility in argument matching during compilation, which can help resolve compatibility issues with certain Fortran compilers.
-
Turn the swanrun file executable by using the command below:
-
Move the swanrun and swan.exe files to the desired working directory where the user wants to run the SWAN model.
-
To run the SWAN model, user need to make sure that the required files such as input files (wind and bathymetry), configuration/namelist file (.swn), initial and boundary condition files (if available) are in the same directory as the swanrun or swan.exe file. Then, execute the following command in the terminal or command prompt:
Important note = If user install in cluster or HPC, usually user are not allowed to run the model directly in the login node like in point 12. So, to run the SWAN model user need to use sbatch script to create a job. An example of sbatch script for running SWAN in cluster or HPC environment is provided below:
#!/bin/bash
#SBATCH --job-name=swantest
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=24
#SBATCH --exclusive
module load mpi/2021.5.1
module load compiler/2022.0.2
time srun ./swanrun -input [your_namelist_file] -omp $SLURM_CPUS_PER_TASK
echo "Job completed successfully."
exit 0
Credits of installation = Javier Rodriguez