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 10# label Grib_section_2; 11# START grib1::section 12# SECTION 2, Grid description section 13# Length of section 14# (octets) 15 16position offsetSection2; 17length[3] section2Length ; 18meta section2Pointer section_pointer(offsetSection2,section2Length,2); 19transient radius=6367470; 20alias radiusOfTheEarth=radius; 21alias radiusInMetres=radius; 22transient shapeOfTheEarth=6 : hidden; 23 24# NV -- number of vertical coordinate parameters 25 26unsigned[1] numberOfVerticalCoordinateValues : dump ; 27 28constant neitherPresent = 255; 29 30alias NV = numberOfVerticalCoordinateValues; 31alias numberOfCoordinatesValues= numberOfVerticalCoordinateValues; 32 33# PV -- location 34# (octet number) 35 36unsigned[1] pvlLocation = 255; 37 38# Data representation type 39codetable[1] dataRepresentationType 'grib1/6.table' = 0; 40meta gridDefinitionDescription codetable_title(dataRepresentationType); 41 42 43# Grid definition 44# (according to data representation type - octet 6 above) 45alias is_rotated_grid=zero; 46 47if (dataRepresentationType < 192) 48{ 49 template dataRepresentation "grib1/grid_definition_[dataRepresentationType:l].def"; 50} 51else 52{ 53 template dataRepresentation "grib1/grid_definition_[dataRepresentationType:l].[centre:l].def"; 54} 55position endGridDefinition; 56 57position offsetBeforePV; 58transient PVPresent = ( NV > 0); 59 60if (pvlLocation != neitherPresent) 61{ 62 padto padding_sec2_2(offsetSection2 + pvlLocation - 1); 63} else { 64 padto padding_sec2_2(offsetSection2 + 32 ); 65} 66 67if(PVPresent ) 68{ 69 ibmfloat pv[NV] : dump; 70 alias vertical.pv=pv; 71} 72 73position offsetBeforePL; 74 75transient PLPresent = (section2Length > (offsetBeforePL - offsetSection2)) 76 && (section2Length >= (Nj * 2 + offsetBeforePL - offsetSection2)) ; 77 78if(PLPresent) 79{ 80 # For grib 1 -> 2 81 constant numberOfOctectsForNumberOfPoints = 2; 82 constant interpretationOfNumberOfPoints = 1; 83 84 unsigned[2] pl[Nj] : dump; 85 alias geography.pl=pl; 86} 87 88if(PVPresent == 0 && PLPresent == 0) 89{ 90 # pad to the end of the grid definiton as in documentation 91 # ( gribex compatibility ) 92 padto padding_sec2_1(offsetSection2 + 32); 93} 94 95#when (PVPresent == 0) { set NV = 0;} 96when ((PVPresent == 1) or (PLPresent==1)) { 97 set pvlLocation = offsetBeforePV - offsetSection2 + 1; 98} 99when ((PVPresent == 0) and (PLPresent==0)) { set pvlLocation = 255; } 100 101alias reducedGrid = PLPresent; 102 103# GRIB-534: To easily remove vertical coordinates, set this key to 1 104concept_nofail deletePV(unknown) { 105 "1" = { PVPresent=0; NV=0; } 106} 107 108padtoeven padding_sec2_3(offsetSection2,section2Length); 109 110meta md5Section2 md5(offsetSection2,section2Length); 111alias md5GridSection = md5Section2; 112