1# Copyright 2005-2018 ECMWF. 2# 3# This software is licensed under the terms of the Apache Licence Version 2.0 4# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5# 6# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by 7# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. 8# 9 10constant ieeeFloats = 0 : hidden, edition_specific; 11transient eps=0; 12 13meta headersOnly headers_only(); 14 15#template section_0 "grib1/section.0.def" ; 16 17meta gts_header gts_header() : no_copy,hidden,read_only; 18meta gts_TTAAii gts_header(20,6) : no_copy,hidden,read_only; 19meta gts_CCCC gts_header(27,4) : no_copy,hidden,read_only; 20meta gts_ddhh00 gts_header(32,6) : no_copy,hidden,read_only; 21 22ascii[4] identifier = "GRIB" : read_only,hidden; 23 24constant offsetSection0=0; 25constant section0Length=8 ; 26meta section0Pointer section_pointer(offsetSection0,section0Length,0); 27 28# Due to a trick done by GRIBEX to support large GRIBs, we need a special treatment 29# of the message length and of the section4 length, so instead of 30# length[3] totalLength ; 31# we get: 32g1_message_length[3] totalLength(section4Length) ; 33position startOfHeaders; 34unsigned[1] editionNumber = 1 : edition_specific,dump; 35 36template section_1 "grib1/section.1.def" ; 37 38alias ls.edition = editionNumber; 39 40# Note flagbit numbers 7 to 0, while wmo is 1 to 8 41flagbit gridDescriptionSectionPresent(section1Flags,7) = 1; 42meta GDSPresent gds_is_present(gridDescriptionSectionPresent,gridDefinition,bitmapPresent,values): dump ; 43#alias GDSPresent = gridDescriptionSectionPresent; 44 45flagbit bitmapPresent(section1Flags,6) :dump; 46alias bitmapSectionPresent=bitmapPresent; 47alias geography.bitmapPresent=bitmapPresent; 48alias missingValuesPresent=bitmapPresent : read_only; 49transient angularPrecision=1000; # milli degrees 50 51if(gridDescriptionSectionPresent){ 52 template section_2 "grib1/section.2.def" ; 53} else { 54 template predefined_grid "grib1/predefined_grid.def"; 55} 56 57# Used to mark end of headers. Can be accessed with grib_get_offset() 58position endOfHeadersMaker; 59 60meta lengthOfHeaders evaluate( endOfHeadersMaker-startOfHeaders); 61meta md5Headers md5(startOfHeaders,lengthOfHeaders); 62 63if (!headersOnly) { 64transient missingValue = 9999 : dump; 65 66if(bitmapPresent) { 67 template section3 "grib1/section.3.def" ; 68} else { 69 constant tableReference = 0; 70} 71 72template section_4 "grib1/section.4.def" ; 73 74template section_5 "grib1/section.5.def" ; 75} 76