/*! \page grib_debug grib_debug \section DESCRIPTION Dump the content of a grib file in debug mode. \section USAGE grib_debug [options] grib_file grib_file ... \section OPTIONS -V \n Version. \n \n \section grib_debug_examples grib_debug examples Dumping in a WMO documentation style with hexadecimal octet values (-H)\n and with the aliases of each key listed in square brackets (-a).\n\n grib_dump -Ha ../data/reduced_gaussian_model_level.grib1\n \verbatim ***** FILE: ../data/reduced_gaussian_model_level.grib1 ====================== MESSAGE 1 ( length=10142 ) ====================== ====================== SECTION_0 ( length=0, padding=0 ) ====================== 1-4 identifier = GRIB 5-7 totalLength = 10142 ( 0x00 0x27 0x9E ) 8 editionNumber = 1 ( 0x01 ) [ls.edition] ====================== SECTION_1 ( length=52, padding=0 ) ====================== 1-3 section1Length = 52 ( 0x00 0x00 0x34 ) 4 gribTablesVersionNo = 128 ( 0x80 ) [table2Version] 5 identificationOfOriginatingGeneratingCentre = 98 ( 0x62 ) [European Center for Medium-Range Weather Forecasts (grib1/0.table) ] [ls.centre, identificationOfCentre, originatingCentre] 6 generatingProcessIdentifier = 128 ( 0x80 ) [generatingProcessIdentificationNumber, process] 7 gridDefinition = 255 ( 0xFF ) 8 section1Flags = 128 [10000000] 9 indicatorOfParameter = 130 ( 0x82 ) [T Temperature K (grib1/2.98.128.table) ] 10 indicatorOfTypeOfLevel = 109 ( 0x6D ) [Hybrid level level number (2 octets) (grib1/3.table) ] [ls.levelType, typeOfLevel, typeOfFirstFixedSurface, mars.levtype] 11-12 lev = 1 ( 0x00 0x01 ) [topLevel, bottomLevel, ls.level, mars.levelist] 13 yearOfCentury = 7 ( 0x07 ) 14 month = 3 ( 0x03 ) 15 day = 18 ( 0x12 ) 16 hour = 12 ( 0x0C ) 17 minute = 0 ( 0x00 ) 18 indicatorOfUnitOfTimeRange = 1 ( 0x01 ) [Hour (grib1/4.table) ] 19 periodOfTime = 0 ( 0x00 ) [P1] 20 periodOfTimeIntervals = 0 ( 0x00 ) [P2] 21 timeRangeIndicator = 0 ( 0x00 ) [Forecast product valid at reference time + P1 (P1>0) (grib1/5.table) ] 22-23 numberIncludedInAverage = 0 ( 0x00 0x00 ) 24 numberMissingFromAveragesOrAccumulations = 0 ( 0x00 ) 25 centuryOfReferenceTimeOfData = 21 ( 0x15 ) 26 identificationOfOriginatingGeneratingSubCentre = 0 ( 0x00 ) [Absent (grib1/0.table) ] [subCentre] 27-28 decimalScaleFactor = 2 ( 0x00 0x02 ) 29-40 reservedNeedNotBePresent = 12 { 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 } # pad reservedNeedNotBePresent 41 localDefinitionNumber = 1 ( 0x01 ) 42 marsClass = 1 ( 0x01 ) [Operational archive (mars/class.table) ] [mars.class] 43 marsType = 2 ( 0x02 ) [Analysis (mars/type.table) ] [ls.dataType, mars.type] 44-45 marsStream = 1025 ( 0x04 0x01 ) [Atmospheric model (mars/stream.table) ] [mars.stream] 46-49 experimentVersionNumber = 0001 [mars.expver] 50 perturbationNumber = 0 ( 0x00 ) 51 numberOfForecastsInEnsemble = 0 ( 0x00 ) 52 padding_local1_1 = 1 { 00 } # pad padding_local1_1 ====================== SECTION_2 ( length=896, padding=0 ) ====================== 1-3 section2Length = 896 ( 0x00 0x03 0x80 ) 4 numberOfVerticalCoordinateValues = 184 ( 0xB8 ) [NV, numberOfCoordinatesValues] 5 pvlLocation = 33 ( 0x21 ) 6 dataRepresentationType = 4 ( 0x04 ) [Gaussian Latitude/Longitude Grid (grib1/6.table) ] 7-8 numberOfPointsAlongAParallel = MISSING ( 0xFF 0xFF ) [geography.Ni] 9-10 numberOfPointsAlongAMeridian = 64 ( 0x00 0x40 ) [geography.Nj] 11-13 latitudeOfFirstGridPoint = 87864 ( 0x01 0x57 0x38 ) [La1] 14-16 longitudeOfFirstGridPoint = 0 ( 0x00 0x00 0x00 ) [Lo1] 17 resolutionAndComponentFlags = 0 [00000000] 18-20 latitudeOfLastGridPoint = -87864 ( 0x81 0x57 0x38 ) [La2] 21-23 longitudeOfLastGridPoint = 357188 ( 0x05 0x73 0x44 ) [Lo2] 24-25 iDirectionIncrement = MISSING ( 0xFF 0xFF ) [Di] 26-27 numberOfParallelsBetweenAPoleAndTheEquator = 32 ( 0x00 0x20 ) 28 scanningMode = 0 [00000000] 29-32 padding_grid4_1 = 4 { 00, 00, 00, 00 } # pad padding_grid4_1 33-768 pv = (184,736) { 0, 2.00004, 3.98083, 7.38719, 12.9083, 21.4136, 33.9529, 51.7466, 76.1677, 108.716, 150.986, 204.637, 271.356, 352.824, 450.686, 566.519, 701.813, 857.946, 1036.17, 1237.59, 1463.16, 1713.71, 1989.87, 2292.16, 2620.9, 2976.3, 3358.43, 3767.2, 4202.42, 4663.78, 5150.86, 5663.16, 6199.84, 6759.73, 7341.47, 7942.93, 8564.62, 9208.3, 9873.56, 10558.9, 11262.5, 11982.7, 12713.9, 13453.2, 14192, 14922.7, 15638.1, 16329.6, 16990.6, 17613.3, 18191, 18717, 19184.5, 19587.5, 19919.8, 20175.4, 20348.9, 20434.2, 20426.2, 20319, 20107, 19785.4, 19348.8, 18798.8, 18141.3, 17385.6, 16544.6, 15633.6, 14665.6, 13653.2, 12608.4, 11543.2, 10471.3, 9405.22, 8356.25, 7335.16, 6353.92, 5422.8, 4550.21, 3743.46, 3010.15, 2356.2, 1784.85, 1297.66, 895.194, 576.314, 336.772, 162.043, 54.2083, 6.57563, 0.00316, 0, 0, 0, 0, 0, 0, 0, 0, 0 ... 84 more values } # ibmfloat pv 769-896 pl = (64,128) { 20, 27, 36, 40, 45, 50, 60, 64, 72, 75, 80, 90, 90, 96, 100, 108, 108, 120, 120, 120, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 120, 120, 120, 108, 108, 100, 96, 90, 90, 80, 75, 72, 64, 60, 50, 45, 40, 36, 27, 20 } # unsigned pl ====================== SECTION_4 ( length=9182, padding=0 ) ====================== 1-3 section4Length = 9182 ( 0x00 0x23 0xDE ) 4 dataFlag = 0 [00000000] 5-6 binaryScaleFactor = 0 ( 0x00 0x00 ) 7-10 referenceValue = 17402.8 11 numberOfBitsContainingEachPackedValue = 12 ( 0x0C ) [nbp, numberOfBits, bitsPerValue] 12-9182 values = (6114,9171) { 203.778, 203.468, 202.958, 202.348, 201.758, 201.278, 200.888, 200.558, 200.268, 200.078, 200.068, 200.318, 200.808, 201.458, 202.138, 202.758, 203.248, 203.588, 203.798, 203.878, 205.968, 205.418, 204.438, 203.218, 202.008, 201.128, 200.708, 200.598, 200.478, 200.228, 199.908, 199.528, 199.108, 198.708, 198.528, 198.748, 199.458, 200.488, 201.548, 202.478, 203.358, 204.178, 204.808, 205.198, 205.508, 205.838, 206.068, 207.338, 206.488, 205.198, 203.798, 202.548, 201.528, 200.848, 200.638, 200.818, 201.028, 200.888, 200.308, 199.638, 199.228, 199.018, 198.738, 198.328, 197.868, 197.358, 196.928, 196.858, 197.348, 198.368, 199.638, 200.758, 201.538, 202.288, 203.338, 204.438, 205.158, 205.558, 205.938, 206.438, 207.008, 207.468, 207.638, 207.178, 206.658, 205.398, 203.788, 202.468, 201.338, 200.298, 199.938, 200.318, 200.608, 200.478, 200.008, 199.208, 198.278, 197.708, 197.558, 197.318 ... 6014 more values } # data_g1simple_packing values ====================== SECTION_5 ( length=4, padding=0 ) ====================== 1-4 7777 = 7777 \endverbatim\n \n \n How to obtain all the key names available in a grib file.\n\n grib_dump -D ../data/regular_latlon_surface.grib1 \verbatim ***** FILE: ../data/regular_latlon_surface.grib1 ====================== MESSAGE 1 ( length=1100 ) ====================== 0-0 constant oneConstant = 1 0-0 constant oneMillionConstant = 1000000 0-0 offset_file offset = 0 0-0 count_file count = 1 0-0 count_total countTotal = 1 0-0 lookup kindOfProduct = 1196575042 [GRIB 1196575042 0-4] 0-0 lookup GRIBEditionNumber = 1 [? 1 7-1] ======> section GRIB (1100,1100,0) 0-0 constant grib1divider = 1000 0-0 constant ieeeFloats = 0 0-0 transient dummy = 1 ======> section section_0 (0,0,0) ----> label empty <===== section section_0 0-4 ascii identifier = GRIB 4-7 g1_message_length totalLength = 1100 7-8 unsigned editionNumber = 1 [ls.edition] ======> section section_1 (52,52,0) 8-8 constant ECMWF = 98 8-8 position offsetSection1 = 8 8-11 section_length section1Length = 52 11-12 unsigned gribTablesVersionNo = 128 [table2Version] 12-13 codetable identificationOfOriginatingGeneratingCentre = 98 [European Center for Medium-Range Weather Forecasts (grib1/0.table) ] [ls.centre, identificationOfCentre, originatingCentre] 13-14 unsigned generatingProcessIdentifier = 128 [generatingProcessIdentificationNumber, process] 14-15 unsigned gridDefinition = 255 15-16 codeflag section1Flags = 128 [10000000:(1=1) Section 2 included;(2=0) Section 3 omited:grib1/1.table] 16-17 codetable indicatorOfParameter = 167 [2T 2 metre temperature K (grib1/2.98.128.table) ] 17-17 sprintf marsParam = 167.128 [mars.param, ls.param] 17-18 codetable indicatorOfTypeOfLevel = 1 [Surface (of the Earth, which includes sea surface) (grib1/3.table) ] [ls.levelType, typeOfLevel, typeOfFirstFixedSurface, mars.levtype] 18-20 unsigned lev = 0 [topLevel, bottomLevel, ls.level, mars.levelist] 20-21 unsigned yearOfCentury = 7 21-22 unsigned month = 3 22-23 unsigned day = 18 23-24 unsigned hour = 12 24-25 unsigned minute = 0 25-25 constant second = 0 25-26 codetable indicatorOfUnitOfTimeRange = 1 [Hour (grib1/4.table) ] 26-27 unsigned periodOfTime = 0 [P1] 27-28 unsigned periodOfTimeIntervals = 0 [P2] 28-29 codetable timeRangeIndicator = 0 [Forecast product valid at reference time + P1 (P1>0) (grib1/5.table) ] 29-31 unsigned numberIncludedInAverage = 0 31-32 unsigned numberMissingFromAveragesOrAccumulations = 0 32-33 unsigned centuryOfReferenceTimeOfData = 21 33-34 codetable identificationOfOriginatingGeneratingSubCentre = 0 [Absent (grib1/0.table) ] [subCentre] 34-36 signed decimalScaleFactor = 0 36-36 transient setLocalDefinition = 0 36-48 pad reservedNeedNotBePresent = 12 { 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 } # pad reservedNeedNotBePresent 48-48 g1date dataDate = 20070318 [mars.date, ls.date] 48-48 evaluate year = 2007 48-48 g1monthlydate monthlyDate = 20070301 48-48 time dataTime = 1200 [mars.time] 48-48 g1startstep marsStartStep = 0 [mars.startStep] 48-48 g1endstep marsEndStep = 0 [mars.endStep] 48-48 g1step marsStep = 0 [mars.step, ls.step, forecastTime] 48-48 g1verificationdate verificationDate = 20070318 48-48 g1monthlydate monthlyVerificationDate = 20070301 48-48 g1day_of_the_year_date dayOfTheYearDate = 2007-078 48-48 constant wrongPadding = 0 48-48 constant localUsePresent = 1 48-48 g1param parameter = 167 48-49 unsigned localDefinitionNumber = 1 ======> section localDefinition (11,11,0) ======> section mars_labeling (8,8,0) 49-50 codetable marsClass = 1 [Operational archive (mars/class.table) ] [mars.class] 50-51 codetable marsType = 2 [Analysis (mars/type.table) ] [ls.dataType, mars.type] 51-53 codetable marsStream = 1025 [Atmospheric model (mars/stream.table) ] [mars.stream] 53-57 ksec1expver experimentVersionNumber = 0001 [mars.expver] 57-57 constant SimulationsOf30Days = s3 57-57 constant TYPE_S3 = 22 <===== section mars_labeling 57-58 unsigned perturbationNumber = 0 58-59 unsigned numberOfForecastsInEnsemble = 0 59-60 pad padding_local1_1 = 1 { 00 } # pad padding_local1_1 <===== section localDefinition 60-60 transient centreForTableNumber = 98 60-60 section_padding localExtensionPadding = 0 {} 60-60 section_padding section1Padding = 0 {} 60-60 padtoeven evenpadding_sec1 = 0 {} 60-60 concept grib1_short_name = 2T [ls.short_name] 60-60 concept grib1_name = 2_metre_temperature [name] 60-60 concept grib1_units = K [units] <===== section section_1 60-60 bit gridDescriptionSectionPresent = 1 [GDSPresent] 60-60 bit bitmapPresent = 0 [bitmapSectionPresent] ======> section section_2 (32,32,0) 60-60 position offsetSection2 = 60 60-63 section_length section2Length = 32 63-64 unsigned numberOfVerticalCoordinateValues = 0 [NV, numberOfCoordinatesValues] 64-64 constant neitherPresent = 255 64-65 unsigned pvlLocation = 255 65-66 codetable dataRepresentationType = 0 [Latitude/Longitude Grid (grib1/6.table) ] ======> section dataRepresentation (22,22,0) 66-66 constant gridDefinitionTemplateNumber = 0 66-68 unsigned numberOfPointsAlongAParallel = 16 [Ni] 68-70 unsigned numberOfPointsAlongAMeridian = 31 [Nj] 70-73 signed latitudeOfFirstGridPoint = 60000 [La1] 73-73 scale latitudeOfFirstGridPointInDegrees = 60 [geography.laFirst] 73-76 signed longitudeOfFirstGridPoint = 0 [Lo1] 76-76 scale longitudeOfFirstGridPointInDegrees = 0 [geography.loFirst] 76-77 codeflag resolutionAndComponentFlags = 128 [10000000:(1=1) Direction increments given;(2=0) Earth assumed spherical with radius = 6367.47 km;(5=0) u and v components resolved relative to easterly and northerly directions:grib1/7.table] 77-77 bit ijDirectionIncrementGiven = 1 [iDirectionIncrementGiven, jDirectionIncrementGiven, DiGiven, DjGiven] 77-77 bit earthIsOblate = 0 77-77 bit resolutionAndComponentFlags3 = 0 77-77 bit resolutionAndComponentFlags4 = 0 77-77 bit uvRelativeToGrid = 0 77-77 bit resolutionAndComponentFlags6 = 0 77-77 bit resolutionAndComponentFlags7 = 0 77-77 bit resolutionAndComponentFlags8 = 0 77-80 signed latitudeOfLastGridPoint = 0 [La2] 80-80 scale latitudeOfLastGridPointInDegrees = 0 [geography.laLast] 80-83 signed longitudeOfLastGridPoint = 30000 [Lo2] 83-83 transient longitudeOfLastGridPointG1to2 = 30000 83-83 scale longitudeOfLastGridPointInDegrees = 30 [geography.loLast] 83-85 unsigned iDirectionIncrement = 2000 [Di] 85-87 unsigned jDirectionIncrement = 2000 [Dj] 87-88 codeflag scanningMode = 0 [00000000:(1=0) Points scan in +i direction;(2=0) Points scan in -j direction;(3=0) Adjacent points in i direction are consecutive :grib1/8.table] 88-88 bit iScansNegatively = 0 88-88 bit jScansPositively = 0 88-88 bit jPointsAreConsecutive = 0 88-88 constant iScansPositively = 1 88-88 bit scanningMode4 = 0 88-88 bit scanningMode5 = 0 88-88 bit scanningMode6 = 0 88-88 bit scanningMode7 = 0 88-88 bit scanningMode8 = 0 88-88 latlon_increment jDirectionIncrementInDegrees = 2 [geography.jInc, geography.gridNorthSouth] 88-88 latlon_increment iDirectionIncrementInDegrees = 2 [geography.iInc, geography.gridWestEast] ----> iterator ITERATOR <===== section dataRepresentation 88-88 position endGridDefinition = 88 88-88 transient PVPresent = 0 88-88 position offsetBeforePV = 88 88-88 position offsetBeforePL = 88 88-88 transient PLPresent = 0 [reducedGrid] 88-92 padto padding_sec2_1 = 4 { 00, 00, 00, 00 } # padto padding_sec2_1 92-92 padtoeven padding_sec2_3 = 0 {} <===== section section_2 92-92 position endOfHeadersMaker = 92 92-92 transient missingValue = 9999 92-92 constant tableReference = 0 ======> section section_4 (1004,1004,0) 92-92 position offsetSection4 = 92 92-95 g1_section4_length section4Length = 1004 95-95 g1_half_byte_codeflag halfByte = 8 95-96 codeflag dataFlag = 8 [00001000:(1=0) Grid-point data;(2=0) Simple packing;(3=0) Floating point values are represented;(4=0) No additional flags at octet 14:grib1/11.table] 96-98 signed binaryScaleFactor = -10 98-102 ibmfloat referenceValue = 269.587 102-103 unsigned numberOfBitsContainingEachPackedValue = 16 [nbp, numberOfBits, bitsPerValue] 103-103 bit sphericalHarmonics = 0 103-103 bit complexPacking = 0 103-103 bit integerPointValues = 0 103-103 bit additionalFlagPresent = 0 ======> section dataValues (993,993,0) 103-103 constant dataRepresentationTemplateNumber = 0 103-103 position offsetBeforeData = 103 103-103 constant bitMapIndicator = 255 103-1096 data_g1simple_packing values = (496,993) { 277.704, 277.797, 278.103, 274.598, 269.587, 278.345, 277.213, 278.19, 277.853, 276.747, 274.361, 273.636, 274.593, 273.782, 273.016, 274.316, 278.492, 278.792, 278.836, 278.333, 277.389, 278.525, 278.175, 277.255, 277.383, 278.047, 277.877, 276.213, 273.99, 278.333, 278.58, 277.642, 278.865, 278.997, 278.509, 278.983, 279.527, 279.414, 278.8, 278.749, 278.895, 279.056, 278.699, 278.426, 276.601, 277.491, 279.646, 279.198, 279.108, 279.156, 279.406, 279.527, 280.344, 280.869, 279.951, 281.621, 281.221, 280.676, 281.049, 280.354, 279.025, 278.192, 280.05, 280.375, 280.68, 281.269, 281.406, 281.483, 279.454, 280.641, 282.984, 282.578, 281.797, 281.542, 281.854, 281.5, 279.917, 280.529, 282.008, 281.102, 282.223, 282.727, 280.315, 278.539, 280.066, 280.789, 280.517, 282.883, 283.897, 285.161, 285.779, 285.847, 281.973, 282.869, 281.926, 280.816, 282.48, 281.894, 281.035, 281.722 ... 396 more values } # data_g1simple_packing values <===== section dataValues 1096-1096 size valuesCount = 496 1096-1096 concept typeOfGrid = regular_ll [ls.gridType] 1096-1096 concept typeOfPacking = grid_simple [ls.packingType, dataRepresentation] 1096-1096 padtoeven padding_sec4_1 = 0 {} <===== section section_4 ======> section section_5 (4,4,0) ----> label gribSection5 1096-1096 position offsetSection5 = 1096 1096-1100 ascii 7777 = 7777 <===== section section_5 <===== section GRIB \endverbatim\n \n\n How to obtain a C code example from a grib file.\n\n grib_dump -C ../data/regular_latlon_surface.grib1\n \code #include /* This code was generated automatically */ int main(int argc,const char** argv) { grib_handle *h = NULL; size_t size = 0; double* v = NULL; FILE* f = NULL; const char* p = NULL; const void* buffer = NULL; if(argc != 2) { fprintf(stderr,"usage: %s out\n",argv[0]); exit(1); } h = grib_handle_new_from_samples(NULL,"GRIB2"); if(!h) { fprintf(stderr,"Cannot create grib handle\n"); exit(1); } /* empty */ GRIB_CHECK(grib_set_long(h,"editionNumber",1),0); GRIB_CHECK(grib_set_long(h,"gribTablesVersionNo",128),0); /* 98 = European Center for Medium-Range Weather Forecasts (grib1/0.table) */ GRIB_CHECK(grib_set_long(h,"identificationOfOriginatingGeneratingCentre",98),0); GRIB_CHECK(grib_set_long(h,"generatingProcessIdentifier",128),0); GRIB_CHECK(grib_set_long(h,"gridDefinition",255),0); /* 128 = 10000000 (1=1) Section 2 included (2=0) Section 3 omited See grib1/1.table */ GRIB_CHECK(grib_set_long(h,"section1Flags",128),0); /* 167 = 2T 2 metre temperature K (grib1/2.98.128.table) */ GRIB_CHECK(grib_set_long(h,"indicatorOfParameter",167),0); /* 1 = Surface (of the Earth, which includes sea surface) (grib1/3.table) */ GRIB_CHECK(grib_set_long(h,"indicatorOfTypeOfLevel",1),0); GRIB_CHECK(grib_set_long(h,"lev",0),0); GRIB_CHECK(grib_set_long(h,"yearOfCentury",7),0); GRIB_CHECK(grib_set_long(h,"month",3),0); GRIB_CHECK(grib_set_long(h,"day",18),0); GRIB_CHECK(grib_set_long(h,"hour",12),0); GRIB_CHECK(grib_set_long(h,"minute",0),0); /* 1 = Hour (grib1/4.table) */ GRIB_CHECK(grib_set_long(h,"indicatorOfUnitOfTimeRange",1),0); GRIB_CHECK(grib_set_long(h,"periodOfTime",0),0); GRIB_CHECK(grib_set_long(h,"periodOfTimeIntervals",0),0); /* 0 = Forecast product valid at reference time + P1 (P1>0) (grib1/5.table) */ GRIB_CHECK(grib_set_long(h,"timeRangeIndicator",0),0); GRIB_CHECK(grib_set_long(h,"numberIncludedInAverage",0),0); GRIB_CHECK(grib_set_long(h,"numberMissingFromAveragesOrAccumulations",0),0); GRIB_CHECK(grib_set_long(h,"centuryOfReferenceTimeOfData",21),0); /* 0 = Absent (grib1/0.table) */ GRIB_CHECK(grib_set_long(h,"identificationOfOriginatingGeneratingSubCentre",0),0); GRIB_CHECK(grib_set_long(h,"decimalScaleFactor",0),0); GRIB_CHECK(grib_set_long(h,"localDefinitionNumber",1),0); /* 1 = Operational archive (mars/class.table) */ GRIB_CHECK(grib_set_long(h,"marsClass",1),0); /* 2 = Analysis (mars/type.table) */ GRIB_CHECK(grib_set_long(h,"marsType",2),0); /* 1025 = Atmospheric model (mars/stream.table) */ GRIB_CHECK(grib_set_long(h,"marsStream",1025),0); p = "0001"; size = strlen(p)+1; GRIB_CHECK(grib_set_string(h,"experimentVersionNumber",p,&size),0); GRIB_CHECK(grib_set_long(h,"perturbationNumber",0),0); GRIB_CHECK(grib_set_long(h,"numberOfForecastsInEnsemble",0),0); GRIB_CHECK(grib_set_long(h,"numberOfVerticalCoordinateValues",0),0); GRIB_CHECK(grib_set_long(h,"pvlLocation",255),0); /* 0 = Latitude/Longitude Grid (grib1/6.table) */ GRIB_CHECK(grib_set_long(h,"dataRepresentationType",0),0); GRIB_CHECK(grib_set_long(h,"numberOfPointsAlongAParallel",16),0); GRIB_CHECK(grib_set_long(h,"numberOfPointsAlongAMeridian",31),0); GRIB_CHECK(grib_set_long(h,"latitudeOfFirstGridPoint",60000),0); GRIB_CHECK(grib_set_long(h,"longitudeOfFirstGridPoint",0),0); /* 128 = 10000000 (1=1) Direction increments given (2=0) Earth assumed spherical with radius = 6367.47 km (5=0) u and v components resolved relative to easterly and northerly directions See grib1/7.table */ GRIB_CHECK(grib_set_long(h,"resolutionAndComponentFlags",128),0); GRIB_CHECK(grib_set_long(h,"latitudeOfLastGridPoint",0),0); GRIB_CHECK(grib_set_long(h,"longitudeOfLastGridPoint",30000),0); GRIB_CHECK(grib_set_long(h,"iDirectionIncrement",2000),0); GRIB_CHECK(grib_set_long(h,"jDirectionIncrement",2000),0); /* 0 = 00000000 (1=0) Points scan in +i direction (2=0) Points scan in -j direction (3=0) Adjacent points in i direction are consecutive See grib1/8.table */ GRIB_CHECK(grib_set_long(h,"scanningMode",0),0); /* ITERATOR */ /* 8 = 00001000 (1=0) Grid-point data (2=0) Simple packing (3=0) Floating point values are represented (4=0) No additional flags at octet 14 See grib1/11.table */ GRIB_CHECK(grib_set_long(h,"dataFlag",8),0); GRIB_CHECK(grib_set_long(h,"numberOfBitsContainingEachPackedValue",16),0); size = 496; v = (double*)calloc(size,sizeof(double)); if(!v) { fprintf(stderr,"failed to allocate %d bytes\n",size*sizeof(double)); exit(1); } v[ 0] = 277.704; v[ 1] = 277.797; v[ 2] = 278.103; v[ 3] = 274.598; v[ 4] = 269.587; v[ 5] = 278.345; v[ 6] = 277.213; v[ 7] = 278.19; v[ 8] = 277.853; v[ 9] = 276.747; v[ 10] = 274.361; v[ 11] = 273.636; v[ 12] = 274.593; v[ 13] = 273.782; v[ 14] = 273.016; v[ 15] = 274.316; v[ 16] = 278.492; v[ 17] = 278.792; v[ 18] = 278.836; v[ 19] = 278.333; v[ 20] = 277.389; v[ 21] = 278.525; v[ 22] = 278.175; v[ 23] = 277.255; v[ 24] = 277.383; v[ 25] = 278.047; v[ 26] = 277.877; v[ 27] = 276.213; v[ 28] = 273.99; v[ 29] = 278.333; v[ 30] = 278.58; v[ 31] = 277.642; v[ 32] = 278.865; v[ 33] = 278.997; v[ 34] = 278.509; v[ 35] = 278.983; v[ 36] = 279.527; v[ 37] = 279.414; v[ 38] = 278.8; v[ 39] = 278.749; v[ 40] = 278.895; v[ 41] = 279.056; v[ 42] = 278.699; v[ 43] = 278.426; v[ 44] = 276.601; v[ 45] = 277.491; v[ 46] = 279.646; v[ 47] = 279.198; v[ 48] = 279.108; v[ 49] = 279.156; v[ 50] = 279.406; v[ 51] = 279.527; v[ 52] = 280.344; v[ 53] = 280.869; v[ 54] = 279.951; v[ 55] = 281.621; v[ 56] = 281.221; v[ 57] = 280.676; v[ 58] = 281.049; v[ 59] = 280.354; v[ 60] = 279.025; v[ 61] = 278.192; v[ 62] = 280.05; v[ 63] = 280.375; v[ 64] = 280.68; v[ 65] = 281.269; v[ 66] = 281.406; v[ 67] = 281.483; v[ 68] = 279.454; v[ 69] = 280.641; v[ 70] = 282.984; v[ 71] = 282.578; v[ 72] = 281.797; v[ 73] = 281.542; v[ 74] = 281.854; v[ 75] = 281.5; v[ 76] = 279.917; v[ 77] = 280.529; v[ 78] = 282.008; v[ 79] = 281.102; v[ 80] = 282.223; v[ 81] = 282.727; v[ 82] = 280.315; v[ 83] = 278.539; v[ 84] = 280.066; v[ 85] = 280.789; v[ 86] = 280.517; v[ 87] = 282.883; v[ 88] = 283.897; v[ 89] = 285.161; v[ 90] = 285.779; v[ 91] = 285.847; v[ 92] = 281.973; v[ 93] = 282.869; v[ 94] = 281.926; v[ 95] = 280.816; v[ 96] = 282.48; v[ 97] = 281.894; v[ 98] = 281.035; v[ 99] = 281.722; v[ 100] = 279.978; v[ 101] = 284.138; v[ 102] = 287.234; v[ 103] = 287.831; v[ 104] = 288.452; v[ 105] = 289.882; v[ 106] = 287.776; v[ 107] = 287.946; v[ 108] = 281.466; v[ 109] = 284.771; v[ 110] = 283.343; v[ 111] = 282.477; v[ 112] = 284.723; v[ 113] = 280.869; v[ 114] = 285.693; v[ 115] = 284.132; v[ 116] = 276.881; v[ 117] = 283.388; v[ 118] = 287.295; v[ 119] = 286.764; v[ 120] = 291.798; v[ 121] = 291.607; v[ 122] = 290.086; v[ 123] = 286.769; v[ 124] = 284.24; v[ 125] = 280.884; v[ 126] = 286.866; v[ 127] = 284.694; v[ 128] = 285.417; v[ 129] = 283.823; v[ 130] = 289.898; v[ 131] = 290.317; v[ 132] = 287.031; v[ 133] = 287.949; v[ 134] = 289.263; v[ 135] = 289.869; v[ 136] = 289.926; v[ 137] = 289.535; v[ 138] = 289.817; v[ 139] = 287.768; v[ 140] = 290.394; v[ 141] = 290.294; v[ 142] = 287.069; v[ 143] = 281.759; v[ 144] = 289.132; v[ 145] = 287.316; v[ 146] = 287.548; v[ 147] = 287.181; v[ 148] = 287.645; v[ 149] = 289.492; v[ 150] = 288.956; v[ 151] = 286.634; v[ 152] = 289.7; v[ 153] = 289.189; v[ 154] = 287.704; v[ 155] = 291.151; v[ 156] = 286.208; v[ 157] = 291.093; v[ 158] = 284.818; v[ 159] = 282.097; v[ 160] = 289.244; v[ 161] = 288.263; v[ 162] = 289.545; v[ 163] = 290.018; v[ 164] = 289.881; v[ 165] = 290.215; v[ 166] = 289.999; v[ 167] = 289.447; v[ 168] = 284.105; v[ 169] = 290.686; v[ 170] = 288.128; v[ 171] = 290.241; v[ 172] = 289.116; v[ 173] = 289.576; v[ 174] = 291.8; v[ 175] = 286.35; v[ 176] = 289.239; v[ 177] = 289.525; v[ 178] = 289.45; v[ 179] = 290.114; v[ 180] = 290.301; v[ 181] = 289.429; v[ 182] = 290.005; v[ 183] = 287.195; v[ 184] = 289.823; v[ 185] = 290.313; v[ 186] = 290.792; v[ 187] = 286.693; v[ 188] = 291.941; v[ 189] = 290.783; v[ 190] = 290.818; v[ 191] = 287.234; v[ 192] = 287.001; v[ 193] = 287.49; v[ 194] = 286.791; v[ 195] = 286.71; v[ 196] = 287.182; v[ 197] = 290.49; v[ 198] = 290.322; v[ 199] = 289.957; v[ 200] = 290.056; v[ 201] = 289.915; v[ 202] = 289.917; v[ 203] = 290.251; v[ 204] = 290.502; v[ 205] = 290.782; v[ 206] = 291.367; v[ 207] = 291.025; v[ 208] = 290.326; v[ 209] = 285.912; v[ 210] = 290.003; v[ 211] = 294.341; v[ 212] = 294.048; v[ 213] = 291.771; v[ 214] = 290.675; v[ 215] = 291.203; v[ 216] = 291.478; v[ 217] = 290.939; v[ 218] = 290.555; v[ 219] = 289.821; v[ 220] = 290.126; v[ 221] = 291.021; v[ 222] = 291.243; v[ 223] = 290.761; v[ 224] = 291.05; v[ 225] = 291.556; v[ 226] = 292.386; v[ 227] = 293.149; v[ 228] = 293.301; v[ 229] = 291.821; v[ 230] = 290.157; v[ 231] = 293.427; v[ 232] = 292.629; v[ 233] = 292.25; v[ 234] = 294.59; v[ 235] = 296.421; v[ 236] = 296.16; v[ 237] = 290.221; v[ 238] = 290.882; v[ 239] = 290.864; v[ 240] = 294.69; v[ 241] = 294.224; v[ 242] = 294.332; v[ 243] = 293.917; v[ 244] = 292.863; v[ 245] = 293.005; v[ 246] = 292.814; v[ 247] = 295.443; v[ 248] = 296.665; v[ 249] = 298.566; v[ 250] = 298.846; v[ 251] = 298.165; v[ 252] = 297.105; v[ 253] = 294.729; v[ 254] = 294.968; v[ 255] = 293.305; v[ 256] = 298.003; v[ 257] = 296.402; v[ 258] = 295.03; v[ 259] = 295.649; v[ 260] = 295.811; v[ 261] = 297.203; v[ 262] = 298.222; v[ 263] = 297.12; v[ 264] = 299.167; v[ 265] = 298.919; v[ 266] = 298.372; v[ 267] = 297.932; v[ 268] = 296.47; v[ 269] = 295.208; v[ 270] = 294.647; v[ 271] = 294.034; v[ 272] = 300.407; v[ 273] = 301.659; v[ 274] = 300.621; v[ 275] = 297.093; v[ 276] = 295.676; v[ 277] = 298.434; v[ 278] = 298.906; v[ 279] = 302.369; v[ 280] = 300.815; v[ 281] = 299.277; v[ 282] = 298.643; v[ 283] = 298.381; v[ 284] = 296.632; v[ 285] = 294.887; v[ 286] = 295.411; v[ 287] = 293.665; v[ 288] = 303.051; v[ 289] = 304.741; v[ 290] = 304.555; v[ 291] = 301.901; v[ 292] = 301.846; v[ 293] = 300.793; v[ 294] = 302.141; v[ 295] = 300.521; v[ 296] = 300.74; v[ 297] = 301.164; v[ 298] = 299.811; v[ 299] = 298.146; v[ 300] = 298.443; v[ 301] = 293.905; v[ 302] = 295.545; v[ 303] = 296.185; v[ 304] = 306.254; v[ 305] = 307.698; v[ 306] = 307.503; v[ 307] = 304.62; v[ 308] = 304.458; v[ 309] = 303.097; v[ 310] = 303.69; v[ 311] = 303.482; v[ 312] = 303.514; v[ 313] = 304.001; v[ 314] = 299.346; v[ 315] = 298.529; v[ 316] = 297.935; v[ 317] = 295.495; v[ 318] = 295.846; v[ 319] = 296.122; v[ 320] = 309.596; v[ 321] = 308.059; v[ 322] = 305.473; v[ 323] = 305.581; v[ 324] = 306.11; v[ 325] = 303.994; v[ 326] = 304.602; v[ 327] = 304.286; v[ 328] = 304.18; v[ 329] = 305.511; v[ 330] = 300.083; v[ 331] = 299.69; v[ 332] = 297.061; v[ 333] = 296.252; v[ 334] = 296.508; v[ 335] = 298.427; v[ 336] = 309.837; v[ 337] = 309.568; v[ 338] = 308.175; v[ 339] = 306.983; v[ 340] = 307.399; v[ 341] = 303.002; v[ 342] = 303.582; v[ 343] = 303.765; v[ 344] = 304.829; v[ 345] = 303.815; v[ 346] = 302.952; v[ 347] = 301.263; v[ 348] = 296.397; v[ 349] = 298.184; v[ 350] = 297.765; v[ 351] = 299.807; v[ 352] = 311.829; v[ 353] = 309.43; v[ 354] = 307.672; v[ 355] = 307.068; v[ 356] = 306.384; v[ 357] = 304.862; v[ 358] = 304.397; v[ 359] = 303.944; v[ 360] = 304.673; v[ 361] = 304.326; v[ 362] = 303.948; v[ 363] = 302.827; v[ 364] = 297.377; v[ 365] = 296.722; v[ 366] = 298.711; v[ 367] = 300.744; v[ 368] = 310.353; v[ 369] = 309.716; v[ 370] = 309.28; v[ 371] = 308.163; v[ 372] = 306.711; v[ 373] = 305.75; v[ 374] = 304.74; v[ 375] = 305.384; v[ 376] = 304.885; v[ 377] = 305.735; v[ 378] = 307.71; v[ 379] = 303.764; v[ 380] = 303.073; v[ 381] = 300.87; v[ 382] = 300.858; v[ 383] = 302.205; v[ 384] = 311.264; v[ 385] = 311.085; v[ 386] = 310.432; v[ 387] = 308.94; v[ 388] = 305.619; v[ 389] = 307; v[ 390] = 306.413; v[ 391] = 307.649; v[ 392] = 308.429; v[ 393] = 309.358; v[ 394] = 309.365; v[ 395] = 307.933; v[ 396] = 306.15; v[ 397] = 305.126; v[ 398] = 305.611; v[ 399] = 303.336; v[ 400] = 309.947; v[ 401] = 309.562; v[ 402] = 309.339; v[ 403] = 310.316; v[ 404] = 308.055; v[ 405] = 307.565; v[ 406] = 310.605; v[ 407] = 308.4; v[ 408] = 309.219; v[ 409] = 310.801; v[ 410] = 310.525; v[ 411] = 309.65; v[ 412] = 306.611; v[ 413] = 306.033; v[ 414] = 307.988; v[ 415] = 308.941; v[ 416] = 308.4; v[ 417] = 307.615; v[ 418] = 307.404; v[ 419] = 308.381; v[ 420] = 309.778; v[ 421] = 311.715; v[ 422] = 308.409; v[ 423] = 307.156; v[ 424] = 308.715; v[ 425] = 307.201; v[ 426] = 310.448; v[ 427] = 309.24; v[ 428] = 306.716; v[ 429] = 307.307; v[ 430] = 309.062; v[ 431] = 309.776; v[ 432] = 303.033; v[ 433] = 302.76; v[ 434] = 303.071; v[ 435] = 306.578; v[ 436] = 309.819; v[ 437] = 305.046; v[ 438] = 309.764; v[ 439] = 307.857; v[ 440] = 301.171; v[ 441] = 302.783; v[ 442] = 301.107; v[ 443] = 300.429; v[ 444] = 303.189; v[ 445] = 304.585; v[ 446] = 303.709; v[ 447] = 307.132; v[ 448] = 302.315; v[ 449] = 302.922; v[ 450] = 302.593; v[ 451] = 302.476; v[ 452] = 302.132; v[ 453] = 305.953; v[ 454] = 300.132; v[ 455] = 301.361; v[ 456] = 302.355; v[ 457] = 304.042; v[ 458] = 302.175; v[ 459] = 297.057; v[ 460] = 296.072; v[ 461] = 296.644; v[ 462] = 296.895; v[ 463] = 296.22; v[ 464] = 300.897; v[ 465] = 300.839; v[ 466] = 300.899; v[ 467] = 301.941; v[ 468] = 302.709; v[ 469] = 301.495; v[ 470] = 302.248; v[ 471] = 301.468; v[ 472] = 303.598; v[ 473] = 304.599; v[ 474] = 299.779; v[ 475] = 297.9; v[ 476] = 295.564; v[ 477] = 296.015; v[ 478] = 293.688; v[ 479] = 294.294; v[ 480] = 300.801; v[ 481] = 300.724; v[ 482] = 301.204; v[ 483] = 302.463; v[ 484] = 302.885; v[ 485] = 305.413; v[ 486] = 305.523; v[ 487] = 303.672; v[ 488] = 304.547; v[ 489] = 303.334; v[ 490] = 301.616; v[ 491] = 298.654; v[ 492] = 297.975; v[ 493] = 295.379; v[ 494] = 293.83; v[ 495] = 300.082; GRIB_CHECK(grib_set_double_array(h,"values",v,size),0); free(v); /* gribSection5 */ /* Save the message */ f = fopen(argv[1],"w"); if(!f) { perror(argv[1]); exit(1); } GRIB_CHECK(grib_get_message(h,&buffer,&size),0); if(fwrite(buffer,1,size,f) != size) { perror(argv[1]); exit(1); } if(fclose(f)) { perror(argv[1]); exit(1); } grib_handle_delete(h); return 0; } \endcode\n */