nmangue / NGrib

NGrib is a .NET library to read GRIB (GRid in Binary) files. GRIB is a gridded data standard from WMO (World Meteorological Organisation) and is used by many meteorological organisation. Fork of GribCS.
GNU Lesser General Public License v3.0
17 stars 10 forks source link

Added some general and local (NOAA and DWD) Parameters. Fixed compilation error on Mac M1. #4

Closed AndyDekiert closed 2 years ago

AndyDekiert commented 2 years ago

Hi @nmangue,

thanks for publishing this nice library. I added some additional parameters to the 4_2 code table and also added local parameter code tables to work with the latest NOAA GFS grib2 files and with ICON files from the German DWD. The local parameters will not always be loaded but only for the associated center read from the identification section.

When I tried to compile the library on my Mac with M1 processor using the current .NET 6.0 SDK I had some strange compiler errors ("csc.dll exited with code 138"). I first thought it may have been related to non UTF-8 encoding in the GRIB1 files. Strangely the code compiled fine if removed some files, compiled and then re-added the same files and compiled again... Later it turned out that the culprit was the humongous ParametersByCategory dictionary in 4_2_Parameter.cs. I assume that the compiler reached some memory or heap limit and exited because with each Add() there was actually a new copy of the Immutable list created. When I "compiled in steps" by first removing some files the compiler had less to compile at a time and possibly did not reach the limit... Anyways: To fix the compiler errors I replaced the Add()-section with some reflection code which creates a list of all Parameter Properties in a specified class. This also shortened the code by a couple of hundred lines ;-)

I hope you are happy with the changes and will merge them into your repo.

Kind regards, Andy

AndyDekiert commented 2 years ago

You're welcome.