Merge branch 'eccodes' of ssh://software.ecmwf.int:7999/GRIB/grib_api into eccodes

This commit is contained in:
Enrico Fucile 2014-09-01 13:21:03 +01:00
commit a1c2439b72
59 changed files with 9749 additions and 7549 deletions

3
.gitignore vendored
View File

@ -113,6 +113,7 @@ tests/read_any
tests/read_index
tests/so_perf
tests/unit_tests
tests/ccsds_perf
tigge/.libs/
tigge/tigge_accumulations
tigge/tigge_check
@ -205,6 +206,8 @@ myconfiggprof*
myconfignopy*
INSTALL
share/
lib
include
#from make
examples/C/check_gaussian_grid

View File

@ -32,7 +32,7 @@ ecbuild_declare_project()
option( ENABLE_JPG "try to add support for JPG encoding" ON )
option( ENABLE_PNG "try to add support for PNG encoding" OFF )
option( ENABLE_NETCDF "try to add support for NetCDF" ON )
option( ENABLE_SZIP "try to add support for SZip encoding" OFF )
option( ENABLE_AEC "try to add support for Adaptive Entropy Coding" OFF )
option( ENABLE_PYTHON "try to build the GRIB_API Python interface" ON )
option( ENABLE_FORTRAN "try to build the GRIB_API Fortran interface" ON )
@ -55,15 +55,15 @@ set( GRIB_API_EXTRA_DEFINITIONS "" )
find_package( CMath )
### SZIP support
### AEC support (Adaptive Entropy Coding)
set( HAVE_LIBSZIP 0 )
if( ENABLE_SZIP )
set( HAVE_LIBAEC 0 )
if( ENABLE_AEC )
find_package( SZip )
find_package( AEC )
if( SZIP_FOUND )
set( HAVE_LIBSZIP 1 )
if( AEC_FOUND )
set( HAVE_LIBAEC 1 )
endif()
endif()
@ -198,7 +198,7 @@ endif()
### export package to other ecbuild packages
set( GRIB_API_TPLS SZip PNG NetCDF Jasper OpenJPEG CMath )
set( GRIB_API_TPLS AEC PNG NetCDF Jasper OpenJPEG CMath )
set( GRIB_API_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src )
set( GRIB_API_LIBRARIES grib_api )

9
NOTICE
View File

@ -1,11 +1,12 @@
ECMWF GRIB API
Copyright 2005-2014 ECMWF.
This product includes software developed at
ECMWF (http://www.ecmwf.int).
This product includes software developed at ECMWF (http://www.ecmwf.int).
Parts of the definitions provided by
WMO (http://www.wmo.int/pages/index_en.html)
Parts of the definitions provided by WMO (http://www.wmo.int/pages/index_en.html)
Adaptive Entropy Coding (CCSDS) provided by
The Max-Planck-Institute for Meteorology and Deutsches Klimarechenzentrum GmbH
IBM POWER optimisations were developed at
The Max-Planck-Institute for Meteorology.

View File

@ -455,6 +455,23 @@ then
AC_SUBST(JPEG_TEST)
fi
dnl check for libaec
CCSDS_TEST=""
AC_ARG_WITH([aec],
[AS_HELP_STRING([--with-aec=DIR],
[use specified libaec installation directory])],
,[with_aec=no])
if test "x$with_aec" != xno ; then
if test "x$with_aec" != xyes ; then
LDFLAGS="$LDFLAGS -L$with_aec/lib"
CPPFLAGS="$CPPFLAGS -I$with_aec/include"
fi
AC_CHECK_LIB(aec, aec_encode, , [AC_MSG_FAILURE(
[aec test failed (--without-aec to disable)])])
CCSDS_TEST="ccsds.sh"
fi
AC_SUBST(CCSDS_TEST)
dnl Check for png
AC_ARG_WITH([png-support],

View File

@ -86,6 +86,7 @@ set(files_to_download
timeRangeIndicator_5.grib
tp_ecmwf.grib
v.grib2
ccsds.grib2
)
foreach( f ${files_to_download} )

View File

@ -1,11 +1,42 @@
#!/bin/sh
DATA_DIR=$1
usage ()
{
prog=`basename $0`
echo "Usage: $prog [-v] data_dir"
echo
echo "-v verbose"
echo "-h prints this help message"
echo
}
VERBOSE=0
while :
do
case "$1" in
-h) usage ; exit 0;;
-v) VERBOSE=1
echo "Running with verbose setting"
;;
--) shift ; break ;;
-*) usage ; exit 0;;
*) break;;
esac
shift
done
DATA_DIR=$1
if [ -z "$DATA_DIR" ]; then
echo "Error: No directory specified." 2>&1
usage
exit 1
fi
# Check if all downloads are already done
DOWNLOADED=${DATA_DIR}/.downloaded
if [ -f $DOWNLOADED ]; then
if [ -f "${DATA_DIR}/.downloaded" ]; then
if [ $VERBOSE -eq 1 ]; then
echo "All downloads are already done. Exiting."
fi
exit 0
fi
@ -92,6 +123,7 @@ files="
timeRangeIndicator_5.grib
tp_ecmwf.grib
v.grib2
ccsds.grib2
tigge/tigge_ammc_pl_gh.grib
tigge/tigge_ammc_pl_q.grib
tigge/tigge_ammc_pl_t.grib
@ -333,282 +365,27 @@ files="
tigge/tigge_sbsj_sfc_tcw.grib
tigge/tigge_sbsj_sfc_tp.grib
tigge/tiggelam_cnmc_sfc.grib
bufr/aaen_55.bufr
bufr/aben_55.bufr
bufr/ahws_139.bufr
bufr/airc_142.bufr
bufr/airc_144.bufr
bufr/airs_57.bufr
bufr/alws_139.bufr
bufr/amda_144.bufr
bufr/amsa_55.bufr
bufr/amsb_55.bufr
bufr/amse_55.bufr
bufr/amsu_55.bufr
bufr/amv2_87.bufr
bufr/amv3_87.bufr
bufr/asbh_139.bufr
bufr/asbl_139.bufr
bufr/asca_139.bufr
bufr/asch_139.bufr
bufr/ascs_139.bufr
bufr/aseh_139.bufr
bufr/asel_139.bufr
bufr/ashs_139.bufr
bufr/atap_55.bufr
bufr/ateu_155.bufr
bufr/atms_201.bufr
bufr/atov_55.bufr
bufr/avhm_87.bufr
bufr/avhn_87.bufr
bufr/avhr_58.bufr
bufr/b002_95.bufr
bufr/b002_96.bufr
bufr/b003_56.bufr
bufr/b004_145.bufr
bufr/b005_87.bufr
bufr/b005_89.bufr
bufr/b006_96.bufr
bufr/b007_31.bufr
bufr/bssh_170.bufr
bufr/bssh_176.bufr
bufr/bssh_178.bufr
bufr/bssh_180.bufr
bufr/btem_109.bufr
bufr/buoy_27.bufr
bufr/cmwi_87.bufr
bufr/cmwn_87.bufr
bufr/cnow_28.bufr
bufr/cori_156.bufr
bufr/crit_202.bufr
bufr/csrh_189.bufr
bufr/emsg_189.bufr
bufr/emsg_87.bufr
bufr/euwv_87.bufr
bufr/fy3a_154.bufr
bufr/fy3b_154.bufr
bufr/g2nd_208.bufr
bufr/g2to_206.bufr
bufr/go15_87.bufr
bufr/goee_87.bufr
bufr/goes_87.bufr
bufr/goga_89.bufr
bufr/gosat.bufr
bufr/grst_26.bufr
bufr/gsd1_208.bufr
bufr/gsd2_208.bufr
bufr/gsd3_208.bufr
bufr/gst4_26.bufr
bufr/hirb_55.bufr
bufr/hirs_55.bufr
bufr/ias1_240.bufr
bufr/iasi_241.bufr
bufr/ifco_208.bufr
bufr/ikco_217.bufr
bufr/itrg_208.bufr
bufr/itwt_233.bufr
bufr/j2eo_216.bufr
bufr/j2nb_216.bufr
bufr/jaso_214.bufr
bufr/kond_209.bufr
bufr/maer_207.bufr
bufr/meta_140.bufr
bufr/mhen_55.bufr
bufr/mhsa_55.bufr
bufr/mhsb_55.bufr
bufr/mhse_55.bufr
bufr/mloz_206.bufr
bufr/modi_87.bufr
bufr/modw_87.bufr
bufr/monw_87.bufr
bufr/nomi_206.bufr
bufr/nos1_208.bufr
bufr/nos2_208.bufr
bufr/nos3_208.bufr
bufr/nos4_208.bufr
bufr/nos5_208.bufr
bufr/nos6_208.bufr
bufr/nos7_208.bufr
bufr/nos8_208.bufr
bufr/ocea_131.bufr
bufr/ocea_132.bufr
bufr/ocea_133.bufr
bufr/ocea_21.bufr
bufr/pgps_110.bufr
bufr/pilo_91.bufr
bufr/rada_250.bufr
bufr/rado_250.bufr
bufr/s4kn_165.bufr
bufr/sb19_206.bufr
bufr/sbu8_206.bufr
bufr/ship_11.bufr
bufr/ship_12.bufr
bufr/ship_13.bufr
bufr/ship_14.bufr
bufr/ship_19.bufr
bufr/ship_9.bufr
bufr/smin_49.bufr
bufr/smis_49.bufr
bufr/smiu_49.bufr
bufr/smos_203.bufr
bufr/sn4k_165.bufr
bufr/soil_7.bufr
bufr/ssbt_127.bufr
bufr/stuk_7.bufr
bufr/syno_1.bufr
bufr/syno_2.bufr
bufr/syno_3.bufr
bufr/syno_4.bufr
bufr/temp_101.bufr
bufr/temp_102.bufr
bufr/temp_106.bufr
bufr/tmr7_129.bufr
bufr/tros_31.bufr
bufr/wavb_134.bufr
bufr/aaen_55.bufr.num.ref
bufr/aben_55.bufr.num.ref
bufr/ahws_139.bufr.num.ref
bufr/airc_142.bufr.num.ref
bufr/airc_144.bufr.num.ref
bufr/airs_57.bufr.num.ref
bufr/alws_139.bufr.num.ref
bufr/amda_144.bufr.num.ref
bufr/amsa_55.bufr.num.ref
bufr/amsb_55.bufr.num.ref
bufr/amse_55.bufr.num.ref
bufr/amsu_55.bufr.num.ref
bufr/amv2_87.bufr.num.ref
bufr/amv3_87.bufr.num.ref
bufr/asbh_139.bufr.num.ref
bufr/asbl_139.bufr.num.ref
bufr/asca_139.bufr.num.ref
bufr/asch_139.bufr.num.ref
bufr/ascs_139.bufr.num.ref
bufr/aseh_139.bufr.num.ref
bufr/asel_139.bufr.num.ref
bufr/ashs_139.bufr.num.ref
bufr/atap_55.bufr.num.ref
bufr/ateu_155.bufr.num.ref
bufr/atms_201.bufr.num.ref
bufr/atov_55.bufr.num.ref
bufr/avhm_87.bufr.num.ref
bufr/avhn_87.bufr.num.ref
bufr/avhr_58.bufr.num.ref
bufr/b002_95.bufr.num.ref
bufr/b002_96.bufr.num.ref
bufr/b003_56.bufr.num.ref
bufr/b004_145.bufr.num.ref
bufr/b005_87.bufr.num.ref
bufr/b005_89.bufr.num.ref
bufr/b006_96.bufr.num.ref
bufr/b007_31.bufr.num.ref
bufr/bssh_170.bufr.num.ref
bufr/bssh_176.bufr.num.ref
bufr/bssh_178.bufr.num.ref
bufr/bssh_180.bufr.num.ref
bufr/btem_109.bufr.num.ref
bufr/buoy_27.bufr.num.ref
bufr/cmwi_87.bufr.num.ref
bufr/cmwn_87.bufr.num.ref
bufr/cnow_28.bufr.num.ref
bufr/cori_156.bufr.num.ref
bufr/crit_202.bufr.num.ref
bufr/csrh_189.bufr.num.ref
bufr/emsg_189.bufr.num.ref
bufr/emsg_87.bufr.num.ref
bufr/euwv_87.bufr.num.ref
bufr/fy3a_154.bufr.num.ref
bufr/fy3b_154.bufr.num.ref
bufr/g2nd_208.bufr.num.ref
bufr/g2to_206.bufr.num.ref
bufr/go15_87.bufr.num.ref
bufr/goee_87.bufr.num.ref
bufr/goes_87.bufr.num.ref
bufr/goga_89.bufr.num.ref
bufr/gosat.bufr.num.ref
bufr/grst_26.bufr.num.ref
bufr/gsd1_208.bufr.num.ref
bufr/gsd2_208.bufr.num.ref
bufr/gsd3_208.bufr.num.ref
bufr/gst4_26.bufr.num.ref
bufr/hirb_55.bufr.num.ref
bufr/hirs_55.bufr.num.ref
bufr/ias1_240.bufr.num.ref
bufr/iasi_241.bufr.num.ref
bufr/ifco_208.bufr.num.ref
bufr/ikco_217.bufr.num.ref
bufr/itrg_208.bufr.num.ref
bufr/itwt_233.bufr.num.ref
bufr/j2eo_216.bufr.num.ref
bufr/j2nb_216.bufr.num.ref
bufr/jaso_214.bufr.num.ref
bufr/kond_209.bufr.num.ref
bufr/maer_207.bufr.num.ref
bufr/meta_140.bufr.num.ref
bufr/mhen_55.bufr.num.ref
bufr/mhsa_55.bufr.num.ref
bufr/mhsb_55.bufr.num.ref
bufr/mhse_55.bufr.num.ref
bufr/mloz_206.bufr.num.ref
bufr/modi_87.bufr.num.ref
bufr/modw_87.bufr.num.ref
bufr/monw_87.bufr.num.ref
bufr/nomi_206.bufr.num.ref
bufr/nos1_208.bufr.num.ref
bufr/nos2_208.bufr.num.ref
bufr/nos3_208.bufr.num.ref
bufr/nos4_208.bufr.num.ref
bufr/nos5_208.bufr.num.ref
bufr/nos6_208.bufr.num.ref
bufr/nos7_208.bufr.num.ref
bufr/nos8_208.bufr.num.ref
bufr/ocea_131.bufr.num.ref
bufr/ocea_132.bufr.num.ref
bufr/ocea_133.bufr.num.ref
bufr/ocea_21.bufr.num.ref
bufr/pgps_110.bufr.num.ref
bufr/pilo_91.bufr.num.ref
bufr/rada_250.bufr.num.ref
bufr/rado_250.bufr.num.ref
bufr/s4kn_165.bufr.num.ref
bufr/sb19_206.bufr.num.ref
bufr/sbu8_206.bufr.num.ref
bufr/ship_11.bufr.num.ref
bufr/ship_12.bufr.num.ref
bufr/ship_13.bufr.num.ref
bufr/ship_14.bufr.num.ref
bufr/ship_19.bufr.num.ref
bufr/ship_9.bufr.num.ref
bufr/smin_49.bufr.num.ref
bufr/smis_49.bufr.num.ref
bufr/smiu_49.bufr.num.ref
bufr/smos_203.bufr.num.ref
bufr/sn4k_165.bufr.num.ref
bufr/soil_7.bufr.num.ref
bufr/ssbt_127.bufr.num.ref
bufr/stuk_7.bufr.num.ref
bufr/syno_1.bufr.num.ref
bufr/syno_2.bufr.num.ref
bufr/syno_3.bufr.num.ref
bufr/syno_4.bufr.num.ref
bufr/temp_101.bufr.num.ref
bufr/temp_102.bufr.num.ref
bufr/temp_106.bufr.num.ref
bufr/tmr7_129.bufr.num.ref
bufr/tros_31.bufr.num.ref
bufr/wavb_134.bufr.num.ref
"
[ -d "${DATA_DIR}/bufr" ] || mkdir "${DATA_DIR}/bufr"
[ -d "${DATA_DIR}/tigge" ] || mkdir "${DATA_DIR}/tigge"
# Decide what tool to use to download data
DNLD_PROG=""
if command -v wget >/dev/null 2>&1; then
DNLD_PROG="wget --tries=1 --timeout=3 -nv -q -O"
PROG=wget
OPTIONS="--tries=1 --timeout=3 -nv -q -O"
if [ $VERBOSE -eq 1 ]; then
OPTIONS="--tries=1 --timeout=3 -nv -O"
fi
DNLD_PROG="$PROG $OPTIONS"
fi
if command -v curl >/dev/null 2>&1; then
DNLD_PROG="curl --silent --show-error --fail --output"
PROG=curl
OPTIONS="--silent --show-error --fail --output"
if [ $VERBOSE -eq 1 ]; then
OPTIONS="--show-error --fail --output"
fi
DNLD_PROG="$PROG $OPTIONS"
fi
if test "x$DNLD_PROG" = "x"; then
echo "Cannot find tool to transfer data from download server. Aborting." 1>&2
@ -619,19 +396,23 @@ download_URL="http://download.ecmwf.org"
cd ${DATA_DIR}
echo "Downloading data files for testing..."
for f in $files; do
# If we haven't already got the file, download it
if [ ! -f "$f" ]; then
$DNLD_PROG $f ${download_URL}/test-data/grib_api/data/$f
if [ $? -ne 0 ]; then
echo "Failed to download file: $f"
exit 1
fi
#chmod 444 $f
if [ $VERBOSE -eq 1 ]; then
echo "Downloaded $f ..."
fi
fi
# If we haven't already got the file, download it
if [ ! -f "$f" ]; then
if [ $VERBOSE -eq 1 ]; then
echo "$DNLD_PROG $f ${download_URL}/test-data/grib_api/data/$f"
fi
$DNLD_PROG $f ${download_URL}/test-data/grib_api/data/$f
if [ $? -ne 0 ]; then
echo "Failed to download file: $f"
exit 1
fi
if [ $VERBOSE -eq 1 ]; then
echo "Downloaded $f ..."
fi
fi
done
# Add a file to indicate we've done the download
touch ${DOWNLOADED}
touch .downloaded
echo "Downloads completed."

View File

@ -126,7 +126,7 @@ concept packingType {
plusOneinOrdersOfSPD=1; twoOrdersOfSPD=1; }
"grid_jpeg" = { sphericalHarmonics = 0; complexPacking = 0; additionalFlagPresent = 0;}
"grid_png" = { sphericalHarmonics = 0; complexPacking = 0; additionalFlagPresent = 0;}
"grid_szip" = { sphericalHarmonics = 0; complexPacking = 0; additionalFlagPresent = 0;}
"grid_ccsds" = { sphericalHarmonics = 0; complexPacking = 0; additionalFlagPresent = 0;}
"grid_simple_log_preprocessing"= { sphericalHarmonics = 0; complexPacking = 0; additionalFlagPresent = 0;}
} : dump;

View File

@ -71,6 +71,7 @@ concept marsType {
}
}
# See GRIB-205 re no_copy
concept marsStream {
oper = {
@ -96,9 +97,7 @@ concept marsStream {
"default" = {
dummyc = 0;
}
}
} : no_copy;
alias mars.stream = marsStream;
alias mars.type = marsType;

View File

@ -71,6 +71,7 @@ concept marsType {
}
}
# See GRIB-205 re no_copy
concept marsStream {
oper = {
@ -96,9 +97,7 @@ concept marsStream {
"default" = {
dummyc = 0;
}
}
} : no_copy;
alias mars.stream = marsStream;
alias mars.type = marsType;

View File

@ -52,6 +52,7 @@ concept marsType {
}
}
# See GRIB-205 re no_copy
concept marsStream {
oper = {
@ -77,7 +78,7 @@ concept marsStream {
"default" = {
dummyc = 0;
}
}
} : no_copy;
alias mars.stream = marsStream;
alias mars.type = marsType;
@ -95,4 +96,3 @@ if (isHindcast == 1) {
alias mars.date = modelVersionDate;
alias mars.time = modelVersionTime;
}

View File

@ -52,6 +52,7 @@ concept marsType {
}
}
# See GRIB-205 re no_copy
concept marsStream {
oper = {
@ -77,7 +78,7 @@ concept marsStream {
"default" = {
dummyc = 0;
}
}
} : no_copy;
alias mars.stream = marsStream;
alias mars.type = marsType;
@ -95,4 +96,3 @@ if (isHindcast == 1) {
alias mars.date = modelVersionDate;
alias mars.time = modelVersionTime;
}

View File

@ -45,7 +45,7 @@ concept packingType (unknown) {
"grid_jpeg" = { dataRepresentationTemplateNumber = 40; }
"grid_png" = { dataRepresentationTemplateNumber = 40010; }
"grid_png" = { dataRepresentationTemplateNumber = 41; }
"grid_szip" = { dataRepresentationTemplateNumber = 42; }
"grid_ccsds" = { dataRepresentationTemplateNumber = 42; }
"grid_ieee" = { dataRepresentationTemplateNumber = 4; }
"grid_second_order" = { dataRepresentationTemplateNumber = 50001; }
"grid_second_order" = { dataRepresentationTemplateNumber = 50002; }

View File

@ -40,6 +40,12 @@
template section_4 "grib2/section.4.def";
}
# Used to mark end of headers. Can be accessed with grib_get_offset()
position endOfHeadersMaker;
meta lengthOfHeaders evaluate( endOfHeadersMaker-startOfHeaders);
meta md5Headers md5(startOfHeaders,lengthOfHeaders);
lookup[1] sectionNumber(4) ;
if(sectionNumber == 5 or new() ){
@ -47,12 +53,6 @@
template section_5 "grib2/section.5.def";
}
# Used to mark end of headers. Can be accessed with grib_get_offset()
position endOfHeadersMaker;
meta lengthOfHeaders evaluate( endOfHeadersMaker-startOfHeaders);
meta md5Headers md5(startOfHeaders,lengthOfHeaders);
lookup[1] sectionNumber(4) ;
if(sectionNumber == 6 or new() ){

View File

@ -49,18 +49,18 @@ alias latitudeWhereDxAndDyAreSpecifiedInDegrees=LaDInDegrees;
# NOTE 2 NOT FOUND
signed[4] orientationOfTheGrid : edition_specific;
alias LoV = orientationOfTheGrid ;
meta geography.orientationOfTheGridInDegrees scale(orientationOfTheGrid,oneConstant,grib2divider,truncateDegrees) : dump;
# Dx - X-direction grid length
# NOTE 3 NOT FOUND
# NOTE 3: Grid length is in units of 103 m at the latitude specified by LaD
unsigned[4] Dx : edition_specific;
meta geography.DxInMetres scale(Dx,oneConstant,grib1divider,truncateDegrees) : dump;
meta geography.DxInMetres scale(Dx,one,thousand,truncateDegrees) : dump;
alias xDirectionGridLength=Dx;
# Dy - Y-direction grid length
# NOTE 3 NOT FOUND
# NOTE 3: Grid length is in units of 103 m at the latitude specified by LaD
unsigned[4] Dy : edition_specific;
meta geography.DyInMetres scale(Dy,oneConstant,grib1divider,truncateDegrees) : dump;
meta geography.DyInMetres scale(Dy,one,thousand,truncateDegrees) : dump;
alias yDirectionGridLength=Dy;
# Projection centre flag
@ -69,4 +69,15 @@ flags[1] projectionCentreFlag 'grib2/tables/[tablesVersion]/3.5.table' : dump;
include "template.3.scanning_mode.def";
iterator polar_stereographic(numberOfPoints,missingValue,values,
radius,Nx,Ny,
latitudeOfFirstGridPointInDegrees,longitudeOfFirstGridPointInDegrees,
LaDInDegrees,orientationOfTheGridInDegrees,
DxInMetres,DyInMetres,
iScansNegatively,
jScansPositively,
jPointsAreConsecutive,
alternativeRowScanning);
# END 2/template.3.20 ----------------------------------------------------------------------

View File

@ -7,22 +7,19 @@
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#
# TEMPLATE 5.42, Grid point and spectral data - CCSDS szip
# TEMPLATE 5.42, Grid point and spectral data - CCSDS
include "template.5.packing.def";
include "template.5.original_values.def";
unsigned[1] szipOptionsMask : dump;
unsigned[1] ccsdsFlags : dump;
flagbit SZ_ALLOW_K13_OPTION_MASK(szipOptionsMask,0) = 0;
flagbit SZ_CHIP_OPTION_MASK(szipOptionsMask,1) = 0;
flagbit SZ_EC_OPTION_MASK(szipOptionsMask,2) = 0;
flagbit SZ_LSB_OPTION_MASK(szipOptionsMask,3) = 0;
flagbit SZ_MSB_OPTION_MASK(szipOptionsMask,4) = 1;
flagbit SZ_NN_OPTION_MASK(szipOptionsMask,5) = 1;
flagbit SZ_RAW_OPTION_MASK(szipOptionsMask,7) = 1;
unsigned[1] szipBitsPerPixel : dump;
unsigned[2] szipPixelPerBlock = 32 : dump;
unsigned[2] szipPixelPerScanLine = 128 * szipPixelPerBlock : dump;
flagbit AEC_DATA_SIGNED_OPTION_MASK(ccsdsFlags,0) = 0;
flagbit AEC_DATA_3BYTE_OPTION_MASK(ccsdsFlags,1) = 0;
flagbit AEC_DATA_MSB_OPTION_MASK(ccsdsFlags,2) = 1;
flagbit AEC_DATA_PREPROCESS_OPTION_MASK(ccsdsFlags,3) = 1;
flagbit AEC_RESTRICTED_OPTION_MASK(ccsdsFlags,4) = 0;
flagbit AEC_PAD_RSI_OPTION_MASK(ccsdsFlags,5) = 0;
unsigned[1] ccsdsBlockSize = 32 : dump;
unsigned[2] ccsdsRsi = 128 : dump;

View File

@ -9,9 +9,9 @@
# START 2/template.7.42 ----------------------------------------------------------------------
# TEMPLATE 7.42, Grid point data - CCSDS szip
# TEMPLATE 7.42, Grid point data - CCSDS
meta codedValues data_szip_packing(
meta codedValues data_ccsds_packing(
section7Length,
offsetBeforeData,
offsetSection7,
@ -23,10 +23,9 @@
numberOfDataPoints,
szipOptionsMask,
szipBitsPerPixel,
szipPixelPerBlock,
szipPixelPerScanLine
ccsdsFlags,
ccsdsBlockSize,
ccsdsRsi
): read_only;

View File

@ -13,10 +13,9 @@ import sys
from gribapi import *
INPUT='../../data/reduced_latlon_surface.grib1'
VERBOSE=1 # verbose error reporting
def example():
def example(INPUT):
f = open(INPUT)
while 1:
@ -50,7 +49,7 @@ def example():
def main():
try:
example()
example(sys.argv[1])
except GribInternalError,err:
if VERBOSE:
traceback.print_exc(file=sys.stderr)

View File

@ -5,8 +5,17 @@
TEMP1=temp1
TEMP2=temp2
$PYTHON iterator.py 2> $TEMP1 > $TEMP1
./p_iterator ../../data/reduced_latlon_surface.grib1 2> $TEMP2 > $TEMP2
FILE="${data_dir}/reduced_latlon_surface.grib1"
$PYTHON iterator.py $FILE 2> $TEMP1 > $TEMP1
./p_iterator $FILE 2> $TEMP2 > $TEMP2
diff $TEMP1 $TEMP2
# Polar stereographic
FILE="${GRIB_SAMPLES_PATH}/polar_stereographic_pl_grib2.tmpl"
$PYTHON iterator.py $FILE 2> $TEMP1 > $TEMP1
./p_iterator $FILE 2> $TEMP2 > $TEMP2
diff $TEMP1 $TEMP2
rm $TEMP1 $TEMP2 || true

View File

@ -93,7 +93,7 @@
#define HAVE_LIBPNG @HAVE_LIBPNG@
#cmakedefine HAVE_LIBSZIP
#cmakedefine HAVE_LIBAEC
#cmakedefine HAVE_NETCDF

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -205,7 +205,7 @@ list( APPEND grib_api_srcs
grib_accessor_class_data_g2secondary_bitmap.c
grib_accessor_class_data_jpeg2000_packing.c
grib_accessor_class_data_png_packing.c
grib_accessor_class_data_szip_packing.c
grib_accessor_class_data_ccsds_packing.c
grib_accessor_class_data_raw_packing.c
grib_accessor_class_data_complex_packing.c
grib_accessor_class_data_g1complex_packing.c

View File

@ -179,7 +179,7 @@ libgrib_api_la_prototypes= \
grib_accessor_class_values.c \
grib_accessor_class_simple_packing_error.c \
grib_accessor_class_data_simple_packing.c \
grib_accessor_class_data_szip_packing.c \
grib_accessor_class_data_ccsds_packing.c \
grib_accessor_class_count_missing.c \
grib_accessor_class_data_sh_packed.c \
grib_accessor_class_data_sh_unpacked.c \

View File

@ -37,12 +37,11 @@ or edit "action.class" and rerun ./make_class.pl
*/
static void init_class (grib_action_class*);
static void xref (grib_action* d, FILE* f,const char* path);
static int notify_change(grib_action* a, grib_accessor* observer,grib_accessor* observed);
static void init_class (grib_action_class*);
static void xref (grib_action* d, FILE* f,const char* path);
static int notify_change (grib_action* a, grib_accessor* observer,grib_accessor* observed);
static grib_action* reparse(grib_action* a,grib_accessor* acc,int *doit);
typedef struct grib_action_section {
grib_action act;
/* Members defined in section */
@ -167,7 +166,14 @@ static int notify_change(grib_action* act, grib_accessor * notified,
tmp_handle->use_trie=1;
err=grib_create_accessor(tmp_handle->root, act, &loader);
if (err) return err;
if (err) {
if (err == GRIB_NOT_FOUND) {
/* FIXME: Allow this error. Needed when changing some packingTypes */
err = GRIB_SUCCESS;
} else {
return err;
}
}
err = grib_section_adjust_sizes(tmp_handle->root,1,0);
if (err) return err;

View File

@ -63,7 +63,7 @@ extern grib_accessor_class* grib_accessor_class_data_sh_packed;
extern grib_accessor_class* grib_accessor_class_data_sh_unpacked;
extern grib_accessor_class* grib_accessor_class_data_shsimple_packing;
extern grib_accessor_class* grib_accessor_class_data_simple_packing;
extern grib_accessor_class* grib_accessor_class_data_szip_packing;
extern grib_accessor_class* grib_accessor_class_data_ccsds_packing;
extern grib_accessor_class* grib_accessor_class_decimal_precision;
extern grib_accessor_class* grib_accessor_class_dictionary;
extern grib_accessor_class* grib_accessor_class_dirty;

View File

@ -28,10 +28,9 @@
MEMBERS=const char* number_of_data_points
MEMBERS=const char* szip_options_mask
MEMBERS=const char* szip_bits_per_pixel
MEMBERS=const char* szip_pixels_per_block
MEMBERS=const char* szip_pixels_per_scanline
MEMBERS=const char* ccsds_flags
MEMBERS=const char* ccsds_block_size
MEMBERS=const char* ccsds_rsi
END_CLASS_DEF
@ -49,11 +48,11 @@ or edit "accessor.class" and rerun ./make_class.pl
static int pack_double(grib_accessor*, const double* val,size_t *len);
static int unpack_double(grib_accessor*, double* val,size_t *len);
static int value_count(grib_accessor*,long*);
static int value_count(grib_accessor*, long*);
static void init(grib_accessor*,const long, grib_arguments* );
static void init_class(grib_accessor_class*);
typedef struct grib_accessor_data_szip_packing {
typedef struct grib_accessor_data_ccsds_packing {
grib_accessor att;
/* Members defined in gen */
/* Members defined in values */
@ -62,25 +61,24 @@ typedef struct grib_accessor_data_szip_packing {
const char* offsetdata;
const char* offsetsection;
int dirty;
/* Members defined in data_szip_packing */
/* Members defined in data_ccsds_packing */
const char* number_of_values;
const char* reference_value;
const char* binary_scale_factor;
const char* decimal_scale_factor;
const char* bits_per_value;
const char* number_of_data_points;
const char* szip_options_mask;
const char* szip_bits_per_pixel;
const char* szip_pixels_per_block;
const char* szip_pixels_per_scanline;
} grib_accessor_data_szip_packing;
const char* ccsds_flags;
const char* ccsds_block_size;
const char* ccsds_rsi;
} grib_accessor_data_ccsds_packing;
extern grib_accessor_class* grib_accessor_class_values;
static grib_accessor_class _grib_accessor_class_data_szip_packing = {
static grib_accessor_class _grib_accessor_class_data_ccsds_packing = {
&grib_accessor_class_values, /* super */
"data_szip_packing", /* name */
sizeof(grib_accessor_data_szip_packing), /* size */
"data_ccsds_packing", /* name */
sizeof(grib_accessor_data_ccsds_packing), /* size */
0, /* inited */
&init_class, /* init_class */
&init, /* init */
@ -95,7 +93,7 @@ static grib_accessor_class _grib_accessor_class_data_szip_packing = {
0, /* get native type */
0, /* get sub_section */
0, /* grib_pack procedures long */
0, /* grib_pack procedures long */
0, /* grib_pack procedures long */
0, /* grib_pack procedures long */
0, /* grib_unpack procedures long */
&pack_double, /* grib_pack procedures double */
@ -120,7 +118,7 @@ static grib_accessor_class _grib_accessor_class_data_szip_packing = {
};
grib_accessor_class* grib_accessor_class_data_szip_packing = &_grib_accessor_class_data_szip_packing;
grib_accessor_class* grib_accessor_class_data_ccsds_packing = &_grib_accessor_class_data_ccsds_packing;
static void init_class(grib_accessor_class* c)
@ -138,8 +136,6 @@ static void init_class(grib_accessor_class* c)
c->unpack_long = (*(c->super))->unpack_long;
c->pack_string = (*(c->super))->pack_string;
c->unpack_string = (*(c->super))->unpack_string;
c->pack_string_array = (*(c->super))->pack_string_array;
c->unpack_string_array = (*(c->super))->unpack_string_array;
c->pack_bytes = (*(c->super))->pack_bytes;
c->unpack_bytes = (*(c->super))->unpack_bytes;
c->pack_expression = (*(c->super))->pack_expression;
@ -159,54 +155,53 @@ static void init_class(grib_accessor_class* c)
static void init(grib_accessor* a,const long v, grib_arguments* args)
{
grib_accessor_data_szip_packing *self =(grib_accessor_data_szip_packing*)a;
grib_accessor_data_ccsds_packing *self =(grib_accessor_data_ccsds_packing*)a;
self->number_of_values = grib_arguments_get_name(a->parent->h,args,self->carg++);
self->reference_value = grib_arguments_get_name(a->parent->h,args,self->carg++);
self->binary_scale_factor = grib_arguments_get_name(a->parent->h,args,self->carg++);
self->decimal_scale_factor = grib_arguments_get_name(a->parent->h,args,self->carg++);
self->bits_per_value = grib_arguments_get_name(a->parent->h,args,self->carg++);
self->bits_per_value = grib_arguments_get_name(a->parent->h,args,self->carg++);
self->number_of_data_points = grib_arguments_get_name(a->parent->h,args,self->carg++);
self->szip_options_mask = grib_arguments_get_name(a->parent->h,args,self->carg++);
self->szip_bits_per_pixel = grib_arguments_get_name(a->parent->h,args,self->carg++);
self->szip_pixels_per_block = grib_arguments_get_name(a->parent->h,args,self->carg++);
self->szip_pixels_per_scanline = grib_arguments_get_name(a->parent->h,args,self->carg++);
self->ccsds_flags = grib_arguments_get_name(a->parent->h,args,self->carg++);
self->ccsds_block_size = grib_arguments_get_name(a->parent->h,args,self->carg++);
self->ccsds_rsi = grib_arguments_get_name(a->parent->h,args,self->carg++);
a->flags |= GRIB_ACCESSOR_FLAG_DATA;
}
static int value_count(grib_accessor* a, long* count)
{
grib_accessor_data_szip_packing *self =(grib_accessor_data_szip_packing*)a;
grib_accessor_data_ccsds_packing *self =(grib_accessor_data_ccsds_packing*)a;
*count = 0;
return grib_get_long_internal(a->parent->h,self->number_of_values,count);
}
#ifdef HAVE_LIBSZIP
#ifdef HAVE_LIBAEC
#include "szlib.h"
#include <libaec.h>
static int unpack_double(grib_accessor* a, double* val, size_t *len)
{
grib_accessor_data_szip_packing *self =(grib_accessor_data_szip_packing*)a;
grib_accessor_data_ccsds_packing *self =(grib_accessor_data_ccsds_packing*)a;
int err = GRIB_SUCCESS;
int i,j;
int i;
size_t buflen = grib_byte_count(a);
SZ_com_t sz_options;
struct aec_stream strm;
double bscale = 0;
double dscale = 0;
unsigned char* buf = NULL;
long n_vals = 0;
size_t n_vals = 0;
size_t size;
unsigned char* decoded = NULL;
unsigned char *p = NULL;
long pos = 0;
long nn=0;
long binary_scale_factor = 0;
long decimal_scale_factor = 0;
@ -214,16 +209,15 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
long bits_per_value =0;
long bits8;
long szip_options_mask ;
long szip_bits_per_pixel ;
long szip_pixels_per_block ;
long szip_pixels_per_scanline ;
long ccsds_flags;
long ccsds_block_size;
long ccsds_rsi;
self->dirty=0;
if((err = grib_value_count(a, &n_vals)) != GRIB_SUCCESS)
if((err = grib_value_count(a, &nn)) != GRIB_SUCCESS)
return err;
n_vals=nn;
if((err = grib_get_long_internal(a->parent->h,self->bits_per_value,&bits_per_value)) != GRIB_SUCCESS)
return err;
@ -234,16 +228,12 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
if((err = grib_get_long_internal(a->parent->h,self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS)
return err;
if((err = grib_get_long_internal(a->parent->h,self->szip_options_mask,&szip_options_mask)) != GRIB_SUCCESS)
if((err = grib_get_long_internal(a->parent->h,self->ccsds_flags,&ccsds_flags)) != GRIB_SUCCESS)
return err;
if((err = grib_get_long_internal(a->parent->h,self->szip_bits_per_pixel, &szip_bits_per_pixel)) != GRIB_SUCCESS)
if((err = grib_get_long_internal(a->parent->h,self->ccsds_block_size, &ccsds_block_size)) != GRIB_SUCCESS)
return err;
if((err = grib_get_long_internal(a->parent->h,self->szip_pixels_per_block, &szip_pixels_per_block)) != GRIB_SUCCESS)
if((err = grib_get_long_internal(a->parent->h,self->ccsds_rsi, &ccsds_rsi)) != GRIB_SUCCESS)
return err;
if((err = grib_get_long_internal(a->parent->h,self->szip_pixels_per_scanline, &szip_pixels_per_scanline)) != GRIB_SUCCESS)
return err;
bscale = grib_power(binary_scale_factor,2);
dscale = grib_power(-decimal_scale_factor,10);
@ -265,11 +255,13 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
buf = (unsigned char*)a->parent->h->buffer->data;
buf += grib_byte_offset(a);
memset(&sz_options, 0, sizeof(sz_options));
sz_options.options_mask = szip_options_mask;
sz_options.bits_per_pixel = szip_bits_per_pixel;
sz_options.pixels_per_block = szip_pixels_per_block;
sz_options.pixels_per_scanline = szip_pixels_per_scanline;
strm.flags = ccsds_flags;
strm.bits_per_sample = bits_per_value;
strm.block_size = ccsds_block_size;
strm.rsi = ccsds_rsi;
strm.next_in = buf;
strm.avail_in = buflen;
/*
printf("sz_options.options_mask %d\n", sz_options.options_mask);
@ -278,18 +270,19 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
printf("sz_options.pixels_per_scanline %d\n", sz_options.pixels_per_scanline);
*/
bits8 = ((szip_bits_per_pixel + 7)/8)*8;
size = n_vals * (szip_bits_per_pixel + 7)/8;
bits8 = ((bits_per_value + 7)/8)*8;
size = n_vals * (bits_per_value + 7)/8;
decoded = grib_context_buffer_malloc_clear(a->parent->h->context,size);
if(!decoded) {
err = GRIB_OUT_OF_MEMORY;
goto cleanup;
}
strm.next_out = decoded;
strm.avail_out = size;
if((err = SZ_BufftoBuffDecompress( decoded,&size,buf, buflen , &sz_options)) != SZ_OK)
if((err = aec_buffer_decode(&strm)) != AEC_OK)
{
printf("SZ_BufftoBuffDecompress Error %d\n", err);
printf("aec_buffer_decode Error %d\n", err);
err = GRIB_ENCODING_ERROR;
goto cleanup;
}
@ -315,7 +308,7 @@ cleanup:
static int pack_double(grib_accessor* a, const double* val, size_t *len)
{
grib_accessor_data_szip_packing *self =(grib_accessor_data_szip_packing*)a;
grib_accessor_data_ccsds_packing *self =(grib_accessor_data_ccsds_packing*)a;
int err = GRIB_SUCCESS;
int i;
@ -323,7 +316,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
unsigned char* buf = NULL;
unsigned char* encoded = NULL;
long n_vals = 0;
size_t n_vals = 0;
long nn=0;
long binary_scale_factor = 0;
long decimal_scale_factor = 0;
@ -334,28 +328,22 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
double d;
unsigned char *p;
double divisor;
long ni,nj;
long scanning_mode;
long list_defining_points;
long number_of_data_points;
long szip_options_mask ;
long szip_bits_per_pixel ;
long szip_pixels_per_block ;
long szip_pixels_per_scanline ;
long ccsds_flags;
long ccsds_block_size;
long ccsds_rsi;
size_t width, height;
SZ_com_t sz_options;
struct aec_stream strm;
self->dirty=1;
if((err = grib_value_count(a, &n_vals)) != GRIB_SUCCESS)
if((err = grib_value_count(a, &nn)) != GRIB_SUCCESS)
return err;
n_vals=nn;
if((err = grib_get_long_internal(a->parent->h,self->bits_per_value,&bits_per_value)) != GRIB_SUCCESS)
return err;
@ -367,13 +355,11 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
return err;
if((err = grib_get_long_internal(a->parent->h,self->szip_options_mask,&szip_options_mask)) != GRIB_SUCCESS)
if((err = grib_get_long_internal(a->parent->h,self->ccsds_flags,&ccsds_flags)) != GRIB_SUCCESS)
return err;
if((err = grib_get_long_internal(a->parent->h,self->szip_bits_per_pixel, &szip_bits_per_pixel)) != GRIB_SUCCESS)
if((err = grib_get_long_internal(a->parent->h,self->ccsds_block_size, &ccsds_block_size)) != GRIB_SUCCESS)
return err;
if((err = grib_get_long_internal(a->parent->h,self->szip_pixels_per_block, &szip_pixels_per_block)) != GRIB_SUCCESS)
return err;
if((err = grib_get_long_internal(a->parent->h,self->szip_pixels_per_scanline, &szip_pixels_per_scanline)) != GRIB_SUCCESS)
if((err = grib_get_long_internal(a->parent->h,self->ccsds_rsi, &ccsds_rsi)) != GRIB_SUCCESS)
return err;
@ -470,7 +456,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
/* buflen = n_vals*(bits_per_value/8);*/
grib_context_log(a->parent->h->context, GRIB_LOG_DEBUG,
"grib_accessor_data_szip_packing : pack_double : packing %s, %d values", a->name, n_vals);
"grib_accessor_data_ccsds_packing : pack_double : packing %s, %d values", a->name, n_vals);
buflen += 10240;
buf = grib_context_buffer_malloc_clear(a->parent->h->context,buflen);
@ -497,11 +483,15 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
return err;
memset(&sz_options, 0, sizeof(sz_options));
sz_options.options_mask = szip_options_mask;
sz_options.bits_per_pixel = bits_per_value;
sz_options.pixels_per_block = szip_pixels_per_block;
sz_options.pixels_per_scanline = szip_pixels_per_scanline;
strm.flags = ccsds_flags;
strm.bits_per_sample = bits_per_value;
strm.block_size = ccsds_block_size;
strm.rsi = ccsds_rsi;
strm.next_out = buf;
strm.avail_out = buflen;
strm.next_in = encoded;
strm.avail_in = bits8/8*n_vals;
/*
@ -516,9 +506,9 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
printf("sz_options.pixels_per_scanline %d\n", sz_options.pixels_per_scanline);
*/
if((err = SZ_BufftoBuffCompress(buf,&buflen,encoded, bits8/8*n_vals, &sz_options)) != SZ_OK)
if((err = aec_buffer_encode(&strm)) != AEC_OK)
{
printf("SZ_BufftoBuffCompress Error %d\n", err);
printf("aec_buffer_encode Error %d\n", err);
err = GRIB_ENCODING_ERROR;
goto cleanup;
}
@ -528,7 +518,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
printf("n_vals = %ld, bits8 = %ld\n", (long)n_vals, (long)bits8);
printf("in %ld out => %ld\n", (long)bits8/8*n_vals,(long) buflen);
*/
buflen = strm.total_out;
grib_buffer_replace(a, buf, buflen ,1,1);
cleanup:
@ -539,7 +529,7 @@ cleanup:
err = grib_set_long_internal(a->parent->h,self->number_of_values, *len);
if(err == GRIB_SUCCESS)
err = grib_set_long_internal(a->parent->h,self->szip_bits_per_pixel, sz_options.bits_per_pixel);
err = grib_set_long_internal(a->parent->h,self->bits_per_value, strm.bits_per_sample);
return err;
}
@ -548,14 +538,14 @@ cleanup:
static int unpack_double(grib_accessor* a, double* val, size_t *len)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
"grib_accessor_data_szip_packing : szip support no enabled. Please rerun configure with --with-szip-support");
"grib_accessor_data_ccsds_packing : ccsds support no enabled. Please rerun configure with --with-aec");
return GRIB_NOT_IMPLEMENTED;
}
static int pack_double(grib_accessor* a, const double* val, size_t *len)
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR,
"grib_accessor_data_szip_packing : szip support no enabled. Please rerun configure with --with-szip-support");
"grib_accessor_data_ccsds_packing : ccsds support no enabled. Please rerun configure with --with-aec");
return GRIB_NOT_IMPLEMENTED;
}

View File

@ -8,10 +8,6 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
/********************************
* Enrico Fucile
********************************/
#include "grib_api_internal.h"
/*
This is used by make_class.pl
@ -180,18 +176,13 @@ static int unpack_double (grib_accessor* a, double* val, size_t *len)
if(*len < 1) return GRIB_ARRAY_TOO_SMALL;
if((ret = grib_get_long_internal(a->parent->h,
self->directionIncrementGiven,&directionIncrementGiven))
!= GRIB_SUCCESS)
if((ret = grib_get_long_internal(a->parent->h, self->directionIncrementGiven,&directionIncrementGiven)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(a->parent->h, self->scansPositively,&scansPositively))
!= GRIB_SUCCESS)
if((ret = grib_get_long_internal(a->parent->h, self->scansPositively,&scansPositively)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(a->parent->h,
self->directionIncrement,&directionIncrement))
!= GRIB_SUCCESS)
if((ret = grib_get_long_internal(a->parent->h, self->directionIncrement,&directionIncrement)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_double_internal(a->parent->h, self->first,&first)) != GRIB_SUCCESS)
@ -200,27 +191,47 @@ static int unpack_double (grib_accessor* a, double* val, size_t *len)
if((ret = grib_get_double_internal(a->parent->h, self->last,&last)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(a->parent->h, self->numberOfPoints,&numberOfPoints))
!= GRIB_SUCCESS)
if((ret = grib_get_long_internal(a->parent->h, self->numberOfPoints,&numberOfPoints)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(a->parent->h, self->angleMultiplier,&angleMultiplier)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(a->parent->h, self->angleDivisor,&angleDivisor))
!= GRIB_SUCCESS)
if((ret = grib_get_long_internal(a->parent->h, self->angleDivisor,&angleDivisor)) != GRIB_SUCCESS)
return ret;
if (self->isLongitude) {
if (last < first && scansPositively) last+=360;
if (last > first && !scansPositively) first-=360;
/*if (last > first && !scansPositively) first-=360;*/
}
if (!directionIncrementGiven && numberOfPoints != GRIB_MISSING_LONG) {
*val = fabs(last-first)/(double)(numberOfPoints-1);
} else if (numberOfPoints == GRIB_MISSING_LONG){
if (!directionIncrementGiven && numberOfPoints != GRIB_MISSING_LONG)
{
if (!scansPositively) { /* scans negatively */
if (first > last){
*val=(first-last)/(numberOfPoints-1);
}
else {
*val=(first+360.0-last)/(numberOfPoints-1);
}
}
else
{
/* scans positively */
if (last > first){
*val=(last-first)/(numberOfPoints-1);
}
else {
*val=(last+360.0-first)/(numberOfPoints-1);
}
}
}
else if (numberOfPoints == GRIB_MISSING_LONG)
{
*val = GRIB_MISSING_DOUBLE;
} else {
}
else
{
Assert(angleDivisor!=0);
*val = (double)directionIncrement/angleDivisor*angleMultiplier;
}
@ -239,7 +250,6 @@ static int unpack_double (grib_accessor* a, double* val, size_t *len)
return ret;
}
static int pack_double(grib_accessor* a, const double* val, size_t *len)
{
grib_accessor_latlon_increment* self = (grib_accessor_latlon_increment*)a;
@ -296,11 +306,10 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
}
}
/*ret = grib_set_long_internal(a->parent->h, self->numberOfPoints,numberOfPoints);
if(ret )
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Accessor %s cannont pack value for %s error %d \n", a->name, self->numberOfPoints, ret);*/
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Accessor %s cannot pack value for %s error %d \n", a->name, self->numberOfPoints, ret);
*/
grib_get_long_internal(a->parent->h, self->numberOfPoints,&codedNumberOfPoints);
@ -334,4 +343,3 @@ static int is_missing(grib_accessor* a){
return (val == GRIB_MISSING_DOUBLE);
}

View File

@ -63,7 +63,7 @@
{ "data_sh_unpacked", &grib_accessor_class_data_sh_unpacked, },
{ "data_shsimple_packing", &grib_accessor_class_data_shsimple_packing, },
{ "data_simple_packing", &grib_accessor_class_data_simple_packing, },
{ "data_szip_packing", &grib_accessor_class_data_szip_packing, },
{ "data_ccsds_packing", &grib_accessor_class_data_ccsds_packing, },
{ "decimal_precision", &grib_accessor_class_decimal_precision, },
{ "dictionary", &grib_accessor_class_dictionary, },
{ "dirty", &grib_accessor_class_dirty, },

View File

@ -67,7 +67,7 @@ data_sh_packed, &grib_accessor_class_data_sh_packed
data_sh_unpacked, &grib_accessor_class_data_sh_unpacked
data_shsimple_packing, &grib_accessor_class_data_shsimple_packing
data_simple_packing, &grib_accessor_class_data_simple_packing
data_szip_packing, &grib_accessor_class_data_szip_packing
data_ccsds_packing, &grib_accessor_class_data_ccsds_packing
decimal_precision, &grib_accessor_class_decimal_precision
descriptors, &grib_accessor_class_descriptors
dictionary, &grib_accessor_class_dictionary

View File

@ -169,7 +169,7 @@ double rint(double x);
#define GRIB_HANDLE_BIG_ECMWF_GRIB1 1
#define MAX_FILE_HANDLES_WITH_MULTI 10
#define ACCESSORS_ARRAY_SIZE 2000
#define ACCESSORS_ARRAY_SIZE 2100
#define MAX_NUM_CONCEPTS 2000
#define MAX_NUM_HASH_ARRAY 2000

View File

@ -495,8 +495,6 @@ int grib_get_g1_message_size(grib_handle *h, grib_accessor *tl, grib_accessor *s
/* grib_accessor_class_data_simple_packing.c */
/* grib_accessor_class_data_szip_packing.c */
/* grib_accessor_class_count_missing.c */
/* grib_accessor_class_data_sh_packed.c */

File diff suppressed because it is too large Load Diff

View File

@ -621,8 +621,10 @@ static void grib_field_delete(grib_context* c,grib_field* field)
grib_field_delete(c,field->next);
grib_file_close(field->file->name,&err);
field->file=NULL;
if (field->file) {
grib_file_close(field->file->name,&err);
field->file=NULL;
}
grib_context_free(c,field);
@ -1290,8 +1292,7 @@ int grib_index_get_long(grib_index* index, const char* key, long* values, size_t
while (k && strcmp(k->name,key)) k=k->next;
if (!k) return GRIB_NOT_FOUND;
if (k->type != GRIB_TYPE_LONG) {
grib_context_log(index->context,GRIB_LOG_ERROR,
"unable to get index %s as long");
grib_context_log(index->context,GRIB_LOG_ERROR, "unable to get index %s as long", key);
return GRIB_WRONG_TYPE;
}
if (k->values_count > *size) return GRIB_ARRAY_TOO_SMALL;
@ -1317,8 +1318,7 @@ int grib_index_get_double(grib_index* index,const char* key, double* values,size
while (k && strcmp(k->name,key)) k=k->next;
if (!k) return GRIB_NOT_FOUND;
if (k->type != GRIB_TYPE_DOUBLE) {
grib_context_log(index->context,GRIB_LOG_ERROR,
"unable to get index %s as double");
grib_context_log(index->context,GRIB_LOG_ERROR, "unable to get index %s as double", key);
return GRIB_WRONG_TYPE;
}
if (k->values_count>*size) return GRIB_ARRAY_TOO_SMALL;

View File

@ -8,11 +8,6 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
/**************************************
* Enrico Fucile
**************************************/
#include "grib_api_internal.h"
#include <math.h>
@ -88,192 +83,175 @@ static void init_class(grib_iterator_class* c)
static int next(grib_iterator* i, double *lat, double *lon, double *val)
{
grib_iterator_polar_stereographic* self = (grib_iterator_polar_stereographic*)i;
grib_iterator_polar_stereographic* self = (grib_iterator_polar_stereographic*)i;
if((long)i->e >= (long)(i->nv-1))
return 0;
i->e++;
if((long)i->e >= (long)(i->nv-1))
return 0;
i->e++;
*lat = self->lats[i->e];
*lon = self->lons[i->e];
*val = i->data[i->e];
*lat = self->lats[i->e];
*lon = self->lons[i->e];
*val = i->data[i->e];
return 1;
return 1;
}
#define RAD2DEG 57.29577951308232087684 /* 180 over pi */
#define DEG2RAD 0.01745329251994329576 /* pi over 180 */
static int init(grib_iterator* iter,grib_handle* h,grib_arguments* args)
{
int ret=0;
double *lats,*lons;
double lonFirstInDegrees,latFirstInDegrees,lonFirst,latFirst,radius=0;
long nx,ny,standardParallel,centralLongitude;
double phi,lambda0,xFirst,yFirst,x,y,Dx,Dy;
double kp,sinphi1,cosphi1,sinlambda0,coslambda0;
long alternativeRowScanning,iScansNegatively;
long jScansPositively,jPointsAreConsecutive;
double sinphi,cosphi,sinlambda,coslambda,cosdlambda,sindlambda;
double cosc,sinc;
long i,j;
int ret=0;
double *lats,*lons;
double lonFirstInDegrees,latFirstInDegrees,lonFirst,latFirst,radius=0;
long nx,ny,standardParallel,centralLongitude;
double phi,lambda0,xFirst,yFirst,x,y,Dx,Dy;
double k,sinphi1,cosphi1;
long alternativeRowScanning,iScansNegatively;
long jScansPositively,jPointsAreConsecutive;
double sinphi,cosphi,cosdlambda,sindlambda;
double cosc,sinc;
long i,j;
grib_iterator_polar_stereographic* self =
(grib_iterator_polar_stereographic*)iter;
grib_iterator_polar_stereographic* self = (grib_iterator_polar_stereographic*)iter;
const char* sradius = grib_arguments_get_name(h,args,self->carg++);
const char* snx = grib_arguments_get_name(h,args,self->carg++);
const char* sny = grib_arguments_get_name(h,args,self->carg++);
const char* slatFirstInDegrees = grib_arguments_get_name(h,args,self->carg++);
const char* slonFirstInDegrees = grib_arguments_get_name(h,args,self->carg++);
const char* sstandardParallel = grib_arguments_get_name(h,args,self->carg++);
const char* scentralLongitude = grib_arguments_get_name(h,args,self->carg++);
const char* sDx = grib_arguments_get_name(h,args,self->carg++);
const char* sDy = grib_arguments_get_name(h,args,self->carg++);
const char* siScansNegatively = grib_arguments_get_name(h,args,self->carg++);
const char* sjScansPositively = grib_arguments_get_name(h,args,self->carg++);
const char* sjPointsAreConsecutive = grib_arguments_get_name(h,args,self->carg++);
const char* salternativeRowScanning = grib_arguments_get_name(h,args,self->carg++);
double c,rho;
double d2r=acos(0.0)/90.0;
double pi4=acos(0.0)/2.0;
sinphi1 = cosphi1 = phi = 0.0; /*TODO initialize properly*/
if((ret = grib_get_double_internal(h, sradius,&radius)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(h, snx,&nx)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(h, sny,&ny)) != GRIB_SUCCESS)
return ret;
const char* sradius = grib_arguments_get_name(h,args,self->carg++);
const char* snx = grib_arguments_get_name(h,args,self->carg++);
const char* sny = grib_arguments_get_name(h,args,self->carg++);
const char* slatFirstInDegrees = grib_arguments_get_name(h,args,self->carg++);
const char* slonFirstInDegrees = grib_arguments_get_name(h,args,self->carg++);
const char* sstandardParallel = grib_arguments_get_name(h,args,self->carg++);
const char* scentralLongitude = grib_arguments_get_name(h,args,self->carg++);
const char* sDx = grib_arguments_get_name(h,args,self->carg++);
const char* sDy = grib_arguments_get_name(h,args,self->carg++);
const char* siScansNegatively = grib_arguments_get_name(h,args,self->carg++);
const char* sjScansPositively = grib_arguments_get_name(h,args,self->carg++);
const char* sjPointsAreConsecutive = grib_arguments_get_name(h,args,self->carg++);
const char* salternativeRowScanning = grib_arguments_get_name(h,args,self->carg++);
double c,rho;
/*double pi4=acos(0.0)/2.0;*/
sinphi1 = cosphi1 = phi = 0.0;
if (iter->nv!=nx*ny) {
grib_context_log(h->context,GRIB_LOG_ERROR,
"Wrong number of points (%ld!=%ldx%ld)",
iter->nv,nx,ny);
return GRIB_WRONG_GRID;
}
if((ret = grib_get_double_internal(h, slatFirstInDegrees,&latFirstInDegrees))
!= GRIB_SUCCESS)
return ret;
if((ret = grib_get_double_internal(h, slonFirstInDegrees,&lonFirstInDegrees))
!= GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(h, sstandardParallel,&standardParallel))
!= GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(h, scentralLongitude,&centralLongitude))
!= GRIB_SUCCESS)
return ret;
if((ret = grib_get_double_internal(h, sDx,&Dx)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_double_internal(h, sDy,&Dy)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(h,
sjPointsAreConsecutive,&jPointsAreConsecutive))
!= GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(h, sjScansPositively,&jScansPositively))
!= GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(h, siScansNegatively,&iScansNegatively))
!= GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(h,
salternativeRowScanning,&alternativeRowScanning))
!= GRIB_SUCCESS)
return ret;
if((ret = grib_get_double_internal(h, sradius,&radius)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(h, snx,&nx)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(h, sny,&ny)) != GRIB_SUCCESS)
return ret;
lambda0=d2r*standardParallel;
latFirst=latFirstInDegrees*d2r;
lonFirst=lonFirstInDegrees*d2r;
coslambda0=cos(lambda0);
sinlambda0=sin(lambda0);
Dx = iScansNegatively == 0 ? Dx : -Dx;
Dy = jScansPositively == 1 ? Dy : -Dy;
self->lats = grib_context_malloc(h->context,iter->nv*sizeof(double));
if (!self->lats) {
grib_context_log(h->context,GRIB_LOG_ERROR,
"unable to allocate %ld bytes",iter->nv*sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
self->lons = grib_context_malloc(h->context,iter->nv*sizeof(double));
if (!self->lats) {
grib_context_log(h->context,GRIB_LOG_ERROR,
"unable to allocate %ld bytes",iter->nv*sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
lats=self->lats;
lons=self->lons;
/* compute xFirst,yFirst in metres */
sinphi=sin(latFirst);
cosphi=cos(latFirst);
sinlambda=sin(lonFirst);
coslambda=cos(lonFirst);
cosdlambda=cos(lonFirst-lambda0);
sindlambda=sin(lonFirst-lambda0);
kp=radius*2.0*tan(pi4-phi/2);
xFirst=kp*cosphi*sindlambda;
yFirst=-kp*cosphi*cosdlambda;
if (jPointsAreConsecutive) {
x=xFirst;
for (i=0;i<nx;i++) {
y=yFirst;
for (j=0;j<ny;j++) {
rho=sqrt(x*x+y*y);
c=2*atan2(rho,(2.0*radius));
cosc=cos(c);
sinc=sin(c);
*lats=asin(cosc)/d2r;
*lons=(lambda0+atan2(x*sinc,rho*cosphi1*cosc-y*sinphi1*sinc))/d2r;
if (*lons<0) *lons+=360;
lons++;
lats++;
y+=Dy;
}
x+=Dx;
if (iter->nv!=nx*ny) {
grib_context_log(h->context,GRIB_LOG_ERROR, "Wrong number of points (%ld!=%ldx%ld)", iter->nv,nx,ny);
return GRIB_WRONG_GRID;
}
} else {
if((ret = grib_get_double_internal(h, slatFirstInDegrees,&latFirstInDegrees)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_double_internal(h, slonFirstInDegrees,&lonFirstInDegrees)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(h, sstandardParallel,&standardParallel)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(h, scentralLongitude,&centralLongitude)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_double_internal(h, sDx,&Dx)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_double_internal(h, sDy,&Dy)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(h, sjPointsAreConsecutive,&jPointsAreConsecutive)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(h, sjScansPositively,&jScansPositively)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(h, siScansNegatively,&iScansNegatively)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(h, salternativeRowScanning,&alternativeRowScanning)) != GRIB_SUCCESS)
return ret;
y=yFirst;
for (j=0;j<ny;j++) {
x=xFirst;
for (i=0;i<nx;i++) {
rho=sqrt(x*x+y*y);
c=2*atan2(rho,(2.0*radius));
cosc=cos(c);
sinc=sin(c);
*lats=asin(cosc*sinphi1+y*sinc*cosphi1/rho)/d2r;
*lons=(lambda0+atan2(x*sinc,rho*cosphi1*cosc-y*sinphi1*sinc))/d2r;
if (*lons<0) *lons+=360;
lons++;
lats++;
sinphi1 = sin(standardParallel*DEG2RAD);
cosphi1 = cos(standardParallel*DEG2RAD);
lambda0 = centralLongitude*DEG2RAD;
latFirst= latFirstInDegrees*DEG2RAD;
lonFirst= lonFirstInDegrees*DEG2RAD;
x+=Dx;
}
y+=Dy;
Dx = iScansNegatively == 0 ? Dx : -Dx;
Dy = jScansPositively == 1 ? Dy : -Dy;
self->lats = grib_context_malloc(h->context,iter->nv*sizeof(double));
if (!self->lats) {
grib_context_log(h->context,GRIB_LOG_ERROR, "unable to allocate %ld bytes",iter->nv*sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
self->lons = grib_context_malloc(h->context,iter->nv*sizeof(double));
if (!self->lats) {
grib_context_log(h->context,GRIB_LOG_ERROR, "unable to allocate %ld bytes",iter->nv*sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
lats=self->lats;
lons=self->lons;
}
iter->e = -1;
/* compute xFirst,yFirst in metres */
sinphi=sin(latFirst);
cosphi=cos(latFirst);
cosdlambda=cos(lonFirst-lambda0);
sindlambda=sin(lonFirst-lambda0);
return ret;
k = 2.0 * radius / ( 1 + sinphi1*sinphi + cosphi1*cosphi*cosdlambda );
xFirst = k * cosphi * sindlambda;
yFirst = k * (cosphi1*sinphi - sinphi1*cosphi*cosdlambda);
/*kp=radius*2.0*tan(pi4-phi/2);
xFirst=kp*cosphi*sindlambda;
yFirst=-kp*cosphi*cosdlambda;*/
if (jPointsAreConsecutive)
{
x=xFirst;
for (i=0;i<nx;i++) {
y=yFirst;
for (j=0;j<ny;j++) {
rho=sqrt(x*x+y*y);
c=2*atan2(rho,(2.0*radius));
cosc=cos(c);
sinc=sin(c);
*lats = asin( cosc*sinphi1 + y*sinc*cosphi1/rho ) * RAD2DEG;
*lons = (lambda0+atan2(x*sinc, rho*cosphi1*cosc - y*sinphi1*sinc)) * RAD2DEG;
if (*lons<0) *lons+=360;
lons++;
lats++;
y+=Dy;
}
x+=Dx;
}
}
else
{
y=yFirst;
for (j=0;j<ny;j++) {
x=xFirst;
for (i=0;i<nx;i++) {
rho=sqrt(x*x+y*y);
c=2*atan2(rho,(2.0*radius));
cosc=cos(c);
sinc=sin(c);
*lats = asin( cosc*sinphi1 + y*sinc*cosphi1/rho ) * RAD2DEG;
*lons = (lambda0+atan2(x*sinc, rho*cosphi1*cosc - y*sinphi1*sinc)) * RAD2DEG;
if (*lons<0) *lons+=360;
lons++;
lats++;
x+=Dx;
}
y+=Dy;
}
}
iter->e = -1;
return ret;
}
static int destroy(grib_iterator* i)
{
grib_iterator_polar_stereographic* self = (grib_iterator_polar_stereographic*)i;
const grib_context *c = i->h->context;
grib_iterator_polar_stereographic* self = (grib_iterator_polar_stereographic*)i;
const grib_context *c = i->h->context;
grib_context_free(c,self->lats);
grib_context_free(c,self->lons);
return 1;
grib_context_free(c,self->lats);
grib_context_free(c,self->lons);
return 1;
}

View File

@ -100,3 +100,11 @@ ecbuild_add_test( TARGET t_jpeg
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/jpeg.sh
RESOURCES include.sh
)
ecbuild_add_test( TARGET t_ccsds
TYPE SCRIPT
CONDITION ENABLE_AEC
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/ccsds.sh
RESOURCES include.sh
)

View File

@ -10,12 +10,13 @@ TESTS = definitions.sh \
bitmap.sh list.sh second_order.sh \
multi_from_message.sh change_scanning.sh \
julian.sh statistics.sh tigge.sh tigge_conversions.sh \
read_any.sh padding.sh lamb_az_eq_area.sh grib_to_netcdf.sh \
debug.sh $(JPEG_TEST)
read_any.sh padding.sh lamb_az_eq_area.sh grib_to_netcdf.sh debug.sh \
$(JPEG_TEST) $(CCSDS_TEST)
noinst_PROGRAMS = packing_check gauss_sub read_any double_cmp packing pack_unpack \
multi_from_message julian read_index index gribex_perf\
jpeg_perf so_perf png_perf bpv_limit laplacian unit_tests
jpeg_perf ccsds_perf so_perf png_perf bpv_limit laplacian \
unit_tests
multi_from_message_SOURCES = multi_from_message.c
laplacian_SOURCES = laplacian.c
@ -31,6 +32,7 @@ read_index_SOURCES = read_index.c
jpeg_perf_SOURCES = jpeg_perf.c
so_perf_SOURCES = so_perf.c
png_perf_SOURCES = png_perf.c
ccsds_perf_SOURCES = ccsds_perf.c
gribex_perf_SOURCES = gribex_perf.c
gauss_sub_SOURCES = gauss_sub.c

View File

@ -3,7 +3,7 @@
#
# 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.
#
@ -19,9 +19,6 @@ infile=${data_dir}/reduced_gaussian_model_level.grib1
outfile=${data_dir}/with_bitmap.grib1
outfile1=${data_dir}/without_bitmap.grib1
# Create the grib2 file from grib1
${tools_dir}grib_set -s editionNumber=2 $grib1 $grib2 2> $REDIRECT > $REDIRECT
rm -f $outfile || true
${tools_dir}grib_set -s bitmapPresent=1 $infile $outfile >$REDIRECT
@ -52,7 +49,7 @@ set values={1,2,3,4,5,6,7,1111,1111,8,9,10};
write ;
EOF
${tools_dir}grib_filter -o out.grib1 bitmap.rules $grib1
${tools_dir}grib_filter -o out.grib1 bitmap.rules $grib1
${tools_dir}grib_filter -o out.grib2 bitmap.rules $grib2
#exit 0
@ -62,4 +59,5 @@ ${tools_dir}grib_get_data -m missing out.grib2 > out.grib2.data
diff out.grib1.data out.grib2.data
rm -f out.grib1.data out.grib2.data out.grib1 out.grib2 bitmap.rules
rm -f $grib2

View File

@ -3,7 +3,7 @@
#
# 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.
#
@ -98,10 +98,6 @@ done
files="regular_latlon_surface.grib2 \
regular_latlon_surface.grib1"
# Create the grib2 file from grib1
${tools_dir}grib_set -s editionNumber=2 ${data_dir}/regular_latlon_surface.grib1 ${data_dir}/regular_latlon_surface.grib2
for file in `echo $files`; do
infile=${data_dir}/$file
@ -122,4 +118,3 @@ done
res=`${tools_dir}grib_get -p decimalScaleFactor,bitsPerValue ${data_dir}/gfs.c255.grib2`
[ "$res" = "1 20" ]
rm -f ${data_dir}/regular_latlon_surface.grib2

48
tests/ccsds.sh Executable file
View File

@ -0,0 +1,48 @@
#!/bin/sh
# Copyright 2005-2014 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
REDIRECT=/dev/null
BLACKLIST="totalLength,section5Length,section7Length,dataRepresentationTemplateNumber,typeOfPacking"
infile=${data_dir}/ccsds.grib2
rm -f $infile.1 $infile.2 || true
${tools_dir}grib_set -f -r -s packingType=grid_simple $infile $infile.1 2> $REDIRECT
${tools_dir}grib_compare -P -b $BLACKLIST,typeOfCompressionUsed,targetCompressionRatio $infile $infile.1 > $REDIRECT
${tools_dir}grib_set -r -s packingType=grid_ccsds $infile.1 $infile.2
${tools_dir}grib_compare -P -b $BLACKLIST $infile.1 $infile.2 > $REDIRECT
templateNumber=`${tools_dir}grib_get -p dataRepresentationTemplateNumber $infile.2`
if [ $templateNumber -ne 42 ]
then
echo dataRepresentationTemplateNumber=$templateNumber
exit 1
fi
rm -f $infile.1 $infile.2 || true
infile=${data_dir}/reduced_latlon_surface.grib2
${tools_dir}grib_set -r -s packingType=grid_ccsds $infile $infile.1
${tools_dir}grib_compare -P -b $BLACKLIST $infile $infile.1 > $REDIRECT
${tools_dir}grib_set -f -r -s packingType=grid_simple $infile.1 $infile.2 2> $REDIRECT
${tools_dir}grib_compare -P -b $BLACKLIST,typeOfCompressionUsed,targetCompressionRatio $infile.1 $infile.2 > $REDIRECT
res1=`${tools_dir}grib_get '-F%1.2f' -p min,max,avg $infile`
res2=`${tools_dir}grib_get '-F%1.2f' -p min,max,avg $infile.1`
res3=`${tools_dir}grib_get '-F%1.2f' -p min,max,avg $infile.2`
[ "$res1" = "$res2" ]
[ "$res1" = "$res3" ]
rm -f $infile.1 $infile.2 || true

246
tests/ccsds_perf.c Normal file
View File

@ -0,0 +1,246 @@
/*
* Copyright 2005-2014 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 "grib_api_internal.h"
#if GRIB_TIMER
void usage(char* prog) {
printf("usage: %s [-a outfile | -w outfile ] grib_file repetitions bitsPerValue\n",prog);
exit(1);
}
size_t grib_handle_write(grib_handle* h,char* filename) {
FILE* of=NULL;
const void *buffer; size_t size;
of = fopen(filename,"w");
if(!of) {
perror(filename);
exit(1);
}
GRIB_CHECK(grib_get_message(h,&buffer,&size),0);
if(fwrite(buffer,1,size,of) != size) {
perror(filename);
exit(1);
}
fclose(of);
return size;
}
static void print_timer(grib_timer* t,int repeat) {
printf("%s : %g cpu\n",t->name_,t->timer_/repeat);
}
int main(int argc, char* argv[]) {
grib_handle *h=NULL;
grib_context* c=NULL;
FILE* fin=NULL;
FILE* fout=NULL;
char* finname;
char* ofilename;
char defofilename[]="ccsds_perf.out";
double *values=NULL;
int append=0;
size_t nvalues=0;
int count,e=0;
int repeatccsds=1;
int repeatsimple=1;
grib_timer *tes,*tds,*tej,*tdj;
char grid_ccsds[]="grid_ccsds";
size_t grid_ccsds_l=strlen(grid_ccsds);
char grid_simple[]="grid_simple";
size_t grid_simple_l=strlen(grid_simple);
char packingType[50]={0,};
size_t len=50;
char param[50]={0,};
char gridType[50]={0,};
char outfilename[255]={0,};
size_t filesize_ccsds=0;
size_t filesize_simple=0;
double perc=0;
long bitsPerValue=0;
int iarg=1;
char grid[20]={0,};
char shortName[20]={0,};
long level;
char levelType[20]={0,};
tes=grib_get_timer(0,"encoding simple", 0, 0);
tds=grib_get_timer(0,"decoding simple", 0, 0);
tej=grib_get_timer(0,"encoding ccsds", 0, 0);
tdj=grib_get_timer(0,"decoding ccsds", 0, 0);
if (argc != 4 && argc != 6 ) usage(argv[0]);
if (!strcmp(argv[iarg],"-w")) {
append=0;
iarg++;
ofilename=argv[iarg];
iarg++;
} else if (!strcmp(argv[iarg],"-a")) {
append=1;
iarg++;
ofilename=argv[iarg];
iarg++;
} else {
append=0;
ofilename=defofilename;
}
finname=argv[iarg++];
repeatsimple=atoi(argv[iarg++]);
bitsPerValue=atoi(argv[iarg++]);
fin = fopen(finname,"r");
if(!fin) {perror(finname);exit(1);}
if (append)
fout = fopen(ofilename,"a");
else
fout = fopen(ofilename,"w");
if(!fout) {perror(ofilename);exit(1);}
c=grib_context_get_default();
e=0;
h=grib_handle_new_from_file(c,fin,&e);
fclose(fin);
GRIB_CHECK(e,0);
len=50;
grib_get_string(h,"shortName",param,&len);
len=20;
grib_get_string(h,"levelType",levelType,&len);
if (!strcmp(levelType,"pl")) {
GRIB_CHECK(grib_get_long(h,"level",&level),0);
sprintf(shortName,"%s%ld",param,level);
} else {
sprintf(shortName,"%s",param);
}
grib_set_long(h,"editionNumber",2);
GRIB_CHECK(grib_get_size(h,"values",&nvalues),0);
values=(double*)grib_context_malloc(c,sizeof(double)*nvalues);
if (!values) { printf("%s: memory allocation error\n",argv[0]); exit(1); }
len=50;
grib_get_string(h,"gridType",gridType,&len);
len=50;
grib_get_string(h,"packingType",packingType,&len);
GRIB_CHECK(grib_get_double_array(h,"values",values,&nvalues),0);
grib_set_long(h,"bitsPerValue",bitsPerValue);
GRIB_CHECK(grib_set_double_array(h,"values",values,nvalues),0);
printf("--------------------------------\n");
printf("- %s - gridType=%s packingType=%s numberOfValues=%ld bitsPerValue=%ld\n",
param,gridType,packingType,(long)nvalues,bitsPerValue);
if (!strcmp(packingType,"spectral_complex") || !strcmp(packingType,"spectral_simple")) {
printf("unable to process spectral data\n");
exit(1);
}
if (!strcmp(gridType,"reduced_gg") || !strcmp(gridType,"regular_gg")) {
long N;
grib_get_long(h,"N",&N);
printf(" N=%ld\n",N);
sprintf(grid,"%ld",N);
}
if (!strcmp(gridType,"regular_ll")) {
double Di,Dj;
grib_get_double(h,"DiInDegrees",&Di);
grib_get_double(h,"DjInDegrees",&Dj);
printf(" Di=%g Dj=%g\n",Di,Dj);
sprintf(grid,"%g/%g",Di,Dj);
}
if (!append)
fprintf(fout,
"shortName gridType numberOfValues bitsPerValue grid sizeSimple sizeccsds encodeccsds encodeSimple decodeccsds decodeSimple\n");
/* decode values grid_simple */
if (strcmp(packingType,grid_simple))
grib_set_string(h,"packingType",grid_simple,&grid_simple_l);
/* printf("decoding simple\n"); */
grib_timer_start(tds);
for (count=0;count<repeatsimple;count++)
GRIB_CHECK(grib_get_double_array(h,"values",values,&nvalues),0);
grib_timer_stop(tds,0);
/* printf("%d messages decoded\n\n",count); */
*outfilename='\0';
sprintf(outfilename,"%s_%s_%ld_simple.grib2",param,gridType,bitsPerValue);
filesize_simple=grib_handle_write(h,outfilename);
printf("file size simple = %ld\n",(long)filesize_simple);
/* encode values grid_simple*/
/* printf("encoding simple\n"); */
grib_timer_start(tes);
for (count=0;count<repeatsimple;count++)
GRIB_CHECK(grib_set_double_array(h,"values",values,nvalues),0);
grib_timer_stop(tes,0);
/* printf("%d messages encoded \n\n",count); */
/* decode values grid_ccsds */
grib_set_string(h,"packingType",grid_ccsds,&grid_ccsds_l);
/* printf("decoding ccsds\n"); */
grib_timer_start(tdj);
for (count=0;count<repeatccsds;count++)
GRIB_CHECK(grib_get_double_array(h,"values",values,&nvalues),0);
grib_timer_stop(tdj,0);
/* printf("%d messages decoded\n\n",count); */
*outfilename='\0';
sprintf(outfilename,"%s_%s_%ld_ccsds.grib2",param,gridType,bitsPerValue);
filesize_ccsds=grib_handle_write(h,outfilename);
printf("file size ccsds = %ld\n",(long)filesize_ccsds);
perc=(double)filesize_simple/(double)filesize_ccsds;
printf("compression ratio = %g \n",perc);
printf("space savings = %g \n",(1.0-1.0/perc)*100);
/* encode values grid_ccsds*/
/* printf("encoding ccsds\n"); */
grib_timer_start(tej);
for (count=0;count<repeatccsds;count++)
GRIB_CHECK(grib_set_double_array(h,"values",values,nvalues),0);
grib_timer_stop(tej,0);
/* printf("%d messages encoded \n\n",count); */
grib_handle_delete(h);
grib_context_free(c,values);
print_timer(tej,repeatccsds);
print_timer(tdj,repeatccsds);
print_timer(tes,repeatsimple);
print_timer(tds,repeatsimple);
printf("--------------------------------\n\n");
fprintf(fout,"%s %s %ld %ld %s %ld %ld %g %g %g %g\n",
shortName,gridType,(long)nvalues,bitsPerValue,
grid,(long)filesize_simple,(long)filesize_ccsds,tej->timer_/repeatccsds,tes->timer_/repeatsimple,tdj->timer_/repeatccsds,tds->timer_/repeatsimple);
return 0;
}
#else
int main(int argc,char* argv[]) {
return 0;
}
#endif

View File

@ -3,7 +3,7 @@
#
# 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.
#
@ -15,8 +15,8 @@ REDIRECT=/dev/null
files="regular_latlon_surface.grib2 \
regular_latlon_surface.grib1"
# First create the necessary grib2 files
${tools_dir}grib_set -s editionNumber=2 ${data_dir}/regular_latlon_surface.grib1 ${data_dir}/regular_latlon_surface.grib2
for file in `echo $files`
do
@ -31,4 +31,3 @@ do
rm -f $outfile1 $outfile2 || true
done
rm -f ${data_dir}/regular_latlon_surface.grib2

View File

@ -3,7 +3,7 @@
#
# 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.
#
@ -32,21 +32,20 @@ files="constant_field\
for f in `echo $files`
do
file=${data_dir}/$f
g2file=${file}.grib2_
rm -f $g2file || true
${tools_dir}grib_set -s editionNumber=2 ${file}.grib1 ${g2file} 2> $REDIRECT > $REDIRECT
rm -f ${file}.grib2 || true
${tools_dir}grib_set -s editionNumber=2 ${file}.grib1 ${file}.grib2 2> $REDIRECT > $REDIRECT
grib1Statistics=`${tools_dir}grib_get -fp numberOfValues,numberOfPoints,max,min,average,numberOfMissing ${file}.grib1`
grib2Statistics=`${tools_dir}grib_get -fp numberOfValues,numberOfPoints,max,min,average,numberOfMissing ${g2file}`
grib2Statistics=`${tools_dir}grib_get -fp numberOfValues,numberOfPoints,max,min,average,numberOfMissing ${file}.grib2`
if [ "$grib1Statistics" != "$grib2Statistics" ]
then
exit 1
fi
#${tools_dir}grib_compare -A1.0e-8 -c values ${file}.grib1 ${g2file} 2> /dev/null > /dev/null
${tools_dir}grib_compare -P -c values ${file}.grib1 ${g2file} 2> $REDIRECT > $REDIRECT
rm -f ${g2file} || true
#${tools_dir}grib_compare -A1.0e-8 -c values ${file}.grib1 ${file}.grib2 2> /dev/null > /dev/null
${tools_dir}grib_compare -P -c values ${file}.grib1 ${file}.grib2 2> $REDIRECT > $REDIRECT
done
#sed "s:toolsdir:${tools_dir}:" ${tools_dir}grib1to2.txt > ${tools_dir}grib1to2.test

View File

@ -32,11 +32,6 @@ files="constant_field\
for f in `echo $files`
do
file=${data_dir}/$f
# First create the grib2 file
rm -f ${file}.grib2 || true
${tools_dir}grib_set -s editionNumber=2 ${file}.grib1 ${file}.grib2 2> $REDIRECT > $REDIRECT
rm -f ${file}.grib1_ || true
${tools_dir}grib_set -s editionNumber=1 ${file}.grib2 ${file}.grib1_ 2> $REDIRECT > $REDIRECT
@ -50,7 +45,6 @@ do
#${tools_dir}grib_compare -A1.0e-8 -c values ${file}.grib1_ ${file}.grib2 2> /dev/null > /dev/null
rm -f ${file}.grib1_ || true
rm -f ${file}.grib2 || true
done
# GRIB-262 Conversion works without error for L137 data

View File

@ -3,7 +3,7 @@
#
# 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.
#
@ -21,24 +21,6 @@ files="reduced_latlon_surface.grib1 \
reduced_gaussian_sub_area.grib2 \
regular_latlon_surface.grib2"
# First create the necessary grib2 files from grib1
files2conv="\
reduced_latlon_surface\
reduced_gaussian_pressure_level\
regular_gaussian_pressure_level\
reduced_gaussian_sub_area\
regular_latlon_surface\
"
for f in $files2conv; do
${tools_dir}grib_set -s editionNumber=2 ${data_dir}/$f.grib1 ${data_dir}/$f.grib2
done
# First create the necessary grib2 files
#${tools_dir}grib_set -s editionNumber=2 ${data_dir}/reduced_latlon_surface.grib1 ${data_dir}/reduced_latlon_surface.grib2
#${tools_dir}grib_set -s editionNumber=2 ${data_dir}/reduced_gaussian_pressure_level.grib1 ${data_dir}/reduced_gaussian_pressure_level.grib2
#${tools_dir}grib_set -s editionNumber=2 ${data_dir}/regular_gaussian_pressure_level.grib1 ${data_dir}/regular_gaussian_pressure_level.grib2
#${tools_dir}grib_set -s editionNumber=2 ${data_dir}/reduced_gaussian_sub_area.grib1 ${data_dir}/reduced_gaussian_sub_area.grib2
for f in `echo $files`
do
file=${data_dir}/$f
@ -47,7 +29,3 @@ do
[ $numberOfPoints = ${iterator_count} ]
done
# Clean up
for f in $files2conv; do
rm -f ${data_dir}/$f.grib2
done

View File

@ -33,8 +33,6 @@ fi
rm -f $infile.1 $infile.2 || true
infile=${data_dir}/reduced_latlon_surface.grib2
# Create the grib2 file from grib1
${tools_dir}grib_set -s editionNumber=2 ${data_dir}/reduced_latlon_surface.grib1 ${data_dir}/reduced_latlon_surface.grib2
${tools_dir}grib_set -s packingType=grid_jpeg $infile $infile.1
${tools_dir}grib_compare -P -b $BLACKLIST $infile $infile.1 > $REDIRECT
@ -52,4 +50,3 @@ res=`${tools_dir}grib_get -l 0,50 $infile.1`
[ "$res" = "2.47244 2.47244 2.5115 2.51931 " ]
rm -f $infile.1 $infile.2 || true
rm -f ${data_dir}/reduced_latlon_surface.grib2

3593
tests/keys

File diff suppressed because it is too large Load Diff

View File

@ -10,13 +10,9 @@
. ./include.sh
#set -x
GRIB1_INFILE=${data_dir}/regular_gaussian_pressure_level_constant.grib1
GRIB2_INFILE=${data_dir}/regular_gaussian_pressure_level_constant.grib2
GRIB_INFILE=${data_dir}/regular_gaussian_pressure_level_constant.grib2
REF_FILE=lamb_az_eq_area.ref
# First create the grib2 file from grib1
${tools_dir}grib_set -s editionNumber=2 $GRIB1_INFILE $GRIB2_INFILE
# Temporary files created for this test
FILTER_FILE=lamb_az_eq_area.filter
GRIB_OUTFILE=lamb_az_eq_area.grib2
@ -45,7 +41,7 @@ write "lamb_az_eq_area.grib2";
EOF
# Use this filter and the input GRIB to create a new GRIB
${tools_dir}grib_filter $FILTER_FILE $GRIB2_INFILE
${tools_dir}grib_filter $FILTER_FILE $GRIB_INFILE
if [ ! -f "$GRIB_OUTFILE" ]; then
echo Failed to create output GRIB from filter >&2
exit 1
@ -57,5 +53,5 @@ ${tools_dir}grib_get_data $GRIB_OUTFILE > $DATA_OUTFILE
diff $DATA_OUTFILE $REF_FILE
# Clean up
rm -f $FILTER_FILE $GRIB_OUTFILE $DATA_OUTFILE $GRIB2_INFILE
rm -f $FILTER_FILE $GRIB_OUTFILE $DATA_OUTFILE

View File

@ -3,7 +3,7 @@
#
# 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.
#
@ -21,13 +21,8 @@ set scaledValueOfCentralWaveNumber={26870,9272,8377,22334};
write "test.grib";
EOF
# First create the grib2 file from grib1
gname=reduced_gaussian_model_level
grib1File=${data_dir}/${gname}.grib1
grib2File=${data_dir}/${gname}.grib2
${tools_dir}grib_set -s editionNumber=2 $grib1File $grib2File
file="${data_dir}/reduced_gaussian_model_level.grib2"
file="$grib2File"
${tools_dir}grib_filter list.filter $file
cat >list.filter<<EOF
@ -54,4 +49,5 @@ EOF
diff x.out list.ref
rm -f x.out list.ref list.filter test.grib $grib2File
rm -f x.out list.ref list.filter test.grib

View File

@ -16,7 +16,7 @@ for file in `find $GRIB_DEFINITION_PATH -name '*.def' -print`
do
${tools_dir}grib_list_keys $file >> tmp$$
done
p4 edit keys
cat >keys <<EOF
%{
#include "grib_api_internal.h"

View File

@ -17,33 +17,6 @@ REDIRECT=/dev/null
cd ${data_dir}
rm -f local.log | true
# GRIB2 definitions for chemicals and aerosols for MACC
sample_g2=$GRIB_SAMPLES_PATH/GRIB2.tmpl
${tools_dir}grib_set -s paramId=210005 $sample_g2 macc.grb2
result=`${tools_dir}grib_get -p discipline,parameterCategory,parameterNumber,shortName,units,aerosolType,name macc.grb2`
[ "$result" = '0 20 2 aermr05 kg kg**-1 62001 Dust Aerosol (0.55 - 0.9 um) Mixing Ratio' ]
[ `${tools_dir}grib_get -p productDefinitionTemplateNumber macc.grb2` = '44' ]
${tools_dir}grib_set -s paramId=210001 $sample_g2 macc.grb2
result=`${tools_dir}grib_get -p discipline,parameterCategory,parameterNumber,shortName,units,aerosolType,name macc.grb2`
[ "$result" = '0 20 2 aermr01 kg kg**-1 62008 Sea Salt Aerosol (0.03 - 0.5 um) Mixing Ratio' ]
${tools_dir}grib_set -s paramId=210007 $sample_g2 macc.grb2
result=`${tools_dir}grib_get -p discipline,parameterCategory,parameterNumber,shortName,typeOfSizeInterval,aerosolType,name macc.grb2`
[ "$result" = '0 20 2 aermr07 255 62016 Hydrophobic Organic Matter Aerosol Mixing Ratio' ]
${tools_dir}grib_set -s paramId=210061 $sample_g2 macc.grb2
result=`${tools_dir}grib_get -p discipline,parameterCategory,parameterNumber,shortName,productDefinitionTemplateNumber,constituentType,name macc.grb2`
[ "$result" = '0 20 2 co2 40 3 Carbon Dioxide' ]
${tools_dir}grib_set -s paramId=210062 $sample_g2 macc.grb2
result=`${tools_dir}grib_get -p discipline,parameterCategory,parameterNumber,shortName,productDefinitionTemplateNumber,constituentType,name macc.grb2`
[ "$result" = '0 20 2 ch4 40 2 Methane' ]
rm -f macc.grb2 | true
${tools_dir}grib_set -s edition=2,setLocalDefinition=1 reduced_gaussian_model_level.grib1 loc.grib2
${tools_dir}grib_set -s setLocalDefinition=1 reduced_gaussian_model_level.grib1 loc.grib1

View File

@ -49,27 +49,6 @@ regular_latlon_surface.grib1
regular_latlon_surface.grib2
"
# First create the necessary grib2 files
files2conv="\
reduced_gaussian_model_level\
reduced_gaussian_pressure_level\
reduced_gaussian_model_level\
reduced_gaussian_pressure_level\
reduced_gaussian_pressure_level_constant\
reduced_gaussian_sub_area\
reduced_gaussian_surface\
reduced_latlon_surface\
regular_gaussian_model_level\
regular_gaussian_pressure_level\
regular_gaussian_pressure_level_constant\
regular_gaussian_surface\
regular_latlon_surface\
"
for f in $files2conv; do
rm -f $f.grib2 || true
${tools_dir}grib_set -s editionNumber=2 $f.grib1 $f.grib2
done
for file in $files
do
[ -f "$file" ]
@ -99,10 +78,5 @@ ${tools_dir}grib_ls -p uuidOfVGrid test_uuid.grib2 > /dev/null
type=`${tools_dir}grib_get -wcount=1 -p typeOfLevel test_uuid.grib2`
[ "$type" = "generalVertical" ]
# Clean up
for f in $files2conv; do
rm -f $f.grib2
done
cd $workdir

View File

@ -3,7 +3,7 @@ set -x
./list_all_keys.ksh
p4 edit keys ../src/grib_hash_keys.c
# p4 edit keys ../src/grib_hash_keys.c
gperf -I -t -G -H hash_keys -N grib_keys_hash_get -m 3 keys > ../src/grib_hash_keys.c

View File

@ -3,7 +3,7 @@
#
# 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.
#
@ -31,14 +31,7 @@ levtype=`${tools_dir}grib_get -p levtype:l $outfile`
centre=`${tools_dir}grib_get -p centre:l $outfile`
[ $centre -eq 80 ]
rm -f $outfile || true
# Create the grib2 file from grib1
grib1File=${data_dir}/regular_gaussian_surface.grib1
grib2File=${data_dir}/regular_gaussian_surface.grib2
${tools_dir}grib_set -s editionNumber=2 $grib1File $grib2File
infile=$grib2File
infile=${data_dir}/regular_gaussian_surface.grib2
outfile=${data_dir}/set.grib2
rm -f $outfile || true
@ -63,4 +56,4 @@ ${tools_dir}grib_set -p levtype $infile $outfile 2> $REDIRECT > $REDIRECT
[ $? -ne 0 ]
rm -f $outfile $grib2File || true

View File

@ -12,9 +12,6 @@
files="regular_latlon_surface.grib2 regular_latlon_surface.grib1"
# Create the grib2 file from grib1
${tools_dir}grib_set -s editionNumber=2 ${data_dir}/regular_latlon_surface.grib1 ${data_dir}/regular_latlon_surface.grib2
for file in $files
do
@ -40,4 +37,3 @@ diff statistics.out ${data_dir}/statistics.out.good
done
rm -f statistics.out statistics.filter || true
rm -f ${data_dir}/regular_latlon_surface.grib2

View File

@ -57,13 +57,7 @@ rm -f ${templog} | true
# GRIB-180
# Set PDT 4.8 where you can find the EndOfOverallTimeInterval keys
# First create the necessary grib2 file
gname=reduced_latlon_surface_constant
grib1File=${data_dir}/${gname}.grib1
grib2File=${data_dir}/${gname}.grib2
rm -f $grib2File || true
${tools_dir}grib_set -s editionNumber=2 $grib1File $grib2File
grib2File=${data_dir}/reduced_latlon_surface_constant.grib2
${tools_dir}grib_set -sproductDefinitionTemplateNumber=8 $grib2File ${grib2File}.p8tmp
# 78 hours is 3 days and 6 hours
@ -71,13 +65,13 @@ ${tools_dir}grib_set -s step=78 $grib2File.p8tmp ${grib2File}.tmp
set `${tools_dir}grib_get -p hourOfEndOfOverallTimeInterval,dayOfEndOfOverallTimeInterval ${grib2File}.tmp`
hourEnd=$1; dayEnd=$2
[ "$hourEnd" = "18" ]
[ "$dayEnd" = "8" ]
[ "$dayEnd" = "8" ]
${tools_dir}grib_set -s step=12 $grib2File.p8tmp ${grib2File}.tmp
set `${tools_dir}grib_get -p hourOfEndOfOverallTimeInterval,dayOfEndOfOverallTimeInterval ${grib2File}.tmp`
hourEnd=$1; dayEnd=$2
[ "$hourEnd" = "0" ]
[ "$dayEnd" = "6" ]
[ "$dayEnd" = "6" ]
rm -f $grib2File.p8tmp ${grib2File}.tmp | true
rm -f $grib2File x.grib
rm -f x.grib

View File

@ -44,8 +44,14 @@ do
done
# GRIB-531
TEMP=temp.$$.tigge.txt
TEMP=temp.$$.tigge
${tools_dir}grib_get -nparameter ${data_dir}/tigge_pf_ecmwf.grib2 > $TEMP
diff ${data_dir}/tigge_pf_ecmwf.grib2.ref $TEMP
# GRIB-205. Changing productionStatusOfProcessedData should not change
# anything else
input=${dir}/tigge_ecmf_sfc_sd.grib
${tools_dir}grib_set -s productionStatusOfProcessedData=5 $input $TEMP
${tools_dir}grib_compare -bproductionStatusOfProcessedData $input $TEMP
rm -f $TEMP

View File

@ -706,8 +706,13 @@ static int compare_values(grib_runtime_options* options,grib_handle* h1,grib_han
save_error(c,name);
}
if(err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS)
if(err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS && len1!=len2)
{
printInfo(h1);
printf("Different size for \"%s\" [%ld] [%ld]\n",name,(long)len1,(long)len2);
save_error(c,name);
}
if(err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS && len1==len2)
{
int i;
countdiff=0;
@ -845,15 +850,17 @@ static int compare_values(grib_runtime_options* options,grib_handle* h1,grib_han
if (packingError2!=0 || packingError1!=0)
printf(" packingError: [%g] [%g]",packingError1,packingError2);
if (!grib_inline_strcmp(name,"packedValues") || !grib_inline_strcmp(name,"values")
|| !grib_inline_strcmp(name,"codedValues")) {
double max1,min1,max2,min2;
grib_get_double(h1,"max",&max1);
grib_get_double(h1,"min",&min1);
grib_get_double(h2,"max",&max2);
grib_get_double(h2,"min",&min2);
printf("\n\tvalues max= [%g] [%g] min= [%g] [%g]",max1,max2,min1,min2);
double max1=0,min1=0,max2=0,min2=0;
/* Note: some packings like spectral do not have min,max */
if (grib_get_double(h1,"max",&max1) == GRIB_SUCCESS &&
grib_get_double(h1,"min",&min1) == GRIB_SUCCESS &&
grib_get_double(h2,"max",&max2) == GRIB_SUCCESS &&
grib_get_double(h2,"min",&min2) == GRIB_SUCCESS)
{
printf("\n\tvalues max= [%g] [%g] min= [%g] [%g]",max1,max2,min1,min2);
}
}
printf("\n");
} else {

View File

@ -516,6 +516,10 @@
RelativePath="..\..\..\src\grib_accessor_class_bufr_uncompressed_data.c"
>
</File>
<File
RelativePath="..\..\..\src\grib_accessor_class_bufrdc_expanded_descriptors.c"
>
</File>
<File
RelativePath="..\..\..\src\grib_accessor_class_bytes.c"
>
@ -685,7 +689,7 @@
>
</File>
<File
RelativePath="..\..\..\src\grib_accessor_class_data_szip_packing.c"
RelativePath="..\..\..\src\grib_accessor_class_data_ccsds_packing.c"
>
</File>
<File
@ -1564,6 +1568,18 @@
RelativePath="..\..\..\src\grib_value.c"
>
</File>
<File
RelativePath="..\..\..\src\grib_vdarray.c"
>
</File>
<File
RelativePath="..\..\..\src\grib_viarray.c"
>
</File>
<File
RelativePath="..\..\..\src\grib_vsarray.c"
>
</File>
<File
RelativePath="..\..\..\src\grib_yacc.c"
>