Initializing the WRF model with ERA5 (pressure level)


This is the tutorial of using WRF with ERA5 pressure level (38 vertical levels) data.

If you prefer model level (138 vertical levels), please check another tutorial.

I recommend the pressure level data, because the download speed is much faster.

If you don’t have cdsapi, please check this official tutorial.

Required Fields

WRF requires a number of fields as input.

  • 3D Data (e.g. data on pressure levels)

    • Temperature
    • U and V components of Wind
    • Geopotential Height
    • Relative Humidity (the code can calculate RH if Specific Humidity is available;this is controlled in the Vtable)
  • 2D Data

    • Surface Pressure
    • Mean Sea Level Pressure
    • Skin Temperature/SST
    • 2-meter Temperature
    • 2-meter Relative or Specific Humidity
    • 10-meter U and V components of wind
    • Soil data (temperature and moisture) and soil height

If any masked field is ingested, then a LANDSEA field is recommended

Water equivalent snow depth (SNOW) is a nice field to have, but not required.

SEAICE is good to have for a high latitude winter case, but it is not required.

Single level data (

import cdsapi

c = cdsapi.Client()


Pressure level data (

import cdsapi

c = cdsapi.Client()


Automation script (Download)

You can automate the script rather than change elements one by one.

#!/bin/bash -l


# Set your python environment
export PATH=~/xin/work/anaconda3/bin:$PATH
source activate root

YY1=`echo $DATE1 | cut -c1-4`
MM1=`echo $DATE1 | cut -c5-6`
DD1=`echo $DATE1 | cut -c7-8`
YY2=`echo $DATE2 | cut -c1-4`
MM2=`echo $DATE2 | cut -c5-6`
DD2=`echo $DATE2 | cut -c7-8`

sed -e "s/DATE1/${DATE1}/g;s/DATE2/${DATE2}/g;s/Nort/${Nort}/g;s/West/${West}/g;s/Sout/${Sout}/g;s/East/${East}/g;" > GetERA5-${DATE1}-${DATE2}

python GetERA5-${DATE1}-${DATE2}

sed -e "s/DATE1/${DATE1}/g;s/DATE2/${DATE2}/g;s/Nort/${Nort}/g;s/West/${West}/g;s/Sout/${Sout}/g;s/East/${East}/g;" > GetERA5-${DATE1}-${DATE2}

python GetERA5-${DATE1}-${DATE2}

mkdir -p ${DATADIR}/$YY1

mv ERA5-${DATE1}-${DATE2}-sl.grib ERA5-${DATE1}-${DATE2}-pl.grib ${DATADIR}/$YY1/

exit 0


Run geogrid.exe as usual.

If you’re not familiar with WRF, please check the online tutorial in detail.


Run ungrib.exe by using the table:

$ ln -s ./ungrib/Variable_Tables/ Vtable


Run metgrid.exe as usual.


  1. How to run the WRF model using ERA5 (on model levels) as initial and boundary conditions
  2. Grib to Netcdf conversion
  3. Download ERA-Interim data
  4. UNGRIB: Required Fields

Version control

Version Action Time
1.0 Init 2019-10-03
1.1 Add support of selecting area 2019-10-04
1.2 Update the method of assigning ‘time’ 2020-03-27

Comments (5)

Tuesday, Mar 24, 2020

Do I need to merge both dataset before running ungrib? If not what name I should give to each? GRIBFILE.AAA and GRIBFILE.AAB?

Xin Zhang
In reply to Sam
Tuesday, Mar 24, 2020

Hi, Sam!

You don’t have to merge both datasets.

You can just use ./link_grib.csh ERF5* to link all files.

Then ungrib.exe will read all GRIBFILE.*.


Zhenning Li
Thursday, Mar 26, 2020

Hi Xin,

Thanks for your great post. Very helpful! Just one question, in your downloading py script, the specific time ranges from 00Z to 12Z, I am just wondering why 13-23Z were not selected? Thanks


Xin Zhang
In reply to Zhenning Li
Thursday, Mar 26, 2020

Hi Zhenning,


That’s just an example which downloads 12 hours data.

You can choose any time interval you like, even unequally spaced intervals.


Xin Zhang
In reply to Zhenning Li
Friday, Mar 27, 2020

Hi Zhenning,

You can use a simpler method to choose the time like this:


I’ve updated that part in the blog. Thank you for your question ;)


Say something

Thank you

Your comment has been submitted and will be published once it has been approved.

Click here to see the pull request you generated.


Your comment has not been submitted. Please go back and try again. Thank You!

If this error persists, please open an issue by clicking here.