Here is a
clean summary you can post on the WRF forum or GitHub that explains the problem and the working solution.
Running WRF/WPS with ECMWF IFS Open Data (soil layer issue and fix)
I recently worked on running
WRF with ECMWF IFS open data, and ran into the known problem where
soil temperature (ST) and soil moisture (SM) fields fail in ungrib or are not interpreted correctly.
After reading several forum threads and testing different approaches, here is a
working setup and explanation.
Problem
Newer ECMWF IFS datasets (post ~cycle 49r1) changed the encoding of soil fields.
In particular:
- soil temperature → discipline=2, category=3, parameter=18
- volumetric soil water → discipline=2, category=0, parameter=25
- soil layers use GRIB2 level type 151
However
stock WPS only handles soil layers using level type 106, so ungrib cannot properly decode the fields without modification.
The soil layers provided by ECMWF correspond to:
| layer | depth |
|---|
| 1 | 0–7 cm |
| 2 | 7–28 cm |
| 3 | 28–100 cm |
| 4 | 100–289 cm |
WRF expects these as:
ST000007
ST007028
ST028100
ST100289
SM000007
SM007028
SM028100
SM100289
Temporary workaround (GRIB rewriting)
One workaround is to rewrite the soil-layer levels with wgrib2:
wgrib2 "$grib_file" -set_grib_type simple -grib_out res1.grb2
wgrib2 res1.grb2 \
-if ":soil level 0 - soil level 1" -set_lev "0-0.07 m below ground" \
-elseif ":soil level 1 - soil level 2" -set_lev "0.07-0.28 m below ground" \
-elseif ":soil level 2 - soil level 3" -set_lev "0.28-1 m below ground" \
-elseif ":soil level 3 - soil level 4" -set_lev "1-2.89 m below ground" \
-endif -grib res.grb2
mv res.grb2 "$grib_file"
Then modify the Vtable.ECMWF entries:
0 | 1 | 0 | 7 | ST000007 | K | T of 0-7 cm ground layer | 2 | 3 | 18 | 106
1 | 2 | 7 | 28 | ST007028 | K | T of 7-28 cm ground layer | 2 | 3 | 18 | 106
2 | 3 | 28 | 100 | ST028100 | K | T of 28-100 cm ground layer | 2 | 3 | 18 | 106
3 | 4 | 100 | 289 | ST100289 | K | T of 100-289 cm ground layer | 2 | 3 | 18 | 106
0 | 1 | 0 | 7 | SM000007 | m3 m-3 | Soil moisture 0-7 cm | 2 | 0 | 25 | 106
1 | 2 | 7 | 28 | SM007028 | m3 m-3 | Soil moisture 7-28 cm | 2 | 0 | 25 | 106
2 | 3 | 28 | 100 | SM028100 | m3 m-3 | Soil moisture 28-100 cm | 2 | 0 | 25 | 106
3 | 4 | 100 | 289 | SM100289 | m3 m-3 | Soil moisture 100-289 cm | 2 | 0 | 25 | 106
With this change, ungrib inventories correctly:
ST000007 ST007028 ST028100 ST100289
SM000007 SM007028 SM028100 SM100289
However, this is only a workaround.
Proper solution (recommended)
A cleaner solution is to
patch WPS to support ECMWF soil layers using level type 151.
The fix was implemented in:
WPS PR #266
This patch includes:
- new Vtable.ECMWF.IFS.grib2
- modifications to
ungrib/src/ngl/g2/params.f
- modifications to
ungrib/src/rd_grib2.F
These changes allow ungrib to correctly decode ECMWF soil fields without rewriting GRIB files.
Key additions:
- support for ECMWF parameters
SOT (soil temperature)
VSW (volumetric soil water)
STL1-STL4
SWVL1-SWVL4
- recognition of GRIB2 level type 151
- mapping of ECMWF soil layer indices (0-1, 1-2, 2-3, 3-4) to WRF soil depths
Required WRF configuration
Make sure WRF uses four soil layers:
num_soil_layers = 4
This matches the ECMWF soil layer structure.
Final result
After applying the patch and using the updated Vtable, ungrib correctly processes:
ST000007
ST007028
ST028100
ST100289
SM000007
SM007028
SM028100
SM100289
and the WRF/WPS workflow runs normally with ECMWF IFS data.
If helpful, can someone please verify this patch suggestion?