-
Notifications
You must be signed in to change notification settings - Fork 0
HAFS online tutorial
This tutorial serves as a guide to learning how to use the Hurricane and Forecast System (HAFS) through a series of practical tests that explore the various capabilities of the model.
This tutorial is based on the latest version of HAFS, and contains information about the prerequisites, installation and building process that are also available in the HAFS User's Guide. The tests can be run in any order, although it is recommended to follow the established order for a better understanding of the model.
The examples in this tutorial are tailored be run on the Mississippi State University's High Performance Computing System (MSU-HPC). The MSU-HPC consist of two components, Orion and Hercules that share a InfiniBand interconnect and two Lustre file systems, "/work/" and "/work2/". In this tutorial, we will use Hercules.
To get a MSU-HPC, contact your project's Account Manager to submit an account request. Once the account is fully set up, you can login to MSU-HPC. To login to Orion or Hercules via SSH, you will have to use your MSU account username, MSU password, and Duo two-factor authentication.
Hercules login nodes are available externally via SSH.
- Linux/Mac users can use the standard ssh client for logging in: ssh -Y username@hercules-login.hpc.msstate.edu
- Windows users can use one of the well-known clients such as Putty or Windows PowerShell.
-
To install Putty and Xming (for X11 window forwarding) if they are not yet installed/available on your device:
-
You can login using Putty as shown below:

-
To use Windows PowerShell
$env:DISPLAY='localhost:0.0'
ssh -Y username@hercules-login.hpc.msstate.edu
-
After logging into Hercules, the next step is to set up the proper shell environment. To do so, you can edit ~/.bashrc and source ~/.bashrc. This step involves editing files. To become more familiar with text editors and basic commands, refer to the reference section for a Vim cheatsheet. It can also be useful to acquaint yourself with basic Linux commands, see the reference section for a Linux commands cheatsheet.
Edit .bashrc and add the following:
$ vi ~/.bashrc
module use /apps/contrib/modulefiles
module load rocoto
module load noaatools
module use /work/noaa/hwrf/soft/modulefiles
module load emc-utils/1.1.0
module load imagemagick
Optional to alias for slurm related commands in .bashrc
alias sq='squeue'
alias squ='squeue -u ${USER}'
alias sqj='squeue -j'
alias sqp='squeue -p'
alias sqq='squeue -q'
alias si='sinfo'
alias ssj='scontrol show job'
Also optional to alias for commonly used dirs in .bashrc
alias tsv2='cd /work2/noaa/hwrf/tutorial/save/${USER}'
alias tns2='cd /work2/noaa/hwrf/tutorial/noscrub/${USER}'
alias tsc2='cd /work2/noaa/hwrf/tutorial/scrub/${USER}'
Then source .bashrc
$ source ~/.bashrc
This section provides the instructions to obtain the source code from the HAFS Github repository, build and install HAFS, and configure the model to run it. The guidelines provided here to download, build and install HAFS are customized for this tutorial. For more detailed directions on downloading any other branch from the HAFS Github repository, please refer to the HAFS User's Guide
Before cloning the HAFS repository, you will need to create a directory to copy the source code and run HAFS, tokeep the tutorial tests separte from other work.
$ mkdir -p /path-of-hafs-directory/
$ cd /path-of-hafs-directory/
Once you are in the directory where you want to copy the source code,the next step is to clone the source code from the HAFS Github repository using the following command:
$ git clone <-b BRANCH> --recursive https://github.com/hafs-community/HAFS.git ./
The BRANCH for this tutorial is feature/hafs-ncas-m
Simply set <-b BRANCH> option to the branch name
After cloning and checking out the tutorial branch, go to the sorc directory to build and install HAFS
$ cd /path-of-hafs-directory/sorc
$ ./install_hafs.sh > install_hafs.log 2>&1
This step could take ~30 mins or longer. If you got any errors during this step, look into the '/sorc/logs' directory
The install_hafs.sh script conducts the following steps:
- Run ./build_all.sh to build executables for all HAFS subcomponents and tools
- Run build_forecast.sh, build_post.sh, build_tracker.sh, build_utils.sh, build_tools.sh, build_gsi.sh, build_hycom_utils.sh, build_ww3_utils.sh
- The above build_*.sh can also run individually to build the specific subcomponent only
- Run ./install_all.sh to copy and install all executables
- Run ./link_fix.sh to link fix directories and files
- Copy platform specific system.conf file
After successfully installing HAFS, check and edit HAFS system.conf, and ensure that it has the appropriate configuration
$ cd /path-of-hafs-directory/parm
$ cp system.conf.<'''system'''> system.conf
$ vi system.conf
where <'''system'''> in this case is hercules
disk_project=hwrf
tape_project=emc-hwrf
cpu_account=hurricane
archive=disk:/work2/noaa/{disk_project}/tutorial/noscrub/{ENV[USER]}/hafsarch/{SUBEXPT}/{out_prefix}.tar
CDSAVE=/work2/noaa/{disk_project}/tutorial/save/{ENV[USER]}
CDNOSCRUB=/work2/noaa/{disk_project}/tutorial/noscrub/{ENV[USER]}/hafstrak
CDSCRUB=/work2/noaa/{disk_project}/tutorial/scrub/{ENV[USER]}
syndat=/work/noaa/hwrf/noscrub/input/SYNDAT-PLUS
To run HAFS, change directories and go to the /rocoto directory to modify the workflow driver (e.g. cronjob_hafs.sh). Make sure HOMEhafs is correct
$ cd /path-of-hafs-directory/rocoto
$ vi cronjob_hafs.sh
After modifying the script, you can repeat running the driver periodically, or add it as a cron task to advance the workflow
-
Manually:
$ ./cronjob_hafs.sh -
Set up a cron task to run periodically:
$ crontab -e*/5 * * * * /path-of-hafs-directory/rocoto/cronjob_hafs.sh
To set up the cron task you need to login login-node-1. This can be done with the following command:
$ ssh hercules-login-1
The practical tests in this tutorial will guide you to further explore and comprehend the steps to run HAFS with specific configurations.
Hurricane Ida made landfall near Port Fourchon, Louisiana, on August 29, 2021, as a Category 4 hurricane with sustained winds of 150 mph. Ida is one of the costliest Atlantic hurricanes in the United States, having caused at least $75.25 billion (2021 USD) in damages. A total of 107 deaths were attributed to Ida, including 87 in the USA and 20 in Venezuela.

This first test will generate a 12h forecast for the 20210827 12Z cycle of Hurricane Ida (2021), using a regional standalone 6-km resolution storm-focused configuration with the Extended Schmidt Gnomonic (ESG grid), with no moving nest. The run uses GFS (Global Forecast System) 0.25 degree resolution grib2 format input data for atmospheric initial and lateral boundary conditions. The test is a coldstart run from GFS. We won't be using vortex initialization or data assimilation. The test uses an atmospheric only configuration, with no ocean coupling and uses the GFDL MP scheme.
To run HAFS with the configuration described above we are going to use the cronjob driver cronjob_hafs_tutorial_test0.sh. To do so you will first have to change into the rocoto directory. where the cronjob driver is located, and check that the script has the right information, making sure that the HOMEhafs dir is correct.
$ cd /path-of-hafs-directory/rocoto
$ vi cronjob_hafs_tutorial_test0.sh

As shown in the example above, the cronjob driver establishes the cycle and storm to be run and configuration
Before running the cronjob driver, we are going to review the configuration of the run, to make sure it matches the intended configuration. To do so, we change into the parm directory and check the configuration file defined in the cronjob driver hafs_regional_atm.conf
After reviewing the configuration, it is time to run the driver. To do so change back into the rocoto directory and execute the driver.
-
Manually:
$ ./cronjob_hafs_tutorial_test0.sh -
Set up a cron task to run periodically:
On Hercules, cron is only available on the hercules-login-1 node
$ ssh hercules-login-1
$ crontab -e*/4 * * * * /bin/sh -l -c /path-of-hafs-directory/rocoto/cronjob_hafs_tutorial_test0.sh >> /path-of-hafs-directory/rocoto/cronjob_hafs_tutorial_test0.log 2>&1
To check the rocoto workflow related files, after running the driver, use the following command to list the files
$ ls -1 hafs-hafs_202405_tutorial_test0-09L-2021082712*
The following files should be generated:

The cronjob driver should also have submitted the launch or other jobs/tasks.
You can check the Slurm jobs through "squ"
$ squeue -u ${USER}
Or through the "qac" command
$ qac
Note: if qac command does not work, please run the “gem install rexml” command first.
You can use Rocoto commands to check the status and rewind the Rocoto worflow taks. For example:
$ rocotostat -w hafs-hafs_202405_tutorial_test0-09L-2021082712.xml -d hafs-hafs_202405_tutorial_test0-09L-2021082712.db

For more information about rocoto:
https://github.com/christopherwharrop/rocoto/
https://christopherwharrop.github.io/rocoto/
You can also check the status of the rocoto workflow and rewind failed tasks with rocoto/rocoto_util.sh
$ ./rocoto_utils.sh [-a | -f | -r | -s]
-a: check all active (SUBMITTING|QUEUED|RUNNING|DEAD|UNKNOWN|FAILED|UNAVAILABLE) tasks
-f: check all failed (DEAD|UNKNOWN|FAILED|UNAVAILABLE) tasks
-r: check and rewind all failed (DEAD|UNKNOWN|FAILED|UNAVAILABLE) tasks
-s: check status for all tasks
You can use the script for a specific workflow as follows:
- Check active tasks for a specific workflow:
- $ ./rocoto_util.sh -a hafs-hafs_202405_tutorial_test0-09L-2021082712
- $ ./rocoto_util.sh -a hafs-hafs_202405_tutorial_test0-09L-2021082712
- Check task status for a specific workflow:
- $ ./rocoto_util.sh -s hafs-hafs_202405_tutorial_test0-09L-2021082712
- $ ./rocoto_util.sh -s hafs-hafs_202405_tutorial_test0-09L-2021082712
- Rewind failed tasks for a specific workflow:
- $ ./rocoto_util.sh -r hafs-hafs_202405_tutorial_test0-09L-2021082712
- $ ./rocoto_util.sh -r hafs-hafs_202405_tutorial_test0-09L-2021082712
Alternatively, you can check active tasks, all task status and rewind all failed tasks for all workflows under current directory as follows:
- $ ./rocoto_util.sh -a
- $ ./rocoto_util.sh -s
- $ ./rocoto_util.sh -r
When running HAFS, it might be necessary to check the jobs log files. Typically the log files are located in the WORKhafs directory with the following naming convention:
WORKhafs=/CDSCRUB_directory/experiment_name/cycle_date_and_time/storm_id
To find the directory:
$ cat /path-of-hafs-directory/parm/system.conf
Search for CDSCRUB and list files
$ ls /CDSCRUB_directory/experiment_name/cycle_date_and_time/storm_id
For example, in Hercules when running experiment hafs_202405_tutorial_test0 for Ida (09L) for cycle 2021082712 in directory:
HOMEhafs=/work2/noaa/hwrf/tutorial/save/${USER}/hafs_202405
The log files are located in the directory:
WORKhafs=/work2/noaa/hwrf/tutorial/scrub/${USER}/hafs_202405_tutorial_test0/2021082712/09L
To list the log files:
$ ls /work2/noaa/hwrf/tutorial/scrub/${USER}/hafs_202405_tutorial_test0/2021082712/09L

The workflow products are located under the COMhafs directory with the following naming convention:
COMhafs=/CDSCRUB_directory/com/experiment_name/cycle_date_and_time/storm_id
To find the directory:
$ cat /path-of-hafs-directory/parm/system.conf
Search for CDSCRUB
$ ls /CDSCRUB_directory/experiment_name/cycle_date_and_time/storm_id
For example, in Hercules when running experiment hafs_202405_tutorial_test0 for Ida (09L) for cycle 2021082712 in directory:
HOMEhafs=/work2/noaa/hwrf/tutorial/save/${USER}/hafs_202405
The workflow products are located in the directory:
COMhafs=/work2/noaa/hwrf/tutorial/scrub/${USER}/hafs_202405_tutorial_test0/com/2021082712/09L
$ ls /work2/noaa/hwrf/tutorial/scrub/${USER}/hafs_202405_tutorial_test0/com/2021082712/09L

After succesfully running HAFS, check forecast job log and results use ncview to view forecast history outputs (atmfhhh.nc,sfcfhhh.nc, e.g.)
Load the necessary modules:
$ module use /path-of-hafs-directory/modulefiles
$ module load hafs.hercules
$ module load ncview
$ module list
Change into the directory with the results
$ cd /CDSCRUB_directory/experiment_name/cycle_date_and_time/storm_id/forecast
To check the forecast job log, you can use the following command:
$ vi forecast.log
To use ncview to view forecast output you can use the following command:
$ ncview NETCDF_FORMAT_FILE
For example:
$ ncview atmf012.nc &
$ ncview sfcf012.nc &
This will show the 12-h forecast results
The test described in this section is similar to Test 0 that employed a regional standalone 6-km resolution storm-focused configuration, but this time using moving-nesting. This test will generate a 12h forecast for the 20210827 12Z cycle of Hurricane Ida (2021), with a regional coarse-resolution storm-focused moving-nesting configuration with the Extended Schmidt Gnomonic (ESG grid). This test uses a 12-km resolution parent domain with a 4-km resolution storm-following moving nest. For initial conditions (IC) we will use GFS NetCDF format analysis, and 0.25 degree resolution grib2 formast forecast for lateral boundary conditions (LBC) The test is a coldstart run from GFS. We won't be using vortex initialization or data assimilation. The test uses an atmospheric only configuration, with no ocean coupling and uses a HAFSv2A-like NATL physics suite (with Thompson microphysics). As shown in the diagram below, the workflow of this test is similar to the workflow for Test 0, with the addition of the atm_prep_mvnest task.
To run HAFS with the configuration described above we are going to use the cronjob driver cronjob_hafs_tutorial_test1.sh. To do so you will first have to change into the rocoto directory where the cronjob driver is located, and check that the script has the right information, making sure that the HOMEhafs dir is correct.
$ cd /path-of-hafs-directory/rocoto
$ vi cronjob_hafs_tutorial_test1.sh
Before running the cronjob driver, we are going to review the configuration of the run, to make sure it matches the intended configuration. To do so, we change into the parm directory and check the configuration file defined in the cronjob driver hafs_tutorial_test1.conf

After reviewing the configuration, it is time to run the driver. To do so change back into the rocoto directory and execute the driver.
-
Manually:
$ ./cronjob_hafs_tutorial_test1.sh -
Set up a cron task to run periodically:
On Hercules, cron is only available on the hercules-login-1 node
$ ssh hercules-login-1
$ crontab -e*/4 * * * * /bin/sh -l -c /path-of-hafs-directory/rocoto/cronjob_hafs_tutorial_test1.sh >> /path-of-hafs-directory/rocoto/cronjob_hafs_tutorial_test1.log 2>&1
The cronjob driver should also have submitted the launch or other jobs/tasks, incluiding the atm_prep_mvnest task.
This practical test explores a coupled configuration with VI and DA. Similar to Test 1, this test generates a 12h forecast for the 20210827 12Z cycle of Hurricane Ida (2021) using a moving nest, where the parent domain has a 12-km resolution, and the moving nest has a 4-km resolution. This test uses VI and MOM6 ocean coupling, but without DA and one-way wave (WW3) coupling turned off. A shown in the diagram below, the workflow now includes tasks atm_init, atm_vi, analysis_merge, ocn_prep and ocn_post.
- atm_init: Interpolates GFS analysis into model grid
- atm_vi: Conducting VI
- analysis_merge: Merges VI output data into GFS background analysis to prepare the forecast input file
- ocn_prep: Preparing RTOFs input data for MOM6
- ocn_post: Generates ocean products
To run HAFS with the configuration described above we are going to use the cronjob driver cronjob_hafs_tutorial_test3.sh. To do so you will first have to change into the rocoto directory where the cronjob driver is located, and check that the script has the right information, making sure that the HOMEhafs dir is correct.
$ cd /path-of-hafs-directory/rocoto
$ vi cronjob_hafs_tutorial_test3.sh
Before running the cronjob driver, we are going to review the configuration of the run, to make sure it matches the intended configuration. To do so, we change into the parm directory and check the configuration file defined in the cronjob driver ../parm/tutorial/hafs_tutorial_test3.conf
After reviewing the configuration, it is time to run the driver. To do so change back into the rocoto directory and execute the driver.
-
Manually:
$ ./cronjob_hafs_tutorial_test3.sh -
Set up a cron task to run periodically:
On Hercules, cron is only available on the hercules-login-1 node
$ ssh hercules-login-1
$ crontab -e*/4 * * * * /bin/sh -l -c /path-of-hafs-directory/rocoto/cronjob_hafs_tutorial_test3.sh >> /path-of-hafs-directory/rocoto/cronjob_hafs_tutorial_test3.log 2>&1
The cronjob driver should also have submitted the launch or other jobs/tasks, incluiding tasks atm_init, atm_vi, ocn_prep, analysis_merge, ocn_post.

To plot the final VI and GFS analysis field before VI with the following steps:
- Copy Copyexec.sh to your atm_vi directory (e.g., /CDSCRUB_directory/experiment_name/cycle_date_and_time/storm_id/atm_vi) from /work2/noaa/hwrf/noscrub/jhshin/VI_Hercules/Copyexec.sh on Hercules.
- Run Copyexec.sh to copy the necessary executable files that can plot the VI binary output files
- Run the script file Runexec.sh
- Use GrADS and ctl files to plot the VI output
- Plot-storm_anl_combine.ctl (Final VI output)
- Plot-vi_inp_30deg0p02.ctl (GFS analysis field before VI)
More information about GrADS: http://cola.gmu.edu/grads/gadoc/gadoc.php
- Plot-storm_anl_combine.ctl (Final VI output)
The cronjob driver of Test 3, contains a section that allows to run the test using data assimilation. To enable the data assimilation configuration follow the next steps:
- Check and edit cronjob_hafs_tutorial_test3.sh to use ../parm/tutorial/hafs_tutorial_test3a.conf
- Review configuration file ../parm/tutorial/hafs_tutorial_test3a.conf
- Run the cronjob driver
Now, on top of Test 3, data assimilation through GSI is further turned on
The workflow will look as following:

HAFS graphics are run for every storm and forecast cycle. For active storms, graphics are available for both operational HFSA and HFSB
The python scripts used to generate the graphs are located in the following Github repository:
https://github.com/hafs-community/hafs_graphics
To clone the repository in your local directory:
$ cd /path-of-hafs-directory
$ mkdir hafs_graphics
$ cd hafs_graphics
$ git clone -b production/hafs.v2 https://github.com/hafs-community/hafs_graphics.git ./
The graphics that can be generated include:
- ATCF - To plot track and intensity
- Atmos - To plot variables like mean sea level pressure, surface temperature, heat fluxes, vertical wind shear
- Ocean - To plot sea surface temperature, sea surface salinity, ocean heat content
HAFS graphics can be run as part of the HAFS workflow. To do so, turn on emcgraphics by adding config.run_emcgraphics=yes into the cronjob driver
Example: In the driver, set config.run_emcgraphics=yes

It can also be run from the HAFS graphics package, using the following drivers in /path-of-hafs-directory/hafs_graphics/run:
- jobhafsATCF.sh
- jobhafsatmos_orion.sh
- jobhafsocean_orion.sh
These drivers are platform dependent, and not yet set up for Hercules.
Lastly, you can run the Python scripts manually.
-
Load the Python environment
$ module purge
$ module use /path-of-hafs-directory/sorc/hafs_graphics.fd/emc_graphics/modulefiles
$ module load graphics.run.hercules
$ module list -
Locate the Python code $ cd /path-of-hafs-directory/sorc/hafs_graphics.fd/emc_graphics/ush/python/
There are three directories: ATCF, atmos, ocean Using the ocean directory as an example, it contains:
- plot_* files: scripts that produce the figures
- plot_ocean.yml: file that needs to be edited with the location of the HAFS output and storm information
- plot_* files: scripts that produce the figures
-
Edit the plot_ocean.yml
$ vi plot_ocean.yml
stormModel: HFSA
stormName: IDA
stormID: 09L
stormBasin: AL
ymdh: '2021082712'
fhhh: f024
trackon: 'yes'
COMhafs: /work2/noaa/hwrf/tutorial/scrub/bliu/hafs_202405_tutorial_test4/com/2021082712/09L cartopyDataDir: /work/noaa/hwrf/noscrub/local/share/cartopy -
Run a Python script
$ ipython
$ run plot_storm_ohc.py
$ display IDALIA10L.2023082718.HFSA.ocean.storm_ohc.f024.png
User Guide Quickstart
User Guide
Vim Cheatsheet
Linux commands cheatsheet