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# START 1/local.98.36 ----------------------------------------------------------------------
11# LOCAL 98 36
12#
13# localDefinitionTemplate_036
14# ---------------------------
15#
16# Description                  Octet    Code    Ksec1    Count
17# -----------                  -----    ----    -----    -----
18#localDefinitionNumber           41      I1      37      -
19#class                           42      I1      38      -
20#type                            43      I1      39      -
21#stream                          44      I2      40      -
22#experimentVersionNumber         46      A4      41      -
23#number                          50      I1      42      -
24#total                           51      I1      43      -
25#offsetToEndOf4DvarWindow        52      I2      44      -
26#lengthOf4DvarWindow             54      I2      45      -
27#spareSetToZero                  56      PAD     n/a     1
28#
29constant GRIBEXSection1Problem = 56 - section1Length ;
30
31template mars_labeling "grib1/mars_labeling.def";
32
33unsigned[1] perturbationNumber           : dump;
34alias number = perturbationNumber;
35
36unsigned[1] numberOfForecastsInEnsemble  : dump;
37alias totalNumber=numberOfForecastsInEnsemble;
38
39# Hours
40unsigned[2] offsetToEndOf4DvarWindow : dump;
41unsigned[2] lengthOf4DvarWindow : dump;
42alias anoffset=offsetToEndOf4DvarWindow;
43
44pad padding_local1_1(1);
45
46#1->2
47alias grib2LocalSectionPresent=present;
48constant grib2LocalSectionNumber=1;
49
50if (stepType is "instant" ) {
51    if (type is "em" || type is "es" ) {
52      alias productDefinitionTemplateNumber=epsStatisticsPoint;
53    } else {
54  		if (numberOfForecastsInEnsemble!=0) {
55			if ((perturbationNumber/2)*2 == perturbationNumber) {
56				alias typeOfEnsembleForecast=two;
57			} else {
58				alias typeOfEnsembleForecast=three;
59			}
60			alias productDefinitionTemplateNumber=epsPoint;
61		} else {
62			alias productDefinitionTemplateNumber=zero;
63		}
64	}
65} else {
66    if (type is "em" || type is "es" ) {
67      alias productDefinitionTemplateNumber=epsStatisticsContinous;
68    } else {
69		if (numberOfForecastsInEnsemble!=0) {
70			if ((perturbationNumber/2)*2 == perturbationNumber) {
71				alias typeOfEnsembleForecast=two;
72			} else {
73				alias typeOfEnsembleForecast=three;
74			}
75			alias productDefinitionTemplateNumber=epsContinous;
76		} else {
77			alias productDefinitionTemplateNumber=eight;
78		}
79    }
80}
81
82# END   1/local.98.36 ----------------------------------------------------------------------
83
84