Closed edwardhartnett closed 1 year ago
Build/tests look good to me. Is there a one-sentence explanation for the connection between the use of 4-byte floats in g2 files and the need for long long ints?
@AlexanderRichert-NOAA here's your one-sentence explanation: "GRIB2 is dumb."
So some 4-byte ints may be negative, some positive. Are the positive ones small enough to fit into a signed int? There is no guarantee. So in order to ensure that any unsigned 4-byte ints which are larger than the largest signed 4-byte ints are handled properly, the whole template arrray needs to be stored as 8-bytes signed long long int. ;-)
GRIB2 sometimes stores 4-byte unsigned floats in templates.
To handle this, internally we need to store template values as long long int. Interestingly, the degrib2.F90 prints every template value as a signed int, even if it is an unsigned int. So some numbers show up as negative in degrib2 output. In g2cdegrib2.c I cast back to int to match the behavior of degrib2.F90.
Part of #209