All Products
Search
Document Center

Use WRF to perform high-performance computing

Last Updated: Jan 04, 2022

This topic uses Weather Research and Forecasting Model (WRF) as an example to show how to perform high-performance computing by using an Elastic High Performance Computing (E-HPC) cluster.

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

Preparations

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 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.

# &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
parent_id = 1,
parent_grid_ratio = 1,
i_parent_start = 1,
j_parent_start = 1,

# &geogrid specifies information such as the parent domain, parent-to-nest domain grid size ratio, and map projection.
# 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 1: Create a cluster and user

  1. Log on to the E-HPC console.

  2. Create a cluster named wrf-test.

    For more information, see Create a cluster. Set the following parameters:

    • Scheduler: Select slurm.

    • Other Software: Select wrf-mpich 3.8.1, wrf-openmpi 3.8.1, mpich 3.2, and openmpi 1.10.7.

    • VNC: Turn on the VNC switch. This way, you can remotely log on to the cloud desktop or app of E-HPC by using the E-HPC console.

      wrf-test
  3. Create a sudo user named wrftest.

    For more information, see Create a user.

Step 2: Run geogrid.exe

The geogrid.exe program defines the model horizontal domain and horizontally interpolates static geographical data to the model domain. Before you run geogrid.exe, perform the following operations:

  • Install NCAR Command Language (NCL) on the logon node. For more information, visit the NCL official website.

  • Configure the namelist.wps file. For more information, see the Preparations section.

Note

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

  1. On the Cluster page of the E-HPC console, find wrf-test and click Connect.

  2. In the Connect panel, set Cluster User to wrftest, specify a password and port number for wrf-test, and then click Connect via SSH.

  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 here. 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 that have the name of FILE:YYYY-MM-DD_hh* 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 that have the name of met_em.d0N.yyyy-mm-dd_hh:mm:ss.nc 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