# Copyright 2005-2007 ECMWF
#
# Licensed under the GNU Lesser General Public License which
# incorporates the terms and conditions of version 3 of the GNU
# General Public License.
# See LICENSE and gpl-3.0.txt for details.

# START 1/local.98.9 ----------------------------------------------------------------------
# LOCAL 98 9
#
# localDefinitionTemplate_009
# ---------------------------
#
# 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  -
#forecastOrSingularVectorNumber      50  I2  42  -
#!  These elements are set to zero for perturbed forecast
#if1                                 -   IF_EQ   60  type
#octetsSetToZero                     52  PAD n/a 41
#ksec1SetToZero                      n/a PAD 43  13
#endif1                              -   ENDIF   if1
#!  These elements are coded for singular vectors
#if2                                 -   IF_NEQ  60  type
#numberOfIterations                  52  I2  43  -
#numberOfSingularVectorsComputed     54  I2  44  -
#normAtInitialTime                   56  I1  45  -
#normAtFinalTime                     57  I1  46  -
#multiplicationFactorForLatLong      58  I4  47  -
#northWestLatitudeOfLPOArea          62  S4  48  -
#northWestLongitudeOfLPOArea         66  S4  49  -
#southEastLatitudeOfLPOArea          70  S4  50  -
#southEastLongitudeOfLPOArea         74  S4  51  -
#accuracyMultipliedByFactor          78  I4  52  -
#numberOfSingularVectorsEvolved      82  I2  53  -
#!Ritz numbers:
#NINT(LOG10(RITZ)-5)                 84  S4  54  -
#NINT(RITZ/(EXP(LOG(10.0*KSEC1(54))  88  S4  55  -
#endif2                              -   ENDIF   if2
#spareSetToZero                      92  PAD n/a 1
#
# 1-> 2
alias grib2LocalSectionPresent=present;
constant grib2LocalSectionNumber=9;

constant GRIBEXSection1Problem = 92 - section1Length ;

template mars_labeling "grib1/mars_labeling.def";

unsigned[2] forecastOrSingularVectorNumber  : dump;

#
# These elements are set to zero for perturbed forecast
#

constant perturbedType = 60;
if(type == perturbedType)
{
  # octetsSetToZero
  pad padding_loc9_1(41);
}

#
# These elements are coded for singular vectors
#

if(type != perturbedType)
{
  unsigned[2] numberOfIterations : dump;
  unsigned[2] numberOfSingularVectorsComputed  : dump;
  unsigned[1] normAtInitialTime : dump ;
  unsigned[1] normAtFinalTime : dump ;
  unsigned[4] multiplicationFactorForLatLong  : dump;
  signed[4] northWestLatitudeOfLPOArea : dump ;
  signed[4] northWestLongitudeOfLPOArea  : dump;
  signed[4] southEastLatitudeOfLPOArea  : dump;
  signed[4] southEastLongitudeOfLPOArea  : dump;
  unsigned[4] accuracyMultipliedByFactor  : dump;
  unsigned[2] numberOfSingularVectorsEvolved  : dump;
  # Ritz numbers:
  signed[4] NINT_LOG10_RITZ : dump ;
  signed[4] NINT_RITZ_EXP : dump ;

  alias local.numberOfIterations= numberOfIterations;
  alias local.numberOfSingularVectorsComputed= numberOfSingularVectorsComputed ;
  alias local.normAtInitialTime= normAtInitialTime  ;
  alias local.normAtFinalTime= normAtFinalTime ;
  alias local.multiplicationFactorForLatLong= multiplicationFactorForLatLong ;
  alias local.northWestLatitudeOfLPOArea= northWestLatitudeOfLPOArea  ;
  alias local.northWestLongitudeOfLPOArea= northWestLongitudeOfLPOArea  ;
  alias local.southEastLatitudeOfLPOArea= southEastLatitudeOfLPOArea  ;
  alias local.southEastLongitudeOfLPOArea= southEastLongitudeOfLPOArea  ;
  alias local.accuracyMultipliedByFactor= accuracyMultipliedByFactor ;
  alias local.numberOfSingularVectorsEvolved= numberOfSingularVectorsEvolved ;
# Ritz numbers:
  alias local.NINT_LOG10_RITZ= NINT_LOG10_RITZ ;
  alias local.NINT_RITZ_EXP= NINT_RITZ_EXP  ;
}

# spareSetToZero
pad padding_loc9_2(1);

# END   1/local.98.9 ----------------------------------------------------------------------

# END   grib::edition
