Merge branch 'develop' into feature/modernisation_merge_accessor_classes

This commit is contained in:
Eugen Betke 2024-10-04 10:35:24 +00:00
commit 376b7e780e
55 changed files with 1933 additions and 1225 deletions

View File

@ -517,11 +517,8 @@ ecbuild_info(" | ecCodes version ${eccodes_VERSION} |")
ecbuild_info(" +--------------------------+") ecbuild_info(" +--------------------------+")
ecbuild_info("") ecbuild_info("")
ecbuild_info(" +--------------------------------------+") ecbuild_info("Please note:")
ecbuild_info(" | Please note: |") ecbuild_info(" For Python3 support, you must install the Python bindings.")
ecbuild_info(" | For Python3 support, first install |") ecbuild_info(" See:")
ecbuild_info(" | ecCodes and then install the Python |") ecbuild_info(" https://confluence.ecmwf.int/display/ECC/ecCodes+installation")
ecbuild_info(" | bindings from PyPI with: |")
ecbuild_info(" | $ pip3 install eccodes |")
ecbuild_info(" +--------------------------------------+")
ecbuild_info("") ecbuild_info("")

View File

@ -1 +1 @@
2.38.0 2.39.0

View File

@ -1,4 +1,5 @@
# RDB stands for REPORT DATA BASE # RDB stands for REPORT DATA BASE
# See https://confluence.ecmwf.int/pages/viewpage.action?pageId=24316441
unsigned[1] rdbType : dump; unsigned[1] rdbType : dump;
unsigned[1] oldSubtype: dump; unsigned[1] oldSubtype: dump;

View File

@ -69,7 +69,8 @@ if (section2Present && bufrHeaderCentre==98 && section2Length==52) {
meta localLatitude2 bits(keyMore,32,25,-9000000,100000) : dump,no_copy; meta localLatitude2 bits(keyMore,32,25,-9000000,100000) : dump,no_copy;
# This rule is taken from BUFRDC. See bufrdc_wmo/buukey.F # This rule is taken from BUFRDC. See bufrdc_wmo/buukey.F
# Also see ECC-686 # See ECC-686
# and https://confluence.ecmwf.int/pages/viewpage.action?pageId=24316441
if (oldSubtype == 255 || numberOfSubsets > 255 || if (oldSubtype == 255 || numberOfSubsets > 255 ||
( oldSubtype >= 121 && oldSubtype <= 130 ) || ( oldSubtype >= 121 && oldSubtype <= 130 ) ||
oldSubtype == 31) { oldSubtype == 31) {

View File

@ -114,7 +114,6 @@ if(matrixOfValues == 0)
# From GRIBEX: # From GRIBEX:
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# ! !
# ! This is the WMO definition, but it is entirely ! # ! This is the WMO definition, but it is entirely !
# ! inadequate when secondary bit maps are present ! # ! inadequate when secondary bit maps are present !
# ! eg 3x3 global grid with a matrix of values ! # ! eg 3x3 global grid with a matrix of values !
@ -129,7 +128,6 @@ if(matrixOfValues == 0)
# ! missing'). ! # ! missing'). !
# ! This definition will accommodate a 1x1 ! # ! This definition will accommodate a 1x1 !
# ! degree global grid. ! # ! degree global grid. !
# ! !
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# #
constant datumSize = NC*NR; constant datumSize = NC*NR;

View File

@ -10,7 +10,8 @@ transient numberOfUnusedBitsAtEndOfSection3 = 0 : read_only;
transient tableReference = 0; transient tableReference = 0;
#position offsetBeforeBitmap; #position offsetBeforeBitmap;
meta bitmap gds_not_present_bitmap( missingValue,numberOfValues, meta bitmap gds_not_present_bitmap(
missingValue,numberOfValues,
numberOfPoints, numberOfPoints,
latitudeOfFirstGridPoint, latitudeOfFirstGridPoint,
Ni,numberOfUnusedBitsAtEndOfSection3) : read_only; Ni,numberOfUnusedBitsAtEndOfSection3) : read_only;

View File

@ -40,6 +40,6 @@ transient numberOfPoints= nd *(Ni + 1) * (Ni + 1);
alias numberOfDataPoints=numberOfPoints; alias numberOfDataPoints=numberOfPoints;
meta numberOfValues meta numberOfValues
number_of_values(values,bitsPerValue,numberOfDataPoints, number_of_values(
values,bitsPerValue,numberOfDataPoints,
bitmapPresent,bitmap,numberOfCodedValues) : dump; bitmapPresent,bitmap,numberOfCodedValues) : dump;

View File

@ -26,7 +26,7 @@ constant dataRepresentationType = 0;
# grib 1 -> 2 # grib 1 -> 2
constant gridDefinitionTemplateNumber = 0; constant gridDefinitionTemplateNumber = 0;
# START 1/grid_definition.latitude_longitude_grid ---------------------------------------------------------------------- # START 1/grid_definition.latitude_longitude_grid
# GRID DEFINITION latitude/longitude grid (or equidistant cylindrical) # GRID DEFINITION latitude/longitude grid (or equidistant cylindrical)
alias numberOfPointsAlongAParallel=Ni; alias numberOfPointsAlongAParallel=Ni;

View File

@ -8,3 +8,4 @@
'eORCA12' = { numberOfGridUsed = 7; } 'eORCA12' = { numberOfGridUsed = 7; }
'CORE2' = { numberOfGridUsed = 8; } 'CORE2' = { numberOfGridUsed = 8; }
'NG5' = { numberOfGridUsed = 9; } 'NG5' = { numberOfGridUsed = 9; }
'DART' = { numberOfGridUsed = 10; }

View File

@ -8,9 +8,9 @@
'sfc' = {typeOfFirstFixedSurface=8; typeOfSecondFixedSurface=255;} 'sfc' = {typeOfFirstFixedSurface=8; typeOfSecondFixedSurface=255;}
'sfc' = {typeOfFirstFixedSurface=17; typeOfSecondFixedSurface=255;} 'sfc' = {typeOfFirstFixedSurface=17; typeOfSecondFixedSurface=255;}
'sfc' = {typeOfFirstFixedSurface=18; typeOfSecondFixedSurface=255;} 'sfc' = {typeOfFirstFixedSurface=18; typeOfSecondFixedSurface=255;}
'o2d' = {typeOfFirstFixedSurface=20; scaleFactorOfFirstFixedSurface=-2; 'sfc' = {typeOfFirstFixedSurface=19; typeOfSecondFixedSurface=255;}
scaledValueOfFirstFixedSurface=29315; typeOfSecondFixedSurface=255;} 'o2d' = {discipline=10; typeOfFirstFixedSurface=20; typeOfSecondFixedSurface=255;}
'o2d' = {typeOfFirstFixedSurface=20; typeOfSecondFixedSurface=255;} 'sfc' = {typeOfFirstFixedSurface=20; typeOfSecondFixedSurface=255;}
'pl' = {typeOfFirstFixedSurface=100; typeOfSecondFixedSurface=255;} 'pl' = {typeOfFirstFixedSurface=100; typeOfSecondFixedSurface=255;}
'pl' = {typeOfFirstFixedSurface=100; typeOfSecondFixedSurface=100;} 'pl' = {typeOfFirstFixedSurface=100; typeOfSecondFixedSurface=100;}
'sfc' = {typeOfFirstFixedSurface=1; typeOfSecondFixedSurface=100; 'sfc' = {typeOfFirstFixedSurface=1; typeOfSecondFixedSurface=100;

View File

@ -5,7 +5,8 @@ codetable[2] marsType "mars/type.table" = "an" : dump,string_type,no_fail,low
codetable[2] marsStream "mars/stream.table" = "oper" : dump,string_type,lowercase; codetable[2] marsStream "mars/stream.table" = "oper" : dump,string_type,lowercase;
ksec1expver[4] experimentVersionNumber = "0001" : dump; ksec1expver[4] experimentVersionNumber = "0001" : dump;
meta class g2_mars_labeling(0,marsClass, meta class g2_mars_labeling(
0,marsClass,
marsType, marsType,
marsStream, marsStream,
experimentVersionNumber, experimentVersionNumber,
@ -15,7 +16,8 @@ meta class g2_mars_labeling(0,marsClass,
derivedForecast, derivedForecast,
typeOfGeneratingProcess); typeOfGeneratingProcess);
meta type g2_mars_labeling(1,marsClass, meta type g2_mars_labeling(
1,marsClass,
marsType, marsType,
marsStream, marsStream,
experimentVersionNumber, experimentVersionNumber,
@ -25,7 +27,8 @@ meta type g2_mars_labeling(1,marsClass,
derivedForecast, derivedForecast,
typeOfGeneratingProcess); typeOfGeneratingProcess);
meta stream g2_mars_labeling(2,marsClass, meta stream g2_mars_labeling(
2,marsClass,
marsType, marsType,
marsStream, marsStream,
experimentVersionNumber, experimentVersionNumber,
@ -41,5 +44,4 @@ alias mars.class = class;
alias mars.type = type; alias mars.type = type;
alias mars.stream = stream; alias mars.stream = stream;
alias mars.expver = experimentVersionNumber; alias mars.expver = experimentVersionNumber;
alias mars.domain = globalDomain; # For now... alias mars.domain = globalDomain; # For now...

View File

@ -4079,6 +4079,27 @@
parameterNumber = 148 ; parameterNumber = 148 ;
typeOfFirstFixedSurface = 1 ; typeOfFirstFixedSurface = 1 ;
} }
#Radar reflectivity
'Radar reflectivity' = {
discipline = 0 ;
parameterCategory = 16 ;
parameterNumber = 4 ;
}
#Pressure at cloud ceiling
'Pressure at cloud ceiling' = {
discipline = 0 ;
parameterCategory = 3 ;
parameterNumber = 0 ;
typeOfFirstFixedSurface = 19 ;
scaledValueOfFirstFixedSurface = 50 ;
scaleFactorOfFirstFixedSurface = 0 ;
}
#Visibility through precipitation
'Visibility through precipitation' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 51 ;
}
#Burned area #Burned area
'Burned area' = { 'Burned area' = {
discipline = 2 ; discipline = 2 ;
@ -5566,6 +5587,13 @@
parameterNumber = 23 ; parameterNumber = 23 ;
typeOfStatisticalProcessing = 0 ; typeOfStatisticalProcessing = 0 ;
} }
#Time-mean visibility through precipitation
'Time-mean visibility through precipitation' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 51 ;
typeOfStatisticalProcessing = 0 ;
}
#Time-maximum volumetric soil moisture #Time-maximum volumetric soil moisture
'Time-maximum volumetric soil moisture' = { 'Time-maximum volumetric soil moisture' = {
discipline = 2 ; discipline = 2 ;
@ -5602,6 +5630,13 @@
typeOfSecondFixedSurface = 8 ; typeOfSecondFixedSurface = 8 ;
typeOfStatisticalProcessing = 2 ; typeOfStatisticalProcessing = 2 ;
} }
#Time-maximum visibility through precipitation
'Time-maximum visibility through precipitation' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 51 ;
typeOfStatisticalProcessing = 2 ;
}
#Time-minimum volumetric soil moisture #Time-minimum volumetric soil moisture
'Time-minimum volumetric soil moisture' = { 'Time-minimum volumetric soil moisture' = {
discipline = 2 ; discipline = 2 ;
@ -5645,6 +5680,13 @@
typeOfSecondFixedSurface = 8 ; typeOfSecondFixedSurface = 8 ;
typeOfStatisticalProcessing = 3 ; typeOfStatisticalProcessing = 3 ;
} }
#Time-minimum visibility through precipitation
'Time-minimum visibility through precipitation' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 51 ;
typeOfStatisticalProcessing = 3 ;
}
#Time-standard-deviation volumetric soil moisture #Time-standard-deviation volumetric soil moisture
'Time-standard-deviation volumetric soil moisture' = { 'Time-standard-deviation volumetric soil moisture' = {
discipline = 2 ; discipline = 2 ;

View File

@ -186,3 +186,69 @@
parameterCategory = 0 ; parameterCategory = 0 ;
parameterNumber = 2 ; parameterNumber = 2 ;
} }
#Maximum temperature
'Maximum temperature' = {
discipline = 0 ;
parameterCategory = 0 ;
parameterNumber = 4 ;
}
#Minimum temperature
'Minimum temperature' = {
discipline = 0 ;
parameterCategory = 0 ;
parameterNumber = 5 ;
}
#Minimum dew point depression
'Minimum dew point depression' = {
discipline = 0 ;
parameterCategory = 0 ;
parameterNumber = 14 ;
}
#Maximum relative humidity
'Maximum relative humidity' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 27 ;
}
#Maximum absolute humidity
'Maximum absolute humidity' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 28 ;
}
#Maximum wind speed
'Maximum wind speed' = {
discipline = 0 ;
parameterCategory = 2 ;
parameterNumber = 21 ;
}
#Net long wave radiation flux (surface)
'Net long wave radiation flux (surface)' = {
discipline = 0 ;
parameterCategory = 5 ;
parameterNumber = 0 ;
}
#Net long wave radiation flux (top of atmosphere)
'Net long wave radiation flux (top of atmosphere)' = {
discipline = 0 ;
parameterCategory = 5 ;
parameterNumber = 1 ;
}
#Maximum snow albedo
'Maximum snow albedo' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 17 ;
}
#Soil temperature
'Soil temperature' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 2 ;
}
#Soil moisture
'Soil moisture' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 22 ;
}

View File

@ -4079,6 +4079,27 @@
parameterNumber = 148 ; parameterNumber = 148 ;
typeOfFirstFixedSurface = 1 ; typeOfFirstFixedSurface = 1 ;
} }
#Radar reflectivity
'231066' = {
discipline = 0 ;
parameterCategory = 16 ;
parameterNumber = 4 ;
}
#Pressure at cloud ceiling
'231067' = {
discipline = 0 ;
parameterCategory = 3 ;
parameterNumber = 0 ;
typeOfFirstFixedSurface = 19 ;
scaledValueOfFirstFixedSurface = 50 ;
scaleFactorOfFirstFixedSurface = 0 ;
}
#Visibility through precipitation
'231068' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 51 ;
}
#Burned area #Burned area
'232000' = { '232000' = {
discipline = 2 ; discipline = 2 ;
@ -5566,6 +5587,13 @@
parameterNumber = 23 ; parameterNumber = 23 ;
typeOfStatisticalProcessing = 0 ; typeOfStatisticalProcessing = 0 ;
} }
#Time-mean visibility through precipitation
'235382' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 51 ;
typeOfStatisticalProcessing = 0 ;
}
#Time-maximum volumetric soil moisture #Time-maximum volumetric soil moisture
'237077' = { '237077' = {
discipline = 2 ; discipline = 2 ;
@ -5602,6 +5630,13 @@
typeOfSecondFixedSurface = 8 ; typeOfSecondFixedSurface = 8 ;
typeOfStatisticalProcessing = 2 ; typeOfStatisticalProcessing = 2 ;
} }
#Time-maximum visibility through precipitation
'237382' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 51 ;
typeOfStatisticalProcessing = 2 ;
}
#Time-minimum volumetric soil moisture #Time-minimum volumetric soil moisture
'238077' = { '238077' = {
discipline = 2 ; discipline = 2 ;
@ -5645,6 +5680,13 @@
typeOfSecondFixedSurface = 8 ; typeOfSecondFixedSurface = 8 ;
typeOfStatisticalProcessing = 3 ; typeOfStatisticalProcessing = 3 ;
} }
#Time-minimum visibility through precipitation
'238382' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 51 ;
typeOfStatisticalProcessing = 3 ;
}
#Time-standard-deviation volumetric soil moisture #Time-standard-deviation volumetric soil moisture
'239077' = { '239077' = {
discipline = 2 ; discipline = 2 ;

View File

@ -186,3 +186,69 @@
parameterCategory = 0 ; parameterCategory = 0 ;
parameterNumber = 2 ; parameterNumber = 2 ;
} }
#Maximum temperature
'3015' = {
discipline = 0 ;
parameterCategory = 0 ;
parameterNumber = 4 ;
}
#Minimum temperature
'3016' = {
discipline = 0 ;
parameterCategory = 0 ;
parameterNumber = 5 ;
}
#Minimum dew point depression
'260006' = {
discipline = 0 ;
parameterCategory = 0 ;
parameterNumber = 14 ;
}
#Maximum relative humidity
'260023' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 27 ;
}
#Maximum absolute humidity
'260024' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 28 ;
}
#Maximum wind speed
'260064' = {
discipline = 0 ;
parameterCategory = 2 ;
parameterNumber = 21 ;
}
#Net long wave radiation flux (surface)
'260095' = {
discipline = 0 ;
parameterCategory = 5 ;
parameterNumber = 0 ;
}
#Net long wave radiation flux (top of atmosphere)
'260096' = {
discipline = 0 ;
parameterCategory = 5 ;
parameterNumber = 1 ;
}
#Maximum snow albedo
'260161' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 17 ;
}
#Soil temperature
'228139' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 2 ;
}
#Soil moisture
'228039' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 22 ;
}

View File

@ -4079,6 +4079,27 @@
parameterNumber = 148 ; parameterNumber = 148 ;
typeOfFirstFixedSurface = 1 ; typeOfFirstFixedSurface = 1 ;
} }
#Radar reflectivity
'rare' = {
discipline = 0 ;
parameterCategory = 16 ;
parameterNumber = 4 ;
}
#Pressure at cloud ceiling
'pcdc' = {
discipline = 0 ;
parameterCategory = 3 ;
parameterNumber = 0 ;
typeOfFirstFixedSurface = 19 ;
scaledValueOfFirstFixedSurface = 50 ;
scaleFactorOfFirstFixedSurface = 0 ;
}
#Visibility through precipitation
'visp' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 51 ;
}
#Burned area #Burned area
'fba' = { 'fba' = {
discipline = 2 ; discipline = 2 ;
@ -5566,6 +5587,13 @@
parameterNumber = 23 ; parameterNumber = 23 ;
typeOfStatisticalProcessing = 0 ; typeOfStatisticalProcessing = 0 ;
} }
#Time-mean visibility through precipitation
'avg_visp' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 51 ;
typeOfStatisticalProcessing = 0 ;
}
#Time-maximum volumetric soil moisture #Time-maximum volumetric soil moisture
'max_vsw' = { 'max_vsw' = {
discipline = 2 ; discipline = 2 ;
@ -5602,6 +5630,13 @@
typeOfSecondFixedSurface = 8 ; typeOfSecondFixedSurface = 8 ;
typeOfStatisticalProcessing = 2 ; typeOfStatisticalProcessing = 2 ;
} }
#Time-maximum visibility through precipitation
'max_visp' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 51 ;
typeOfStatisticalProcessing = 2 ;
}
#Time-minimum volumetric soil moisture #Time-minimum volumetric soil moisture
'min_vsw' = { 'min_vsw' = {
discipline = 2 ; discipline = 2 ;
@ -5645,6 +5680,13 @@
typeOfSecondFixedSurface = 8 ; typeOfSecondFixedSurface = 8 ;
typeOfStatisticalProcessing = 3 ; typeOfStatisticalProcessing = 3 ;
} }
#Time-minimum visibility through precipitation
'min_visp' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 51 ;
typeOfStatisticalProcessing = 3 ;
}
#Time-standard-deviation volumetric soil moisture #Time-standard-deviation volumetric soil moisture
'std_vsw' = { 'std_vsw' = {
discipline = 2 ; discipline = 2 ;

View File

@ -186,3 +186,69 @@
parameterCategory = 0 ; parameterCategory = 0 ;
parameterNumber = 2 ; parameterNumber = 2 ;
} }
#Maximum temperature
'tmax' = {
discipline = 0 ;
parameterCategory = 0 ;
parameterNumber = 4 ;
}
#Minimum temperature
'tmin' = {
discipline = 0 ;
parameterCategory = 0 ;
parameterNumber = 5 ;
}
#Minimum dew point depression
'mindpd' = {
discipline = 0 ;
parameterCategory = 0 ;
parameterNumber = 14 ;
}
#Maximum relative humidity
'maxrh' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 27 ;
}
#Maximum absolute humidity
'maxah' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 28 ;
}
#Maximum wind speed
'maxgust' = {
discipline = 0 ;
parameterCategory = 2 ;
parameterNumber = 21 ;
}
#Net long wave radiation flux (surface)
'nlwrs' = {
discipline = 0 ;
parameterCategory = 5 ;
parameterNumber = 0 ;
}
#Net long wave radiation flux (top of atmosphere)
'nlwrt' = {
discipline = 0 ;
parameterCategory = 5 ;
parameterNumber = 1 ;
}
#Maximum snow albedo
'mxsalb' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 17 ;
}
#Soil temperature
'st' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 2 ;
}
#Soil moisture
'sm' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 22 ;
}

View File

@ -40,6 +40,7 @@ alias nTileAtt=numberOfUsedTileAttributesForTileAttributeCombination;
alias tile.nTileAtt=nTileAtt; alias tile.nTileAtt=nTileAtt;
alias mars.tile=typeOfTile; alias mars.tile=typeOfTile;
alias mars.tileAttribute=tileAttribute; alias mars.tileattribute=tileAttribute;
transient paramtype = "tile"; constant paramTypeTile = "tile";
alias mars.paramType=paramtype; unalias mars.paramtype;
alias mars.paramtype=paramTypeTile;

View File

@ -20,6 +20,7 @@
'neutralBuoyancy' = {typeOfFirstFixedSurface=16; typeOfSecondFixedSurface=255;} 'neutralBuoyancy' = {typeOfFirstFixedSurface=16; typeOfSecondFixedSurface=255;}
'mostUnstableParcel' = {typeOfFirstFixedSurface=17; typeOfSecondFixedSurface=255;} 'mostUnstableParcel' = {typeOfFirstFixedSurface=17; typeOfSecondFixedSurface=255;}
'mixedLayerParcel' = {typeOfFirstFixedSurface=18; typeOfSecondFixedSurface=255;} 'mixedLayerParcel' = {typeOfFirstFixedSurface=18; typeOfSecondFixedSurface=255;}
'lowestLevelOfCloudCoverExceedance' = {typeOfFirstFixedSurface=19; typeOfSecondFixedSurface=255;}
'isothermal' = {typeOfFirstFixedSurface=20; typeOfSecondFixedSurface=255;} 'isothermal' = {typeOfFirstFixedSurface=20; typeOfSecondFixedSurface=255;}
'isobaricInPa' = {typeOfFirstFixedSurface=100; typeOfSecondFixedSurface=255; pressureUnits='Pa';} 'isobaricInPa' = {typeOfFirstFixedSurface=100; typeOfSecondFixedSurface=255; pressureUnits='Pa';}
'isobaricInhPa' = {typeOfFirstFixedSurface=100; pressureUnits='hPa'; typeOfSecondFixedSurface=255;} 'isobaricInhPa' = {typeOfFirstFixedSurface=100; pressureUnits='hPa'; typeOfSecondFixedSurface=255;}

View File

@ -4079,6 +4079,27 @@
parameterNumber = 148 ; parameterNumber = 148 ;
typeOfFirstFixedSurface = 1 ; typeOfFirstFixedSurface = 1 ;
} }
#Radar reflectivity
'dB' = {
discipline = 0 ;
parameterCategory = 16 ;
parameterNumber = 4 ;
}
#Pressure at cloud ceiling
'Pa' = {
discipline = 0 ;
parameterCategory = 3 ;
parameterNumber = 0 ;
typeOfFirstFixedSurface = 19 ;
scaledValueOfFirstFixedSurface = 50 ;
scaleFactorOfFirstFixedSurface = 0 ;
}
#Visibility through precipitation
'm' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 51 ;
}
#Burned area #Burned area
'%' = { '%' = {
discipline = 2 ; discipline = 2 ;
@ -5566,6 +5587,13 @@
parameterNumber = 23 ; parameterNumber = 23 ;
typeOfStatisticalProcessing = 0 ; typeOfStatisticalProcessing = 0 ;
} }
#Time-mean visibility through precipitation
'm' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 51 ;
typeOfStatisticalProcessing = 0 ;
}
#Time-maximum volumetric soil moisture #Time-maximum volumetric soil moisture
'm**3 m**-3' = { 'm**3 m**-3' = {
discipline = 2 ; discipline = 2 ;
@ -5602,6 +5630,13 @@
typeOfSecondFixedSurface = 8 ; typeOfSecondFixedSurface = 8 ;
typeOfStatisticalProcessing = 2 ; typeOfStatisticalProcessing = 2 ;
} }
#Time-maximum visibility through precipitation
'm' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 51 ;
typeOfStatisticalProcessing = 2 ;
}
#Time-minimum volumetric soil moisture #Time-minimum volumetric soil moisture
'm**3 m**-3' = { 'm**3 m**-3' = {
discipline = 2 ; discipline = 2 ;
@ -5645,6 +5680,13 @@
typeOfSecondFixedSurface = 8 ; typeOfSecondFixedSurface = 8 ;
typeOfStatisticalProcessing = 3 ; typeOfStatisticalProcessing = 3 ;
} }
#Time-minimum visibility through precipitation
'm' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 51 ;
typeOfStatisticalProcessing = 3 ;
}
#Time-standard-deviation volumetric soil moisture #Time-standard-deviation volumetric soil moisture
'm**3 m**-3' = { 'm**3 m**-3' = {
discipline = 2 ; discipline = 2 ;

View File

@ -186,3 +186,69 @@
parameterCategory = 0 ; parameterCategory = 0 ;
parameterNumber = 2 ; parameterNumber = 2 ;
} }
#Maximum temperature
'K' = {
discipline = 0 ;
parameterCategory = 0 ;
parameterNumber = 4 ;
}
#Minimum temperature
'K' = {
discipline = 0 ;
parameterCategory = 0 ;
parameterNumber = 5 ;
}
#Minimum dew point depression
'K' = {
discipline = 0 ;
parameterCategory = 0 ;
parameterNumber = 14 ;
}
#Maximum relative humidity
'%' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 27 ;
}
#Maximum absolute humidity
'kg m**-3' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 28 ;
}
#Maximum wind speed
'm s**-1' = {
discipline = 0 ;
parameterCategory = 2 ;
parameterNumber = 21 ;
}
#Net long wave radiation flux (surface)
'W m**-2' = {
discipline = 0 ;
parameterCategory = 5 ;
parameterNumber = 0 ;
}
#Net long wave radiation flux (top of atmosphere)
'W m**-2' = {
discipline = 0 ;
parameterCategory = 5 ;
parameterNumber = 1 ;
}
#Maximum snow albedo
'%' = {
discipline = 0 ;
parameterCategory = 19 ;
parameterNumber = 17 ;
}
#Soil temperature
'K' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 2 ;
}
#Soil moisture
'kg m**-3' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 22 ;
}

View File

@ -55,6 +55,7 @@ if( HAVE_BUILD_TOOLS )
grib_get_set_uuid grib_get_set_uuid
grib_clone grib_clone
grib_ecc-1316 grib_ecc-1316
grib_infinity_grid_second_order
bufr_attributes bufr_attributes
bufr_clone bufr_clone
bufr_expanded bufr_expanded

View File

@ -31,8 +31,10 @@ program codes_dump_test
if (iret == CODES_END_OF_FILE) exit if (iret == CODES_END_OF_FILE) exit
call codes_set_debug(0) call codes_set_debug(0)
call codes_set_data_quality_checks(1)
call codes_dump(msgid) call codes_dump(msgid)
call codes_set_debug(1) call codes_set_debug(1)
call codes_set_data_quality_checks(0)
call codes_release(msgid) call codes_release(msgid)

View File

@ -0,0 +1,41 @@
! (C) Copyright 2005- 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.
!
! Description: issue with grid_second_order hanging when encoding fields with infinite values
!
!
USE eccodes
USE ieee_arithmetic
IMPLICIT NONE
INTEGER :: IGRIBH
REAL(KIND=8) :: ZT (421*441)
CHARACTER*32 :: CLPACKING ! grid_simple / grid_second_order
CHARACTER*32 :: CLINFINITY ! 0 / 1
CALL GETARG (1, CLPACKING)
CALL GETARG (2, CLINFINITY)
CALL codes_grib_new_from_samples(IGRIBH, "regular_ll_sfc_grib2")
CALL codes_set_long (IGRIBH, "Ni", 421_8)
CALL codes_set_long (IGRIBH, "Nj", 441_8)
CALL codes_set_long (IGRIBH, "bitsPerValue", 16_8)
CALL codes_set_string (IGRIBH, "packingType", TRIM (CLPACKING))
ZT = 0._8
IF (CLINFINITY == '1') THEN
ZT (1) = IEEE_VALUE (0._8, IEEE_POSITIVE_INF)
ENDIF
! This should fail if CLINFINITY is 1 (inf passed in)
CALL codes_set_real8_array (IGRIBH, "values", ZT)
END

View File

@ -0,0 +1,37 @@
#!/bin/sh
# (C) Copyright 2005- 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.
#
# -----------------------------------------------------------------
# This is the test for the JIRA issue ECC-1927
# grid_second_order hangs when encoding fields with infinite values
# -----------------------------------------------------------------
. ./include.ctest.sh
for encoding in grid_simple grid_second_order; do
for infinity in 0 1; do
if [ $infinity -eq 1 ]; then
set +e
fi
${examples_dir}/eccodes_f_grib_infinity_grid_second_order $encoding $infinity
c=$?
if [ $infinity -eq 1 ]; then
set -e
if [ $c -eq 0 ]; then
echo "Encoding infinite numbers should have failed"
exit 1
fi
fi
done
done

View File

@ -2786,6 +2786,12 @@
call grib_set_debug(dmode) call grib_set_debug(dmode)
end subroutine codes_set_debug end subroutine codes_set_debug
!> Set data quality check value (0, 1 or 2)
subroutine codes_set_data_quality_checks(val)
integer(kind=kindOfInt), intent(in) :: val
call grib_set_data_quality_checks(val)
end subroutine codes_set_data_quality_checks
!> Set the definition path !> Set the definition path

View File

@ -79,7 +79,7 @@ integer, external :: grib_f_set_int, grib_f_set_int_array, &
integer, external :: grib_f_get_message_size, grib_f_copy_message, grib_f_count_in_file integer, external :: grib_f_get_message_size, grib_f_copy_message, grib_f_count_in_file
integer, external :: grib_f_write, grib_f_multi_write, grib_f_multi_append integer, external :: grib_f_write, grib_f_multi_write, grib_f_multi_append
integer, external :: grib_f_clone, grib_f_copy_namespace integer, external :: grib_f_clone, grib_f_copy_namespace
external :: grib_f_check , grib_f_set_debug external :: grib_f_check , grib_f_set_debug, grib_f_set_data_quality_checks
integer, external :: grib_f_util_sections_copy integer, external :: grib_f_util_sections_copy
integer, external :: grib_f_set_definitions_path, grib_f_set_samples_path integer, external :: grib_f_set_definitions_path, grib_f_set_samples_path
integer, external :: grib_f_julian_to_datetime, grib_f_datetime_to_julian, grib_f_copy_key integer, external :: grib_f_julian_to_datetime, grib_f_datetime_to_julian, grib_f_copy_key

View File

@ -3211,6 +3211,12 @@
call grib_f_set_debug(dmode) call grib_f_set_debug(dmode)
end subroutine grib_set_debug end subroutine grib_set_debug
!> Set data quality check value (0, 1 or 2)
subroutine grib_set_data_quality_checks(val)
integer(kind=kindOfInt), intent(in) :: val
call grib_f_set_data_quality_checks(val)
end subroutine grib_set_data_quality_checks
!> Set the definition path !> Set the definition path
!> !>

View File

@ -2875,6 +2875,13 @@ void grib_f_set_debug_(int* dmode)
grib_context* c = grib_context_get_default(); grib_context* c = grib_context_get_default();
grib_context_set_debug(c, *dmode); grib_context_set_debug(c, *dmode);
} }
/*****************************************************************************/
void grib_f_set_data_quality_checks_(int* val)
{
Assert(val);
grib_context* c = grib_context_get_default();
grib_context_set_data_quality_checks(c, *val);
}
/*****************************************************************************/ /*****************************************************************************/
int grib_f_set_definitions_path_(char* path, int len) int grib_f_set_definitions_path_(char* path, int len)

View File

@ -310,6 +310,7 @@ int codes_f_bufr_keys_iterator_new_(int* gid,int* iterid);
int grib_f_read_file_(int* fid, void* buffer, size_t* nbytes); int grib_f_read_file_(int* fid, void* buffer, size_t* nbytes);
int codes_f_bufr_keys_iterator_delete_(int* iterid); int codes_f_bufr_keys_iterator_delete_(int* iterid);
void grib_f_set_debug_(int* mode); void grib_f_set_debug_(int* mode);
void grib_f_set_data_quality_checks_(int* val);
int grib_f_set_definitions_path_(char* path, int len); int grib_f_set_definitions_path_(char* path, int len);
int grib_f_read_any_from_file_(int* fid, void* buffer, size_t* nbytes); int grib_f_read_any_from_file_(int* fid, void* buffer, size_t* nbytes);
int any_f_new_from_file_(int* fid, int* gid); int any_f_new_from_file_(int* fid, int* gid);

View File

@ -856,8 +856,7 @@ static int encode_double_value(grib_context* c, grib_buffer* buff, long* pos, bu
return err; return err;
} }
static int encode_string_value(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, static int encode_string_value(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, char* sval)
grib_accessor_bufr_data_array_t* self, char* sval)
{ {
int err = 0; int err = 0;
int len; int len;
@ -866,7 +865,7 @@ static int encode_string_value(grib_context* c, grib_buffer* buff, long* pos, bu
grib_buffer_set_ulength_bits(c, buff, buff->ulength_bits + bd->width); grib_buffer_set_ulength_bits(c, buff, buff->ulength_bits + bd->width);
err = grib_encode_string(buff->data, pos, len, sval); err = grib_encode_string(buff->data, pos, len, sval);
if (err) { if (err) {
grib_context_log(c, GRIB_LOG_ERROR, "encode_string_value: %s. Failed to encode '%s'", bd->shortName, sval); grib_context_log(c, GRIB_LOG_ERROR, "%s: %s. Failed to encode '%s'", __func__, bd->shortName, sval);
} }
return err; return err;
@ -1171,7 +1170,7 @@ static int encode_new_element(grib_context* c, grib_accessor_bufr_data_array_t*
grib_sarray_delete(c, stringValues); grib_sarray_delete(c, stringValues);
} }
else { else {
err = encode_string_value(c, buff, pos, bd, self, csval); err = encode_string_value(c, buff, pos, bd, csval);
grib_context_free(c, csval); grib_context_free(c, csval);
} }
} }
@ -1293,7 +1292,7 @@ static int encode_element(grib_context* c, grib_accessor_bufr_data_array_t* self
grib_context_log(c, GRIB_LOG_ERROR, "encode_element '%s': Invalid index %d", bd->shortName, idx); grib_context_log(c, GRIB_LOG_ERROR, "encode_element '%s': Invalid index %d", bd->shortName, idx);
return GRIB_INVALID_ARGUMENT; return GRIB_INVALID_ARGUMENT;
} }
err = encode_string_value(c, buff, pos, bd, self, self->stringValues_->v[idx]->v[0]); err = encode_string_value(c, buff, pos, bd, self->stringValues_->v[idx]->v[0]);
} }
} }
else { else {

View File

@ -85,6 +85,7 @@ static void print_aec_stream_info(struct aec_stream* strm, const char* func)
fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.avail_in=%lu\n", func, strm->avail_in); fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.avail_in=%lu\n", func, strm->avail_in);
} }
#define MAX_BITS_PER_VALUE 32
int grib_accessor_data_ccsds_packing_t::pack_double(const double* val, size_t* len) int grib_accessor_data_ccsds_packing_t::pack_double(const double* val, size_t* len)
{ {
grib_handle* hand = grib_handle_of_accessor(this); grib_handle* hand = grib_handle_of_accessor(this);
@ -253,6 +254,7 @@ int grib_accessor_data_ccsds_packing_t::pack_double(const double* val, size_t* l
} }
binary_scale_factor = grib_get_binary_scale_fact(max, reference_value, bits_per_value, &err); binary_scale_factor = grib_get_binary_scale_fact(max, reference_value, bits_per_value, &err);
if (err) return err;
divisor = codes_power<double>(-binary_scale_factor, 2); divisor = codes_power<double>(-binary_scale_factor, 2);
size_t nbytes = (bits_per_value + 7) / 8; size_t nbytes = (bits_per_value + 7) / 8;
@ -302,8 +304,8 @@ int grib_accessor_data_ccsds_packing_t::pack_double(const double* val, size_t* l
} }
break; break;
default: default:
grib_context_log(context_, GRIB_LOG_ERROR, "%s pack_double: packing %s, bits_per_value=%ld (max 32)", grib_context_log(context_, GRIB_LOG_ERROR, "%s pack_double: packing %s, bitsPerValue=%ld (max %ld)",
cclass_name, name_, bits_per_value); cclass_name, name_, bits_per_value, MAX_BITS_PER_VALUE);
err = GRIB_INVALID_BPV; err = GRIB_INVALID_BPV;
goto cleanup; goto cleanup;
} }
@ -501,8 +503,8 @@ static int unpack(grib_accessor* a, T* val, size_t* len)
} }
break; break;
default: default:
grib_context_log(a->context_, GRIB_LOG_ERROR, "%s %s: unpacking %s, bits_per_value=%ld (max 32)", grib_context_log(a->context_, GRIB_LOG_ERROR, "%s %s: unpacking %s, bitsPerValue=%ld (max %ld)",
cclass_name, __func__, a->name_, bits_per_value); cclass_name, __func__, a->name_, bits_per_value, MAX_BITS_PER_VALUE);
err = GRIB_INVALID_BPV; err = GRIB_INVALID_BPV;
goto cleanup; goto cleanup;
} }

View File

@ -412,7 +412,6 @@ int grib_accessor_data_complex_packing_t::pack_double(const double* val, size_t*
return GRIB_INTERNAL_ERROR; return GRIB_INTERNAL_ERROR;
} }
binary_scale_factor = grib_get_binary_scale_fact(d * max, reference_value, bits_per_value, &ret); binary_scale_factor = grib_get_binary_scale_fact(d * max, reference_value, bits_per_value, &ret);
if (ret == GRIB_UNDERFLOW) { if (ret == GRIB_UNDERFLOW) {
d = 0; d = 0;
binary_scale_factor = 0; binary_scale_factor = 0;

View File

@ -596,6 +596,9 @@ int grib_accessor_data_g1second_order_general_extended_packing_t::pack_double(co
else if (val[i] < min) else if (val[i] < min)
min = val[i]; min = val[i];
} }
if ((ret = grib_check_data_values_minmax(handle, min, max)) != GRIB_SUCCESS) {
return ret;
}
/* ECC-1219: packingType conversion from grid_ieee to grid_second_order */ /* ECC-1219: packingType conversion from grid_ieee to grid_second_order */
if ((ret = get_bits_per_value(handle, bits_per_value_, &bits_per_value)) != GRIB_SUCCESS) if ((ret = get_bits_per_value(handle, bits_per_value_, &bits_per_value)) != GRIB_SUCCESS)
@ -641,6 +644,7 @@ int grib_accessor_data_g1second_order_general_extended_packing_t::pack_double(co
return GRIB_INTERNAL_ERROR; return GRIB_INTERNAL_ERROR;
} }
binary_scale_factor = grib_get_binary_scale_fact(max, reference_value, bits_per_value, &ret); binary_scale_factor = grib_get_binary_scale_fact(max, reference_value, bits_per_value, &ret);
if (ret != GRIB_SUCCESS) return ret;
divisor = codes_power<double>(-binary_scale_factor, 2); divisor = codes_power<double>(-binary_scale_factor, 2);
} }

View File

@ -1461,7 +1461,7 @@ int grib_accessor_data_g22order_packing_t::pack_double(const double* val, size_t
} }
template <typename T> template <typename T>
static int unpack(grib_accessor* a, T* val, const size_t* len) static int unpack(grib_accessor* a, T* val, size_t* len)
{ {
grib_accessor_data_g22order_packing_t* self = reinterpret_cast<grib_accessor_data_g22order_packing_t*>(a); grib_accessor_data_g22order_packing_t* self = reinterpret_cast<grib_accessor_data_g22order_packing_t*>(a);
static_assert(std::is_floating_point<T>::value, "Requires floating points numbers"); static_assert(std::is_floating_point<T>::value, "Requires floating points numbers");
@ -1563,6 +1563,14 @@ static int unpack(grib_accessor* a, T* val, const size_t* len)
a->dirty_ = 0; a->dirty_ = 0;
if (bits_per_value == 0) {
for (i = 0; i < n_vals; i++) {
val[i] = reference_value;
}
*len = n_vals;
return GRIB_SUCCESS;
}
sec_val = (long*)grib_context_malloc(a->context_, (n_vals) * sizeof(long)); sec_val = (long*)grib_context_malloc(a->context_, (n_vals) * sizeof(long));
if (!sec_val) return GRIB_OUT_OF_MEMORY; if (!sec_val) return GRIB_OUT_OF_MEMORY;
memset(sec_val, 0, (n_vals) * sizeof(long)); // See SUP-718 memset(sec_val, 0, (n_vals) * sizeof(long)); // See SUP-718

View File

@ -397,6 +397,7 @@ int grib_accessor_data_png_packing_t::pack_double(const double* val, size_t* len
} }
binary_scale_factor = grib_get_binary_scale_fact(max, reference_value, bits_per_value, &err); binary_scale_factor = grib_get_binary_scale_fact(max, reference_value, bits_per_value, &err);
if (err) return err;
divisor = codes_power<double>(-binary_scale_factor, 2); divisor = codes_power<double>(-binary_scale_factor, 2);
#ifndef PNG_ANYBITS #ifndef PNG_ANYBITS

View File

@ -218,10 +218,9 @@ static grib_concept_value* get_concept_impl(grib_handle* h, grib_action_concept*
char master[1024] = {0,}; char master[1024] = {0,};
char local[1024] = {0,}; char local[1024] = {0,};
char masterDir[1024] = {0,}; char masterDir[1024] = {0,};
size_t lenMasterDir = 1024; size_t lenMasterDir = sizeof(masterDir);
char key[4096] = {0,}; char key[4096] = {0,};
char* full = 0; char* full = 0;
int id;
const size_t bufLen = sizeof(buf); const size_t bufLen = sizeof(buf);
const size_t keyLen = sizeof(key); const size_t keyLen = sizeof(key);
@ -234,7 +233,15 @@ static grib_concept_value* get_concept_impl(grib_handle* h, grib_action_concept*
Assert(self->masterDir); Assert(self->masterDir);
grib_get_string(h, self->masterDir, masterDir, &lenMasterDir); grib_get_string(h, self->masterDir, masterDir, &lenMasterDir);
snprintf(buf, bufLen, "%s/%s", masterDir, self->basename); // See ECC-1920: The basename could be a key or a string
char* basename = self->basename; // default is a string
Assert(basename);
char baseNameValue[1024] = {0,}; // its value if a key
size_t lenBaseName = sizeof(baseNameValue);
if (grib_get_string(h, self->basename, baseNameValue, &lenBaseName) == GRIB_SUCCESS) {
basename = baseNameValue; // self->basename was a key whose value is baseNameValue
}
snprintf(buf, bufLen, "%s/%s", masterDir, basename);
grib_recompose_name(h, NULL, buf, master, 1); grib_recompose_name(h, NULL, buf, master, 1);
@ -242,13 +249,13 @@ static grib_concept_value* get_concept_impl(grib_handle* h, grib_action_concept*
char localDir[1024] = {0,}; char localDir[1024] = {0,};
size_t lenLocalDir = 1024; size_t lenLocalDir = 1024;
grib_get_string(h, self->localDir, localDir, &lenLocalDir); grib_get_string(h, self->localDir, localDir, &lenLocalDir);
snprintf(buf, bufLen, "%s/%s", localDir, self->basename); snprintf(buf, bufLen, "%s/%s", localDir, basename);
grib_recompose_name(h, NULL, buf, local, 1); grib_recompose_name(h, NULL, buf, local, 1);
} }
snprintf(key, keyLen, "%s%s", master, local); snprintf(key, keyLen, "%s%s", master, local);
id = grib_itrie_get_id(h->context->concepts_index, key); int id = grib_itrie_get_id(h->context->concepts_index, key);
if ((c = h->context->concepts[id]) != NULL) if ((c = h->context->concepts[id]) != NULL)
return c; return c;
@ -274,7 +281,7 @@ static grib_concept_value* get_concept_impl(grib_handle* h, grib_action_concept*
else { else {
grib_context_log(context, GRIB_LOG_FATAL, grib_context_log(context, GRIB_LOG_FATAL,
"unable to find definition file %s in %s:%s\nDefinition files path=\"%s\"", "unable to find definition file %s in %s:%s\nDefinition files path=\"%s\"",
self->basename, master, local, context->grib_definition_files_path); basename, master, local, context->grib_definition_files_path);
return NULL; return NULL;
} }

View File

@ -12,11 +12,11 @@
/* Generic functions */ /* Generic functions */
/******************************************************************************/ /******************************************************************************/
char* codes_samples_path(const grib_context* c) char* codes_samples_path(const codes_context* c)
{ {
return grib_samples_path(c); return grib_samples_path(c);
} }
char* codes_definition_path(const grib_context* c) char* codes_definition_path(const codes_context* c)
{ {
return grib_definition_path(c); return grib_definition_path(c);
} }
@ -41,16 +41,16 @@ void codes_print_api_version(FILE* out)
{ {
grib_print_api_version(out); grib_print_api_version(out);
} }
int codes_count_in_file(grib_context* c, FILE* f, int* n) int codes_count_in_file(codes_context* c, FILE* f, int* n)
{ {
return grib_count_in_file(c, f, n); return grib_count_in_file(c, f, n);
} }
int codes_count_in_filename(grib_context* c, const char* filename, int* n) int codes_count_in_filename(codes_context* c, const char* filename, int* n)
{ {
return grib_count_in_filename(c, filename, n); return grib_count_in_filename(c, filename, n);
} }
grib_context* codes_context_get_default(void) codes_context* codes_context_get_default(void)
{ {
return grib_context_get_default(); return grib_context_get_default();
} }
@ -74,7 +74,7 @@ void codes_check(const char* call, const char* file, int line, int e, const char
/* Fieldsets */ /* Fieldsets */
/******************************************************************************/ /******************************************************************************/
grib_fieldset* codes_fieldset_new_from_files(grib_context* c, const char* filenames[], int nfiles, const char** keys, int nkeys, const char* where_string, const char* order_by_string, int* err) grib_fieldset* codes_fieldset_new_from_files(codes_context* c, const char* filenames[], int nfiles, const char** keys, int nkeys, const char* where_string, const char* order_by_string, int* err)
{ {
return grib_fieldset_new_from_files(c, filenames, nfiles, keys, nkeys, where_string, order_by_string, err); return grib_fieldset_new_from_files(c, filenames, nfiles, keys, nkeys, where_string, order_by_string, err);
} }
@ -101,11 +101,11 @@ int codes_fieldset_count(const grib_fieldset* set)
/* Indexing */ /* Indexing */
/******************************************************************************/ /******************************************************************************/
grib_index* codes_index_new_from_file(grib_context* c, const char* filename, const char* keys, int* err) grib_index* codes_index_new_from_file(codes_context* c, const char* filename, const char* keys, int* err)
{ {
return grib_index_new_from_file(c, filename, keys, err); return grib_index_new_from_file(c, filename, keys, err);
} }
grib_index* codes_index_new(grib_context* c, const char* keys, int* err) grib_index* codes_index_new(codes_context* c, const char* keys, int* err)
{ {
return grib_index_new(c, keys, err); return grib_index_new(c, keys, err);
} }
@ -117,7 +117,7 @@ int codes_index_write(grib_index* index, const char* filename)
{ {
return grib_index_write(index, filename); return grib_index_write(index, filename);
} }
grib_index* codes_index_read(grib_context* c, const char* filename, int* err) grib_index* codes_index_read(codes_context* c, const char* filename, int* err)
{ {
return grib_index_read(c, filename, err); return grib_index_read(c, filename, err);
} }
@ -164,15 +164,15 @@ int codes_write_message(const grib_handle* h, const char* file, const char* mode
{ {
return grib_write_message(h, file, mode); return grib_write_message(h, file, mode);
} }
grib_handle* codes_handle_new_from_message(grib_context* c, const void* data, size_t data_len) grib_handle* codes_handle_new_from_message(codes_context* c, const void* data, size_t data_len)
{ {
return grib_handle_new_from_message(c, data, data_len); return grib_handle_new_from_message(c, data, data_len);
} }
grib_handle* codes_handle_new_from_message_copy(grib_context* c, const void* data, size_t data_len) grib_handle* codes_handle_new_from_message_copy(codes_context* c, const void* data, size_t data_len)
{ {
return grib_handle_new_from_message_copy(c, data, data_len); return grib_handle_new_from_message_copy(c, data, data_len);
} }
grib_handle* codes_grib_handle_new_from_samples(grib_context* c, const char* sample_name) grib_handle* codes_grib_handle_new_from_samples(codes_context* c, const char* sample_name)
{ {
return grib_handle_new_from_samples(c, sample_name); return grib_handle_new_from_samples(c, sample_name);
} }
@ -189,11 +189,11 @@ int codes_handle_delete(grib_handle* h)
{ {
return grib_handle_delete(h); return grib_handle_delete(h);
} }
grib_handle* codes_handle_new_from_partial_message_copy(grib_context* c, const void* data, size_t size) grib_handle* codes_handle_new_from_partial_message_copy(codes_context* c, const void* data, size_t size)
{ {
return grib_handle_new_from_partial_message_copy(c, data, size); return grib_handle_new_from_partial_message_copy(c, data, size);
} }
grib_handle* codes_handle_new_from_partial_message(grib_context* c, const void* data, size_t buflen) grib_handle* codes_handle_new_from_partial_message(codes_context* c, const void* data, size_t buflen)
{ {
return grib_handle_new_from_partial_message(c, data, buflen); return grib_handle_new_from_partial_message(c, data, buflen);
} }
@ -230,23 +230,23 @@ grib_string_list* codes_grib_util_get_mars_param(const char* param_id)
{ {
return grib_util_get_mars_param(param_id); return grib_util_get_mars_param(param_id);
} }
void codes_grib_multi_support_on(grib_context* c) void codes_grib_multi_support_on(codes_context* c)
{ {
grib_multi_support_on(c); grib_multi_support_on(c);
} }
void codes_grib_multi_support_off(grib_context* c) void codes_grib_multi_support_off(codes_context* c)
{ {
grib_multi_support_off(c); grib_multi_support_off(c);
} }
void codes_grib_multi_support_reset_file(grib_context* c, FILE* f) void codes_grib_multi_support_reset_file(codes_context* c, FILE* f)
{ {
grib_multi_support_reset_file(c, f); grib_multi_support_reset_file(c, f);
} }
grib_handle* codes_grib_handle_new_from_multi_message(grib_context* c, void** data, size_t* data_len, int* error) grib_handle* codes_grib_handle_new_from_multi_message(codes_context* c, void** data, size_t* data_len, int* error)
{ {
return grib_handle_new_from_multi_message(c, data, data_len, error); return grib_handle_new_from_multi_message(c, data, data_len, error);
} }
grib_multi_handle* codes_grib_multi_handle_new(grib_context* c) grib_multi_handle* codes_grib_multi_handle_new(codes_context* c)
{ {
return grib_multi_handle_new(c); return grib_multi_handle_new(c);
} }
@ -467,24 +467,24 @@ void codes_dump_action_tree(codes_context* c, FILE* f)
} }
/* GTS, GRIBEX */ /* GTS, GRIBEX */
/******************************************************************************/ /******************************************************************************/
void codes_gts_header_off(grib_context* c) void codes_gts_header_off(codes_context* c)
{ {
grib_gts_header_off(c); grib_gts_header_off(c);
} }
void codes_gts_header_on(grib_context* c) void codes_gts_header_on(codes_context* c)
{ {
grib_gts_header_on(c); grib_gts_header_on(c);
} }
void codes_gribex_mode_on(grib_context* c) void codes_gribex_mode_on(codes_context* c)
{ {
grib_gribex_mode_on(c); grib_gribex_mode_on(c);
} }
int codes_get_gribex_mode(const grib_context* c) int codes_get_gribex_mode(const codes_context* c)
{ {
return grib_get_gribex_mode(c); return grib_get_gribex_mode(c);
} }
void codes_gribex_mode_off(grib_context* c) void codes_gribex_mode_off(codes_context* c)
{ {
grib_gribex_mode_off(c); grib_gribex_mode_off(c);
} }
@ -577,41 +577,45 @@ void codes_get_reduced_row_p(long pl, double lon_first, double lon_last, long* n
grib_get_reduced_row_p(pl, lon_first, lon_last, npoints, olon_first, olon_last); grib_get_reduced_row_p(pl, lon_first, lon_last, npoints, olon_first, olon_last);
} }
void codes_context_delete(grib_context* c) void codes_context_delete(codes_context* c)
{ {
grib_context_delete(c); grib_context_delete(c);
} }
void codes_context_set_definitions_path(grib_context* c, const char* path) void codes_context_set_definitions_path(codes_context* c, const char* path)
{ {
grib_context_set_definitions_path(c, path); grib_context_set_definitions_path(c, path);
} }
void codes_context_set_samples_path(grib_context* c, const char* path) void codes_context_set_samples_path(codes_context* c, const char* path)
{ {
grib_context_set_samples_path(c, path); grib_context_set_samples_path(c, path);
} }
void codes_context_set_debug(grib_context* c, int mode) void codes_context_set_debug(codes_context* c, int mode)
{ {
grib_context_set_debug(c, mode); grib_context_set_debug(c, mode);
} }
void codes_context_set_data_quality_checks(codes_context* c, int val)
{
grib_context_set_data_quality_checks(c, val);
}
void codes_context_set_memory_proc(grib_context* c, grib_malloc_proc p_malloc, grib_free_proc p_free, grib_realloc_proc p_realloc) void codes_context_set_memory_proc(codes_context* c, grib_malloc_proc p_malloc, grib_free_proc p_free, grib_realloc_proc p_realloc)
{ {
grib_context_set_memory_proc(c, p_malloc, p_free, p_realloc); grib_context_set_memory_proc(c, p_malloc, p_free, p_realloc);
} }
void codes_context_set_persistent_memory_proc(grib_context* c, grib_malloc_proc p_malloc, grib_free_proc p_free) void codes_context_set_persistent_memory_proc(codes_context* c, grib_malloc_proc p_malloc, grib_free_proc p_free)
{ {
grib_context_set_persistent_memory_proc(c, p_malloc, p_free); grib_context_set_persistent_memory_proc(c, p_malloc, p_free);
} }
void codes_context_set_buffer_memory_proc(grib_context* c, grib_malloc_proc p_malloc, grib_free_proc p_free, grib_realloc_proc p_realloc) void codes_context_set_buffer_memory_proc(codes_context* c, grib_malloc_proc p_malloc, grib_free_proc p_free, grib_realloc_proc p_realloc)
{ {
grib_context_set_buffer_memory_proc(c, p_malloc, p_free, p_realloc); grib_context_set_buffer_memory_proc(c, p_malloc, p_free, p_realloc);
} }
void codes_context_set_print_proc(grib_context* c, grib_print_proc p_print) void codes_context_set_print_proc(codes_context* c, grib_print_proc p_print)
{ {
grib_context_set_print_proc(c, p_print); grib_context_set_print_proc(c, p_print);
} }
void codes_context_set_logging_proc(grib_context* c, grib_log_proc p_log) void codes_context_set_logging_proc(codes_context* c, grib_log_proc p_log)
{ {
grib_context_set_logging_proc(c, p_log); grib_context_set_logging_proc(c, p_log);
} }

View File

@ -1174,7 +1174,8 @@ void codes_context_set_definitions_path(codes_context* c, const char* path);
*/ */
void codes_context_set_samples_path(codes_context* c, const char* path); void codes_context_set_samples_path(codes_context* c, const char* path);
void codes_context_set_debug(grib_context* c, int mode); void codes_context_set_debug(codes_context* c, int mode);
void codes_context_set_data_quality_checks(codes_context* c, int val);
/** /**
* Sets memory procedures of the context * Sets memory procedures of the context

View File

@ -1172,6 +1172,7 @@ void grib_context_set_definitions_path(grib_context* c, const char* path);
void grib_context_set_samples_path(grib_context* c, const char* path); void grib_context_set_samples_path(grib_context* c, const char* path);
void grib_context_set_debug(grib_context* c, int mode); void grib_context_set_debug(grib_context* c, int mode);
void grib_context_set_data_quality_checks(grib_context* c, int val);
/** /**
* Sets memory procedures of the context * Sets memory procedures of the context

View File

@ -241,6 +241,17 @@ void grib_context_set_print_proc(grib_context* c, grib_print_proc p)
c->print = (p ? p : &default_print); c->print = (p ? p : &default_print);
} }
void grib_context_set_data_quality_checks(grib_context* c, int val)
{
c = c ? c : grib_context_get_default();
// If val == 0, disable data quality checks
// If val == 1, failure results in an error
// If val == 2, failure results in a warning
Assert(val == 0 || val == 1 || val == 2);
c->grib_data_quality_checks = val;
}
void grib_context_set_debug(grib_context* c, int mode) void grib_context_set_debug(grib_context* c, int mode)
{ {
c = c ? c : grib_context_get_default(); c = c ? c : grib_context_get_default();

View File

@ -84,7 +84,6 @@ void grib_dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
} }
c = c->super ? *(c->super) : NULL; c = c->super ? *(c->super) : NULL;
} }
Assert(0);
} }
void grib_dump_double(grib_dumper* d, grib_accessor* a, const char* comment) void grib_dump_double(grib_dumper* d, grib_accessor* a, const char* comment)
@ -97,7 +96,6 @@ void grib_dump_double(grib_dumper* d, grib_accessor* a, const char* comment)
} }
c = c->super ? *(c->super) : NULL; c = c->super ? *(c->super) : NULL;
} }
Assert(0);
} }
void grib_dump_string(grib_dumper* d, grib_accessor* a, const char* comment) void grib_dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
@ -110,7 +108,6 @@ void grib_dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
} }
c = c->super ? *(c->super) : NULL; c = c->super ? *(c->super) : NULL;
} }
Assert(0);
} }
void grib_dump_string_array(grib_dumper* d, grib_accessor* a, const char* comment) void grib_dump_string_array(grib_dumper* d, grib_accessor* a, const char* comment)
@ -123,7 +120,6 @@ void grib_dump_string_array(grib_dumper* d, grib_accessor* a, const char* commen
} }
c = c->super ? *(c->super) : NULL; c = c->super ? *(c->super) : NULL;
} }
Assert(0);
} }
void grib_dump_label(grib_dumper* d, grib_accessor* a, const char* comment) void grib_dump_label(grib_dumper* d, grib_accessor* a, const char* comment)
@ -136,7 +132,6 @@ void grib_dump_label(grib_dumper* d, grib_accessor* a, const char* comment)
} }
c = c->super ? *(c->super) : NULL; c = c->super ? *(c->super) : NULL;
} }
Assert(0);
} }
void grib_dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment) void grib_dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment)
@ -149,7 +144,6 @@ void grib_dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment)
} }
c = c->super ? *(c->super) : NULL; c = c->super ? *(c->super) : NULL;
} }
Assert(0);
} }
void grib_dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) void grib_dump_bits(grib_dumper* d, grib_accessor* a, const char* comment)
@ -162,7 +156,6 @@ void grib_dump_bits(grib_dumper* d, grib_accessor* a, const char* comment)
} }
c = c->super ? *(c->super) : NULL; c = c->super ? *(c->super) : NULL;
} }
Assert(0);
} }
void grib_dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accessors* block) void grib_dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accessors* block)
@ -175,7 +168,6 @@ void grib_dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accessors
} }
c = c->super ? *(c->super) : NULL; c = c->super ? *(c->super) : NULL;
} }
Assert(0);
} }
void grib_dump_values(grib_dumper* d, grib_accessor* a) void grib_dump_values(grib_dumper* d, grib_accessor* a)
@ -188,7 +180,6 @@ void grib_dump_values(grib_dumper* d, grib_accessor* a)
} }
c = c->super ? *(c->super) : NULL; c = c->super ? *(c->super) : NULL;
} }
Assert(0);
} }
void grib_dump_header(grib_dumper* d, const grib_handle* ch) void grib_dump_header(grib_dumper* d, const grib_handle* ch)

View File

@ -16,7 +16,7 @@
START_CLASS_DEF START_CLASS_DEF
CLASS = dumper CLASS = dumper
IMPLEMENTS = dump_long;dump_bits IMPLEMENTS = dump_long;dump_bits
IMPLEMENTS = dump_double;dump_string IMPLEMENTS = dump_double;dump_string;dump_string_array
IMPLEMENTS = dump_bytes;dump_values IMPLEMENTS = dump_bytes;dump_values
IMPLEMENTS = dump_label;dump_section IMPLEMENTS = dump_label;dump_section
IMPLEMENTS = init;destroy IMPLEMENTS = init;destroy
@ -45,6 +45,7 @@ static void dump_long (grib_dumper* d, grib_accessor* a,const char* commen
static void dump_bits (grib_dumper* d, grib_accessor* a,const char* comment); static void dump_bits (grib_dumper* d, grib_accessor* a,const char* comment);
static void dump_double (grib_dumper* d, grib_accessor* a,const char* comment); static void dump_double (grib_dumper* d, grib_accessor* a,const char* comment);
static void dump_string (grib_dumper* d, grib_accessor* a,const char* comment); static void dump_string (grib_dumper* d, grib_accessor* a,const char* comment);
static void dump_string_array (grib_dumper* d, grib_accessor* a,const char* comment);
static void dump_bytes (grib_dumper* d, grib_accessor* a,const char* comment); static void dump_bytes (grib_dumper* d, grib_accessor* a,const char* comment);
static void dump_values (grib_dumper* d, grib_accessor* a); static void dump_values (grib_dumper* d, grib_accessor* a);
static void dump_label (grib_dumper* d, grib_accessor* a,const char* comment); static void dump_label (grib_dumper* d, grib_accessor* a,const char* comment);
@ -70,7 +71,7 @@ static grib_dumper_class _grib_dumper_class_debug = {
&dump_long, /* dump long */ &dump_long, /* dump long */
&dump_double, /* dump double */ &dump_double, /* dump double */
&dump_string, /* dump string */ &dump_string, /* dump string */
0, /* dump string array */ &dump_string_array, /* dump string array */
&dump_label, /* dump labels */ &dump_label, /* dump labels */
&dump_bytes, /* dump bytes */ &dump_bytes, /* dump bytes */
&dump_bits, /* dump bits */ &dump_bits, /* dump bits */
@ -381,6 +382,76 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
grib_context_free(a->context_, value); grib_context_free(a->context_, value);
} }
static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_debug* self = (grib_dumper_debug*)d;
char** values;
size_t size = 0, i = 0;
grib_context* c = NULL;
int err = 0;
int tab = 0;
long count = 0;
if ((a->flags_ & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return;
c = a->context_;
a->value_count(&count);
if (count == 0)
return;
size = count;
if (size == 1) {
dump_string(d, a, comment);
return;
}
values = (char**)grib_context_malloc_clear(c, size * sizeof(char*));
if (!values) {
grib_context_log(c, GRIB_LOG_ERROR, "unable to allocate %zu bytes", size);
return;
}
err = a->unpack_string_array(values, &size);
// print_offset(self->dumper.out,d,a);
//print_offset(self->dumper.out, self->begin, self->theEnd);
if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) {
fprintf(self->dumper.out, " ");
fprintf(self->dumper.out, "# type %s (str) \n", a->creator_->op);
}
aliases(d, a);
if (comment) {
fprintf(self->dumper.out, " ");
fprintf(self->dumper.out, "# %s \n", comment);
}
if (a->flags_ & GRIB_ACCESSOR_FLAG_READ_ONLY) {
fprintf(self->dumper.out, " ");
fprintf(self->dumper.out, "#-READ ONLY- ");
tab = 13;
}
else
fprintf(self->dumper.out, " ");
tab++;
fprintf(self->dumper.out, "%s = {\n", a->name_);
for (i = 0; i < size; i++) {
fprintf(self->dumper.out, "%-*s\"%s\",\n", (int)(tab + strlen(a->name_) + 4), " ", values[i]);
}
fprintf(self->dumper.out, " }");
if (err) {
fprintf(self->dumper.out, " ");
fprintf(self->dumper.out, "# *** ERR=%d (%s)", err, grib_get_error_message(err));
}
fprintf(self->dumper.out, "\n");
for (i=0; i<size; ++i) grib_context_free(c, values[i]);
grib_context_free(c, values);
}
static void dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment) static void dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment)
{ {
grib_dumper_debug* self = (grib_dumper_debug*)d; grib_dumper_debug* self = (grib_dumper_debug*)d;

View File

@ -108,7 +108,7 @@ int transform_iterator_data(grib_context* context, double* data,
{ {
double* data2; double* data2;
double *pData0, *pData1, *pData2; double *pData0, *pData1, *pData2;
unsigned long ix, iy; long ix, iy;
if (!iScansNegatively && jScansPositively && !jPointsAreConsecutive && !alternativeRowScanning) { if (!iScansNegatively && jScansPositively && !jPointsAreConsecutive && !alternativeRowScanning) {
/* Already +i and +j. No need to change */ /* Already +i and +j. No need to change */

View File

@ -211,7 +211,7 @@ static std::vector<double> HEALPix_longitudes(size_t N, size_t i)
return longitudes; return longitudes;
} }
static int iterate_healpix(grib_iterator_healpix* self, long N) static int iterate_healpix(grib_iterator_healpix* self, long N, bool nested)
{ {
size_t Ny = 4 * static_cast<size_t>(N) - 1; size_t Ny = 4 * static_cast<size_t>(N) - 1;
auto Nd = static_cast<double>(N); auto Nd = static_cast<double>(N);
@ -241,7 +241,7 @@ static int iterate_healpix(grib_iterator_healpix* self, long N)
// Equator // Equator
latitudes[2 * N - 1] = 0.0; latitudes[2 * N - 1] = 0.0;
if (self->nested) { if (nested) {
if (!is_power_of_2(N)) { if (!is_power_of_2(N)) {
grib_context* c = grib_context_get_default(); grib_context* c = grib_context_get_default();
grib_context_log(c, GRIB_LOG_ERROR, "%s: For nested ordering, Nside must be a power of 2", ITER); grib_context_log(c, GRIB_LOG_ERROR, "%s: For nested ordering, Nside must be a power of 2", ITER);
@ -389,7 +389,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
} }
try { try {
err = iterate_healpix(self, N); err = iterate_healpix(self, N, self->nested);
} }
catch (...) { catch (...) {
return GRIB_INTERNAL_ERROR; return GRIB_INTERNAL_ERROR;

View File

@ -10,6 +10,7 @@
#include "grib_scaling.h" #include "grib_scaling.h"
#include "grib_api_internal.h" #include "grib_api_internal.h"
#include <math.h>
// Unfortunately, metkit uses grib_power() (illegal usage of private API) // Unfortunately, metkit uses grib_power() (illegal usage of private API)
// As soon as it is fixed, the wrapper below can be deleted // As soon as it is fixed, the wrapper below can be deleted
@ -26,6 +27,12 @@ long grib_get_binary_scale_fact(double max, double min, long bpval, int* error)
unsigned long maxint = 0; unsigned long maxint = 0;
const size_t ulong_size = sizeof(maxint) * 8; const size_t ulong_size = sizeof(maxint) * 8;
// See ECC-1927
if ((isnan(range) || isinf(range))) {
*error = GRIB_OUT_OF_RANGE; /*overflow*/
return 0;
}
/* See ECC-246 /* See ECC-246
unsigned long maxint = codes_power<double>(bpval,2) - 1; unsigned long maxint = codes_power<double>(bpval,2) - 1;
double dmaxint=(double)maxint; double dmaxint=(double)maxint;

View File

@ -875,6 +875,20 @@ static int write_out_error_data_file(const double* data_values, size_t data_valu
return GRIB_SUCCESS; return GRIB_SUCCESS;
} }
static long get_bitsPerValue_for_packingType(const int specPackingType, const long specBitsPerValue)
{
if (specPackingType == GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE) {
if (specBitsPerValue > 60) return 60;
}
else if (specPackingType == GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER) {
if (specBitsPerValue > 60) return 32;
}
else if (specPackingType == GRIB_UTIL_PACKING_TYPE_CCSDS) {
if (specBitsPerValue > 32) return 32;
}
return specBitsPerValue; //original
}
static int get_grib_sample_name(grib_handle* h, long editionNumber, static int get_grib_sample_name(grib_handle* h, long editionNumber,
const grib_util_grid_spec* spec, const char* grid_type, char* sample_name) const grib_util_grid_spec* spec, const char* grid_type, char* sample_name)
{ {
@ -1341,17 +1355,26 @@ grib_handle* grib_util_set_spec(grib_handle* h,
Assert(grib_get_long(h, "bitsPerValue", &bitsPerValue) == 0); Assert(grib_get_long(h, "bitsPerValue", &bitsPerValue) == 0);
SET_LONG_VALUE("bitsPerValue", bitsPerValue); SET_LONG_VALUE("bitsPerValue", bitsPerValue);
} }
} break; }
break;
case GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES: case GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES: {
SET_LONG_VALUE("bitsPerValue", packing_spec->bitsPerValue); // See ECC-1921
const long bitsPerValue = get_bitsPerValue_for_packingType(packing_spec->packing_type, packing_spec->bitsPerValue);
if (bitsPerValue != packing_spec->bitsPerValue) {
fprintf(stderr, "ECCODES WARNING : Cannot pack with requested bitsPerValue (%ld). Using %ld\n",
packing_spec->bitsPerValue, bitsPerValue);
}
SET_LONG_VALUE("bitsPerValue", bitsPerValue);
}
break; break;
case GRIB_UTIL_ACCURACY_SAME_DECIMAL_SCALE_FACTOR_AS_INPUT: { case GRIB_UTIL_ACCURACY_SAME_DECIMAL_SCALE_FACTOR_AS_INPUT: {
long decimalScaleFactor = 0; long decimalScaleFactor = 0;
Assert(grib_get_long(h, "decimalScaleFactor", &decimalScaleFactor) == 0); Assert(grib_get_long(h, "decimalScaleFactor", &decimalScaleFactor) == 0);
SET_LONG_VALUE("decimalScaleFactor", decimalScaleFactor); SET_LONG_VALUE("decimalScaleFactor", decimalScaleFactor);
} break; }
break;
case GRIB_UTIL_ACCURACY_USE_PROVIDED_DECIMAL_SCALE_FACTOR: case GRIB_UTIL_ACCURACY_USE_PROVIDED_DECIMAL_SCALE_FACTOR:
SET_LONG_VALUE("decimalScaleFactor", packing_spec->decimalScaleFactor); SET_LONG_VALUE("decimalScaleFactor", packing_spec->decimalScaleFactor);

File diff suppressed because it is too large Load Diff

View File

@ -704,12 +704,16 @@ trigger_block: TRIGGER '(' argument_list ')' '{' instructions '}' { $$ = grib_ac
concept_block: CONCEPT IDENT '{' concept_list '}' flags { $$ = grib_action_create_concept(grib_parser_context,$2,$4,0,0,0,0,0,0,$6,0); free($2); } concept_block: CONCEPT IDENT '{' concept_list '}' flags { $$ = grib_action_create_concept(grib_parser_context,$2,$4,0,0,0,0,0,0,$6,0); free($2); }
| CONCEPT IDENT '(' IDENT ')' '{' concept_list '}' flags { $$ = grib_action_create_concept(grib_parser_context,$2,$7,0,0,$4,0,0,0,$9,0); free($2);free($4); } | CONCEPT IDENT '(' IDENT ')' '{' concept_list '}' flags { $$ = grib_action_create_concept(grib_parser_context,$2,$7,0,0,$4,0,0,0,$9,0); free($2);free($4); }
| CONCEPT IDENT '(' IDENT ',' STRING ',' IDENT ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$2,0,$6,0,$4,$8,$10,0,$12,0); free($2);free($6);free($4);free($8);free($10); } | CONCEPT IDENT '(' IDENT ',' STRING ',' IDENT ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$2,0,$6,0,$4,$8,$10,0,$12,0); free($2);free($6);free($4);free($8);free($10); }
| CONCEPT IDENT '(' IDENT ',' IDENT ',' IDENT ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$2,0,$6,0,$4,$8,$10,0,$12,0); free($2);free($6);free($4);free($8);free($10); }
| CONCEPT IDENT '(' IDENT ',' STRING ',' IDENT ',' IDENT ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$2,0,$6,0,$4,$8,$10,$12,$14,0); free($2);free($6);free($4);free($8);free($10);free($12); } | CONCEPT IDENT '(' IDENT ',' STRING ',' IDENT ',' IDENT ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$2,0,$6,0,$4,$8,$10,$12,$14,0); free($2);free($6);free($4);free($8);free($10);free($12); }
| CONCEPT IDENT '(' IDENT ',' STRING ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$2,0,$6,0,$4,$8,0,0,$10,0); free($2);free($6);free($4);free($8); } | CONCEPT IDENT '(' IDENT ',' STRING ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$2,0,$6,0,$4,$8,0,0,$10,0); free($2);free($6);free($4);free($8); }
| CONCEPT IDENT '.' IDENT '(' IDENT ',' STRING ',' IDENT ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$4,0,$8,$2,$6,$10,$12,0,$14,0); free($4);free($8);free($6);free($10); free($12); free($2);} | CONCEPT IDENT '.' IDENT '(' IDENT ',' STRING ',' IDENT ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$4,0,$8,$2,$6,$10,$12,0,$14,0); free($4);free($8);free($6);free($10); free($12); free($2);}
| CONCEPT IDENT '.' IDENT '(' IDENT ',' IDENT ',' IDENT ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$4,0,$8,$2,$6,$10,$12,0,$14,0); free($4);free($8);free($6);free($10); free($12); free($2);}
| CONCEPT IDENT '.' IDENT '(' IDENT ',' STRING ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$4,0,$8,$2,$6,$10,0,0,$12,0); free($4);free($8);free($6);free($10); free($2);} | CONCEPT IDENT '.' IDENT '(' IDENT ',' STRING ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$4,0,$8,$2,$6,$10,0,0,$12,0); free($4);free($8);free($6);free($10); free($2);}
| CONCEPT IDENT '.' IDENT '{' concept_list '}' flags { $$ = grib_action_create_concept(grib_parser_context,$4,$6,0,$2,0,0,0,0,$8,0); free($2);free($4); } | CONCEPT IDENT '.' IDENT '{' concept_list '}' flags { $$ = grib_action_create_concept(grib_parser_context,$4,$6,0,$2,0,0,0,0,$8,0); free($2);free($4); }
| CONCEPT IDENT '.' IDENT '(' IDENT ')' '{' concept_list '}' flags { $$ = grib_action_create_concept(grib_parser_context,$4,$9,0,$2,$6,0,0,0,$11,0); free($2);free($4);free($6); } | CONCEPT IDENT '.' IDENT '(' IDENT ')' '{' concept_list '}' flags { $$ = grib_action_create_concept(grib_parser_context,$4,$9,0,$2,$6,0,0,0,$11,0); free($2);free($4);free($6); }
| CONCEPT_NOFAIL IDENT '{' concept_list '}' flags { $$ = grib_action_create_concept(grib_parser_context,$2,$4,0,0,0,0,0,0,$6,1); free($2); } | CONCEPT_NOFAIL IDENT '{' concept_list '}' flags { $$ = grib_action_create_concept(grib_parser_context,$2,$4,0,0,0,0,0,0,$6,1); free($2); }
| CONCEPT_NOFAIL IDENT '(' IDENT ')' '{' concept_list '}' flags { $$ = grib_action_create_concept(grib_parser_context,$2,$7,0,0,$4,0,0,0,$9,1); free($2);free($4); } | CONCEPT_NOFAIL IDENT '(' IDENT ')' '{' concept_list '}' flags { $$ = grib_action_create_concept(grib_parser_context,$2,$7,0,0,$4,0,0,0,$9,1); free($2);free($4); }
| CONCEPT_NOFAIL IDENT '(' IDENT ',' STRING ',' IDENT ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$2,0,$6,0,$4,$8,$10,0,$12,1); free($2);free($6);free($4);free($8);free($10); } | CONCEPT_NOFAIL IDENT '(' IDENT ',' STRING ',' IDENT ',' IDENT ')' flags { $$ = grib_action_create_concept(grib_parser_context,$2,0,$6,0,$4,$8,$10,0,$12,1); free($2);free($6);free($4);free($8);free($10); }

View File

@ -144,7 +144,6 @@ if( HAVE_BUILD_TOOLS )
grib_ecc-1708 grib_ecc-1708
grib_ecc-1691 grib_ecc-1691
grib_ecc-1766 grib_ecc-1766
grib_ecc-1806
grib_ecc-1829 grib_ecc-1829
bufr_ecc-1028 bufr_ecc-1028
bufr_ecc-1195 bufr_ecc-1195
@ -276,6 +275,7 @@ if( HAVE_BUILD_TOOLS )
grib_ecc-1467 grib_ecc-1467
grib_ecc-1764 grib_ecc-1764
grib_ecc-1792 grib_ecc-1792
grib_ecc-1806
grib_ecc-1907 grib_ecc-1907
grib_modelName grib_modelName
grib_sub_hourly grib_sub_hourly

View File

@ -106,5 +106,11 @@ grep -q "unsigned iDirectionIncrement = 2000000 (can be missing)" $temp
grep -q "constant zero = 0 (read-only)" $temp grep -q "constant zero = 0 (read-only)" $temp
grep -q "unsigned reserved = MISSING (can be missing) (read-only)" $temp grep -q "unsigned reserved = MISSING (can be missing) (read-only)" $temp
# Debug dump a BUFR using -TB switch
infile=${data_dir}/bufr/pgps_110.bufr
${tools_dir}/grib_dump -Da -TB $infile > $temp
# ${tools_dir}/grib_dump -Da -TB -s unpack=1 $infile > $temp
# Clean up # Clean up
rm -f $temp rm -f $temp

View File

@ -75,6 +75,33 @@ input=${data_dir}/gfs.complex.mvmu.grib2
stats=`${tools_dir}/grib_get -F%.2f -p max,min,avg $input` stats=`${tools_dir}/grib_get -F%.2f -p max,min,avg $input`
[ "$stats" = "2.81 0.00 0.30" ] [ "$stats" = "2.81 0.00 0.30" ]
# ECC-1926
# grid_complex_spatial_differencing with bpv=0
# Create a data section similar to the attached file dswrf-1.grib2
cat >$tempFilt<<EOF
set packingType='grid_complex_spatial_differencing';
set numberOfGroupsOfDataValues=0;
set orderOfSpatialDifferencing=2;
set primaryMissingValueSubstitute=0;
set referenceForGroupWidths = 64;
set numberOfBitsUsedForTheGroupWidths = 4;
set referenceForGroupLengths = 203736800;
set trueLengthOfLastGroup = 8;
set numberOfBitsForScaledGroupLengths = 7;
set numberOfOctetsExtraDescriptors = 1;
write;
EOF
input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
${tools_dir}/grib_filter -o $temp1 $tempFilt $input
grib_check_key_equals $temp1 packingType,isConstant 'grid_complex_spatial_differencing 1'
stats1=`${tools_dir}/grib_get -M -F%.0f -n statistics $input`
stats2=`${tools_dir}/grib_get -M -F%.0f -n statistics $temp1`
[ "$stats1" = "$stats2" ]
${tools_dir}/grib_set -rs packingType=grid_simple $temp1 $temp2
grib_check_key_equals $temp2 packingType,isConstant 'grid_simple 1'
${tools_dir}/grib_compare -b totalLength,section5Length,dataRepresentationTemplateNumber $temp2 $temp1
# Decode as string - Null op # Decode as string - Null op
cat >$tempFilt<<EOF cat >$tempFilt<<EOF
print "[computeStatistics:s]"; print "[computeStatistics:s]";

View File

@ -422,6 +422,16 @@ static void test_gts_header_mode()
Assert(c->gts_header_on == 0); Assert(c->gts_header_on == 0);
} }
static void test_data_quality_checks()
{
grib_context* c = grib_context_get_default();
printf("Running %s ...\n", __func__);
grib_context_set_data_quality_checks(c, 1);//warning
grib_context_set_data_quality_checks(c, 2);//error
grib_context_set_data_quality_checks(c, 0);//no checks
}
static void test_bufr_multi_element_constant_arrays() static void test_bufr_multi_element_constant_arrays()
{ {
grib_context* c = grib_context_get_default(); grib_context* c = grib_context_get_default();
@ -859,6 +869,7 @@ int main(int argc, char** argv)
test_gribex_mode(); test_gribex_mode();
test_gts_header_mode(); test_gts_header_mode();
test_bufr_multi_element_constant_arrays(); test_bufr_multi_element_constant_arrays();
test_data_quality_checks();
test_concept_condition_strings(); test_concept_condition_strings();

View File

@ -27,7 +27,7 @@ ecbuild_add_library( TARGET ecc_tools
# tools binaries # tools binaries
list( APPEND ecc_tools_binaries list( APPEND ecc_tools_binaries
codes_info codes_count codes_split_file codes_info codes_count codes_split_file codes_export_resource
grib_histogram grib_filter grib_ls grib_dump grib_histogram grib_filter grib_ls grib_dump
grib2ppm grib_set grib_get grib_get_data grib_copy grib2ppm grib_set grib_get grib_get_data grib_copy
grib_compare codes_parser grib_index_build bufr_index_build grib_compare codes_parser grib_index_build bufr_index_build
@ -39,7 +39,6 @@ list( APPEND ecc_tools_binaries
list( APPEND ecc_tools_binaries_extra list( APPEND ecc_tools_binaries_extra
grib_repair grib_repair
grib_to_json grib_to_json
codes_export_resource
grib_check_gaussian_grid grib_check_gaussian_grid
bufr_split_by_rdbSubtype ) bufr_split_by_rdbSubtype )