# Copyright 2005-2018 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.
#

# START 1/local.98.21 ----------------------------------------------------------------------
# LOCAL 98 21
#
# localDefinitionTemplate_029
# ---------------------------
#
# Description                Octet    Code    Ksec1    Count
# -----------                -----    ----    -----    -----
#localDefinitionNumber          41     I1    37  -
#class                          42     I1    38  -
#type                           43     I1    39  -
#stream                         44     I2    40  -
#experimentVersionNumber        46     A4    41  -
#number                         50     I1    42  -
#totalNumberOfClusters          51     I1    43  -
#spareSetToZero                 52     PAD   n/a 1
#clusteringMethod               53     I1    44  -
#northernLatitudeOfDomain       54     S3    45  -
#westernLongitudeOfDomain       57     S3    46  -
#southernLatitudeOfDomain       60     S3    47  -
#easternLongitudeOfDomain       63     S3    48  -
#numberOfForecastsInCluster     66     I1    49  -
#numberOfParametersUsedForClustering         67     I1    50  -
#numberOfPressureLevelsUsedForClustering     68     I1    51  -
#numberOfStepsUsedForClustering          69     I1    52  -
#spareSetToZero                 70     PAD   n/a 10
#!
#! EPS members
#listOfEnsembleForecastNumbers   -     LIST   - numberOfForecastsInCluster
#baseDateEPS                     -     I4     -  -
#baseTimeEPS                     -     I2     -  -
#number                          -     I1     -  -
#endListOfEnsembleForecastNumbers - ENDLIST   -  listOfEnsembleForecastNumbers
#!
#! Variables
#listOfParametersUsedForClustering   -     LIST   - numberOfParametersUsedForClustering
#parameterCode                       -     I1     -  -
#tableCode                           -     I1     -  -
#endListOfParametersUsedForClustering - ENDLIST   -  listOfParametersUsedForClustering
#!
#! Pressure levels
#listOfPressureLevelsUsedForClustering   -     LIST   - numberOfPressureLevelsUsedForClustering
#pressureLevel                       -     I2     -  -
#endListOfPressureLevelsUsedForClustering - ENDLIST   -  listOfPressureLevelsUsedForClustering
#!
#! Steps
#listOfStepsUsedForClustering   -     LIST   - numberOfStepsUsedForClustering
#step                           -     I2     -  -
#endListOfStepsUsedForClustering - ENDLIST   -  listOfStepsUsedForClustering
#!
#spareToEnsureFixedLength        -   PADTO   n/a 960
#

constant GRIBEXSection1Problem = 960 - section1Length ;

template mars_labeling "grib1/mars_labeling.def";

unsigned[1]  clusterNumber : dump;
alias number=clusterNumber;

unsigned[1]  totalNumberOfClusters  : dump ;
alias totalNumber=totalNumberOfClusters;
pad  padding_loc29_1(1);
unsigned[1]  clusteringMethod  : dump ;
signed[3]  northernLatitudeOfDomain  : dump;
signed[3]  westernLongitudeOfDomain   : dump ;
signed[3]  southernLatitudeOfDomain   : dump ;
signed[3]  easternLongitudeOfDomain  : dump   ;
unsigned[1] numberOfForecastsInCluster   : dump;
unsigned[1] numberOfParametersUsedForClustering  : dump ;
unsigned[1] numberOfPressureLevelsUsedForClustering : dump ;
unsigned[1] numberOfStepsUsedForClustering : dump  ;

pad padding_loc29_2(10);

listOfEnsembleForecastNumbers list(numberOfForecastsInCluster){
      unsigned[4] baseDateEPS : dump;
      unsigned[2] baseTimeEPS : dump;
      unsigned[1] number : dump;
}

listOfParametersUsedForClustering list(numberOfParametersUsedForClustering){
      unsigned[1] parameterCode;
      unsigned[1] tableCode;
}

unsigned[2] pressureLevel[numberOfPressureLevelsUsedForClustering] : dump;

# Name_change old=step new=stepForClustering
unsigned[2] stepForClustering[numberOfStepsUsedForClustering] : dump;

#spareToEnsureFixedLength        -   PADTO   n/a 960
padto padding_loc29_3(offsetSection1 + 960);

alias number = clusterNumber;
