eccodes/definitions/grib1/section.2.def

90 lines
2.5 KiB
Modula-2
Raw Normal View History

2013-03-25 12:04:10 +00:00
# SECTION 2, Grid description section
2021-03-05 12:25:16 +00:00
# Length of section
2013-03-25 12:04:10 +00:00
position offsetSection2;
section_length[3] section2Length ;
2013-03-25 12:04:10 +00:00
meta section2Pointer section_pointer(offsetSection2,section2Length,2);
transient radius=6367470;
alias radiusOfTheEarth=radius;
alias radiusInMetres=radius;
2020-07-19 17:18:55 +00:00
transient shapeOfTheEarth=0: hidden; #ECC-811
2013-03-25 12:04:10 +00:00
2021-03-05 12:25:16 +00:00
# NV -- number of vertical coordinate parameters
2013-03-25 12:04:10 +00:00
unsigned[1] numberOfVerticalCoordinateValues : dump ;
constant neitherPresent = 255;
alias NV = numberOfVerticalCoordinateValues;
alias numberOfCoordinatesValues= numberOfVerticalCoordinateValues;
2021-03-05 12:25:16 +00:00
# PV -- location (octet number)
2013-03-25 12:04:10 +00:00
unsigned[1] pvlLocation = 255;
2021-03-05 12:25:16 +00:00
# Data representation type
2013-03-25 12:04:10 +00:00
codetable[1] dataRepresentationType 'grib1/6.table' = 0;
meta gridDefinitionDescription codetable_title(dataRepresentationType);
2021-03-05 12:25:16 +00:00
# Grid definition (according to data representation type - octet 6 above)
alias isRotatedGrid = false;
2013-03-25 12:04:10 +00:00
2021-02-06 13:07:35 +00:00
if (dataRepresentationType < 192) {
2015-08-13 14:04:31 +00:00
template dataRepresentation "grib1/grid_definition_[dataRepresentationType:l].def";
2021-02-06 13:07:35 +00:00
} else {
2015-08-13 14:04:31 +00:00
template dataRepresentation "grib1/grid_definition_[dataRepresentationType:l].[centre:l].def";
2013-03-25 12:04:10 +00:00
}
position endGridDefinition;
position offsetBeforePV;
transient PVPresent = ( NV > 0);
2021-02-06 13:07:35 +00:00
if (pvlLocation != neitherPresent) {
2015-08-13 14:04:31 +00:00
padto padding_sec2_2(offsetSection2 + pvlLocation - 1);
2013-03-25 12:04:10 +00:00
} else {
2015-08-13 14:04:31 +00:00
padto padding_sec2_2(offsetSection2 + 32 );
2013-03-25 12:04:10 +00:00
}
2021-02-06 13:07:35 +00:00
if (PVPresent ) {
2013-03-25 12:04:10 +00:00
ibmfloat pv[NV] : dump;
alias vertical.pv=pv;
}
position offsetBeforePL;
transient PLPresent = (section2Length > (offsetBeforePL - offsetSection2))
2021-02-06 13:07:35 +00:00
&& (section2Length >= (Nj * 2 + offsetBeforePL - offsetSection2));
2013-03-25 12:04:10 +00:00
2021-02-06 13:07:35 +00:00
if (PLPresent) {
2013-03-25 12:04:10 +00:00
# For grib 1 -> 2
2015-08-13 14:04:31 +00:00
constant numberOfOctectsForNumberOfPoints = 2;
constant interpretationOfNumberOfPoints = 1;
2013-03-25 12:04:10 +00:00
unsigned[2] pl[Nj] : dump;
alias geography.pl=pl;
}
2021-02-06 13:07:35 +00:00
if (PVPresent == 0 && PLPresent == 0) {
2013-03-25 12:04:10 +00:00
# pad to the end of the grid definiton as in documentation
# ( gribex compatibility )
padto padding_sec2_1(offsetSection2 + 32);
}
#when (PVPresent == 0) { set NV = 0;}
when ((PVPresent == 1) or (PLPresent==1)) {
set pvlLocation = offsetBeforePV - offsetSection2 + 1;
}
when ((PVPresent == 0) and (PLPresent==0)) { set pvlLocation = 255; }
alias reducedGrid = PLPresent;
2014-09-29 17:03:49 +00:00
# GRIB-534: To easily remove vertical coordinates, set this key to 1
concept_nofail deletePV(unknown) {
"1" = { PVPresent=0; NV=0; }
}
2013-03-25 12:04:10 +00:00
padtoeven padding_sec2_3(offsetSection2,section2Length);
meta md5Section2 md5(offsetSection2,section2Length);
alias md5GridSection = md5Section2;
constant isSpectral = !isGridded : constraint;