LarissaReames-NOAA / MPASSIT

Fortran program to interpolate MPAS data to structured grids
GNU General Public License v3.0
7 stars 13 forks source link

Add option to create target grid at runtime by parameter specification #5

Closed LarissaReames-NOAA closed 1 year ago

LarissaReames-NOAA commented 1 year ago

Users can now create a target grid on the fly, including global grids, instead of being forced to provide a WRF file target grid.

I've tested Lambert conformal, regional lat-lon, and global lat-on configurations.

Also made I/O parallel netcdf friendly.

Made array creation cleaner and more MPI-friendly to reduce memory footprint.

@weather4evr If you have time, it would be great if you could test the new grid capabilities to flesh out anything that I've missed or might need to add/consider.

weather4evr commented 1 year ago

@LarissaReames-NOAA I'll try to test this out next week.

LarissaReames-NOAA commented 1 year ago

Bug fixes from @weather4evr have been implemented, along with some additional changes. You should now be able to run with the 'file' target type and use conservative regridding without issue.

weather4evr commented 1 year ago

I can now get identical results with conservative interpolation using this new branch for the 'file' target type. Thank you for the fixes.

I then tried to manually define the grid contained in the file I had been using and was hoping to get the same answers from the user-defined grid and using the 'file' target type. There were definitely differences. In addition, the lat/lon arrays differed. It's entirely possible I defined the grid incorrectly in the namelist. Have you tried this test with the HRRR grid--both when using the file to define the grid and manually specifying it?

LarissaReames-NOAA commented 1 year ago

I have and I did notice some slight differences in the grid location when I put what I thought were HRRR-identical parameters in the namelist. I scavenged all of the internal code for creating the grid from WPS geogrid, so something may be slightly amiss in exactly how I pass the variables through compared to how it's done in geogrid.

weather4evr commented 1 year ago

Maybe it's due to the staggering? In the WPS namelist, the nx/ny you input are number of staggered points. In this code, it seems to be that what's input is the number of unstaggered points, as the output file has staggered dimensions of (nx+1, ny+1).

LarissaReames-NOAA commented 1 year ago

Yeah, that seems a likely culprit. I'll see if I can get it to use nx,ny as staggered points instead of center points.

LarissaReames-NOAA commented 1 year ago

Hmmmm. The grids are now the same size, but the old 'file' grid type looks to be about 1 grid point southwest of the 'Lambert' grid type

(main) bash-4.2$  nccmp -dmfqS out_lcc_test.nc out_file_test.nc
Variable Group   Count          Sum      AbsSum          Min         Max       Range         Mean      StdDev
XLONG    /     1905141      32038.4     32038.4   0.00958252   0.0259666   0.0163841    0.0168168  0.00383956
XLONG_U  /     1906200      32054.9     32054.9   0.00957489   0.0259705   0.0163956    0.0168161  0.00384095
XLONG_V  /     1906940      32069.3     32069.3   0.00958252   0.0259743   0.0163918    0.0168172  0.00384075
XLAT     /     1905141        24951       24951   0.00710678   0.0174217   0.0103149    0.0130967  0.00257325
XLAT_U   /     1906200      24963.8     24963.8   0.00709915   0.0174217   0.0103226    0.0130961   0.0025746
XLAT_V   /     1906940      24974.1     24974.1   0.00710297   0.0174217   0.0103188    0.0130964   0.0025733
MAPFAC_M /     1902983     -7.05323     54.6037 -8.15392e-05 7.21216e-05 0.000153661 -3.70641e-06 3.36939e-05
MAPFAC_U /     1904056     -7.06653     54.6312 -8.16584e-05 7.21216e-05  0.00015378  -3.7113e-06 3.36921e-05
MAPFAC_V /     1904790     -7.05415     54.7063 -8.16584e-05 7.22408e-05 0.000153899 -3.70338e-06 3.37261e-05
HGT      /     1310925 -9.08217e+08 9.08266e+08     -3933.98     129.657     4063.64     -692.806     691.736
U10      /     1673529      358.494      285373     -8.58374     9.59716     18.1809  0.000214215     0.32892
T2       /     1620339      9247.27 1.10489e+06     -299.448      300.51     599.958     0.005707     11.5572
weather4evr commented 1 year ago

Not sure how you specified the lambert grid, but maybe you could specify the lat/lon of the SW corner and then use ref_x = 1, ref_y = 1?

That should at least force the SW corner points to be equal...I think.

LarissaReames-NOAA commented 1 year ago

Okay I modified the ref_x and ref_y computation slightly, and I think now we're just getting precision-scale differences/noise with very small mean values

-bash-4.2$  nccmp -dmfqS out_lcc_test.nc out_file_test.nc
Variable Group   Count          Sum      AbsSum          Min         Max       Range         Mean      StdDev
XLONG    /     1229786  -0.00356674     11.9849 -2.28882e-05 2.28882e-05 4.57764e-05 -2.90029e-09 1.04335e-05
XLONG_U  /     1232782      0.02425     12.0182 -2.28882e-05 2.28882e-05 4.57764e-05   1.9671e-08 1.04386e-05
XLONG_V  /     1232125  -0.00698853     12.0022 -2.28882e-05 2.28882e-05 4.57764e-05 -5.67193e-09 1.04289e-05
XLAT     /     1743183     -13.1605     13.4855 -2.67029e-05 1.33514e-05 4.00543e-05 -7.54968e-06 4.08358e-06
XLAT_U   /     1741356     -13.7412     14.0492 -2.86102e-05 1.14441e-05 4.00543e-05 -7.89107e-06 4.24147e-06
XLAT_V   /     1744934     -13.1721     13.4986 -2.67029e-05 1.33514e-05 4.00543e-05 -7.54879e-06 4.08387e-06
MAPFAC_M /     1056495    -0.102859    0.139609 -3.57628e-07 3.57628e-07 7.15256e-07 -9.73586e-08 9.68964e-08
MAPFAC_U /     1053366    -0.101105    0.139153 -3.57628e-07 3.57628e-07 7.15256e-07 -9.59824e-08 9.81943e-08
MAPFAC_V /     1056642    -0.102935    0.139713 -3.57628e-07 3.57628e-07 7.15256e-07 -9.74173e-08 9.69804e-08
HGT      /     1310925 -9.08217e+08 9.08266e+08     -3933.98     129.657     4063.64     -692.806     691.736
U10      /     1663004      1.24103     137.969    -0.379978     1.60743     1.98741  7.46256e-07  0.00129006
T2       /     1172920     -574.925      760.53     -297.399  0.00512695     297.405 -0.000490165    0.380514