# Copyright 2005-2016 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.16 ---------------------------------------------------------------------
# LOCAL 98 16
#
# localDefinitionTemplate_016
# ---------------------------
#
# 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      I2      42      -
#zero                            n/a     PAD     43      1
#systemNumber                    52      I2      44      -
#methodNumber                    54      I2      45      -
#verifyingMonth                  56      I4      46      -
#averagingPeriod                 60      I1      47      -
#forecastMonth                   61      I2      48      -
#spareSetToZero                  63      PAD     n/a     18
#

# ------------------- From section 1
# ------------------- End of section 1

constant GRIBEXSection1Problem = 80 - section1Length ;

# used in local definition 13
transient localFlag=1 : hidden;

template mars_labeling "grib1/mars_labeling.def";

unsigned[2] perturbationNumber : dump ;

# zero

unsigned[2] systemNumber : dump ;

unsigned[2] methodNumber : dump ;

unsigned[4] verifyingMonth : dump ;

meta endOfInterval g1end_of_interval_monthly(verifyingMonth);

meta yearOfEndOfOverallTimeInterval   vector(endOfInterval,0);
meta monthOfEndOfOverallTimeInterval   vector(endOfInterval,1);
meta dayOfEndOfOverallTimeInterval   vector(endOfInterval,2);
meta hourOfEndOfOverallTimeInterval   vector(endOfInterval,3);
meta minuteOfEndOfOverallTimeInterval   vector(endOfInterval,4);
meta secondOfEndOfOverallTimeInterval   vector(endOfInterval,5);

transient hourOfEndOfOverallTimeInterval=23;
transient minuteOfEndOfOverallTimeInterval=59;
transient secondOfEndOfOverallTimeInterval=59;

transient indicatorOfUnitForTimeRange=3;
transient lengthOfTimeRange=1;
unsigned[1] averagingPeriod : dump ;

transient typeOfStatisticalProcessing=0;
transient indicatorOfUnitForTimeIncrement = 1;
transient timeIncrement=averagingPeriod;

unsigned[2] forecastMonth : dump ;
remove forecastTime;
transient forecastTime=forecastMonth - 1;
#remove typeOfTimeIncrement;
transient typeOfTimeIncrement = 3;

# Old GRIBS do not have forecast forecastMonth set. It is computed from verifyingMonth
meta marsForecastMonth g1forecastmonth(verifyingMonth,dataDate,day,hour,forecastMonth) : read_only;

alias origin = centre;
alias number = perturbationNumber;
alias system = systemNumber;
alias method = methodNumber;



# spareSetToZero
pad padding_loc16_1(18);

# END   1/local.98.16 ----------------------------------------------------------------------

