Merge branch 'develop' into feature/ECC-1136-BUFR-restrict

This commit is contained in:
Shahram Najm 2020-08-28 13:28:25 +01:00
commit 06590ecd42
70 changed files with 1548 additions and 1288 deletions

1
.gitignore vendored
View File

@ -69,6 +69,7 @@ data/bufr/*test
*.sublime-workspace
.idea
.vscode
build/
*.back

View File

@ -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
}

View File

@ -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 )

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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' = {

View File

@ -697,10 +697,10 @@
}
#Snow depth
'sd' = {
localTablesVersion = 1 ;
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 11 ;
unitsFactor = 1000 ;
parameterNumber = 254 ;
}
#Large-scale precipitation
'lsp' = {

View File

@ -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' = {

View File

@ -697,10 +697,10 @@
}
#Snow depth
'141' = {
localTablesVersion = 1 ;
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 11 ;
unitsFactor = 1000 ;
parameterNumber = 254 ;
}
#Large-scale precipitation
'142' = {

View File

@ -697,10 +697,10 @@
}
#Snow depth
'sd' = {
localTablesVersion = 1 ;
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 11 ;
unitsFactor = 1000 ;
parameterNumber = 254 ;
}
#Large-scale precipitation
'lsp' = {

View File

@ -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' = {

View File

@ -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);

View File

@ -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; }

View File

@ -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; }

View File

@ -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";

View File

@ -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;

View File

@ -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;}

View File

@ -0,0 +1,5 @@
'undefined' = { numberOfGridInReference = 0; }
'T grid' = { numberOfGridInReference = 1; }
'U grid' = { numberOfGridInReference = 2; }
'V grid' = { numberOfGridInReference = 3; }
'W grid' = { numberOfGridInReference = 4; }

View File

@ -0,0 +1,5 @@
'undefined' = { numberOfGridUsed = 0; }
'ORCA2' = { numberOfGridUsed = 1; }
'ORCA1' = { numberOfGridUsed = 2; }
'ORCA025' = { numberOfGridUsed = 3; }
'ORCA12' = { numberOfGridUsed = 4; }

View File

@ -0,0 +1 @@
"unknown" = {dummy=0;}

View File

@ -0,0 +1 @@
"unknown" = {dummy=0;}

View File

@ -0,0 +1 @@
"unknown" = {dummy=0;}

View File

@ -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@

View File

@ -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()
########################################################################

View File

@ -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}

View File

@ -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 )

View File

@ -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

View File

@ -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 \

View File

@ -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);

View File

@ -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)

View File

@ -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]);

View File

@ -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;

View File

@ -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];

View File

@ -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]);

View File

@ -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) {

View File

@ -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");

View File

@ -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;
}

View File

@ -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;
}

File diff suppressed because it is too large Load Diff

View File

@ -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, },

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -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) */
}
/*

View File

@ -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 )

View File

@ -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)

View File

@ -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 <assert.h>
#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;
}

16
tests/bufr_check_descriptors.sh Executable file
View File

@ -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

View File

@ -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

View File

@ -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

47
tests/grib_grid_unstructured.sh Executable file
View File

@ -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

View File

@ -153,5 +153,7 @@ int main(int argc, char* argv[])
free(shortNames[i]);
free(shortNames);
/*grib_context_delete(grib_context_get_default());*/
return 0;
}

View File

@ -10,7 +10,6 @@
#include "grib_api_internal.h"
#include "eccodes.h"
#include <assert.h>
#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);

View File

@ -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 <stdio.h>
#include <assert.h>
#include <float.h>
#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");

View File

@ -1,3 +1,4 @@
leak:process_elements
leak:tests/bufr_ecc-517.c
leak:src/action_class_rename.c
leak:tests/grib_indexing.c

View File

@ -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

View File

@ -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";

View File

@ -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";

View File

@ -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);

View File

@ -508,10 +508,6 @@
RelativePath="..\..\..\src\grib_accessor_class_bufr_clear_tables.c"
>
</File>
<File
RelativePath="..\..\..\src\grib_accessor_class_bufr_data.c"
>
</File>
<File
RelativePath="..\..\..\src\grib_accessor_class_bufr_data_array.c"
>

View File

@ -215,7 +215,6 @@
<ClCompile Include="..\..\..\src\grib_accessor_class_budgdate.c" />
<ClCompile Include="..\..\..\src\grib_accessor_class_bufrdc_expanded_descriptors.c" />
<ClCompile Include="..\..\..\src\grib_accessor_class_bufr_clear_tables.c" />
<ClCompile Include="..\..\..\src\grib_accessor_class_bufr_data.c" />
<ClCompile Include="..\..\..\src\grib_accessor_class_bufr_data_array.c" />
<ClCompile Include="..\..\..\src\grib_accessor_class_bufr_data_element.c" />
<ClCompile Include="..\..\..\src\grib_accessor_class_bufr_elements_table.c" />

View File

@ -171,9 +171,6 @@
<ClCompile Include="..\..\..\src\grib_accessor_class_bufr_clear_tables.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\grib_accessor_class_bufr_data.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\grib_accessor_class_bufr_data_array.c">
<Filter>Source Files</Filter>
</ClCompile>