All Products
Search
Document Center

Elastic High Performance Computing:Use WRF to perform high-performance computing

Last Updated:Sep 19, 2022

This topic describes how to run Weather Research and Forecasting Model (WRF) in an Elastic High Performance Computing (E-HPC) cluster for a meteorological simulation.

Background information

WRF is a next-generation mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications. WRF can produce simulations based on actual atmospheric conditions or idealized conditions. The model serves a wide range of meteorological applications. It uses a software architecture that allows for parallel computation and system extensibility. For more information, visit the WRF official website.WRF

Before you begin

  1. Create an E-HPC cluster. For more information, see Create a cluster by using the wizard.

    Configure the following parameters.

    Item

    Description

    Hardware settings

    Deploy a standard cluster that consists of two management nodes, one compute node, and one logon node. All nodes are ecs.c7.large Elastic Compute Service (ECS) instances. Each instance has 2 vCPUs, 4 GiB of memory, and one 2.7 GHz third-generation Intel Xeon Scalable (Ice Lake) processor.

    Software settings

    Deploy a CentOS 7.6 public image and the Slurm scheduler. Turn on VNC.

  2. Create a user. For more information, see Create a user.

    The user is used to log on to the cluster, compile LAMMPS, and submit jobs. Grant the sudo permissions to the user.

  3. Install WRF. For more information, see Install software.

    Install the following software:

    • wrf-mpich V3.8.1

    • wrf-openmpi V3.8.1

    • mpich V3.2

    • openmpi V1.10.7

Step 1: Configure the namelist.wps file

The namelist.wps file is a shared file of WRF Preprocessing System (WPS). It is used to set the parameters of main programs, including geogrid.exe, ungrib.exe, and metgrid.exe. Each main program has an exclusive namelist record named &geogrid, &ungrib, and &metgrid. The three programs have a group record named &share that each program reads. The following example shows the recommended values of the required parameters. For the parameters that are not described in the following example, use the default values. For information about the parameters and parameter descriptions of the namelist.wps file, visit the WRF official website.

Note

In this example, namelist.wps resides in the /home/wrftest/WPS directory.

# &share
&share   
wrf_core = 'ARW',    # wrf_core: Specify the WRF dynamical core. Valid values: ARW and NMM. Default value: ARW. 
start_date = '2005-08-28_00:00:00',   # start_date: Specify the start time of the simulation.
end_date = '2005-08-29_00:00:00',     # end_date: Specify the end time of the simulation.
interval_seconds = 21600,
max_dom = 1,            # max_dom: Specify the total number of model domains, including nests. In this example, a domain is selected.
io_form_geogrid = 2,    # io_form_geogrid: Specify the format of geogrid output files.


# &geogrid
# &geogrid specifies information such as the parent domain, parent-to-nest domain grid size ratio, and map projection.
&geogrid
parent_id = 1,
parent_grid_ratio = 1,
i_parent_start = 1,
j_parent_start = 1,

# Specify the number of grid points in the west-east direction and that of grid points in the south-north direction. In this example, set the values to 98 and 70.
e_we = 98,       
e_sn = 70,
geog_data_res = 'default',

# Specify the grid lengths in the west-east direction and in the south-north direction. Unit: meters. In this example, set the values to 30000 and 30000.
dx = 30000,     
dy = 30000,

# Specify the projection. For more information, visit the WRF official website.
map_proj = 'mercator'

# Specify the latitude and longitude of a known location in the domain.
ref_lat = 25.00,
ref_lon = -89.00,

# Specify the parameters of the map projection. The values vary with projections.
truelat1 = 0.0,   
truelat2 = 0.0,
stand_lon = -89.0,
geog_data_path = 'Path of static geographical data'


# &ungrib
&ungrib
out_format = 'WPS',  # out_format: Specify the format of the intermediate files generated by ungrib.exe for metgrid.exe to read. Valid values: WPS, SI, and MM5. Default value: WPS.
prefix = 'FILE'      # prefix: Specify the prefix of the intermediate files. The prefix can include a path.
 
 
# &metgrid 
&metgrid  
fg_name = 'FILE',      # fg_name: Specify the prefixes of the intermediate files generated by ungrib.exe.
io_form_metgrid = 2,   ## io_form_metgrid: Specify the I/O format of the metgrid output file. Valid values: 1, 2, and 3. 1 specifies a binary file with an extension of .int. 2 specifies a NetCDF file with an extension of .nc. 3 specifies a GRIB 1 file with an extension of .gr1.

Step 2: Run geogrid.exe

The geogrid.exe program defines the model horizontal domain and horizontally interpolates static geographical data to the model domain.

  1. Log on to the cluster.

    Log on to the cluster as the sudo user. For more information, see Log on to a cluster.

  2. Install NCAR Command Language (NCL). For more information, visit the NCL official website.

  3. Check whether the required software of WRF is installed in the cluster.

    export MODULEPATH=/opt/ehpcmodulefiles/
    module avail
  4. Load the WRF software environment.

    module load wrf-mpich/3.8.1 mpich/3.2
    echo $WPSHOME $WRFHOME
  5. Copy the installed WPS and WRF software to the working directory.

    cp -r $WPSHOME $WPSCOPYHOME
    cp -r $WRFHOME $WRFCOPYHOME
    Note

    Replace $WPSCOPYHOME and $WRFCOPYHOME in the preceding code with the actual working directory, for example, /home/wrftest/WPS.

  6. Download and decompress the geographical data file.

    Note

    In this example, the geog_complete.tar.gz file is used. You can also download a different geographical data file based on your needs. For more information, visit the WRF official website.

    cd /home/wrftest/WPS
    wget https://www2.mmm.ucar.edu/wrf/src/wps_files/geog_complete.tar.gz
    tar -zxvf geog_complete.tar.gz
  7. Link the GEOGRID.TBL file.

    The GEOGRID.TBL file determines which fields are interpolated by geogrid.

    ln -s geogrid/GEOGRID.TBL GEOGRID.TBL
  8. Interpolate static geographical data to the model domain.

    ./geogrid.exe

    After geogrid.exe is run, the geo_em.d0N.nc file is generated in the WPS directory. The following result is returned.

    georgid

Step 3: Run ungrib.exe

The ungrib.exe program extracts meteorological fields from GRIB files.

  1. Download and decompress the meteorological data file of Hurricane Katrina.

    Note

    In this example, the Katrina.tar.gz file is used. To download Katrina.tar.gz, click Katrina.tar.gz. You can also download a different geographical data file based on your needs. For more information, visit the WRF official website.

    wget http://www2.mmm.ucar.edu/wrf/TUTORIAL_DATA/Katrina.tar.gz
    tar -zxvf Katrina.tar.gz
  2. Link the data file to the WPS directory.

    ./link_grib.csh /home/wrftest/wrfdata/Katrina/avn
  3. Link the Vtable of the data file.

    In this example, Vtable.GFS is used. You can also select a different Vtable based on your needs.

    ln -sf ungrib/Variable_Tables/Vtable.GFS Vtable
  4. Extract the required meteorological fields.

    ./ungrib.exe

    After ungrib.exe is run, files named in the FILE:YYYY-MM-DD_hh* format are generated in the WPS directory. The following result is returned.

    ungrib

Step 4: Run metgrid.exe

The metgrid.exe file horizontally interpolates meteorological fields to the model domain determined by geogrid.exe.

  1. Link the GEOGRID.TBL file.

    The GEOGRID.TBL file defines how metgrid.exe horizontally interpolates meteorological fields to the model domain.

    ln -s metgrid/METGRID.TBL.ARW METGRID.TBL
  2. Horizontally interpolate meteorological fields to the model domain determined by geogrid.exe.

    ./metgrid.exe

    After metgrid.exe is run, files named in the met_em.d0N.yyyy-mm-dd_hh:mm:ss.nc format are generated in the WPS directory. The following result is returned.

    metgrid

Step 5: Run wrf.exe

The wrf.exe program stores the forecast data. Before you run wrf.exe, define the namelist.input file. The parameters about &time_control and &domains in the namelist.input file must be the same as those in the namelist.wps file. For more information, visit the WRF official website.

Note

In this example, namelist.input resides in the /home/wrftest/WRFV3/run directory.

  1. Go to the WRFV3 directory.

    cd /home/wrftest/WRFV3
  2. Import the processing result of WPS.

    ln -s /home/wrftest/WRFV3/run/met_em*
  3. Initialize simulation data.

    ./real.exe

    After real.exe is run, the wrfinput.d0N and wrfbyd.dxx files are generated in the /home/wrftest/WRFV3/run directory.

  4. Export the forecast data.

    mpirun -np 10 /home/wrftest/WRFV3/run/wrf.exe

    After wrf.exe is run, the wrfout.d0N_[date] file is generated in the WRF directory.

    Create NCAR Graphics images for the WRF result, as shown in the following figure.WRF