wrf-model / WPS

The official repository for the WRF Preprocessing System (WPS)
202 stars 159 forks source link

Adding support for ICON in WPS #221

Closed grafmi closed 1 year ago

grafmi commented 1 year ago

The ICON grib2 data set is now able to be ingested by the ungrib program. Informations about the ICON data set can be found here: https://www.dwd.de/DWD/forschung/nwv/fepub/icon_database_main.pdf

  1. Two Vtable files (pressure and model levels) have been created with the fields required by the WRF model. Minor changes have been adapted compared to PR #154
  2. Modifications to the ungrib source code: Adding support for level code 150 in rd_grid2.F because model levels of ICON are on generalized vertical height coordinates. The general vertical height coordinate is not specified by vertical coordinate parameters but by providing a 3D field, that specifies the geometric height of every model grid point in meters. For more details, see Appendix in: https://www.dwd.de/DWD/forschung/nwv/fepub/icon_database_main.pdf
  3. Addition of new soil levels: New soil levels from ICON are added to METGRID.TBL.ARW for metgrid.exe. Details about the soil levels in ICON can be found in the documentation (see above). Compared to PR #154 all available model levels (soil moisture and temperature) are included now.
  4. Conversion of soil moisture units to those expected by the WRF model: The preprocessing in rrpr.F has to be modified to convert the units of column-integrated soil moisture provided by ICON from kg m-2 to m3 m-2 for WRF input.
  5. Addition of an identifier for DWD models (ICON) in rd_grib2.F and rd_grib1.F as done by @WQadam

This PR has been tested with ICON-EU (~6.6 km resolution) data, but it should be able to run with ICON-D2 (~2.2 km resolution) and ICON-Global. For the latter it needs to be converted from an icosahedral grid to a regular lat-lon grid. Data for testing can be taken from PR #154

This PR is very similar to PR #220. Nevertheless I published it, so you can decide which one is more appropriate for your needs.

weiwangncar commented 1 year ago

@grafmi Thanks for redoing this PR. I was able to compile the code, download the 0.6 deg ICON data using download_icon.sh, and run through ungrib, metgrid, real and wrf. I like that the Vtable included the GHT data from the model. This will provide a better estimate for input geopotential for the WRF model. I have a couple of quetions:

  1. The link for the sited documentation file in pdf is not there any more. Can you provide the correct link?
  2. Do you know the latitude/longitude bounds of the 0.6 degree dataset?
  3. When I downloaded the data, the last two layers of soil T were not there. Is this typical?
  4. Are the downloaded qv and qv_2m mixing ratio or specific humidity?

@mgduda @jimbresch If you would like to take a look at this, I have a couple of downloaded ICON data files on Cheyenne. Let me know.

grafmi commented 1 year ago

@weiwangncar

  1. I provided a working link in the description on top
  2. The lat/lon boundaries of ICON-EU are 23.5°W – 62.5°E / 29.5°N – 70.5°N. You will find these information and the domain of ICON-D2 also here: DWD Database Reference for the Global and Regional ICON
  3. According to the documentation (see link above), the last two layers should be there - maybe, my old download script did not include them
  4. qv and qv_2m are specific humidity (see link above)
weiwangncar commented 1 year ago

@mgduda @jimbresch Can you review this PR? Let's see if we can get it into v4.5 release. Thanks!

weiwangncar commented 1 year ago

@grafmi Do you mind making your download script available for others?

grafmi commented 1 year ago

@grafmi Do you mind making your download script available for others?

@weiwangncar It's fine for me to make it available to others. Where should I provide it?

weiwangncar commented 1 year ago

@grafmi We may add a link in the release note for downloading the script, and we can also add it to our FAQs. Is there anything in the script you'd like to revise? Have you used it recently? It seems the data is update daily on the server and there is no archive of the data, correct?

sael9740 commented 1 year ago

I was having issues with this version when using the ICON-D2 dataset with pressure levels. I am not very familiar with WPS in general so I may be missing something obvious. The file I'm attaching has my namelists, run scripts and log files for downloading the ICON-D2 data, running ungrib and running metgrid.

icon-d2-grafmi-test.tar.gz

It looks like something funky is happening with GEOPT:

metgrid.log:

...
2023-04-14 11:18:36.698 --- DEBUG:         .      PRES SOIL_LEVE     SOILT     SOILM       GHT     GEOPT        TT  SOILM999  SOILM486  SOILM162  SOILM054  SOILM018  SOILM006  SOILM002  SOILM001  SOILT999  SOILT486  SOILT162  SOILT054  SOILT018  SOILT006  SOILT002  SOILT001  SKINTEMP   SOILHGT      PSFC        RH        VV        UU      PMSL 
2023-04-14 11:18:36.698 --- DEBUG:     20000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.698 --- DEBUG:     25000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.698 --- DEBUG:     30000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.698 --- DEBUG:     40000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.698 --- DEBUG:     50000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.698 --- DEBUG:     60000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.699 --- DEBUG:     70000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.699 --- DEBUG:     85000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.699 --- DEBUG:     95000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.699 --- DEBUG:     97500         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.699 --- DEBUG:    100000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.699 --- DEBUG:    200100         X         -         -         -         X         -         X         X         X         X         X         X         X         X         X         X         X         X         X         X         X         X         X         X         X         X         X         X         X         - 
2023-04-14 11:18:36.699 --- DEBUG:         1         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         - 
2023-04-14 11:18:36.699 --- DEBUG:         2         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         - 
2023-04-14 11:18:36.699 --- DEBUG:         6         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         - 
2023-04-14 11:18:36.699 --- DEBUG:        18         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         - 
2023-04-14 11:18:36.699 --- DEBUG:        54         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         - 
2023-04-14 11:18:36.699 --- DEBUG:       162         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         - 
2023-04-14 11:18:36.699 --- DEBUG:       486         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         - 
2023-04-14 11:18:36.699 --- DEBUG:      1458         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         - 
2023-04-14 11:18:36.699 --- DEBUG:    201300         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X 
...

metgrid.exe stderr/stdout:

...
WARNING: Entry in METGRID.TBL not found for field GEOPT. Default options will be used for this field!
...
 WRF_DEBUG: Warning DIM             4 , NAME num_metgrid_levels REDEFINED  by var GEOPT            12           11  in wrf_io.F90 line         2588
ERROR: Error in ext_pkg_write_field

Interestingly I did have success though when running with @WQadam's WPS:Support-for-DWD-suite-of-models from PR #220.

WQadam commented 1 year ago

I was having issues with this version when using the ICON-D2 dataset with pressure levels. I am not very familiar with WPS in general so I may be missing something obvious. The file I'm attaching has my namelists, run scripts and log files for downloading the ICON-D2 data, running ungrib and running metgrid.

icon-d2-grafmi-test.tar.gz

It looks like something funky is happening with GEOPT:

metgrid.log:

...
2023-04-14 11:18:36.698 --- DEBUG:         .      PRES SOIL_LEVE     SOILT     SOILM       GHT     GEOPT        TT  SOILM999  SOILM486  SOILM162  SOILM054  SOILM018  SOILM006  SOILM002  SOILM001  SOILT999  SOILT486  SOILT162  SOILT054  SOILT018  SOILT006  SOILT002  SOILT001  SKINTEMP   SOILHGT      PSFC        RH        VV        UU      PMSL 
2023-04-14 11:18:36.698 --- DEBUG:     20000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.698 --- DEBUG:     25000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.698 --- DEBUG:     30000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.698 --- DEBUG:     40000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.698 --- DEBUG:     50000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.698 --- DEBUG:     60000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.699 --- DEBUG:     70000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.699 --- DEBUG:     85000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.699 --- DEBUG:     95000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.699 --- DEBUG:     97500         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.699 --- DEBUG:    100000         X         -         -         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X         X         X         - 
2023-04-14 11:18:36.699 --- DEBUG:    200100         X         -         -         -         X         -         X         X         X         X         X         X         X         X         X         X         X         X         X         X         X         X         X         X         X         X         X         X         X         - 
2023-04-14 11:18:36.699 --- DEBUG:         1         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         - 
2023-04-14 11:18:36.699 --- DEBUG:         2         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         - 
2023-04-14 11:18:36.699 --- DEBUG:         6         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         - 
2023-04-14 11:18:36.699 --- DEBUG:        18         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         - 
2023-04-14 11:18:36.699 --- DEBUG:        54         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         - 
2023-04-14 11:18:36.699 --- DEBUG:       162         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         - 
2023-04-14 11:18:36.699 --- DEBUG:       486         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         - 
2023-04-14 11:18:36.699 --- DEBUG:      1458         -         X         X         X         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         - 
2023-04-14 11:18:36.699 --- DEBUG:    201300         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         -         X 
...

metgrid.exe stderr/stdout:

...
WARNING: Entry in METGRID.TBL not found for field GEOPT. Default options will be used for this field!
...
 WRF_DEBUG: Warning DIM             4 , NAME num_metgrid_levels REDEFINED  by var GEOPT            12           11  in wrf_io.F90 line         2588
ERROR: Error in ext_pkg_write_field

Interestingly I did have success though when running with @WQadam's WPS:Support-for-DWD-suite-of-models from PR #220.

Looks like GEOPT is missing from the metgrid.tbl in this PR, hence why it worked in mine but not this one. GEOPT should be added to the metgrid table like HGTT is in the metgrid table.

grafmi commented 1 year ago

Yes, it seems that I forgot to add the field GEOPT to the METGRID.TBL. Thanks for the hint @WQadam. @sael9740 Try to add the lines below to METGRID.TBL.ARW:

_name=GEOPT output=no interp_option=nearestneighbor ========================================

sael9740 commented 1 year ago

Yes, it seems that I forgot to add the field GEOPT to the METGRID.TBL. Thanks for the hint @WQadam. @sael9740 Try to add the lines below to METGRID.TBL.ARW:

_name=GEOPT output=no interp_option=nearestneighbor ========================================

@grafmi - This fixed the issue for me. Thanks for the help!

WQadam commented 1 year ago

I'm guessing it is alright to put GEOPT in the metgrid table like that. I see other vtables use GEOPT, mainly ecmwf. When running the EC and ERA5 models i see its needed to run calc_p_ecmwf before metgrid. I thought this was executable was mainly to calculate pressure which isnt needed for icon but i think this executable might also fill the lowest GEOPT level which metgrid is erroring on. Basically not sure if by putting GEOPT in the metgrid table we have bypassed a wrf error check for the ECMWF and ERA models? I have run some ERA5 initialized wrf runs without needing to do calc_p_ecmwf and the output has seemed fine.

weiwangncar commented 1 year ago

@sael9740 There is no need to process GEOPT in metgrid since the model would not know what to do with it. The correct fix is to remove Geopotential in the row for GEOPT in Vtable.ICONp, like it is done in Vtable.ECMWF:

 129 | 100  |   *  |      | GEOPT    | m2 s-2  |                                         |  0  |  3  |  4  | 100 |
     | 100  |   *  |      | HGT      | m       | Height                                  |     |     |     | 100 |

The ungrib program knows to compute HGT from GEOPT and write only HGT out in the intermediate file. Can you give it a try?

sael9740 commented 1 year ago

@weiwangncar - Ya sure. I'll try that now and get back with you.

sael9740 commented 1 year ago

@sael9740 There is no need to process GEOPT in metgrid since the model would not know what to do with it. The correct fix is to remove Geopotential in the row for GEOPT in Vtable.ICONp, like it is done in Vtable.ECMWF:

 129 | 100  |   *  |      | GEOPT    | m2 s-2  |                                         |  0  |  3  |  4  | 100 |
     | 100  |   *  |      | HGT      | m       | Height                                  |     |     |     | 100 |

The ungrib program knows to compute HGT from GEOPT and write only HGT out in the intermediate file. Can you give it a try?

@weiwangncar - Yes this worked. Just to be clear I used https://github.com/wrf-model/WPS/commit/a22c0730138af592965137749575a4dde9ad89dc as is with the exception that I removed the GEOPT entry in the Vtable.ICONp: https://github.com/wrf-model/WPS/blob/a22c0730138af592965137749575a4dde9ad89dc/ungrib/Variable_Tables/Vtable.ICONp#L8

weiwangncar commented 1 year ago

@sael9740 @grafmi Thanks for trying.

andrewsoong commented 1 year ago

@grafmi Do you mind making your download script available for others?

@weiwangncar It's fine for me to make it available to others. Where should I provide it?

Is WPS-V4.5 suitable for handling ICON global forecast data?(Data is downloaded here:https://opendata.dwd.de/weather/nwp/icon/grib) Thanks!

WQadam commented 1 year ago

@grafmi Do you mind making your download script available for others?

@weiwangncar It's fine for me to make it available to others. Where should I provide it?

Is WPS-V4.5 suitable for handling ICON global forecast data?(Data is downloaded here:https://opendata.dwd.de/weather/nwp/icon/grib) Thanks!

Yes it is! You have to do an additional step on download though to get it to a lat lon grid as WPS cant handle the icosahedral grid. Once set up the conversion is quick but can take a while to set up. I have run it from the model level version but i think you should be able to run it with the pressure levels aswell, however there isnt many pressure levels in the global model.

see helpful links here on how to regrid icon global - https://www.dwd.de/DE/leistungen/opendata/help/modelle/Opendata_cdo_EN.pdf?__blob=publicationFile&v=3 https://github.com/DeutscherWetterdienst/regrid

andrewsoong commented 1 year ago

@grafmi Do you mind making your download script available for others?

@weiwangncar It's fine for me to make it available to others. Where should I provide it?

Is WPS-V4.5 suitable for handling ICON global forecast data?(Data is downloaded here:https://opendata.dwd.de/weather/nwp/icon/grib) Thanks!

Yes it is! You have to do an additional step on download though to get it to a lat lon grid as WPS cant handle the icosahedral grid. Once set up the conversion is quick but can take a while to set up. I have run it from the model level version but i think you should be able to run it with the pressure levels aswell, however there isnt many pressure levels in the global model.

see helpful links here on how to regrid icon global - https://www.dwd.de/DE/leistungen/opendata/help/modelle/Opendata_cdo_EN.pdf?__blob=publicationFile&v=3 https://github.com/DeutscherWetterdienst/regrid

Thank you so much! Can you provide a script that can download global ICON model-level data for WRF?

WQadam commented 1 year ago

icon_download_modlv_global.txt

See the download file above that is a shell script. I have had to put it as a text file to put it onto github.

You will have to fill out the working directory and create your domain target text files and nc file by looking at the DWD help link in my previous comment. Things to note are there is a few date variables that are set in the script and you will need to change these to your start and end date of the download. Plus the value in the time do loop sets how often the files are downloaded ie hourly, three hourly etc. CDO needs to be installed aswell on the machine to use this script as it uses these commands. Also i have only tested it for reasonable data using soil level 0 rather than 5 (0.5) which is supported by WPS 4.5 but in theory i dont think this will make a difference to the run data much unless you are looking at soil moisture and temperature.