Page 1 of 1

wrfpost with ARW is misplacing the grid! Bug?

PostPosted: Mon Aug 25, 2008 9:07 pm
by cdavis
Hi all,
I am having trouble producing grib files with WPPV3 (for the purpose of verification with the MET toolkit). I am running WRF 3.0 with the ARW core. As you can hopefully see in the attached plots wrfpost is doing something very bad to the latitude and longitude fields. This was first made apparent by MET only finding matching pairs where the incorrect grid overlaps the South Island. This looks like a bug in wrfpost.exe since I had no problem with this domain using RIP and the fields from the WRF netcdf output file look reasonable when plotted. Also the usage of wrfpost.exe does not seem to give much room for user error, with only the model start, forecast hour, and model type (NCAR) being specified. I compiled wrfpost.exe with the pgi compiler no MPI option.
inner nest d01
map.png (35.44 KiB) Viewed 12246 times

outer nest d02
map1.png (44.4 KiB) Viewed 12237 times

Has anyone seen anything like this?
Does it look like a bug?


Re: wrfpost with ARW is misplacing the grid! Bug?

PostPosted: Thu Aug 28, 2008 12:27 pm
by smasters
I have seen the same problem with any grid I locate in the southern hemisphere. If you look at the GDS part of the grib files produced by WRFPOST, the "Latin1" and "Latin2" (projection latitudes of the Lambert Conformal) are incorrect. You can use "wgrib -V <gribfile> to view the projection information. The netCDF files appear to be correct; if you do an "ncdump" on one of the output files, you will see the correct projection lattitude values. Looking at the output from wrfpost, correct values seem to be read into the program, but are somehow lost when written to the grib file.

You can really see the problem if you use IDV on both the grib and netCDF files...the netCDF will show in the correct location and the grib will be wrong (as your plot shows).

I sent a package with the netCDF and grib files showing the problem to wrfhelp on 21 August.

Steve Masters
Melbourne, FL

Re: wrfpost with ARW is misplacing the grid! Bug?

PostPosted: Fri Aug 29, 2008 12:55 am
by cdavis
Thanks Steve.
I have actually located the cause of the problem. As you say, a Lambert conformal grid is never going to work in the Southern hemisphere.
The first problem is that the routine w3fi74 is not able to deal with negative values for TRUELAT1 and TRUELAT2. Here is a diff showing the changes I have made ...
$ diff WPPV3/lib/w3lib/w3fi74.f WPPV3-fresh/WPPV3/lib/w3lib/w3fi74.f
< LAT1 = IGDS(15)
< IF (LAT1 .LT. 0) THEN
< LAT1 = -LAT1
< LAT1 = IOR(LAT1,8388608)
< GDS(29) = CHAR(MOD(LAT1/65536,256))
< GDS(30) = CHAR(MOD(LAT1/ 256,256))
< GDS(31) = CHAR(MOD(LAT1 ,256))
< LAT2 = IGDS(16)
< IF (LAT2 .LT. 0) THEN
< LAT2 = -LAT2
< LAT2 = IOR(LAT2,8388608)
< GDS(32) = CHAR(MOD(LAT2/65536,256))
< GDS(33) = CHAR(MOD(LAT2/ 256,256))
< GDS(34) = CHAR(MOD(LAT2 ,256))
< LATSP = IGDS(17)
< LATSP = IOR(LATSP,8388608)
< GDS(35) = CHAR(MOD(LATSP/65536,256))
< GDS(36) = CHAR(MOD(LATSP/ 256,256))
< GDS(37) = CHAR(MOD(LATSP ,256))
> GDS(29) = CHAR(MOD(IGDS(15)/65536,256))
> GDS(30) = CHAR(MOD(IGDS(15)/ 256,256))
> GDS(31) = CHAR(MOD(IGDS(15) ,256))
> GDS(32) = CHAR(MOD(IGDS(16)/65536,256))
> GDS(33) = CHAR(MOD(IGDS(16)/ 256,256))
> GDS(34) = CHAR(MOD(IGDS(16) ,256))
> GDS(35) = CHAR(MOD(IGDS(17)/65536,256))
> GDS(36) = CHAR(MOD(IGDS(17)/ 256,256))
> GDS(37) = CHAR(MOD(IGDS(17) ,256))

Note that I allowed the "Latitude for South Pole" entry to be negative also, though I am not sure if this is critical.

The other changes I needed to make were in sorc/GRIBIT.f. For South pole in the projection IGDS(12) = 128, and for some reason I needed to reverse the scan order (IGDS(13) = 128)- it is possible that this is the wrong fix and that some other problem is causing the data to be packed in the wrong order. Obviously this fix results in a SH version of wrfpost and someone needs to add code elsewhere to make it work for both hemispheres.

$ diff WPPV3/sorc/wrfpost/GRIBIT.f WPPV3-fresh/WPPV3/sorc/wrfpost/GRIBIT.f
< IGDS(12) = 128 !for South
< IGDS(13) = 128
> IGDS(12) = 0
> IGDS(13) = 64
< IGDS(17) = -90000
> IGDS(17) = 0

Re: wrfpost with ARW is misplacing the grid! Bug?

PostPosted: Mon Jan 13, 2014 3:33 pm
by Tim Kerr
Hi Cory,
thanks for sorting this out. The problem still occurs with the Unified Post Processor (UPP).
I needed to implement your edit of w3fi74.f which for UPP is in the directory:
It seems the necesary changes to GRIBIT.F have been implemented, so that does not need editing.
I have sent the details to WRF Help so hopefully it will get fixed.

Re: wrfpost with ARW is misplacing the grid! Bug?

PostPosted: Tue Mar 27, 2018 11:06 pm
by palmeira

Looks like the UPPV3.x is still with the southern hemisphere wind problem. The w3fi74.f is correct but wind out is inverted...