# (C) Copyright 2005- ECMWF.

# Uncertainties in ensembles of regional re-analysis project (UERRA)
constant marsClass = 'ur';

alias tigge_short_name=shortName;
alias short_name=shortName;
alias parameter=paramId;
alias tigge_name=name;

alias parameter.paramId=paramId;
alias parameter.shortName=shortName;
alias parameter.units=units;
alias parameter.name=name;

# Special UERRA rule for level type 103 'Specified height level above ground (m)'
if(typeOfFirstFixedSurface == 103) {
    # only the parameters above 10m
    if (level > 10) {
        constant heightLevelName = 'hl';
        alias mars.levtype = heightLevelName;
        # levelist was unaliased in template.4.horizontal.def so we must have it back
        alias mars.levelist = level;
    }
}
if(typeOfFirstFixedSurface == 118) {
    constant levTypeName = 'ml';
    alias mars.levtype = levTypeName;
}

# See GRIB-871 and ECC-854
if(typeOfFirstFixedSurface == 151 && typeOfSecondFixedSurface == 151) {
    alias level = bottomLevel;
    #alias mars.levelist = level;
}

alias mars.expver = marsExpver;
alias mars.class  = marsClass;
alias mars.param = paramId;
alias mars.origin = centre;

# See GRIB-911 re typeOfProcessedData values in UERRA
concept marsType {

   fc = {
     typeOfProcessedData = 1;
   }
   "9" = {
     typeOfProcessedData = 1;
   }

   an = {
     typeOfProcessedData = 0;
   }
   "2" = {
     typeOfProcessedData = 0;
   }

   # See ECC-456. Special rule for Swedish data
   # oi is Optimal Interpolation
   oi = {
     centre = 82;
     typeOfGeneratingProcess = 0;
     generatingProcessIdentifier = 50;
   }
   "4" = {
     centre = 82;
     typeOfGeneratingProcess = 0;
     generatingProcessIdentifier = 50;
   }

   "default" = {
     dummyc = 0;
   }
}

# See GRIB-205 re no_copy
# Cannot use typeOfProcessedData for stream. See GRIB-911
concept marsStream {

    oper = {
      productDefinitionTemplateNumber = 8;
    }

    oper = {
      productDefinitionTemplateNumber = 0;
    }

    enda = {
      productDefinitionTemplateNumber = 11;
    }

    enda = {
      productDefinitionTemplateNumber = 1;
    }

    "default" = {
      dummyc = 0;
    }
} : no_copy;

alias mars.stream = marsStream;
alias mars.type   = marsType;
