mirror of https://github.com/ecmwf/eccodes.git
362 lines
12 KiB
Modula-2
362 lines
12 KiB
Modula-2
# Copyright 2005-2013 ECMWF.
|
|
#
|
|
# This software is licensed under the terms of the Apache Licence Version 2.0
|
|
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
|
#
|
|
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
|
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
|
#
|
|
|
|
constant ECMWF = 98 : hidden;
|
|
constant ECMWF_s = "ecmf" : hidden;
|
|
constant WMO= 0;
|
|
constant conceptsMasterDir="grib1" : hidden;
|
|
constant conceptsLocalDirECMF="grib1/localConcepts/ecmf" : hidden;
|
|
constant conceptsLocalDirAll="grib1/localConcepts/[centre:s]" : hidden;
|
|
transient productionStatusOfProcessedData=0;
|
|
position offsetSection1;
|
|
length[3] section1Length ;
|
|
meta section1Pointer section_pointer(offsetSection1,section1Length,1);
|
|
constant wrongPadding=0;
|
|
|
|
# GRIB tables Version No.
|
|
# (currently 3 for international exchange)
|
|
unsigned[1] table2Version : edition_specific,dump;
|
|
alias gribTablesVersionNo=table2Version;
|
|
|
|
|
|
#assert(section1Length > 5);
|
|
|
|
# Identification of originating/generating centre
|
|
codetable[1] centre 'grib1/0.table' : dump,string_type;
|
|
alias identificationOfOriginatingGeneratingCentre=centre;
|
|
meta centreDescription codetable_title(centre);
|
|
|
|
alias parameter.centre=centre;
|
|
alias originatingCentre=centre;
|
|
alias ls.centre = centre;
|
|
|
|
# Generating process identification number
|
|
# (allocated by originating centre)
|
|
unsigned[1] generatingProcessIdentifier : dump ;
|
|
alias generatingProcessIdentificationNumber=generatingProcessIdentifier;
|
|
alias process=generatingProcessIdentifier;
|
|
|
|
unsigned[1] gridDefinition = 255 : edition_specific ;
|
|
flags[1] section1Flags 'grib1/1.table' = 128 : hidden ; # = section 2 present
|
|
|
|
alias centreForTable2=centre;
|
|
|
|
codetable[1] indicatorOfParameter 'grib1/2.[centreForTable2:l].[table2Version:l].table' : edition_specific,no_copy,dump;
|
|
meta parameterName codetable_title(indicatorOfParameter);
|
|
meta parameterUnits codetable_units(indicatorOfParameter);
|
|
|
|
codetable[1] indicatorOfTypeOfLevel 'grib1/3.table' : edition_specific,no_copy,dump,string_type;
|
|
alias levelType=indicatorOfTypeOfLevel;
|
|
|
|
transient pressureUnits="hPa";
|
|
|
|
concept_nofail vertical.typeOfLevel (unknown) {
|
|
#set uses the last one
|
|
#get returns the first match
|
|
'surface' = {indicatorOfTypeOfLevel=1;}
|
|
'cloudBase' = {indicatorOfTypeOfLevel=2;}
|
|
'cloudTop' = {indicatorOfTypeOfLevel=3;}
|
|
'isothermZero' = {indicatorOfTypeOfLevel=4;}
|
|
'adiabaticCondensation' = {indicatorOfTypeOfLevel=5;}
|
|
'maxWind' = {indicatorOfTypeOfLevel=6;}
|
|
'tropopause' = {indicatorOfTypeOfLevel=7;}
|
|
'nominalTop' = {indicatorOfTypeOfLevel=8;}
|
|
'seaBottom' = {indicatorOfTypeOfLevel=9;}
|
|
'isobaricInhPa' = {indicatorOfTypeOfLevel=100;}
|
|
'isobaricInPa' = {indicatorOfTypeOfLevel=210;}
|
|
'isobaricLayer' = {indicatorOfTypeOfLevel=101;}
|
|
'meanSea' = {indicatorOfTypeOfLevel=102;}
|
|
'isobaricLayerHighPrecision' = {indicatorOfTypeOfLevel=121;}
|
|
'isobaricLayerMixedPrecision' = {indicatorOfTypeOfLevel=141;}
|
|
'heightAboveSea' = {indicatorOfTypeOfLevel=103;}
|
|
'heightAboveSeaLayer' = {indicatorOfTypeOfLevel=104;}
|
|
'heightAboveGroundHighPrecision' = {indicatorOfTypeOfLevel=125;}
|
|
'heightAboveGround' = {indicatorOfTypeOfLevel=105;}
|
|
'heightAboveGroundLayer' = {indicatorOfTypeOfLevel=106;}
|
|
'sigma' = {indicatorOfTypeOfLevel=107;}
|
|
'sigmaLayer' = {indicatorOfTypeOfLevel=108;}
|
|
'sigmaLayerHighPrecision' = {indicatorOfTypeOfLevel=128;}
|
|
'hybrid' = {indicatorOfTypeOfLevel=109;}
|
|
'hybridLayer' = {indicatorOfTypeOfLevel=110;}
|
|
'depthBelowLand' = {indicatorOfTypeOfLevel=111;}
|
|
'depthBelowLandLayer' = {indicatorOfTypeOfLevel=112;}
|
|
'theta' = {indicatorOfTypeOfLevel=113;}
|
|
'thetaLayer' = {indicatorOfTypeOfLevel=114;}
|
|
'pressureFromGround' = {indicatorOfTypeOfLevel=115;}
|
|
'pressureFromGroundLayer' = {indicatorOfTypeOfLevel=116;}
|
|
'potentialVorticity' = {indicatorOfTypeOfLevel=117;}
|
|
'depthBelowSea' = {indicatorOfTypeOfLevel=160;}
|
|
'entireAtmosphere' = {indicatorOfTypeOfLevel=200;level=0;}
|
|
'entireOcean' = {indicatorOfTypeOfLevel=201;level=0;}
|
|
'oceanWave' = {indicatorOfTypeOfLevel=211;}
|
|
'oceanMixedLayer' = {indicatorOfTypeOfLevel=212;}
|
|
}
|
|
|
|
when ( typeOfLevel is "isobaricInPa" ) { set pressureUnits="Pa"; }
|
|
else { set pressureUnits="hPa";}
|
|
|
|
alias ls.typeOfLevel=typeOfLevel;
|
|
|
|
if ( indicatorOfTypeOfLevel == 101 or
|
|
indicatorOfTypeOfLevel == 104 or
|
|
indicatorOfTypeOfLevel == 106 or
|
|
indicatorOfTypeOfLevel == 108 or
|
|
indicatorOfTypeOfLevel == 110 or
|
|
indicatorOfTypeOfLevel == 112 or
|
|
indicatorOfTypeOfLevel == 114 or
|
|
indicatorOfTypeOfLevel == 116 or
|
|
indicatorOfTypeOfLevel == 120 or
|
|
indicatorOfTypeOfLevel == 121 or
|
|
indicatorOfTypeOfLevel == 128 or
|
|
indicatorOfTypeOfLevel == 141 )
|
|
{
|
|
unsigned[1] topLevel : can_be_missing,dump;
|
|
unsigned[1] bottomLevel : can_be_missing,dump;
|
|
meta levels sprintf("%d-%d",topLevel,bottomLevel) : dump;
|
|
alias ls.levels=levels;
|
|
alias vertical.level = topLevel;
|
|
alias vertical.topLevel = topLevel;
|
|
alias vertical.bottomLevel = bottomLevel;
|
|
}
|
|
else
|
|
{
|
|
unsigned[2] level : can_be_missing,dump;
|
|
if (indicatorOfTypeOfLevel == 210) {
|
|
meta marsLevel scale(level,oneConstant,hundred) : read_only;
|
|
alias mars.levelist = marsLevel;
|
|
}
|
|
alias vertical.level=level;
|
|
alias vertical.topLevel = level;
|
|
alias vertical.bottomLevel = level;
|
|
alias ls.level=level;
|
|
alias lev=level;
|
|
|
|
}
|
|
|
|
if( indicatorOfTypeOfLevel == 109 ||
|
|
indicatorOfTypeOfLevel == 100 ||
|
|
indicatorOfTypeOfLevel == 110 ||
|
|
indicatorOfTypeOfLevel == 113 ||
|
|
indicatorOfTypeOfLevel == 117)
|
|
{
|
|
alias mars.levelist = level;
|
|
}
|
|
|
|
unsigned[1] yearOfCentury : edition_specific ;
|
|
unsigned[1] month ;
|
|
unsigned[1] day ;
|
|
unsigned[1] hour ;
|
|
unsigned[1] minute ;
|
|
transient second = 0;
|
|
|
|
codetable[1] unitOfTimeRange 'grib1/4.table' = 1 : edition_specific;
|
|
alias unitOfTime=unitOfTimeRange;
|
|
alias indicatorOfUnitOfTimeRange=unitOfTimeRange;
|
|
|
|
unsigned[1] P1 : edition_specific;
|
|
|
|
unsigned[1] P2 : edition_specific;
|
|
|
|
codetable[1] timeRangeIndicator 'grib1/5.table' = 1 : dump,edition_specific;
|
|
|
|
unsigned[2] numberIncludedInAverage;
|
|
|
|
meta mybits bits(numberIncludedInAverage,0,12);
|
|
|
|
unsigned[1] numberMissingFromAveragesOrAccumulations;
|
|
unsigned[1] centuryOfReferenceTimeOfData ;
|
|
|
|
codetable[1] subCentre 'grib1/0.[centre].table' : dump;
|
|
|
|
if(table2Version >= 128) {
|
|
_if (centre != 98 && subCentre == 98) {
|
|
alias centreForTable2 = subCentre;
|
|
} else {
|
|
alias centreForTable2 = centre;
|
|
}
|
|
} else {
|
|
alias centreForTable2 = WMO;
|
|
}
|
|
|
|
#if ( subCentre == 98 ) {
|
|
# alias conceptsLocalDir=conceptsLocalDirECMF;
|
|
#} else {
|
|
# alias conceptsLocalDir=conceptsLocalDirAll;
|
|
#}
|
|
|
|
concept paramIdECMF (defaultParameter,"paramId.def",conceptsMasterDir,conceptsLocalDirECMF): no_copy;
|
|
concept paramId (paramIdECMF,"paramId.def",conceptsMasterDir,conceptsLocalDirAll): long_type,dump;
|
|
|
|
concept cfNameECMF(defaultName,"cfName.def",conceptsMasterDir,conceptsLocalDirECMF) : dump,no_copy,read_only;
|
|
concept cfName(cfNameECMF,"cfName.def",conceptsMasterDir,conceptsLocalDirAll) : dump,no_copy,read_only;
|
|
|
|
concept cfVarNameECMF(defaultName,"cfVarName.def",conceptsMasterDir,conceptsLocalDirECMF) : dump,no_copy,read_only;
|
|
concept cfVarName(cfVarNameECMF,"cfVarName.def",conceptsMasterDir,conceptsLocalDirAll) : dump,no_copy,read_only;
|
|
|
|
concept unitsECMF(defaultName,"units.def",conceptsMasterDir,conceptsLocalDirECMF) : no_copy,read_only;
|
|
concept units(unitsECMF,"units.def",conceptsMasterDir,conceptsLocalDirAll) : dump,no_copy,read_only;
|
|
|
|
concept nameECMF(defaultName,"name.def",conceptsMasterDir,conceptsLocalDirECMF) : dump,no_copy,read_only;
|
|
concept name(nameECMF,"name.def",conceptsMasterDir,conceptsLocalDirAll) : dump,no_copy,read_only;
|
|
|
|
signed[2] decimalScaleFactor :dump;
|
|
transient setLocalDefinition= 0 : no_copy;
|
|
|
|
meta dataDate g1date(centuryOfReferenceTimeOfData,yearOfCentury,month,day) : dump;
|
|
meta year evaluate(dataDate / 10000) ;
|
|
|
|
meta dataTime time(hour,minute,second) : dump;
|
|
meta julianDay julian_day(dataDate,hour,minute,second) : edition_specific;
|
|
|
|
codetable[1] stepUnits 'stepUnits.table' = 1 : transient,dump,no_copy;
|
|
|
|
concept stepType (timeRangeIndicator) {
|
|
#set uses the last one
|
|
#get returns the first match
|
|
"instant" = {timeRangeIndicator=14;} # Fields from DWD in MARS
|
|
"instant" = {timeRangeIndicator=1;}
|
|
"instant" = {timeRangeIndicator=10;}
|
|
"instant" = {timeRangeIndicator=0;}
|
|
"avg" = {timeRangeIndicator=3;}
|
|
"avgfc" = {timeRangeIndicator=113;}
|
|
"avgd" = {timeRangeIndicator=113;}
|
|
"accum" = {timeRangeIndicator=2;}
|
|
"accum" = {timeRangeIndicator=4;}
|
|
# Since grib1 has not min/max, we had to use our own convention
|
|
# therefore we set the centre to ECMWF (98)
|
|
"max" = {timeRangeIndicator=118;}
|
|
"max" = {timeRangeIndicator=2;centre=98;}
|
|
"min" = {timeRangeIndicator=119;}
|
|
"min" = {timeRangeIndicator=2;centre=98;}
|
|
"diff" = {timeRangeIndicator=5;}
|
|
"rms" = {timeRangeIndicator=120;}
|
|
"sd" = {timeRangeIndicator=121;}
|
|
"cov" = {timeRangeIndicator=122;}
|
|
"avgua" = {timeRangeIndicator=123;}
|
|
"avgia" = {timeRangeIndicator=124;}
|
|
}
|
|
|
|
#alias stepTypeInternal=stepType;
|
|
#alias lengthOfTimeRange=numberIncludedInAverage;
|
|
#alias indicatorOfUnitForTimeRange=unitOfTimeRange;
|
|
#alias indicatorOfUnitForTimeIncrement=zero;
|
|
#alias timeIncrement=zero;
|
|
|
|
#if (timeRangeIndicator==113) {
|
|
# alias lengthOfTimeRange=numberIncludedInAverage;
|
|
# alias indicatorOfUnitForTimeRange=unitOfTimeRange;
|
|
# alias indicatorOfUnitForTimeIncrement=unitOfTimeRange;
|
|
# alias timeIncrement=P2;
|
|
# alias forecastTime=P1;
|
|
#}
|
|
|
|
#if (stepType is "accum") {
|
|
# transient accumulationRange=P2-P1;
|
|
# alias lengthOfTimeRange=accumulationRange;
|
|
# alias forecastTime=P1;
|
|
# alias indicatorOfUnitForTimeRange=unitOfTimeRange;
|
|
#}
|
|
|
|
#conversion 1->2
|
|
_if (stepType is "instant" ) {
|
|
alias productDefinitionTemplateNumber=zero;
|
|
} else {
|
|
alias productDefinitionTemplateNumber=eight;
|
|
}
|
|
|
|
meta stepRange g1step_range(P1,P2,timeRangeIndicator,unitOfTimeRange,stepUnits,stepType) : dump;
|
|
meta startStep long_vector(stepRange,0) : dump,no_copy;
|
|
meta endStep long_vector(stepRange,1) : dump,no_copy;
|
|
|
|
alias stepInHours = endStep;
|
|
alias ls.stepRange = stepRange;
|
|
alias ls.dataDate = dataDate;
|
|
|
|
alias mars.step = endStep;
|
|
alias mars.date = dataDate;
|
|
alias mars.levtype = indicatorOfTypeOfLevel;
|
|
alias mars.time = dataTime;
|
|
#alias mars.param = paramId;
|
|
meta marsParam mars_param(paramId,gribTablesVersionNo,indicatorOfParameter): read_only,dump;
|
|
alias mars.param = marsParam;
|
|
|
|
meta time.validityDate validity_date(dataDate,dataTime,step,stepUnits);
|
|
meta time.validityTime validity_time(dataDate,dataTime,step,stepUnits);
|
|
|
|
transient deleteLocalDefinition=0;
|
|
|
|
if(((section1Length > 40) or new() or setLocalDefinition> 0) and deleteLocalDefinition==0)
|
|
{
|
|
constant localUsePresent = 1 : edition_specific;
|
|
alias grib2LocalSectionPresent=present;
|
|
|
|
if( (centre == ECMWF) or
|
|
(centre != ECMWF and
|
|
subCentre == ECMWF))
|
|
{
|
|
pad reservedNeedNotBePresent(12);
|
|
codetable[1] localDefinitionNumber 'grib1/localDefinitionNumber.98.table' = 1 : dump;
|
|
template localDefinition "grib1/local.98.[localDefinitionNumber:l].def";
|
|
if (changed(localDefinitionNumber)) {
|
|
if(!new() && localDefinitionNumber!=4 ) {
|
|
section_padding localExtensionPadding : read_only;
|
|
}
|
|
}
|
|
|
|
template_nofail marsKeywords "mars/grib1.[stream:s].[type:s].def";
|
|
#template marsKeywords "mars/grib1.[stream:s].[type:s].def";
|
|
|
|
}
|
|
else
|
|
{
|
|
if ( !new() || setLocalDefinition ) {
|
|
# Other centres
|
|
pad reservedNeedNotBePresent(12);
|
|
template_nofail localDefinition "grib1/local.[centre:l].def";
|
|
|
|
section_padding localExtensionPadding : read_only;
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
constant localUsePresent = 0 : edition_specific;
|
|
# template defaultMarsLabeling "mars/default_labeling.def";
|
|
}
|
|
|
|
section_padding section1Padding : read_only;
|
|
|
|
#if (!wrongPadding) {
|
|
# padtoeven evenpadding_sec1(offsetSection1,section1Length);
|
|
#}
|
|
|
|
|
|
concept shortNameECMF (defaultShortName,"shortName.def",conceptsMasterDir,conceptsLocalDirECMF) : no_copy;
|
|
concept ls.shortName (shortNameECMF,"shortName.def",conceptsMasterDir,conceptsLocalDirAll) : no_copy,dump;
|
|
meta ifsParam ifs_param(paramId,type);
|
|
|
|
alias parameter.paramId=paramId;
|
|
alias parameter.shortName=shortName;
|
|
alias parameter.units=units;
|
|
alias parameter.name=name;
|
|
|
|
alias parameter=paramId;
|
|
alias short_name=shortName;
|
|
|
|
alias time.stepRange=stepRange;
|
|
alias time.stepUnits=stepUnits;
|
|
alias time.dataDate=dataDate;
|
|
alias time.dataTime=dataTime;
|
|
alias time.startStep=startStep;
|
|
alias time.endStep=endStep;
|
|
alias time.stepType=stepType;
|
|
|
|
meta md5Section1 md5(offsetSection1,section1Length);
|