Merge branch 'develop' into feature/FireInMars

This commit is contained in:
Sebastien Villaume 2022-03-10 16:38:40 +00:00
commit 7c73868638
114 changed files with 9343 additions and 8611 deletions

View File

@ -2,7 +2,7 @@
# general configuration # # general configuration #
#---------------------------------# #---------------------------------#
version: 2.25.0-{build}-{branch} version: latest-{build}-{branch}
branches: branches:
only: only:

View File

@ -21,7 +21,7 @@ cmake_minimum_required( VERSION 3.12 FATAL_ERROR )
find_package( ecbuild 3.4 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild) find_package( ecbuild 3.4 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild)
# Initialise project # Initialise project
project( eccodes VERSION 2.25.0 LANGUAGES C ) project( eccodes VERSION 2.26.0 LANGUAGES C )
############################################################################### ###############################################################################
# system checks needed for eccodes_config.h and some options like MEMFS # system checks needed for eccodes_config.h and some options like MEMFS
@ -116,7 +116,10 @@ ecbuild_add_option( FEATURE NETCDF
find_package( AEC ) find_package( AEC )
if(NOT DEFINED ENABLE_AEC AND NOT AEC_FOUND) if(NOT DEFINED ENABLE_AEC AND NOT AEC_FOUND)
ecbuild_critical("AEC (Adaptive Entropy Coding) support is highly recommended from ecCodes >= 2.25.0\nTo force the build without it, use -DENABLE_AEC=OFF") ecbuild_critical("AEC library was not found.\n"
"AEC (Adaptive Entropy Coding) provides the WMO GRIB CCSDS compression and decompression of data. "
"This is highly recommended from ecCodes >= 2.25.0"
"\nTo force the build without it, use -DENABLE_AEC=OFF")
endif() endif()
ecbuild_add_option( FEATURE AEC ecbuild_add_option( FEATURE AEC
DESCRIPTION "Support for Adaptive Entropy Coding" DESCRIPTION "Support for Adaptive Entropy Coding"

View File

@ -23,10 +23,10 @@
# LIBAEC_PATH # LIBAEC_PATH
# libaec_PATH # libaec_PATH
find_path( AEC_INCLUDE_DIR szlib.h find_path( AEC_INCLUDE_DIR libaec.h
PATHS ${AEC_DIR} ${AEC_PATH} ${LIBAEC_DIR} ${libaec_DIR} ${LIBAEC_PATH} ${libaec_PATH} ENV AEC_DIR ENV AEC_PATH ENV LIBAEC_DIR ENV libaec_DIR ENV LIBAEC_PATH ENV libaec_PATH PATHS ${AEC_DIR} ${AEC_PATH} ${LIBAEC_DIR} ${libaec_DIR} ${LIBAEC_PATH} ${libaec_PATH} ENV AEC_DIR ENV AEC_PATH ENV LIBAEC_DIR ENV libaec_DIR ENV LIBAEC_PATH ENV libaec_PATH
PATH_SUFFIXES include include/aec NO_DEFAULT_PATH ) PATH_SUFFIXES include include/aec NO_DEFAULT_PATH )
find_path( AEC_INCLUDE_DIR szlib.h PATH_SUFFIXES include include/aec ) find_path( AEC_INCLUDE_DIR libaec.h PATH_SUFFIXES include include/aec )
find_library( AEC_LIBRARY NAMES aec find_library( AEC_LIBRARY NAMES aec
PATHS ${AEC_DIR} ${AEC_PATH} ${LIBAEC_DIR} ${libaec_DIR} ${LIBAEC_PATH} ${libaec_PATH} ENV AEC_DIR ENV AEC_PATH ENV LIBAEC_DIR ENV libaec_DIR ENV LIBAEC_PATH ENV libaec_PATH PATHS ${AEC_DIR} ${AEC_PATH} ${LIBAEC_DIR} ${libaec_DIR} ${LIBAEC_PATH} ${libaec_PATH} ENV AEC_DIR ENV AEC_PATH ENV LIBAEC_DIR ENV libaec_DIR ENV LIBAEC_PATH ENV libaec_PATH

View File

@ -10,9 +10,10 @@ add_subdirectory(gts)
file(READ "grib_data_files.txt" files_to_download) file(READ "grib_data_files.txt" files_to_download)
string(REGEX REPLACE "\n" ";" files_to_download "${files_to_download}") string(REGEX REPLACE "\n" ";" files_to_download "${files_to_download}")
# Download the CCSDS file even if HAVE_AEC feature is disabled. # Download the CCSDS files even if HAVE_AEC feature is disabled.
# This is for testing (See ECC-1352) # This is for testing (See ECC-1352)
list(APPEND files_to_download ccsds.grib2) list(APPEND files_to_download ccsds.grib2)
list(APPEND files_to_download ccsds_szip.grib2) # See ECC-1362
if( ENABLE_EXTRA_TESTS ) if( ENABLE_EXTRA_TESTS )

View File

@ -1,6 +1,6 @@
######################### #########################
## ##
## author: Sebastien Villaume <Sebastien.Villaume@smhi.se> ## author: Sebastien Villaume
## created: 6 Oct 2011 ## created: 6 Oct 2011
## modified: 13 May 2013 ## modified: 13 May 2013
## ##

View File

@ -1,6 +1,6 @@
######################### #########################
## ##
## author: Sebastien Villaume <Sebastien.Villaume@smhi.se> ## author: Sebastien Villaume
## created: 6 Oct 2011 ## created: 6 Oct 2011
## modified: 13 May 2013 ## modified: 13 May 2013
## ##

View File

@ -49,7 +49,7 @@ if(bitmapPresent) {
): read_only; ): read_only;
alias data.packedValues = codedValues; alias data.packedValues = codedValues;
if (boustrophedonicOrdering) if (boustrophedonicOrdering)
{ {
if (GRIBEX_boustrophedonic) if (GRIBEX_boustrophedonic)

View File

@ -49,7 +49,7 @@ if(bitmapPresent) {
): read_only; ): read_only;
alias data.packedValues = codedValues; alias data.packedValues = codedValues;
if (boustrophedonicOrdering) if (boustrophedonicOrdering)
{ {
if (GRIBEX_boustrophedonic) if (GRIBEX_boustrophedonic)

View File

@ -61,7 +61,7 @@ if(matrixOfValues == 0)
# For grib1 -> grib2 # For grib1 -> grib2
constant bitMapIndicator = 0; constant bitMapIndicator = 0;
meta codedValues data_g1simple_packing ( meta codedValues data_g1simple_packing(
section4Length, section4Length,
offsetBeforeData, offsetBeforeData,
offsetSection4, offsetSection4,

View File

@ -93,7 +93,7 @@ constant PUnset = -32767;
subSetJ, subSetJ,
subSetK, subSetK,
subSetM, subSetM,
pentagonalResolutionParameterJ, pentagonalResolutionParameterJ,
pentagonalResolutionParameterK, pentagonalResolutionParameterK,
pentagonalResolutionParameterM pentagonalResolutionParameterM
@ -122,7 +122,7 @@ constant PUnset = -32767;
subSetJ, subSetJ,
subSetK, subSetK,
subSetM, subSetM,
pentagonalResolutionParameterJ, pentagonalResolutionParameterJ,
pentagonalResolutionParameterK, pentagonalResolutionParameterK,
pentagonalResolutionParameterM pentagonalResolutionParameterM

View File

@ -89,7 +89,7 @@ constant PUnset = -32767;
subSetJ, subSetJ,
subSetK, subSetK,
subSetM, subSetM,
pentagonalResolutionParameterJ, pentagonalResolutionParameterJ,
pentagonalResolutionParameterK, pentagonalResolutionParameterK,
pentagonalResolutionParameterM pentagonalResolutionParameterM
@ -118,7 +118,7 @@ constant PUnset = -32767;
subSetJ, subSetJ,
subSetK, subSetK,
subSetM, subSetM,
pentagonalResolutionParameterJ, pentagonalResolutionParameterJ,
pentagonalResolutionParameterK, pentagonalResolutionParameterK,
pentagonalResolutionParameterM pentagonalResolutionParameterM

View File

@ -12,7 +12,7 @@
#model 52 I1 44 - #model 52 I1 44 -
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 6 Oct 2011 # created: 6 Oct 2011
# modified: 13 May 2013 # modified: 13 May 2013
# #

View File

@ -1,6 +1,6 @@
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 6 Oct 2011 # created: 6 Oct 2011
# modified: 20 Feb 2014 # modified: 20 Feb 2014
# #

View File

@ -23,7 +23,7 @@
#PartDef 74 PAD n/a 7 #PartDef 74 PAD n/a 7
################################################################ ################################################################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 6 Oct 2011 # created: 6 Oct 2011
# modified: 20 Feb 2014 # modified: 20 Feb 2014
# #

View File

@ -112,7 +112,7 @@ if(localFlag == 3)
alias system = systemNumber; alias system = systemNumber;
alias method = methodNumber; alias method = methodNumber;
alias refdate = referenceDate; alias refdate = referenceDate;
alias mars._leg_number = legNumber; alias mars._leg_number = legNumber;
} }
@ -143,7 +143,7 @@ if(localFlag == 4)
alias baseTimeOfThisLeg = legBaseTime; alias baseTimeOfThisLeg = legBaseTime;
unsigned[1] legNumber : dump; unsigned[1] legNumber : dump;
unsigned[1] oceanAtmosphereCoupling : dump; unsigned[1] oceanAtmosphereCoupling : dump;
# Hours # Hours
unsigned[2] offsetToEndOf4DvarWindow : dump; unsigned[2] offsetToEndOf4DvarWindow : dump;
alias anoffset=offsetToEndOf4DvarWindow; alias anoffset=offsetToEndOf4DvarWindow;

View File

@ -1,6 +1,6 @@
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 6 Oct 2011 # created: 6 Oct 2011
# modified: 13 May 2013 # modified: 13 May 2013
# #

View File

@ -1,8 +1,7 @@
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 13 May 2013 # created: 13 May 2013
# modified:
# #
######################### #########################
"none"={matchAerosolBinNumber=0;} "none"={matchAerosolBinNumber=0;}

View File

@ -1,6 +1,6 @@
######################### #########################
## ##
## author: Sebastien Villaume <Sebastien.Villaume@smhi.se> ## author: Sebastien Villaume
## created: 6 Oct 2011 ## created: 6 Oct 2011
## modified: 13 May 2013 ## modified: 13 May 2013
## ##

View File

@ -1,8 +1,7 @@
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 13 May 2013 # created: 13 May 2013
# modified:
# #
######################### #########################
"all"={matchLandType=0;} "all"={matchLandType=0;}

View File

@ -1,6 +1,6 @@
######################### #########################
## ##
## author: Sebastien Villaume <Sebastien.Villaume@smhi.se> ## author: Sebastien Villaume
## created: 6 Oct 2011 ## created: 6 Oct 2011
## modified: 13 May 2013 ## modified: 13 May 2013
## ##

View File

@ -1,6 +1,6 @@
######################### #########################
## ##
## author: Sebastien Villaume <Sebastien.Villaume@smhi.se> ## author: Sebastien Villaume
## created: 6 Oct 2011 ## created: 6 Oct 2011
## modified: 13 May 2013 ## modified: 13 May 2013
## ##

View File

@ -1,8 +1,7 @@
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 13 May 2013 # created: 13 May 2013
# modified:
# #
######################### #########################
"none"={matchSort=0;} "none"={matchSort=0;}

View File

@ -1,8 +1,7 @@
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 13 May 2013 # created: 13 May 2013
# modified:
# #
######################### #########################
"none"={matchTimeRepres=0;} "none"={matchTimeRepres=0;}

View File

@ -1,6 +1,6 @@
######################### #########################
## ##
## author: Sebastien Villaume <Sebastien.Villaume@smhi.se> ## author: Sebastien Villaume
## created: 6 Oct 2011 ## created: 6 Oct 2011
## modified: 13 May 2013 ## modified: 13 May 2013
## ##

View File

@ -1,6 +1,6 @@
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 6 Oct 2011 # created: 6 Oct 2011
# modified: 13 May 2013 # modified: 13 May 2013
# #

View File

@ -1,6 +1,6 @@
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 6 Oct 2011 # created: 6 Oct 2011
# modified: 13 May 2013 # modified: 13 May 2013
# #

View File

@ -1,6 +1,6 @@
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 6 Oct 2011 # created: 6 Oct 2011
# modified: 13 Sep 2013 # modified: 13 Sep 2013
# #

View File

@ -1,50 +1,33 @@
######################### #########################
# # author: Sebastien Villaume (SMHI)
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se>
# created: 6 Oct 2011 # created: 6 Oct 2011
# modified: 13 Sep 2013 # modified: 13 Sep 2013
# #
######################### #########################
constant conceptsMasterMarsDir="mars" : hidden; constant conceptsMasterMarsDir="mars" : hidden;
constant conceptsLocalMarsDirAll="mars/[centre:s]" : hidden; constant conceptsLocalMarsDirAll="mars/[centre:s]" : hidden;
# Base MARS keywors
########################## ##########################
# # alias mars.class = marsClass;
# Base MARS keywors # alias mars.type = marsType;
# # alias mars.stream = marsStream;
########################## alias mars.model = marsModel;
alias mars.expver = experimentVersionNumber;
alias mars.class = marsClass; alias mars.domain = globalDomain;
alias mars.type = marsType;
alias mars.stream = marsStream;
alias mars.model = marsModel;
alias mars.expver = experimentVersionNumber;
alias mars.domain = globalDomain;
# local section 82
######################### #########################
# #
# local section 82 #
# #
#########################
### nothing needed here... ### nothing needed here...
# Local section 83
######################### #########################
# #
# local section 83 #
# #
#########################
if ( localDefinitionNumber == 83 ) { if ( localDefinitionNumber == 83 ) {
alias mars.sort = matchSort;
alias mars.sort = matchSort; alias mars.timerepres = matchTimeRepres;
alias mars.timerepres = matchTimeRepres; alias mars.landtype = matchLandType;
alias mars.landtype = matchLandType; alias mars.aerosolbinnumber = matchAerosolBinNumber;
alias mars.aerosolbinnumber = matchAerosolBinNumber;
concept_nofail matchAerosolPacking (unknown,"aerosolPackingConcept.def",conceptsLocalMarsDirAll,conceptsMasterMarsDir); concept_nofail matchAerosolPacking (unknown,"aerosolPackingConcept.def",conceptsLocalMarsDirAll,conceptsMasterMarsDir);
alias mars.aerosolpacking = matchAerosolPacking; alias mars.aerosolpacking = matchAerosolPacking;
} }

View File

@ -61,7 +61,7 @@ alias levelType=indicatorOfTypeOfLevel;
transient pressureUnits="hPa"; transient pressureUnits="hPa";
concept_nofail typeOfLevelECMF (unknown, "typeOfLevel.def",conceptsMasterDir,conceptsLocalDirECMF); concept_nofail typeOfLevelECMF (unknown, "typeOfLevel.def",conceptsMasterDir,conceptsLocalDirECMF);
concept_nofail vertical.typeOfLevel (typeOfLevelECMF, "typeOfLevel.def",conceptsDir2,conceptsDir1); concept_nofail vertical.typeOfLevel (typeOfLevelECMF, "typeOfLevel.def",conceptsDir2,conceptsDir1);
when ( typeOfLevel is "isobaricInPa" ) { set pressureUnits="Pa"; } when ( typeOfLevel is "isobaricInPa" ) { set pressureUnits="Pa"; }
@ -129,7 +129,7 @@ unsigned[1] P1 : edition_specific;
unsigned[1] P2 : edition_specific; unsigned[1] P2 : edition_specific;
# Local comes before Master to give precedence to the local, centre-specific table # Local comes before Master to give precedence to the local, centre-specific table
codetable[1] timeRangeIndicator ('5.table',tablesLocalDir,tablesMasterDir) = 1 : dump,edition_specific; codetable[1] timeRangeIndicator ('5.table',tablesLocalDir,tablesMasterDir) = 1 : dump,edition_specific;
unsigned[2] numberIncludedInAverage; unsigned[2] numberIncludedInAverage;
@ -255,7 +255,7 @@ if(((section1Length > 40) or new() or setLocalDefinition> 0) and deleteLocalDefi
{ {
constant localUsePresent = 1 : edition_specific; constant localUsePresent = 1 : edition_specific;
alias grib2LocalSectionPresent=present; alias grib2LocalSectionPresent=present;
if( (centre == ECMWF) or if( (centre == ECMWF) or
(centre != ECMWF and (centre != ECMWF and
subCentre == ECMWF)) subCentre == ECMWF))
@ -279,7 +279,7 @@ if(((section1Length > 40) or new() or setLocalDefinition> 0) and deleteLocalDefi
# Other centres # Other centres
pad reservedNeedNotBePresent(12); pad reservedNeedNotBePresent(12);
template_nofail localDefinition "grib1/local.[centre:l].def"; template_nofail localDefinition "grib1/local.[centre:l].def";
section_padding localExtensionPadding : read_only; section_padding localExtensionPadding : read_only;
} }
} }

View File

@ -1,8 +1,7 @@
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 14 Feb 2014 # created: 14 Feb 2014
# modified:
# #
################################# #################################
### LOCAL SECTION DESCRIPTION ### ### LOCAL SECTION DESCRIPTION ###

View File

@ -1,8 +1,7 @@
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 14 Feb 2014 # created: 14 Feb 2014
# modified:
# #
################################# #################################
### LOCAL SECTION DESCRIPTION ### ### LOCAL SECTION DESCRIPTION ###

View File

@ -1,8 +1,7 @@
################################################# #################################################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 14 Feb 2014 # created: 14 Feb 2014
# modified:
# #
################################# #################################
### LOCAL SECTION DESCRIPTION ### ### LOCAL SECTION DESCRIPTION ###

View File

@ -50,3 +50,22 @@ unsigned[1] minuteOfModelVersion = 0 : dump;
constant secondOfModelVersion = 0; constant secondOfModelVersion = 0;
meta dateOfModelVersion g2date(yearOfModelVersion, monthOfModelVersion, dayOfModelVersion) : dump; meta dateOfModelVersion g2date(yearOfModelVersion, monthOfModelVersion, dayOfModelVersion) : dump;
meta timeOfModelVersion time (hourOfModelVersion, minuteOfModelVersion, secondOfModelVersion) : dump; meta timeOfModelVersion time (hourOfModelVersion, minuteOfModelVersion, secondOfModelVersion) : dump;
# Note: the key inputOriginatingCentre is in the PDTNs 70, 71, 72 and 73
#concept efas_forecast {
# "griddedobs" = { inputOriginatingCentre=98; marsType = "an"; }
# # "reanalysis" = { inputOriginatingCentre=98; marsType = "an"; }
#
# "hres" = { inputOriginatingCentre=98; marsType = "fc"; } # deterministic
# "ens" = { inputOriginatingCentre=98; marsType = "pf"; } # ensemble
# "ens" = { inputOriginatingCentre=98; marsType = "cf"; } # ensemble
#
# DWD rules
# "global" = { inputOriginatingCentre=78; inputProcessIdentifier = 1; }
# "lam" = { inputOriginatingCentre=78; inputProcessIdentifier = 2; }
#
# TODO: For now anything coming from cnmc (COSMO) is local area
# "lam" = { inputOriginatingCentre=80; }
#
# "unknown" = { dummy = 1; }
#} : hidden;

View File

@ -20,7 +20,7 @@ if(type != perturbedType)
# Ritz numbers: # Ritz numbers:
signed[4] NINT_LOG10_RITZ : dump ; signed[4] NINT_LOG10_RITZ : dump ;
signed[4] NINT_RITZ_EXP : dump ; signed[4] NINT_RITZ_EXP : dump ;
alias local.numberOfIterations= numberOfIterations; alias local.numberOfIterations= numberOfIterations;
alias local.numberOfSingularVectorsComputed= numberOfSingularVectorsComputed ; alias local.numberOfSingularVectorsComputed= numberOfSingularVectorsComputed ;
alias local.normAtInitialTime= normAtInitialTime ; alias local.normAtInitialTime= normAtInitialTime ;

File diff suppressed because it is too large Load Diff

View File

@ -1,63 +1,63 @@
'S' = { 'S' = {
parameterCategory = 255; parameterCategory = 255;
parameterNumber = 255; parameterNumber = 255;
scaleFactorOfFirstFixedSurface = 0; scaleFactorOfFirstFixedSurface = 0;
scaledValueOfFirstFixedSurface = 0; scaledValueOfFirstFixedSurface = 0;
typeOfFirstFixedSurface = 119; typeOfFirstFixedSurface = 119;
typeOfSecondFixedSurface = 255; typeOfSecondFixedSurface = 255;
} }
'H' = { 'H' = {
parameterCategory = 255; parameterCategory = 255;
parameterNumber = 255; parameterNumber = 255;
scaleFactorOfFirstFixedSurface = 0; scaleFactorOfFirstFixedSurface = 0;
scaledValueOfFirstFixedSurface = 0; scaledValueOfFirstFixedSurface = 0;
typeOfFirstFixedSurface = 103; typeOfFirstFixedSurface = 103;
typeOfSecondFixedSurface = 255; typeOfSecondFixedSurface = 255;
} }
'P' = { 'P' = {
ZLMULT = 1.0000000e-02; ZLMULT = 1.0000000e-02;
parameterCategory = 255; parameterCategory = 255;
parameterNumber = 255; parameterNumber = 255;
scaleFactorOfFirstFixedSurface = 0; scaleFactorOfFirstFixedSurface = 0;
scaledValueOfFirstFixedSurface = 0; scaledValueOfFirstFixedSurface = 0;
typeOfFirstFixedSurface = 100; typeOfFirstFixedSurface = 100;
typeOfSecondFixedSurface = 255; typeOfSecondFixedSurface = 255;
} }
'V' = { 'V' = {
parameterCategory = 255; parameterCategory = 255;
parameterNumber = 255; parameterNumber = 255;
scaleFactorOfFirstFixedSurface = 0; scaleFactorOfFirstFixedSurface = 0;
scaledValueOfFirstFixedSurface = 0; scaledValueOfFirstFixedSurface = 0;
typeOfFirstFixedSurface = 109; typeOfFirstFixedSurface = 109;
typeOfSecondFixedSurface = 255; typeOfSecondFixedSurface = 255;
} }
'T' = { 'T' = {
parameterCategory = 255; parameterCategory = 255;
parameterNumber = 255; parameterNumber = 255;
scaleFactorOfFirstFixedSurface = 0; scaleFactorOfFirstFixedSurface = 0;
scaledValueOfFirstFixedSurface = 0; scaledValueOfFirstFixedSurface = 0;
typeOfFirstFixedSurface = 20; typeOfFirstFixedSurface = 20;
typeOfSecondFixedSurface = 255; typeOfSecondFixedSurface = 255;
} }
'KT' = { 'KT' = {
ZLBASE = 1.5000000e-01; ZLBASE = 1.5000000e-01;
parameterCategory = 255; parameterCategory = 255;
parameterNumber = 255; parameterNumber = 255;
scaleFactorOfFirstFixedSurface = 0; scaleFactorOfFirstFixedSurface = 0;
scaledValueOfFirstFixedSurface = 0; scaledValueOfFirstFixedSurface = 0;
typeOfFirstFixedSurface = 20; typeOfFirstFixedSurface = 20;
typeOfSecondFixedSurface = 255; typeOfSecondFixedSurface = 255;
} }
'KB' = { 'KB' = {
ZLBASE = 1.5000000e-01; ZLBASE = 1.5000000e-01;
parameterCategory = 255; parameterCategory = 255;
parameterNumber = 255; parameterNumber = 255;
scaleFactorOfFirstFixedSurface = 0; scaleFactorOfFirstFixedSurface = 0;
scaledValueOfFirstFixedSurface = 0; scaledValueOfFirstFixedSurface = 0;
typeOfFirstFixedSurface = 20; typeOfFirstFixedSurface = 20;
typeOfSecondFixedSurface = 255; typeOfSecondFixedSurface = 255;
} }
'default' = { 'default' = {
typeOfFirstFixedSurface = 255; typeOfFirstFixedSurface = 255;
typeOfSecondFixedSurface = 255; typeOfSecondFixedSurface = 255;
} }

View File

@ -8,4 +8,6 @@
typeOfSecondFixedSurface = 255 ; typeOfSecondFixedSurface = 255 ;
scaledValueOfFirstFixedSurface = 0 ; scaledValueOfFirstFixedSurface = 0 ;
scaleFactorOfFirstFixedSurface = 0 ; scaleFactorOfFirstFixedSurface = 0 ;
scaledValueOfSecondFixedSurface = missing() ;
scaleFactorOfSecondFixedSurface = missing() ;
} }

View File

@ -158,4 +158,6 @@
typeOfSecondFixedSurface = 255 ; typeOfSecondFixedSurface = 255 ;
scaledValueOfFirstFixedSurface = 0 ; scaledValueOfFirstFixedSurface = 0 ;
scaleFactorOfFirstFixedSurface = 0 ; scaleFactorOfFirstFixedSurface = 0 ;
scaledValueOfSecondFixedSurface = missing() ;
scaleFactorOfSecondFixedSurface = missing() ;
} }

View File

@ -158,4 +158,6 @@
typeOfSecondFixedSurface = 255 ; typeOfSecondFixedSurface = 255 ;
scaledValueOfFirstFixedSurface = 0 ; scaledValueOfFirstFixedSurface = 0 ;
scaleFactorOfFirstFixedSurface = 0 ; scaleFactorOfFirstFixedSurface = 0 ;
scaledValueOfSecondFixedSurface = missing() ;
scaleFactorOfSecondFixedSurface = missing() ;
} }

View File

@ -158,4 +158,6 @@
typeOfSecondFixedSurface = 255 ; typeOfSecondFixedSurface = 255 ;
scaledValueOfFirstFixedSurface = 0 ; scaledValueOfFirstFixedSurface = 0 ;
scaleFactorOfFirstFixedSurface = 0 ; scaleFactorOfFirstFixedSurface = 0 ;
scaledValueOfSecondFixedSurface = missing() ;
scaleFactorOfSecondFixedSurface = missing() ;
} }

View File

@ -158,4 +158,6 @@
typeOfSecondFixedSurface = 255 ; typeOfSecondFixedSurface = 255 ;
scaledValueOfFirstFixedSurface = 0 ; scaledValueOfFirstFixedSurface = 0 ;
scaleFactorOfFirstFixedSurface = 0 ; scaleFactorOfFirstFixedSurface = 0 ;
scaledValueOfSecondFixedSurface = missing() ;
scaleFactorOfSecondFixedSurface = missing() ;
} }

View File

@ -158,4 +158,6 @@
typeOfSecondFixedSurface = 255 ; typeOfSecondFixedSurface = 255 ;
scaledValueOfFirstFixedSurface = 0 ; scaledValueOfFirstFixedSurface = 0 ;
scaleFactorOfFirstFixedSurface = 0 ; scaleFactorOfFirstFixedSurface = 0 ;
scaledValueOfSecondFixedSurface = missing() ;
scaleFactorOfSecondFixedSurface = missing() ;
} }

View File

@ -1,8 +1,7 @@
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 14 Feb 2014 # created: 14 Feb 2014
# modified:
# #
######################### #########################

View File

@ -1,6 +1,5 @@
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 14 Feb 2014 # created: 14 Feb 2014
# modified:
# #
######################### #########################

View File

@ -1,4 +1,4 @@
"unknown" = { typeOfPostProcessing = 0; } # For template.4.postproc.def
"lisflood" = { typeOfPostProcessing = 1; } "lisflood" = { typeOfPostProcessing = 1; }
"lisflood_eric" = { typeOfPostProcessing = 2; } "lisflood_eric" = { typeOfPostProcessing = 2; }
"lisflood_season" = { typeOfPostProcessing = 3; } "lisflood_season" = { typeOfPostProcessing = 3; }
@ -15,4 +15,3 @@
"mhm_mrm" = { typeOfPostProcessing = 203; } "mhm_mrm" = { typeOfPostProcessing = 203; }
"pcrg_mrm" = { typeOfPostProcessing = 204; } "pcrg_mrm" = { typeOfPostProcessing = 204; }
"meteogrid" = { typeOfPostProcessing = 205; } "meteogrid" = { typeOfPostProcessing = 205; }

View File

@ -1,4 +1,4 @@
# CODE TABLE 4.15, Confidence level units # CODE TABLE 4.15, Confidence level units
0 0 bad 0 0 bad
1 1 suspect 1 1 suspect

View File

@ -31,7 +31,7 @@
29 29 Total snowfall (m) 29 29 Total snowfall (m)
30 30 Precipitable water category (Code table 4.202) 30 30 Precipitable water category (Code table 4.202)
31 31 Hail (m) 31 31 Hail (m)
32 32 Graupel (snow pellets) (kg kg-1) 32 32 Graupel (snow pellets) (kg kg-1)
33 33 Categorical rain (Code table 4.222) 33 33 Categorical rain (Code table 4.222)
34 34 Categorical freezing rain (Code table 4.222) 34 34 Categorical freezing rain (Code table 4.222)
35 35 Categorical ice pellets (Code table 4.222) 35 35 Categorical ice pellets (Code table 4.222)

View File

@ -1,4 +1,4 @@
# CODE TABLE 4.15, Confidence level units # CODE TABLE 4.15, Confidence level units
0 0 bad 0 0 bad
1 1 suspect 1 1 suspect

View File

@ -1,7 +1,7 @@
# (C) Copyright 2005- ECMWF. # (C) Copyright 2005- ECMWF.
# TEMPLATE 3.1, Rotated Latitude/longitude (or equidistant cylindrical, or Plate Carree) # TEMPLATE 3.1, Rotated Latitude/longitude (or equidistant cylindrical, or Plate Carree)
include "grib2/template.3.shape_of_the_earth.def"; include "grib2/template.3.shape_of_the_earth.def";
include "grib2/template.3.latlon.def"; include "grib2/template.3.latlon.def";
include "grib2/template.3.rotation.def"; include "grib2/template.3.rotation.def";

View File

@ -50,7 +50,7 @@ include "grib2/template.3.scanning_mode.def";
unsigned[4] orientationOfTheGrid : dump ; unsigned[4] orientationOfTheGrid : dump ;
meta geography.orientationOfTheGridInDegrees meta geography.orientationOfTheGridInDegrees
scale(orientationOfTheGrid,oneConstant,grib2divider,truncateDegrees) : dump; scale(orientationOfTheGrid,oneConstant,grib2divider,truncateDegrees) : dump;
# Di - longitudinal direction grid length # Di - longitudinal direction grid length
# NOTE 2: Grid lengths are in units of 10**-3 m, at the latitude specified by LaD # NOTE 2: Grid lengths are in units of 10**-3 m, at the latitude specified by LaD
unsigned[4] Di : edition_specific,no_copy; unsigned[4] Di : edition_specific,no_copy;

View File

@ -48,7 +48,7 @@ include "grib2/template.3.scanning_mode.def";
unsigned[4] Di : edition_specific,no_copy; unsigned[4] Di : edition_specific,no_copy;
alias iDirectionIncrementGridLength = Di; alias iDirectionIncrementGridLength = Di;
meta geography.DiInMetres scale(Di,oneConstant,hundred,truncateDegrees) : dump; meta geography.DiInMetres scale(Di,oneConstant,hundred,truncateDegrees) : dump;
# Dj - j-direction increment length in units of 10-2 m # Dj - j-direction increment length in units of 10-2 m
unsigned[4] Dj : edition_specific,no_copy; unsigned[4] Dj : edition_specific,no_copy;
alias jDirectionIncrementGridLength = Dj; alias jDirectionIncrementGridLength = Dj;

View File

@ -1,7 +1,7 @@
# (C) Copyright 2005- ECMWF. # (C) Copyright 2005- ECMWF.
# TEMPLATE 3.2, Stretched Latitude/longitude (or equidistant cylindrical, or Plate Carree) # TEMPLATE 3.2, Stretched Latitude/longitude (or equidistant cylindrical, or Plate Carree)
include "grib2/template.3.shape_of_the_earth.def"; include "grib2/template.3.shape_of_the_earth.def";
include "grib2/template.3.latlon.def"; include "grib2/template.3.latlon.def";
include "grib2/template.3.stretching.def"; include "grib2/template.3.stretching.def";

View File

@ -1,6 +1,5 @@
# (C) Copyright 2005- ECMWF. # (C) Copyright 2005- ECMWF.
# TEMPLATE 3.4, Variable resolution latitude/longitude # TEMPLATE 3.4, Variable resolution latitude/longitude
include "grib2/template.3.shape_of_the_earth.def"; include "grib2/template.3.shape_of_the_earth.def";
include "grib2/template.3.latlon_vares.def"; include "grib2/template.3.latlon_vares.def";

View File

@ -1,7 +1,7 @@
# (C) Copyright 2005- ECMWF. # (C) Copyright 2005- ECMWF.
# TEMPLATE 3.41, Rotated Gaussian latitude/longitude # TEMPLATE 3.41, Rotated Gaussian latitude/longitude
include "grib2/template.3.shape_of_the_earth.def"; include "grib2/template.3.shape_of_the_earth.def";
include "grib2/template.3.gaussian.def"; include "grib2/template.3.gaussian.def";
include "grib2/template.3.rotation.def"; include "grib2/template.3.rotation.def";

View File

@ -1,7 +1,7 @@
# (C) Copyright 2005- ECMWF. # (C) Copyright 2005- ECMWF.
# TEMPLATE 3.5, Variable resolution rotated latitude/longitude # TEMPLATE 3.5, Variable resolution rotated latitude/longitude
include "grib2/template.3.shape_of_the_earth.def"; include "grib2/template.3.shape_of_the_earth.def";
include "grib2/template.3.latlon_vares.def"; include "grib2/template.3.latlon_vares.def";
include "grib2/template.3.rotation.def"; include "grib2/template.3.rotation.def";

View File

@ -26,11 +26,11 @@ meta g2grid g2grid(
subdivisionsOfBasicAngle subdivisionsOfBasicAngle
); );
meta geography.latitudeOfFirstGridPointInDegrees g2latlon(g2grid,0) : dump; meta geography.latitudeOfFirstGridPointInDegrees g2latlon(g2grid,0) : dump;
meta geography.longitudeOfFirstGridPointInDegrees g2latlon(g2grid,1) : dump; meta geography.longitudeOfFirstGridPointInDegrees g2latlon(g2grid,1) : dump;
meta geography.latitudeOfLastGridPointInDegrees g2latlon(g2grid,2) : dump; meta geography.latitudeOfLastGridPointInDegrees g2latlon(g2grid,2) : dump;
meta geography.longitudeOfLastGridPointInDegrees g2latlon(g2grid,3) : dump; meta geography.longitudeOfLastGridPointInDegrees g2latlon(g2grid,3) : dump;
meta geography.iDirectionIncrementInDegrees g2latlon(g2grid,4,iDirectionIncrementGiven) : can_be_missing,dump; meta geography.iDirectionIncrementInDegrees g2latlon(g2grid,4,iDirectionIncrementGiven) : can_be_missing,dump;
meta global global_gaussian(N,Ni,iDirectionIncrement, meta global global_gaussian(N,Ni,iDirectionIncrement,
latitudeOfFirstGridPoint, latitudeOfFirstGridPoint,

View File

@ -1,4 +1,5 @@
# (C) Copyright 2005- ECMWF. # (C) Copyright 2005- ECMWF.
# Atmospheric chemical or physical constituent type # Aerosol type
codetable[2] aerosolType ('4.233.table',masterDir,localDir) : dump; codetable[2] aerosolType ('4.233.table',masterDir,localDir) : dump;
meta aerosolTypeName codetable_title(aerosolType);

View File

@ -47,7 +47,7 @@ if (typeOfSecondFixedSurface == 255) {
scaledValueOfSecondFixedSurface, scaledValueOfSecondFixedSurface,
pressureUnits) :dump; pressureUnits) :dump;
alias level=topLevel; # (see GRIB-725) alias level=topLevel; # (see GRIB-725)
} }
alias ls.level=level; alias ls.level=level;
alias vertical.level=level; alias vertical.level=level;

View File

@ -2,18 +2,17 @@
# The input process identifier shall have the value of the 'analysis or forecast process identifier' of the # The input process identifier shall have the value of the 'analysis or forecast process identifier' of the
# original GRIB message used as input of the post-processing # original GRIB message used as input of the post-processing
unsigned[2] inputProcessIdentifier : dump,edition_specific; unsigned[2] inputProcessIdentifier : dump,edition_specific;
# The input originating centre shall have the value of the 'originating centre' of the original GRIB message # The input originating centre shall have the value of the 'originating centre' of the original GRIB message
# used as input of the post-processing # used as input of the post-processing
codetable[2] inputOriginatingCentre 'common/c-11.table' : dump,edition_specific,string_type; codetable[2] inputOriginatingCentre 'common/c-11.table' : dump,edition_specific,string_type;
# This identifies which post-processing technique was used. This is defined by the originating centre # This identifies which post-processing technique was used. This is defined by the originating centre
unsigned[1] typeOfPostProcessing : dump,edition_specific; unsigned[1] typeOfPostProcessing : dump,edition_specific;
concept postProcessing (unknown,"postProcessingConcept.def",conceptsDir2,conceptsDir1):no_copy; concept postProcessing (unknown,"postProcessingConcept.def",conceptsDir2,conceptsDir1):no_copy;
if (datasetForLocal is "fire") { if (datasetForLocal is "fire") {
template_nofail fireTemplate "grib2/fireTemplate.def"; template_nofail fireTemplate "grib2/fireTemplate.def";
} }

View File

@ -74,7 +74,7 @@ if (numberOfTimeRange == 1 || numberOfTimeRange == 2) {
meta endStep g2end_step( meta endStep g2end_step(
startStep, startStep,
stepUnits, stepUnits,
year, year,
month, month,
day, day,
@ -94,7 +94,7 @@ if (numberOfTimeRange == 1 || numberOfTimeRange == 2) {
typeOfTimeIncrement, typeOfTimeIncrement,
numberOfTimeRange numberOfTimeRange
) : dump,no_copy; ) : dump,no_copy;
meta stepRange g2step_range(startStep,endStep): dump; meta stepRange g2step_range(startStep,endStep): dump;
} else { } else {
constant stepType = "multiple steps"; constant stepType = "multiple steps";

View File

@ -16,7 +16,7 @@ unsigned[4] numberOfCodedValues;
# NR - first dimension (rows) # NR - first dimension (rows)
unsigned[2] firstDimension; unsigned[2] firstDimension;
alias NR = firstDimension; alias NR = firstDimension;
# NC - second dimension (columns) # NC - second dimension (columns)
unsigned[2] secondDimension; unsigned[2] secondDimension;
@ -47,12 +47,12 @@ ieeefloat coefsSecond[NC2]; # TODO: find proper names
alias data.coefsFirst = coefsFirst; alias data.coefsFirst = coefsFirst;
alias data.coefsSecond=coefsSecond; alias data.coefsSecond=coefsSecond;
if(matrixBitmapsPresent == 1) { if (matrixBitmapsPresent == 1) {
constant datumSize = NC*NR; constant datumSize = NC*NR;
constant secondaryBitmapsCount = numberOfValues + 0; constant secondaryBitmapsCount = numberOfValues + 0;
constant secondaryBitmapsSize = secondaryBitmapsCount/8; constant secondaryBitmapsSize = secondaryBitmapsCount/8;
transient numberOfDataMatrices = numberOfDataPoints/datumSize; transient numberOfDataMatrices = numberOfDataPoints/datumSize;
position offsetBBitmap; position offsetBBitmap;
meta secondaryBitmaps g2bitmap( meta secondaryBitmaps g2bitmap(
@ -63,7 +63,7 @@ if(matrixBitmapsPresent == 1) {
numberOfCodedValues , numberOfCodedValues ,
dummy) : read_only; dummy) : read_only;
meta bitmap data_g2secondary_bitmap(primaryBitmap, meta bitmap data_g2secondary_bitmap(primaryBitmap,
secondaryBitmaps, secondaryBitmaps,
missingValue,datumSize,numberOfDataPoints) : read_only; missingValue,datumSize,numberOfDataPoints) : read_only;
} }

View File

@ -3,5 +3,5 @@
# TEMPLATE 5.50, Spectral data - simple packing # TEMPLATE 5.50, Spectral data - simple packing
include "grib2/template.5.packing.def"; include "grib2/template.5.packing.def";
# Real part of (0,0) # Real part of (0,0)
ieeefloat realPartOf00 ; ieeefloat realPartOf00 ;

View File

@ -31,7 +31,6 @@ transient numberOfPackedValues = numberOfValues - 1 : no_copy;
numberOfValues numberOfValues
) ; ) ;
meta packingError simple_packing_error(bitsPerValue,binaryScaleFactor,decimalScaleFactor,referenceValue,ieee) : no_copy; meta packingError simple_packing_error(bitsPerValue,binaryScaleFactor,decimalScaleFactor,referenceValue,ieee) : no_copy;
meta unpackedError simple_packing_error(zero,binaryScaleFactor,decimalScaleFactor,referenceValue,ieee) : no_copy; meta unpackedError simple_packing_error(zero,binaryScaleFactor,decimalScaleFactor,referenceValue,ieee) : no_copy;

View File

@ -1,8 +1,7 @@
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 14 Feb 2014 # created: 14 Feb 2014
# modified:
# #
################################# #################################
### LOCAL SECTION DESCRIPTION ### ### LOCAL SECTION DESCRIPTION ###

View File

@ -1,8 +1,7 @@
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 14 Feb 2014 # created: 14 Feb 2014
# modified:
# #
################################# #################################
### LOCAL SECTION DESCRIPTION ### ### LOCAL SECTION DESCRIPTION ###

View File

@ -1,8 +1,7 @@
################################################# #################################################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 14 Feb 2014 # created: 14 Feb 2014
# modified:
# #
################################# #################################
### LOCAL SECTION DESCRIPTION ### ### LOCAL SECTION DESCRIPTION ###

View File

@ -1,8 +1,7 @@
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 14 Feb 2014 # created: 14 Feb 2014
# modified:
# #
######################### #########################

View File

@ -1,6 +1,5 @@
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 14 Feb 2014 # created: 14 Feb 2014
# modified:
# #
######################### #########################

View File

@ -1,6 +1,6 @@
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 6 Oct 2011 # created: 6 Oct 2011
# modified: 13 May 2013 # modified: 13 May 2013
# #

View File

@ -1,6 +1,6 @@
######################### #########################
## ##
## author: Sebastien Villaume <Sebastien.Villaume@smhi.se> ## author: Sebastien Villaume
## created: 6 Oct 2011 ## created: 6 Oct 2011
## modified: 20 Feb 2014 ## modified: 20 Feb 2014
## ##

View File

@ -1,6 +1,6 @@
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 6 Oct 2011 # created: 6 Oct 2011
# modified: 20 Feb 2014 # modified: 20 Feb 2014
# #

View File

@ -1,6 +1,6 @@
######################### #########################
# #
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se> # author: Sebastien Villaume
# created: 6 Oct 2011 # created: 6 Oct 2011
# modified: 13 May 2013 # modified: 13 May 2013
# #

View File

@ -82,6 +82,7 @@ if( HAVE_BUILD_TOOLS )
grib_set_bitmap grib_set_bitmap
grib_list grib_list
grib_get_data grib_get_data
grib_nearest
grib_nearest_multiple grib_nearest_multiple
grib_multi grib_multi
grib_set_missing grib_set_missing

View File

@ -35,14 +35,14 @@ int main(int argc, char** argv)
int i = 0; int i = 0;
codes_fieldset* set = NULL; codes_fieldset* set = NULL;
codes_handle* h = NULL; codes_handle* h = NULL;
char param[20] = {0,}; char shortName[20] = {0,};
size_t len = 20; size_t len = 20;
double lats[4] = {0,}; double lats[4] = {0,};
double lons[4] = {0,}; double lons[4] = {0,};
double values[4] = {0,}; double values[4] = {0,};
double distances[4] = {0,}; double distances[4] = {0,};
int indexes[4] = {0,}; int indexes[4] = {0,};
char* order_by = "param,step"; char* order_by = "shortName,step:i";
size_t size = 4; size_t size = 4;
double lat = -40, lon = 15; double lat = -40, lon = 15;
@ -63,7 +63,6 @@ int main(int argc, char** argv)
printf("\nordering by %s\n", order_by); printf("\nordering by %s\n", order_by);
printf("\n%d fields in the fieldset\n", codes_fieldset_count(set)); printf("\n%d fields in the fieldset\n", codes_fieldset_count(set));
printf("n,step,param\n");
mode = CODES_NEAREST_SAME_GRID | CODES_NEAREST_SAME_POINT; mode = CODES_NEAREST_SAME_GRID | CODES_NEAREST_SAME_POINT;
count = 1; count = 1;
@ -71,9 +70,9 @@ int main(int argc, char** argv)
while ((h = codes_fieldset_next_handle(set, &err)) != NULL) { while ((h = codes_fieldset_next_handle(set, &err)) != NULL) {
CODES_CHECK(codes_get_long(h, "step", &step), 0); CODES_CHECK(codes_get_long(h, "step", &step), 0);
len = 20; len = 20;
CODES_CHECK(codes_get_string(h, "shortName", param, &len), 0); CODES_CHECK(codes_get_string(h, "shortName", shortName, &len), 0);
printf("%d %ld %s ", count, step, param); printf("Msg #%d, step=%ld, shortName=%s", count, step, shortName);
if (!nearest) nearest = codes_grib_nearest_new(h, &err); if (!nearest) nearest = codes_grib_nearest_new(h, &err);
CODES_CHECK(err, 0); CODES_CHECK(err, 0);
CODES_CHECK(codes_grib_nearest_find(nearest, h, lat, lon, mode, lats, lons, values, distances, indexes, &size), 0); CODES_CHECK(codes_grib_nearest_find(nearest, h, lat, lon, mode, lats, lons, values, distances, indexes, &size), 0);
@ -91,5 +90,9 @@ int main(int argc, char** argv)
if (set) codes_fieldset_delete(set); if (set) codes_fieldset_delete(set);
for (i = 0; i < nfiles; i++)
free(filenames[i]);
free(filenames);
return 0; return 0;
} }

66
examples/C/grib_nearest.sh Executable file
View File

@ -0,0 +1,66 @@
#!/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="grib_nearest_c"
tempTxt=temp.$label.txt
tempRef=temp.$label.ref
input=${data_dir}/high_level_api.grib2
${examples_dir}/c_grib_nearest $input > $tempTxt
cat > $tempRef <<EOF
ordering by shortName,step:i
5 fields in the fieldset
Msg #1, step=0, shortName=msl
Idx lat lon dist val
58017 -40.85 15.30 97.627 101524
58016 -40.85 14.40 107.078 101570
57617 -39.95 15.30 26.1625 101655
57616 -39.95 14.40 51.4303 101669
Msg #2, step=6, shortName=msl
Idx lat lon dist val
58017 -40.85 15.30 97.627 101547
58016 -40.85 14.40 107.078 101605
57617 -39.95 15.30 26.1625 101589
57616 -39.95 14.40 51.4303 101641
Msg #3, step=12, shortName=msl
Idx lat lon dist val
58017 -40.85 15.30 97.627 101606
58016 -40.85 14.40 107.078 101623
57617 -39.95 15.30 26.1625 101652
57616 -39.95 14.40 51.4303 101678
Msg #4, step=18, shortName=msl
Idx lat lon dist val
58017 -40.85 15.30 97.627 101507
58016 -40.85 14.40 107.078 101486
57617 -39.95 15.30 26.1625 101573
57616 -39.95 14.40 51.4303 101571
Msg #5, step=24, shortName=msl
Idx lat lon dist val
58017 -40.85 15.30 97.627 101379
58016 -40.85 14.40 107.078 101372
57617 -39.95 15.30 26.1625 101494
57616 -39.95 14.40 51.4303 101471
EOF
diff $tempRef $tempTxt
rm -f $tempTxt $tempRef

View File

@ -89,7 +89,7 @@ grib_handle* codes_fieldset_next_handle(grib_fieldset* set, int* err)
{ {
return grib_fieldset_next_handle(set, err); return grib_fieldset_next_handle(set, err);
} }
int codes_fieldset_count(grib_fieldset* set) int codes_fieldset_count(const grib_fieldset* set)
{ {
return grib_fieldset_count(set); return grib_fieldset_count(set);
} }

View File

@ -187,7 +187,7 @@ void codes_fieldset_delete(codes_fieldset* set);
void codes_fieldset_rewind(codes_fieldset* set); void codes_fieldset_rewind(codes_fieldset* set);
int codes_fieldset_apply_order_by(codes_fieldset* set, const char* order_by_string); int codes_fieldset_apply_order_by(codes_fieldset* set, const char* order_by_string);
codes_handle* codes_fieldset_next_handle(codes_fieldset* set, int* err); codes_handle* codes_fieldset_next_handle(codes_fieldset* set, int* err);
int codes_fieldset_count(codes_fieldset* set); int codes_fieldset_count(const codes_fieldset* set);
int codes_values_check(codes_handle* h, codes_values* values, int count); int codes_values_check(codes_handle* h, codes_values* values, int count);
/*! \defgroup codes_index The indexing feature /*! \defgroup codes_index The indexing feature

View File

@ -2467,7 +2467,8 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset
self->dataAccessors = grib_accessors_list_create(c); self->dataAccessors = grib_accessors_list_create(c);
if (self->dataAccessorsTrie) { if (self->dataAccessorsTrie) {
grib_trie_with_rank_delete(self->dataAccessorsTrie); /* ECC-989: do not call grib_trie_with_rank_delete */
grib_trie_with_rank_delete_container(self->dataAccessorsTrie);
} }
self->dataAccessorsTrie = grib_trie_with_rank_new(c); self->dataAccessorsTrie = grib_trie_with_rank_new(c);
@ -3466,8 +3467,10 @@ static void destroy(grib_context* c, grib_accessor* a)
self_clear(c, self); self_clear(c, self);
if (self->dataAccessors) if (self->dataAccessors)
grib_accessors_list_delete(c, self->dataAccessors); grib_accessors_list_delete(c, self->dataAccessors);
if (self->dataAccessorsTrie) if (self->dataAccessorsTrie) {
grib_trie_with_rank_delete_container(self->dataAccessorsTrie); grib_trie_with_rank_delete_container(self->dataAccessorsTrie);
self->dataAccessorsTrie = NULL;
}
if (self->tempStrings) { if (self->tempStrings) {
grib_sarray_delete_content(c, self->tempStrings); grib_sarray_delete_content(c, self->tempStrings);
grib_sarray_delete(c, self->tempStrings); grib_sarray_delete(c, self->tempStrings);

View File

@ -535,9 +535,10 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
*val = atol(p); *val = atol(p);
*len = 1; *len = 1;
#if 0 #ifdef DEBUG
/* ECC-980: Changes reverted because of side-effects! /* ECC-980: Changes reverted because of side-effects!
* e.g. marsType being a codetable and concept! see ifsParam * e.g. marsType being a codetable and concept! see ifsParam.
* Keep this check in DEBUG mode only
*/ */
{ {
char *endptr; char *endptr;

View File

@ -214,7 +214,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
grib_handle* hand = grib_handle_of_accessor(a); grib_handle* hand = grib_handle_of_accessor(a);
int err = GRIB_SUCCESS, i = 0; int err = GRIB_SUCCESS, i = 0;
size_t buflen = grib_byte_count(a); size_t buflen = 0;
struct aec_stream strm; struct aec_stream strm;
double bscale = 0; double bscale = 0;
double dscale = 0; double dscale = 0;
@ -260,9 +260,6 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
if ((err = grib_get_long_internal(hand, self->ccsds_rsi, &ccsds_rsi)) != GRIB_SUCCESS) if ((err = grib_get_long_internal(hand, self->ccsds_rsi, &ccsds_rsi)) != GRIB_SUCCESS)
return err; return err;
bscale = grib_power(binary_scale_factor, 2);
dscale = grib_power(-decimal_scale_factor, 10);
/* TODO: This should be called upstream */ /* TODO: This should be called upstream */
if (*len < n_vals) if (*len < n_vals)
return GRIB_ARRAY_TOO_SMALL; return GRIB_ARRAY_TOO_SMALL;
@ -275,6 +272,10 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
return GRIB_SUCCESS; return GRIB_SUCCESS;
} }
bscale = grib_power(binary_scale_factor, 2);
dscale = grib_power(-decimal_scale_factor, 10);
buflen = grib_byte_count(a);
buf = (unsigned char*)hand->buffer->data; buf = (unsigned char*)hand->buffer->data;
buf += grib_byte_offset(a); buf += grib_byte_offset(a);

View File

@ -158,7 +158,7 @@ static int unpack_string(grib_accessor* a, char* v, size_t* len)
{ {
grib_accessor_gaussian_grid_name* self = (grib_accessor_gaussian_grid_name*)a; grib_accessor_gaussian_grid_name* self = (grib_accessor_gaussian_grid_name*)a;
long N = 0, Ni = 0, isOctahedral = 0; long N = 0, Ni = 0;
char tmp[MAX_GRIDNAME_LEN] = {0,}; char tmp[MAX_GRIDNAME_LEN] = {0,};
size_t length = 0; size_t length = 0;
int ret = GRIB_SUCCESS; int ret = GRIB_SUCCESS;
@ -167,20 +167,21 @@ static int unpack_string(grib_accessor* a, char* v, size_t* len)
return ret; return ret;
if ((ret = grib_get_long_internal(a->parent->h, self->Ni, &Ni)) != GRIB_SUCCESS) if ((ret = grib_get_long_internal(a->parent->h, self->Ni, &Ni)) != GRIB_SUCCESS)
return ret; return ret;
if ((ret = grib_get_long_internal(a->parent->h, self->isOctahedral, &isOctahedral)) != GRIB_SUCCESS)
return ret;
if (Ni == GRIB_MISSING_LONG) { if (Ni == GRIB_MISSING_LONG) {
/* reduced gaussian grid */ /* Reduced gaussian grid */
long isOctahedral = 0;
if ((ret = grib_get_long_internal(a->parent->h, self->isOctahedral, &isOctahedral)) != GRIB_SUCCESS)
return ret;
if (isOctahedral == 1) { if (isOctahedral == 1) {
sprintf(tmp, "O%ld", N); sprintf(tmp, "O%ld", N);
} }
else { else {
sprintf(tmp, "N%ld", N); sprintf(tmp, "N%ld", N); /* Classic */
} }
} }
else { else {
/* regular gaussian grid */ /* Regular gaussian grid */
sprintf(tmp, "F%ld", N); sprintf(tmp, "F%ld", N);
} }
length = strlen(tmp) + 1; length = strlen(tmp) + 1;

View File

@ -321,8 +321,7 @@ static int unpack_double(grib_accessor* a, double* v, size_t* len)
grib_unpack_string(a, val, &l); grib_unpack_string(a, val, &l);
*v = strtod(val, &last); *v = strtod(val, &last);
if (*last == 0) { /* conversion of string to double worked */
if (*last == 0) {
grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting string %s to long", a->name); grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting string %s to long", a->name);
return GRIB_SUCCESS; return GRIB_SUCCESS;
} }
@ -515,7 +514,14 @@ static int pack_string(grib_accessor* a, const char* v, size_t* len)
{ {
if (a->cclass->pack_double && a->cclass->pack_double != &pack_double) { if (a->cclass->pack_double && a->cclass->pack_double != &pack_double) {
size_t l = 1; size_t l = 1;
double val = atof(v); char* endPtr = NULL; /* for error handling */
double val = strtod(v, &endPtr);
if (*endPtr) {
grib_context_log(a->context, GRIB_LOG_ERROR,
"pack_string: Invalid value (%s) for %s. String cannot be converted to a double",
v, a->name);
return GRIB_WRONG_TYPE;
}
return grib_pack_double(a, &val, &l); return grib_pack_double(a, &val, &l);
} }
@ -525,8 +531,7 @@ static int pack_string(grib_accessor* a, const char* v, size_t* len)
return grib_pack_long(a, &val, &l); return grib_pack_long(a, &val, &l);
} }
grib_context_log(a->context, GRIB_LOG_ERROR, grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack '%s' as string", a->name);
"Should not grib_pack %s as string", a->name);
return GRIB_NOT_IMPLEMENTED; return GRIB_NOT_IMPLEMENTED;
} }

View File

@ -294,8 +294,7 @@ static int compare(grib_accessor* a, grib_accessor* b)
static int pack_string(grib_accessor* a, const char* val, size_t* len) static int pack_string(grib_accessor* a, const char* val, size_t* len)
{ {
char* theEnd = NULL; long v = 0; /* The converted value */
long v = 0;
#if 0 #if 0
/* Requires more work e.g. filter */ /* Requires more work e.g. filter */
@ -304,9 +303,9 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len)
} }
#endif #endif
v = strtol(val, &theEnd, 10); if (string_to_long(val, &v) != GRIB_SUCCESS) {
if (theEnd) { grib_context_log(a->context, GRIB_LOG_ERROR,
grib_context_log(a->context, GRIB_LOG_ERROR, "trying to pack \"%s\" as long", val); "Trying to pack \"%s\" as long. String cannot be converted to an integer", val);
return GRIB_WRONG_TYPE; return GRIB_WRONG_TYPE;
} }
return grib_pack_long(a, &v, len); return grib_pack_long(a, &v, len);

View File

@ -240,7 +240,7 @@ void grib_fieldset_delete(grib_fieldset* set);
void grib_fieldset_rewind(grib_fieldset* set); void grib_fieldset_rewind(grib_fieldset* set);
int grib_fieldset_apply_order_by(grib_fieldset* set, const char* order_by_string); int grib_fieldset_apply_order_by(grib_fieldset* set, const char* order_by_string);
grib_handle* grib_fieldset_next_handle(grib_fieldset* set, int* err); grib_handle* grib_fieldset_next_handle(grib_fieldset* set, int* err);
int grib_fieldset_count(grib_fieldset* set); int grib_fieldset_count(const grib_fieldset* set);
int grib_values_check(grib_handle* h, grib_values* values, int count); int grib_values_check(grib_handle* h, grib_values* values, int count);
/*! \defgroup grib_index The grib_index /*! \defgroup grib_index The grib_index

View File

@ -219,7 +219,6 @@ size_t grib_sarray_used_size(grib_sarray* v);
grib_oarray* grib_oarray_new(grib_context* c, size_t size, size_t incsize); grib_oarray* grib_oarray_new(grib_context* c, size_t size, size_t incsize);
grib_oarray* grib_oarray_push(grib_context* c, grib_oarray* v, void* val); grib_oarray* grib_oarray_push(grib_context* c, grib_oarray* v, void* val);
void grib_oarray_delete(grib_context* c, grib_oarray* v); void grib_oarray_delete(grib_context* c, grib_oarray* v);
void grib_oarray_delete_content(grib_context* c, grib_oarray* v);
void** grib_oarray_get_array(grib_context* c, grib_oarray* v); void** grib_oarray_get_array(grib_context* c, grib_oarray* v);
void* grib_oarray_get(grib_oarray* v, int i); void* grib_oarray_get(grib_oarray* v, int i);
size_t grib_oarray_used_size(grib_oarray* v); size_t grib_oarray_used_size(grib_oarray* v);
@ -675,14 +674,12 @@ bufr_descriptors_array* grib_accessor_class_expanded_descriptors_get_expanded(gr
/* grib_accessor_class_md5.c */ /* grib_accessor_class_md5.c */
/* grib_jasper_encoding.c */ /* grib_jasper_encoding.c */
int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, double* values, size_t* no_values); int grib_jasper_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* values, const size_t* n_vals);
int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper);
int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, double* val, size_t* n_vals);
int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper); int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper);
/* grib_openjpeg_encoding.c */ /* grib_openjpeg_encoding.c */
int grib_openjpeg_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* values, const size_t* n_vals);
int grib_openjpeg_encode(grib_context* c, j2k_encode_helper* helper); int grib_openjpeg_encode(grib_context* c, j2k_encode_helper* helper);
int grib_openjpeg_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* val, const size_t* n_vals);
/* action_class_set_missing.c */ /* action_class_set_missing.c */
grib_action* grib_action_create_set_missing(grib_context* context, const char* name); grib_action* grib_action_create_set_missing(grib_context* context, const char* name);
@ -714,7 +711,6 @@ grib_index* grib_index_read(grib_context* c, const char* filename, int* err);
int grib_index_search_same(grib_index* index, grib_handle* h); int grib_index_search_same(grib_index* index, grib_handle* h);
int grib_index_add_file(grib_index* index, const char* filename); int grib_index_add_file(grib_index* index, const char* filename);
int _codes_index_add_file(grib_index* index, const char* filename, int message_type); int _codes_index_add_file(grib_index* index, const char* filename, int message_type);
int grib_index_add_file(grib_index* index, const char* filename);
grib_index* grib_index_new_from_file(grib_context* c, const char* filename, const char* keys, int* err); grib_index* grib_index_new_from_file(grib_context* c, const char* filename, const char* keys, int* err);
int grib_index_get_size(const grib_index* index, const char* key, size_t* size); int grib_index_get_size(const grib_index* index, const char* key, size_t* size);
int grib_index_get_string(const grib_index* index, const char* key, char** values, size_t* size); int grib_index_get_string(const grib_index* index, const char* key, char** values, size_t* size);
@ -815,14 +811,6 @@ void grib_timer_print(grib_timer* t);
void grib_timer_partial_rate(grib_timer* t, double start, long total); void grib_timer_partial_rate(grib_timer* t, double start, long total);
void grib_print_all_timers(void); void grib_print_all_timers(void);
void grib_reset_all_timers(void); void grib_reset_all_timers(void);
grib_timer* grib_get_timer(grib_context* c, const char* name, const char* statname, int elapsed);
int grib_timer_start(grib_timer* t);
int grib_timer_stop(grib_timer* t, long total);
double grib_timer_value(grib_timer* t);
void grib_timer_print(grib_timer* t);
void grib_timer_partial_rate(grib_timer* t, double start, long total);
void grib_print_all_timers(void);
void grib_reset_all_timers(void);
/* grib_ibmfloat.c */ /* grib_ibmfloat.c */
unsigned long grib_ibm_to_long(double x); unsigned long grib_ibm_to_long(double x);
@ -841,15 +829,10 @@ double grib_ieeefloat_error(double x);
double grib_long_to_ieee(unsigned long x); double grib_long_to_ieee(unsigned long x);
unsigned long grib_ieee_nearest_smaller_to_long(double x); unsigned long grib_ieee_nearest_smaller_to_long(double x);
int grib_nearest_smaller_ieee_float(double a, double* ret); int grib_nearest_smaller_ieee_float(double a, double* ret);
double grib_ieeefloat_error(double x);
double grib_long_to_ieee(unsigned long x);
int grib_nearest_smaller_ieee_float(double a, double* x);
unsigned long grib_ieee_to_long(double x);
unsigned long grib_ieee64_to_long(double x); unsigned long grib_ieee64_to_long(double x);
double grib_long_to_ieee64(unsigned long x); double grib_long_to_ieee64(unsigned long x);
int grib_ieee_decode_array(grib_context* c, unsigned char* buf, size_t nvals, int bytes, double* val); int grib_ieee_decode_array(grib_context* c, unsigned char* buf, size_t nvals, int bytes, double* val);
int grib_ieee_decode_array(grib_context* c, unsigned char* buf, size_t nvals, int bytes, double* val);
int grib_ieee_encode_array(grib_context* c, double* val, size_t nvals, int bytes, unsigned char* buf);
int grib_ieee_encode_array(grib_context* c, double* val, size_t nvals, int bytes, unsigned char* buf); int grib_ieee_encode_array(grib_context* c, double* val, size_t nvals, int bytes, unsigned char* buf);
/* grib_accessor_class_reference_value_error.c */ /* grib_accessor_class_reference_value_error.c */
@ -1008,10 +991,10 @@ 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); int grib_fieldset_apply_order_by(grib_fieldset* set, const char* order_by_string);
void grib_fieldset_delete_order_by(grib_context* c, grib_order_by* order_by); void grib_fieldset_delete_order_by(grib_context* c, grib_order_by* order_by);
void grib_fieldset_delete(grib_fieldset* set); void grib_fieldset_delete(grib_fieldset* set);
int grib_fieldset_add(grib_fieldset* set, char* filename); int grib_fieldset_add(grib_fieldset* set, const char* filename);
void grib_fieldset_rewind(grib_fieldset* set); void grib_fieldset_rewind(grib_fieldset* set);
grib_handle* grib_fieldset_next_handle(grib_fieldset* set, int* err); grib_handle* grib_fieldset_next_handle(grib_fieldset* set, int* err);
int grib_fieldset_count(grib_fieldset* set); int grib_fieldset_count(const grib_fieldset* set);
grib_handle* grib_fieldset_retrieve(grib_fieldset* set, int i, int* err); grib_handle* grib_fieldset_retrieve(grib_fieldset* set, int i, int* err);
/* grib_filepool.c */ /* grib_filepool.c */
@ -1138,8 +1121,6 @@ void* grib_trie_get(grib_trie* t, const char* key);
/* grib_trie_with_rank.c */ /* grib_trie_with_rank.c */
grib_trie_with_rank* grib_trie_with_rank_new(grib_context* c); grib_trie_with_rank* grib_trie_with_rank_new(grib_context* c);
void grib_trie_with_rank_delete_container(grib_trie_with_rank* t); void grib_trie_with_rank_delete_container(grib_trie_with_rank* t);
void grib_trie_with_rank_delete(grib_trie_with_rank* t);
void grib_trie_with_rank_clear(grib_trie_with_rank* t);
int grib_trie_with_rank_insert(grib_trie_with_rank* t, const char* key, void* data); int grib_trie_with_rank_insert(grib_trie_with_rank* t, const char* key, void* data);
void* grib_trie_with_rank_get(grib_trie_with_rank* t, const char* key, int rank); void* grib_trie_with_rank_get(grib_trie_with_rank* t, const char* key, int rank);

View File

@ -44,13 +44,10 @@ static grib_fieldset* grib_fieldset_create_from_order_by(grib_context* c, grib_o
static int grib_fieldset_resize(grib_fieldset* set, size_t newsize); static int grib_fieldset_resize(grib_fieldset* set, size_t newsize);
static void grib_trim(char** x); static void grib_trim(char** x);
static grib_order_by* grib_fieldset_new_order_by(grib_context* c, const char* z); static grib_order_by* grib_fieldset_new_order_by(grib_context* c, const char* z);
static int grib_fieldset_compare(grib_fieldset* set, int* i, int* j); static void grib_fieldset_sort(grib_fieldset* set, int theStart, int theEnd);
static void grib_fieldset_sort(grib_fieldset* set, int beg, int theEnd);
static int grib_fieldset_columns_resize(grib_fieldset* set, size_t newsize);
static grib_int_array* grib_fieldset_create_int_array(grib_context* c, size_t size); static grib_int_array* grib_fieldset_create_int_array(grib_context* c, size_t size);
static int grib_fieldset_resize_int_array(grib_int_array* a, size_t newsize); static int grib_fieldset_resize_int_array(grib_int_array* a, size_t newsize);
static void grib_fieldset_delete_int_array(grib_int_array* f); static void grib_fieldset_delete_int_array(grib_int_array* f);
static void grib_fieldset_delete_columns(grib_fieldset* set);
static grib_field** grib_fieldset_create_fields(grib_context* c, size_t size); static grib_field** grib_fieldset_create_fields(grib_context* c, size_t size);
static void grib_fieldset_delete_fields(grib_fieldset* set); static void grib_fieldset_delete_fields(grib_fieldset* set);
static int grib_fieldset_resize_fields(grib_fieldset* set, size_t newsize); static int grib_fieldset_resize_fields(grib_fieldset* set, size_t newsize);
@ -60,7 +57,7 @@ static int grib_fieldset_set_order_by(grib_fieldset* set, grib_order_by* ob);
/* --------------- grib_column functions ------------------*/ /* --------------- grib_column functions ------------------*/
int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int type) int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int type)
{ {
grib_column* column = 0; grib_column* column = NULL;
grib_context* c; grib_context* c;
int err = 0; int err = 0;
@ -69,38 +66,34 @@ int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int type)
c = set->context; c = set->context;
set->columns[id].errors = (int*)grib_context_malloc_clear(c, set->columns[id].errors = (int*)grib_context_malloc_clear(c, sizeof(int) * GRIB_START_ARRAY_SIZE);
sizeof(int) * GRIB_START_ARRAY_SIZE);
switch (type) { switch (type) {
case GRIB_TYPE_LONG: case GRIB_TYPE_LONG:
set->columns[id].long_values = (long*)grib_context_malloc_clear(c, set->columns[id].long_values = (long*)grib_context_malloc_clear(c, sizeof(long) * GRIB_START_ARRAY_SIZE);
sizeof(long) * GRIB_START_ARRAY_SIZE);
if (!set->columns[id].long_values) { if (!set->columns[id].long_values) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_new_column : Cannot malloc %ld bytes", "grib_fieldset_new_column: Cannot malloc %ld bytes",
sizeof(long) * GRIB_START_ARRAY_SIZE); sizeof(long) * GRIB_START_ARRAY_SIZE);
err = GRIB_OUT_OF_MEMORY; err = GRIB_OUT_OF_MEMORY;
return err; return err;
} }
break; break;
case GRIB_TYPE_DOUBLE: case GRIB_TYPE_DOUBLE:
set->columns[id].double_values = (double*)grib_context_malloc_clear(c, set->columns[id].double_values = (double*)grib_context_malloc_clear(c, sizeof(double) * GRIB_START_ARRAY_SIZE);
sizeof(double) * GRIB_START_ARRAY_SIZE);
if (!set->columns[id].double_values) { if (!set->columns[id].double_values) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_new_column : Cannot malloc %ld bytes", "grib_fieldset_new_column: Cannot malloc %ld bytes",
sizeof(double) * GRIB_START_ARRAY_SIZE); sizeof(double) * GRIB_START_ARRAY_SIZE);
err = GRIB_OUT_OF_MEMORY; err = GRIB_OUT_OF_MEMORY;
return err; return err;
} }
break; break;
case GRIB_TYPE_STRING: case GRIB_TYPE_STRING:
set->columns[id].string_values = (char**)grib_context_malloc_clear(c, set->columns[id].string_values = (char**)grib_context_malloc_clear(c, sizeof(char*) * GRIB_START_ARRAY_SIZE);
sizeof(char*) * GRIB_START_ARRAY_SIZE);
if (!set->columns[id].string_values) { if (!set->columns[id].string_values) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_new_column : Cannot malloc %ld bytes", "grib_fieldset_new_column: Cannot malloc %ld bytes",
sizeof(char*) * GRIB_START_ARRAY_SIZE); sizeof(char*) * GRIB_START_ARRAY_SIZE);
err = GRIB_OUT_OF_MEMORY; err = GRIB_OUT_OF_MEMORY;
return err; return err;
@ -108,7 +101,7 @@ int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int type)
break; break;
default: default:
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_new_column : unknown column type %d", type); "grib_fieldset_new_column: Unknown column type %d", type);
grib_context_free(c, column); grib_context_free(c, column);
return err; return err;
} }
@ -146,7 +139,7 @@ static void grib_fieldset_delete_columns(grib_fieldset* set)
break; break;
default: default:
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_new_column : unknown column type %d", set->columns[i].type); "grib_fieldset_new_column: Unknown column type %d", set->columns[i].type);
} }
grib_context_free(c, set->columns[i].errors); grib_context_free(c, set->columns[i].errors);
grib_context_free(c, set->columns[i].name); grib_context_free(c, set->columns[i].name);
@ -178,7 +171,8 @@ static int grib_fieldset_columns_resize(grib_fieldset* set, size_t newsize)
newsize * sizeof(long)); newsize * sizeof(long));
if (!newlongs) { if (!newlongs) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_columns_resize : Cannot malloc %ld bytes", newsize - set->columns[i].values_array_size); "grib_fieldset_columns_resize: Cannot malloc %ld bytes",
newsize - set->columns[i].values_array_size);
return GRIB_OUT_OF_MEMORY; return GRIB_OUT_OF_MEMORY;
} }
else else
@ -189,7 +183,8 @@ static int grib_fieldset_columns_resize(grib_fieldset* set, size_t newsize)
newsize * sizeof(double)); newsize * sizeof(double));
if (!newdoubles) { if (!newdoubles) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_columns_resize : Cannot malloc %ld bytes", newsize - set->columns[i].values_array_size); "grib_fieldset_columns_resize: Cannot malloc %ld bytes",
newsize - set->columns[i].values_array_size);
return GRIB_OUT_OF_MEMORY; return GRIB_OUT_OF_MEMORY;
} }
else else
@ -200,7 +195,8 @@ static int grib_fieldset_columns_resize(grib_fieldset* set, size_t newsize)
newsize * sizeof(char*)); newsize * sizeof(char*));
if (!newstrings) { if (!newstrings) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_columns_resize : Cannot malloc %ld bytes", newsize - set->columns[i].values_array_size); "grib_fieldset_columns_resize: Cannot malloc %ld bytes",
newsize - set->columns[i].values_array_size);
return GRIB_OUT_OF_MEMORY; return GRIB_OUT_OF_MEMORY;
} }
else else
@ -210,7 +206,7 @@ static int grib_fieldset_columns_resize(grib_fieldset* set, size_t newsize)
newerrors = (int*)grib_context_realloc(c, set->columns[i].errors, newsize * sizeof(int)); newerrors = (int*)grib_context_realloc(c, set->columns[i].errors, newsize * sizeof(int));
if (!newerrors) { if (!newerrors) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_columns_resize : Cannot malloc %ld bytes", "grib_fieldset_columns_resize: Cannot malloc %ld bytes",
newsize * sizeof(int)); newsize * sizeof(int));
return GRIB_OUT_OF_MEMORY; return GRIB_OUT_OF_MEMORY;
} }
@ -266,7 +262,7 @@ grib_fieldset* grib_fieldset_new_from_files(grib_context* c, char* filenames[],
int ret = GRIB_SUCCESS; int ret = GRIB_SUCCESS;
grib_order_by* ob = NULL; grib_order_by* ob = NULL;
grib_fieldset* set = 0; grib_fieldset* set = NULL;
if (!c) if (!c)
c = grib_context_get_default(); c = grib_context_get_default();
@ -300,8 +296,13 @@ grib_fieldset* grib_fieldset_new_from_files(grib_context* c, char* filenames[],
} }
} }
if (where_string) if (where_string) {
grib_fieldset_apply_where(set, where_string); ret = grib_fieldset_apply_where(set, where_string);
if (ret != GRIB_SUCCESS) {
*err = ret;
return NULL;
}
}
if (order_by_string) { if (order_by_string) {
if (!set->order_by && ob) if (!set->order_by && ob)
@ -315,10 +316,9 @@ grib_fieldset* grib_fieldset_new_from_files(grib_context* c, char* filenames[],
return set; return set;
} }
static grib_fieldset* grib_fieldset_create_from_keys(grib_context* c, char** keys, int nkeys, static grib_fieldset* grib_fieldset_create_from_keys(grib_context* c, char** keys, int nkeys, int* err)
int* err)
{ {
grib_fieldset* set = 0; grib_fieldset* set = NULL;
size_t msize = 0, size = 0; size_t msize = 0, size = 0;
int i = 0; int i = 0;
int type = 0; int type = 0;
@ -382,8 +382,7 @@ static grib_fieldset* grib_fieldset_create_from_keys(grib_context* c, char** key
return set; return set;
} }
static grib_fieldset* grib_fieldset_create_from_order_by(grib_context* c, grib_order_by* ob, static grib_fieldset* grib_fieldset_create_from_order_by(grib_context* c, grib_order_by* ob, int* err)
int* err)
{ {
char** keys = NULL; char** keys = NULL;
size_t nkeys = 0; size_t nkeys = 0;
@ -411,20 +410,22 @@ static grib_fieldset* grib_fieldset_create_from_order_by(grib_context* c, grib_o
return set; return set;
} }
/* Experimental: Needs more work */
int grib_fieldset_apply_where(grib_fieldset* set, const char* where_string) int grib_fieldset_apply_where(grib_fieldset* set, const char* where_string)
{ {
int err = GRIB_NOT_IMPLEMENTED; int err = GRIB_NOT_IMPLEMENTED;
grib_math* m = 0; grib_math* m = NULL;
if (!set) if (!set)
return GRIB_INVALID_ARGUMENT; return GRIB_INVALID_ARGUMENT;
m = grib_math_new(set->context, where_string, &err); m = grib_math_new(set->context, where_string, &err);
if (err || !m) return err;
print_math(m); print_math(m);
printf("\n"); printf("\n");
grib_math_delete(set->context, m); grib_math_delete(set->context, m);
return err; return GRIB_NOT_IMPLEMENTED;
} }
int grib_fieldset_apply_order_by(grib_fieldset* set, const char* order_by_string) int grib_fieldset_apply_order_by(grib_fieldset* set, const char* order_by_string)
@ -457,9 +458,9 @@ static int grib_fieldset_compare(grib_fieldset* set, int* i, int* j)
int ret = 0; int ret = 0;
double d = 0; double d = 0;
int idkey = 0; int idkey = 0;
grib_order_by* ob = 0; grib_order_by* ob = NULL;
int ii = 0, jj = 0; int ii = 0, jj = 0;
int* order = 0; int* order = NULL;
if (!set || !set->order_by) if (!set || !set->order_by)
return GRIB_INVALID_ARGUMENT; return GRIB_INVALID_ARGUMENT;
@ -505,18 +506,18 @@ static int grib_fieldset_compare(grib_fieldset* set, int* i, int* j)
return ret; return ret;
} }
static void grib_fieldset_sort(grib_fieldset* set, int beg, int theEnd) static void grib_fieldset_sort(grib_fieldset* set, int theStart, int theEnd)
{ {
double temp; double temp;
int l = 0, r = 0; int l = 0, r = 0;
if (theEnd > beg) { if (theEnd > theStart) {
l = beg + 1; l = theStart + 1;
r = theEnd; r = theEnd;
while (l < r) { while (l < r) {
if (grib_fieldset_compare(set, &l, &beg) <= 0) { if (grib_fieldset_compare(set, &l, &theStart) <= 0) {
l++; l++;
} }
else if (grib_fieldset_compare(set, &r, &beg) >= 0) { else if (grib_fieldset_compare(set, &r, &theStart) >= 0) {
r--; r--;
} }
else { else {
@ -524,16 +525,16 @@ static void grib_fieldset_sort(grib_fieldset* set, int beg, int theEnd)
} }
} }
if (grib_fieldset_compare(set, &l, &beg) < 0) { if (grib_fieldset_compare(set, &l, &theStart) < 0) {
SWAP(set->order->el[l], set->order->el[beg]) SWAP(set->order->el[l], set->order->el[theStart])
l--; l--;
} }
else { else {
l--; l--;
SWAP(set->order->el[l], set->order->el[beg]) SWAP(set->order->el[l], set->order->el[theStart])
} }
grib_fieldset_sort(set, beg, l); grib_fieldset_sort(set, theStart, l);
grib_fieldset_sort(set, r, theEnd); grib_fieldset_sort(set, r, theEnd);
} }
} }
@ -560,7 +561,7 @@ static grib_order_by* grib_fieldset_new_order_by(grib_context* c, const char* ob
{ {
char *t1 = 0, *t2 = 0, *p = 0; char *t1 = 0, *t2 = 0, *p = 0;
int id = 0; int id = 0;
char* z = 0; char* z = NULL;
int mode, mode_default = GRIB_ORDER_BY_ASC; int mode, mode_default = GRIB_ORDER_BY_ASC;
grib_order_by *ob, *sob; grib_order_by *ob, *sob;
@ -628,7 +629,7 @@ static grib_order_by* grib_fieldset_new_order_by(grib_context* c, const char* ob
void grib_fieldset_delete(grib_fieldset* set) void grib_fieldset_delete(grib_fieldset* set)
{ {
grib_context* c = 0; grib_context* c = NULL;
if (!set) if (!set)
return; return;
@ -644,17 +645,17 @@ void grib_fieldset_delete(grib_fieldset* set)
grib_context_free(c, set); grib_context_free(c, set);
} }
int grib_fieldset_add(grib_fieldset* set, char* filename) int grib_fieldset_add(grib_fieldset* set, const char* filename)
{ {
int ret = GRIB_SUCCESS; int ret = GRIB_SUCCESS;
int err = 0; int err = 0;
int i = 0; int i = 0;
grib_handle* h = 0; grib_handle* h = NULL;
/* int nkeys; */ /* int nkeys; */
grib_file* file; grib_file* file;
double offset = 0; double offset = 0;
long length = 0; long length = 0;
grib_context* c = 0; grib_context* c = NULL;
if (!set || !filename) if (!set || !filename)
return GRIB_INVALID_ARGUMENT; return GRIB_INVALID_ARGUMENT;
@ -742,15 +743,15 @@ grib_handle* grib_fieldset_next_handle(grib_fieldset* set, int* err)
return h; return h;
} }
int grib_fieldset_count(grib_fieldset* set) int grib_fieldset_count(const grib_fieldset* set)
{ {
return set->size; return set->size;
} }
grib_handle* grib_fieldset_retrieve(grib_fieldset* set, int i, int* err) grib_handle* grib_fieldset_retrieve(grib_fieldset* set, int i, int* err)
{ {
grib_handle* h = 0; grib_handle* h = NULL;
grib_field* field = 0; grib_field* field = NULL;
*err = GRIB_SUCCESS; *err = GRIB_SUCCESS;
if (!set) { if (!set) {
*err = GRIB_INVALID_ARGUMENT; *err = GRIB_INVALID_ARGUMENT;
@ -783,10 +784,9 @@ static grib_int_array* grib_fieldset_create_int_array(grib_context* c, size_t si
c = grib_context_get_default(); c = grib_context_get_default();
a = (grib_int_array*)grib_context_malloc_clear(c, sizeof(grib_int_array)); a = (grib_int_array*)grib_context_malloc_clear(c, sizeof(grib_int_array));
if (!a) { if (!a) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_create_int_array : Cannot malloc %ld bytes", "grib_fieldset_create_int_array: Cannot malloc %ld bytes",
sizeof(grib_int_array)); sizeof(grib_int_array));
return NULL; return NULL;
} }
@ -794,7 +794,7 @@ static grib_int_array* grib_fieldset_create_int_array(grib_context* c, size_t si
a->el = (int*)grib_context_malloc_clear(c, sizeof(int) * size); a->el = (int*)grib_context_malloc_clear(c, sizeof(int) * size);
if (!a->el) { if (!a->el) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_fieldset_create_int_array : Cannot malloc %ld bytes", "grib_fieldset_create_int_array: Cannot malloc %ld bytes",
sizeof(int) * size); sizeof(int) * size);
return NULL; return NULL;
} }
@ -896,7 +896,7 @@ static void grib_fieldset_delete_fields(grib_fieldset* set)
static void grib_trim(char** x) static void grib_trim(char** x)
{ {
char* p = 0; char* p = NULL;
while (**x == ' ') while (**x == ' ')
(*x)++; (*x)++;
if (**x == '\0') if (**x == '\0')

File diff suppressed because it is too large Load Diff

View File

@ -445,9 +445,9 @@ void grib_math_delete(grib_context* c, grib_math* m)
grib_math* grib_math_new(grib_context* c, const char* formula, int* err) grib_math* grib_math_new(grib_context* c, const char* formula, int* err)
{ {
grib_math* x; grib_math* x = NULL;
char* f = 0; char* f = NULL;
char* fsave = 0; char* fsave = NULL;
*err = 0; *err = 0;
@ -467,6 +467,7 @@ grib_math* grib_math_new(grib_context* c, const char* formula, int* err)
if (*f) { if (*f) {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_math_new : Part of the formula was not processed: '%s'", f); "grib_math_new : Part of the formula was not processed: '%s'", f);
*err = GRIB_INVALID_ARGUMENT;
return NULL; return NULL;
} }

View File

@ -170,8 +170,7 @@ static int init_sphere(grib_handle* h,
double Dx, double Dy, double radius, double Dx, double Dy, double radius,
double latFirstInRadians, double lonFirstInRadians, double latFirstInRadians, double lonFirstInRadians,
double LoVInRadians, double Latin1InRadians, double Latin2InRadians, double LoVInRadians, double Latin1InRadians, double Latin2InRadians,
double LaDInRadians, double LaDInRadians)
long iScansNegatively, long jScansPositively, long jPointsAreConsecutive)
{ {
int i, j; int i, j;
double f, n, rho, rho0, angle, x0, y0, x, y, tmp, tmp2; double f, n, rho, rho0, angle, x0, y0, x, y, tmp, tmp2;
@ -474,8 +473,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
LoVInDegrees, LoVInDegrees,
Dx, Dy, radius, Dx, Dy, radius,
latFirstInRadians, lonFirstInRadians, latFirstInRadians, lonFirstInRadians,
LoVInRadians, Latin1InRadians, Latin2InRadians, LaDInRadians, LoVInRadians, Latin1InRadians, Latin2InRadians, LaDInRadians);
iScansNegatively, jScansPositively, jPointsAreConsecutive);
} }
if (err) return err; if (err) return err;

View File

@ -18,18 +18,67 @@
#undef PACKAGE_TARNAME #undef PACKAGE_TARNAME
#undef PACKAGE_VERSION #undef PACKAGE_VERSION
#include "jasper/jasper.h" #include "jasper/jasper.h"
#define MAXOPTSSIZE 1024 #define MAXOPTSSIZE 1024
int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, double* values, size_t* no_values) static int ecc_jasper_initialise()
{ {
/*jas_setdbglevel(99999);*/ #if JASPER_VERSION_MAJOR == 3
int jaserr = 0;
jas_conf_clear();
jas_conf_set_max_mem_usage(jas_get_total_mem_size());
jaserr = jas_init_library();
if (jaserr) return jaserr;
jaserr = jas_init_thread();
if (jaserr) return jaserr;
#endif
return 0;
}
static jas_image_t* ecc_jasper_decode(jas_stream_t *in)
{
#if JASPER_VERSION_MAJOR == 3
/* Second argument (=fmt) < 0 means "If possible, try to determine the format of the input data" */
return jas_image_decode(in, -1, 0);
#else
return jpc_decode(in, NULL);
#endif
}
static int ecc_jasper_encode(jas_image_t *image, jas_stream_t *jpcstream, char *optstr)
{
#if JASPER_VERSION_MAJOR == 3
const int fmt = jas_image_strtofmt("jpc");
return jas_image_encode(image, jpcstream, fmt, optstr);
#else
return jpc_encode(image, jpcstream, optstr);
#endif
}
static void ecc_jasper_cleanup()
{
#if JASPER_VERSION_MAJOR == 3
jas_cleanup_thread();
jas_cleanup_library();
#endif
}
int grib_jasper_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* values, const size_t* n_vals)
{
/* jas_setdbglevel(99999); */
jas_image_t* image = NULL; jas_image_t* image = NULL;
jas_stream_t* jpeg = NULL; jas_stream_t* jpeg = NULL;
int code = GRIB_SUCCESS; int code = GRIB_SUCCESS;
jas_matrix_t* matrix = NULL; jas_matrix_t* matrix = NULL;
jas_image_cmpt_t* p; jas_image_cmpt_t* p;
int i, j, k; int i, j, k;
int jaserr = 0; /* 0 means success */
jaserr = ecc_jasper_initialise();
if (jaserr) {
grib_context_log(c, GRIB_LOG_ERROR, "grib_jasper_decode: Failed to initialize JasPer library. JasPer error %d", jaserr);
code = GRIB_DECODING_ERROR;
goto cleanup;
}
jpeg = jas_stream_memopen((char*)buf, *buflen); jpeg = jas_stream_memopen((char*)buf, *buflen);
if (!jpeg) { if (!jpeg) {
@ -37,9 +86,9 @@ int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, doub
goto cleanup; goto cleanup;
} }
grib_context_log(c, GRIB_LOG_DEBUG, "grib_jasper_decode: Jasper version %s", jas_getversion()); grib_context_log(c, GRIB_LOG_DEBUG, "grib_jasper_decode: JasPer version %s", jas_getversion());
image = jpc_decode(jpeg, NULL); image = ecc_jasper_decode(jpeg);
if (!image) { if (!image) {
code = GRIB_DECODING_ERROR; code = GRIB_DECODING_ERROR;
goto cleanup; goto cleanup;
@ -54,15 +103,19 @@ int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, doub
} }
matrix = jas_matrix_create(jas_image_height(image), jas_image_width(image)); matrix = jas_matrix_create(jas_image_height(image), jas_image_width(image));
if (!matrix) { if (!matrix) {
code = GRIB_DECODING_ERROR; code = GRIB_DECODING_ERROR;
goto cleanup; goto cleanup;
} }
jas_image_readcmpt(image, 0, 0, 0, jas_image_width(image), jas_image_height(image), matrix); jaserr = jas_image_readcmpt(image, 0, 0, 0, jas_image_width(image), jas_image_height(image), matrix);
if (jaserr) {
grib_context_log(c, GRIB_LOG_ERROR, "grib_jasper_decode: Failed to read JasPer component data. JasPer error %d", jaserr);
code = GRIB_DECODING_ERROR;
goto cleanup;
}
Assert(p->height_ * p->width_ == *no_values); Assert(p->height_ * p->width_ == *n_vals);
k = 0; k = 0;
for (i = 0; i < p->height_; i++) for (i = 0; i < p->height_; i++)
@ -77,6 +130,7 @@ cleanup:
jas_image_destroy(image); jas_image_destroy(image);
if (jpeg) if (jpeg)
jas_stream_close(jpeg); jas_stream_close(jpeg);
ecc_jasper_cleanup();
return code; return code;
} }
@ -84,7 +138,7 @@ cleanup:
int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper)
{ {
int code = GRIB_SUCCESS; int code = GRIB_SUCCESS;
int jaserr; int jaserr = 0;
char opts[MAXOPTSSIZE]; char opts[MAXOPTSSIZE];
double reference_value = helper->reference_value; double reference_value = helper->reference_value;
@ -156,7 +210,7 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper)
} }
} }
/*jas_init();*/ ecc_jasper_initialise();
opts[0] = 0; opts[0] = 0;
@ -166,7 +220,7 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper)
} }
Assert(cmpt.width_ * cmpt.height_ * cmpt.cps_ == buflen); Assert(cmpt.width_ * cmpt.height_ * cmpt.cps_ == buflen);
grib_context_log(c, GRIB_LOG_DEBUG, "grib_jasper_encode: Jasper version %s", jas_getversion()); grib_context_log(c, GRIB_LOG_DEBUG, "grib_jasper_encode: JasPer version %s", jas_getversion());
pcmpt = &cmpt; pcmpt = &cmpt;
image.cmpts_ = &pcmpt; image.cmpts_ = &pcmpt;
@ -175,12 +229,12 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper)
cmpt.stream_ = istream; cmpt.stream_ = istream;
jpcstream = jas_stream_memopen((char*)helper->jpeg_buffer, helper->buffer_size); jpcstream = jas_stream_memopen((char*)helper->jpeg_buffer, helper->buffer_size);
jaserr = jpc_encode(&image, jpcstream, opts);
if (jaserr != 0) { jaserr = ecc_jasper_encode(&image, jpcstream, opts);
/* increase the number of guard bits */ if (jaserr) {
/* Failed to encode. Increase the number of guard bits */
strcat(opts, "\nnumgbits=4"); strcat(opts, "\nnumgbits=4");
grib_context_log(c, GRIB_LOG_ERROR, "JASPER: error %d, increasing the number of guard bits", jaserr); grib_context_log(c, GRIB_LOG_ERROR, "grib_jasper_encode: JasPer error %d, increasing the number of guard bits", jaserr);
jas_stream_close(istream); jas_stream_close(istream);
istream = 0; istream = 0;
jas_stream_close(jpcstream); jas_stream_close(jpcstream);
@ -189,11 +243,11 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper)
istream = jas_stream_memopen((char*)encoded, buflen); istream = jas_stream_memopen((char*)encoded, buflen);
cmpt.stream_ = istream; cmpt.stream_ = istream;
jpcstream = jas_stream_memopen((char*)helper->jpeg_buffer, helper->buffer_size); jpcstream = jas_stream_memopen((char*)helper->jpeg_buffer, helper->buffer_size);
jaserr = jpc_encode(&image, jpcstream, opts); jaserr = ecc_jasper_encode(&image, jpcstream, opts);
} }
if (jaserr != 0) { if (jaserr) {
grib_context_log(c, GRIB_LOG_ERROR, "JASPER: error %d", jaserr); grib_context_log(c, GRIB_LOG_ERROR, "grib_jasper_encode: Failed to encode. JasPer error %d", jaserr);
code = GRIB_ENCODING_ERROR; code = GRIB_ENCODING_ERROR;
goto cleanup; goto cleanup;
} }
@ -210,23 +264,23 @@ cleanup:
jas_stream_close(istream); jas_stream_close(istream);
if (jpcstream) if (jpcstream)
jas_stream_close(jpcstream); jas_stream_close(jpcstream);
ecc_jasper_cleanup();
return code; return code;
} }
#else #else
int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, double* val, size_t* n_vals) int grib_jasper_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* val, const size_t* n_vals)
{ {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_accessor_data_jpeg2000_packing: Jasper JPEG support not enabled."); "grib_accessor_data_jpeg2000_packing: JasPer JPEG support not enabled.");
return GRIB_FUNCTIONALITY_NOT_ENABLED; return GRIB_FUNCTIONALITY_NOT_ENABLED;
} }
int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper)
{ {
grib_context_log(c, GRIB_LOG_ERROR, grib_context_log(c, GRIB_LOG_ERROR,
"grib_accessor_data_jpeg2000_packing: Jasper JPEG support not enabled."); "grib_accessor_data_jpeg2000_packing: JasPer JPEG support not enabled.");
return GRIB_FUNCTIONALITY_NOT_ENABLED; return GRIB_FUNCTIONALITY_NOT_ENABLED;
} }

View File

@ -82,6 +82,7 @@ void grib_oarray_delete(grib_context* c, grib_oarray* v)
grib_context_free(c, v); grib_context_free(c, v);
} }
#if 0
void grib_oarray_delete_content(grib_context* c, grib_oarray* v) void grib_oarray_delete_content(grib_context* c, grib_oarray* v)
{ {
int i; int i;
@ -90,12 +91,14 @@ void grib_oarray_delete_content(grib_context* c, grib_oarray* v)
if (!c) if (!c)
c = grib_context_get_default(); c = grib_context_get_default();
for (i = 0; i < v->n; i++) { for (i = 0; i < v->n; i++) {
if (v->v[i]) if (v->v[i]) {
grib_context_free(c, v->v[i]); grib_context_free(c, v->v[i]);
v->v[i] = 0; v->v[i] = 0;
}
} }
v->n = 0; v->n = 0;
} }
#endif
void** grib_oarray_get_array(grib_context* c, grib_oarray* v) void** grib_oarray_get_array(grib_context* c, grib_oarray* v)
{ {

View File

@ -382,8 +382,9 @@ void grib_trie_with_rank_delete_container(grib_trie_with_rank* t)
GRIB_MUTEX_UNLOCK(&mutex); GRIB_MUTEX_UNLOCK(&mutex);
} }
/* #if 0
static void grib_trie_with_rank_delete_list(grib_context* c,grib_trie_with_rank_list *list) { static void grib_trie_with_rank_delete_list(grib_context* c,grib_trie_with_rank_list *list)
{
grib_trie_with_rank_list* next=list; grib_trie_with_rank_list* next=list;
grib_trie_with_rank_list* p; grib_trie_with_rank_list* p;
while (next) { while (next) {
@ -393,7 +394,6 @@ static void grib_trie_with_rank_delete_list(grib_context* c,grib_trie_with_rank_
grib_context_free( c, p ); grib_context_free( c, p );
} }
} }
*/
void grib_trie_with_rank_delete(grib_trie_with_rank* t) void grib_trie_with_rank_delete(grib_trie_with_rank* t)
{ {
@ -434,7 +434,6 @@ void grib_trie_with_rank_clear(grib_trie_with_rank* t)
} }
} }
/*
static void grib_trie_with_rank_insert_in_list(grib_trie_with_rank* t,void* data) { static void grib_trie_with_rank_insert_in_list(grib_trie_with_rank* t,void* data) {
if (t->list==NULL) { if (t->list==NULL) {
t->list=grib_context_malloc_clear(t->context,sizeof(grib_trie_with_rank_list)); t->list=grib_context_malloc_clear(t->context,sizeof(grib_trie_with_rank_list));
@ -448,7 +447,7 @@ static void grib_trie_with_rank_insert_in_list(grib_trie_with_rank* t,void* data
t->last_list->rank++; t->last_list->rank++;
} }
} }
*/ #endif
int grib_trie_with_rank_insert(grib_trie_with_rank* t, const char* key, void* data) int grib_trie_with_rank_insert(grib_trie_with_rank* t, const char* key, void* data)
{ {

View File

@ -16,6 +16,7 @@ list(APPEND test_bins
read_any read_any
julian julian
grib_indexing grib_indexing
grib_fieldset
grib_multi_from_message grib_multi_from_message
grib_read_index grib_read_index
unit_tests unit_tests
@ -215,6 +216,7 @@ if( HAVE_BUILD_TOOLS )
grib_nearest_test grib_nearest_test
pseudo_budg pseudo_budg
grib_gridType grib_gridType
grib_fieldset
grib_octahedral grib_octahedral
grib_grid_mercator grib_grid_mercator
grib_global grib_global

View File

@ -57,5 +57,14 @@ for f in $files; do
rm -f $temp rm -f $temp
done done
# ECC-989: Valgrind error: setting 'unpack=1' before setting unexpandedDescriptors
# ---------------------------------------------------------------------------------
f="$ECCODES_SAMPLES_PATH/BUFR4.tmpl"
cat > $fRules <<EOF
set unpack=1;
set unexpandedDescriptors={4025};
EOF
${tools_dir}/codes_bufr_filter $fRules $f
rm -f $fRules $fLog $temp rm -f $fRules $fLog $temp

View File

@ -173,9 +173,16 @@ ${tools_dir}/bufr_set -s ident=' AB CD ' $f $fBufrTmp
result=`${tools_dir}/bufr_get -p ident $fBufrTmp` result=`${tools_dir}/bufr_get -p ident $fBufrTmp`
[ "$result" = "AB CD" ] [ "$result" = "AB CD" ]
# ${tools_dir}/bufr_compare $f $fBufrTmp # ${tools_dir}/bufr_compare $f $fBufrTmp
#-----------------------------------------------------------
# ECC-1359: string that can be converted to an integer
# ----------------------------------------------------------
${tools_dir}/bufr_set -s messageLength:s=333 $ECCODES_SAMPLES_PATH/BUFR4_local.tmpl $fBufrTmp
result=`${tools_dir}/bufr_get -p messageLength $fBufrTmp`
[ "$result" = "333" ]
# Clean up # Clean up
rm -f $fLog rm -f $fLog
rm -f $fBufrTmp rm -f $fBufrTmp

View File

@ -113,6 +113,24 @@ ${tools_dir}/grib_set -s setLocalDefinition=1,localDefinitionNumber=1 $temp $tem
${tools_dir}/grib_compare -b totalLength,numberOfSection $temp $temp1 ${tools_dir}/grib_compare -b totalLength,numberOfSection $temp $temp1
grib_check_key_equals $temp1 localUsePresent 1 grib_check_key_equals $temp1 localUsePresent 1
# Check local ECMWF chemicals/aerosols
# ------------------------------------
${tools_dir}/grib_set -s paramId=217232 $sample2 $temp
${tools_dir}/grib_dump -O -p constituentType $temp > $temp1
grep -q "Biomass burning volatile organic compounds .*grib2/tables/local/ecmf/1/4.230.table" $temp1
${tools_dir}/grib_set -s paramId=219231 $sample2 $temp
${tools_dir}/grib_dump -O -p constituentType $temp > $temp1
grep -q "Anthropogenic volatile organic compounds .*grib2/tables/local/ecmf/1/4.230.table" $temp1
${tools_dir}/grib_set -s paramId=211248 $sample2 $temp
${tools_dir}/grib_dump -O -p aerosolType $temp > $temp1
grep -q "Nitrate Coarse Mode .*grib2/tables/local/ecmf/1/4.233.table" $temp1
${tools_dir}/grib_set -s paramId=215189 $sample2 $temp
${tools_dir}/grib_dump -O -p aerosolType $temp > $temp1
grep -q "Nitrate Fine Mode .*grib2/tables/local/ecmf/1/4.233.table" $temp1
grib_check_key_equals $temp aerosolTypeName "Nitrate Fine Mode"
# Clean up # Clean up
rm -f $tempSample rm -f $tempSample $temp $temp1
rm -f $temp $temp1

View File

@ -21,16 +21,6 @@ outfile2=temp.$label.2
rm -f $outfile1 $outfile2 rm -f $outfile1 $outfile2
# Use the sample file with CCSDS packing
# ---------------------------------------
sample_ccsds=$ECCODES_SAMPLES_PATH/ccsds_grib2.tmpl
${tools_dir}/grib_filter -o $outfile1 - $sample_ccsds << EOF
set values = { 55.0161, 99.7008 };
write;
EOF
grib_check_key_equals $outfile1 packingType grid_ccsds
stats=`${tools_dir}/grib_get -M -F%.4f -p min,max $outfile1`
[ "$stats" = "55.0161 99.7008" ]
# ECC-1263 # ECC-1263
# --------- # ---------
@ -111,5 +101,12 @@ ${tools_dir}/grib_compare -b $BLACKLIST $infile $outfile1
${tools_dir}/grib_compare -c data:n $outfile1 $outfile2 ${tools_dir}/grib_compare -c data:n $outfile1 $outfile2
# ECC-1362
# ---------
infile=${data_dir}/ccsds_szip.grib2
res=`${tools_dir}/grib_get '-F%.3f' -p min,max,avg $infile`
[ "$res" = "-180.000 180.000 -0.044" ]
# Clean up # Clean up
rm -f $outfile1 $outfile2 rm -f $outfile1 $outfile2

View File

@ -14,6 +14,8 @@
label="grib_dump_samples_test" label="grib_dump_samples_test"
temp=${label}".temp" temp=${label}".temp"
sample_ccsds="$ECCODES_SAMPLES_PATH/ccsds_grib2.tmpl"
# Test selected sample GRIB files # Test selected sample GRIB files
samples=" samples="
GRIB1.tmpl GRIB1.tmpl
@ -25,9 +27,10 @@ samples="
regular_ll_sfc_grib1.tmpl regular_ll_sfc_grib1.tmpl
regular_ll_sfc_grib2.tmpl regular_ll_sfc_grib2.tmpl
" "
for file in $samples; do
sf="$ECCODES_SAMPLES_PATH/$file" for sfile in $samples; do
${tools_dir}/grib_dump -O $sf >/dev/null sample="$ECCODES_SAMPLES_PATH/$sfile"
${tools_dir}/grib_dump -O $sample >/dev/null
done done
# Test grib_dump with -t option # Test grib_dump with -t option
@ -37,5 +40,16 @@ grep -q "codetable (int) typeOfSecondFixedSurface" $temp
grep -q "ieeefloat (double) referenceValue" $temp grep -q "ieeefloat (double) referenceValue" $temp
grep -q "unsigned (int) numberOfSection" $temp grep -q "unsigned (int) numberOfSection" $temp
# Extra tests for CCSDS
if [ $HAVE_AEC -eq 1 ]; then
${tools_dir}/grib_dump -O $sample_ccsds >/dev/null
rm -f $temp
echo 'set values = { 55.0161, 66.666, 99.7008 };write;' |\
${tools_dir}/grib_filter -o $temp - $sample_ccsds
grib_check_key_equals $temp packingType,numberOfValues 'grid_ccsds 3'
stats=`${tools_dir}/grib_get -M -F%.4f -p min,max $temp`
[ "$stats" = "55.0161 99.7008" ]
${tools_dir}/grib_dump -O $temp
fi
rm -f $temp rm -f $temp

View File

@ -54,7 +54,6 @@ static int encode_file(char* input_file, char* output_file)
grib_handle* source_handle = NULL; grib_handle* source_handle = NULL;
const void* buffer = NULL; const void* buffer = NULL;
int err = 0; int err = 0;
size_t str_len = 0;
FILE* in = fopen(input_file, "rb"); FILE* in = fopen(input_file, "rb");
FILE* out = fopen(output_file, "wb"); FILE* out = fopen(output_file, "wb");
@ -89,7 +88,7 @@ static int encode_file(char* input_file, char* output_file)
GRIB_CHECK(grib_set_long(clone_handle, "bitsPerValue", 16), 0); GRIB_CHECK(grib_set_long(clone_handle, "bitsPerValue", 16), 0);
/*GRIB_CHECK(grib_set_string(clone_handle, "packingType", "grid_ccsds", &str_len), 0);*/ /*GRIB_CHECK(grib_set_string(clone_handle, "packingType", "grid_ccsds", &str_len), 0);*/
GRIB_CHECK(grib_set_string(clone_handle, "packingType", "grid_simple", &str_len), 0); /*GRIB_CHECK(grib_set_string(clone_handle, "packingType", "grid_simple", &str_len), 0);*/
GRIB_CHECK(grib_set_double_array(clone_handle, "values", values, values_len), 0); GRIB_CHECK(grib_set_double_array(clone_handle, "values", values, values_len), 0);
@ -118,7 +117,7 @@ void do_stuff(void* arg)
int i; int i;
for (i = 0; i < FILES_PER_ITERATION; i++) { for (i = 0; i < FILES_PER_ITERATION; i++) {
sprintf(output_file, "temp.grib_encode_pthreads.out_%d-%d.grib", (int)number, i); sprintf(output_file, "temp.grib_encode_pthreads_test.out_%d-%d.grib", (int)number, i);
encode_file(INPUT_FILE, output_file); encode_file(INPUT_FILE, output_file);
} }
} }

Some files were not shown because too many files have changed in this diff Show More