1
# Copyright 2005-2007 ECMWF
3
# Licensed under the GNU Lesser General Public License which
4
# incorporates the terms and conditions of version 3 of the GNU
5
# General Public License.
6
# See LICENSE and gpl-3.0.txt for details.
8
constant ECMWF = 98 : hidden;
9
constant ECMWF_s = "ecmf" : hidden;
11
constant hundred=100 :hidden;
12
constant conceptsMasterDir="grib1" : hidden;
13
constant conceptsLocalDirECMF="grib1/localConcepts/ecmf" : hidden;
14
constant conceptsLocalDirAll="grib1/localConcepts/[centre:s]" : hidden;
15
transient productionStatusOfProcessedData=0;
16
position offsetSection1;
17
length[3] section1Length ;
18
meta section1Pointer section_pointer(offsetSection1,section1Length,1);
20
# GRIB tables Version No.
21
# (currently 3 for international exchange)
22
unsigned[1] table2Version : edition_specific,dump;
23
alias gribTablesVersionNo=table2Version;
25
#assert(section1Length > 5);
27
# Identification of originating/generating center
28
codetable[1] centre 'grib1/0.table' : dump,string_type;
30
alias parameter.centre=centre;
31
alias originatingCentre=centre;
32
alias ls.centre = centre;
33
alias identificationOfOriginatingGeneratingCentre=centre;
35
# Generating process identification number
36
# (allocated by originating center)
37
unsigned[1] generatingProcessIdentifier : dump ;
38
alias generatingProcessIdentificationNumber=generatingProcessIdentifier;
39
alias process=generatingProcessIdentifier;
41
unsigned[1] gridDefinition = 255 : edition_specific ;
42
flags[1] section1Flags 'grib1/1.table' = 128 : hidden ; # = section 2 present
44
alias centreForTable2=centre;
46
codetable[1] indicatorOfParameter 'grib1/2.[centreForTable2:l].[table2Version:l].table' : edition_specific,no_copy,dump;
47
meta parameterName codetable_title(indicatorOfParameter);
48
meta parameterUnits codetable_units(indicatorOfParameter);
50
meta marsParam sprintf("%d.%d",indicatorOfParameter,gribTablesVersionNo): read_only,dump;
51
alias ls.param=marsParam;
53
codetable[1] indicatorOfTypeOfLevel 'grib1/3.table' : edition_specific,no_copy,dump,string_type;
54
alias ls.levelType=indicatorOfTypeOfLevel;
56
transient pressureUnits="hPa";
58
concept_nofail vertical.typeOfLevel (unknown) {
59
#set uses the last one
60
#get returns the first match
61
'surface' = {indicatorOfTypeOfLevel=1;}
62
'cloudBase' = {indicatorOfTypeOfLevel=2;}
63
'cloudTop' = {indicatorOfTypeOfLevel=3;}
64
'isothermZero' = {indicatorOfTypeOfLevel=4;}
65
'adiabaticCondensation' = {indicatorOfTypeOfLevel=5;}
66
'maxWind' = {indicatorOfTypeOfLevel=6;}
67
'tropopause' = {indicatorOfTypeOfLevel=7;}
68
'nominalTop' = {indicatorOfTypeOfLevel=8;}
69
'seaBottom' = {indicatorOfTypeOfLevel=9;}
70
'isobaricInhPa' = {indicatorOfTypeOfLevel=100;}
71
'isobaricInPa' = {indicatorOfTypeOfLevel=210;}
72
'isobaricLayer' = {indicatorOfTypeOfLevel=101;}
73
'meanSea' = {indicatorOfTypeOfLevel=102;}
74
'isobaricLayerHighPrecision' = {indicatorOfTypeOfLevel=121;}
75
'isobaricLayerMixedPrecision' = {indicatorOfTypeOfLevel=141;}
76
'heightAboveSea' = {indicatorOfTypeOfLevel=103;}
77
'heightAboveSeaLayer' = {indicatorOfTypeOfLevel=104;}
78
'heightAboveGroundHighPrecision' = {indicatorOfTypeOfLevel=125;}
79
'heightAboveGround' = {indicatorOfTypeOfLevel=105;}
80
'heightAboveGroundLayer' = {indicatorOfTypeOfLevel=106;}
81
'sigma' = {indicatorOfTypeOfLevel=107;}
82
'sigmaLayer' = {indicatorOfTypeOfLevel=108;}
83
'sigmaLayerHighPrecision' = {indicatorOfTypeOfLevel=128;}
84
'hybrid' = {indicatorOfTypeOfLevel=109;}
85
'hybridLayer' = {indicatorOfTypeOfLevel=110;}
86
'depthBelowLand' = {indicatorOfTypeOfLevel=111;}
87
'depthBelowLandLayer' = {indicatorOfTypeOfLevel=112;}
88
'theta' = {indicatorOfTypeOfLevel=113;}
89
'thetaLayer' = {indicatorOfTypeOfLevel=114;}
90
'pressureFromGround' = {indicatorOfTypeOfLevel=115;}
91
'pressureFromGroundLayer' = {indicatorOfTypeOfLevel=116;}
92
'potentialVorticity' = {indicatorOfTypeOfLevel=117;}
93
'depthBelowSea' = {indicatorOfTypeOfLevel=160;}
94
'entireAtmosphere' = {indicatorOfTypeOfLevel=200;level=0;}
95
'entireOcean' = {indicatorOfTypeOfLevel=201;level=0;}
96
'oceanWave' = {indicatorOfTypeOfLevel=211;}
97
'oceanMixedLayer' = {indicatorOfTypeOfLevel=212;}
100
when ( typeOfLevel is "isobaricInPa" ) { set pressureUnits="Pa"; }
101
else { set pressureUnits="hPa";}
103
alias ls.typeOfLevel=typeOfLevel;
105
if ( indicatorOfTypeOfLevel == 101 or
106
indicatorOfTypeOfLevel == 104 or
107
indicatorOfTypeOfLevel == 106 or
108
indicatorOfTypeOfLevel == 108 or
109
indicatorOfTypeOfLevel == 110 or
110
indicatorOfTypeOfLevel == 112 or
111
indicatorOfTypeOfLevel == 114 or
112
indicatorOfTypeOfLevel == 116 or
113
indicatorOfTypeOfLevel == 120 or
114
indicatorOfTypeOfLevel == 121 or
115
indicatorOfTypeOfLevel == 128 or
116
indicatorOfTypeOfLevel == 141 )
118
unsigned[1] topLevel : can_be_missing,dump;
119
unsigned[1] bottomLevel : can_be_missing,dump;
120
meta levels sprintf("%d-%d",topLevel,bottomLevel) : dump;
121
alias ls.levels=levels;
122
alias vertical.level = topLevel;
123
alias vertical.topLevel = topLevel;
124
alias vertical.bottomLevel = bottomLevel;
128
if (indicatorOfTypeOfLevel == 210) {
129
unsigned[2] levelInPascal :can_be_missing,dump,no_copy;
130
meta vertical.level scale(levelInPascal,oneConstant,hundred);
132
unsigned[2] level :can_be_missing,dump;
133
alias vertical.level=level;
135
alias vertical.topLevel = level;
136
alias vertical.bottomLevel = level;
137
alias ls.level=level;
142
if(indicatorOfTypeOfLevel == 109 || indicatorOfTypeOfLevel == 100 || indicatorOfTypeOfLevel == 110 || indicatorOfTypeOfLevel == 210 || indicatorOfTypeOfLevel == 113 || indicatorOfTypeOfLevel == 117)
144
alias mars.levelist = level;
147
unsigned[1] yearOfCentury : edition_specific ;
152
transient second = 0;
154
codetable[1] unitOfTimeRange 'grib1/4.table' = 1 : edition_specific;
155
alias unitOfTime=unitOfTimeRange;
156
alias indicatorOfUnitOfTimeRange=unitOfTimeRange;
158
unsigned[1] P1 : edition_specific;
159
unsigned[1] P2 : edition_specific;
160
alias periodOfTimeIntervals=P2;
162
codetable[1] timeRangeIndicator 'grib1/5.table' = 1 : dump,edition_specific;
164
if (timeRangeIndicator==10) {
165
meta periodOfTime g1p1p2(P1,P2) : edition_specific;
167
alias periodOfTime=P1 ;
170
unsigned[2] numberIncludedInAverage;
172
meta mybits bits(numberIncludedInAverage,0,12);
174
unsigned[1] numberMissingFromAveragesOrAccumulations;
175
unsigned[1] centuryOfReferenceTimeOfData ;
177
codetable[1] subCentre 'grib1/0.[centre].table' : dump;
178
alias identificationOfOriginatingGeneratingSubCentre = subCentre;
180
if(table2Version >= 128) {
181
if (centre != 98 && subCentre == 98) {
182
alias centreForTable2 = subCentre;
184
alias centreForTable2 = centre;
187
alias centreForTable2 = WMO;
190
signed[2] decimalScaleFactor :dump;
191
transient setLocalDefinition= 0 : no_copy;
193
meta dataDate g1date(centuryOfReferenceTimeOfData,yearOfCentury,month,day) : dump;
194
meta year evaluate(dataDate / 10000) ;
196
meta dataTime time(hour,minute,second) : dump;
197
meta julianDay julian_day(dataDate,hour,minute,second) : edition_specific;
199
codetable[1] stepUnits 'grib2/tables/1/4.4.table' = "h" : transient,dump,no_copy;
201
concept stepType (timeRangeIndicator) {
202
#set uses the last one
203
#get returns the first match
204
"accum" = {timeRangeIndicator=0;centre=98;indicatorOfParameter=61;table2Version=1;}
205
"accum" = {timeRangeIndicator=0;centre=98;indicatorOfParameter=61;table2Version=2;}
206
"accum" = {timeRangeIndicator=0;centre=98;indicatorOfParameter=61;table2Version=3;}
207
"accum" = {timeRangeIndicator=0;centre=98;indicatorOfParameter=228;table2Version=128;}
208
"accum" = {timeRangeIndicator=0;centre=98;indicatorOfParameter=228;table2Version=128;}
209
"instant" = {timeRangeIndicator=1;}
210
"instant" = {timeRangeIndicator=10;}
211
"instant" = {timeRangeIndicator=0;}
212
"avg" = {timeRangeIndicator=3;}
213
"accum" = {timeRangeIndicator=4;}
214
"accum" = {timeRangeIndicator=2;}
215
"max" = {timeRangeIndicator=118;}
216
"max" = {timeRangeIndicator=2;centre=98;}
217
"min" = {timeRangeIndicator=119;}
218
"min" = {timeRangeIndicator=2;centre=98;}
219
"diff" = {timeRangeIndicator=5;}
220
"rms" = {timeRangeIndicator=120;}
221
"sd" = {timeRangeIndicator=121;}
222
"cov" = {timeRangeIndicator=122;}
223
"ratio" = {timeRangeIndicator=123;}
227
if (stepType is "instant" ) {
228
alias productDefinitionTemplateNumber=zero;
230
alias productDefinitionTemplateNumber=eight;
233
meta stepRange g1step_range(P1,P2,timeRangeIndicator,unitOfTimeRange,stepUnits,stepType) : dump;
234
meta startStep long_vector(stepRange,0) : dump,no_copy;
235
meta endStep long_vector(stepRange,1) : dump,no_copy;
237
#meta stepRangeInHours g1step_range(P1,P2,timeRangeIndicator,unitOfTimeRange) : no_copy;
238
#meta startStepInHours long_vector(stepRangeInHours,0) : no_copy;
239
#meta endStepInHours long_vector(stepRangeInHours,1) : no_copy;
240
alias stepInHours = endStep;
242
alias ls.stepRange = stepRange;
243
alias ls.stepUnits = stepUnits;
244
alias ls.date = dataDate;
246
alias mars.step = endStep;
247
alias mars.date = dataDate;
248
alias mars.param = marsParam;
249
alias mars.levtype = indicatorOfTypeOfLevel;
250
alias mars.time = dataTime;
252
meta time.validityDate validity_date(date,time,step,stepUnits);
253
meta time.validityTime validity_time(date,time,step,stepUnits);
255
constant wrongPadding = 0;
256
transient deleteLocalDefinition=0;
258
if(((section1Length > 40) or new() or setLocalDefinition> 0) and deleteLocalDefinition==0)
260
constant localUsePresent = 1 : edition_specific;
261
alias grib2LocalSectionPresent=present;
263
if( (centre == ECMWF) or
267
pad reservedNeedNotBePresent(12);
268
codetable[1] localDefinitionNumber 'grib1/localDefinitionNumber.98.table' = 1 : dump;
269
template localDefinition "grib1/local.98.[localDefinitionNumber:l].def";
270
if (changed(localDefinitionNumber)) {
271
if(!new() && localDefinitionNumber!=4 ) {
272
section_padding localExtensionPadding : read_only;
276
template_nofail marsKeywords1 "mars/grib1.[stream:s].[type:s].def";
282
pad reservedNeedNotBePresent(12);
283
template localDefinition "grib1/local.[centre:l].def";
285
section_padding localExtensionPadding : read_only;
291
constant localUsePresent = 0 : edition_specific;
292
# template defaultMarsLabeling "mars/default_labeling.def";
295
section_padding section1Padding : read_only;
298
padtoeven evenpadding_sec1(offsetSection1,section1Length);
301
if ( subCentre == 98 ) {
302
alias conceptsLocalDir=conceptsLocalDirECMF;
304
alias conceptsLocalDir=conceptsLocalDirAll;
309
concept_nofail paramId (defaultParameter,"paramId.def",conceptsMasterDir,conceptsLocalDir);
310
concept ls.shortName (defaultShortName,"shortName.def",conceptsMasterDir,conceptsLocalDir) : no_copy;
311
concept cfName (defaultShortName,"cfName.def",conceptsMasterDir,conceptsLocalDir) : no_copy;
312
concept name(defaultName,"name.def",conceptsMasterDir,conceptsLocalDir) : dump,no_copy,read_only;
313
concept units(defaultName,"units.def",conceptsMasterDir,conceptsLocalDir) : dump,no_copy,read_only;
315
alias parameter.paramId=paramId;
316
alias parameter.shortName=shortName;
318
alias parameter=paramId;
319
alias short_name=shortName;
321
alias time.stepRange=stepRange;
322
alias time.stepUnits=stepUnits;
323
alias time.dataDate=dataDate;
324
alias time.dataTime=dataTime;
325
alias time.startStep=startStep;
326
alias time.endStep=endStep;
328
meta md5Section1 md5(offsetSection1,section1Length);