diff --git a/.gitignore b/.gitignore index 8a3639ff7..07b6b263b 100644 --- a/.gitignore +++ b/.gitignore @@ -69,6 +69,7 @@ data/bufr/*test *.sublime-workspace .idea +.vscode build/ *.back diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json deleted file mode 100644 index 256560fbd..000000000 --- a/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "configurations": [ - { - "name": "Linux", - "includePath": [ - "/usr/include", - "/usr/include/linux", - "/usr/local/apps/gcc/7.3.0/lib64/gcc/x86_64-suse-linux/7.3.0/include", - "${workspaceRoot}" - ], - "defines": [], - "compilerPath": "/usr/local/apps/gcc/7.3.0/bin/gcc", - "cStandard": "c89", - "cppStandard": "c++17", - "intelliSenseMode": "clang-x64" - } - ], - "version": 4 -} diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e1d52963..232d2dbb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,7 @@ check_symbol_exists( fseeko "stdio.h" ECCODES_HAVE_FSEEKO ) check_symbol_exists( posix_memalign "stdlib.h" ECCODES_HAVE_POSIX_MEMALIGN ) check_symbol_exists( fmemopen "stdio.h" ECCODES_HAVE_FMEMOPEN ) check_symbol_exists( funopen "stdio.h" ECCODES_HAVE_FUNOPEN ) +check_symbol_exists( realpath "stdlib.h" ECCODES_HAVE_REALPATH ) check_c_source_compiles( " typedef int foo_t; @@ -81,6 +82,10 @@ ecbuild_add_option( FEATURE EXAMPLES DESCRIPTION "Build the examples" DEFAULT ON ) +ecbuild_add_option( FEATURE BUILD_TOOLS + DESCRIPTION "Build the command line tools" + DEFAULT ON ) + ecbuild_add_option( FEATURE JPG DESCRIPTION "Support for JPG decoding/encoding" DEFAULT ON ) @@ -319,10 +324,9 @@ endif() ############################################################################### # contents - -if( NOT ${DEVELOPER_MODE} ) - set( the_default_data_prefix ${CMAKE_INSTALL_PREFIX} ) -else() +set( the_default_data_prefix ${CMAKE_INSTALL_PREFIX} ) +if( ${DEVELOPER_MODE} ) + ecbuild_info("DEVELOPER_MODE is defined") set( the_default_data_prefix ${CMAKE_BINARY_DIR} ) endif() @@ -353,6 +357,11 @@ if( CMAKE_COMPILER_IS_GNUCC ) ecbuild_add_c_flags("-pedantic") endif() +# gfortran 10 has become stricter with argument matching +if( HAVE_FORTRAN AND CMAKE_Fortran_COMPILER_ID MATCHES "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 10 ) + ecbuild_add_fortran_flags("-fallow-argument-mismatch") +endif() + ############################################################################### # contents @@ -394,7 +403,10 @@ include_directories( ${ECCODES_INCLUDE_DIRS} ${ECCODES_EXTRA_INCLUDE_DIRS} ) add_subdirectory( definitions ) # must be before memfs add_subdirectory( memfs ) add_subdirectory( src ) -add_subdirectory( tools ) +if( HAVE_BUILD_TOOLS ) + add_subdirectory( tools ) + add_subdirectory( tigge ) +endif() add_subdirectory( fortran ) if( PYTHON_VERSION_MAJOR GREATER 2 ) @@ -407,7 +419,6 @@ else() set( ECCODES_PYTHON_DIR "python" ) endif() add_subdirectory( tests ) -add_subdirectory( tigge ) add_subdirectory( examples ) add_subdirectory( data ) add_subdirectory( samples ) diff --git a/INSTALL b/INSTALL index 8250fdc10..e74cf260d 100644 --- a/INSTALL +++ b/INSTALL @@ -19,7 +19,7 @@ However it requires that cmake be installed on your system. 2. Unpack distribution: > tar -xzf eccodes-x.y.z-Source.tar.gz -3. Create a separate directory where to build ecCodes: +3. Create a separate directory to build ecCodes: > mkdir build > cd build @@ -56,6 +56,8 @@ However if you wish to exercise more of the functionality of ecCodes, you are ad In this mode the tests will take longer and you need to be connected to the internet so data files can be downloaded for the tests. +Also note that if you have several CPUs, you can invoke the "make" and "ctest" commands above in parallel +(e.g. "make -j4", "ctest -j4"). This will speed up the whole build/test process significantly. + For more details, please see: https://confluence.ecmwf.int/display/ECC/ecCodes+installation - diff --git a/README.md b/README.md index c6711cf96..4cbecdfb9 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ INSTALLATION tar -xzf eccodes-x.y.z-Source.tar.gz ``` -3. Create a separate directory where to build ecCodes: +3. Create a separate directory to build ecCodes: ``` mkdir build cd build diff --git a/definitions/grib1/section.2.def b/definitions/grib1/section.2.def index 1256f1fdd..b1f2b98e2 100644 --- a/definitions/grib1/section.2.def +++ b/definitions/grib1/section.2.def @@ -8,7 +8,7 @@ meta section2Pointer section_pointer(offsetSection2,section2Length,2); transient radius=6367470; alias radiusOfTheEarth=radius; alias radiusInMetres=radius; -transient shapeOfTheEarth=6 : hidden; +transient shapeOfTheEarth=0: hidden; #ECC-811 # NV -- number of vertical coordinate parameters diff --git a/definitions/grib2/localConcepts/ecmf/cfName.def b/definitions/grib2/localConcepts/ecmf/cfName.def index 1b4449d4a..fa9fd3b97 100644 --- a/definitions/grib2/localConcepts/ecmf/cfName.def +++ b/definitions/grib2/localConcepts/ecmf/cfName.def @@ -13,10 +13,10 @@ } #Snow depth 'lwe_thickness_of_surface_snow_amount' = { + localTablesVersion = 1 ; discipline = 0 ; - parameterNumber = 11 ; parameterCategory = 1 ; - unitsFactor = 1000 ; + parameterNumber = 254 ; } #Convective precipitation 'lwe_thickness_of_convective_precipitation_amount' = { diff --git a/definitions/grib2/localConcepts/ecmf/cfVarName.def b/definitions/grib2/localConcepts/ecmf/cfVarName.def index 5e7319ba0..354e12452 100644 --- a/definitions/grib2/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib2/localConcepts/ecmf/cfVarName.def @@ -697,10 +697,10 @@ } #Snow depth 'sd' = { + localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 1 ; - parameterNumber = 11 ; - unitsFactor = 1000 ; + parameterNumber = 254 ; } #Large-scale precipitation 'lsp' = { diff --git a/definitions/grib2/localConcepts/ecmf/name.def b/definitions/grib2/localConcepts/ecmf/name.def index 9d32b62a1..029336bed 100644 --- a/definitions/grib2/localConcepts/ecmf/name.def +++ b/definitions/grib2/localConcepts/ecmf/name.def @@ -697,10 +697,10 @@ } #Snow depth 'Snow depth' = { + localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 1 ; - parameterNumber = 11 ; - unitsFactor = 1000 ; + parameterNumber = 254 ; } #Large-scale precipitation 'Large-scale precipitation' = { diff --git a/definitions/grib2/localConcepts/ecmf/paramId.def b/definitions/grib2/localConcepts/ecmf/paramId.def index 41f6cde73..8a5eb616f 100644 --- a/definitions/grib2/localConcepts/ecmf/paramId.def +++ b/definitions/grib2/localConcepts/ecmf/paramId.def @@ -697,10 +697,10 @@ } #Snow depth '141' = { + localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 1 ; - parameterNumber = 11 ; - unitsFactor = 1000 ; + parameterNumber = 254 ; } #Large-scale precipitation '142' = { diff --git a/definitions/grib2/localConcepts/ecmf/shortName.def b/definitions/grib2/localConcepts/ecmf/shortName.def index 2bcedea79..0910d7256 100644 --- a/definitions/grib2/localConcepts/ecmf/shortName.def +++ b/definitions/grib2/localConcepts/ecmf/shortName.def @@ -697,10 +697,10 @@ } #Snow depth 'sd' = { + localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 1 ; - parameterNumber = 11 ; - unitsFactor = 1000 ; + parameterNumber = 254 ; } #Large-scale precipitation 'lsp' = { diff --git a/definitions/grib2/localConcepts/ecmf/units.def b/definitions/grib2/localConcepts/ecmf/units.def index 50d064ad2..cc0b7e011 100644 --- a/definitions/grib2/localConcepts/ecmf/units.def +++ b/definitions/grib2/localConcepts/ecmf/units.def @@ -697,10 +697,10 @@ } #Snow depth 'm of water equivalent' = { + localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 1 ; - parameterNumber = 11 ; - unitsFactor = 1000 ; + parameterNumber = 254 ; } #Large-scale precipitation 'm' = { diff --git a/definitions/grib2/localConcepts/ecmf/unstructuredGrid.def b/definitions/grib2/localConcepts/ecmf/unstructuredGrid.def new file mode 100644 index 000000000..5a0125f4c --- /dev/null +++ b/definitions/grib2/localConcepts/ecmf/unstructuredGrid.def @@ -0,0 +1,7 @@ +# ECMWF Unstructured Grid Mapping + +concept_nofail unstructuredGridType(unknown,"unstructuredGridType.def",conceptsLocalDirAll,conceptsMasterDir); + +concept_nofail unstructuredGridSubtype(unknown,"unstructuredGridSubtype.def",conceptsLocalDirAll,conceptsMasterDir); + +concept_nofail unstructuredGridUUID(unknown,"unstructuredGridUUID.def",conceptsLocalDirAll,conceptsMasterDir); diff --git a/definitions/grib2/localConcepts/ecmf/unstructuredGridSubtype.def b/definitions/grib2/localConcepts/ecmf/unstructuredGridSubtype.def new file mode 100644 index 000000000..1a8429f26 --- /dev/null +++ b/definitions/grib2/localConcepts/ecmf/unstructuredGridSubtype.def @@ -0,0 +1,6 @@ +'undefined' = { numberOfGridInReference = 0; } +'T grid' = { numberOfGridInReference = 1; } +'U grid' = { numberOfGridInReference = 2; } +'V grid' = { numberOfGridInReference = 3; } +'W grid' = { numberOfGridInReference = 4; } +'F grid' = { numberOfGridInReference = 5; } diff --git a/definitions/grib2/localConcepts/ecmf/unstructuredGridType.def b/definitions/grib2/localConcepts/ecmf/unstructuredGridType.def new file mode 100644 index 000000000..33dcb3cac --- /dev/null +++ b/definitions/grib2/localConcepts/ecmf/unstructuredGridType.def @@ -0,0 +1,8 @@ +'undefined' = { numberOfGridUsed = 0; } +'ORCA2' = { numberOfGridUsed = 1; } +'ORCA1' = { numberOfGridUsed = 2; } +'ORCA025' = { numberOfGridUsed = 3; } +'ORCA12' = { numberOfGridUsed = 4; } +'eORCA1' = { numberOfGridUsed = 5; } +'eORCA025' = { numberOfGridUsed = 6; } +'eORCA12' = { numberOfGridUsed = 7; } diff --git a/definitions/grib2/template.3.101.def b/definitions/grib2/template.3.101.def index 692e48bae..6c37f39de 100644 --- a/definitions/grib2/template.3.101.def +++ b/definitions/grib2/template.3.101.def @@ -10,3 +10,5 @@ unsigned[1] numberOfGridInReference : dump; # UUID of horizontal grid byte[16] uuidOfHGrid : dump; + +template_nofail unstructuredGrid "grib2/localConcepts/[centre:s]/unstructuredGrid.def"; diff --git a/definitions/grib2/template.4.horizontal.def b/definitions/grib2/template.4.horizontal.def index 348e4eb89..d3739c0b1 100755 --- a/definitions/grib2/template.4.horizontal.def +++ b/definitions/grib2/template.4.horizontal.def @@ -24,61 +24,7 @@ unsigned[4] scaledValueOfSecondFixedSurface = missing() : can_be_missing,dump,no transient pressureUnits="hPa"; -concept_nofail vertical.typeOfLevel (unknown) { -#set uses the last one -#get returns the first match - 'surface' = { typeOfFirstFixedSurface=1; typeOfSecondFixedSurface=255; } - 'cloudBase' = { typeOfFirstFixedSurface=2; typeOfSecondFixedSurface=255; } - 'cloudTop' = { typeOfFirstFixedSurface=3; typeOfSecondFixedSurface=255; } - 'isothermZero' = { typeOfFirstFixedSurface=4; typeOfSecondFixedSurface=255; } - 'adiabaticCondensation' = {typeOfFirstFixedSurface=5; typeOfSecondFixedSurface=255; } - 'maxWind' = {typeOfFirstFixedSurface=6; typeOfSecondFixedSurface=255;} - 'tropopause' = {typeOfFirstFixedSurface=7; typeOfSecondFixedSurface=255;} - 'nominalTop' = {typeOfFirstFixedSurface=8; typeOfSecondFixedSurface=255; } - 'seaBottom' = {typeOfFirstFixedSurface=9; typeOfSecondFixedSurface=255;} - - # Note: We already had 'entireAtmosphere' mapped before adding this one so had to choose another name - 'atmosphere' = {typeOfFirstFixedSurface=10; typeOfSecondFixedSurface=255;} - - 'isothermal' = {typeOfFirstFixedSurface=20; typeOfSecondFixedSurface=255;} - 'isobaricInPa' = {typeOfFirstFixedSurface=100; typeOfSecondFixedSurface=255; pressureUnits='Pa'; } - 'isobaricInhPa' = {typeOfFirstFixedSurface=100; pressureUnits='hPa'; typeOfSecondFixedSurface=255;} - 'isobaricLayer' = {typeOfFirstFixedSurface=100; typeOfSecondFixedSurface=100;} - 'meanSea' = { typeOfFirstFixedSurface=101; typeOfSecondFixedSurface=255; } - 'heightAboveSea' = {typeOfFirstFixedSurface=102; typeOfSecondFixedSurface=255;} - 'heightAboveSeaLayer' = {typeOfFirstFixedSurface=102; typeOfSecondFixedSurface=102;} - 'heightAboveGround' = {typeOfFirstFixedSurface=103; typeOfSecondFixedSurface=255;} - 'heightAboveGroundLayer' = {typeOfFirstFixedSurface=103;typeOfSecondFixedSurface=103;} - 'sigma' = {typeOfFirstFixedSurface=104; typeOfSecondFixedSurface=255;} - 'sigmaLayer' = {typeOfFirstFixedSurface=104; typeOfSecondFixedSurface=104;} - 'hybrid' = {typeOfFirstFixedSurface=105; typeOfSecondFixedSurface=255;} - 'hybridHeight' = {typeOfFirstFixedSurface=118; typeOfSecondFixedSurface=255;} - 'hybridLayer' = {typeOfFirstFixedSurface=105; typeOfSecondFixedSurface=105; } - 'depthBelowLand' = {typeOfFirstFixedSurface=106; typeOfSecondFixedSurface=255;} - 'depthBelowLandLayer' = {typeOfFirstFixedSurface=106; typeOfSecondFixedSurface=106;} - 'theta' = {typeOfFirstFixedSurface=107; typeOfSecondFixedSurface=255;} - 'thetaLayer' = {typeOfFirstFixedSurface=107;typeOfSecondFixedSurface=107;} - 'pressureFromGround' = {typeOfFirstFixedSurface=108; typeOfSecondFixedSurface=255;} - 'pressureFromGroundLayer' = {typeOfFirstFixedSurface=108;typeOfSecondFixedSurface=108;} - 'potentialVorticity' = {typeOfFirstFixedSurface=109; typeOfSecondFixedSurface=255;} - 'eta' = {typeOfFirstFixedSurface=111; typeOfSecondFixedSurface=255;} - 'soil' = {typeOfFirstFixedSurface=151; typeOfSecondFixedSurface=255;} - 'soilLayer' = {typeOfFirstFixedSurface=151; typeOfSecondFixedSurface=151;} - -# In the case of Generalized vertical height coordinates, NV must be 6 - 'generalVertical' = {genVertHeightCoords=1; typeOfFirstFixedSurface=150; NV=6;} - 'generalVerticalLayer' = {genVertHeightCoords=1; typeOfFirstFixedSurface=150; typeOfSecondFixedSurface=150; NV=6;} - - 'depthBelowSea' = {typeOfFirstFixedSurface=160; typeOfSecondFixedSurface=255;} - 'entireAtmosphere' = {typeOfFirstFixedSurface=1;typeOfSecondFixedSurface=8;} - 'entireOcean' = {typeOfFirstFixedSurface=1;typeOfSecondFixedSurface=9;} - 'snow' = {typeOfFirstFixedSurface=114;typeOfSecondFixedSurface=255;} - 'snowLayer' = {typeOfFirstFixedSurface=114; typeOfSecondFixedSurface=114;} - - 'oceanSurface' = {typeOfFirstFixedSurface=160; scaleFactorOfFirstFixedSurface=0; scaledValueOfFirstFixedSurface=0; typeOfSecondFixedSurface=255;} - 'oceanLayer' = {typeOfFirstFixedSurface=160; typeOfSecondFixedSurface=160;} - 'mixedLayerDepth' = {typeOfFirstFixedSurface=169; typeOfSecondFixedSurface=255;} -} +concept_nofail vertical.typeOfLevel (unknown,"typeOfLevelConcept.def",conceptsMasterDir,conceptsLocalDirAll); alias levelType=typeOfFirstFixedSurface; diff --git a/definitions/grib2/typeOfLevelConcept.def b/definitions/grib2/typeOfLevelConcept.def new file mode 100644 index 000000000..550fe2d1c --- /dev/null +++ b/definitions/grib2/typeOfLevelConcept.def @@ -0,0 +1,49 @@ +# Concept typeOfLevel +'surface' = {typeOfFirstFixedSurface=1; typeOfSecondFixedSurface=255;} +'cloudBase' = {typeOfFirstFixedSurface=2; typeOfSecondFixedSurface=255;} +'cloudTop' = {typeOfFirstFixedSurface=3; typeOfSecondFixedSurface=255;} +'isothermZero' = {typeOfFirstFixedSurface=4; typeOfSecondFixedSurface=255;} +'adiabaticCondensation' = {typeOfFirstFixedSurface=5; typeOfSecondFixedSurface=255;} +'maxWind' = {typeOfFirstFixedSurface=6; typeOfSecondFixedSurface=255;} +'tropopause' = {typeOfFirstFixedSurface=7; typeOfSecondFixedSurface=255;} +'nominalTop' = {typeOfFirstFixedSurface=8; typeOfSecondFixedSurface=255;} +'seaBottom' = {typeOfFirstFixedSurface=9; typeOfSecondFixedSurface=255;} +# Note: We already had 'entireAtmosphere' mapped before adding this one so had to choose another name +'atmosphere' = {typeOfFirstFixedSurface=10; typeOfSecondFixedSurface=255;} +'isothermal' = {typeOfFirstFixedSurface=20; typeOfSecondFixedSurface=255;} +'isobaricInPa' = {typeOfFirstFixedSurface=100; typeOfSecondFixedSurface=255; pressureUnits='Pa';} +'isobaricInhPa' = {typeOfFirstFixedSurface=100; pressureUnits='hPa'; typeOfSecondFixedSurface=255;} +'isobaricLayer' = {typeOfFirstFixedSurface=100; typeOfSecondFixedSurface=100;} +'meanSea' = {typeOfFirstFixedSurface=101; typeOfSecondFixedSurface=255;} +'heightAboveSea' = {typeOfFirstFixedSurface=102; typeOfSecondFixedSurface=255;} +'heightAboveSeaLayer' = {typeOfFirstFixedSurface=102; typeOfSecondFixedSurface=102;} +'heightAboveGround' = {typeOfFirstFixedSurface=103; typeOfSecondFixedSurface=255;} +'heightAboveGroundLayer' = {typeOfFirstFixedSurface=103; typeOfSecondFixedSurface=103;} +'sigma' = {typeOfFirstFixedSurface=104; typeOfSecondFixedSurface=255;} +'sigmaLayer' = {typeOfFirstFixedSurface=104; typeOfSecondFixedSurface=104;} +'hybrid' = {typeOfFirstFixedSurface=105; typeOfSecondFixedSurface=255;} +'hybridHeight' = {typeOfFirstFixedSurface=118; typeOfSecondFixedSurface=255;} +'hybridLayer' = {typeOfFirstFixedSurface=105; typeOfSecondFixedSurface=105;} +'depthBelowLand' = {typeOfFirstFixedSurface=106; typeOfSecondFixedSurface=255;} +'depthBelowLandLayer' = {typeOfFirstFixedSurface=106; typeOfSecondFixedSurface=106;} +'theta' = {typeOfFirstFixedSurface=107; typeOfSecondFixedSurface=255;} +'thetaLayer' = {typeOfFirstFixedSurface=107; typeOfSecondFixedSurface=107;} +'pressureFromGround' = {typeOfFirstFixedSurface=108; typeOfSecondFixedSurface=255;} +'pressureFromGroundLayer' = {typeOfFirstFixedSurface=108; typeOfSecondFixedSurface=108;} +'potentialVorticity' = {typeOfFirstFixedSurface=109; typeOfSecondFixedSurface=255;} +'eta' = {typeOfFirstFixedSurface=111; typeOfSecondFixedSurface=255;} +'soil' = {typeOfFirstFixedSurface=151; typeOfSecondFixedSurface=255;} +'soilLayer' = {typeOfFirstFixedSurface=151; typeOfSecondFixedSurface=151;} +# In the case of Generalized vertical height coordinates, NV must be 6 +'generalVertical' = {genVertHeightCoords=1; typeOfFirstFixedSurface=150; NV=6;} +'generalVerticalLayer' = {genVertHeightCoords=1; typeOfFirstFixedSurface=150; typeOfSecondFixedSurface=150; NV=6;} +'depthBelowSea' = {typeOfFirstFixedSurface=160; typeOfSecondFixedSurface=255;} +'oceanSurface' = {typeOfFirstFixedSurface=160; scaleFactorOfFirstFixedSurface=0; scaledValueOfFirstFixedSurface=0; typeOfSecondFixedSurface=255;} +'oceanLayer' = {typeOfFirstFixedSurface=160; typeOfSecondFixedSurface=160;} +'entireAtmosphere' = {typeOfFirstFixedSurface=1; typeOfSecondFixedSurface=8;} +'entireOcean' = {typeOfFirstFixedSurface=1; typeOfSecondFixedSurface=9;} +'snow' = {typeOfFirstFixedSurface=114; typeOfSecondFixedSurface=255;} +'snowLayer' = {typeOfFirstFixedSurface=114; typeOfSecondFixedSurface=114;} +'seaIce' = {typeOfFirstFixedSurface=152; typeOfSecondFixedSurface=255;} +'seaIceLayer' = {typeOfFirstFixedSurface=152; typeOfSecondFixedSurface=152;} +'mixedLayerDepth' = {typeOfFirstFixedSurface=169; typeOfSecondFixedSurface=255;} diff --git a/definitions/grib2/typeOfUnstructuredGridConcept.def b/definitions/grib2/typeOfUnstructuredGridConcept.def new file mode 100644 index 000000000..4a36af701 --- /dev/null +++ b/definitions/grib2/typeOfUnstructuredGridConcept.def @@ -0,0 +1,5 @@ +'undefined' = { numberOfGridInReference = 0; } +'T grid' = { numberOfGridInReference = 1; } +'U grid' = { numberOfGridInReference = 2; } +'V grid' = { numberOfGridInReference = 3; } +'W grid' = { numberOfGridInReference = 4; } diff --git a/definitions/grib2/unstructuredGridConcept.def b/definitions/grib2/unstructuredGridConcept.def new file mode 100644 index 000000000..49b90fd90 --- /dev/null +++ b/definitions/grib2/unstructuredGridConcept.def @@ -0,0 +1,5 @@ +'undefined' = { numberOfGridUsed = 0; } +'ORCA2' = { numberOfGridUsed = 1; } +'ORCA1' = { numberOfGridUsed = 2; } +'ORCA025' = { numberOfGridUsed = 3; } +'ORCA12' = { numberOfGridUsed = 4; } diff --git a/definitions/grib2/unstructuredGridSubtype.def b/definitions/grib2/unstructuredGridSubtype.def new file mode 100644 index 000000000..6c68ab7da --- /dev/null +++ b/definitions/grib2/unstructuredGridSubtype.def @@ -0,0 +1 @@ +"unknown" = {dummy=0;} diff --git a/definitions/grib2/unstructuredGridType.def b/definitions/grib2/unstructuredGridType.def new file mode 100644 index 000000000..6c68ab7da --- /dev/null +++ b/definitions/grib2/unstructuredGridType.def @@ -0,0 +1 @@ +"unknown" = {dummy=0;} diff --git a/definitions/grib2/unstructuredGridUUID.def b/definitions/grib2/unstructuredGridUUID.def new file mode 100644 index 000000000..6c68ab7da --- /dev/null +++ b/definitions/grib2/unstructuredGridUUID.def @@ -0,0 +1 @@ +"unknown" = {dummy=0;} diff --git a/eccodes_config.h.in b/eccodes_config.h.in index 6cdae518c..6c00bc7bb 100644 --- a/eccodes_config.h.in +++ b/eccodes_config.h.in @@ -50,6 +50,7 @@ #cmakedefine ECCODES_HAVE_POSIX_MEMALIGN #cmakedefine ECCODES_HAVE_FMEMOPEN #cmakedefine ECCODES_HAVE_FUNOPEN +#cmakedefine ECCODES_HAVE_REALPATH #if defined(EC_HAVE_ASSERT_H) || defined(ECCODES_HAVE_ASSERT_H) #define HAVE_ASSERT_H 1 @@ -64,15 +65,15 @@ #endif #if defined(EC_HAVE_SYS_STAT_H) || defined(ECCODES_HAVE_SYS_STAT_H) -#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_STAT_H 1 #endif #if defined(EC_HAVE_FCNTL_H) || defined(ECCODES_HAVE_FCNTL_H) -#define HAVE_FCNTL_H 1 +#define HAVE_FCNTL_H 1 #endif #if defined(EC_HAVE_UNISTD_H) || defined(ECCODES_HAVE_UNISTD_H) -#define HAVE_UNISTD_H 1 +#define HAVE_UNISTD_H 1 #endif #if defined(EC_HAVE_FSEEKO) || defined(ECCODES_HAVE_FSEEKO) @@ -80,9 +81,10 @@ #endif #if defined(EC_HAVE_POSIX_MEMALIGN) || defined(ECCODES_HAVE_POSIX_MEMALIGN) -#define POSIX_MEMALIGN 1 +#define POSIX_MEMALIGN 1 #endif + /* other */ #define IEEE_BE @IEEE_BE@ diff --git a/examples/C/CMakeLists.txt b/examples/C/CMakeLists.txt index 9b850c9fc..bd8299a06 100644 --- a/examples/C/CMakeLists.txt +++ b/examples/C/CMakeLists.txt @@ -59,59 +59,92 @@ endforeach() # Now add each test (shell scripts) ######################################################################## -list(APPEND tests_sanity - grib_set_data - large_grib1 - grib_sections_copy - get_product_kind_samples -) -list(APPEND tests_extra - grib_iterator - grib_get_keys - grib_print_data - grib_set_keys - grib_keys_iterator - grib_multi_write - grib_precision - grib_clone - grib_copy_message - grib_ensemble_index - grib_set_pv - grib_set_bitmap - grib_list - grib_get_data - grib_nearest_multiple - grib_multi - set_missing - bufr_attributes - bufr_copy_data - bufr_clone - bufr_expanded - bufr_get_keys - bufr_get_string_array - bufr_keys_iterator - bufr_missing - bufr_read_header - bufr_read_scatterometer - bufr_read_synop - bufr_read_temp - bufr_set_keys - bufr_subset - get_product_kind -) +if( HAVE_BUILD_TOOLS ) + # Command line tools are available + list(APPEND tests_sanity + grib_set_data + large_grib1 + grib_sections_copy + get_product_kind_samples) + list(APPEND tests_extra + grib_iterator + grib_get_keys + grib_print_data + grib_set_keys + grib_keys_iterator + grib_multi_write + grib_precision + grib_clone + grib_copy_message + grib_ensemble_index + grib_set_pv + grib_set_bitmap + grib_list + grib_get_data + grib_nearest_multiple + grib_multi + set_missing + bufr_attributes + bufr_copy_data + bufr_clone + bufr_expanded + bufr_get_keys + bufr_get_string_array + bufr_keys_iterator + bufr_missing + bufr_read_header + bufr_read_scatterometer + bufr_read_synop + bufr_read_temp + bufr_set_keys + bufr_subset + get_product_kind) +else() + # No command line tools + list(APPEND tests_sanity + grib_set_data + get_product_kind_samples) + list(APPEND tests_extra + grib_iterator + grib_get_keys + grib_print_data + grib_set_keys + grib_keys_iterator + grib_precision + grib_ensemble_index + grib_set_pv + grib_list + grib_get_data + grib_nearest_multiple + grib_multi + set_missing + bufr_attributes + bufr_expanded + bufr_get_keys + bufr_get_string_array + bufr_keys_iterator + bufr_missing + bufr_read_header + bufr_read_scatterometer + bufr_read_synop + bufr_read_temp + bufr_set_keys + bufr_subset + get_product_kind) +endif() foreach( test ${tests_sanity} ) - ecbuild_add_test( TARGET eccodes_c_${test} - TYPE SCRIPT - LABELS "sanity" - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh ) + ecbuild_add_test( TARGET eccodes_c_${test} + TYPE SCRIPT + LABELS "sanity" + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh ) endforeach() foreach( test ${tests_extra} ) - ecbuild_add_test( TARGET eccodes_c_${test} - TYPE SCRIPT - CONDITION ENABLE_EXTRA_TESTS - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh - TEST_DEPENDS eccodes_download_gribs eccodes_download_bufrs ) + ecbuild_add_test( TARGET eccodes_c_${test} + TYPE SCRIPT + CONDITION ENABLE_EXTRA_TESTS + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh + TEST_DEPENDS eccodes_download_gribs eccodes_download_bufrs ) endforeach() ######################################################################## diff --git a/examples/F90/CMakeLists.txt b/examples/F90/CMakeLists.txt index d22a8b30f..06a2583c1 100644 --- a/examples/F90/CMakeLists.txt +++ b/examples/F90/CMakeLists.txt @@ -5,53 +5,92 @@ configure_file( include.ctest.sh.in include.ctest.sh @ONLY ) execute_process( COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include.sh ${CMAKE_CURRENT_BINARY_DIR} ) -# Build the executables used by test scripts -################################################ -list( APPEND tests_sanity - grib_set_pv - grib_set_data - grib_ecc-671 ) -list( APPEND tests_extra - grib_index - grib_copy_message - bufr_copy_message - grib_get_keys - grib_get_data - get_pl - get_pv - grib_keys_iterator - grib_multi_write - grib_multi - grib_nearest - grib_precision - grib_print_data - grib_set_keys - grib_set_bitmap - grib_set_missing - grib_samples - grib_count_messages - grib_count_messages_multi - grib_copy_namespace - read_message - read_from_file - get_set_uuid - grib_clone - bufr_attributes - bufr_copy_data - bufr_clone - bufr_expanded - bufr_get_keys - bufr_get_string_array - bufr_keys_iterator - bufr_read_header - bufr_read_scatterometer - bufr_read_synop - bufr_read_temp - bufr_read_tropical_cyclone - bufr_set_keys - bufr_copy_keys - bufr_subset - get_product_kind ) +# Add all the tests +############################################# +if( HAVE_BUILD_TOOLS ) + list( APPEND tests_sanity + grib_set_pv + grib_set_data + grib_ecc-671 ) + list( APPEND tests_extra + grib_index + grib_copy_message + bufr_copy_message + grib_get_keys + grib_get_data + get_pl + get_pv + grib_keys_iterator + grib_multi_write + grib_multi + grib_nearest + grib_precision + grib_print_data + grib_set_keys + grib_set_bitmap + grib_set_missing + grib_samples + grib_count_messages + grib_count_messages_multi + grib_copy_namespace + read_message + read_from_file + get_set_uuid + grib_clone + bufr_attributes + bufr_copy_data + bufr_clone + bufr_expanded + bufr_get_keys + bufr_get_string_array + bufr_keys_iterator + bufr_read_header + bufr_read_scatterometer + bufr_read_synop + bufr_read_temp + bufr_read_tropical_cyclone + bufr_set_keys + bufr_copy_keys + bufr_subset + get_product_kind ) +else() + # No command line tools + list( APPEND tests_sanity + grib_set_pv + grib_set_data + grib_ecc-671 ) + list( APPEND tests_extra + grib_index + grib_get_keys + grib_get_data + get_pl + get_pv + grib_keys_iterator + grib_multi + grib_nearest + grib_precision + grib_print_data + grib_set_missing + grib_samples + grib_count_messages + grib_count_messages_multi + read_from_file + grib_clone + bufr_attributes + bufr_clone + bufr_expanded + bufr_get_keys + bufr_get_string_array + bufr_keys_iterator + bufr_read_header + bufr_read_scatterometer + bufr_read_synop + bufr_read_temp + bufr_read_tropical_cyclone + bufr_set_keys + bufr_subset + get_product_kind ) +endif() foreach( tool ${tests_sanity} ) ecbuild_add_test( TARGET eccodes_f_${tool} diff --git a/tests/readvalues.F b/examples/deprecated/readvalues.F similarity index 100% rename from tests/readvalues.F rename to examples/deprecated/readvalues.F diff --git a/examples/python/CMakeLists.txt b/examples/python/CMakeLists.txt index 158b0629f..2e7fb82c5 100644 --- a/examples/python/CMakeLists.txt +++ b/examples/python/CMakeLists.txt @@ -25,46 +25,82 @@ endforeach() # Now add each test -################################################# -list(APPEND tests_basic - grib_set_pv - grib_read_sample - bufr_read_sample - bufr_ecc-869 -) -list(APPEND tests_extra - grib_clone - grib_count_messages - grib_get_message_offset - grib_get_keys - grib_index - grib_iterator - grib_keys_iterator - grib_multi_write - grib_nearest - grib_print_data - grib_samples - grib_set_missing - binary_message - grib_set_bitmap - bufr_attributes - bufr_clone - bufr_copy_data - bufr_expanded - bufr_get_keys - bufr_keys_iterator - bufr_read_header - bufr_read_scatterometer - bufr_read_tropical_cyclone - bufr_read_synop - bufr_read_temp - bufr_set_keys - bufr_subset - get_product_kind - gts_get_keys - metar_get_keys - bufr_ecc-448 -) +################################################ +if( HAVE_BUILD_TOOLS ) + list(APPEND tests_basic + grib_set_pv + grib_read_sample + bufr_read_sample + bufr_ecc-869 + ) + list(APPEND tests_extra + grib_clone + grib_count_messages + grib_get_message_offset + grib_get_keys + grib_index + grib_iterator + grib_keys_iterator + grib_multi_write + grib_nearest + grib_print_data + grib_samples + grib_set_missing + binary_message + grib_set_bitmap + bufr_attributes + bufr_clone + bufr_copy_data + bufr_expanded + bufr_get_keys + bufr_keys_iterator + bufr_read_header + bufr_read_scatterometer + bufr_read_tropical_cyclone + bufr_read_synop + bufr_read_temp + bufr_set_keys + bufr_subset + get_product_kind + gts_get_keys + metar_get_keys + bufr_ecc-448 + ) +else() + # No command line tools + list(APPEND tests_basic + grib_read_sample + bufr_read_sample + ) + list(APPEND tests_extra + grib_clone + grib_count_messages + grib_get_keys + grib_index + grib_iterator + grib_keys_iterator + grib_multi_write + grib_nearest + grib_print_data + grib_samples + bufr_attributes + bufr_clone + bufr_expanded + bufr_get_keys + bufr_keys_iterator + bufr_read_header + bufr_read_scatterometer + bufr_read_tropical_cyclone + bufr_read_synop + bufr_read_temp + bufr_set_keys + bufr_subset + get_product_kind + gts_get_keys + metar_get_keys + bufr_ecc-448 + ) +endif() # The high level python test requires new features in the unittest # which are only there for python 2.7 onwards @@ -97,7 +133,7 @@ ecbuild_add_test( TARGET eccodes_p_bufr_encode_flight_test TYPE SCRIPT DEPENDS ${ptools} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bufr_encode_flight.sh - CONDITION HAVE_PYTHON AND ENABLE_EXTRA_TESTS + CONDITION HAVE_PYTHON AND ENABLE_EXTRA_TESTS AND HAVE_BUILD_TOOLS ENVIRONMENT PYTHON=${PYTHON_EXECUTABLE} RESOURCES flight_data.csv TEST_DEPENDS eccodes_download_bufrs ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ef91a859e..6ffefeef8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -65,7 +65,6 @@ list( APPEND grib_api_srcs grib_accessor_class_bits.c grib_accessor_class_bits_per_value.c grib_accessor_class_bufr_clear_tables.c - grib_accessor_class_bufr_data.c grib_accessor_class_bufr_elements_table.c grib_accessor_class_bufr_data_array.c grib_accessor_class_bufr_data_element.c diff --git a/src/Makefile.am b/src/Makefile.am index c483bf548..8acb0e949 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -64,7 +64,6 @@ libeccodes_la_prototypes= \ grib_accessor_class_bitmap.c \ grib_accessor_class_bits.c \ grib_accessor_class_bits_per_value.c \ - grib_accessor_class_bufr_data.c \ grib_accessor_class_bufr_clear_tables.c \ grib_accessor_class_bufr_data_array.c \ grib_accessor_class_bufr_data_element.c \ diff --git a/src/action_class_concept.c b/src/action_class_concept.c index 6694410d4..19064b7f8 100644 --- a/src/action_class_concept.c +++ b/src/action_class_concept.c @@ -208,8 +208,9 @@ static void destroy(grib_context* context, grib_action* act) grib_action_concept* self = (grib_action_concept*)act; grib_concept_value* v = self->concept; - if (v) - grib_trie_delete(v->index); + if (v) { + grib_trie_delete_container(v->index); + } while (v) { grib_concept_value* n = v->next; grib_concept_value_delete(context, v); diff --git a/src/action_class_transient_darray.c b/src/action_class_transient_darray.c index 64606fd69..a36f399e6 100644 --- a/src/action_class_transient_darray.c +++ b/src/action_class_transient_darray.c @@ -140,8 +140,6 @@ static void destroy(grib_context* context, grib_action* act) grib_context_free_persistent(context, a->name); grib_darray_delete(context, a->darray); - grib_context_free_persistent(context, act->name); - grib_context_free_persistent(context, act->op); } static void xref(grib_action* d, FILE* f, const char* path) diff --git a/src/grib_accessor_class_bufr_data.c b/src/deprecated/grib_accessor_class_bufr_data.c similarity index 100% rename from src/grib_accessor_class_bufr_data.c rename to src/deprecated/grib_accessor_class_bufr_data.c diff --git a/src/grib_accessor_class.c b/src/grib_accessor_class.c index 7b470f217..d00fb0d95 100644 --- a/src/grib_accessor_class.c +++ b/src/grib_accessor_class.c @@ -248,6 +248,7 @@ void grib_push_accessor(grib_accessor* a, grib_block_of_accessors* l) l->last = a; if (hand->use_trie) { + DebugAssert( a->all_names[0] ); if (*(a->all_names[0]) != '_') { id = grib_hash_keys_get_id(a->context->keys, a->all_names[0]); diff --git a/src/grib_accessor_class.h b/src/grib_accessor_class.h index 31292b4cb..9631bde1e 100644 --- a/src/grib_accessor_class.h +++ b/src/grib_accessor_class.h @@ -13,7 +13,6 @@ extern grib_accessor_class* grib_accessor_class_blob; extern grib_accessor_class* grib_accessor_class_box; extern grib_accessor_class* grib_accessor_class_budgdate; extern grib_accessor_class* grib_accessor_class_bufr_clear_tables; -extern grib_accessor_class* grib_accessor_class_bufr_data; extern grib_accessor_class* grib_accessor_class_bufr_data_array; extern grib_accessor_class* grib_accessor_class_bufr_data_element; extern grib_accessor_class* grib_accessor_class_bufr_elements_table; diff --git a/src/grib_accessor_class_bufr_data_array.c b/src/grib_accessor_class_bufr_data_array.c index 51c4217c4..4d5797c9e 100644 --- a/src/grib_accessor_class_bufr_data_array.c +++ b/src/grib_accessor_class_bufr_data_array.c @@ -252,7 +252,7 @@ static int process_elements(grib_accessor* a, int flag, long onlySubset, long st typedef int (*codec_element_proc)(grib_context* c, grib_accessor_bufr_data_array* self, int subsetIndex, grib_buffer* b, unsigned char* data, long* pos, int i, bufr_descriptor* descriptor, long elementIndex, grib_darray* dval, grib_sarray* sval); typedef int (*codec_replication_proc)(grib_context* c, grib_accessor_bufr_data_array* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, long elementIndex, grib_darray* dval, long* numberOfRepetitions); -static int create_keys(grib_accessor* a, long onlySubset, long startSubset, long endSubset); +static int create_keys(const grib_accessor* a, long onlySubset, long startSubset, long endSubset); static void restart_bitmap(grib_accessor_bufr_data_array* self) { @@ -1929,7 +1929,7 @@ static int adding_extra_key_attributes(grib_handle* h) return (!skip); } -static grib_accessor* create_accessor_from_descriptor(grib_accessor* a, grib_accessor* attribute, grib_section* section, +static grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, grib_accessor* attribute, grib_section* section, long ide, long subset, int dump, int count, int add_extra_attributes) { grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; @@ -2127,7 +2127,7 @@ static const int number_of_qualifiers = NUMBER_OF_QUALIFIERS_PER_CATEGORY * NUMB static GRIB_INLINE int significanceQualifierIndex(int X, int Y) { - int a[] = { -1, 0, 1, -1, 2, 3, 4, 5, 6 }; + static const int a[] = { -1, 0, 1, -1, 2, 3, 4, 5, 6 }; int ret = Y + a[X] * NUMBER_OF_QUALIFIERS_PER_CATEGORY; DebugAssert(ret > 0); return ret; @@ -2141,7 +2141,7 @@ static GRIB_INLINE void reset_deeper_qualifiers( int i; for (i = 0; i < numElements; i++) { if (significanceQualifierDepth[i] > depth) { - significanceQualifierGroup[i] = 0; + significanceQualifierGroup[i] = NULL; } } } @@ -2153,7 +2153,7 @@ typedef struct bitmap_s grib_accessors_list* referredElementStart; } bitmap_s; -static grib_accessor* get_element_from_bitmap(grib_accessor* a, bitmap_s* bitmap) +static grib_accessor* get_element_from_bitmap(const grib_accessor* a, bitmap_s* bitmap) { int ret; long bitmapVal = 1; @@ -2390,7 +2390,7 @@ static int grib_data_accessors_trie_push(grib_trie_with_rank* accessorsTrie, gri return grib_trie_with_rank_insert(accessorsTrie, a->name, a); } -static int create_keys(grib_accessor* a, long onlySubset, long startSubset, long endSubset) +static int create_keys(const grib_accessor* a, long onlySubset, long startSubset, long endSubset) { grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; int err = 0; @@ -2428,6 +2428,7 @@ static int create_keys(grib_accessor* a, long onlySubset, long startSubset, long int bitmapIndex = -1; int incrementBitmapIndex = 1; grib_accessor* elementFromBitmap = NULL; + grib_handle* hand = grib_handle_of_accessor(a); /*int reuseBitmap=0;*/ int dump = 1, count = 0; /*int forceGroupClosure=0;*/ @@ -2460,7 +2461,7 @@ static int create_keys(grib_accessor* a, long onlySubset, long startSubset, long gaGroup = grib_accessor_factory(self->dataKeys, &creatorGroup, 0, NULL); gaGroup->bufr_group_number = groupNumber; - gaGroup->sub_section = grib_section_create(grib_handle_of_accessor(a), gaGroup); + gaGroup->sub_section = grib_section_create(hand, gaGroup); section = gaGroup->sub_section; /*rootSection=section;*/ /*sectionUp=self->dataKeys;*/ @@ -2475,7 +2476,7 @@ static int create_keys(grib_accessor* a, long onlySubset, long startSubset, long /*indexOfGroupNumber=0;*/ depth = 0; extraElement = 0; - add_extra_attributes = adding_extra_key_attributes(grib_handle_of_accessor(a)); + add_extra_attributes = adding_extra_key_attributes(hand); for (iss = 0; iss < end; iss++) { qualityPresent = 0; @@ -2521,7 +2522,7 @@ static int create_keys(grib_accessor* a, long onlySubset, long startSubset, long } gaGroup = grib_accessor_factory(groupSection, &creatorGroup, 0, NULL); - gaGroup->sub_section = grib_section_create(grib_handle_of_accessor(a), gaGroup); + gaGroup->sub_section = grib_section_create(hand, gaGroup); gaGroup->bufr_group_number = groupNumber; accessor_constant_set_type(gaGroup, GRIB_TYPE_LONG); accessor_constant_set_dval(gaGroup, groupNumber); @@ -2565,7 +2566,7 @@ static int create_keys(grib_accessor* a, long onlySubset, long startSubset, long depth++; } gaGroup = grib_accessor_factory(groupSection, &creatorGroup, 0, NULL); - gaGroup->sub_section = grib_section_create(grib_handle_of_accessor(a), gaGroup); + gaGroup->sub_section = grib_section_create(hand, gaGroup); gaGroup->bufr_group_number = groupNumber; accessor_constant_set_type(gaGroup, GRIB_TYPE_LONG); accessor_constant_set_dval(gaGroup, groupNumber); @@ -2641,6 +2642,9 @@ static int create_keys(grib_accessor* a, long onlySubset, long startSubset, long err = GRIB_DECODING_ERROR; return err; } + if (elementAccessor->name == NULL) { + return GRIB_DECODING_ERROR; + } /*if (associatedFieldAccessor) grib_accessor_delete(c, associatedFieldAccessor);*/ associatedFieldAccessor = NULL; @@ -3391,7 +3395,14 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return err; if (self->compressedData) { + const size_t rlen = l * self->numberOfSubsets; ii = 0; + if (*len < rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "wrong size (%ld) for %s, it contains %d values ", *len, a->name, rlen); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } for (k = 0; k < numberOfSubsets; k++) { for (i = 0; i < l; i++) { val[ii++] = self->numericValues->v[i]->n > 1 ? self->numericValues->v[i]->v[k] : self->numericValues->v[i]->v[0]; diff --git a/src/grib_accessor_class_bufr_elements_table.c b/src/grib_accessor_class_bufr_elements_table.c index 615df7350..f908182dd 100644 --- a/src/grib_accessor_class_bufr_elements_table.c +++ b/src/grib_accessor_class_bufr_elements_table.c @@ -354,10 +354,20 @@ static int bufr_get_from_table(grib_accessor* a, bufr_descriptor* v) if (!list) return GRIB_NOT_FOUND; - v->shortName = grib_context_strdup(a->context, list[1]); - v->type = convert_type(list[2]); +#ifdef DEBUG + { + /* ECC-1137: check descriptor key name and unit lengths */ + const size_t maxlen_shortName = sizeof(v->shortName); + const size_t maxlen_units = sizeof(v->units); + Assert( strlen(list[1]) < maxlen_shortName ); + Assert( strlen(list[4]) < maxlen_units ); + } +#endif + + strcpy(v->shortName, list[1]); + v->type = convert_type(list[2]); /* v->name=grib_context_strdup(c,list[3]); See ECC-489 */ - v->units = grib_context_strdup(a->context, list[4]); + strcpy(v->units, list[4]); /* ECC-985: Scale and reference are often 0 so we can reduce calls to atol */ v->scale = atol_fast(list[5]); diff --git a/src/grib_accessor_class_concept.c b/src/grib_accessor_class_concept.c index 2e35cb01d..035ed7e8f 100644 --- a/src/grib_accessor_class_concept.c +++ b/src/grib_accessor_class_concept.c @@ -345,7 +345,7 @@ static int grib_concept_apply(grib_accessor* a, const char* name) grib_action* act = a->creator; int nofail = action_concept_get_nofail(a); - Assert(concepts != NULL); + DebugAssert(concepts); c = (grib_concept_value*)grib_trie_get(concepts->index, name); @@ -630,7 +630,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) *len = slen; return GRIB_BUFFER_TOO_SMALL; } - strncpy(val, p, slen); + strcpy(val, p); /* NOLINT: CWE-119 clang-analyzer-security.insecureAPI.strcpy */ *len = slen; #if 0 if (a->context->debug==1) { diff --git a/src/grib_accessor_class_expanded_descriptors.c b/src/grib_accessor_class_expanded_descriptors.c index 14e320ff8..fa5c72a0c 100644 --- a/src/grib_accessor_class_expanded_descriptors.c +++ b/src/grib_accessor_class_expanded_descriptors.c @@ -399,9 +399,9 @@ static void __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, bufr_ bufr_descriptor* au = grib_bufr_descriptor_new(self->tablesAccessor, 999999, err); au->width = ccp->associatedFieldWidth; grib_bufr_descriptor_set_scale(au, 0); - au->shortName = grib_context_strdup(c, "associatedField"); + strcpy(au->shortName, "associatedField"); /* au->name=grib_context_strdup(c,"associated field"); See ECC-489 */ - au->units = grib_context_strdup(c, "associated units"); + strcpy(au->units, "associated units"); #if MYDEBUG for (idepth = 0; idepth < global_depth; idepth++) printf("\t"); diff --git a/src/grib_accessor_class_g1fcperiod.c b/src/grib_accessor_class_g1fcperiod.c index e8664d64a..876e494c5 100644 --- a/src/grib_accessor_class_g1fcperiod.c +++ b/src/grib_accessor_class_g1fcperiod.c @@ -159,7 +159,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) } *len = l; - strncpy(val, tmp, l); + strcpy(val, tmp); /* NOLINT: CWE-119 clang-analyzer-security.insecureAPI.strcpy */ return GRIB_SUCCESS; } diff --git a/src/grib_accessor_class_g2latlon.c b/src/grib_accessor_class_g2latlon.c index c1d3456ab..fd364b4d3 100644 --- a/src/grib_accessor_class_g2latlon.c +++ b/src/grib_accessor_class_g2latlon.c @@ -185,10 +185,10 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) { grib_accessor_g2latlon* self = (grib_accessor_g2latlon*)a; int ret = 0; - double grid[6]; size_t size = 6; double new_val = *val; + grib_handle* hand = grib_handle_of_accessor(a); if (*len < 1) { ret = GRIB_ARRAY_TOO_SMALL; @@ -197,11 +197,11 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) if (self->given) { long given = *val != GRIB_MISSING_DOUBLE; - if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->given, given)) != GRIB_SUCCESS) + if ((ret = grib_set_long_internal(hand, self->given, given)) != GRIB_SUCCESS) return ret; } - if ((ret = grib_get_double_array_internal(grib_handle_of_accessor(a), self->grid, grid, &size)) != GRIB_SUCCESS) + if ((ret = grib_get_double_array_internal(hand, self->grid, grid, &size)) != GRIB_SUCCESS) return ret; /* index 1 is longitudeOfFirstGridPointInDegrees @@ -211,10 +211,13 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) /* WMO regulation for GRIB edition 2: * The longitude values shall be limited to the range 0 to 360 degrees inclusive */ new_val = normalise_longitude_in_degrees(*val); + if (hand->context->debug && new_val != *val) { + fprintf(stderr, "ECCODES DEBUG pack_double g2latlon: normalise longitude %g -> %g\n", *val, new_val); + } } grid[self->index] = new_val; - return grib_set_double_array_internal(grib_handle_of_accessor(a), self->grid, grid, size); + return grib_set_double_array_internal(hand, self->grid, grid, size); } static int pack_missing(grib_accessor* a) @@ -234,10 +237,8 @@ static int is_missing(grib_accessor* a) grib_accessor_g2latlon* self = (grib_accessor_g2latlon*)a; long given = 1; - if (self->given) grib_get_long_internal(grib_handle_of_accessor(a), self->given, &given); - return !given; } diff --git a/src/grib_accessor_classes_hash.c b/src/grib_accessor_classes_hash.c index 306873272..cd712ffe1 100644 --- a/src/grib_accessor_classes_hash.c +++ b/src/grib_accessor_classes_hash.c @@ -37,12 +37,12 @@ error "gperf generated tables don't work with this execution character set. Plea #line 6 "accessor_class_list.gperf" struct accessor_class_hash { char *name; grib_accessor_class **cclass;}; -#define TOTAL_KEYWORDS 227 +#define TOTAL_KEYWORDS 226 #define MIN_WORD_LENGTH 1 #define MAX_WORD_LENGTH 44 #define MIN_HASH_VALUE 1 -#define MAX_HASH_VALUE 618 -/* maximum key range = 618, duplicates = 0 */ +#define MAX_HASH_VALUE 552 +/* maximum key range = 552, duplicates = 0 */ #ifdef __GNUC__ @@ -56,32 +56,32 @@ grib_accessor_classes_get_id (const char *str, unsigned int len) { static const unsigned short asso_values[] = { - 619, 619, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 0, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 619, 619, 619, 0, 60, - 18, 14, 21, 619, 23, 619, 4, 619, 619, 619, - 619, 619, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 0, 619, 0, 134, 189, - 0, 3, 187, 28, 45, 1, 17, 0, 165, 217, - 14, 64, 55, 619, 109, 3, 2, 98, 201, 3, - 1, 60, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 619, 619, 619, 619, 619, - 619, 619, 619, 619, 619, 619 + 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 0, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 553, 553, 553, 10, 44, + 14, 0, 24, 553, 28, 553, 0, 553, 553, 553, + 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 0, 553, 0, 158, 74, + 0, 0, 119, 29, 145, 1, 7, 14, 146, 207, + 13, 63, 20, 553, 87, 1, 53, 103, 160, 9, + 7, 30, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, + 553, 553, 553, 553, 553, 553 }; register int hval = len; @@ -117,589 +117,559 @@ static const struct accessor_class_hash classes[] = {""}, #line 9 "accessor_class_list.gperf" {" "}, - {""}, {""}, {""}, {""}, {""}, -#line 211 "accessor_class_list.gperf" - {"time", &grib_accessor_class_time}, -#line 199 "accessor_class_list.gperf" + {""}, {""}, {""}, {""}, +#line 198 "accessor_class_list.gperf" {"size", &grib_accessor_class_size}, #line 14 "accessor_class_list.gperf" {"ascii", &grib_accessor_class_ascii}, - {""}, -#line 212 "accessor_class_list.gperf" - {"times", &grib_accessor_class_times}, - {""}, -#line 196 "accessor_class_list.gperf" +#line 195 "accessor_class_list.gperf" {"signed", &grib_accessor_class_signed}, - {""}, {""}, -#line 75 "accessor_class_list.gperf" - {"data_raw_packing", &grib_accessor_class_data_raw_packing}, - {""}, -#line 205 "accessor_class_list.gperf" - {"statistics", &grib_accessor_class_statistics}, -#line 142 "accessor_class_list.gperf" - {"int8", &grib_accessor_class_int8}, - {""}, -#line 197 "accessor_class_list.gperf" + {""}, {""}, {""}, {""}, {""}, +#line 196 "accessor_class_list.gperf" {"signed_bits", &grib_accessor_class_signed_bits}, {""}, -#line 80 "accessor_class_list.gperf" - {"data_simple_packing", &grib_accessor_class_data_simple_packing}, -#line 76 "accessor_class_list.gperf" - {"data_secondary_bitmap", &grib_accessor_class_data_secondary_bitmap}, - {""}, -#line 82 "accessor_class_list.gperf" - {"dictionary", &grib_accessor_class_dictionary}, -#line 206 "accessor_class_list.gperf" - {"statistics_spectral", &grib_accessor_class_statistics_spectral}, -#line 190 "accessor_class_list.gperf" - {"section", &grib_accessor_class_section}, -#line 164 "accessor_class_list.gperf" - {"nearest", &grib_accessor_class_nearest}, #line 74 "accessor_class_list.gperf" - {"data_png_packing", &grib_accessor_class_data_png_packing}, - {""}, {""}, -#line 208 "accessor_class_list.gperf" - {"step_in_units", &grib_accessor_class_step_in_units}, -#line 126 "accessor_class_list.gperf" - {"gen", &grib_accessor_class_gen}, + {"data_raw_packing", &grib_accessor_class_data_raw_packing}, {""}, -#line 192 "accessor_class_list.gperf" - {"section_padding", &grib_accessor_class_section_padding}, -#line 193 "accessor_class_list.gperf" - {"section_pointer", &grib_accessor_class_section_pointer}, -#line 138 "accessor_class_list.gperf" - {"int32", &grib_accessor_class_int32}, -#line 66 "accessor_class_list.gperf" - {"data_g22order_packing", &grib_accessor_class_data_g22order_packing}, +#line 141 "accessor_class_list.gperf" + {"int8", &grib_accessor_class_int8}, {""}, -#line 140 "accessor_class_list.gperf" - {"int64", &grib_accessor_class_int64}, -#line 70 "accessor_class_list.gperf" - {"data_g2shsimple_packing", &grib_accessor_class_data_g2shsimple_packing}, -#line 136 "accessor_class_list.gperf" - {"int16", &grib_accessor_class_int16}, -#line 88 "accessor_class_list.gperf" - {"expanded_descriptors", &grib_accessor_class_expanded_descriptors}, - {""}, -#line 124 "accessor_class_list.gperf" - {"gds_is_present", &grib_accessor_class_gds_is_present}, - {""}, {""}, -#line 191 "accessor_class_list.gperf" - {"section_length", &grib_accessor_class_section_length}, +#line 79 "accessor_class_list.gperf" + {"data_simple_packing", &grib_accessor_class_data_simple_packing}, +#line 75 "accessor_class_list.gperf" + {"data_secondary_bitmap", &grib_accessor_class_data_secondary_bitmap}, #line 189 "accessor_class_list.gperf" - {"second_order_bits_per_value", &grib_accessor_class_second_order_bits_per_value}, -#line 127 "accessor_class_list.gperf" - {"getenv", &grib_accessor_class_getenv}, -#line 235 "accessor_class_list.gperf" - {"when", &grib_accessor_class_when}, -#line 117 "accessor_class_list.gperf" - {"g2grid", &grib_accessor_class_g2grid}, -#line 115 "accessor_class_list.gperf" - {"g2date", &grib_accessor_class_g2date}, -#line 121 "accessor_class_list.gperf" - {"g2step", &grib_accessor_class_g2step}, -#line 113 "accessor_class_list.gperf" - {"g2bitmap", &grib_accessor_class_g2bitmap}, - {""}, -#line 176 "accessor_class_list.gperf" + {"section", &grib_accessor_class_section}, +#line 175 "accessor_class_list.gperf" {"pad", &grib_accessor_class_pad}, -#line 116 "accessor_class_list.gperf" - {"g2end_step", &grib_accessor_class_g2end_step}, - {""}, -#line 202 "accessor_class_list.gperf" +#line 201 "accessor_class_list.gperf" {"spd", &grib_accessor_class_spd}, +#line 81 "accessor_class_list.gperf" + {"dictionary", &grib_accessor_class_dictionary}, {""}, {""}, {""}, -#line 120 "accessor_class_list.gperf" - {"g2lon", &grib_accessor_class_g2lon}, -#line 83 "accessor_class_list.gperf" - {"dirty", &grib_accessor_class_dirty}, - {""}, {""}, -#line 125 "accessor_class_list.gperf" - {"gds_not_present_bitmap", &grib_accessor_class_gds_not_present_bitmap}, - {""}, {""}, -#line 50 "accessor_class_list.gperf" - {"data_apply_bitmap", &grib_accessor_class_data_apply_bitmap}, - {""}, {""}, -#line 143 "accessor_class_list.gperf" - {"iterator", &grib_accessor_class_iterator}, #line 73 "accessor_class_list.gperf" + {"data_png_packing", &grib_accessor_class_data_png_packing}, +#line 191 "accessor_class_list.gperf" + {"section_padding", &grib_accessor_class_section_padding}, +#line 192 "accessor_class_list.gperf" + {"section_pointer", &grib_accessor_class_section_pointer}, +#line 125 "accessor_class_list.gperf" + {"gen", &grib_accessor_class_gen}, +#line 137 "accessor_class_list.gperf" + {"int32", &grib_accessor_class_int32}, + {""}, +#line 65 "accessor_class_list.gperf" + {"data_g22order_packing", &grib_accessor_class_data_g22order_packing}, +#line 82 "accessor_class_list.gperf" + {"dirty", &grib_accessor_class_dirty}, +#line 49 "accessor_class_list.gperf" + {"data_apply_bitmap", &grib_accessor_class_data_apply_bitmap}, +#line 69 "accessor_class_list.gperf" + {"data_g2shsimple_packing", &grib_accessor_class_data_g2shsimple_packing}, + {""}, +#line 87 "accessor_class_list.gperf" + {"expanded_descriptors", &grib_accessor_class_expanded_descriptors}, +#line 188 "accessor_class_list.gperf" + {"second_order_bits_per_value", &grib_accessor_class_second_order_bits_per_value}, +#line 190 "accessor_class_list.gperf" + {"section_length", &grib_accessor_class_section_length}, +#line 139 "accessor_class_list.gperf" + {"int64", &grib_accessor_class_int64}, +#line 52 "accessor_class_list.gperf" + {"data_apply_gdsnotpresent", &grib_accessor_class_data_apply_gdsnotpresent}, +#line 123 "accessor_class_list.gperf" + {"gds_is_present", &grib_accessor_class_gds_is_present}, +#line 50 "accessor_class_list.gperf" + {"data_apply_boustrophedonic", &grib_accessor_class_data_apply_boustrophedonic}, +#line 135 "accessor_class_list.gperf" + {"int16", &grib_accessor_class_int16}, +#line 126 "accessor_class_list.gperf" + {"getenv", &grib_accessor_class_getenv}, +#line 120 "accessor_class_list.gperf" + {"g2step", &grib_accessor_class_g2step}, +#line 116 "accessor_class_list.gperf" + {"g2grid", &grib_accessor_class_g2grid}, +#line 72 "accessor_class_list.gperf" {"data_jpeg2000_packing", &grib_accessor_class_data_jpeg2000_packing}, {""}, -#line 215 "accessor_class_list.gperf" - {"to_string", &grib_accessor_class_to_string}, -#line 53 "accessor_class_list.gperf" - {"data_apply_gdsnotpresent", &grib_accessor_class_data_apply_gdsnotpresent}, - {""}, #line 51 "accessor_class_list.gperf" - {"data_apply_boustrophedonic", &grib_accessor_class_data_apply_boustrophedonic}, - {""}, -#line 56 "accessor_class_list.gperf" - {"data_constant_field", &grib_accessor_class_data_constant_field}, -#line 64 "accessor_class_list.gperf" - {"data_g1shsimple_packing", &grib_accessor_class_data_g1shsimple_packing}, -#line 130 "accessor_class_list.gperf" - {"gts_header", &grib_accessor_class_gts_header}, - {""}, -#line 55 "accessor_class_list.gperf" - {"data_complex_packing", &grib_accessor_class_data_complex_packing}, -#line 52 "accessor_class_list.gperf" {"data_apply_boustrophedonic_bitmap", &grib_accessor_class_data_apply_boustrophedonic_bitmap}, -#line 122 "accessor_class_list.gperf" +#line 115 "accessor_class_list.gperf" + {"g2end_step", &grib_accessor_class_g2end_step}, +#line 70 "accessor_class_list.gperf" + {"data_g2simple_packing", &grib_accessor_class_data_g2simple_packing}, +#line 67 "accessor_class_list.gperf" + {"data_g2complex_packing", &grib_accessor_class_data_g2complex_packing}, +#line 176 "accessor_class_list.gperf" + {"padding", &grib_accessor_class_padding}, +#line 210 "accessor_class_list.gperf" + {"time", &grib_accessor_class_time}, + {""}, +#line 211 "accessor_class_list.gperf" + {"times", &grib_accessor_class_times}, +#line 119 "accessor_class_list.gperf" + {"g2lon", &grib_accessor_class_g2lon}, + {""}, {""}, {""}, {""}, {""}, {""}, +#line 63 "accessor_class_list.gperf" + {"data_g1shsimple_packing", &grib_accessor_class_data_g1shsimple_packing}, +#line 110 "accessor_class_list.gperf" + {"g2_eps", &grib_accessor_class_g2_eps}, + {""}, {""}, {""}, +#line 163 "accessor_class_list.gperf" + {"nearest", &grib_accessor_class_nearest}, +#line 71 "accessor_class_list.gperf" + {"data_g2simple_packing_with_preprocessing", &grib_accessor_class_data_g2simple_packing_with_preprocessing}, + {""}, {""}, {""}, {""}, +#line 94 "accessor_class_list.gperf" + {"g1area", &grib_accessor_class_g1area}, +#line 186 "accessor_class_list.gperf" + {"scale", &grib_accessor_class_scale}, +#line 207 "accessor_class_list.gperf" + {"step_in_units", &grib_accessor_class_step_in_units}, +#line 55 "accessor_class_list.gperf" + {"data_constant_field", &grib_accessor_class_data_constant_field}, +#line 54 "accessor_class_list.gperf" + {"data_complex_packing", &grib_accessor_class_data_complex_packing}, +#line 121 "accessor_class_list.gperf" {"g2step_range", &grib_accessor_class_g2step_range}, +#line 64 "accessor_class_list.gperf" + {"data_g1simple_packing", &grib_accessor_class_data_g1simple_packing}, +#line 57 "accessor_class_list.gperf" + {"data_g1complex_packing", &grib_accessor_class_data_g1complex_packing}, {""}, #line 177 "accessor_class_list.gperf" - {"padding", &grib_accessor_class_padding}, + {"padto", &grib_accessor_class_padto}, {""}, -#line 214 "accessor_class_list.gperf" - {"to_integer", &grib_accessor_class_to_integer}, -#line 71 "accessor_class_list.gperf" - {"data_g2simple_packing", &grib_accessor_class_data_g2simple_packing}, -#line 68 "accessor_class_list.gperf" - {"data_g2complex_packing", &grib_accessor_class_data_g2complex_packing}, -#line 97 "accessor_class_list.gperf" - {"g1date", &grib_accessor_class_g1date}, -#line 95 "accessor_class_list.gperf" - {"g1area", &grib_accessor_class_g1area}, -#line 96 "accessor_class_list.gperf" - {"g1bitmap", &grib_accessor_class_g1bitmap}, - {""}, {""}, {""}, {""}, {""}, -#line 209 "accessor_class_list.gperf" - {"sum", &grib_accessor_class_sum}, -#line 69 "accessor_class_list.gperf" - {"data_g2secondary_bitmap", &grib_accessor_class_data_g2secondary_bitmap}, -#line 67 "accessor_class_list.gperf" - {"data_g2bifourier_packing", &grib_accessor_class_data_g2bifourier_packing}, -#line 111 "accessor_class_list.gperf" - {"g2_eps", &grib_accessor_class_g2_eps}, -#line 225 "accessor_class_list.gperf" - {"uint8", &grib_accessor_class_uint8}, - {""}, {""}, -#line 93 "accessor_class_list.gperf" - {"g1_message_length", &grib_accessor_class_g1_message_length}, -#line 183 "accessor_class_list.gperf" +#line 182 "accessor_class_list.gperf" {"raw", &grib_accessor_class_raw}, -#line 72 "accessor_class_list.gperf" - {"data_g2simple_packing_with_preprocessing", &grib_accessor_class_data_g2simple_packing_with_preprocessing}, -#line 57 "accessor_class_list.gperf" - {"data_dummy_field", &grib_accessor_class_data_dummy_field}, -#line 218 "accessor_class_list.gperf" - {"trim", &grib_accessor_class_trim}, -#line 78 "accessor_class_list.gperf" - {"data_sh_unpacked", &grib_accessor_class_data_sh_unpacked}, +#line 92 "accessor_class_list.gperf" + {"g1_message_length", &grib_accessor_class_g1_message_length}, +#line 53 "accessor_class_list.gperf" + {"data_ccsds_packing", &grib_accessor_class_data_ccsds_packing}, {""}, #line 15 "accessor_class_list.gperf" {"assert", &grib_accessor_class_assert}, -#line 221 "accessor_class_list.gperf" - {"uint32", &grib_accessor_class_uint32}, -#line 118 "accessor_class_list.gperf" - {"g2latlon", &grib_accessor_class_g2latlon}, -#line 79 "accessor_class_list.gperf" - {"data_shsimple_packing", &grib_accessor_class_data_shsimple_packing}, -#line 207 "accessor_class_list.gperf" - {"step_human_readable", &grib_accessor_class_step_human_readable}, -#line 109 "accessor_class_list.gperf" - {"g2_aerosol", &grib_accessor_class_g2_aerosol}, -#line 178 "accessor_class_list.gperf" - {"padto", &grib_accessor_class_padto}, -#line 145 "accessor_class_list.gperf" - {"julian_day", &grib_accessor_class_julian_day}, -#line 216 "accessor_class_list.gperf" - {"transient", &grib_accessor_class_transient}, + {""}, {""}, {""}, {""}, +#line 104 "accessor_class_list.gperf" + {"g1p1p2", &grib_accessor_class_g1p1p2}, +#line 68 "accessor_class_list.gperf" + {"data_g2secondary_bitmap", &grib_accessor_class_data_g2secondary_bitmap}, +#line 66 "accessor_class_list.gperf" + {"data_g2bifourier_packing", &grib_accessor_class_data_g2bifourier_packing}, +#line 114 "accessor_class_list.gperf" + {"g2date", &grib_accessor_class_g2date}, {""}, -#line 223 "accessor_class_list.gperf" - {"uint64", &grib_accessor_class_uint64}, -#line 144 "accessor_class_list.gperf" - {"julian_date", &grib_accessor_class_julian_date}, - {""}, -#line 107 "accessor_class_list.gperf" - {"g1step_range", &grib_accessor_class_g1step_range}, -#line 94 "accessor_class_list.gperf" - {"g1_section4_length", &grib_accessor_class_g1_section4_length}, -#line 217 "accessor_class_list.gperf" - {"transient_darray", &grib_accessor_class_transient_darray}, -#line 184 "accessor_class_list.gperf" +#line 112 "accessor_class_list.gperf" + {"g2bitmap", &grib_accessor_class_g2bitmap}, +#line 164 "accessor_class_list.gperf" + {"non_alpha", &grib_accessor_class_non_alpha}, +#line 183 "accessor_class_list.gperf" {"rdbtime_guess_date", &grib_accessor_class_rdbtime_guess_date}, +#line 208 "accessor_class_list.gperf" + {"sum", &grib_accessor_class_sum}, + {""}, +#line 224 "accessor_class_list.gperf" + {"uint8", &grib_accessor_class_uint8}, +#line 220 "accessor_class_list.gperf" + {"uint32", &grib_accessor_class_uint32}, + {""}, {""}, {""}, +#line 106 "accessor_class_list.gperf" + {"g1step_range", &grib_accessor_class_g1step_range}, +#line 193 "accessor_class_list.gperf" + {"select_step_template", &grib_accessor_class_select_step_template}, +#line 108 "accessor_class_list.gperf" + {"g2_aerosol", &grib_accessor_class_g2_aerosol}, +#line 124 "accessor_class_list.gperf" + {"gds_not_present_bitmap", &grib_accessor_class_gds_not_present_bitmap}, +#line 204 "accessor_class_list.gperf" + {"statistics", &grib_accessor_class_statistics}, +#line 56 "accessor_class_list.gperf" + {"data_dummy_field", &grib_accessor_class_data_dummy_field}, +#line 144 "accessor_class_list.gperf" + {"julian_day", &grib_accessor_class_julian_day}, +#line 143 "accessor_class_list.gperf" + {"julian_date", &grib_accessor_class_julian_date}, +#line 13 "accessor_class_list.gperf" + {"array", &grib_accessor_class_array}, + {""}, {""}, +#line 142 "accessor_class_list.gperf" + {"iterator", &grib_accessor_class_iterator}, + {""}, +#line 205 "accessor_class_list.gperf" + {"statistics_spectral", &grib_accessor_class_statistics_spectral}, +#line 12 "accessor_class_list.gperf" + {"apply_operators", &grib_accessor_class_apply_operators}, + {""}, +#line 62 "accessor_class_list.gperf" + {"data_g1secondary_bitmap", &grib_accessor_class_data_g1secondary_bitmap}, + {""}, +#line 96 "accessor_class_list.gperf" + {"g1date", &grib_accessor_class_g1date}, + {""}, +#line 95 "accessor_class_list.gperf" + {"g1bitmap", &grib_accessor_class_g1bitmap}, +#line 122 "accessor_class_list.gperf" + {"gaussian_grid_name", &grib_accessor_class_gaussian_grid_name}, + {""}, {""}, #line 222 "accessor_class_list.gperf" - {"uint32_little_endian", &grib_accessor_class_uint32_little_endian}, -#line 65 "accessor_class_list.gperf" - {"data_g1simple_packing", &grib_accessor_class_data_g1simple_packing}, + {"uint64", &grib_accessor_class_uint64}, +#line 213 "accessor_class_list.gperf" + {"to_integer", &grib_accessor_class_to_integer}, + {""}, +#line 128 "accessor_class_list.gperf" + {"group", &grib_accessor_class_group}, +#line 60 "accessor_class_list.gperf" + {"data_g1second_order_general_packing", &grib_accessor_class_data_g1second_order_general_packing}, + {""}, +#line 217 "accessor_class_list.gperf" + {"trim", &grib_accessor_class_trim}, +#line 61 "accessor_class_list.gperf" + {"data_g1second_order_row_by_row_packing", &grib_accessor_class_data_g1second_order_row_by_row_packing}, + {""}, {""}, {""}, #line 58 "accessor_class_list.gperf" - {"data_g1complex_packing", &grib_accessor_class_data_g1complex_packing}, + {"data_g1second_order_constant_width_packing", &grib_accessor_class_data_g1second_order_constant_width_packing}, +#line 215 "accessor_class_list.gperf" + {"transient", &grib_accessor_class_transient}, +#line 59 "accessor_class_list.gperf" + {"data_g1second_order_general_extended_packing", &grib_accessor_class_data_g1second_order_general_extended_packing}, +#line 166 "accessor_class_list.gperf" + {"number_of_points", &grib_accessor_class_number_of_points}, +#line 227 "accessor_class_list.gperf" + {"unsigned", &grib_accessor_class_unsigned}, +#line 218 "accessor_class_list.gperf" + {"uint16", &grib_accessor_class_uint16}, +#line 185 "accessor_class_list.gperf" + {"round", &grib_accessor_class_round}, +#line 147 "accessor_class_list.gperf" + {"laplacian", &grib_accessor_class_laplacian}, +#line 216 "accessor_class_list.gperf" + {"transient_darray", &grib_accessor_class_transient_darray}, +#line 234 "accessor_class_list.gperf" + {"when", &grib_accessor_class_when}, +#line 228 "accessor_class_list.gperf" + {"unsigned_bits", &grib_accessor_class_unsigned_bits}, +#line 203 "accessor_class_list.gperf" + {"sprintf", &grib_accessor_class_sprintf}, +#line 167 "accessor_class_list.gperf" + {"number_of_points_gaussian", &grib_accessor_class_number_of_points_gaussian}, #line 16 "accessor_class_list.gperf" {"bit", &grib_accessor_class_bit}, #line 18 "accessor_class_list.gperf" {"bits", &grib_accessor_class_bits}, - {""}, +#line 145 "accessor_class_list.gperf" + {"ksec1expver", &grib_accessor_class_ksec1expver}, #line 17 "accessor_class_list.gperf" {"bitmap", &grib_accessor_class_bitmap}, -#line 165 "accessor_class_list.gperf" - {"non_alpha", &grib_accessor_class_non_alpha}, - {""}, -#line 224 "accessor_class_list.gperf" - {"uint64_little_endian", &grib_accessor_class_uint64_little_endian}, - {""}, {""}, -#line 63 "accessor_class_list.gperf" - {"data_g1secondary_bitmap", &grib_accessor_class_data_g1secondary_bitmap}, - {""}, -#line 105 "accessor_class_list.gperf" - {"g1p1p2", &grib_accessor_class_g1p1p2}, - {""}, -#line 228 "accessor_class_list.gperf" - {"unsigned", &grib_accessor_class_unsigned}, -#line 19 "accessor_class_list.gperf" - {"bits_per_value", &grib_accessor_class_bits_per_value}, - {""}, {""}, {""}, {""}, -#line 229 "accessor_class_list.gperf" - {"unsigned_bits", &grib_accessor_class_unsigned_bits}, -#line 123 "accessor_class_list.gperf" - {"gaussian_grid_name", &grib_accessor_class_gaussian_grid_name}, -#line 61 "accessor_class_list.gperf" - {"data_g1second_order_general_packing", &grib_accessor_class_data_g1second_order_general_packing}, -#line 102 "accessor_class_list.gperf" - {"g1monthlydate", &grib_accessor_class_g1monthlydate}, - {""}, -#line 62 "accessor_class_list.gperf" - {"data_g1second_order_row_by_row_packing", &grib_accessor_class_data_g1second_order_row_by_row_packing}, - {""}, -#line 131 "accessor_class_list.gperf" - {"hash_array", &grib_accessor_class_hash_array}, -#line 219 "accessor_class_list.gperf" - {"uint16", &grib_accessor_class_uint16}, -#line 59 "accessor_class_list.gperf" - {"data_g1second_order_constant_width_packing", &grib_accessor_class_data_g1second_order_constant_width_packing}, - {""}, -#line 60 "accessor_class_list.gperf" - {"data_g1second_order_general_extended_packing", &grib_accessor_class_data_g1second_order_general_extended_packing}, - {""}, {""}, {""}, {""}, -#line 114 "accessor_class_list.gperf" - {"g2bitmap_present", &grib_accessor_class_g2bitmap_present}, -#line 13 "accessor_class_list.gperf" - {"array", &grib_accessor_class_array}, -#line 148 "accessor_class_list.gperf" - {"laplacian", &grib_accessor_class_laplacian}, -#line 149 "accessor_class_list.gperf" - {"latitudes", &grib_accessor_class_latitudes}, - {""}, -#line 186 "accessor_class_list.gperf" - {"round", &grib_accessor_class_round}, - {""}, -#line 86 "accessor_class_list.gperf" - {"element", &grib_accessor_class_element}, -#line 220 "accessor_class_list.gperf" - {"uint16_little_endian", &grib_accessor_class_uint16_little_endian}, - {""}, {""}, -#line 146 "accessor_class_list.gperf" - {"ksec1expver", &grib_accessor_class_ksec1expver}, - {""}, -#line 167 "accessor_class_list.gperf" - {"number_of_points", &grib_accessor_class_number_of_points}, - {""}, -#line 203 "accessor_class_list.gperf" - {"spectral_truncation", &grib_accessor_class_spectral_truncation}, -#line 198 "accessor_class_list.gperf" - {"simple_packing_error", &grib_accessor_class_simple_packing_error}, - {""}, -#line 99 "accessor_class_list.gperf" - {"g1end_of_interval_monthly", &grib_accessor_class_g1end_of_interval_monthly}, -#line 48 "accessor_class_list.gperf" +#line 231 "accessor_class_list.gperf" + {"values", &grib_accessor_class_values}, +#line 117 "accessor_class_list.gperf" + {"g2latlon", &grib_accessor_class_g2latlon}, +#line 93 "accessor_class_list.gperf" + {"g1_section4_length", &grib_accessor_class_g1_section4_length}, +#line 47 "accessor_class_list.gperf" {"data_2order_packing", &grib_accessor_class_data_2order_packing}, -#line 181 "accessor_class_list.gperf" - {"position", &grib_accessor_class_position}, -#line 12 "accessor_class_list.gperf" - {"apply_operators", &grib_accessor_class_apply_operators}, -#line 168 "accessor_class_list.gperf" - {"number_of_points_gaussian", &grib_accessor_class_number_of_points_gaussian}, {""}, -#line 129 "accessor_class_list.gperf" - {"group", &grib_accessor_class_group}, -#line 49 "accessor_class_list.gperf" - {"data_2order_packing_count", &grib_accessor_class_data_2order_packing_count}, -#line 112 "accessor_class_list.gperf" - {"g2_mars_labeling", &grib_accessor_class_g2_mars_labeling}, -#line 187 "accessor_class_list.gperf" - {"scale", &grib_accessor_class_scale}, -#line 21 "accessor_class_list.gperf" - {"box", &grib_accessor_class_box}, -#line 36 "accessor_class_list.gperf" - {"bytes", &grib_accessor_class_bytes}, -#line 226 "accessor_class_list.gperf" +#line 225 "accessor_class_list.gperf" {"unexpanded_descriptors", &grib_accessor_class_unexpanded_descriptors}, {""}, -#line 182 "accessor_class_list.gperf" - {"proj_string", &grib_accessor_class_proj_string}, +#line 19 "accessor_class_list.gperf" + {"bits_per_value", &grib_accessor_class_bits_per_value}, +#line 98 "accessor_class_list.gperf" + {"g1end_of_interval_monthly", &grib_accessor_class_g1end_of_interval_monthly}, +#line 48 "accessor_class_list.gperf" + {"data_2order_packing_count", &grib_accessor_class_data_2order_packing_count}, +#line 206 "accessor_class_list.gperf" + {"step_human_readable", &grib_accessor_class_step_human_readable}, +#line 221 "accessor_class_list.gperf" + {"uint32_little_endian", &grib_accessor_class_uint32_little_endian}, {""}, -#line 54 "accessor_class_list.gperf" - {"data_ccsds_packing", &grib_accessor_class_data_ccsds_packing}, -#line 84 "accessor_class_list.gperf" - {"divdouble", &grib_accessor_class_divdouble}, - {""}, -#line 232 "accessor_class_list.gperf" - {"values", &grib_accessor_class_values}, -#line 128 "accessor_class_list.gperf" - {"global_gaussian", &grib_accessor_class_global_gaussian}, - {""}, {""}, {""}, {""}, -#line 230 "accessor_class_list.gperf" - {"validity_date", &grib_accessor_class_validity_date}, -#line 231 "accessor_class_list.gperf" - {"validity_time", &grib_accessor_class_validity_time}, - {""}, {""}, -#line 160 "accessor_class_list.gperf" - {"md5", &grib_accessor_class_md5}, -#line 195 "accessor_class_list.gperf" - {"sexagesimal2decimal", &grib_accessor_class_sexagesimal2decimal}, - {""}, -#line 210 "accessor_class_list.gperf" - {"suppressed", &grib_accessor_class_suppressed}, - {""}, {""}, {""}, -#line 158 "accessor_class_list.gperf" - {"mars_param", &grib_accessor_class_mars_param}, -#line 159 "accessor_class_list.gperf" - {"mars_step", &grib_accessor_class_mars_step}, - {""}, -#line 161 "accessor_class_list.gperf" - {"message", &grib_accessor_class_message}, -#line 132 "accessor_class_list.gperf" - {"headers_only", &grib_accessor_class_headers_only}, - {""}, -#line 154 "accessor_class_list.gperf" - {"long", &grib_accessor_class_long}, - {""}, -#line 85 "accessor_class_list.gperf" - {"double", &grib_accessor_class_double}, - {""}, -#line 92 "accessor_class_list.gperf" - {"g1_increment", &grib_accessor_class_g1_increment}, -#line 200 "accessor_class_list.gperf" - {"smart_table", &grib_accessor_class_smart_table}, - {""}, {""}, -#line 24 "accessor_class_list.gperf" - {"bufr_data", &grib_accessor_class_bufr_data}, -#line 22 "accessor_class_list.gperf" - {"budgdate", &grib_accessor_class_budgdate}, - {""}, {""}, -#line 201 "accessor_class_list.gperf" - {"smart_table_column", &grib_accessor_class_smart_table_column}, - {""}, -#line 25 "accessor_class_list.gperf" - {"bufr_data_array", &grib_accessor_class_bufr_data_array}, +#line 214 "accessor_class_list.gperf" + {"to_string", &grib_accessor_class_to_string}, +#line 202 "accessor_class_list.gperf" + {"spectral_truncation", &grib_accessor_class_spectral_truncation}, #line 77 "accessor_class_list.gperf" - {"data_sh_packed", &grib_accessor_class_data_sh_packed}, + {"data_sh_unpacked", &grib_accessor_class_data_sh_unpacked}, +#line 197 "accessor_class_list.gperf" + {"simple_packing_error", &grib_accessor_class_simple_packing_error}, {""}, {""}, {""}, -#line 26 "accessor_class_list.gperf" - {"bufr_data_element", &grib_accessor_class_bufr_data_element}, - {""}, -#line 163 "accessor_class_list.gperf" - {"missing", &grib_accessor_class_missing}, - {""}, -#line 33 "accessor_class_list.gperf" - {"bufr_simple_thinning", &grib_accessor_class_bufr_simple_thinning}, - {""}, -#line 89 "accessor_class_list.gperf" - {"forward", &grib_accessor_class_forward}, -#line 35 "accessor_class_list.gperf" - {"bufrdc_expanded_descriptors", &grib_accessor_class_bufrdc_expanded_descriptors}, +#line 78 "accessor_class_list.gperf" + {"data_shsimple_packing", &grib_accessor_class_data_shsimple_packing}, {""}, {""}, -#line 100 "accessor_class_list.gperf" +#line 88 "accessor_class_list.gperf" + {"forward", &grib_accessor_class_forward}, +#line 99 "accessor_class_list.gperf" {"g1fcperiod", &grib_accessor_class_g1fcperiod}, -#line 32 "accessor_class_list.gperf" - {"bufr_has_delayed_replication", &grib_accessor_class_bufr_has_delayed_replication}, -#line 134 "accessor_class_list.gperf" +#line 127 "accessor_class_list.gperf" + {"global_gaussian", &grib_accessor_class_global_gaussian}, +#line 133 "accessor_class_list.gperf" {"ieeefloat", &grib_accessor_class_ieeefloat}, -#line 43 "accessor_class_list.gperf" - {"concept", &grib_accessor_class_concept}, -#line 204 "accessor_class_list.gperf" - {"sprintf", &grib_accessor_class_sprintf}, - {""}, -#line 173 "accessor_class_list.gperf" +#line 172 "accessor_class_list.gperf" {"offset_file", &grib_accessor_class_offset_file}, +#line 35 "accessor_class_list.gperf" + {"bytes", &grib_accessor_class_bytes}, {""}, #line 194 "accessor_class_list.gperf" - {"select_step_template", &grib_accessor_class_select_step_template}, - {""}, {""}, -#line 213 "accessor_class_list.gperf" - {"to_double", &grib_accessor_class_to_double}, -#line 234 "accessor_class_list.gperf" - {"vector", &grib_accessor_class_vector}, - {""}, {""}, -#line 44 "accessor_class_list.gperf" - {"constant", &grib_accessor_class_constant}, - {""}, -#line 98 "accessor_class_list.gperf" - {"g1day_of_the_year_date", &grib_accessor_class_g1day_of_the_year_date}, -#line 34 "accessor_class_list.gperf" - {"bufr_string_values", &grib_accessor_class_bufr_string_values}, - {""}, {""}, {""}, {""}, -#line 180 "accessor_class_list.gperf" - {"padtomultiple", &grib_accessor_class_padtomultiple}, - {""}, {""}, {""}, {""}, -#line 162 "accessor_class_list.gperf" - {"message_copy", &grib_accessor_class_message_copy}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 91 "accessor_class_list.gperf" - {"g1_half_byte_codeflag", &grib_accessor_class_g1_half_byte_codeflag}, - {""}, {""}, -#line 37 "accessor_class_list.gperf" - {"change_scanning_direction", &grib_accessor_class_change_scanning_direction}, - {""}, -#line 20 "accessor_class_list.gperf" - {"blob", &grib_accessor_class_blob}, - {""}, {""}, {""}, {""}, -#line 133 "accessor_class_list.gperf" - {"ibmfloat", &grib_accessor_class_ibmfloat}, - {""}, {""}, {""}, -#line 87 "accessor_class_list.gperf" - {"evaluate", &grib_accessor_class_evaluate}, - {""}, {""}, {""}, {""}, -#line 171 "accessor_class_list.gperf" - {"octahedral_gaussian", &grib_accessor_class_octahedral_gaussian}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 166 "accessor_class_list.gperf" - {"number_of_coded_values", &grib_accessor_class_number_of_coded_values}, - {""}, {""}, -#line 179 "accessor_class_list.gperf" - {"padtoeven", &grib_accessor_class_padtoeven}, - {""}, {""}, -#line 169 "accessor_class_list.gperf" - {"number_of_values", &grib_accessor_class_number_of_values}, -#line 157 "accessor_class_list.gperf" - {"lookup", &grib_accessor_class_lookup}, - {""}, -#line 147 "accessor_class_list.gperf" - {"label", &grib_accessor_class_label}, - {""}, {""}, -#line 156 "accessor_class_list.gperf" - {"longitudes", &grib_accessor_class_longitudes}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, -#line 170 "accessor_class_list.gperf" - {"number_of_values_data_raw_packing", &grib_accessor_class_number_of_values_data_raw_packing}, -#line 152 "accessor_class_list.gperf" - {"library_version", &grib_accessor_class_library_version}, -#line 31 "accessor_class_list.gperf" - {"bufr_group", &grib_accessor_class_bufr_group}, -#line 155 "accessor_class_list.gperf" - {"long_vector", &grib_accessor_class_long_vector}, - {""}, -#line 150 "accessor_class_list.gperf" - {"latlon_increment", &grib_accessor_class_latlon_increment}, - {""}, {""}, {""}, {""}, {""}, {""}, -#line 135 "accessor_class_list.gperf" - {"ifs_param", &grib_accessor_class_ifs_param}, - {""}, {""}, {""}, -#line 174 "accessor_class_list.gperf" - {"offset_values", &grib_accessor_class_offset_values}, -#line 38 "accessor_class_list.gperf" - {"check_internal_version", &grib_accessor_class_check_internal_version}, - {""}, {""}, {""}, -#line 175 "accessor_class_list.gperf" - {"pack_bufr_values", &grib_accessor_class_pack_bufr_values}, - {""}, {""}, {""}, -#line 233 "accessor_class_list.gperf" - {"variable", &grib_accessor_class_variable}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 139 "accessor_class_list.gperf" - {"int32_little_endian", &grib_accessor_class_int32_little_endian}, - {""}, {""}, -#line 141 "accessor_class_list.gperf" - {"int64_little_endian", &grib_accessor_class_int64_little_endian}, - {""}, -#line 137 "accessor_class_list.gperf" - {"int16_little_endian", &grib_accessor_class_int16_little_endian}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, -#line 40 "accessor_class_list.gperf" - {"codetable", &grib_accessor_class_codetable}, - {""}, {""}, {""}, {""}, {""}, -#line 108 "accessor_class_list.gperf" - {"g1verificationdate", &grib_accessor_class_g1verificationdate}, -#line 81 "accessor_class_list.gperf" - {"decimal_precision", &grib_accessor_class_decimal_precision}, -#line 41 "accessor_class_list.gperf" - {"codetable_title", &grib_accessor_class_codetable_title}, - {""}, {""}, {""}, {""}, -#line 188 "accessor_class_list.gperf" - {"scale_values", &grib_accessor_class_scale_values}, - {""}, {""}, -#line 23 "accessor_class_list.gperf" - {"bufr_clear_tables", &grib_accessor_class_bufr_clear_tables}, - {""}, {""}, {""}, {""}, -#line 119 "accessor_class_list.gperf" - {"g2level", &grib_accessor_class_g2level}, - {""}, -#line 106 "accessor_class_list.gperf" - {"g1param", &grib_accessor_class_g1param}, - {""}, {""}, -#line 153 "accessor_class_list.gperf" - {"local_definition", &grib_accessor_class_local_definition}, - {""}, {""}, {""}, -#line 227 "accessor_class_list.gperf" - {"unpack_bufr_values", &grib_accessor_class_unpack_bufr_values}, - {""}, -#line 27 "accessor_class_list.gperf" - {"bufr_elements_table", &grib_accessor_class_bufr_elements_table}, - {""}, {""}, -#line 47 "accessor_class_list.gperf" - {"count_total", &grib_accessor_class_count_total}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 30 "accessor_class_list.gperf" - {"bufr_extract_subsets", &grib_accessor_class_bufr_extract_subsets}, - {""}, {""}, -#line 151 "accessor_class_list.gperf" - {"latlonvalues", &grib_accessor_class_latlonvalues}, - {""}, -#line 28 "accessor_class_list.gperf" - {"bufr_extract_area_subsets", &grib_accessor_class_bufr_extract_area_subsets}, -#line 39 "accessor_class_list.gperf" - {"codeflag", &grib_accessor_class_codeflag}, - {""}, -#line 11 "accessor_class_list.gperf" - {"abstract_vector", &grib_accessor_class_abstract_vector}, -#line 29 "accessor_class_list.gperf" - {"bufr_extract_datetime_subsets", &grib_accessor_class_bufr_extract_datetime_subsets}, -#line 45 "accessor_class_list.gperf" - {"count_file", &grib_accessor_class_count_file}, - {""}, {""}, {""}, {""}, -#line 185 "accessor_class_list.gperf" - {"reference_value_error", &grib_accessor_class_reference_value_error}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 110 "accessor_class_list.gperf" - {"g2_chemical", &grib_accessor_class_g2_chemical}, - {""}, -#line 46 "accessor_class_list.gperf" - {"count_missing", &grib_accessor_class_count_missing}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, + {"sexagesimal2decimal", &grib_accessor_class_sexagesimal2decimal}, #line 42 "accessor_class_list.gperf" - {"codetable_units", &grib_accessor_class_codetable_units}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, -#line 90 "accessor_class_list.gperf" - {"from_scale_factor_scaled_value", &grib_accessor_class_from_scale_factor_scaled_value}, -#line 10 "accessor_class_list.gperf" - {"abstract_long_vector", &grib_accessor_class_abstract_long_vector}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, -#line 104 "accessor_class_list.gperf" - {"g1number_of_coded_values_sh_simple", &grib_accessor_class_g1number_of_coded_values_sh_simple}, -#line 103 "accessor_class_list.gperf" - {"g1number_of_coded_values_sh_complex", &grib_accessor_class_g1number_of_coded_values_sh_complex}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, -#line 172 "accessor_class_list.gperf" - {"octect_number", &grib_accessor_class_octect_number}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {"concept", &grib_accessor_class_concept}, +#line 91 "accessor_class_list.gperf" + {"g1_increment", &grib_accessor_class_g1_increment}, +#line 113 "accessor_class_list.gperf" + {"g2bitmap_present", &grib_accessor_class_g2bitmap_present}, +#line 181 "accessor_class_list.gperf" + {"proj_string", &grib_accessor_class_proj_string}, + {""}, +#line 209 "accessor_class_list.gperf" + {"suppressed", &grib_accessor_class_suppressed}, + {""}, {""}, +#line 223 "accessor_class_list.gperf" + {"uint64_little_endian", &grib_accessor_class_uint64_little_endian}, +#line 85 "accessor_class_list.gperf" + {"element", &grib_accessor_class_element}, +#line 180 "accessor_class_list.gperf" + {"position", &grib_accessor_class_position}, +#line 148 "accessor_class_list.gperf" + {"latitudes", &grib_accessor_class_latitudes}, + {""}, +#line 159 "accessor_class_list.gperf" + {"md5", &grib_accessor_class_md5}, +#line 43 "accessor_class_list.gperf" + {"constant", &grib_accessor_class_constant}, +#line 165 "accessor_class_list.gperf" + {"number_of_coded_values", &grib_accessor_class_number_of_coded_values}, +#line 153 "accessor_class_list.gperf" + {"long", &grib_accessor_class_long}, +#line 160 "accessor_class_list.gperf" + {"message", &grib_accessor_class_message}, +#line 84 "accessor_class_list.gperf" + {"double", &grib_accessor_class_double}, + {""}, +#line 157 "accessor_class_list.gperf" + {"mars_param", &grib_accessor_class_mars_param}, +#line 111 "accessor_class_list.gperf" + {"g2_mars_labeling", &grib_accessor_class_g2_mars_labeling}, +#line 179 "accessor_class_list.gperf" + {"padtomultiple", &grib_accessor_class_padtomultiple}, + {""}, +#line 219 "accessor_class_list.gperf" + {"uint16_little_endian", &grib_accessor_class_uint16_little_endian}, + {""}, {""}, +#line 21 "accessor_class_list.gperf" + {"box", &grib_accessor_class_box}, + {""}, +#line 229 "accessor_class_list.gperf" + {"validity_date", &grib_accessor_class_validity_date}, +#line 230 "accessor_class_list.gperf" + {"validity_time", &grib_accessor_class_validity_time}, + {""}, +#line 233 "accessor_class_list.gperf" + {"vector", &grib_accessor_class_vector}, + {""}, +#line 83 "accessor_class_list.gperf" + {"divdouble", &grib_accessor_class_divdouble}, + {""}, +#line 76 "accessor_class_list.gperf" + {"data_sh_packed", &grib_accessor_class_data_sh_packed}, + {""}, {""}, +#line 134 "accessor_class_list.gperf" + {"ifs_param", &grib_accessor_class_ifs_param}, +#line 129 "accessor_class_list.gperf" + {"gts_header", &grib_accessor_class_gts_header}, + {""}, +#line 161 "accessor_class_list.gperf" + {"message_copy", &grib_accessor_class_message_copy}, + {""}, {""}, +#line 130 "accessor_class_list.gperf" + {"hash_array", &grib_accessor_class_hash_array}, {""}, #line 101 "accessor_class_list.gperf" - {"g1forecastmonth", &grib_accessor_class_g1forecastmonth} + {"g1monthlydate", &grib_accessor_class_g1monthlydate}, +#line 162 "accessor_class_list.gperf" + {"missing", &grib_accessor_class_missing}, + {""}, +#line 187 "accessor_class_list.gperf" + {"scale_values", &grib_accessor_class_scale_values}, + {""}, {""}, {""}, {""}, +#line 178 "accessor_class_list.gperf" + {"padtoeven", &grib_accessor_class_padtoeven}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, +#line 38 "accessor_class_list.gperf" + {"codeflag", &grib_accessor_class_codeflag}, + {""}, +#line 90 "accessor_class_list.gperf" + {"g1_half_byte_codeflag", &grib_accessor_class_g1_half_byte_codeflag}, + {""}, {""}, +#line 158 "accessor_class_list.gperf" + {"mars_step", &grib_accessor_class_mars_step}, + {""}, {""}, {""}, {""}, {""}, {""}, +#line 24 "accessor_class_list.gperf" + {"bufr_data_array", &grib_accessor_class_bufr_data_array}, + {""}, +#line 25 "accessor_class_list.gperf" + {"bufr_data_element", &grib_accessor_class_bufr_data_element}, +#line 151 "accessor_class_list.gperf" + {"library_version", &grib_accessor_class_library_version}, + {""}, {""}, +#line 32 "accessor_class_list.gperf" + {"bufr_simple_thinning", &grib_accessor_class_bufr_simple_thinning}, + {""}, {""}, {""}, +#line 36 "accessor_class_list.gperf" + {"change_scanning_direction", &grib_accessor_class_change_scanning_direction}, + {""}, +#line 34 "accessor_class_list.gperf" + {"bufrdc_expanded_descriptors", &grib_accessor_class_bufrdc_expanded_descriptors}, +#line 31 "accessor_class_list.gperf" + {"bufr_has_delayed_replication", &grib_accessor_class_bufr_has_delayed_replication}, + {""}, {""}, +#line 168 "accessor_class_list.gperf" + {"number_of_values", &grib_accessor_class_number_of_values}, + {""}, {""}, +#line 226 "accessor_class_list.gperf" + {"unpack_bufr_values", &grib_accessor_class_unpack_bufr_values}, + {""}, +#line 146 "accessor_class_list.gperf" + {"label", &grib_accessor_class_label}, +#line 173 "accessor_class_list.gperf" + {"offset_values", &grib_accessor_class_offset_values}, +#line 174 "accessor_class_list.gperf" + {"pack_bufr_values", &grib_accessor_class_pack_bufr_values}, + {""}, +#line 170 "accessor_class_list.gperf" + {"octahedral_gaussian", &grib_accessor_class_octahedral_gaussian}, + {""}, {""}, +#line 131 "accessor_class_list.gperf" + {"headers_only", &grib_accessor_class_headers_only}, + {""}, {""}, +#line 154 "accessor_class_list.gperf" + {"long_vector", &grib_accessor_class_long_vector}, +#line 20 "accessor_class_list.gperf" + {"blob", &grib_accessor_class_blob}, +#line 169 "accessor_class_list.gperf" + {"number_of_values_data_raw_packing", &grib_accessor_class_number_of_values_data_raw_packing}, +#line 89 "accessor_class_list.gperf" + {"from_scale_factor_scaled_value", &grib_accessor_class_from_scale_factor_scaled_value}, + {""}, +#line 149 "accessor_class_list.gperf" + {"latlon_increment", &grib_accessor_class_latlon_increment}, +#line 132 "accessor_class_list.gperf" + {"ibmfloat", &grib_accessor_class_ibmfloat}, +#line 232 "accessor_class_list.gperf" + {"variable", &grib_accessor_class_variable}, + {""}, {""}, {""}, +#line 156 "accessor_class_list.gperf" + {"lookup", &grib_accessor_class_lookup}, +#line 44 "accessor_class_list.gperf" + {"count_file", &grib_accessor_class_count_file}, + {""}, {""}, +#line 22 "accessor_class_list.gperf" + {"budgdate", &grib_accessor_class_budgdate}, +#line 155 "accessor_class_list.gperf" + {"longitudes", &grib_accessor_class_longitudes}, +#line 86 "accessor_class_list.gperf" + {"evaluate", &grib_accessor_class_evaluate}, +#line 199 "accessor_class_list.gperf" + {"smart_table", &grib_accessor_class_smart_table}, + {""}, {""}, {""}, {""}, {""}, {""}, +#line 200 "accessor_class_list.gperf" + {"smart_table_column", &grib_accessor_class_smart_table_column}, +#line 97 "accessor_class_list.gperf" + {"g1day_of_the_year_date", &grib_accessor_class_g1day_of_the_year_date}, +#line 11 "accessor_class_list.gperf" + {"abstract_vector", &grib_accessor_class_abstract_vector}, + {""}, {""}, {""}, {""}, +#line 138 "accessor_class_list.gperf" + {"int32_little_endian", &grib_accessor_class_int32_little_endian}, + {""}, {""}, {""}, +#line 37 "accessor_class_list.gperf" + {"check_internal_version", &grib_accessor_class_check_internal_version}, + {""}, {""}, +#line 212 "accessor_class_list.gperf" + {"to_double", &grib_accessor_class_to_double}, + {""}, {""}, +#line 140 "accessor_class_list.gperf" + {"int64_little_endian", &grib_accessor_class_int64_little_endian}, +#line 107 "accessor_class_list.gperf" + {"g1verificationdate", &grib_accessor_class_g1verificationdate}, + {""}, {""}, +#line 136 "accessor_class_list.gperf" + {"int16_little_endian", &grib_accessor_class_int16_little_endian}, + {""}, {""}, +#line 118 "accessor_class_list.gperf" + {"g2level", &grib_accessor_class_g2level}, +#line 39 "accessor_class_list.gperf" + {"codetable", &grib_accessor_class_codetable}, +#line 30 "accessor_class_list.gperf" + {"bufr_group", &grib_accessor_class_bufr_group}, + {""}, {""}, +#line 33 "accessor_class_list.gperf" + {"bufr_string_values", &grib_accessor_class_bufr_string_values}, +#line 29 "accessor_class_list.gperf" + {"bufr_extract_subsets", &grib_accessor_class_bufr_extract_subsets}, + {""}, {""}, {""}, {""}, +#line 27 "accessor_class_list.gperf" + {"bufr_extract_area_subsets", &grib_accessor_class_bufr_extract_area_subsets}, +#line 184 "accessor_class_list.gperf" + {"reference_value_error", &grib_accessor_class_reference_value_error}, + {""}, +#line 80 "accessor_class_list.gperf" + {"decimal_precision", &grib_accessor_class_decimal_precision}, +#line 28 "accessor_class_list.gperf" + {"bufr_extract_datetime_subsets", &grib_accessor_class_bufr_extract_datetime_subsets}, + {""}, {""}, +#line 105 "accessor_class_list.gperf" + {"g1param", &grib_accessor_class_g1param}, + {""}, {""}, {""}, {""}, {""}, {""}, +#line 150 "accessor_class_list.gperf" + {"latlonvalues", &grib_accessor_class_latlonvalues}, +#line 171 "accessor_class_list.gperf" + {"octect_number", &grib_accessor_class_octect_number}, + {""}, +#line 152 "accessor_class_list.gperf" + {"local_definition", &grib_accessor_class_local_definition}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, +#line 46 "accessor_class_list.gperf" + {"count_total", &grib_accessor_class_count_total}, + {""}, +#line 10 "accessor_class_list.gperf" + {"abstract_long_vector", &grib_accessor_class_abstract_long_vector}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, +#line 45 "accessor_class_list.gperf" + {"count_missing", &grib_accessor_class_count_missing}, + {""}, {""}, {""}, {""}, +#line 40 "accessor_class_list.gperf" + {"codetable_title", &grib_accessor_class_codetable_title}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, +#line 23 "accessor_class_list.gperf" + {"bufr_clear_tables", &grib_accessor_class_bufr_clear_tables}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, +#line 103 "accessor_class_list.gperf" + {"g1number_of_coded_values_sh_simple", &grib_accessor_class_g1number_of_coded_values_sh_simple}, +#line 102 "accessor_class_list.gperf" + {"g1number_of_coded_values_sh_complex", &grib_accessor_class_g1number_of_coded_values_sh_complex}, + {""}, {""}, {""}, {""}, +#line 26 "accessor_class_list.gperf" + {"bufr_elements_table", &grib_accessor_class_bufr_elements_table}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, +#line 100 "accessor_class_list.gperf" + {"g1forecastmonth", &grib_accessor_class_g1forecastmonth}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, +#line 41 "accessor_class_list.gperf" + {"codetable_units", &grib_accessor_class_codetable_units}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, +#line 109 "accessor_class_list.gperf" + {"g2_chemical", &grib_accessor_class_g2_chemical} }; static const struct accessor_class_hash * diff --git a/src/grib_accessor_factory.h b/src/grib_accessor_factory.h index e53058a17..7495fdd58 100644 --- a/src/grib_accessor_factory.h +++ b/src/grib_accessor_factory.h @@ -13,7 +13,6 @@ { "box", &grib_accessor_class_box, }, { "budgdate", &grib_accessor_class_budgdate, }, { "bufr_clear_tables", &grib_accessor_class_bufr_clear_tables, }, -{ "bufr_data", &grib_accessor_class_bufr_data, }, { "bufr_data_array", &grib_accessor_class_bufr_data_array, }, { "bufr_data_element", &grib_accessor_class_bufr_data_element, }, { "bufr_elements_table", &grib_accessor_class_bufr_elements_table, }, diff --git a/src/grib_accessor_factory_hash_list b/src/grib_accessor_factory_hash_list index 80aee104d..a900c1bff 100644 --- a/src/grib_accessor_factory_hash_list +++ b/src/grib_accessor_factory_hash_list @@ -14,7 +14,6 @@ blob, &grib_accessor_class_blob box, &grib_accessor_class_box budgdate, &grib_accessor_class_budgdate bufr_clear_tables, &grib_accessor_class_bufr_clear_tables -bufr_data, &grib_accessor_class_bufr_data bufr_data_array, &grib_accessor_class_bufr_data_array bufr_data_element, &grib_accessor_class_bufr_data_element bufr_elements_table, &grib_accessor_class_bufr_elements_table diff --git a/src/grib_api_internal.h b/src/grib_api_internal.h index d9f4d3b87..1bce88538 100644 --- a/src/grib_api_internal.h +++ b/src/grib_api_internal.h @@ -820,8 +820,8 @@ struct bufr_descriptor int Y; int type; /*char* name; Not needed: All usage commented out. See ECC-489 */ - char* shortName; - char* units; + char shortName[128]; + char units[128]; long scale; double factor; long reference; diff --git a/src/grib_api_prototypes.h b/src/grib_api_prototypes.h index 129df97dd..627d90244 100644 --- a/src/grib_api_prototypes.h +++ b/src/grib_api_prototypes.h @@ -274,8 +274,6 @@ size_t grib_viarray_used_size(grib_viarray* v); /* grib_accessor_class_bits_per_value.c */ -/* grib_accessor_class_bufr_data.c */ - /* grib_accessor_class_bufr_clear_tables.c */ /* grib_accessor_class_bufr_data_array.c */ @@ -1227,7 +1225,7 @@ grib_handle* bufr_external_template(grib_context* c, const char* name); char* grib_external_template_path(grib_context* c, const char* name); /* grib_dependency.c */ -grib_handle* grib_handle_of_accessor(grib_accessor* a); +grib_handle* grib_handle_of_accessor(const grib_accessor* a); void grib_dependency_add(grib_accessor* observer, grib_accessor* observed); void grib_dependency_remove_observed(grib_accessor* observed); int _grib_dependency_notify_change(grib_handle* h, grib_accessor* observed); diff --git a/src/grib_bufr_descriptor.c b/src/grib_bufr_descriptor.c index 5a2549b5b..9518786e5 100644 --- a/src/grib_bufr_descriptor.c +++ b/src/grib_bufr_descriptor.c @@ -35,8 +35,8 @@ bufr_descriptor* grib_bufr_descriptor_clone(bufr_descriptor* d) cd->X = d->X; cd->Y = d->Y; /* cd->name=grib_context_strdup(d->context,d->name); See ECC-489 */ - cd->shortName = grib_context_strdup(d->context, d->shortName); - cd->units = grib_context_strdup(d->context, d->units); + strcpy(cd->shortName, d->shortName); + strcpy(cd->units, d->units); cd->scale = d->scale; cd->factor = d->factor; cd->width = d->width; @@ -50,14 +50,11 @@ bufr_descriptor* grib_bufr_descriptor_clone(bufr_descriptor* d) int grib_bufr_descriptor_set_code(grib_accessor* tables_accessor, int code, bufr_descriptor* v) { int err = 0; - grib_context* c; bufr_descriptor* d; if (!v) return GRIB_NULL_POINTER; - c = v->context; - if (v->type == BUFR_DESCRIPTOR_TYPE_REPLICATION || v->type == BUFR_DESCRIPTOR_TYPE_OPERATOR) { v->code = code; v->F = code / 100000; @@ -74,10 +71,10 @@ int grib_bufr_descriptor_set_code(grib_accessor* tables_accessor, int code, bufr v->Y = d->Y; /* grib_context_free(c,v->name); See ECC-489 */ /* v->name=grib_context_strdup(c,d->name); See ECC-489 */ - grib_context_free(c, v->shortName); - v->shortName = grib_context_strdup(c, d->shortName); - grib_context_free(c, v->units); - v->units = grib_context_strdup(c, d->units); + + strcpy(v->shortName,d->shortName); + strcpy(v->units,d->units); + v->scale = d->scale; v->factor = d->factor; v->width = d->width; @@ -130,7 +127,5 @@ void grib_bufr_descriptor_delete(bufr_descriptor* v) c = v->context; /* grib_context_free(c,v->name); See ECC-489 */ - grib_context_free(c, v->shortName); - grib_context_free(c, v->units); grib_context_free(c, v); } diff --git a/src/grib_context.c b/src/grib_context.c index 350ad0a1a..5feeb6f66 100644 --- a/src/grib_context.c +++ b/src/grib_context.c @@ -607,9 +607,7 @@ grib_context* grib_context_new(grib_context* parent) static char* resolve_path(grib_context* c, char* path) { char* result = NULL; -#ifdef ECCODES_ON_WINDOWS - result = grib_context_strdup(c, path); -#else +#if defined(ECCODES_HAVE_REALPATH) char resolved[ECC_PATH_MAXLEN + 1]; if (!realpath(path, resolved)) { result = grib_context_strdup(c, path); /* Failed to resolve. Use original path */ @@ -617,7 +615,10 @@ static char* resolve_path(grib_context* c, char* path) else { result = grib_context_strdup(c, resolved); } +#else + result = grib_context_strdup(c, path); #endif + return result; } diff --git a/src/grib_dependency.c b/src/grib_dependency.c index 2935a22ae..08647b3ad 100644 --- a/src/grib_dependency.c +++ b/src/grib_dependency.c @@ -15,7 +15,7 @@ ***************************************************************************/ #include "grib_api_internal.h" -grib_handle* grib_handle_of_accessor(grib_accessor* a) +grib_handle* grib_handle_of_accessor(const grib_accessor* a) { if (a->parent == NULL) { return a->h; diff --git a/src/grib_expression.c b/src/grib_expression.c index 43dcde427..57801fac8 100644 --- a/src/grib_expression.c +++ b/src/grib_expression.c @@ -89,13 +89,15 @@ void grib_expression_print(grib_context* ctx, grib_expression* g, grib_handle* f void grib_expression_free(grib_context* ctx, grib_expression* g) { - grib_expression_class* c = g->cclass; - while (c) { - if (c->destroy) - c->destroy(ctx, g); - c = c->super ? *(c->super) : NULL; + if (g) { + grib_expression_class* c = g->cclass; + while (c) { + if (c->destroy) + c->destroy(ctx, g); + c = c->super ? *(c->super) : NULL; + } + grib_context_free_persistent(ctx, g); } - grib_context_free_persistent(ctx, g); } void grib_expression_add_dependency(grib_expression* e, grib_accessor* observer) diff --git a/src/grib_ieeefloat.c b/src/grib_ieeefloat.c index 5e8851895..3c393110b 100644 --- a/src/grib_ieeefloat.c +++ b/src/grib_ieeefloat.c @@ -442,22 +442,22 @@ unsigned long grib_ieee_to_long(double x) * Byte swapping is actually implemented in grib_decode_unsigned_long and * grib_encode_unsigned_long. */ - unsigned long grib_ieee64_to_long(double x) { unsigned long lval; - memcpy(&lval, &x, 8); + DebugAssert(sizeof(double) == sizeof(long)); + memcpy(&lval, &x, sizeof(long)); return lval; } double grib_long_to_ieee64(unsigned long x) { double dval; - memcpy(&dval, &x, 8); + DebugAssert(sizeof(double) == sizeof(long)); + memcpy(&dval, &x, sizeof(long)); return dval; } - int grib_ieee_decode_array(grib_context* c, unsigned char* buf, size_t nvals, int bytes, double* val) { int err = 0, i = 0, j = 0; diff --git a/src/grib_trie_with_rank.c b/src/grib_trie_with_rank.c index 93859a9a7..978499f99 100644 --- a/src/grib_trie_with_rank.c +++ b/src/grib_trie_with_rank.c @@ -358,25 +358,27 @@ static void grib_trie_with_rank_delete_container_list(grib_context* c,grib_trie_ } */ +static void _grib_trie_with_rank_delete_container(grib_trie_with_rank* t) +{ + int i; + DebugAssert(t); + for (i = t->first; i <= t->last; i++) + if (t->next[i]) { + grib_trie_with_rank_delete_container(t->next[i]); + } + grib_oarray_delete(t->context, t->objs); + /* grib_trie_with_rank_delete_container_list(t->context,t->list); */ +#ifdef RECYCLE_TRIE + grib_context_free_persistent(t->context, t); +#else + grib_context_free(t->context, t); +#endif +} void grib_trie_with_rank_delete_container(grib_trie_with_rank* t) { GRIB_MUTEX_INIT_ONCE(&once, &init); GRIB_MUTEX_LOCK(&mutex); - DebugAssert(t); - { - int i; - for (i = t->first; i <= t->last; i++) - if (t->next[i]) { - grib_trie_with_rank_delete_container(t->next[i]); - } - grib_oarray_delete(t->context, t->objs); - /* grib_trie_with_rank_delete_container_list(t->context,t->list); */ -#ifdef RECYCLE_TRIE - grib_context_free_persistent(t->context, t); -#else - grib_context_free(t->context, t); -#endif - } + _grib_trie_with_rank_delete_container(t); GRIB_MUTEX_UNLOCK(&mutex); } @@ -452,11 +454,8 @@ int grib_trie_with_rank_insert(grib_trie_with_rank* t, const char* key, void* da { grib_trie_with_rank* last = t; const char* k = key; - - if (!t) { - Assert(!"grib_trie_with_rank_insert: grib_trie==NULL"); - return -1; - } + DebugAssert(t); + if (!t) return -1; GRIB_MUTEX_INIT_ONCE(&once, &init); GRIB_MUTEX_LOCK(&mutex); @@ -487,7 +486,7 @@ int grib_trie_with_rank_insert(grib_trie_with_rank* t, const char* key, void* da grib_oarray_push(t->context, t->objs, data); /* grib_trie_with_rank_insert_in_list(t,data); */ GRIB_MUTEX_UNLOCK(&mutex); - return grib_oarray_used_size(t->objs); + return t->objs->n; /* grib_oarray_used_size(t->objs) */ } /* diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 96170b788..d013f2466 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -9,32 +9,33 @@ execute_process( COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_S # Build the executables used by test scripts ################################################ -list( APPEND test_bins - grib_bpv_limit - grib_double_cmp - read_any - julian - grib_indexing - grib_multi_from_message - grib_read_index - unit_tests - bufr_keys_iter - gauss_sub - grib_nearest_test - grib_util_set_spec - grib_local_MeteoFrance - grib_2nd_order_numValues - grib_optimize_scaling - grib_optimize_scaling_sh - grib_ecc-386 - bufr_ecc-517 - bufr_get_element - bufr_extract_headers - grib_sh_ieee64 - ieee - grib_sh_imag - grib_lam_bf - grib_lam_gp ) +list(APPEND test_bins + grib_bpv_limit + grib_double_cmp + read_any + julian + grib_indexing + grib_multi_from_message + grib_read_index + unit_tests + bufr_keys_iter + gauss_sub + grib_nearest_test + grib_util_set_spec + grib_local_MeteoFrance + grib_2nd_order_numValues + grib_optimize_scaling + grib_optimize_scaling_sh + grib_ecc-386 + bufr_ecc-517 + bufr_get_element + bufr_extract_headers + bufr_check_descriptors + grib_sh_ieee64 + ieee + grib_sh_imag + grib_lam_bf + grib_lam_gp) foreach( tool ${test_bins} ) # here we use the fact that each tool has only one C file that matches its name @@ -46,293 +47,315 @@ endforeach() # Now add each test (shell scripts) ################################################# -# These tests do not require any data downloads -list(APPEND tests_no_data_reqd - unit_tests - julian - grib_dump_samples - bufr_dump_samples - definitions - grib_calendar - grib_md5 - filter_substr - grib_uerra - grib_2nd_order_numValues - grib_ecc-136 - grib_ecc-967 - grib_ecc-1065 - grib_ecc-1053 - bufr_json_samples - bufr_ecc-359 - bufr_ecc-517 - bufr_rdbSubTypes - grib_efas - grib_sh_imag - pseudo_diag - grib_grid_lambert_conformal - grib_grid_polar_stereographic - grib_grid_space_view - grib_g1fcperiod) +if( HAVE_BUILD_TOOLS ) -# These tests do require data downloads -list(APPEND tests_data_reqd - grib_data_quality_checks - grib_bpv_limit - grib_complex - grib_double_cmp - grib_change_packing - bufr_dump_data - bufr_dump_descriptors - bufr_dump_subset - bufr_dump_decode_filter - bufr_dump_encode_filter - bufrdc_desc_ref - bufrdc_ref - bufr_compare - bufr_copy - bufr_count - bufr_get - bufr_filter - bufr_filter_extract_datetime - bufr_filter_extract_area - bufr_json_data - bufr_ls - bufr_ls_json - bufr_change_edition - bufr_keys_iter - bufr_get_element - bufr_wmo_tables - bufr_extract_headers - bufr_ecc-673 - bufr_ecc-428 - bufr_ecc-286 - bufr_ecc-288 - bufr_ecc-313 - bufr_ecc-616 - bufr_ecc-686 - bufr_ecc-690 - bufr_ecc-379 - bufr_ecc-393 - bufr_ecc-433 - bufr_ecc-750 - bufr_ecc-765 - bufr_ecc-875 - bufr_ecc-887 - grib_ecc-490 - grib_ecc-756 - grib_ecc-873 - grib_ecc-600 - grib_ecc-923 - grib_ecc-979 - grib_ecc-984 - grib_ecc-1000 - grib_ecc-1001 - grib_ecc-1030 - bufr_ecc-556 - gts_get - gts_ls - gts_count - gts_compare - metar_ls - metar_get - metar_dump - metar_compare - bufr_set - ieee - grib_sh_ieee64 - grib_optimize_scaling - grib_optimize_scaling_sh - grib_lam_bf - grib_lam_gp - grib1to2 - grib2to1 - grib1to3 - grib2to3 - grib3_templates - badgrib - grib_ls - grib_ls_json - grib_filter - grib_multi - grib_nearest_test - pseudo_budg - grib_gridType - grib_octahedral - grib_grid_mercator - grib_global - grib_concept - grib_decimalPrecision - grib_bitsPerValue - grib_get_fail - grib_missing - grib_local - grib_step - grib_set - grib_iterator - grib_proj_string - grib_compare - grib_copy - grib_level - grib_indexing - grib_bitmap - grib_list - grib_second_order - grib_multi_from_message - grib_change_scanning - grib_statistics - grib_tigge - read_any - grib_dump - grib_dump_debug - grib_dump_json - grib_local_MeteoFrance - grib_neg_fctime - codes_split_file - grib_mars_types) + # These tests do not require any data downloads + list(APPEND tests_no_data_reqd + unit_tests + julian + grib_dump_samples + bufr_dump_samples + bufr_check_descriptors + definitions + grib_calendar + grib_md5 + filter_substr + grib_uerra + grib_2nd_order_numValues + grib_ecc-136 + grib_ecc-967 + grib_ecc-1065 + grib_ecc-1053 + bufr_json_samples + bufr_ecc-359 + bufr_ecc-517 + bufr_rdbSubTypes + grib_efas + grib_sh_imag + pseudo_diag + grib_grid_unstructured + grib_grid_lambert_conformal + grib_grid_polar_stereographic + grib_grid_space_view + grib_g1fcperiod) -if( HAVE_FORTRAN AND ENABLE_EXTRA_TESTS ) - list(APPEND tests_data_reqd bufr_dump_encode_fortran) - list(APPEND tests_data_reqd bufr_dump_decode_fortran) -endif() -if( ENABLE_EXTRA_TESTS ) - list(APPEND tests_data_reqd grib_util_set_spec) - list(APPEND tests_data_reqd grib_padding) - list(APPEND tests_data_reqd grib_tigge_conversions) - list(APPEND tests_data_reqd bufr_dump_encode_C) - list(APPEND tests_data_reqd bufr_dump_decode_C) -endif() + # These tests do require data downloads + list(APPEND tests_data_reqd + grib_data_quality_checks + grib_bpv_limit + grib_complex + grib_double_cmp + grib_change_packing + bufr_dump_data + bufr_dump_descriptors + bufr_dump_subset + bufr_dump_decode_filter + bufr_dump_encode_filter + bufrdc_desc_ref + bufrdc_ref + bufr_compare + bufr_copy + bufr_count + bufr_get + bufr_filter + bufr_filter_extract_datetime + bufr_filter_extract_area + bufr_json_data + bufr_ls + bufr_ls_json + bufr_change_edition + bufr_keys_iter + bufr_get_element + bufr_wmo_tables + bufr_extract_headers + bufr_ecc-673 + bufr_ecc-428 + bufr_ecc-286 + bufr_ecc-288 + bufr_ecc-313 + bufr_ecc-616 + bufr_ecc-686 + bufr_ecc-690 + bufr_ecc-379 + bufr_ecc-393 + bufr_ecc-433 + bufr_ecc-750 + bufr_ecc-765 + bufr_ecc-875 + bufr_ecc-887 + grib_ecc-490 + grib_ecc-756 + grib_ecc-873 + grib_ecc-600 + grib_ecc-923 + grib_ecc-979 + grib_ecc-984 + grib_ecc-1000 + grib_ecc-1001 + grib_ecc-1030 + bufr_ecc-556 + gts_get + gts_ls + gts_count + gts_compare + metar_ls + metar_get + metar_dump + metar_compare + bufr_set + ieee + grib_sh_ieee64 + grib_optimize_scaling + grib_optimize_scaling_sh + grib_lam_bf + grib_lam_gp + grib1to2 + grib2to1 + grib1to3 + grib2to3 + grib3_templates + badgrib + grib_ls + grib_ls_json + grib_filter + grib_multi + grib_nearest_test + pseudo_budg + grib_gridType + grib_octahedral + grib_grid_mercator + grib_global + grib_concept + grib_decimalPrecision + grib_bitsPerValue + grib_get_fail + grib_missing + grib_local + grib_step + grib_set + grib_iterator + grib_proj_string + grib_compare + grib_copy + grib_level + grib_indexing + grib_bitmap + grib_list + grib_second_order + grib_multi_from_message + grib_change_scanning + grib_statistics + grib_tigge + read_any + grib_dump + grib_dump_debug + grib_dump_json + grib_local_MeteoFrance + grib_neg_fctime + codes_split_file + grib_mars_types) -# These tests do not require any data downloads -foreach( test ${tests_no_data_reqd} ) + if( HAVE_FORTRAN AND ENABLE_EXTRA_TESTS ) + list(APPEND tests_data_reqd bufr_dump_encode_fortran) + list(APPEND tests_data_reqd bufr_dump_decode_fortran) + endif() + if( ENABLE_EXTRA_TESTS ) + list(APPEND tests_data_reqd grib_util_set_spec) + list(APPEND tests_data_reqd grib_padding) + list(APPEND tests_data_reqd grib_tigge_conversions) + list(APPEND tests_data_reqd bufr_dump_encode_C) + list(APPEND tests_data_reqd bufr_dump_decode_C) + endif() + + # These tests do not require any data downloads + foreach( test ${tests_no_data_reqd} ) + ecbuild_add_test( TARGET eccodes_t_${test} + TYPE SCRIPT + LABELS "sanity" + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh ) + endforeach() + ecbuild_add_test( TARGET eccodes_t_grib_check_gaussian_grids + TYPE SCRIPT + CONDITION ECCODES_INSTALL_EXTRA_TOOLS + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_check_gaussian_grids.sh ) + + + # Note: making the test dependent on the grib files (with DEPENDS) + # means they will be downloaded at "make" time + # rather than when you do "ctest". Use TEST_DEPENDS instead + foreach( test ${tests_data_reqd} ) + ecbuild_add_test( TARGET eccodes_t_${test} + TYPE SCRIPT + CONDITION ENABLE_EXTRA_TESTS + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh + RESOURCES asca_139.t1.ref + TEST_DEPENDS eccodes_download_gribs eccodes_download_tigge_gribs + eccodes_download_bufrs eccodes_download_metars eccodes_download_gts ) + endforeach() + + if( HAVE_FORTRAN AND ENABLE_EXTRA_TESTS ) + set_tests_properties( eccodes_t_bufr_dump_encode_fortran PROPERTIES TIMEOUT 2500 ) + endif() + if( ENABLE_EXTRA_TESTS ) + set_tests_properties( eccodes_t_bufr_dump_encode_C PROPERTIES TIMEOUT 2500 ) + endif() + + + if( HAVE_PYTHON AND ENABLE_EXTRA_TESTS ) + list( APPEND ptests bufr_dump_encode_python bufr_dump_decode_python ) + foreach( test ${ptests} ) + ecbuild_add_test( TARGET eccodes_t_${test} + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh + ENVIRONMENT PYTHON=${PYTHON_EXECUTABLE} PYTHONPATH=${PROJECT_BINARY_DIR}/python + TEST_DEPENDS eccodes_download_bufrs ) + endforeach() + endif() + + ########################################### + # Note: the reference file is in the tests dir not data dir! + ecbuild_add_test( TARGET eccodes_t_grib_grid_lamb_az_eq_area + TYPE SCRIPT + CONDITION ENABLE_EXTRA_TESTS + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_grid_lamb_az_eq_area.sh + RESOURCES grib_lamb_az_eq_area.ref + TEST_DEPENDS eccodes_download_gribs ) + + # These ones are conditional + ########################################### + ecbuild_add_test( TARGET eccodes_t_tools_data_from_stdin + TYPE SCRIPT + CONDITION NOT ECCODES_ON_WINDOWS AND ENABLE_EXTRA_TESTS + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools_data_from_stdin.sh + TEST_DEPENDS eccodes_download_bufrs ) + + ecbuild_add_test( TARGET eccodes_t_bufr_ecc-197 + TYPE SCRIPT + CONDITION NOT ECCODES_ON_WINDOWS AND ENABLE_EXTRA_TESTS + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bufr_ecc-197.sh + TEST_DEPENDS eccodes_download_bufrs ) + + if( ENABLE_EXTRA_TESTS AND HAVE_ECCODES_THREADS ) + ecbuild_add_executable( TARGET grib_encode_pthreads + NOINSTALL + SOURCES grib_encode_pthreads.c + LIBS eccodes ) + ecbuild_add_test( TARGET eccodes_t_grib_encode_pthreads + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_encode_pthreads.sh ) + + foreach( test grib_threads_ecc-604 grib_threads_ecc-604-encode bufr_threads_ecc-604 ) + ecbuild_add_executable( TARGET ${test} + NOINSTALL + SOURCES ${test}.c + LIBS eccodes ) + endforeach() + ecbuild_add_test( TARGET eccodes_t_grib_threads_ecc-604 + TYPE SCRIPT + TEST_DEPENDS eccodes_download_gribs + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_threads_ecc-604.sh ) + ecbuild_add_test( TARGET eccodes_t_bufr_threads_ecc-604 + TYPE SCRIPT + TEST_DEPENDS eccodes_download_bufrs + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bufr_threads_ecc-604.sh ) + endif() + + ecbuild_add_test( TARGET eccodes_t_grib_to_netcdf + TYPE SCRIPT + CONDITION HAVE_NETCDF AND ENABLE_EXTRA_TESTS + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_to_netcdf.sh + TEST_DEPENDS eccodes_download_gribs ) + + ecbuild_add_test( TARGET eccodes_t_grib_jpeg + TYPE SCRIPT + CONDITION HAVE_JPEG AND ENABLE_EXTRA_TESTS + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_jpeg.sh + TEST_DEPENDS eccodes_download_gribs ) + + ecbuild_add_test( TARGET eccodes_t_grib_png + TYPE SCRIPT + CONDITION HAVE_PNG AND ENABLE_EXTRA_TESTS + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_png.sh + TEST_DEPENDS eccodes_download_gribs ) + + ecbuild_add_test( TARGET eccodes_t_grib_ccsds + TYPE SCRIPT + CONDITION HAVE_AEC AND ENABLE_EXTRA_TESTS + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_ccsds.sh + TEST_DEPENDS eccodes_download_gribs ) + + ecbuild_add_test( TARGET eccodes_t_grib_check_param_concepts + TYPE SCRIPT + CONDITION ENABLE_EXTRA_TESTS + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_check_param_concepts.sh ) + + ecbuild_add_test( TARGET eccodes_t_bufr_split_by_rdbSubtype + TYPE SCRIPT + CONDITION ENABLE_EXTRA_TESTS AND ECCODES_INSTALL_EXTRA_TOOLS + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bufr_split_by_rdbSubtype.sh + TEST_DEPENDS eccodes_download_bufrs ) + + # Performance test. Must have -DENABLE_GRIB_TIMER=ON + ecbuild_add_test( TARGET eccodes_t_grib_ecc-386 + TYPE SCRIPT + CONDITION ENABLE_EXTRA_TESTS AND ENABLE_GRIB_TIMER + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_ecc-386.sh + TEST_DEPENDS eccodes_download_gribs ) +else() + # No command line tools + list(APPEND tests_no_tools + unit_tests + julian + bufr_check_descriptors + grib_sh_imag + grib_2nd_order_numValues + grib_sh_ieee64) + + foreach( test ${tests_no_tools} ) ecbuild_add_test( TARGET eccodes_t_${test} TYPE SCRIPT LABELS "sanity" COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh ) -endforeach() -ecbuild_add_test( TARGET eccodes_t_grib_check_gaussian_grids - TYPE SCRIPT - CONDITION ECCODES_INSTALL_EXTRA_TOOLS - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_check_gaussian_grids.sh ) - - -# Note: making the test dependent on the grib files (with DEPENDS) -# means they will be downloaded at "make" time -# rather than when you do "ctest". Use TEST_DEPENDS instead -foreach( test ${tests_data_reqd} ) - ecbuild_add_test( TARGET eccodes_t_${test} - TYPE SCRIPT - CONDITION ENABLE_EXTRA_TESTS - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh - RESOURCES asca_139.t1.ref - TEST_DEPENDS eccodes_download_gribs eccodes_download_tigge_gribs - eccodes_download_bufrs eccodes_download_metars eccodes_download_gts ) -endforeach() - -if( HAVE_FORTRAN AND ENABLE_EXTRA_TESTS ) - set_tests_properties( eccodes_t_bufr_dump_encode_fortran PROPERTIES TIMEOUT 2500 ) -endif() -if( ENABLE_EXTRA_TESTS ) - set_tests_properties( eccodes_t_bufr_dump_encode_C PROPERTIES TIMEOUT 2500 ) -endif() - - -if( HAVE_PYTHON AND ENABLE_EXTRA_TESTS ) - list( APPEND ptests bufr_dump_encode_python bufr_dump_decode_python ) - foreach( test ${ptests} ) - ecbuild_add_test( TARGET eccodes_t_${test} - TYPE SCRIPT - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh - ENVIRONMENT PYTHON=${PYTHON_EXECUTABLE} PYTHONPATH=${PROJECT_BINARY_DIR}/python - TEST_DEPENDS eccodes_download_bufrs ) endforeach() + endif() - -########################################### -# Note: the reference file is in the tests dir not data dir! -ecbuild_add_test( TARGET eccodes_t_grib_grid_lamb_az_eq_area - TYPE SCRIPT - CONDITION ENABLE_EXTRA_TESTS - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_grid_lamb_az_eq_area.sh - RESOURCES grib_lamb_az_eq_area.ref - TEST_DEPENDS eccodes_download_gribs ) - -# These ones are conditional -########################################### -ecbuild_add_test( TARGET eccodes_t_tools_data_from_stdin - TYPE SCRIPT - CONDITION NOT ECCODES_ON_WINDOWS AND ENABLE_EXTRA_TESTS - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools_data_from_stdin.sh - TEST_DEPENDS eccodes_download_bufrs ) - -ecbuild_add_test( TARGET eccodes_t_bufr_ecc-197 - TYPE SCRIPT - CONDITION NOT ECCODES_ON_WINDOWS AND ENABLE_EXTRA_TESTS - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bufr_ecc-197.sh - TEST_DEPENDS eccodes_download_bufrs ) - -if( ENABLE_EXTRA_TESTS AND HAVE_ECCODES_THREADS ) - ecbuild_add_executable( TARGET grib_encode_pthreads - NOINSTALL - SOURCES grib_encode_pthreads.c - LIBS eccodes ) - ecbuild_add_test( TARGET eccodes_t_grib_encode_pthreads - TYPE SCRIPT - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_encode_pthreads.sh ) - - foreach( test grib_threads_ecc-604 grib_threads_ecc-604-encode bufr_threads_ecc-604 ) - ecbuild_add_executable( TARGET ${test} - NOINSTALL - SOURCES ${test}.c - LIBS eccodes ) - endforeach() - ecbuild_add_test( TARGET eccodes_t_grib_threads_ecc-604 - TYPE SCRIPT - TEST_DEPENDS eccodes_download_gribs - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_threads_ecc-604.sh ) - ecbuild_add_test( TARGET eccodes_t_bufr_threads_ecc-604 - TYPE SCRIPT - TEST_DEPENDS eccodes_download_bufrs - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bufr_threads_ecc-604.sh ) -endif() - -ecbuild_add_test( TARGET eccodes_t_grib_to_netcdf - TYPE SCRIPT - CONDITION HAVE_NETCDF AND ENABLE_EXTRA_TESTS - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_to_netcdf.sh - TEST_DEPENDS eccodes_download_gribs ) - -ecbuild_add_test( TARGET eccodes_t_grib_jpeg - TYPE SCRIPT - CONDITION HAVE_JPEG AND ENABLE_EXTRA_TESTS - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_jpeg.sh - TEST_DEPENDS eccodes_download_gribs ) - -ecbuild_add_test( TARGET eccodes_t_grib_png - TYPE SCRIPT - CONDITION HAVE_PNG AND ENABLE_EXTRA_TESTS - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_png.sh - TEST_DEPENDS eccodes_download_gribs ) - -ecbuild_add_test( TARGET eccodes_t_grib_ccsds - TYPE SCRIPT - CONDITION HAVE_AEC AND ENABLE_EXTRA_TESTS - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_ccsds.sh - TEST_DEPENDS eccodes_download_gribs ) - -ecbuild_add_test( TARGET eccodes_t_grib_check_param_concepts - TYPE SCRIPT - CONDITION ENABLE_EXTRA_TESTS - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_check_param_concepts.sh ) - -ecbuild_add_test( TARGET eccodes_t_bufr_split_by_rdbSubtype - TYPE SCRIPT - CONDITION ENABLE_EXTRA_TESTS AND ECCODES_INSTALL_EXTRA_TOOLS - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bufr_split_by_rdbSubtype.sh - TEST_DEPENDS eccodes_download_bufrs ) - -# Performance test. Must have -DENABLE_GRIB_TIMER=ON -ecbuild_add_test( TARGET eccodes_t_grib_ecc-386 - TYPE SCRIPT - CONDITION ENABLE_EXTRA_TESTS AND ENABLE_GRIB_TIMER - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_ecc-386.sh - TEST_DEPENDS eccodes_download_gribs ) diff --git a/tests/Makefile.am b/tests/Makefile.am index cd6804d3f..c4fbe532a 100755 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,13 +1,17 @@ TESTS = definitions.sh \ grib_calendar.sh \ + codes_split_file.sh \ bufrdc_desc_ref.sh \ bufrdc_ref.sh \ + grib_data_quality_checks.sh \ bufr_dump_data.sh \ bufr_dump_samples.sh \ + bufr_dump_subset.sh \ bufr_json_samples.sh \ bufr_filter.sh \ bufr_json_data.sh \ bufr_compare.sh \ + bufr_dump_descriptors.sh \ bufr_copy.sh \ bufr_count.sh \ bufr_get.sh \ @@ -32,6 +36,7 @@ TESTS = definitions.sh \ pseudo_budg.sh \ pseudo_diag.sh \ grib_gridType.sh \ + grib_change_packing.sh \ grib_octahedral.sh \ grib_global.sh \ grib_concept.sh \ @@ -62,8 +67,10 @@ TESTS = definitions.sh \ grib_grid_space_view.sh \ grib_grid_polar_stereographic.sh \ grib_grid_mercator.sh \ + grib_grid_unstructured.sh \ grib_to_netcdf.sh \ grib_dump_debug.sh \ + grib_dump_json.sh \ grib_jpeg.sh \ grib_ccsds.sh \ grib_md5.sh \ @@ -99,7 +106,11 @@ TESTS = definitions.sh \ grib_ecc-984.sh \ grib_ecc-1000.sh \ grib_ecc-1001.sh \ - grib_ecc-1030.sh + grib_ecc-1030.sh \ + grib_lam_gp.sh \ + grib_lam_bf.sh \ + bufr_get_element.sh \ + bufr_extract_headers.sh # First download all the necessary data for testing # Note: if download fails, no tests will be done @@ -110,7 +121,8 @@ download_data: noinst_PROGRAMS = packing_check gauss_sub read_any grib_double_cmp packing pack_unpack \ julian grib_read_index grib_indexing gribex_perf\ jpeg_perf grib_ccsds_perf so_perf png_perf grib_bpv_limit laplacian \ - unit_tests bufr_ecc-517 + unit_tests bufr_ecc-517 grib_lam_gp grib_lam_bf grib_sh_imag \ + bufr_extract_headers bufr_get_element laplacian_SOURCES = laplacian.c packing_SOURCES = packing.c @@ -129,6 +141,11 @@ grib_ccsds_perf_SOURCES = grib_ccsds_perf.c gribex_perf_SOURCES = gribex_perf.c gauss_sub_SOURCES = gauss_sub.c bufr_ecc_517_SOURCES = bufr_ecc-517.c +grib_lam_gp_SOURCES = grib_lam_gp.c +grib_lam_bf_SOURCES = grib_lam_bf.c +grib_sh_imag_SOURCES = grib_sh_imag.c +bufr_extract_headers_SOURCES = bufr_extract_headers.c +bufr_get_element_SOURCES = bufr_get_element.c LDADD = $(top_builddir)/src/libeccodes.la $(EMOS_LIB) diff --git a/tests/bufr_check_descriptors.c b/tests/bufr_check_descriptors.c new file mode 100644 index 000000000..e0967e833 --- /dev/null +++ b/tests/bufr_check_descriptors.c @@ -0,0 +1,59 @@ +/* + * (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. + */ + +#include +#include "grib_api_internal.h" + +int main(int argc, char** argv) +{ + char* filename = NULL; + FILE* fp = NULL; + char line[1024] = {0,}; + char** list = NULL; + size_t i = 0, line_number = 0; + char* str_key = NULL; + char* str_units = NULL; + bufr_descriptor v; + const size_t maxlen_keyName = sizeof(v.shortName); + const size_t maxlen_units = sizeof(v.units); + + Assert(argc == 2); + + filename = argv[1]; + fp = fopen(filename, "r"); + Assert(fp); + + while (fgets(line, sizeof(line) - 1, fp)) { + ++line_number; + Assert(strlen(line) > 0); + if (line[0] == '#') continue; /* Ignore first line with column titles */ + list = string_split(line, "|"); + Assert(list); + str_key = list[1]; + str_units = list[4]; + if (strlen(str_key) >= maxlen_keyName) { + fprintf(stderr, "Error on line %lu: bufr_descriptor key name '%s' exceeds %lu characters.\n", + line_number, str_key, maxlen_keyName); + return 1; + } + if (strlen(str_units) >= maxlen_units) { + fprintf(stderr, "Error on line %lu: bufr_descriptor units '%s' exceeds %lu characters.\n", + line_number, str_units, maxlen_units); + return 1; + } + + for (i = 0; list[i] != NULL; ++i) free(list[i]); + free(list); + } + + fclose(fp); + + return 0; +} diff --git a/tests/bufr_check_descriptors.sh b/tests/bufr_check_descriptors.sh new file mode 100755 index 000000000..26274afe4 --- /dev/null +++ b/tests/bufr_check_descriptors.sh @@ -0,0 +1,16 @@ +#!/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. +# + +. ./include.sh + +for file in `find ${ECCODES_DEFINITION_PATH}/bufr/ -name 'element.table' -print` +do + ${test_dir}/bufr_check_descriptors $file +done diff --git a/tests/bufr_ls.sh b/tests/bufr_ls.sh index 01244e0e2..b2abc0fa7 100755 --- a/tests/bufr_ls.sh +++ b/tests/bufr_ls.sh @@ -16,12 +16,9 @@ cd ${data_dir}/bufr # Define a common label for all the tmp files label="bufr_ls_test" -# Create log file fLog=${label}".log" rm -f $fLog touch $fLog - -# Define tmp file fTmp=${label}".tmp.txt" rm -f $fTmp @@ -34,9 +31,9 @@ for f in ${bufr_files} ; do ${tools_dir}/bufr_ls $f >> $fLog done -#------------------------------------------- +#----------------- # Test "-p" switch -#------------------------------------------- +#----------------- f="aaen_55.bufr" ref_ls=$f".ls.ref" res_ls=$f".ls.test" @@ -48,6 +45,17 @@ ${tools_dir}/bufr_ls -p totalLength,bufrHeaderCentre,bufrHeaderSubCentre,masterT awk NR==3 $fTmp | awk '{split($0,a," "); for (i=1; i<=8; i++) print a[i]}' > $res_ls diff $ref_ls $res_ls +# ------------------------ +# Test printing array key +# ------------------------ +set +e +${tools_dir}/bufr_ls -p numericValues $f >$fTmp 2>&1 +status=$? +set -e +[ $status -ne 0 ] +cat $fTmp +grep -q "Passed array is too small" $fTmp + rm -f $fLog $res_ls rm -f $fTmp diff --git a/tests/grib1to2.sh b/tests/grib1to2.sh index cc1123c48..74140cc32 100755 --- a/tests/grib1to2.sh +++ b/tests/grib1to2.sh @@ -80,6 +80,15 @@ if [ -x "${tools_dir}/grib_check_gaussian_grid" ]; then ${tools_dir}/grib_check_gaussian_grid $input $output fi + +echo "ECC-811 Check shapeOfTheEarth..." +# --------------------------------------------------- +sample_g1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl +${tools_dir}/grib_set -s edition=2 $sample_g1 $output +grib_check_key_equals $sample_g1 shapeOfTheEarth 0 +grib_check_key_equals $output shapeOfTheEarth 0 + + rm -f $output #sed "s:toolsdir:${tools_dir}/:" ${tools_dir}/grib1to2.txt > ${tools_dir}/grib1to2.test diff --git a/tests/grib_grid_unstructured.sh b/tests/grib_grid_unstructured.sh new file mode 100755 index 000000000..28ca7b4ba --- /dev/null +++ b/tests/grib_grid_unstructured.sh @@ -0,0 +1,47 @@ +#!/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. +# + +. ./include.sh + +label="grib_grid_unstructured" + +# Only relevant for GRIB2 +sample=$ECCODES_SAMPLES_PATH/GRIB2.tmpl +temp1=temp.1.${label} +temp2=temp.2.${label} + +${tools_dir}/grib_set -s gridType=unstructured_grid,numberOfGridInReference=4,numberOfGridUsed=2 $sample $temp1 +grib_check_key_equals $temp1 'unstructuredGridType' 'ORCA1' +grib_check_key_equals $temp1 'unstructuredGridSubtype' 'W grid' +#grib_check_key_equals $temp1 'unstructuredGridUUID' 'ORCA1 W grid unknown' + +${tools_dir}/grib_set -s gridType=unstructured_grid,unstructuredGridType=ORCA1,unstructuredGridSubtype='W grid' $sample $temp2 +${tools_dir}/grib_compare $temp1 $temp2 +grib_check_key_equals $temp2 'numberOfGridInReference' '4' +grib_check_key_equals $temp2 'numberOfGridUsed' '2' + +# Test some lat/lon parameters +${tools_dir}/grib_set -s paramId=250003 $sample $temp1 +grib_check_key_equals $temp1 'unstructuredGridSubtype' 'T grid' + +${tools_dir}/grib_set -s paramId=250005 $sample $temp1 +grib_check_key_equals $temp1 'unstructuredGridSubtype' 'U grid' + +${tools_dir}/grib_set -s paramId=250007 $sample $temp1 +grib_check_key_equals $temp1 'unstructuredGridSubtype' 'V grid' + +${tools_dir}/grib_set -s paramId=250009 $sample $temp1 +grib_check_key_equals $temp1 'unstructuredGridSubtype' 'W grid' + +${tools_dir}/grib_set -s paramId=250011 $sample $temp1 +grib_check_key_equals $temp1 'unstructuredGridSubtype' 'F grid' + + +rm -f $temp1 $temp2 diff --git a/tests/grib_indexing.c b/tests/grib_indexing.c index 1de587d52..328cb490b 100644 --- a/tests/grib_indexing.c +++ b/tests/grib_indexing.c @@ -153,5 +153,7 @@ int main(int argc, char* argv[]) free(shortNames[i]); free(shortNames); + /*grib_context_delete(grib_context_get_default());*/ + return 0; } diff --git a/tests/grib_util_set_spec.c b/tests/grib_util_set_spec.c index 805fbec69..5f21d940e 100644 --- a/tests/grib_util_set_spec.c +++ b/tests/grib_util_set_spec.c @@ -10,7 +10,6 @@ #include "grib_api_internal.h" #include "eccodes.h" -#include #define STR_EQUAL(s1, s2) (strcmp((s1), (s2)) == 0) @@ -53,20 +52,20 @@ static void test_reduced_gg(int remove_local_def, int edition, const char* packi grib_util_grid_spec spec = {0,}; grib_util_packing_spec packing_spec = {0,}; - assert(input_filename); + Assert(input_filename); in = fopen(input_filename, "rb"); - assert(in); + Assert(in); handle = grib_handle_new_from_file(0, in, &err); - assert(handle); + Assert(handle); CODES_CHECK(grib_get_string(handle, "gridType", gridType, &slen), 0); if (!STR_EQUAL(gridType, "reduced_gg")) { grib_handle_delete(handle); return; } - assert(output_filename); + Assert(output_filename); out = fopen(output_filename, "wb"); - assert(out); + Assert(out); CODES_CHECK(grib_get_size(handle, "values", &inlen), 0); values = (double*)malloc(sizeof(double) * inlen); @@ -108,23 +107,23 @@ static void test_reduced_gg(int remove_local_def, int edition, const char* packi values, outlen, &err); - assert(finalh); - assert(err == 0); + Assert(finalh); + Assert(err == 0); /* Try some invalid inputs and check it is handled */ { codes_handle* h2 = 0; packing_spec.accuracy = 999; h2 = grib_util_set_spec(handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err); - assert(err == GRIB_INTERNAL_ERROR); - assert(!h2); + Assert(err == GRIB_INTERNAL_ERROR); + Assert(!h2); if (h2) exit(1); #ifdef INFINITY packing_spec.accuracy = GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES; values[0] = INFINITY; h2 = grib_util_set_spec(handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err); - assert(err == GRIB_ENCODING_ERROR); - assert(!h2); + Assert(err == GRIB_ENCODING_ERROR); + Assert(!h2); if (h2) exit(1); #endif } @@ -134,7 +133,7 @@ static void test_reduced_gg(int remove_local_def, int edition, const char* packi CODES_CHECK(codes_check_message_header(buffer, size, PRODUCT_GRIB), 0); CODES_CHECK(codes_check_message_footer(buffer, size, PRODUCT_GRIB), 0); if (fwrite(buffer, 1, size, out) != size) { - assert(0); + Assert(0); } grib_handle_delete(handle); grib_handle_delete(finalh); @@ -164,11 +163,11 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi grib_util_grid_spec spec = {0,}; grib_util_packing_spec packing_spec = {0,}; - assert(input_filename); + Assert(input_filename); in = fopen(input_filename, "rb"); - assert(in); + Assert(in); handle = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err); - assert(handle); + Assert(handle); CODES_CHECK(codes_get_long(handle, "edition", &input_edition), 0); @@ -177,9 +176,9 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi grib_handle_delete(handle); return; } - assert(output_filename); + Assert(output_filename); out = fopen(output_filename, "wb"); - assert(out); + Assert(out); CODES_CHECK(codes_get_size(handle, "values", &inlen), 0); values = (double*)malloc(sizeof(double) * inlen); @@ -224,8 +223,8 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi values, outlen, &err); - assert(finalh); - assert(err == 0); + Assert(finalh); + Assert(err == 0); /* Check expand_bounding_box worked. * Specified latitudeOfFirstGridPointInDegrees cannot be encoded in GRIB1 @@ -234,7 +233,7 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi const double expected_lat1 = 60.001; double lat1 = 0; CODES_CHECK(codes_get_double(finalh, "latitudeOfFirstGridPointInDegrees", &lat1), 0); - assert(fabs(lat1 - expected_lat1) < 1e-10); + Assert(fabs(lat1 - expected_lat1) < 1e-10); } /* Write out the message to the output file */ @@ -242,7 +241,7 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi CODES_CHECK(codes_check_message_header(buffer, size, PRODUCT_GRIB), 0); CODES_CHECK(codes_check_message_footer(buffer, size, PRODUCT_GRIB), 0); if (fwrite(buffer, 1, size, out) != size) { - assert(0); + Assert(0); } codes_handle_delete(handle); codes_handle_delete(finalh); @@ -272,15 +271,15 @@ static void test_grid_complex_spatial_differencing(int remove_local_def, int edi grib_util_grid_spec spec={0,}; grib_util_packing_spec packing_spec={0,}; - in = fopen(input_filename,"rb"); assert(in); - handle = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err); assert(handle); + in = fopen(input_filename,"rb"); Assert(in); + handle = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err); Assert(handle); CODES_CHECK(grib_get_string(handle, "packingType", gridType, &slen),0); if (!STR_EQUAL(gridType, "grid_complex_spatial_differencing")) { grib_handle_delete(handle); return; } - out = fopen(output_filename,"wb"); assert(out); + out = fopen(output_filename,"wb"); Assert(out); CODES_CHECK(codes_get_size(handle,"values",&inlen), 0); values = (double*)malloc(sizeof(double)*inlen); @@ -325,13 +324,13 @@ static void test_grid_complex_spatial_differencing(int remove_local_def, int edi values, outlen, &err); - assert(finalh); - assert(err == 0); + Assert(finalh); + Assert(err == 0); /* Write out the message to the output file */ CODES_CHECK(codes_get_message(finalh, &buffer, &size),0); if(fwrite(buffer,1,size,out) != size) { - assert(0); + Assert(0); } codes_handle_delete(handle); codes_handle_delete(finalh); diff --git a/tests/ieee.c b/tests/ieee.c index 3dcd6bf89..1c1595548 100644 --- a/tests/ieee.c +++ b/tests/ieee.c @@ -7,9 +7,7 @@ * 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. */ - #include -#include #include #include "grib_api_internal.h" @@ -95,14 +93,14 @@ int main(int argc, char* argv[]) #if 1 unsigned long i = 0; printf("Test doubles with grib_ieee_to_long/grib_long_to_ieee...\n"); - assert(test_doubles(grib_ieee_to_long, grib_long_to_ieee) == 1); + Assert(test_doubles(grib_ieee_to_long, grib_long_to_ieee) == 1); printf("Test doubles with grib_ieee64_to_long/grib_long_to_ieee64...\n"); - assert(test_doubles(grib_ieee64_to_long, grib_long_to_ieee64) == 1); + Assert(test_doubles(grib_ieee64_to_long, grib_long_to_ieee64) == 1); printf("Test integers...\n"); /* test(3242539564, grib_ieee_to_long, grib_long_to_ieee); This fails! */ - assert(grib_ieee_to_long(grib_long_to_ieee(i)) == i); + Assert(grib_ieee_to_long(grib_long_to_ieee(i)) == i); /* The minimum value for which we can convert a long to ieee and back is 0x800000 */ /* The maximum value for which we can convert a long to ieee and back is 0x7f800000 */ @@ -111,8 +109,8 @@ int main(int argc, char* argv[]) if (grib_ieee_to_long(grib_long_to_ieee(i)) != i) { printf("i=%lu i=%lx e=%g x=%lx\n", i, i, grib_long_to_ieee(i), grib_ieee_to_long(grib_long_to_ieee(i))); - /*assert(grib_ieee_to_long(grib_long_to_ieee(i)) == i);*/ - assert(0); + /*Assert(grib_ieee_to_long(grib_long_to_ieee(i)) == i);*/ + Assert(0); } /*if(grib_ieee_to_long(grib_long_to_ieee(j)) != j) { @@ -133,7 +131,7 @@ int main(int argc, char* argv[]) double c = p(ref1, ref1); double d = p(ref2, ref2); - assert(min < max); + Assert(min < max); #endif printf("ALL DONE\n"); diff --git a/tests/lsan-leap42.supp b/tests/lsan-leap42.supp index d11c22254..8089a595f 100644 --- a/tests/lsan-leap42.supp +++ b/tests/lsan-leap42.supp @@ -1,3 +1,4 @@ leak:process_elements leak:tests/bufr_ecc-517.c leak:src/action_class_rename.c +leak:tests/grib_indexing.c diff --git a/tests/migration_ml.sh b/tests/migration_ml.sh deleted file mode 100755 index 03a2dd36f..000000000 --- a/tests/migration_ml.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -# --- setup the environment -. ./include.sh - -src=${data_dir}/essential_ml/grib1_ecmwf -dest=${data_dir}/essential_ml/grib2_ecmwf - -if [ ! -d $src ]; then - echo "Data source folder does not exist: '$src'" - exit 1 -fi - -mkdir -p $dest - -# --- convert to grib 2 - -for file in `ls $src/*.grib`; do - f=`basename $file` - ${tools_dir}/grib_set -s edition=2 $file $dest/$f - - if [ ! $? == 0 ]; then - echo "FAIL" - exit 1 - fi -done - -# --- compare the results - -set +e # don't fail on error for now -for file in `ls $src/*.grib`; do - name=`basename $file` - echo "Comparing $name" - ${tools_dir}/grib_compare -c mars:n,name,shortName $src/$name $dest/$name -done -set -e diff --git a/tools/bufr_compare.c b/tools/bufr_compare.c index 0768d37c5..3077fee10 100644 --- a/tools/bufr_compare.c +++ b/tools/bufr_compare.c @@ -219,7 +219,7 @@ grib_option grib_options[] = { { "R:", 0, 0, 0, 1, 0 }, { "A:", 0, 0, 0, 1, 0 }, /* {"P",0,"Compare data values using the packing error as tolerance.\n",0,1,0},*/ - { "t:", "factor", "Compare data values using factor multiplied by the tolerance specified in options -P -R -A.\n", 0, 1, 0 }, + { "t:", "factor", "Compare data values using factor multiplied by the tolerance specified in options -R -A.\n", 0, 1, 0 }, { "w:", 0, 0, 0, 1, 0 }, { "f", 0, 0, 0, 1, 0 }, { "F", 0, 0, 1, 0, 0 }, @@ -239,7 +239,7 @@ static int end = -1; const char* tool_description = "Compare BUFR messages contained in two files." "\n\tIf some differences are found it fails returning an error code." - "\n\tFloating-point values are compared exactly by default, different tolerance can be defined see -P -A -R." + "\n\tFloating-point values are compared exactly by default, different tolerances can be defined (see -A -R)." "\n\tDefault behaviour: absolute error=0, bit-by-bit compare, same order in files."; const char* tool_name = "bufr_compare"; diff --git a/tools/grib_compare.c b/tools/grib_compare.c index 9af9b8c9c..8b238272b 100644 --- a/tools/grib_compare.c +++ b/tools/grib_compare.c @@ -168,7 +168,7 @@ static int theEnd = -1; const char* tool_description = "Compare GRIB messages contained in two files." "\n\tIf some differences are found it fails returning an error code." - "\n\tFloating-point values are compared exactly by default, different tolerance can be defined see -P -A -R." + "\n\tFloating-point values are compared exactly by default, different tolerances can be defined (see -P -A -R)." "\n\tDefault behaviour: absolute error=0, bit-by-bit compare, same order in files."; const char* tool_name = "grib_compare"; diff --git a/tools/grib_tools.c b/tools/grib_tools.c index 8a5a4142a..700102f10 100644 --- a/tools/grib_tools.c +++ b/tools/grib_tools.c @@ -1072,6 +1072,9 @@ void grib_print_key_values(grib_runtime_options* options, grib_handle* h) /* ECC-236: Do not use grib_is_missing for BUFR */ if (!grib_is_defined(h, options->print_keys[i].name)) ret = GRIB_NOT_FOUND; + if (ret == GRIB_SUCCESS) { + ret = grib_get_size(h, options->print_keys[i].name, &num_vals); + } if (ret == GRIB_SUCCESS) { if (options->print_keys[i].type == GRIB_TYPE_UNDEFINED) grib_get_native_type(h, options->print_keys[i].name, &(options->print_keys[i].type)); @@ -1083,18 +1086,22 @@ void grib_print_key_values(grib_runtime_options* options, grib_handle* h) sprintf(value, "MISSING"); break; case GRIB_TYPE_DOUBLE: - ret = grib_get_double(h, options->print_keys[i].name, &dvalue); - if (dvalue == GRIB_MISSING_DOUBLE) - sprintf(value, "MISSING"); - else - sprintf(value, options->format, dvalue); + if (num_vals > 1) { + ret = GRIB_ARRAY_TOO_SMALL; + } else { + ret = grib_get_double(h, options->print_keys[i].name, &dvalue); + if (dvalue == GRIB_MISSING_DOUBLE) sprintf(value, "MISSING"); + else sprintf(value, options->format, dvalue); + } break; case GRIB_TYPE_LONG: - ret = grib_get_long(h, options->print_keys[i].name, &lvalue); - if (lvalue == GRIB_MISSING_LONG) - sprintf(value, "MISSING"); - else - sprintf(value, "%ld", lvalue); + if (num_vals > 1) { + ret = GRIB_ARRAY_TOO_SMALL; + } else { + ret = grib_get_long(h, options->print_keys[i].name, &lvalue); + if (lvalue == GRIB_MISSING_LONG) sprintf(value, "MISSING"); + else sprintf(value, "%ld", lvalue); + } break; case GRIB_TYPE_BYTES: ret = grib_get_string(h, options->print_keys[i].name, value, &len); diff --git a/windows/msvc/grib_api_lib/grib_api_lib.vcproj b/windows/msvc/grib_api_lib/grib_api_lib.vcproj index 47c945500..710bff752 100644 --- a/windows/msvc/grib_api_lib/grib_api_lib.vcproj +++ b/windows/msvc/grib_api_lib/grib_api_lib.vcproj @@ -508,10 +508,6 @@ RelativePath="..\..\..\src\grib_accessor_class_bufr_clear_tables.c" > - - diff --git a/windows/msvc/grib_api_lib/grib_api_lib.vcxproj b/windows/msvc/grib_api_lib/grib_api_lib.vcxproj index b4a3525e3..8c1a7fefb 100755 --- a/windows/msvc/grib_api_lib/grib_api_lib.vcxproj +++ b/windows/msvc/grib_api_lib/grib_api_lib.vcxproj @@ -215,7 +215,6 @@ - diff --git a/windows/msvc/grib_api_lib/grib_api_lib.vcxproj.filters b/windows/msvc/grib_api_lib/grib_api_lib.vcxproj.filters index 8e3828e34..dd3f31726 100755 --- a/windows/msvc/grib_api_lib/grib_api_lib.vcxproj.filters +++ b/windows/msvc/grib_api_lib/grib_api_lib.vcxproj.filters @@ -171,9 +171,6 @@ Source Files - - Source Files - Source Files