Merge branch 'develop' into feature/OceanInMars

This commit is contained in:
Shahram Najm 2022-02-14 22:13:55 +00:00
commit 509a32607b
97 changed files with 592 additions and 347 deletions

View File

@ -26,22 +26,24 @@ project( eccodes VERSION 2.25.0 LANGUAGES C )
###############################################################################
# system checks needed for eccodes_config.h and some options like MEMFS
check_type_size( int ECCODES_SIZEOF_INT )
check_type_size( long ECCODES_SIZEOF_LONG )
check_type_size( size_t ECCODES_SIZEOF_SIZE_T )
check_type_size( int ECCODES_SIZEOF_INT )
check_type_size( long ECCODES_SIZEOF_LONG )
check_type_size( size_t ECCODES_SIZEOF_SIZE_T )
check_include_files( assert.h ECCODES_HAVE_ASSERT_H )
check_include_files( string.h ECCODES_HAVE_STRING_H )
check_include_files( sys/types.h ECCODES_HAVE_SYS_TYPES_H )
check_include_files( sys/stat.h ECCODES_HAVE_SYS_STAT_H )
check_include_files( fcntl.h ECCODES_HAVE_FCNTL_H )
check_include_files( unistd.h ECCODES_HAVE_UNISTD_H )
check_include_files( assert.h ECCODES_HAVE_ASSERT_H )
check_include_files( string.h ECCODES_HAVE_STRING_H )
check_include_files( sys/types.h ECCODES_HAVE_SYS_TYPES_H )
check_include_files( sys/stat.h ECCODES_HAVE_SYS_STAT_H )
check_include_files( fcntl.h ECCODES_HAVE_FCNTL_H )
check_include_files( unistd.h ECCODES_HAVE_UNISTD_H )
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_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_symbol_exists( fsync "unistd.h" ECCODES_HAVE_FSYNC)
check_symbol_exists( fdatasync "unistd.h" ECCODES_HAVE_FDATASYNC)
check_c_source_compiles(
" typedef int foo_t;

View File

@ -1,7 +1,7 @@
ecmf 165 10u m s**-1 10 metre U wind component
ecmf 166 10v m s**-1 10 metre V wind component
ecmf 59 cape J kg**-1 Convective available potential energy
ecmf 156 gh gpm Geopotential Height
ecmf 156 gh gpm Geopotential height
ecmf 151 msl Pa Mean sea level pressure
ecmf 179 ttr J m**-2 Top net thermal radiation
ecmf 3 pt K Potential temperature
@ -9,8 +9,8 @@ ecmf 60 pv K m**2 kg**-1 s**-1 Potential vorticity
ecmf 235 skt K Skin temperature
ecmf 228141 sd kg m**-2 Snow depth water equivalent
ecmf 228144 sf kg m**-2 Snow Fall water equivalent
ecmf 228039 sm kg m**-3 Soil Moisture
ecmf 228139 st K Soil Temperature
ecmf 228039 sm kg m**-3 Soil moisture
ecmf 228139 st K Soil temperature
ecmf 133 q kg kg**-1 Specific humidity
ecmf 189 sund s Sunshine duration
ecmf 168 2d K 2 metre dewpoint temperature

View File

@ -50,7 +50,7 @@
table2Version = 3 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'geopotential_height' = {
table2Version = 3 ;
indicatorOfParameter = 7 ;
@ -166,7 +166,7 @@
table2Version = 2 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'geopotential_height' = {
table2Version = 2 ;
indicatorOfParameter = 7 ;
@ -282,7 +282,7 @@
table2Version = 1 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'geopotential_height' = {
table2Version = 1 ;
indicatorOfParameter = 7 ;

View File

@ -94,7 +94,7 @@
table2Version = 3 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'gh' = {
table2Version = 3 ;
indicatorOfParameter = 7 ;
@ -668,12 +668,12 @@
indicatorOfParameter = 7 ;
indicatorOfTypeOfLevel = 1 ;
}
#Soil Moisture
#Soil moisture
'sm' = {
table2Version = 3 ;
indicatorOfParameter = 86 ;
}
#Soil Temperature
#Soil temperature
'st' = {
table2Version = 3 ;
indicatorOfParameter = 85 ;
@ -790,7 +790,7 @@
table2Version = 2 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'gh' = {
table2Version = 2 ;
indicatorOfParameter = 7 ;
@ -1349,12 +1349,12 @@
indicatorOfParameter = 7 ;
indicatorOfTypeOfLevel = 1 ;
}
#Soil Moisture
#Soil moisture
'sm' = {
table2Version = 2 ;
indicatorOfParameter = 86 ;
}
#Soil Temperature
#Soil temperature
'st' = {
table2Version = 2 ;
indicatorOfParameter = 85 ;
@ -1471,7 +1471,7 @@
table2Version = 1 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'gh' = {
table2Version = 1 ;
indicatorOfParameter = 7 ;
@ -2030,12 +2030,12 @@
indicatorOfParameter = 7 ;
indicatorOfTypeOfLevel = 1 ;
}
#Soil Moisture
#Soil moisture
'sm' = {
table2Version = 1 ;
indicatorOfParameter = 86 ;
}
#Soil Temperature
#Soil temperature
'st' = {
table2Version = 1 ;
indicatorOfParameter = 85 ;

View File

@ -13,28 +13,25 @@ position offsetBeforeData;
if( bitmapPresent || !GDSPresent ) {
# For grib1 -> grib2
constant bitMapIndicator = 0;
meta codedValues data_raw_packing(
meta codedValues data_raw_packing(
section4Length,
offsetBeforeData,
offsetSection4,
numberOfCodedValues,
precision
);
numberOfValues,
precision);
meta values data_apply_bitmap(codedValues,
bitmap,missingValue,binaryScaleFactor) : dump;
alias data.packedValues = codedValues;
alias data.packedValues = codedValues;
} else {
# For grib1 -> grib2
constant bitMapIndicator = 255;
meta values data_raw_packing(
# For grib1 -> grib2
constant bitMapIndicator = 255;
meta values data_raw_packing(
section4Length,
offsetBeforeData,
offsetSection4,
numberOfCodedValues,
precision
);
alias data.packedValues = values;
precision);
alias data.packedValues = values;
}
meta numberOfCodedValues number_of_values_data_raw_packing(values,precision);

View File

@ -394,7 +394,7 @@
table2Version = 190 ;
indicatorOfParameter = 155 ;
}
#Geopotential Height
#Geopotential height
'geopotential_height' = {
table2Version = 128 ;
indicatorOfParameter = 156 ;

View File

@ -1134,7 +1134,7 @@
table2Version = 190 ;
indicatorOfParameter = 155 ;
}
#Geopotential Height
#Geopotential height
'gh' = {
table2Version = 128 ;
indicatorOfParameter = 156 ;
@ -17239,7 +17239,7 @@
table2Version = 228 ;
indicatorOfParameter = 19 ;
}
#Soil Moisture
#Soil moisture
'sm' = {
table2Version = 228 ;
indicatorOfParameter = 39 ;
@ -17254,7 +17254,7 @@
table2Version = 228 ;
indicatorOfParameter = 132 ;
}
#Soil Temperature
#Soil temperature
'st' = {
table2Version = 228 ;
indicatorOfParameter = 139 ;

View File

@ -1134,8 +1134,8 @@
table2Version = 190 ;
indicatorOfParameter = 155 ;
}
#Geopotential Height
'Geopotential Height' = {
#Geopotential height
'Geopotential height' = {
table2Version = 128 ;
indicatorOfParameter = 156 ;
}
@ -17239,8 +17239,8 @@
table2Version = 228 ;
indicatorOfParameter = 19 ;
}
#Soil Moisture
'Soil Moisture' = {
#Soil moisture
'Soil moisture' = {
table2Version = 228 ;
indicatorOfParameter = 39 ;
}
@ -17254,8 +17254,8 @@
table2Version = 228 ;
indicatorOfParameter = 132 ;
}
#Soil Temperature
'Soil Temperature' = {
#Soil temperature
'Soil temperature' = {
table2Version = 228 ;
indicatorOfParameter = 139 ;
}

View File

@ -1134,7 +1134,7 @@
table2Version = 190 ;
indicatorOfParameter = 155 ;
}
#Geopotential Height
#Geopotential height
'156' = {
table2Version = 128 ;
indicatorOfParameter = 156 ;
@ -17239,7 +17239,7 @@
table2Version = 228 ;
indicatorOfParameter = 19 ;
}
#Soil Moisture
#Soil moisture
'228039' = {
table2Version = 228 ;
indicatorOfParameter = 39 ;
@ -17254,7 +17254,7 @@
table2Version = 228 ;
indicatorOfParameter = 132 ;
}
#Soil Temperature
#Soil temperature
'228139' = {
table2Version = 228 ;
indicatorOfParameter = 139 ;

View File

@ -1134,7 +1134,7 @@
table2Version = 190 ;
indicatorOfParameter = 155 ;
}
#Geopotential Height
#Geopotential height
'gh' = {
table2Version = 128 ;
indicatorOfParameter = 156 ;
@ -17239,7 +17239,7 @@
table2Version = 228 ;
indicatorOfParameter = 19 ;
}
#Soil Moisture
#Soil moisture
'sm' = {
table2Version = 228 ;
indicatorOfParameter = 39 ;
@ -17254,7 +17254,7 @@
table2Version = 228 ;
indicatorOfParameter = 132 ;
}
#Soil Temperature
#Soil temperature
'st' = {
table2Version = 228 ;
indicatorOfParameter = 139 ;

View File

@ -1134,7 +1134,7 @@
table2Version = 190 ;
indicatorOfParameter = 155 ;
}
#Geopotential Height
#Geopotential height
'gpm' = {
table2Version = 128 ;
indicatorOfParameter = 156 ;
@ -17239,7 +17239,7 @@
table2Version = 228 ;
indicatorOfParameter = 19 ;
}
#Soil Moisture
#Soil moisture
'kg m**-3' = {
table2Version = 228 ;
indicatorOfParameter = 39 ;
@ -17254,7 +17254,7 @@
table2Version = 228 ;
indicatorOfParameter = 132 ;
}
#Soil Temperature
#Soil temperature
'K' = {
table2Version = 228 ;
indicatorOfParameter = 139 ;

View File

@ -105,7 +105,7 @@
table2Version = 200 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'gh' = {
table2Version = 200 ;
indicatorOfParameter = 7 ;
@ -945,7 +945,7 @@
table2Version = 200 ;
indicatorOfParameter = 221 ;
}
#Soil Temperature
#Soil temperature
'st' = {
table2Version = 200 ;
indicatorOfParameter = 85 ;

View File

@ -105,8 +105,8 @@
table2Version = 200 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
'Geopotential Height' = {
#Geopotential height
'Geopotential height' = {
table2Version = 200 ;
indicatorOfParameter = 7 ;
}
@ -945,8 +945,8 @@
table2Version = 200 ;
indicatorOfParameter = 221 ;
}
#Soil Temperature
'Soil Temperature' = {
#Soil temperature
'Soil temperature' = {
table2Version = 200 ;
indicatorOfParameter = 85 ;
}

View File

@ -105,7 +105,7 @@
table2Version = 200 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'156' = {
table2Version = 200 ;
indicatorOfParameter = 7 ;
@ -945,7 +945,7 @@
table2Version = 200 ;
indicatorOfParameter = 221 ;
}
#Soil Temperature
#Soil temperature
'228139' = {
table2Version = 200 ;
indicatorOfParameter = 85 ;

View File

@ -105,7 +105,7 @@
table2Version = 200 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'gh' = {
table2Version = 200 ;
indicatorOfParameter = 7 ;
@ -945,7 +945,7 @@
table2Version = 200 ;
indicatorOfParameter = 221 ;
}
#Soil Temperature
#Soil temperature
'st' = {
table2Version = 200 ;
indicatorOfParameter = 85 ;

View File

@ -105,7 +105,7 @@
table2Version = 200 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'gpm' = {
table2Version = 200 ;
indicatorOfParameter = 7 ;
@ -945,7 +945,7 @@
table2Version = 200 ;
indicatorOfParameter = 221 ;
}
#Soil Temperature
#Soil temperature
'K' = {
table2Version = 200 ;
indicatorOfParameter = 85 ;

View File

@ -94,8 +94,8 @@
table2Version = 3 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
'Geopotential Height' = {
#Geopotential height
'Geopotential height' = {
table2Version = 3 ;
indicatorOfParameter = 7 ;
}
@ -668,13 +668,13 @@
indicatorOfParameter = 7 ;
indicatorOfTypeOfLevel = 1 ;
}
#Soil Moisture
'Soil Moisture' = {
#Soil moisture
'Soil moisture' = {
table2Version = 3 ;
indicatorOfParameter = 86 ;
}
#Soil Temperature
'Soil Temperature' = {
#Soil temperature
'Soil temperature' = {
table2Version = 3 ;
indicatorOfParameter = 85 ;
}
@ -790,8 +790,8 @@
table2Version = 2 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
'Geopotential Height' = {
#Geopotential height
'Geopotential height' = {
table2Version = 2 ;
indicatorOfParameter = 7 ;
}
@ -1349,13 +1349,13 @@
indicatorOfParameter = 7 ;
indicatorOfTypeOfLevel = 1 ;
}
#Soil Moisture
'Soil Moisture' = {
#Soil moisture
'Soil moisture' = {
table2Version = 2 ;
indicatorOfParameter = 86 ;
}
#Soil Temperature
'Soil Temperature' = {
#Soil temperature
'Soil temperature' = {
table2Version = 2 ;
indicatorOfParameter = 85 ;
}
@ -1471,8 +1471,8 @@
table2Version = 1 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
'Geopotential Height' = {
#Geopotential height
'Geopotential height' = {
table2Version = 1 ;
indicatorOfParameter = 7 ;
}
@ -2030,13 +2030,13 @@
indicatorOfParameter = 7 ;
indicatorOfTypeOfLevel = 1 ;
}
#Soil Moisture
'Soil Moisture' = {
#Soil moisture
'Soil moisture' = {
table2Version = 1 ;
indicatorOfParameter = 86 ;
}
#Soil Temperature
'Soil Temperature' = {
#Soil temperature
'Soil temperature' = {
table2Version = 1 ;
indicatorOfParameter = 85 ;
}

View File

@ -94,7 +94,7 @@
table2Version = 3 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'156' = {
table2Version = 3 ;
indicatorOfParameter = 7 ;
@ -668,12 +668,12 @@
indicatorOfParameter = 7 ;
indicatorOfTypeOfLevel = 1 ;
}
#Soil Moisture
#Soil moisture
'228039' = {
table2Version = 3 ;
indicatorOfParameter = 86 ;
}
#Soil Temperature
#Soil temperature
'228139' = {
table2Version = 3 ;
indicatorOfParameter = 85 ;
@ -790,7 +790,7 @@
table2Version = 2 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'156' = {
table2Version = 2 ;
indicatorOfParameter = 7 ;
@ -1349,12 +1349,12 @@
indicatorOfParameter = 7 ;
indicatorOfTypeOfLevel = 1 ;
}
#Soil Moisture
#Soil moisture
'228039' = {
table2Version = 2 ;
indicatorOfParameter = 86 ;
}
#Soil Temperature
#Soil temperature
'228139' = {
table2Version = 2 ;
indicatorOfParameter = 85 ;
@ -1471,7 +1471,7 @@
table2Version = 1 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'156' = {
table2Version = 1 ;
indicatorOfParameter = 7 ;
@ -2030,12 +2030,12 @@
indicatorOfParameter = 7 ;
indicatorOfTypeOfLevel = 1 ;
}
#Soil Moisture
#Soil moisture
'228039' = {
table2Version = 1 ;
indicatorOfParameter = 86 ;
}
#Soil Temperature
#Soil temperature
'228139' = {
table2Version = 1 ;
indicatorOfParameter = 85 ;

View File

@ -94,7 +94,7 @@
table2Version = 3 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'gh' = {
table2Version = 3 ;
indicatorOfParameter = 7 ;
@ -668,12 +668,12 @@
indicatorOfParameter = 7 ;
indicatorOfTypeOfLevel = 1 ;
}
#Soil Moisture
#Soil moisture
'sm' = {
table2Version = 3 ;
indicatorOfParameter = 86 ;
}
#Soil Temperature
#Soil temperature
'st' = {
table2Version = 3 ;
indicatorOfParameter = 85 ;
@ -790,7 +790,7 @@
table2Version = 2 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'gh' = {
table2Version = 2 ;
indicatorOfParameter = 7 ;
@ -1349,12 +1349,12 @@
indicatorOfParameter = 7 ;
indicatorOfTypeOfLevel = 1 ;
}
#Soil Moisture
#Soil moisture
'sm' = {
table2Version = 2 ;
indicatorOfParameter = 86 ;
}
#Soil Temperature
#Soil temperature
'st' = {
table2Version = 2 ;
indicatorOfParameter = 85 ;
@ -1471,7 +1471,7 @@
table2Version = 1 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'gh' = {
table2Version = 1 ;
indicatorOfParameter = 7 ;
@ -2030,12 +2030,12 @@
indicatorOfParameter = 7 ;
indicatorOfTypeOfLevel = 1 ;
}
#Soil Moisture
#Soil moisture
'sm' = {
table2Version = 1 ;
indicatorOfParameter = 86 ;
}
#Soil Temperature
#Soil temperature
'st' = {
table2Version = 1 ;
indicatorOfParameter = 85 ;

View File

@ -94,7 +94,7 @@
table2Version = 3 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'gpm' = {
table2Version = 3 ;
indicatorOfParameter = 7 ;
@ -668,12 +668,12 @@
indicatorOfParameter = 7 ;
indicatorOfTypeOfLevel = 1 ;
}
#Soil Moisture
#Soil moisture
'kg m**-3' = {
table2Version = 3 ;
indicatorOfParameter = 86 ;
}
#Soil Temperature
#Soil temperature
'K' = {
table2Version = 3 ;
indicatorOfParameter = 85 ;
@ -790,7 +790,7 @@
table2Version = 2 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'gpm' = {
table2Version = 2 ;
indicatorOfParameter = 7 ;
@ -1349,12 +1349,12 @@
indicatorOfParameter = 7 ;
indicatorOfTypeOfLevel = 1 ;
}
#Soil Moisture
#Soil moisture
'kg m**-3' = {
table2Version = 2 ;
indicatorOfParameter = 86 ;
}
#Soil Temperature
#Soil temperature
'K' = {
table2Version = 2 ;
indicatorOfParameter = 85 ;
@ -1471,7 +1471,7 @@
table2Version = 1 ;
indicatorOfParameter = 44 ;
}
#Geopotential Height
#Geopotential height
'gpm' = {
table2Version = 1 ;
indicatorOfParameter = 7 ;
@ -2030,12 +2030,12 @@
indicatorOfParameter = 7 ;
indicatorOfTypeOfLevel = 1 ;
}
#Soil Moisture
#Soil moisture
'kg m**-3' = {
table2Version = 1 ;
indicatorOfParameter = 86 ;
}
#Soil Temperature
#Soil temperature
'K' = {
table2Version = 1 ;
indicatorOfParameter = 85 ;

View File

@ -308,7 +308,7 @@
parameterCategory = 2 ;
parameterNumber = 13 ;
}
#Geopotential Height
#Geopotential height
'geopotential_height' = {
discipline = 0 ;
parameterCategory = 3 ;

View File

@ -3623,7 +3623,7 @@
parameterCategory = 2 ;
parameterNumber = 13 ;
}
#Geopotential Height
#Geopotential height
'gh' = {
discipline = 0 ;
parameterCategory = 3 ;
@ -5527,13 +5527,13 @@
parameterNumber = 5 ;
typeOfFirstFixedSurface = 1 ;
}
#Soil Moisture
#Soil moisture
'sm' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 22 ;
}
#Soil Temperature
#Soil temperature
'st' = {
discipline = 2 ;
parameterCategory = 0 ;

View File

@ -1,27 +1,4 @@
#Soil Moisture
'sm' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 22 ;
typeOfSecondFixedSurface = 106 ;
typeOfFirstFixedSurface = 106 ;
scaleFactorOfFirstFixedSurface = 0 ;
scaledValueOfFirstFixedSurface = 0 ;
scaledValueOfSecondFixedSurface = 2 ;
scaleFactorOfSecondFixedSurface = 1 ;
}
#Soil Temperature
'st' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 2 ;
scaledValueOfFirstFixedSurface = 0 ;
typeOfSecondFixedSurface = 106 ;
scaledValueOfSecondFixedSurface = 2 ;
scaleFactorOfSecondFixedSurface = 1 ;
typeOfFirstFixedSurface = 106 ;
scaleFactorOfFirstFixedSurface = 0 ;
}
# Automatically generated by ./create_def.pl, do not edit
#Maximum temperature at 2 metres in the last 6 hours
'mx2t6' = {
discipline = 0 ;
@ -64,4 +41,27 @@
scaleFactorOfFirstFixedSurface = 1 ;
scaledValueOfFirstFixedSurface = 15 ;
}
#Soil moisture
'sm' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 22 ;
typeOfSecondFixedSurface = 106 ;
typeOfFirstFixedSurface = 106 ;
scaleFactorOfFirstFixedSurface = 0 ;
scaledValueOfFirstFixedSurface = 0 ;
scaledValueOfSecondFixedSurface = 2 ;
scaleFactorOfSecondFixedSurface = 1 ;
}
#Soil temperature
'st' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 2 ;
scaledValueOfFirstFixedSurface = 0 ;
typeOfSecondFixedSurface = 106 ;
scaledValueOfSecondFixedSurface = 2 ;
scaleFactorOfSecondFixedSurface = 1 ;
typeOfFirstFixedSurface = 106 ;
scaleFactorOfFirstFixedSurface = 0 ;
}

View File

@ -41,8 +41,8 @@
scaledValueOfFirstFixedSurface = 15 ;
scaleFactorOfFirstFixedSurface = 1 ;
}
#Soil Moisture
'Soil Moisture' = {
#Soil moisture
'Soil moisture' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 22 ;
@ -53,8 +53,8 @@
scaledValueOfSecondFixedSurface = 2 ;
scaleFactorOfSecondFixedSurface = 1 ;
}
#Soil Temperature
'Soil Temperature' = {
#Soil temperature
'Soil temperature' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 2 ;

View File

@ -41,7 +41,7 @@
scaledValueOfFirstFixedSurface = 15 ;
scaleFactorOfFirstFixedSurface = 1 ;
}
#Soil Moisture
#Soil moisture
'228039' = {
discipline = 2 ;
parameterCategory = 0 ;
@ -53,7 +53,7 @@
scaledValueOfSecondFixedSurface = 2 ;
scaleFactorOfSecondFixedSurface = 1 ;
}
#Soil Temperature
#Soil temperature
'228139' = {
discipline = 2 ;
parameterCategory = 0 ;

View File

@ -41,7 +41,7 @@
scaledValueOfFirstFixedSurface = 15 ;
scaleFactorOfFirstFixedSurface = 1 ;
}
#Soil Moisture
#Soil moisture
'sm' = {
discipline = 2 ;
parameterCategory = 0 ;
@ -53,7 +53,7 @@
scaledValueOfSecondFixedSurface = 2 ;
scaleFactorOfSecondFixedSurface = 1 ;
}
#Soil Temperature
#Soil temperature
'st' = {
discipline = 2 ;
parameterCategory = 0 ;

View File

@ -41,7 +41,7 @@
scaledValueOfFirstFixedSurface = 15 ;
scaleFactorOfFirstFixedSurface = 1 ;
}
#Soil Moisture
#Soil moisture
'kg m**-3' = {
discipline = 2 ;
parameterCategory = 0 ;
@ -53,7 +53,7 @@
scaledValueOfSecondFixedSurface = 2 ;
scaleFactorOfSecondFixedSurface = 1 ;
}
#Soil Temperature
#Soil temperature
'K' = {
discipline = 2 ;
parameterCategory = 0 ;

View File

@ -3623,8 +3623,8 @@
parameterCategory = 2 ;
parameterNumber = 13 ;
}
#Geopotential Height
'Geopotential Height' = {
#Geopotential height
'Geopotential height' = {
discipline = 0 ;
parameterCategory = 3 ;
parameterNumber = 5 ;
@ -5527,14 +5527,14 @@
parameterNumber = 5 ;
typeOfFirstFixedSurface = 1 ;
}
#Soil Moisture
'Soil Moisture' = {
#Soil moisture
'Soil moisture' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 22 ;
}
#Soil Temperature
'Soil Temperature' = {
#Soil temperature
'Soil temperature' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 2 ;

View File

@ -3623,7 +3623,7 @@
parameterCategory = 2 ;
parameterNumber = 13 ;
}
#Geopotential Height
#Geopotential height
'156' = {
discipline = 0 ;
parameterCategory = 3 ;
@ -5527,13 +5527,13 @@
parameterNumber = 5 ;
typeOfFirstFixedSurface = 1 ;
}
#Soil Moisture
#Soil moisture
'228039' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 22 ;
}
#Soil Temperature
#Soil temperature
'228139' = {
discipline = 2 ;
parameterCategory = 0 ;

View File

@ -3623,7 +3623,7 @@
parameterCategory = 2 ;
parameterNumber = 13 ;
}
#Geopotential Height
#Geopotential height
'gh' = {
discipline = 0 ;
parameterCategory = 3 ;
@ -5527,13 +5527,13 @@
parameterNumber = 5 ;
typeOfFirstFixedSurface = 1 ;
}
#Soil Moisture
#Soil moisture
'sm' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 22 ;
}
#Soil Temperature
#Soil temperature
'st' = {
discipline = 2 ;
parameterCategory = 0 ;

View File

@ -3623,7 +3623,7 @@
parameterCategory = 2 ;
parameterNumber = 13 ;
}
#Geopotential Height
#Geopotential height
'gpm' = {
discipline = 0 ;
parameterCategory = 3 ;
@ -5527,13 +5527,13 @@
parameterNumber = 5 ;
typeOfFirstFixedSurface = 1 ;
}
#Soil Moisture
#Soil moisture
'kg m**-3' = {
discipline = 2 ;
parameterCategory = 0 ;
parameterNumber = 22 ;
}
#Soil Temperature
#Soil temperature
'K' = {
discipline = 2 ;
parameterCategory = 0 ;

View File

@ -51,6 +51,9 @@
#cmakedefine ECCODES_HAVE_FMEMOPEN
#cmakedefine ECCODES_HAVE_FUNOPEN
#cmakedefine ECCODES_HAVE_REALPATH
#cmakedefine ECCODES_HAVE_FSYNC
#cmakedefine ECCODES_HAVE_FDATASYNC
#cmakedefine ECCODES_ON_LINUX_32BIT
#if defined(EC_HAVE_ASSERT_H) || defined(ECCODES_HAVE_ASSERT_H)
#define HAVE_ASSERT_H 1

View File

@ -22,7 +22,7 @@ program copy
character(len=32) :: product_kind
call codes_open_file(infile, '../../data/constant_field.grib1', 'r')
call codes_open_file(outfile, 'out.copy.grib1', 'w')
call codes_open_file(outfile, 'out.copy.grib1', 'W')
! A new GRIB message is loaded from file
! igrib_in is the GRIB id to be used in subsequent calls

View File

@ -82,6 +82,12 @@ static void init()
}
#endif
typedef enum FileMode {
FILE_MODE_READ,
FILE_MODE_WRITE,
FILE_MODE_APPEND
} FileMode;
int GRIB_NULL=-1;
int GRIB_NULL_NEAREST=-1;
/*extern int errno;*/
@ -92,6 +98,7 @@ struct l_grib_file {
FILE* f;
char* buffer;
int id;
FileMode mode;
l_grib_file* next;
};
@ -218,28 +225,35 @@ static void fort_char_clean(char* str,int len)
*p=' ';
}
static int push_file(FILE* f,char* buffer)
/* Note: the open_mode argument will be all lowercase. See grib_f_open_file_ */
static int push_file(FILE* f, const char* open_mode, char* buffer)
{
l_grib_file* current = file_set;
l_grib_file* previous = file_set;
l_grib_file* the_new = NULL;
int myindex = MIN_FILE_ID;
FileMode fmode = FILE_MODE_READ;
if (strcmp(open_mode, "w") == 0) fmode = FILE_MODE_WRITE;
else if (strcmp(open_mode, "a") == 0) fmode = FILE_MODE_APPEND;
if(!file_set){
file_set = (l_grib_file*)malloc(sizeof(l_grib_file));
Assert(file_set);
file_set->id = myindex;
file_set->f = f;
file_set->buffer =buffer;
file_set->next = NULL;
file_set->id = myindex;
file_set->f = f;
file_set->mode = fmode;
file_set->buffer = buffer;
file_set->next = NULL;
return myindex;
}
while(current){
if(current->id < 0){
current->id = -(current->id);
current->f = f;
current->buffer = buffer;
current->f = f;
current->mode = fmode;
current->buffer = buffer;
return current->id ;
} else{
myindex++;
@ -250,11 +264,12 @@ static int push_file(FILE* f,char* buffer)
the_new = (l_grib_file*)malloc(sizeof(l_grib_file));
Assert(the_new);
the_new->id = myindex;
the_new->f = f;
the_new->buffer = buffer;
the_new->next = current;
previous->next = the_new;
the_new->id = myindex;
the_new->f = f;
the_new->mode = fmode;
the_new->buffer = buffer;
the_new->next = current;
previous->next = the_new;
return myindex;
}
@ -750,11 +765,23 @@ static bufr_keys_iterator* get_bufr_keys_iterator(int keys_iterator_id)
static int clear_file(int file_id)
{
int err = 0;
l_grib_file* current = file_set;
while(current){
if(current->id == file_id){
current->id = -(current->id);
if (current->f) fclose(current->f);
if (current->f) {
if (current->mode == FILE_MODE_WRITE || current->mode == FILE_MODE_APPEND)
err = codes_flush_sync_close_file(current->f);
else
err = fclose(current->f);
if (err) {
int ioerr = errno;
grib_context* c = grib_context_get_default();
grib_context_log(c,(GRIB_LOG_ERROR)|(GRIB_LOG_PERROR),"IO ERROR: %s",strerror(ioerr));
return GRIB_IO_PROBLEM;
}
}
if (current->buffer) free(current->buffer);
return GRIB_SUCCESS;
}
@ -1040,7 +1067,7 @@ int grib_f_open_file_(int* fid, char* name , char* op, int lname, int lop) {
#endif
setvbuf(f,iobuf,_IOFBF,context->io_buffer_size);
}
*fid = push_file(f,iobuf);
*fid = push_file(f, oper, iobuf);
ret=GRIB_SUCCESS;
}
return ret;

View File

@ -109,11 +109,11 @@ static int create_accessor(grib_section* p, grib_action* act, grib_loader* h)
long val = 0;
if ((ret = grib_expression_evaluate_long(p->h, a->expression, &val)) != GRIB_SUCCESS) {
grib_context_log(p->h->context, GRIB_LOG_DEBUG, " List %s creating %d values unable to evaluate long \n", act->name, val);
grib_context_log(p->h->context, GRIB_LOG_DEBUG, "List %s creating %d values unable to evaluate long", act->name, val);
return ret;
}
grib_context_log(p->h->context, GRIB_LOG_DEBUG, " List %s creating %d values \n", act->name, val);
grib_context_log(p->h->context, GRIB_LOG_DEBUG, "List %s creating %d values", act->name, val);
ga = grib_accessor_factory(p, act, 0, NULL);
if (!ga)
@ -167,7 +167,8 @@ static grib_action* reparse(grib_action* a, grib_accessor* acc, int* doit)
long val = 0;
if ((ret = grib_expression_evaluate_long(grib_handle_of_accessor(acc), self->expression, &val)) != GRIB_SUCCESS) {
grib_context_log(acc->context, GRIB_LOG_ERROR, " List %s creating %d values unable to evaluate long \n", acc->name, val);
grib_context_log(acc->context, GRIB_LOG_ERROR,
"List %s creating %ld values, unable to evaluate long", acc->name, val);
}
*doit = (val != acc->loop);

View File

@ -130,3 +130,67 @@ char* codes_getenv(const char* name)
}
return result;
}
int codes_check_grib_ieee_packing_value(int value)
{
grib_context* c = grib_context_get_default();
if (value != 32 && value != 64) {
grib_context_log(c, GRIB_LOG_ERROR, "Invalid value for ECCODES_GRIB_IEEE_PACKING: should be 32 or 64");
return GRIB_INVALID_ARGUMENT;
}
return GRIB_SUCCESS;
}
/* Note: To be called in cases where we are WRITING a file (Do not call when reading) */
int codes_flush_sync_close_file(FILE* f)
{
int err = 0;
int fd = 0;
grib_context* c = grib_context_get_default();
Assert(f);
fd = fileno(f);
if (fd == -1) {
grib_context_log(c, GRIB_LOG_PERROR, "fileno() error: invalid stream");
return GRIB_IO_PROBLEM;
}
#if 0
#ifdef HAVE_FCNTL_H
/* Heavy handed way of getting the file access mode: only proceed if writing */
val = fcntl(fd, F_GETFL, 0);
if (val < 0) {
grib_context_log(c, GRIB_LOG_PERROR, "Call to fcntl failed");
return err;
}
if ((val & O_ACCMODE) != O_WRONLY) {
/* File is not being written */
return GRIB_SUCCESS;
}
#endif
#endif
err = fflush(f);
if (err) {
grib_context_log(c, GRIB_LOG_PERROR, "Call to fflush failed");
return err;
}
#if defined(ECCODES_HAVE_FSYNC)
err = fsync(fd);
while (err < 0 && errno == EINTR) {
err = fsync(fd);
}
if (err < 0) {
grib_context_log(c, GRIB_LOG_PERROR, "Cannot fsync file");
return GRIB_IO_PROBLEM;
}
#endif
err = fclose(f);
if (err) {
grib_context_log(c, GRIB_LOG_PERROR, "Call to fclose failed");
return err;
}
return GRIB_SUCCESS;
}

View File

@ -185,7 +185,7 @@ grib_accessor* grib_accessor_factory(grib_section* p, grib_action* creator,
if (!p->h->buffer->growable) {
if (!p->h->partial)
grib_context_log(p->h->context, GRIB_LOG_ERROR,
"Creating (%s)%s of %s at offset %d-%d over message boundary (%d)",
"Creating (%s)%s of %s at offset %ld-%ld over message boundary (%lu)",
p->owner ? p->owner->name : "", a->name,
creator->op, a->offset,
a->offset + a->length,

View File

@ -660,7 +660,7 @@ static int unpack_string_array(grib_accessor* a, char** val, size_t* len)
if (*len < self->expandedAOSize) {
grib_context_log(a->context, GRIB_LOG_ERROR,
" wrong size (%ld) for %s it contains %d values ", *len, a->name, self->expandedAOSize);
"Wrong size (%lu) for %s, it contains %lu values", *len, a->name, self->expandedAOSize);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -726,7 +726,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
if (*len < self->expandedAOSize) {
grib_context_log(a->context, GRIB_LOG_ERROR,
" wrong size (%ld) for %s it contains %d values ", *len, a->name, self->expandedAOSize);
"Wrong size (%lu) for %s it contains %lu values", *len, a->name, self->expandedAOSize);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -784,7 +784,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
if (*len < self->expandedAOSize) {
grib_context_log(a->context, GRIB_LOG_ERROR,
" wrong size (%ld) for %s it contains %d values ", *len, a->name, self->expandedAOSize);
"Wrong size (%lu) for %s it contains %lu values", *len, a->name, self->expandedAOSize);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -169,7 +169,8 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
grib_handle* hand = grib_handle_of_accessor(a);
if (len[0] < (a->length + 1)) {
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name, a->length + 1);
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s it contains %ld values",
len[0], a->name, a->length + 1);
len[0] = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -186,7 +187,8 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len)
int i = 0;
grib_handle* hand = grib_handle_of_accessor(a);
if (len[0] > (a->length) + 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, "pack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name, a->length + 1);
grib_context_log(a->context, GRIB_LOG_ERROR,
"pack_string: Wrong size (%lu) for %s it contains %ld values", len[0], a->name, a->length + 1);
len[0] = 0;
return GRIB_BUFFER_TOO_SMALL;
}

View File

@ -224,7 +224,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
return err;
if (*len < tlen) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, tlen);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %ld values", a->name, tlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -249,7 +249,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
return err;
if (*len < tlen) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, tlen);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %ld values", a->name, tlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -282,7 +282,8 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
grib_handle* hand = grib_handle_of_accessor(a);
if (len[0] < (a->length)) {
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name, a->length);
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s it contains %ld values",
len[0], a->name, a->length);
len[0] = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -1381,7 +1381,7 @@ static int encode_new_replication(grib_context* c, grib_accessor_bufr_data_array
int err = 0;
unsigned long repetitions = 1;
bufr_descriptor** descriptors = self->expanded->v;
/* Assert( buff->data==data); */
DebugAssert( buff->data == data );
switch (descriptors[i]->code) {
case 31000:
@ -1425,6 +1425,7 @@ static int encode_new_replication(grib_context* c, grib_accessor_bufr_data_array
grib_context_log(c, GRIB_LOG_DEBUG, "BUFR data encoding replication: \twidth=%ld pos=%ld ulength=%ld ulength_bits=%ld",
(long)descriptors[i]->width, (long)*pos, (long)buff->ulength, (long)buff->ulength_bits);
grib_buffer_set_ulength_bits(c, buff, buff->ulength_bits + descriptors[i]->width);
data = buff->data; /* ECC-1347 */
grib_encode_unsigned_longb(data, repetitions, pos, descriptors[i]->width);
*numberOfRepetitions = repetitions;

View File

@ -371,7 +371,7 @@ static grib_codetable* load_table(grib_accessor_codetable* self)
size = grib_byte_count((grib_accessor*)self) * 8;
}
size = (1UL << size); /* 2^size */
size = (1ULL << size); /* 2^size - 64bits */
t = (grib_codetable*)grib_context_malloc_clear_persistent(c, sizeof(grib_codetable) +
(size - 1) * sizeof(code_table_entry));
@ -783,10 +783,8 @@ static int get_native_type(grib_accessor* a)
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_codetable* self = (grib_accessor_codetable*)a;
long rlen = 0;
unsigned long i = 0;
long pos = a->offset * 8;
long rlen = 0, i = 0;
long pos = a->offset * 8;
grib_handle* hand = NULL;
#ifdef DEBUG
@ -804,7 +802,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
}
if (*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR, " wrong size (%ld) for %s it contains %d values ", *len, a->name, rlen);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%lu) for %s, it contains %ld values",
*len, a->name, rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -640,7 +640,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
slen = strlen(p) + 1;
if (*len < slen) {
grib_context_log(a->context, GRIB_LOG_ERROR,
"Concept unpack_string. Wrong size for %s, value='%s' which requires %d bytes (len=%d)",
"Concept unpack_string. Wrong size for %s, value='%s' which requires %lu bytes (len=%lu)",
a->name, p, slen, *len);
*len = slen;
return GRIB_BUFFER_TOO_SMALL;

View File

@ -314,32 +314,35 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
long i = 0;
long j = 0;
double missing_value = 0;
grib_handle* hand = grib_handle_of_accessor(a);
grib_context* ctxt = a->context;
if (*len == 0)
return GRIB_NO_VALUES;
if (!grib_find_accessor(grib_handle_of_accessor(a), self->bitmap)) {
err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->coded_values, val, *len);
if (!grib_find_accessor(hand, self->bitmap)) {
/*printf("SETTING TOTAL number_of_data_points %s %ld\n",self->number_of_data_points,*len);*/
if (self->number_of_data_points)
grib_set_long_internal(grib_handle_of_accessor(a), self->number_of_data_points, *len);
grib_set_long_internal(hand, self->number_of_data_points, *len);
err = grib_set_double_array_internal(hand, self->coded_values, val, *len);
return err;
}
if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS)
if ((err = grib_get_double_internal(hand, self->missing_value, &missing_value)) != GRIB_SUCCESS)
return err;
if ((err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->bitmap, val, bmaplen)) != GRIB_SUCCESS)
if ((err = grib_set_double_array_internal(hand, self->bitmap, val, bmaplen)) != GRIB_SUCCESS)
return err;
coded_n_vals = *len;
if (coded_n_vals < 1) {
err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->coded_values, NULL, 0);
err = grib_set_double_array_internal(hand, self->coded_values, NULL, 0);
return err;
}
coded_vals = (double*)grib_context_malloc_clear(a->context, coded_n_vals * sizeof(double));
coded_vals = (double*)grib_context_malloc_clear(ctxt, coded_n_vals * sizeof(double));
if (!coded_vals)
return GRIB_OUT_OF_MEMORY;
@ -349,16 +352,15 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
}
}
err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->coded_values, coded_vals, j);
err = grib_set_double_array_internal(hand, self->coded_values, coded_vals, j);
grib_context_free(ctxt, coded_vals);
if (j == 0) {
if (self->number_of_values)
err = grib_set_long_internal(grib_handle_of_accessor(a), self->number_of_values, 0);
err = grib_set_long_internal(hand, self->number_of_values, 0);
if (self->binary_scale_factor)
err = grib_set_long_internal(grib_handle_of_accessor(a), self->binary_scale_factor, 0);
err = grib_set_long_internal(hand, self->binary_scale_factor, 0);
}
grib_context_free(a->context, coded_vals);
return err;
}

View File

@ -668,7 +668,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
n_vals = (pen_j + 1) * (pen_j + 2);
if (*len != n_vals) {
grib_context_log(a->context, GRIB_LOG_ERROR, "COMPLEX_PACKING : wrong number of values, expected %d - got %d", n_vals, *len);
grib_context_log(a->context, GRIB_LOG_ERROR, "COMPLEX_PACKING: wrong number of values, expected %ld - got %lu",
n_vals, *len);
return GRIB_INTERNAL_ERROR;
}

View File

@ -193,18 +193,18 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
long half_byte = 0;
long bits_per_value = 0;
size_t buflen = 0;
grib_context* c = a->context;
grib_handle* h = grib_handle_of_accessor(a);
char* ieee_packing_s = NULL;
char* packingType_s = NULL;
char* precision_s = NULL;
grib_accessor_class* super = *(a->cclass->super);
if (*len == 0)
return GRIB_NO_VALUES;
#if 0
/* TODO: spectral_ieee does not work */
if (c->ieee_packing && self->ieee_packing) {
grib_handle* h = grib_handle_of_accessor(a);
grib_context* c = a->context;
char* packingType_s = NULL;
char* ieee_packing_s = NULL;
long precision = c->ieee_packing == 32 ? 1 : 2;
size_t lenstr = strlen(self->ieee_packing);
@ -220,6 +220,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
grib_context_free(c, precision_s);
return grib_set_double_array(h, "values", val, *len);
}
#endif
if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->sub_j, &sub_j)) != GRIB_SUCCESS)
return ret;

View File

@ -236,15 +236,20 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len)
val[i] += units_bias;
if (c->ieee_packing && self->ieee_packing) {
long precision = c->ieee_packing == 32 ? 1 : 2;
long precision = 0; /* Either 1(=32 bits) or 2(=64 bits) */
size_t lenstr = strlen(self->ieee_packing);
if ((ret = codes_check_grib_ieee_packing_value(c->ieee_packing)) != GRIB_SUCCESS)
return ret;
packingType_s = grib_context_strdup(c, self->packingType);
ieee_packing_s = grib_context_strdup(c, self->ieee_packing);
precision_s = grib_context_strdup(c, self->precision);
precision = c->ieee_packing == 32 ? 1 : 2;
grib_set_string(h, packingType_s, ieee_packing_s, &lenstr);
grib_set_long(h, precision_s, precision);
if ((ret = grib_set_string(h, packingType_s, ieee_packing_s, &lenstr)) != GRIB_SUCCESS)
return ret;
if ((ret = grib_set_long(h, precision_s, precision)) != GRIB_SUCCESS)
return ret;
grib_context_free(c, packingType_s);
grib_context_free(c, ieee_packing_s);

View File

@ -784,7 +784,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
self->dirty = 1;
if (*len != bt->n_vals_bif) {
grib_context_log(gh->context, GRIB_LOG_ERROR, "BIFOURIER_PACKING : wrong number of values, expected %d - got %d", bt->n_vals_bif, *len);
grib_context_log(gh->context, GRIB_LOG_ERROR, "BIFOURIER_PACKING: wrong number of values, expected %lu - got %lu",
bt->n_vals_bif, *len);
ret = GRIB_INTERNAL_ERROR;
goto cleanup;
}

View File

@ -182,6 +182,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len)
double units_bias = 0.0;
double* val = (double*)cval;
int i;
grib_context* c = a->context;
if (*len == 0) {
grib_buffer_replace(a, NULL, 0, 1, 1);
@ -216,6 +217,22 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len)
for (i = 0; i < n_vals; i++)
val[i] += units_bias;
/* IEEE packing */
if (c->ieee_packing) {
grib_handle* h = grib_handle_of_accessor(a);
long precision = 0; /* Either 1(=32 bits) or 2(=64 bits) */
size_t lenstr = 10;
if ((ret = codes_check_grib_ieee_packing_value(c->ieee_packing)) != GRIB_SUCCESS)
return ret;
precision = c->ieee_packing == 32 ? 1 : 2;
if ((ret = grib_set_string(h, "packingType", "grid_ieee", &lenstr)) != GRIB_SUCCESS)
return ret;
if ((ret = grib_set_long(h, "precision", precision)) != GRIB_SUCCESS)
return ret;
return grib_set_double_array(h, "values", val, *len);
}
if (super != grib_accessor_class_data_g2simple_packing) {
/* Normal case: parent not same as me! */
ret = super->pack_double(a, val, len);
@ -244,8 +261,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len)
if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS)
return ret;
if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bits_per_value, &bits_per_value)) !=
GRIB_SUCCESS)
if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS)
return ret;
if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS)

View File

@ -473,7 +473,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len)
if (width * height != *len) {
grib_context_log(a->context, GRIB_LOG_ERROR,
"grib_accessor_class_data_jpeg2000_packing pack_double: width=%ld height=%ld len=%d."
"grib_accessor_class_data_jpeg2000_packing pack_double: width=%ld height=%ld len=%ld."
" width*height should equal len!",
(long)width, (long)height, (long)*len);
return GRIB_INTERNAL_ERROR;

View File

@ -680,7 +680,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
err = number_of_bits((unsigned long)ceil(fabs(max - min)), &bits_per_value);
if (err) {
grib_context_log(a->context, GRIB_LOG_ERROR,
"Range of values too large. Try a smaller value for decimal precision (less than %d)",
"Range of values too large. Try a smaller value for decimal precision (less than %ld)",
decimal_scale_factor);
return err;
}

View File

@ -762,7 +762,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
expandedSize = BUFR_DESCRIPTORS_ARRAY_USED_SIZE(self->expanded);
if (*len < expandedSize) {
grib_context_log(a->context, GRIB_LOG_ERROR,
" wrong size (%ld) for %s it contains %d values ", *len, a->name, expandedSize);
"Wrong size (%ld) for %s, it contains %lu values", *len, a->name, expandedSize);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -789,7 +789,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
if (*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR,
" wrong size (%ld) for %s it contains %d values ", *len, a->name, rlen);
"Wrong size (%ld) for %s, it contains %lu values", *len, a->name, rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -233,7 +233,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
if (ret)
return ret;
if (*len < 60) {
grib_context_log(a->context, GRIB_LOG_ERROR, " Buffer too small for %s (%d) ", a->name, *len);
grib_context_log(a->context, GRIB_LOG_ERROR, "Buffer too small for %s (%lu)", a->name, *len);
len = 0;
return GRIB_BUFFER_TOO_SMALL;
}

View File

@ -209,7 +209,7 @@ static int unpack_bytes(grib_accessor* a, unsigned char* val, size_t* len)
long offset = grib_byte_offset(a);
if (*len < (size_t)length) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it is %d bytes long\n", a->name, length);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it is %ld bytes long\n", a->name, length);
*len = length;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -244,7 +244,7 @@ static int unpack_bytes(grib_accessor* a, unsigned char* val, size_t* len)
long offset = grib_byte_offset(a);
if (*len < length) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it is %d bytes long\n", a->name, length);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it is %ld bytes long", a->name, length);
*len = length;
return GRIB_ARRAY_TOO_SMALL;
}
@ -606,7 +606,7 @@ static int is_missing(grib_accessor* a)
if (a->flags & GRIB_ACCESSOR_FLAG_TRANSIENT) {
if (a->vvalue == NULL) {
grib_context_log(a->context, GRIB_LOG_ERROR, "%s internal error (flags=0x%X)", a->name, a->flags);
grib_context_log(a->context, GRIB_LOG_ERROR, "%s internal error (flags=0x%lX)", a->name, a->flags);
Assert(!"grib_accessor_class_gen::is_missing(): a->vvalue == NULL");
return 0;
}

View File

@ -207,7 +207,8 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
int i = 0;
if (len[0] < (a->length + 1)) {
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name, a->length + 1);
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s it contains %ld values",
len[0], a->name, a->length + 1);
len[0] = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -167,7 +167,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
rlen = count;
if (*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR, " wrong size (%ld) for %s it contains %d values ", *len, a->name, rlen);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%lu) for %s, it contains %lu values", *len, a->name, rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -190,7 +190,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
long off = 0;
if (*len < 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, " wrong size for %s it pack at least 1 values ", a->name, rlen);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it packs at least 1 value", a->name);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -168,7 +168,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
long off = 0;
if (*len < 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, " wrong size for %s it pack at least 1 values ", a->name, rlen);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it packs at least 1 value", a->name);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -214,7 +214,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
return err;
if (*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR, " wrong size (%ld) for %s it contains %d values ", *len, a->name, rlen);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%lu) for %s, it contains %ld values", *len, a->name, rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -194,7 +194,8 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len)
return GRIB_INVALID_KEY_VALUE;
}
if (len[0] > (a->length) + 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, "pack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name, a->length + 1);
grib_context_log(a->context, GRIB_LOG_ERROR, "pack_string: Wrong size (%lu) for %s, it contains %ld values",
len[0], a->name, a->length + 1);
len[0] = 0;
return GRIB_BUFFER_TOO_SMALL;
}

View File

@ -217,7 +217,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
rlen = count;
if (*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR, " wrong size for %s it contains %d values ", a->name, rlen);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %lu values", a->name, rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -176,7 +176,8 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
int i = 0;
if (len[0] < (a->length + 1)) {
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name, a->length + 1);
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values",
len[0], a->name, a->length + 1);
len[0] = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -181,7 +181,8 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
int i = 0;
if (len[0] < (a->length + 1)) {
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name, a->length + 1);
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s it contains %ld values",
len[0], a->name, a->length + 1);
len[0] = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -258,7 +258,8 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
length = strlen(buff);
if (len[0] < length + 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name, a->length + 1);
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values",
len[0], a->name, a->length + 1);
len[0] = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -186,7 +186,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
rlen = count;
if (*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR, " wrong size for %s it contains %d values ", a->name, rlen);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %lu values", a->name, rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -197,7 +197,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
if (*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR,
" wrong size (%ld) for %s it contains %d values ", *len, a->name, rlen);
"Wrong size (%ld) for %s it contains %ld values", *len, a->name, rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -281,7 +281,7 @@ static grib_smart_table* load_table(grib_accessor_smart_table* self)
next = next->next;
}
size = (1UL << self->widthOfCode); /* 2 ^ self->widthOfCode */
size = (1ULL << self->widthOfCode); /* 2 ^ self->widthOfCode - 64 bits */
t = (grib_smart_table*)grib_context_malloc_clear_persistent(c, sizeof(grib_smart_table));
t->entries = (grib_smart_table_entry*)grib_context_malloc_clear_persistent(c, size * sizeof(grib_smart_table_entry));
@ -569,7 +569,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
if (*len < self->tableCodesSize) {
grib_context_log(a->context, GRIB_LOG_ERROR,
" wrong size (%ld) for %s it contains %d values ", *len, a->name, self->tableCodesSize);
"Wrong size (%lu) for %s it contains %lu values", *len, a->name, self->tableCodesSize);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -198,7 +198,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
if (*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR,
" wrong size (%ld) for %s it contains %d values ", *len, a->name, rlen);
"Wrong size (%ld) for %s it contains %ld values", *len, a->name, rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -192,7 +192,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->T, &T)) != GRIB_SUCCESS) {
if (Tc == -1)
grib_context_log(a->context, GRIB_LOG_ERROR,
"%s. Spectral Truncation Type Unknown: %s=%d %s=%d %s=%d \n",
"%s. Spectral Truncation Type Unknown: %s=%ld %s=%ld %s=%ld",
a->name, self->J, J, self->K, K, self->M, M);
Tc = 0;
grib_set_long(grib_handle_of_accessor(a), self->T, Tc);

View File

@ -172,7 +172,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
/* We ignore the 'seconds' in our time calculation! */
if (second != 0) {
grib_context_log(a->context, GRIB_LOG_ERROR,
"Truncating time: non-zero seconds(%d) ignored", second);
"Truncating time: non-zero seconds(%ld) ignored", second);
}
if (*len < 1)

View File

@ -210,7 +210,8 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
length = string_length(a);
if (len[0] < length + 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name, a->length + 1);
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values",
len[0], a->name, a->length + 1);
len[0] = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -205,7 +205,8 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
length = string_length(a);
if (len[0] < length + 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name, a->length + 1);
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values",
len[0], a->name, a->length + 1);
len[0] = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -205,7 +205,8 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
length = string_length(a);
if (len[0] < length + 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%d) for %s it contains %d values ", len[0], a->name, a->length + 1);
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values",
len[0], a->name, a->length + 1);
len[0] = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -301,7 +301,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
rlen = count;
if (*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR, " wrong size (%ld) for %s it contains %d values ", *len, a->name, rlen);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%ld) for %s, it contains %ld values", *len, a->name, rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -193,7 +193,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
if (*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR,
" wrong size (%ld) for %s it contains %d values ", *len, a->name, rlen);
"Wrong size (%ld) for %s, it contains %ld values", *len, a->name, rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -315,7 +315,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
slen = strlen(p) + 1;
if (*len < slen) {
grib_context_log(a->context, GRIB_LOG_ERROR,
"Variable unpack_string. Wrong size for %s, it is %d bytes long (len=%d)",
"Variable unpack_string. Wrong size for %s, it is %ld bytes long (len=%lu)",
a->name, slen, *len);
*len = slen;
return GRIB_BUFFER_TOO_SMALL;

View File

@ -38,6 +38,7 @@ extern "C" {
#define GRIB_INLINE
#endif
/* See ECC-670 */
#if IS_BIG_ENDIAN
#if GRIB_MEM_ALIGN
#define FAST_BIG_ENDIAN 1
@ -1095,7 +1096,7 @@ struct grib_context
grib_hash_array_value* hash_array[MAX_NUM_HASH_ARRAY];
grib_trie* def_files;
grib_string_list* blocklist;
int ieee_packing;
int ieee_packing; /* 32 or 64 */
int bufrdc_mode;
int bufr_set_to_missing_if_out_of_range;
int bufr_multi_element_constant_arrays;

View File

@ -1003,7 +1003,6 @@ long grib_date_to_julian(long ddate);
/* grib_fieldset.c */
int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int type);
int grib_fieldset_column_copy_from_handle(grib_handle* h, grib_fieldset* set, int i);
grib_fieldset* grib_fieldset_new_from_files(grib_context* c, char* filenames[], int nfiles, char** keys, int nkeys, const char* where_string, const char* order_by_string, int* err);
int grib_fieldset_apply_where(grib_fieldset* set, const char* where_string);
int grib_fieldset_apply_order_by(grib_fieldset* set, const char* order_by_string);
@ -1414,7 +1413,7 @@ grib_iterator* grib_iterator_factory(grib_handle* h, grib_arguments* args, unsig
/* grib_iterator_class_latlon_reduced.c */
/* grib_iterator_class_gen.c */
int transform_iterator_data(grib_handle* h, double* data, long iScansNegatively, long jScansPositively, long jPointsAreConsecutive, long alternativeRowScanning, size_t numPoints, long nx, long ny);
int transform_iterator_data(grib_context* c, double* data, long iScansNegatively, long jScansPositively, long jPointsAreConsecutive, long alternativeRowScanning, size_t numPoints, long nx, long ny);
/* grib_iterator_class_latlon.c */
@ -1447,6 +1446,8 @@ char get_dir_separator_char(void);
int path_is_regular_file(const char* path);
int path_is_directory(const char* filename);
char* codes_getenv(const char* name);
int codes_check_grib_ieee_packing_value(int value);
int codes_flush_sync_close_file(FILE* f);
/* grib_util.c */
grib_handle* grib_util_sections_copy(grib_handle* hfrom, grib_handle* hto, int what, int* err);

View File

@ -223,7 +223,7 @@ static int grib_fieldset_columns_resize(grib_fieldset* set, size_t newsize)
return GRIB_SUCCESS;
}
int grib_fieldset_column_copy_from_handle(grib_handle* h, grib_fieldset* set, int i)
static int grib_fieldset_column_copy_from_handle(grib_handle* h, grib_fieldset* set, int i)
{
int err = 0;
long lval = 0;
@ -333,7 +333,7 @@ static grib_fieldset* grib_fieldset_create_from_keys(grib_context* c, char** key
set = (grib_fieldset*)grib_context_malloc_clear(c, msize);
if (!set) {
grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_create : Cannot malloc %ld bytes", msize);
"grib_fieldset_create_from_keys: Cannot malloc %lu bytes", msize);
return NULL;
}
@ -357,7 +357,7 @@ static grib_fieldset* grib_fieldset_create_from_keys(grib_context* c, char** key
set->columns = (grib_column*)grib_context_malloc_clear(c, sizeof(grib_column) * nkeys);
if (!set->columns) {
grib_context_log(c, GRIB_LOG_ERROR, "grib_fieldset_new_query: memory allocation error");
grib_context_log(c, GRIB_LOG_ERROR, "grib_fieldset_create_from_keys: memory allocation error");
*err = GRIB_OUT_OF_MEMORY;
return NULL;
}
@ -602,7 +602,7 @@ static grib_order_by* grib_fieldset_new_order_by(grib_context* c, const char* ob
else if (strncmp(p, "desc", 4) == 0)
mode = GRIB_ORDER_BY_DESC;
else
grib_context_log(c, GRIB_LOG_ERROR, "Invalid sort specifier: %s", p);
grib_context_log(c, GRIB_LOG_ERROR, "grib_fieldset_new_order_by: Invalid sort specifier: %s", p);
}
grib_trim(&p);
}
@ -819,7 +819,7 @@ static int grib_fieldset_resize_int_array(grib_int_array* a, size_t newsize)
el = (int*)grib_context_realloc(a->context, a->el, newsize);
if (!el) {
grib_context_log(a->context, GRIB_LOG_ERROR,
"grib_fieldset_resize_int_array : Cannot malloc %d bytes",
"grib_fieldset_resize_int_array: Cannot malloc %lu bytes",
newsize);
return GRIB_OUT_OF_MEMORY;
}
@ -863,7 +863,7 @@ static int grib_fieldset_resize_fields(grib_fieldset* set, size_t newsize)
fields = (grib_field**)grib_context_realloc(set->context, set->fields, newsize * sizeof(grib_field*));
if (!fields) {
grib_context_log(set->context, GRIB_LOG_ERROR,
"grib_fieldset_resize_fields : Cannot malloc %d bytes",
"grib_fieldset_resize_fields: Cannot malloc %lu bytes",
newsize * sizeof(grib_field*));
return GRIB_OUT_OF_MEMORY;
}
@ -931,6 +931,7 @@ static int grib_fieldset_set_order_by(grib_fieldset* set, grib_order_by* ob)
}
if (next->idkey == -1) {
grib_context_log(set->context, GRIB_LOG_ERROR,
"grib_fieldset_set_order_by: "
"Unable to apply the order by. Key missing from the fieldset.\n");
return GRIB_MISSING_KEY;
}

View File

@ -325,7 +325,7 @@ int grib_write_message(const grib_handle* h, const char* file, const char* mode)
fclose(fh);
return GRIB_IO_PROBLEM;
}
if (fclose(fh) != 0) {
if (codes_flush_sync_close_file(fh) != GRIB_SUCCESS) {
perror(file);
return GRIB_IO_PROBLEM;
}

View File

@ -993,7 +993,7 @@ int grib_index_search_same(grib_index* index, grib_handle* h)
grib_index_key* keys;
long lval = 0;
double dval = 0.0;
grib_context* c;
grib_context* c = NULL;
if (!index)
return GRIB_NULL_INDEX;
@ -1883,8 +1883,7 @@ grib_handle* codes_new_from_index(grib_index* index, int message_type, int* err)
sizeof(grib_field_list));
if (!index->fieldset) {
grib_context_log(index->context, GRIB_LOG_ERROR,
"unable to allocate %d bytes",
sizeof(grib_field_list));
"unable to allocate %lu bytes", sizeof(grib_field_list));
return NULL;
}
index->current = index->fieldset;

View File

@ -9,9 +9,8 @@
*/
/***************************************************************************
* Jean Baptiste Filippi - 01.11.2005 *
* Enrico Fucile
* *
* Jean Baptiste Filippi - 01.11.2005 *
* Enrico Fucile *
***************************************************************************/
#include "grib_api_internal.h"
@ -35,7 +34,7 @@ static const struct table_entry table[] = {
grib_iterator* grib_iterator_factory(grib_handle* h, grib_arguments* args, unsigned long flags, int* ret)
{
int i;
char* type = (char*)grib_arguments_get_name(h, args, 0);
const char* type = (char*)grib_arguments_get_name(h, args, 0);
for (i = 0; i < NUMBER(table); i++)
if (strcmp(type, table[i].type) == 0) {
@ -47,12 +46,13 @@ grib_iterator* grib_iterator_factory(grib_handle* h, grib_arguments* args, unsig
*ret = grib_iterator_init(it, h, args);
if (*ret == GRIB_SUCCESS)
return it;
grib_context_log(h->context, GRIB_LOG_DEBUG, "grib_iterator_factory: error %d instantiating iterator %s", *ret, table[i].type);
grib_context_log(h->context, GRIB_LOG_ERROR, "Geoiterator factory: Error instantiating iterator %s (%s)",
table[i].type, grib_get_error_message(*ret));
grib_iterator_delete(it);
return NULL;
}
grib_context_log(h->context, GRIB_LOG_ERROR, "grib_iterator_factory : Unknown type : %s for iterator", type);
grib_context_log(h->context, GRIB_LOG_ERROR, "Geoiterator factory: Unknown type: %s for iterator", type);
return NULL;
}

View File

@ -190,7 +190,7 @@ static int iterate_reduced_gaussian_subarea_legacy(grib_iterator* iter, grib_han
if (iter->e >= iter->nv) {
size_t np = count_subarea_points(h, get_reduced_row, pl, plsize, lon_first, lon_last);
grib_context_log(h->context, GRIB_LOG_ERROR,
"Reduced Gaussian iterator (sub-area legacy). Num points=%ld, size(values)=%ld", np, iter->nv);
"Reduced Gaussian Geoiterator (sub-area legacy). Num points=%ld, size(values)=%ld", np, iter->nv);
return GRIB_WRONG_GRID;
}
@ -251,7 +251,7 @@ static int iterate_reduced_gaussian_subarea_algorithm2(grib_iterator* iter, grib
/* Only print error message on the second pass */
size_t np = count_subarea_points(h, get_reduced_row, pl, plsize, lon_first, lon_last);
grib_context_log(h->context, GRIB_LOG_ERROR,
"Reduced Gaussian iterator (sub-area). Num points=%ld, size(values)=%ld", np, iter->nv);
"Reduced Gaussian Geoiterator (sub-area). Num points=%ld, size(values)=%ld", np, iter->nv);
return GRIB_WRONG_GRID;
}
self->los[iter->e] = lon2;

View File

@ -79,7 +79,8 @@ static void init_class(grib_iterator_class* c)
* Return pointer to data at (i,j) (Fortran convention)
*/
static double* pointer_to_data(unsigned int i, unsigned int j,
long iScansNegatively, long jScansPositively, long jPointsAreConsecutive, long alternativeRowScanning,
long iScansNegatively, long jScansPositively,
long jPointsAreConsecutive, long alternativeRowScanning,
unsigned int nx, unsigned int ny, double* data)
{
/* Regular grid */
@ -97,9 +98,11 @@ static double* pointer_to_data(unsigned int i, unsigned int j,
return NULL;
}
/* Apply the scanning mode flags which may require data array to be transformed */
/* to standard west-to-east south-to-north mode */
int transform_iterator_data(grib_handle* h, double* data,
/* Apply the scanning mode flags which may require data array to be transformed
* to standard west-to-east (+i) south-to-north (+j) mode.
* The data array passed in should have 'numPoints' elements.
*/
int transform_iterator_data(grib_context* context, double* data,
long iScansNegatively, long jScansPositively,
long jPointsAreConsecutive, long alternativeRowScanning,
size_t numPoints, long nx, long ny)
@ -113,13 +116,15 @@ int transform_iterator_data(grib_handle* h, double* data,
return GRIB_SUCCESS;
}
if (!context) context = grib_context_get_default();
if (!iScansNegatively && !jScansPositively && !jPointsAreConsecutive && !alternativeRowScanning &&
nx > 0 && ny > 0) {
/* regular grid +i -j: convert from we:ns to we:sn */
/* Regular grid +i -j: convert from we:ns to we:sn */
size_t row_size = ((size_t)nx) * sizeof(double);
data2 = (double*)grib_context_malloc(h->context, row_size);
data2 = (double*)grib_context_malloc(context, row_size);
if (!data2) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error allocating %ld bytes", row_size);
grib_context_log(context, GRIB_LOG_ERROR, "Geoiterator data: Error allocating %ld bytes", row_size);
return GRIB_OUT_OF_MEMORY;
}
for (iy = 0; iy < ny / 2; iy++) {
@ -127,28 +132,32 @@ int transform_iterator_data(grib_handle* h, double* data,
memcpy(data + iy * nx, data + (ny - 1 - iy) * ((size_t)nx), row_size);
memcpy(data + (ny - 1 - iy) * ((size_t)nx), data2, row_size);
}
grib_context_free(h->context, data2);
grib_context_free(context, data2);
return GRIB_SUCCESS;
}
if (nx < 1 || ny < 1) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Invalid values for Nx and/or Ny");
grib_context_log(context, GRIB_LOG_ERROR, "Geoiterator data: Invalid values for Nx and/or Ny");
return GRIB_GEOCALCULUS_PROBLEM;
}
data2 = (double*)grib_context_malloc(h->context, numPoints * sizeof(double));
data2 = (double*)grib_context_malloc(context, numPoints * sizeof(double));
if (!data2) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error allocating %ld bytes", numPoints * sizeof(double));
grib_context_log(context, GRIB_LOG_ERROR, "Geoiterator data: Error allocating %ld bytes", numPoints * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
pData0 = data2;
for (iy = 0; iy < ny; iy++) {
long deltaX = 0;
pData1 = pointer_to_data(0, iy, iScansNegatively, jScansPositively, jPointsAreConsecutive, alternativeRowScanning, nx, ny, data);
if (!pData1)
pData1 = pointer_to_data(0, iy, iScansNegatively, jScansPositively, jPointsAreConsecutive, alternativeRowScanning, nx, ny, data);
if (!pData1) {
grib_context_free(context, data2);
return GRIB_GEOCALCULUS_PROBLEM;
}
pData2 = pointer_to_data(1, iy, iScansNegatively, jScansPositively, jPointsAreConsecutive, alternativeRowScanning, nx, ny, data);
if (!pData2)
if (!pData2) {
grib_context_free(context, data2);
return GRIB_GEOCALCULUS_PROBLEM;
}
deltaX = pData2 - pData1;
for (ix = 0; ix < nx; ix++) {
*pData0++ = *pData1;
@ -156,7 +165,7 @@ int transform_iterator_data(grib_handle* h, double* data,
}
}
memcpy(data, data2, ((size_t)numPoints) * sizeof(double));
grib_context_free(h->context, data2);
grib_context_free(context, data2);
return GRIB_SUCCESS;
}
@ -184,13 +193,13 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
return err;
if (numberOfPoints != dli) {
grib_context_log(h->context, GRIB_LOG_ERROR, "%s != size(%s) (%ld!=%ld)",
grib_context_log(h->context, GRIB_LOG_ERROR, "Geoiterator: %s != size(%s) (%ld!=%ld)",
s_numPoints, s_rawData, numberOfPoints, dli);
return GRIB_WRONG_GRID;
}
iter->nv = dli;
if (iter->nv == 0) {
grib_context_log(h->context, GRIB_LOG_ERROR, "size(%s) is %ld", s_rawData, dli);
grib_context_log(h->context, GRIB_LOG_ERROR, "Geoiterator: size(%s) is %ld", s_rawData, dli);
return GRIB_WRONG_GRID;
}
iter->data = (double*)grib_context_malloc(h->context, (iter->nv) * sizeof(double));

View File

@ -82,6 +82,7 @@ static void init_class(grib_iterator_class* c)
}
/* END_CLASS_IMP */
#define ITER "Lambert conformal Geoiterator"
#define EPSILON 1.0e-10
#ifndef M_PI
@ -205,12 +206,12 @@ static int init_sphere(grib_handle* h,
/* Allocate latitude and longitude arrays */
self->lats = (double*)grib_context_malloc(h->context, nv * sizeof(double));
if (!self->lats) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error allocating %ld bytes", nv * sizeof(double));
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Error allocating %ld bytes", ITER, nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
self->lons = (double*)grib_context_malloc(h->context, nv * sizeof(double));
if (!self->lats) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error allocating %ld bytes", nv * sizeof(double));
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Error allocating %ld bytes", ITER, nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
@ -302,7 +303,7 @@ static int init_oblate(grib_handle* h,
} else {
con = latFirstInRadians * ns;
if (con <= 0) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Point cannot be projected");
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Point cannot be projected: latFirstInRadians=%g", ITER, latFirstInRadians);
return GRIB_GEOCALCULUS_PROBLEM;
}
rh1 = 0;
@ -316,12 +317,12 @@ static int init_oblate(grib_handle* h,
/* Allocate latitude and longitude arrays */
self->lats = (double*)grib_context_malloc(h->context, nv * sizeof(double));
if (!self->lats) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error allocating %ld bytes", nv * sizeof(double));
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Error allocating %ld bytes", ITER, nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
self->lons = (double*)grib_context_malloc(h->context, nv * sizeof(double));
if (!self->lats) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error allocating %ld bytes", nv * sizeof(double));
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Error allocating %ld bytes", ITER, nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
@ -351,7 +352,8 @@ static int init_oblate(grib_handle* h,
ts = pow((rh1 / (earthMajorAxisInMetres * F)), con);
latRad = compute_phi(e, ts, &err);
if (err) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Failed to compute the latitude angle, phi2, for the inverse");
grib_context_log(h->context, GRIB_LOG_ERROR,
"%s: Failed to compute the latitude angle, phi2, for the inverse", ITER);
grib_context_free(h->context, self->lats);
grib_context_free(h->context, self->lons);
return err;
@ -414,7 +416,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
}
if (iter->nv != nx * ny) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Wrong number of points (%ld!=%ldx%ld)", iter->nv, nx, ny);
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Wrong number of points (%ld!=%ldx%ld)", ITER, iter->nv, nx, ny);
return GRIB_WRONG_GRID;
}
@ -446,7 +448,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
/* Standard Parallels cannot be equal and on opposite sides of the equator */
if (fabs(Latin1InDegrees + Latin2InDegrees) < EPSILON) {
grib_context_log(h->context, GRIB_LOG_ERROR,
"Cannot have equal latitudes for standard parallels on opposite sides of equator");
"%s: Cannot have equal latitudes for standard parallels on opposite sides of equator", ITER);
return GRIB_WRONG_GRID;
}
@ -480,7 +482,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
iter->e = -1;
/* Apply the scanning mode flags which may require data array to be transformed */
err = transform_iterator_data(h, iter->data,
err = transform_iterator_data(h->context, iter->data,
iScansNegatively, jScansPositively, jPointsAreConsecutive, alternativeRowScanning,
iter->nv, nx, ny);
return err;

View File

@ -202,7 +202,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
}
if (south > north) {
grib_context_log(h->context, GRIB_LOG_ERROR,
"First and last latitudes are inconsistent with scanning order: lat1=%g, lat2=%g jScansPositively=%ld",
"Lat/Lon Geoiterator: First and last latitudes are inconsistent with scanning order: lat1=%g, lat2=%g jScansPositively=%ld",
lat1, lat2, jScansPositively);
return GRIB_WRONG_GRID;
}

View File

@ -82,6 +82,7 @@ static void init_class(grib_iterator_class* c)
}
/* END_CLASS_IMP */
#define ITER "Mercator Geoiterator"
#define EPSILON 1.0e-10
#ifndef M_PI
@ -171,7 +172,7 @@ static int init_mercator(grib_handle* h,
/* Forward projection: convert lat,lon to x,y */
if (fabs(fabs(latFirstInRadians) - M_PI_2) <= EPSILON) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Mercator: Transformation cannot be computed at the poles");
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Transformation cannot be computed at the poles", ITER);
return GRIB_GEOCALCULUS_PROBLEM;
}
else {
@ -186,12 +187,12 @@ static int init_mercator(grib_handle* h,
/* Allocate latitude and longitude arrays */
self->lats = (double*)grib_context_malloc(h->context, nv * sizeof(double));
if (!self->lats) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error allocating %ld bytes", nv * sizeof(double));
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Error allocating %ld bytes", ITER, nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
self->lons = (double*)grib_context_malloc(h->context, nv * sizeof(double));
if (!self->lats) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error allocating %ld bytes", nv * sizeof(double));
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Error allocating %ld bytes", ITER, nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
@ -210,7 +211,7 @@ static int init_mercator(grib_handle* h,
ts = exp(-_y / (earthMajorAxisInMetres * m1));
latRad = compute_phi(e, ts, &err);
if (err) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Mercator: Failed to compute the latitude angle, phi2, for the inverse");
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Failed to compute the latitude angle, phi2, for the inverse", ITER);
grib_context_free(h->context, self->lats);
grib_context_free(h->context, self->lons);
return err;
@ -270,7 +271,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
}
if (iter->nv != ni * nj) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Wrong number of points (%ld!=%ldx%ld)", iter->nv, ni, nj);
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Wrong number of points (%ld!=%ldx%ld)", ITER, iter->nv, ni, nj);
return GRIB_WRONG_GRID;
}
@ -317,7 +318,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
iter->e = -1;
/* Apply the scanning mode flags which may require data array to be transformed */
err = transform_iterator_data(h, iter->data,
err = transform_iterator_data(h->context, iter->data,
iScansNegatively, jScansPositively, jPointsAreConsecutive, alternativeRowScanning,
iter->nv, ni, nj);
return err;

View File

@ -82,6 +82,8 @@ static void init_class(grib_iterator_class* c)
}
/* END_CLASS_IMP */
#define ITER "Polar stereographic Geoiterator"
static int next(grib_iterator* i, double* lat, double* lon, double* val)
{
grib_iterator_polar_stereographic* self = (grib_iterator_polar_stereographic*)i;
@ -150,7 +152,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
const char* s_alternativeRowScanning = grib_arguments_get_name(h, args, self->carg++);
if (grib_is_earth_oblate(h)) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Polar stereographic only supported for spherical earth.");
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Only supported for spherical earth.", ITER);
return GRIB_GEOCALCULUS_PROBLEM;
}
@ -162,7 +164,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
return ret;
if (iter->nv != nx * ny) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Wrong number of points (%ld!=%ldx%ld)", iter->nv, nx, ny);
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Wrong number of points (%ld!=%ldx%ld)", ITER, iter->nv, nx, ny);
return GRIB_WRONG_GRID;
}
if ((ret = grib_get_double_internal(h, s_latFirstInDegrees, &latFirstInDegrees)) != GRIB_SUCCESS)
@ -242,12 +244,12 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
}
self->lats = (double*)grib_context_malloc(h->context, iter->nv * sizeof(double));
if (!self->lats) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error allocating %ld bytes", iter->nv * sizeof(double));
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Error allocating %ld bytes", ITER, iter->nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
self->lons = (double*)grib_context_malloc(h->context, iter->nv * sizeof(double));
if (!self->lats) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Error allocating %ld bytes", iter->nv * sizeof(double));
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Error allocating %ld bytes", ITER, iter->nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
lats = self->lats;
@ -355,7 +357,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
iter->e = -1;
/* Apply the scanning mode flags which may require data array to be transformed */
ret = transform_iterator_data(h, iter->data,
ret = transform_iterator_data(h->context, iter->data,
iScansNegatively, jScansPositively, jPointsAreConsecutive, alternativeRowScanning,
iter->nv, nx, ny);

View File

@ -248,7 +248,8 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_
break;
default:
grib_context_log(h->context, GRIB_LOG_ERROR, "Copying %s, cannot establish type %d [%s]", name, grib_accessor_get_native_type(ga), ga->creator->cclass->name);
grib_context_log(h->context, GRIB_LOG_ERROR,
"Copying %s, cannot establish type %ld [%s]", name, grib_accessor_get_native_type(ga), ga->creator->cclass->name);
break;
}

View File

@ -467,7 +467,7 @@ int grib_set_bytes_internal(grib_handle* h, const char* name, const unsigned cha
return grib_dependency_notify_change(a);
}
grib_context_log(h->context, GRIB_LOG_ERROR, "unable to set %s=%ld as bytes (%s)",
grib_context_log(h->context, GRIB_LOG_ERROR, "unable to set %s=%s as bytes (%s)",
name, val, grib_get_error_message(ret));
return ret;
}

View File

@ -37,7 +37,7 @@ list(APPEND test_bins
extract_offsets
bufr_check_descriptors
grib_sh_ieee64
ieee
grib_ieee
grib_set_bytes
grib_packing_order
grib_sh_imag
@ -99,6 +99,7 @@ if( HAVE_BUILD_TOOLS )
bufr_ecc-1259
bufr_ecc-1290
bufr_ecc-1304
bufr_ecc-1347
bufr_json_samples
bufr_ecc-359
bufr_ecc-517
@ -193,7 +194,7 @@ if( HAVE_BUILD_TOOLS )
metar_dump
metar_compare
bufr_set
ieee
grib_ieee
grib_sh_ieee64
grib_optimize_scaling
grib_optimize_scaling_sh

View File

@ -42,7 +42,7 @@ TESTS = definitions.sh \
gts_get.sh \
metar_ls.sh \
metar_dump.sh \
ieee.sh \
grib_ieee.sh \
grib1to2.sh \
grib1to3.sh \
unit_tests.sh \

44
tests/bufr_ecc-1347.sh Executable file
View File

@ -0,0 +1,44 @@
#!/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
set -u
label="bufr_ecc-1347-test"
tempBufr=temp.$label.bufr
tempFilt=temp.$label.filter
sample_bufr3=$ECCODES_SAMPLES_PATH/BUFR3.tmpl
cat > $tempFilt <<EOF
set inputDelayedDescriptorReplicationFactor= {0};
set inputExtendedDelayedDescriptorReplicationFactor= {1458};
set masterTableNumber=0;
set bufrHeaderSubCentre=0;
set bufrHeaderCentre=98;
set updateSequenceNumber=1;
set dataCategory=2;
set dataSubCategory=0;
set masterTablesVersionNumber=27;
set localTablesVersionNumber=0;
set numberOfSubsets=1;
set observedData=1;
set compressedData=0;
set unexpandedDescriptors={
301128, 7007, 2102, 201133, 25065, 25066, 201000, 309052, 205011,
5001, 6001, 7001 };
write;
EOF
${tools_dir}/codes_bufr_filter -o $tempBufr $tempFilt $sample_bufr3
${tools_dir}/bufr_dump -p $tempBufr
rm -f $tempBufr $tempFilt

View File

@ -9,7 +9,8 @@
#
. ./include.sh
set -u
label="grib_compare_test"
REDIRECT=/dev/null
infile="${data_dir}/regular_latlon_surface.grib1"
@ -25,15 +26,15 @@ ${tools_dir}/grib_compare -b indicatorOfParameter,paramId,shortName $infile $out
# ----------------------------------------
infile=${data_dir}/v.grib2
for i in 1 2 3; do
${tools_dir}/grib_copy -wcount=$i $infile temp_comp.$i
${tools_dir}/grib_copy -wcount=$i $infile temp.$label.$i
done
cat temp_comp.1 temp_comp.2 temp_comp.3 > temp_comp.123
cat temp_comp.3 temp_comp.2 temp_comp.1 > temp_comp.321
cat temp.$label.2 temp.$label.1 temp.$label.3 > temp.$label.213
cat temp.$label.3 temp.$label.2 temp.$label.1 > temp.$label.321
# Compare files in which the messages are not in the same order
${tools_dir}/grib_compare -r temp_comp.123 temp_comp.321
${tools_dir}/grib_compare -r temp.$label.213 temp.$label.321
rm -f temp_comp.1 temp_comp.2 temp_comp.3 temp_comp.123 temp_comp.321
rm -f temp.$label.1 temp.$label.2 temp.$label.3 temp.$label.213 temp.$label.321
# ----------------------------------------
# GRIB-797: test last argument being a directory

View File

@ -10,7 +10,13 @@
. ./include.sh
# This file does not have a bitmap
infile=${data_dir}/regular_latlon_surface.grib1
# Clean environment before we begin
unset GRIB_IEEE_PACKING
unset ECCODES_GRIB_IEEE_PACKING
shdata=${data_dir}/spherical_model_level.grib1
suff=_ieee_test.grib1
outsimple=simple$suff
@ -34,32 +40,31 @@ cat > r.filter <<EOF
print "[values%g]";
EOF
${tools_dir}/grib_filter -o $outsimple w.filter $infile
${tools_dir}/grib_filter -o $outsimple w.filter $infile
${tools_dir}/grib_filter r.filter $outsimple > $outsimple.txt
diff $outsimple.txt ${data_dir}/ieee_test.good
${tools_dir}/grib_set -r -s packingType=grid_ieee $outsimple $out32
${tools_dir}/grib_filter r.filter $out32 > $out32.txt
${tools_dir}/grib_filter r.filter $out32 > $out32.txt
diff $out32.txt ${data_dir}/ieee_test.good
GRIB_IEEE_PACKING=32
export GRIB_IEEE_PACKING
${tools_dir}/grib_filter -o $out32 w.filter $infile
${tools_dir}/grib_filter r.filter $out32 > $out32.txt
export GRIB_IEEE_PACKING=32
${tools_dir}/grib_filter -o $out32 w.filter $infile
${tools_dir}/grib_filter r.filter $out32 > $out32.txt
diff $out32.txt ${data_dir}/ieee_test.good
grib_check_key_equals $out32 'packingType,precision' 'grid_ieee 1'
GRIB_IEEE_PACKING=64
export GRIB_IEEE_PACKING
${tools_dir}/grib_filter -o $out64 w.filter $infile
${tools_dir}/grib_filter r.filter $out64 > $out64.txt
export GRIB_IEEE_PACKING=64
${tools_dir}/grib_filter -o $out64 w.filter $infile
${tools_dir}/grib_filter r.filter $out64 > $out64.txt
diff $out64.txt ${data_dir}/ieee_test.good
grib_check_key_equals $out64 'packingType,precision' 'grid_ieee 2'
rm -f $outsimple $out32 $out64 $out32.txt $out64.txt
rm -f ${data_dir}/$outsimple.txt ${data_dir}/$out32.txt ${data_dir}/$out64.txt
rm -f ${data_dir}/$outsimple.txt ${data_dir}/$out32.txt ${data_dir}/$out64.txt
rm -f w.filter $outsimple.txt
${tools_dir}/grib_filter r.filter $shdata > $shdata.txt
@ -70,6 +75,9 @@ ${tools_dir}/grib_filter r.filter ${shdata}_ieee > $shdata.txt
diff $shdata.txt $shdata.good
rm -f ${shdata}_ieee
unset GRIB_IEEE_PACKING
unset ECCODES_GRIB_IEEE_PACKING
echo "Test ECC-1075: grib_dump error on GRIB1 with raw packing"
# -------------------------------------------------------------
@ -97,19 +105,62 @@ stats2=`${tools_dir}/grib_get -M -F%.3f -p min,max,avg $temp`
grib_check_key_equals $temp numberOfEffectiveValues,numberOfValues,numberOfMissing '214661 214661 98701'
grib_check_key_equals $temp totalLength 899004
echo "Test ECCODES_GRIB_IEEE_PACKING on GRIB2 with bitmap..."
# ------------------------------------------------------------
infile=${data_dir}/reduced_latlon_surface.grib2
grib_check_key_equals $infile bitmapPresent 1
ECCODES_GRIB_IEEE_PACKING=32 ${tools_dir}/grib_copy -r $infile $temp
grib_check_key_equals $temp packingType grid_ieee
${tools_dir}/grib_compare -c data:n -R all=6e-8 $infile $temp
echo "Test ECCODES_GRIB_IEEE_PACKING on GRIB2 without bitmap..."
# --------------------------------------------------------------
infile=${data_dir}/regular_latlon_surface.grib2
grib_check_key_equals $infile bitmapPresent 0
ECCODES_GRIB_IEEE_PACKING=32 ${tools_dir}/grib_copy -r $infile $temp
grib_check_key_equals $temp packingType grid_ieee
${tools_dir}/grib_compare -c data:n $infile $temp
#### All combinations: with/without bitmap, grib1/2, 32/64bits
editions="1 2"
precisions="32 64"
inputs="reduced_latlon_surface.grib regular_latlon_surface.grib"
for edition in $editions; do
for prec in $precisions; do
for input in $inputs; do
infile=${data_dir}/$input$edition
ECCODES_GRIB_IEEE_PACKING=$prec ${tools_dir}/grib_copy -r $infile $temp
grib_check_key_equals $temp packingType grid_ieee
${tools_dir}/grib_compare -c data:n -R all=6e-8 $infile $temp
done
done
done
echo "Test ECC-1345: env. var value should be checked..."
# -------------------------------------------------------
tempErr=temp.grib_ieee.txt
set +e
# Should fail. Only 32 and 64 are valid
infile=${data_dir}/regular_latlon_surface.grib2
ECCODES_GRIB_IEEE_PACKING=16 ${tools_dir}/grib_copy -r $infile $temp 2>$tempErr
status=$?
set -e
[ $status -ne 0 ]
grep -q "Invalid value for ECCODES_GRIB_IEEE_PACKING: should be 32 or 64" $tempErr
rm -f $tempErr
echo "Test raw packing on GRIB1 with bitmap..."
# ---------------------------------------------
# TODO: This test is currently failing
# grib1 with a bitmap -> raw packing
infile=${data_dir}/reduced_latlon_surface.grib1
grib_check_key_equals $infile numberOfMissing 98701
${tools_dir}/grib_set -r -s packingType=grid_ieee $infile $temp
${tools_dir}/grib_get -p numberOfEffectiveValues,numberOfValues,numberOfMissing $temp
stats1=`${tools_dir}/grib_get -M -F%.3f -p min,max,avg $infile`
stats2=`${tools_dir}/grib_get -M -F%.3f -p min,max,avg $temp`
# [ "$stats1" = "$stats2" ]
[ "$stats1" = "$stats2" ]
ECCODES_GRIB_IEEE_PACKING=32 ${tools_dir}/grib_copy -r $infile $temp
stats2=`${tools_dir}/grib_get -M -F%.3f -p min,max,avg $temp`
[ "$stats1" = "$stats2" ]
echo "Test changing precision ..."

View File

@ -78,7 +78,7 @@ grib_files="\
regular_gaussian_surface.grib1 \
missing.grib2"
ncf_types="NC_SHORT NC_INT NC_FLOAT NC_DOUBLE"
ncf_types="NC_INT NC_FLOAT NC_DOUBLE"
# Go thru all the specified GRIB files and convert them to NetCDF
for dt in $ncf_types; do