Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

Debugging metgrid.exe, SegFault using SNODAS data for WPS >= v3.9

This post was from a previous version of the WRF&MPAS-A Support Forum. New replies have been disabled and if you have follow up questions related to this post, then please start a new thread from the forum home page.

bartbrashers

New member
Is there an undocumented setting in namelist.wps to increase the level of debugging output from metgrid.exe, similar to wrf.exe's debug_level?

I've been using SNODAS snow cover and snow depth (SNOW and SNOWH) for a number of years now. I wrote a Fortran program to write the data in WPS Intermediate File Format, following http://www2.mmm.ucar.edu/wrf/users/docs/user_guide_v4/v4.1/users_guide_chap3.html#_Writing_Meteorological_Data. I interpolate the daily SNOW:YYYY-MM-DD_HH files to 6-hourly, and link to them where I'm running metgrid.exe. I add them to namelist.wps in the &metgrid fg_name variable.

This procedure works fine for WPS-3.8.1 or earlier, but fails for later versions of WPS. As soon as metgrid.exe tries to read the very first SNOW:YYYY-MM-DD_HH, I get a Segmentation Fault error (crash).

Failing more verbose output, does anyone have any hints on where I should start looking? Was there a change in the definition of the WPS Intermediate File Format with WPS-3.9?

Bart Brashers
 
Using a hint from a different post on mixing data sources for finer-resolution SNOW and SNOWH fields, I removed the line "interp_mask=LANDSEA(0)" from the chunk of METGRID.TBL pertaining to snow:

========================================
name=SNOW
interp_option=four_pt+average_4pt
# interp_mask=LANDSEA(0)
masked=water
missing_value=-1.E30
fill_missing=0.
flag_in_output=FLAG_SNOW
========================================
name=SNOWH
interp_option=four_pt+average_4pt
# interp_mask=LANDSEA(0)
masked=water
missing_value=-1.E30
fill_missing=0.
flag_in_output=FLAG_SNOWH
========================================

avoids the Segmentation Fault and produces fields similar to those for WPS 3.8.1 and before.

This seems like a bug in metgrid to me...

Bart
 
Bart,
Thank you for bringing this to our attention and for the debugging tests. Out of curiosity, have you tried any of the 4+ versions of WPS? If possible, can you attach the files necessary for me to try to repeat this problem (namelist.wps, Vtable you are using, input data files, and any other files you needed to change, if so). That would help us to be able to dig a little deeper.

To answer your question about a namelist.wps debug option - yes, you can add the same parameter (debug_level) to the &share section of the namelist. We recently removed this option from the default namelist.input file, though, because it wasn't providing any useful information and more often would just add a lot of junk to the log files, making them difficult to read through. I assume the behavior would be similar for WPS, but I've never actually used the option there.
 
This procedure worked in WPS-3.8.1 and before, and does not work in WPS-3.9 or newer - including 4.0, 4.0.1, 4.0.2, and 4.1.

It fails for a variety of sources of the IC/BC datasets, e.g. ERA-Interim, ERA5, NAM from NCAR's ds609.0, NAM from NOMADS, GFS from NCAR's ds084.1. As an example, here's the Vtable I've been using for NAM from ds609.0 (identical to WPS-4.1's ungrib/Variable_Tables/Vtable.NAM):

Code:
GRIB1| Level| From |  To  | metgrid  | metgrid | metgrid                                 |GRIB2|GRIB2|GRIB2|GRIB2|
Param| Type |Level1|Level2| Name     | Units   | Description                             |Discp|Catgy|Param|Level|
-----+------+------+------+----------+---------+-----------------------------------------+-----------------------+
  11 | 100  |   *  |      | TT       | K       | Temperature                             |  0  |  0  |  0  | 100 |
  33 | 100  |   *  |      | UU       | m s-1   | U                                       |  0  |  2  |  2  | 100 |
  34 | 100  |   *  |      | VV       | m s-1   | V                                       |  0  |  2  |  3  | 100 |
  52 | 100  |   *  |      | RH       | %       | Relative Humidity                       |  0  |  1  |  1  | 100 |
   7 | 100  |   *  |      | HGT      | m       | Height                                  |  0  |  3  |  5  | 100 |
  11 | 105  |   2  |      | TT       | K       | Temperature       at 2 m                |  0  |  0  |  0  | 103 |
  52 | 105  |   2  |      | RH       | %       | Relative Humidity at 2 m                |  0  |  1  |  1  | 103 |
  33 | 105  |  10  |      | UU       | m s-1   | U                 at 10 m               |  0  |  2  |  2  | 103 |
  34 | 105  |  10  |      | VV       | m s-1   | V                 at 10 m               |  0  |  2  |  3  | 103 |
   1 |   1  |   0  |      | PSFC     | Pa      | Surface Pressure                        |  0  |  3  |  0  |   1 |
 130 | 102  |   0  |      | PMSL     | Pa      | Sea-level Pressure                      |  0  |  3  | 192 | 101 |
 144 | 112  |   0  |  10  | SM000010 | fraction| Soil Moist 0-10 cm below grn layer (Up) |  2  |  0  | 192 | 106 |
 144 | 112  |  10  |  40  | SM010040 | fraction| Soil Moist 10-40 cm below grn layer     |  2  |  0  | 192 | 106 |
 144 | 112  |  40  | 100  | SM040100 | fraction| Soil Moist 40-100 cm below grn layer    |  2  |  0  | 192 | 106 |
 144 | 112  | 100  | 200  | SM100200 | fraction| Soil Moist 100-200 cm below gr layer    |  2  |  0  | 192 | 106 |
  85 | 112  |   0  |  10  | ST000010 | K       | T 0-10 cm below ground layer (Upper)    |  2  |  0  |  2  | 106 |
  85 | 112  |  10  |  40  | ST010040 | K       | T 10-40 cm below ground layer (Upper)   |  2  |  0  |  2  | 106 |
  85 | 112  |  40  | 100  | ST040100 | K       | T 40-100 cm below ground layer (Upper)  |  2  |  0  |  2  | 106 |
  85 | 112  | 100  | 200  | ST100200 | K       | T 100-200 cm below ground layer (Bottom)|  2  |  0  |  2  | 106 |
  91 |   1  |   0  |      | SEAICE   | proprtn | Ice flag                                | 10  |  2  |  0  |   1 |
  81 |   1  |   0  |      | LANDSEA  | proprtn | Land/Sea flag (1=land,0=sea in NAM)     |  2  |  0  |  0  |   1 |
   7 |   1  |   0  |      | SOILHGT  | m       | Terrain field of source analysis        |  0  |  3  |  5  |   1 |
  11 |   1  |   0  |      | SKINTEMP | K       | Skin temperature (can use for SST also) |  0  |  0  |  0  |   1 |
  65 |   1  |   0  |      | SNOW     | kg m-2  | Water equivalent snow depth             |  0  |  1  | 13  |   1 |
  66 |   1  |   0  |      | SNOWH    | m       | Snow Depth                              |  0  |  1  | 11  |   1 |
 223 |   1  |   0  |      | CANWAT   | kg m-2  | Plant Canopy Surface Water              |  2  |  0  | 196 |   1 |
-----+------+------+------+----------+---------+-----------------------------------------+-----------------------+

And here's a sample namelist.wps:

Code:
&share
 wrf_core = 'ARW',
 max_dom = 4,
 start_date = '2014-01-01_12:00:00','2014-01-01_12:00:00','2014-01-01_12:00:00','2014-01-01_12:00:00','2014-01-01_12:00:00',
 end_date   = '2014-01-07_00:00:00','2014-01-07_00:00:00','2014-01-07_00:00:00','2014-01-07_00:00:00','2014-01-07_00:00:00',
 interval_seconds = 21600
 io_form_geogrid  = 2,
 nocolons = .false.,
/

&geogrid
 parent_grid_ratio =     1,    3,    3,    3,    3,
 parent_id         =     1,    2,    3,    4,    5,
 i_parent_start    =   1,  34,  34,  34,    5,
 j_parent_start    =   1,  34,  34,  34,    5,
 e_we              =   100,  100,  100,  100,    5,
 e_sn              =   100,  100,  100,  100,    5,
 dx                = 40500,
 dy                = 40500,
 map_proj          = 'lambert',
 truelat1          = 44.,
 truelat2          = 54.,
 stand_lon         = -99.,
 ref_lat           = 49.,
 ref_lon           = -99.,
 geog_data_res     =  'modis_30s+10m', 'modis_30s+30s', 'modis_30s+30s', 'modis_30s+30s',
 geog_data_path    = '/wrf/wrf.init/wrf.geo/'
 opt_geogrid_tbl_path = '/usr/local/src/wrf/WPS-4.1/geogrid',
/

&ungrib
 out_format = 'WPS',
 prefix = 'XXXX',
/

&metgrid
 fg_name = 'FILE','SST','SNOW','SNOWH',
 io_form_metgrid = 2,
 opt_metgrid_tbl_path  = '/wrf/wrf.init/NAM',
 constants_name  = '',
/

If you provide me with your email address, I can send you a sample SNOW:YYYY-MM-DD_HH file.

I got the hint from http://forum.mmm.ucar.edu/phpBB3/viewtopic.php?f=31&t=518&p=10955&hilit=SNOW#p10955 about the difference in METGRID.TBL.
 
Thanks for attaching that. I just wanted to let you know that I have been able to reproduce what you are seeing (except it works okay for v3.9 for me, and the problem starts in v3.9.1). The interesting thing is that I see the problem on our supercomputer (Cheyenne), with both a GNU and ifort compiler, but not on my local (Mac) - even when using the same version of the GNU compiler. I am still trying to figure out what may be causing this and compiling the code with debugging is not providing much insight, but I just wanted to update you to let you know I haven't forgotten about this. I'll keep you posted!
 
Hi,
I actually was able to reproduce it on my own laptop, as well. So it looks like the only change between V3.9 and V3.9.1 related to this, is the fact that interp_mask=LANDSEA(0) was added to the METGRID.TBL. I assume this was added because it's typically recommended to have a LANDSEA field with each dataset, as the land-sea masks can differ. However, it's not mandatory. So since you don't have that included in your SNOW/SNOWH data, the correct procedure is to simply remove that line from the METGRID.TBL, as you've done. Perhaps we should have a note somewhere that mentions this to users. Again, thank you for bringing this to our attention.
 
Top