This guide provides instructions for installing, compiling and running the ADCIRC hydrodynamic model on Linux (specifically, Ubuntu WSL).
- Visit the ADCIRC GitHub Repo. https://github.com/adcirc/adcirc
- The source code needed for compilation can be downloaded in the terminal using one of the following commands:
$ gh repo clone adcirc/adcirc
(if GitHub CLI is installed)$ git clone https:/github.com/adcirc/adcirc.git
The main libraries needed to run a basic, local run of ADCIRC are the following:
- A Fortran compiler, here we chose GFortran:
gfortran
- The HDF5 Fortran Library, needed by the NetCDF Library:
hdf5-fortran
- The NetCDF Library:
netcdf-bin
- GNU Make, for building executable files:
make
- MPI, for parallel computing:
openmpi
These libraries themselves have dependencies. Following these following commands in order will ensure them working on a clean Linux installation:
$ sudo apt-get update
$ sudo apt-get install gfortran
$ sudo apt-get install make
$ sudo apt-get install cmake
$ sudo apt-get install openmpi-bin
$ sudo apt-get install libopenmpi-dev
$ sudo apt-get install perl
$ sudo apt-get install libhdf5-dev
$ sudo apt-get install libhdf5-fortran-102
$ sudo apt-get install netcdf-bin
$ sudo apt-get install libnetcdff-dev
$ sudo apt-get install libxdmf-dev
Now going in the ADCIRC Source Code folder we downloaded from Git, we will find the work
folder. This folder holds all the parameters and files needed for compiling ADCIRC.
The work/cmplrflags.mk
text file contains the flags needed by the compiler to build ADCIRC.
We will make two modifications to that file.
- Point Make to which compiler to use by uncommenting the following line (which can be found in the very first lines of the file:
compiler=gfortran
. If using a different compiler, please uncomment the equivalent line instead. - Switch the HDF5 Library pointer flag. Ubuntu places the HDF5 Library under a serial subdirectory, leading to an error during compilation where the compiler cannot find the library using the given name:
/usr/bin/ld: cannot find -lhdf5_fortran: No such file or directory
Changing every instance of -lhdf5_fortran
to the correct -lhdf5_serial_fortran
flag in cmplrflags
fixes this issue.
If working in a terminal, this can quickly be done using the built-in nano
terminal text editor. Following the next steps will help you perform this quick edit:
$ cd adcirc/work
Enter theadcirc/work
folder if you haven’t done so yet.$ nano cmplrflgs.mk
Open the compiler flags file in the text editor.- Hit the
Ctrl+\
keyboard shortcut to replace a string. Type in-lhdf5_fortran
in theSearch (to replace):
field and hit enter. - Type in
-lhdf5_serial_fortran
in theReplace with:
field and hit enter. - Hit
A
to replace all occurrences. It should have replace 10 occurrences. - Navigate using the arrow keys to uncomment the
compiler=gfortran
line. - Hit the
Ctrl+X
keyboard shortcut to close the file, confirming to save and using the same file name.
We are ready to compile! The following steps will compile ADCIRC with NetCDF support, letting it write its output files in the (easier to use and friendlier to 3rd-party tools) NetCDF format (.nc files).
Assuming you are still in the adcirc/work
folder:
-
$ chmod +x config.guess
To update the permissions of theconfig.guess
file, which figures out your current hardware configuration. -
$ make adcirc NETCDF=enable NETCDFHOME=/usr NETCDF4=enable
Compiles ADCIRC with NetCDF support.- The NETCDFHOME flag can be added to
cmplrflgs.mk
to avoid typing it everytime. Make sure to add it under the correct compiler mode. Here this will be under gfortran, look for the faollowing line in the file:
ifeq ($(compiler),gfortran)
- The NETCDFHOME flag can be added to
-
Type in
$ dir
to make sure the executableadcirc
was successfully created. If yes, the model can be executed using the command:./adcirc
(which will terminate because this current location has no input files to work with). -
While this command will only work in the same folder where the executable is, forcing you to copy it to other directories, we can add it to the PATH variable, letting us access from any directory.
$ cd ~
to return to the home directory.$ nano .bashrc
To edit your system paths.- At the very bottom of the file write in the following line:
export PATH="~/path/to/adcirc/work/:$PATH"
Where
~/path/to/adcirc/work/
is the path to your the folder where the executable adcirc file is located, here~/adcirc/work/
.Save and exit. Run
$ source ~/.bashrc
to reload your PATH configuration. You should now be able to call ADCIRC from any directory using the simple$ adcirc
command.Some additional steps are required to compile savio on HPC Savio.
- NetCDF library adjustments
- Add NETCDFHOME and FLIB paths to
cmplrflgs.mk
Involves compiling and running a couple extra files
Compile adcprep with NETCDF/4 support
Compile padcirc with NETCDF/4 support
run these to prep the files (where —np 8 is the number of processors to be used):
./adcprep --np 8 --partmesh ./adcprep --np 8 --prepall
then call padcirc with openmpi:
mpirun -np 8 ./padcirc
Conda does not come preinstalled on Ubuntu and requires a few command lines to get installed through the terminal:
-
Download the installation script:
$ wget <https://repo.anaconda.com/archive/Anaconda3-2023.09-0-Linux-x86_64.sh>
This url will change depending on the version that you want and follows this naming convention:
https://repo.anaconda.com/archive/Anaconda3-YYYY.MM-#-Linux-x86_64.sh
-
Give permission to script:
$ chmod +x Anaconda3-2023.09-0-Linux-x86-64.sh
-
Run bash and follow instructions:
$ ./Anaconda3-2023.09-0-Linux-x86-64.sh
-
cd Add Conda to path by modifying
.bashrc
:$ nano .bashrc
- Add the following line at the end:
export PATH="~/anaconda3/bin:$PATH"
- Save and close the file.
$ source ~/.bashrc
to reload bash configuration.
-
Make new env:
$ conda create -n <env-name>
-
Activate environment with:
$ conda activate <env-name>
or$ source activate <env-name>
- Activate environment if you already have one.
- Visit the Kalpana Github Repo. https://github.com/ccht-ncsu/Kalpana.git
- Clone the source code:
$ git clone https://github.com/ccht-ncsu/Kalpana.git
- Kalpana has some required dependencies which can be found in the
Kalpana/install/requirements.txt
text file. We can install all the dependencies using pip:cd Kalpana/install
Navigate to the install folder.- Install the dependencies using:
$ pip install -r requirements.txt
or$ pip install . e
in more recent versions.
- I have found that Kalpana implicitly needs the PostgreSQL Database Adapter to work properly. This can be fixed by:
$ sudo apt-get install libpq-dev
$ pip install psycopg2
- We can add
kalpana.py
and the other scripts to PATH so that their functions can be accessed from any directory:$ nano ~/.bashrc
- Add the following line:
export PATH="~/Kalpana/kalpana:$PATH"
- Save and close the file.
$ source ~/.bashrc
to reload bash configuration.
-
Activate environment if you already have one.
-
Install ADCIRCPy using pip:
$ pip install adcircpy
We’re done installing! Now to run an example model. Thankfully adcirc offers a test suite that we can clone from GitHub.
- Visit the ADCIRC Test Suite Github Repo. https://github.com/adcirc/adcirc-testsuite
- Clone the Test Suite:
$ git clone https:/github.com/adcirc/adcirc-testsuite.git
- There will be many examples under the
adcirc-testsuite/adcirc
folder, Let’s try to run the global tide example:$ cd adcirc-testsuite/adcirc/adcirc_global-tide-2d
- Notice the existence of
fort.13
,fort.14
, andfort.15
files in this directory. These are your input files. - Call
$ adcirc
. If the adcirc executable was correctly added to path earlier this should work and the model will start running! (Note that this example will need to output in NetCDF, so the adcirc should have been compiled with NetCDF enabled, if not, we can quickly go recompile it using previous steps. Remember to run$ make clean
before recompiling). $ ls
to display files in the directory after complete run. Notice new files were added. These are output files that can be used for visualization.
- Visualize! We can quickly visualize the max elevations using ADCIRCPy directly in the terminal assuming it was installed correctly:
$ plot_maxele maxele.63.nc
A window should open with a plot of the maximum elevations at every node!- Visit the following site for documentation on the CLI and Library functionalities of ADCIRCPy: ADCIRCPy — adcircpy 1.2.7.post7.dev0+2263910 documentation
- Visit the following site for documentation and descriptions of ADCIRC’s output files: Output File Descriptions - ADCIRC
- Kalpana can be used to post-process and make nicer plots in Python/Jupyter notebooks and is a more powerful visualization tool.
- Automatic run configuration and hurricane forcing using ADCIRCPy.
- Visualization and Post-Processing Using Kalpana.