Merge branch 'release/2.9.0'

This commit is contained in:
Shahram Najm 2018-09-27 09:53:43 +01:00
commit 97565ff9ba
180 changed files with 1826 additions and 8164 deletions

1
.gitignore vendored
View File

@ -9,7 +9,6 @@ config.h.in
lex.yy.c
stamp-h1
src/config.h
src/eccodes_version.h
src/grib_api.h.new
src/grib_api_constants.h.new
src/eccodes_constants.h.new

View File

@ -1 +1 @@
set( ${PROJECT_NAME}_VERSION_STR "2.8.2" )
set( ${PROJECT_NAME}_VERSION_STR "2.9.0" )

View File

@ -145,3 +145,5 @@ eum_iasi_twt.bufr
delayed_repl_01.bufr
israel_observations_2017041010.bufr
goes16_nm.bufr
aeolus_wmo_26.bufr
ecc738.msg2.bufr

View File

@ -11172,7 +11172,6 @@ dist_definitionsgrib1_localConcepts_efkl_DATA = \
definitionsgrib1_localConcepts_eidbdir = @ECCODES_DEFINITION_PATH@/grib1/localConcepts/eidb
dist_definitionsgrib1_localConcepts_eidb_DATA = \
grib1/localConcepts/eidb/cfName.def\
grib1/localConcepts/eidb/name.def\
grib1/localConcepts/eidb/paramId.def\
grib1/localConcepts/eidb/shortName.def\
@ -11197,7 +11196,6 @@ definitionsgrib1_localConcepts_eswidir = @ECCODES_DEFINITION_PATH@/grib1/localCo
dist_definitionsgrib1_localConcepts_eswi_DATA = \
grib1/localConcepts/eswi/aerosolConcept.def\
grib1/localConcepts/eswi/aerosolbinnumber.table\
grib1/localConcepts/eswi/cfName.def\
grib1/localConcepts/eswi/landTypeConcept.def\
grib1/localConcepts/eswi/landtype.table\
grib1/localConcepts/eswi/name.def\

View File

@ -77,8 +77,8 @@ if(kindOfProduct == `TIDE`){
if(kindOfProduct == `BUFR`){
template BUFR "bufr/boot.def" ;
constant BUFRstr="BUFR";
alias identifier=BUFRstr;
#constant BUFRstr="BUFR"; #ECC-742
#alias identifier=BUFRstr;
}
if(kindOfProduct == `CDFX`){

View File

@ -93,5 +93,8 @@ transient userDateEnd = 0 : hidden;
transient userTimeEnd = 0 : hidden;
meta userDateTimeEnd julian_date(userDateEnd,userTimeEnd) : hidden;
# See ECC-741
transient skipExtraKeyAttributes=0 : hidden;
template boot_edition "bufr/boot_edition_[ed:l].def";

View File

@ -9,7 +9,24 @@
constant defaultSequence=0;
constant tablesMasterDir="bufr/tables/[masterTableNumber]/wmo/[masterTablesVersionNumber]" : hidden;
if (masterTablesVersionNumber==19) {
if (masterTablesVersionNumber == 19) {
# See SUP-2302: We need this exception for EUMETSAT local tables, because there are conflicting elements in their table version 1 when
# used in combination with different WMO tables versions. This is associated with the way BUFRDC manages the tables that
# are files with masterTablesVersionNumber and localTablesVersionNumber in the name.
# ecCodes doesn't associate a local version number with a particular master table version number.
# EUMETSAT use a combination of masterTablesVersionNumber and localTablesVersionNumber
# to version the tables. This is a problem because they reuse codes in the different versions.
# They can have version 19-1 ( masterTablesVersionNumber=19, localTablesVersionNumber=1) and also 25-1 and
# in the two tables they may reuse an element changing width, reference, scale and meaning.
# The correct way of doing this would be to have two different tables localTablesVersionNumber=1 and localTablesVersionNumber=2
# with a different use of their own descriptors. Local tables should be managed by the owner with different version numbers.
# They rely on the fact that the two versions of the tables are used in combination with different master tables.
# This is not always true.
# Hence this 'if' statement to solve the conflict of tables.
constant tablesLocalDir="bufr/tables/[masterTableNumber]/local/[masterTablesVersionNumber]-[localTablesVersionNumber]/[bufrHeaderCentre:l]/[bufrHeaderSubCentre]" : hidden;
} else {
constant tablesLocalDir="bufr/tables/[masterTableNumber]/local/[localTablesVersionNumber]/[bufrHeaderCentre:l]/[bufrHeaderSubCentre]" : hidden;

View File

@ -1 +0,0 @@
30

View File

@ -56,7 +56,7 @@
table2Version = 3 ;
}
#Mean sea level pressure
'air_pressure_at_sea_level' = {
'air_pressure_at_mean_sea_level' = {
indicatorOfParameter = 2 ;
table2Version = 3 ;
indicatorOfTypeOfLevel = 1 ;
@ -159,7 +159,7 @@
table2Version = 2 ;
}
#Mean sea level pressure
'air_pressure_at_sea_level' = {
'air_pressure_at_mean_sea_level' = {
indicatorOfParameter = 2 ;
table2Version = 2 ;
indicatorOfTypeOfLevel = 1 ;
@ -262,7 +262,7 @@
table2Version = 1 ;
}
#Mean sea level pressure
'air_pressure_at_sea_level' = {
'air_pressure_at_mean_sea_level' = {
indicatorOfParameter = 2 ;
table2Version = 1 ;
indicatorOfTypeOfLevel = 1 ;

View File

@ -90,7 +90,7 @@
table2Version = 128 ;
}
#Mean sea level pressure
'air_pressure_at_sea_level' = {
'air_pressure_at_mean_sea_level' = {
indicatorOfParameter = 151 ;
table2Version = 128 ;
}
@ -194,3 +194,73 @@
indicatorOfParameter = 238 ;
table2Version = 128 ;
}
#Sea-ice thickness
'sea_ice_thickness' = {
table2Version = 174 ;
indicatorOfParameter = 98 ;
}
#Sea ice area fraction
'sea_ice_area_fraction' = {
table2Version = 128 ;
indicatorOfParameter = 31 ;
}
#Sea ice snow thickness
'surface_snow_thickness' = {
table2Version = 174 ;
indicatorOfParameter = 97 ;
}
#Depth of 20C isotherm
'depth_of_isosurface_of_sea_water_potential_temperature' = {
table2Version = 151 ;
indicatorOfParameter = 163 ;
}
#Ocean barotropic stream function
'ocean_barotropic_streamfunction' = {
table2Version = 151 ;
indicatorOfParameter = 147 ;
}
#Surface downward northward stress
'surface_downward_northward_stress' = {
table2Version = 151 ;
indicatorOfParameter = 154 ;
}
#Surface downward eastward stress
'surface_downward_eastward_stress' = {
table2Version = 151 ;
indicatorOfParameter = 153 ;
}
#Sea surface height
'sea_surface_height_above_geoid' = {
table2Version = 151 ;
indicatorOfParameter = 145 ;
}
#Sea water practical salinity
'sea_water_practical_salinity' = {
table2Version = 151 ;
indicatorOfParameter = 130 ;
}
#Sea water potential temperature
'sea_water_potential_temperature' = {
table2Version = 151 ;
indicatorOfParameter = 129 ;
}
#Sea water sigma theta
'sea_water_sigma_theta' = {
table2Version = 151 ;
indicatorOfParameter = 138 ;
}
#Northward sea water velocity
'northward_sea_water_velocity' = {
table2Version = 151 ;
indicatorOfParameter = 132 ;
}
#Eastward sea water velocity
'eastward_sea_water_velocity' = {
table2Version = 151 ;
indicatorOfParameter = 131 ;
}
#Upward sea water velocity
'upward_sea_water_velocity' = {
table2Version = 151 ;
indicatorOfParameter = 133 ;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -71,7 +71,7 @@
typeOfStatisticalProcessing = 1 ;
}
#Mean sea level pressure
'air_pressure_at_sea_level' = {
'air_pressure_at_mean_sea_level' = {
discipline = 0 ;
parameterNumber = 0 ;
typeOfFirstFixedSurface = 101 ;
@ -160,3 +160,9 @@
parameterCategory = 2 ;
parameterNumber = 37 ;
}
#Sea ice area fraction
'sea_ice_area_fraction' = {
discipline = 10 ;
parameterCategory = 2 ;
parameterNumber = 0 ;
}

View File

@ -1,13 +1,4 @@
# Copyright 2005-2018 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.
#
# Definition 11, Supplementary data used by the analysis
# Local definition 11: Supplementary data used by the analysis
unsigned[2] yearOfAnalysis = year : dump;
unsigned[1] monthOfAnalysis = month : dump;

View File

@ -1,6 +1,4 @@
# Copyright 2005-2018 ECMWF.
# Definition 14, Brightness temperature
# Local definition 14: Brightness temperature
unsigned[4] channelNumber : dump ;
alias mars.channel = channelNumber;

View File

@ -1,18 +1,9 @@
# Copyright 2005-2018 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.
#
# Local definition 15: Seasonal forecast data
unsigned[2] systemNumber : dump ;
unsigned[2] methodNumber : dump ;
unsigned[2] systemNumber : dump;
unsigned[2] methodNumber : dump;
alias system=systemNumber;
alias method=methodNumber;
alias local.systemNumber=systemNumber;
alias local.methodNumber=methodNumber;

View File

@ -1,7 +1,7 @@
# Copyright 2005-2018 ECMWF.
# Local definition 16: Seasonal forecast monthly mean data
unsigned[2] systemNumber : dump ;
unsigned[2] methodNumber : dump ;
unsigned[2] systemNumber : dump;
unsigned[2] methodNumber : dump;
alias local.systemNumber=systemNumber;
alias local.methodNumber=methodNumber;

View File

@ -1,11 +1,4 @@
# Copyright 2005-2018 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.
#
# Local definition 18: Multianalysis ensemble data
codetable[1] dataOrigin "common/c-1.table" : dump;
alias mars.origin=dataOrigin;
@ -22,5 +15,3 @@ consensus list(consensusCount)
alias local.dataOrigin=dataOrigin;
alias local.modelIdentifier=modelIdentifier;
alias local.consensusCount=consensusCount;

View File

@ -1,13 +1,4 @@
# Copyright 2005-2018 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.
#
# GRIB2 Local Definition 192: Multiple ECMWF local definitions
# Local definition 192: Multiple ECMWF local definitions
unsigned[1] numberOfLocalDefinitions = 2 : dump;

View File

@ -1,11 +1,4 @@
# Copyright 2005-2018 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.
#
# Local definition 20: 4D variational increments
unsigned[1] iterationNumber : dump;
alias number=iterationNumber;
@ -17,4 +10,3 @@ alias iteration = iterationNumber;
alias local.iterationNumber =iterationNumber;
alias local.totalNumberOfIterations=totalNumberOfIterations;

View File

@ -1,13 +1,4 @@
# Copyright 2005-2018 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.
#
# Definition 21 - Sensitive area predictions
# Local definition 21: Sensitive area predictions
unsigned[2] forecastOrSingularVectorNumber : dump;
@ -39,4 +30,3 @@ unsigned[1] shapeOfVerificationArea : dump;
# concept sensitiveAreaDomain(unknown,"sensitive_area_domain.def",conceptsMasterDir,conceptsLocalDir);
alias mars.domain = marsDomain;

View File

@ -1,4 +1,4 @@
# Copyright 2005-2018 ECMWF.
# Local definition 24: Satellite Channel Data
unsigned[2] channelNumber : dump, can_be_missing;
alias mars.channel = channelNumber;

View File

@ -1,11 +1,4 @@
# Copyright 2005-2018 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.
#
# Local definition 25: 4DVar model errors
unsigned[1] componentIndex : dump;
alias mars.number=componentIndex;
@ -16,4 +9,3 @@ unsigned[1] modelErrorType : dump;
alias local.componentIndex=componentIndex;
alias local.numberOfComponents=numberOfComponents;
alias local.modelErrorType=modelErrorType;

View File

@ -1,18 +1,9 @@
# Copyright 2005-2018 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.
#
unsigned[4] referenceDate : dump ;
unsigned[4] climateDateFrom : dump;
unsigned[4] climateDateTo : dump ;
alias local.referenceDate= referenceDate ;
alias local.climateDateFrom= climateDateFrom ;
alias local.climateDateTo= climateDateTo ;
# Local definition 26: MARS labelling or ensemble forecast data (with hindcast support)
unsigned[4] referenceDate : dump;
unsigned[4] climateDateFrom : dump;
unsigned[4] climateDateTo : dump;
alias local.referenceDate= referenceDate;
alias local.climateDateFrom= climateDateFrom;
alias local.climateDateTo= climateDateTo;

View File

@ -1,16 +1,7 @@
# Copyright 2005-2018 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.
#
# Definition 28 - COSMO local area EPS
# Local Definition 28 - COSMO local area EPS
unsigned[4] baseDateEPS : dump;
unsigned[2] baseTimeEPS : dump;
unsigned[1] numberOfRepresentativeMember : dump;
unsigned[1] numberOfMembersInCluster : dump;
unsigned[1] totalInitialConditions : dump;

View File

@ -1,28 +1,20 @@
# Copyright 2005-2018 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.
#
# Local definition 30: Forecasting Systems with Variable Resolution
unsigned[1] oceanAtmosphereCoupling : dump;
unsigned[4] legBaseDate : dump ;
unsigned[2] legBaseTime : dump ;
unsigned[1] legNumber : dump ;
unsigned[4] referenceDate : dump ;
unsigned[4] climateDateFrom : dump ;
unsigned[4] climateDateTo : dump;
unsigned[4] legBaseDate : dump;
unsigned[2] legBaseTime : dump;
unsigned[1] legNumber : dump;
unsigned[4] referenceDate : dump;
unsigned[4] climateDateFrom : dump;
unsigned[4] climateDateTo : dump;
alias local.oceanAtmosphereCoupling=oceanAtmosphereCoupling;
alias local.legBaseDate=legBaseDate ;
alias local.legBaseTime=legBaseTime ;
alias local.legNumber=legNumber ;
alias local.referenceDate=referenceDate ;
alias local.climateDateFrom=climateDateFrom ;
alias local.legBaseDate=legBaseDate;
alias local.legBaseTime=legBaseTime;
alias local.legNumber=legNumber;
alias local.referenceDate=referenceDate;
alias local.climateDateFrom=climateDateFrom;
alias local.climateDateTo=climateDateTo;
alias mars._leg_number = legNumber;

View File

@ -1,13 +1,4 @@
# Copyright 2005-2018 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.
#
# Definition 300 - Multi-dimensional parameters
# Local definition 300: Multi-dimensional parameters
codetable[1] dimensionType "grib2/dimensionType.table"=0;
@ -19,4 +10,3 @@ alias dimension=dimensionNumber;
unsigned[2] totalNumberOfdimensions;
alias extraDimensionPresent=one;

View File

@ -1,17 +1,7 @@
# Copyright 2005-2018 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.
#
# Definition 36 - MARS labelling for long window 4Dvar system (inspired by local def 1)
# Local definition 36: MARS labelling for long window 4Dvar system (inspired by local def 1)
# Hours
unsigned[2] offsetToEndOf4DvarWindow : dump;
unsigned[2] lengthOf4DvarWindow : dump;
alias anoffset=offsetToEndOf4DvarWindow;

View File

@ -1,13 +1,4 @@
# Copyright 2005-2018 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.
#
# Definition 38 - 4D variational increments for long window 4Dvar system (inspired by local def 20)
# Local definition 38: 4D variational increments for long window 4Dvar system (inspired by local def 20)
unsigned[1] iterationNumber : dump;
alias number=iterationNumber;
@ -25,4 +16,3 @@ unsigned[2] offsetToEndOf4DvarWindow : dump;
unsigned[2] lengthOf4DvarWindow : dump;
alias anoffset=offsetToEndOf4DvarWindow;

View File

@ -1,13 +1,4 @@
# Copyright 2005-2018 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.
#
# Definition 39 - 4DVar model errors for long window 4Dvar system (inspired by local def 25)
# Local definition 39: 4DVar model errors for long window 4Dvar system (inspired by local def 25)
unsigned[1] componentIndex : dump;
alias mars.number=componentIndex;
@ -23,4 +14,3 @@ alias local.modelErrorType=modelErrorType;
unsigned[2] offsetToEndOf4DvarWindow : dump;
unsigned[2] lengthOf4DvarWindow : dump;
alias anoffset=offsetToEndOf4DvarWindow;

View File

@ -145,3 +145,75 @@
parameterCategory = 128 ;
parameterNumber = 238 ;
}
#Sea-ice thickness
'sea_ice_thickness' = {
discipline = 192 ;
parameterCategory = 174 ;
parameterNumber = 98 ;
}
#Depth of 20C isotherm
'depth_of_isosurface_of_sea_water_potential_temperature' = {
discipline = 192 ;
parameterCategory = 151 ;
parameterNumber = 163 ;
}
#Ocean barotropic stream function
'ocean_barotropic_streamfunction' = {
discipline = 192 ;
parameterCategory = 151 ;
parameterNumber = 147 ;
}
#Surface downward northward stress
'surface_downward_northward_stress' = {
discipline = 192 ;
parameterCategory = 151 ;
parameterNumber = 154 ;
}
#Surface downward eastward stress
'surface_downward_eastward_stress' = {
discipline = 192 ;
parameterCategory = 151 ;
parameterNumber = 153 ;
}
#Sea surface height
'sea_surface_height_above_geoid' = {
discipline = 192 ;
parameterCategory = 151 ;
parameterNumber = 145 ;
}
#Sea water practical salinity
'sea_water_practical_salinity' = {
discipline = 192 ;
parameterCategory = 151 ;
parameterNumber = 130 ;
}
#Sea water potential temperature
'sea_water_potential_temperature' = {
discipline = 192 ;
parameterCategory = 151 ;
parameterNumber = 129 ;
}
#Sea water sigma theta
'sea_water_sigma_theta' = {
discipline = 192 ;
parameterCategory = 151 ;
parameterNumber = 138 ;
}
#Northward sea water velocity
'northward_sea_water_velocity' = {
discipline = 192 ;
parameterCategory = 151 ;
parameterNumber = 132 ;
}
#Eastward sea water velocity
'eastward_sea_water_velocity' = {
discipline = 192 ;
parameterCategory = 151 ;
parameterNumber = 131 ;
}
#Upward sea water velocity
'upward_sea_water_velocity' = {
discipline = 192 ;
parameterCategory = 151 ;
parameterNumber = 133 ;
}

View File

@ -49,7 +49,7 @@
parameterCategory = 2 ;
}
#Boundary layer dissipation
'dissipation_in_atmosphere_boundary_layer' = {
'kinetic_energy_dissipation_in_atmosphere_boundary_layer' = {
discipline = 0 ;
parameterNumber = 20 ;
parameterCategory = 2 ;
@ -71,7 +71,7 @@
typeOfStatisticalProcessing = 1 ;
}
#Mean sea level pressure
'air_pressure_at_sea_level' = {
'air_pressure_at_mean_sea_level' = {
discipline = 0 ;
parameterNumber = 0 ;
typeOfFirstFixedSurface = 101 ;

View File

@ -26,7 +26,7 @@
unitsFactor = 1000 ;
}
#Boundary layer dissipation
'dissipation_in_atmosphere_boundary_layer' = {
'kinetic_energy_dissipation_in_atmosphere_boundary_layer' = {
discipline = 0 ;
parameterNumber = 20 ;
parameterCategory = 2 ;
@ -50,7 +50,7 @@
parameterCategory = 0 ;
}
#Total column water vapour
'lwe_thickness_of_atmosphere_water_vapor_content' = {
'lwe_thickness_of_atmosphere_mass_content_of_water_vapor' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 137 ;
@ -74,7 +74,7 @@
parameterNumber = 11 ;
}
#Large-scale precipitation
'lwe_thickness_of_large_scale_precipitation_amount' = {
'lwe_thickness_of_stratiform_precipitation_amount' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 142 ;
@ -140,7 +140,7 @@
parameterNumber = 211 ;
}
#Temperature of snow layer
'snow_temperature' = {
'temperature_in_surface_snow' = {
discipline = 192 ;
parameterCategory = 128 ;
parameterNumber = 238 ;

View File

@ -29,7 +29,7 @@
28 efic Extreme forecast index control
29 pb Probability boundaries
30 ep Event probability
31 bf Bias-corrected Forecast
31 bf Bias-corrected forecast
32 cd Climate distribution
33 4i 4D analysis increments
34 go Gridded observations

View File

@ -1,4 +1,6 @@
#!/usr/local/bin/perl56 -I/usr/local/lib/metaps/perl
#! /usr/local/apps/perl/current/bin/perl
# old #!/usr/local/bin/perl56 -I/usr/local/lib/metaps/perl
use strict; use warnings;
@ -19,19 +21,19 @@ use DBI;
my $db="param";
my $host="grib-param-db-prod.ecmwf.int";
my $user="ecmwf_ro";
my $pass="ecmwf_ro";
my $user="ecmwf_ro"; # Read-only access to Param DB
my $pass="ecmwf_ro"; # Read-only access to Param DB
my $dbh = DBI->connect("dbi:mysql(RaiseError=>1):database=$db;host=$host","$user","$pass") or die $DBI::errstr;
my $mars_dir = "mars";
foreach my $att qw(class type stream) {
foreach my $att ('class', 'type', 'stream') {
my $sth = $dbh->prepare("select grib_code,mars_abbreviation,long_name from grib_$att order by grib_code");
$sth->execute();
my $mars_file = "${mars_dir}/${att}.table";
open OUT,">${mars_file}" or die $!;
open OUT,">${mars_file}" or die "Failed to write \"$mars_file\": $!";
print OUT "0 0 Unknown\n";
while (my @row = $sth->fetchrow_array) {

View File

@ -74,6 +74,7 @@ int main(int argc, char** argv) {
fint = fopen(fintname,"r");
if(!fint) {
printf("ERROR: unable to open file %s\n",fintname);
fclose(fdir);
return 1;
}
@ -162,7 +163,7 @@ int main(int argc, char** argv) {
if (!values_dir) values_dir=grib_context_malloc(c,sizeof(double)*values_count);
if (!values_dir) {
printf("ERROR %s: memory allocation problem\n");
printf("ERROR: memory allocation problem\n");
exit(1);
}
size=values_count;
@ -174,12 +175,12 @@ int main(int argc, char** argv) {
if (!values_int) values_int=grib_context_malloc(c,sizeof(double)*values_count);
if (!values_int) {
printf("ERROR %s: memory allocation problem\n");
printf("ERROR: memory allocation problem\n");
exit(1);
}
GRIB_CHECK(grib_get_double_array(hint,"values",values_int,&size),0);
if (values_count != size) {
printf("ERROR %s: wrong values count %d %d\n",argv[0],values_count,size);
printf("ERROR %s: wrong values count %d %d\n",argv[0],values_count,size);
exit(1);
}
@ -188,7 +189,7 @@ int main(int argc, char** argv) {
for (j=0;j<sea_state_count;j++) {
if (!values[k]) values[k]=grib_context_malloc(c,sizeof(double)*values_count);
if (!values[k]) {
printf("ERROR %s: memory allocation problem\n");
printf("ERROR: memory allocation problem\n");
exit(1);
}
for (n=0;n<values_count;n++) values[k]=0;

View File

@ -22,35 +22,20 @@ rm -f ${TEMP_BUFR} ${TEMP_TEXT} ${REF} ${MYLOG}
cat > ${REF} <<EOF
== 1 == DIFFERENCE == Different size for "unexpandedDescriptors" [43] [28]
== 1 == DIFFERENCE == [#2#icaoLocationIndicator] not found in 2nd field
== 1 == DIFFERENCE == [#2#icaoLocationIndicator->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#stationType] not found in 2nd field
== 1 == DIFFERENCE == [#2#stationType->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#year] not found in 2nd field
== 1 == DIFFERENCE == [#2#year->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#month] not found in 2nd field
== 1 == DIFFERENCE == [#2#month->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#day] not found in 2nd field
== 1 == DIFFERENCE == [#2#day->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#hour] not found in 2nd field
== 1 == DIFFERENCE == [#2#hour->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#minute] not found in 2nd field
== 1 == DIFFERENCE == [#2#minute->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#latitude] not found in 2nd field
== 1 == DIFFERENCE == [#2#latitude->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#longitude] not found in 2nd field
== 1 == DIFFERENCE == [#2#longitude->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#heightOfStation] not found in 2nd field
== 1 == DIFFERENCE == [#2#heightOfStation->units] not found in 2nd field
== 1 == DIFFERENCE == [#4#heightAboveStation] not found in 2nd field
== 1 == DIFFERENCE == [#4#heightAboveStation->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#windDirection] not found in 2nd field
== 1 == DIFFERENCE == [#2#windDirection->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#extremeCounterclockwiseWindDirectionOfAVariableWind] not found in 2nd field
== 1 == DIFFERENCE == [#2#extremeCounterclockwiseWindDirectionOfAVariableWind->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#extremeClockwiseWindDirectionOfAVariableWind] not found in 2nd field
== 1 == DIFFERENCE == [#2#extremeClockwiseWindDirectionOfAVariableWind->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#windSpeed] not found in 2nd field
== 1 == DIFFERENCE == [#2#windSpeed->units] not found in 2nd field
EOF
INPUT=${data_dir}/bufr/metar_with_2_bias.bufr

View File

@ -71,12 +71,6 @@ int main(int argc,char* argv[])
printf("Number of values: %ld\n",numObs);
/* Allocate memory for the values to be read. Each
* parameter must have the same number of values. */
lat = (double*)malloc(numObs*sizeof(double));
lon = (double*)malloc(numObs*sizeof(double));
bscatter = (double*)malloc(numObs*sizeof(double));
/* Get latitude */
sprintf(key_name,"latitude");
@ -87,6 +81,10 @@ int main(int argc,char* argv[])
return 1;
}
/* Allocate memory for the values to be read. Each
* parameter must have the same number of values. */
lat = (double*)malloc(numObs*sizeof(double));
/* Get the values (from all the subsets) */
CODES_CHECK(codes_get_double_array(h,key_name,lat,&len),0);
@ -101,6 +99,7 @@ int main(int argc,char* argv[])
}
/* Get the values (from all the subsets) */
lon = (double*)malloc(numObs*sizeof(double));
CODES_CHECK(codes_get_double_array(h,key_name,lon,&len),0);
/* Get backScatter for beam two. We use an access by condition for this key. */
@ -114,15 +113,14 @@ int main(int argc,char* argv[])
}
/* Get the values (from all the subsets) */
bscatter = (double*)malloc(numObs*sizeof(double));
CODES_CHECK(codes_get_double_array(h,key_name,bscatter,&len),0);
/* Print the values */
printf("pixel lat lon backscatter \n");
printf("-------------------------------\n");
for(i=0; i < numObs; i++) {
printf("%4d %.3f %.3f %.3f \n",
i+1,lat[i],lon[i],bscatter[i]);
printf("%4d %.3f %.3f %.3f \n", i+1,lat[i],lon[i],bscatter[i]);
}
/* Delete handle */

View File

@ -71,8 +71,7 @@ int main(int argc, char** argv)
printf("max=%.10e min=%.10e average=%.10e\n",max,min,average);
{
/* Example of accessing specific elements from data values */
i=0;
/* Example of accessing specific elements from data values */
double vals_arr[3] = {0, 0, 0};
const int NUM = 3;
int index_arr[3];

View File

@ -1,11 +1,6 @@
# examples/C include file for CMake
set -ea
# If this environment variable is set, then become verbose
# so one can see why and how a test failed
if test "x$ECCODES_TEST_VERBOSE_OUTPUT" != "x"; then
set -x
fi
set -eax
proj_dir=@PROJECT_SOURCE_DIR@
data_dir=@PROJECT_BINARY_DIR@/data

View File

@ -16,12 +16,7 @@ else
# This is for autotools
echo
echo "TEST: $0"
# If this environment variable is set, then become verbose
# so one can see why and how a test failed
if test "x$ECCODES_TEST_VERBOSE_OUTPUT" != "x"; then
set -x
fi
set -x
if [ -z "${data_dir}" ]
then

View File

@ -22,35 +22,20 @@ rm -f ${TEMP} ${REF} ${MYLOG}
cat > ${REF} <<EOF
== 1 == DIFFERENCE == Different size for "unexpandedDescriptors" [43] [28]
== 1 == DIFFERENCE == [#2#icaoLocationIndicator] not found in 2nd field
== 1 == DIFFERENCE == [#2#icaoLocationIndicator->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#stationType] not found in 2nd field
== 1 == DIFFERENCE == [#2#stationType->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#year] not found in 2nd field
== 1 == DIFFERENCE == [#2#year->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#month] not found in 2nd field
== 1 == DIFFERENCE == [#2#month->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#day] not found in 2nd field
== 1 == DIFFERENCE == [#2#day->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#hour] not found in 2nd field
== 1 == DIFFERENCE == [#2#hour->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#minute] not found in 2nd field
== 1 == DIFFERENCE == [#2#minute->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#latitude] not found in 2nd field
== 1 == DIFFERENCE == [#2#latitude->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#longitude] not found in 2nd field
== 1 == DIFFERENCE == [#2#longitude->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#heightOfStation] not found in 2nd field
== 1 == DIFFERENCE == [#2#heightOfStation->units] not found in 2nd field
== 1 == DIFFERENCE == [#4#heightAboveStation] not found in 2nd field
== 1 == DIFFERENCE == [#4#heightAboveStation->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#windDirection] not found in 2nd field
== 1 == DIFFERENCE == [#2#windDirection->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#extremeCounterclockwiseWindDirectionOfAVariableWind] not found in 2nd field
== 1 == DIFFERENCE == [#2#extremeCounterclockwiseWindDirectionOfAVariableWind->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#extremeClockwiseWindDirectionOfAVariableWind] not found in 2nd field
== 1 == DIFFERENCE == [#2#extremeClockwiseWindDirectionOfAVariableWind->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#windSpeed] not found in 2nd field
== 1 == DIFFERENCE == [#2#windSpeed->units] not found in 2nd field
EOF
INPUT=metar_with_2_bias.bufr

View File

@ -1,11 +1,6 @@
# examples/F90 include file for CMake
set -ea
# If this environment variable is set, then become verbose
# so one can see why and how a test failed
if test "x$ECCODES_TEST_VERBOSE_OUTPUT" != "x"; then
set -x
fi
set -eax
proj_dir=@PROJECT_SOURCE_DIR@
data_dir=@PROJECT_BINARY_DIR@/data

View File

@ -12,17 +12,11 @@ if [ -f "$CMAKE_INCLUDE_FILE" ]; then
. ./$CMAKE_INCLUDE_FILE
else
set -ea
set -eax
echo
echo "TEST: $0"
# If this environment variable is set, then become verbose
# so one can see why and how a test failed
if test "x$ECCODES_TEST_VERBOSE_OUTPUT" != "x"; then
set -x
fi
if [ -z "${data_dir}" ]
then
cd ../../

View File

@ -22,35 +22,20 @@ rm -f ${TEMP} ${REF} ${MYLOG}
cat > ${REF} <<EOF
== 1 == DIFFERENCE == Different size for "unexpandedDescriptors" [43] [28]
== 1 == DIFFERENCE == [#2#icaoLocationIndicator] not found in 2nd field
== 1 == DIFFERENCE == [#2#icaoLocationIndicator->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#stationType] not found in 2nd field
== 1 == DIFFERENCE == [#2#stationType->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#year] not found in 2nd field
== 1 == DIFFERENCE == [#2#year->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#month] not found in 2nd field
== 1 == DIFFERENCE == [#2#month->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#day] not found in 2nd field
== 1 == DIFFERENCE == [#2#day->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#hour] not found in 2nd field
== 1 == DIFFERENCE == [#2#hour->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#minute] not found in 2nd field
== 1 == DIFFERENCE == [#2#minute->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#latitude] not found in 2nd field
== 1 == DIFFERENCE == [#2#latitude->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#longitude] not found in 2nd field
== 1 == DIFFERENCE == [#2#longitude->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#heightOfStation] not found in 2nd field
== 1 == DIFFERENCE == [#2#heightOfStation->units] not found in 2nd field
== 1 == DIFFERENCE == [#4#heightAboveStation] not found in 2nd field
== 1 == DIFFERENCE == [#4#heightAboveStation->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#windDirection] not found in 2nd field
== 1 == DIFFERENCE == [#2#windDirection->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#extremeCounterclockwiseWindDirectionOfAVariableWind] not found in 2nd field
== 1 == DIFFERENCE == [#2#extremeCounterclockwiseWindDirectionOfAVariableWind->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#extremeClockwiseWindDirectionOfAVariableWind] not found in 2nd field
== 1 == DIFFERENCE == [#2#extremeClockwiseWindDirectionOfAVariableWind->units] not found in 2nd field
== 1 == DIFFERENCE == [#2#windSpeed] not found in 2nd field
== 1 == DIFFERENCE == [#2#windSpeed->units] not found in 2nd field
EOF
INPUT=metar_with_2_bias.bufr

View File

@ -1,11 +1,6 @@
# examples/python include file for CMake
set -ea
# If this environment variable is set, then become verbose
# so one can see why and how a test failed
if test "x$ECCODES_TEST_VERBOSE_OUTPUT" != "x"; then
set -x
fi
set -eax
data_dir=@PROJECT_BINARY_DIR@/data

View File

@ -4,16 +4,10 @@ if [ -f "$CMAKE_INCLUDE_FILE" ]; then
. ./$CMAKE_INCLUDE_FILE
else
set -ea
set -eax
echo
echo "TEST: $0"
# If this environment variable is set, then become verbose
# so one can see why and how a test failed
if test "x$ECCODES_TEST_VERBOSE_OUTPUT" != "x"; then
set -x
fi
cpath=$TOPBUILDDIR
ECCODES_DEFINITION_PATH=$cpath/definitions
export ECCODES_DEFINITION_PATH

View File

@ -23,8 +23,17 @@ from eccodes import *
INPUT = '../../data/metar/metar.txt'
VERBOSE = 1 # verbose error reporting
def print_keys(msg_id):
keys = ['CCCC', 'latitude', 'longitude', 'dateTime',
'elevation', 'temperature', 'dewPointTemperature', 'qnh']
for key in keys:
try:
print(' %s: %s' % (key, codes_get(msg_id, key)))
except CodesInternalError as err:
print('Error with key="%s" : %s' % (key, err.msg))
def example():
def example1():
# open METAR file
f = open(INPUT)
@ -33,36 +42,38 @@ def example():
# loop for the messages in the file
while 1:
# get handle for message
gid = codes_metar_new_from_file(f)
if gid is None:
msg_id = codes_metar_new_from_file(f)
if msg_id is None:
break
print("message: %s" % cnt)
# ---------------------------------------------
# get values for keys holding a single value
# ---------------------------------------------
keys = ['CCCC', 'latitude', 'longitude', 'dateTime',
'elevation', 'temperature', 'dewPointTemperature', 'qnh']
for key in keys:
try:
print(' %s: %s' % (key, codes_get(gid, key)))
except CodesInternalError as err:
print('Error with key="%s" : %s' % (key, err.msg))
print_keys(msg_id)
cnt += 1
# delete handle
codes_release(gid)
codes_release(msg_id)
# close the file
f.close()
def example2():
# This time read from a string rather than a file.
metar_str = 'METAR LQMO 022350Z 09003KT 6000 FEW010 SCT035 BKN060 08/08 Q1003='
# get handle for message
msg_id = codes_new_from_message(metar_str)
print("\nFrom string: '%s'" % metar_str)
print_keys(msg_id)
codes_release(msg_id)
def main():
try:
example()
example1()
example2()
except CodesInternalError as err:
if VERBOSE:
traceback.print_exc(file=sys.stderr)

View File

@ -375,7 +375,7 @@ end subroutine codes_index_release
!>
!> @param ifile id of the opened file to be used in all the file functions.
!> @param filename name of the file to be open
!> @param mode open mode can be 'r' (read) or 'w' (write)
!> @param mode open mode can be 'r' (read), 'w' (write) or 'a' (append)
!> @param status CODES_SUCCESS if OK, integer value on error
subroutine codes_open_file ( ifile, filename, mode, status )
integer(kind=kindOfInt),intent(out) :: ifile

View File

@ -492,7 +492,7 @@
!>
!> @param ifile id of the opened file to be used in all the file functions.
!> @param filename name of the file to be open
!> @param mode open mode can be 'r' (read only) or 'w' (write only)
!> @param mode open mode can be 'r' (read only), 'w' (write only) or 'a' (append)
!> @param status GRIB_SUCCESS if OK, integer value on error
subroutine grib_open_file ( ifile, filename, mode, status )
integer(kind=kindOfInt),intent(out) :: ifile

View File

@ -4056,7 +4056,7 @@ Public Member Functions</h2></td></tr>
<table class="params">
<tr><td class="paramname">ifile</td><td>id of the opened file to be used in all the file functions. </td></tr>
<tr><td class="paramname">filename</td><td>name of the file to be open </td></tr>
<tr><td class="paramname">mode</td><td>open mode can be 'r' (read only) or 'w' (write only) </td></tr>
<tr><td class="paramname">mode</td><td>open mode can be 'r' (read only), 'w' (write only) or 'a' (append) </td></tr>
<tr><td class="paramname">status</td><td>CODES_SUCCESS if OK, integer value on error </td></tr>
</table>
</dd>

View File

@ -34,7 +34,7 @@ for directory in dirs:
dname = os.path.basename(directory)
NAMES.append(dname)
for dirpath, dirnames, files in os.walk(directory):
for dirpath, dirnames, files in os.walk(directory, followlinks=True):
if EXCLUDED in dirnames:
print('Note: %s/%s will not be included.' % (dirpath,EXCLUDED))

View File

@ -11,6 +11,11 @@ try:
except AttributeError:
numpy_include = numpy.get_numpy_include()
# See ECC-644
extra_compile_args = []
cmake_c_compiler_id='@CMAKE_C_COMPILER_ID@'
if cmake_c_compiler_id == 'PGI':
extra_compile_args.append('-noswitcherror')
attdict = dict(sources=['@CMAKE_CURRENT_SOURCE_DIR@/swig_wrap_numpy.c',
'@CMAKE_CURRENT_SOURCE_DIR@/grib_interface.c'],
@ -21,6 +26,7 @@ attdict = dict(sources=['@CMAKE_CURRENT_SOURCE_DIR@/swig_wrap_numpy.c',
library_dirs=['@CMAKE_BINARY_DIR@/lib'],
runtime_library_dirs=[],
libraries=['eccodes'],
extra_compile_args=extra_compile_args,
extra_objects=[])
shared_libs='@BUILD_SHARED_LIBS@'

View File

@ -21,14 +21,14 @@ bufr_keys_iterator* codes_bufr_keys_iterator_new(grib_handle* h, unsigned long f
"Invalid keys iterator for message: please use codes_keys_iterator_new");
return NULL;
}
ki= (bufr_keys_iterator*)grib_context_malloc_clear(h->context,sizeof(bufr_keys_iterator));
if (!ki) return NULL;
ki->filter_flags = filter_flags;
ki->handle = h;
DebugAssert(h->product_kind == PRODUCT_BUFR);
ki->names = NULL;
ki->key_name = NULL;
ki->i_curr_attribute=0;
ki->accessor_flags_only= GRIB_ACCESSOR_FLAG_DUMP;
ki->accessor_flags_skip= GRIB_ACCESSOR_FLAG_HIDDEN; /*ECC-568*/
@ -132,7 +132,10 @@ static int next_attribute(bufr_keys_iterator* kiter)
return 0;
}
prefix=(char*)grib_context_malloc_clear(kiter->current->context,strlen(kiter->prefix)+strlen(kiter->attributes[i_curr_attribute]->name)+3);
sprintf(prefix,"%s->%s",kiter->prefix,kiter->attributes[i_curr_attribute]->name);
/*sprintf(prefix,"%s->%s",kiter->prefix,kiter->attributes[i_curr_attribute]->name);*/
strcpy(prefix, kiter->prefix); /* strcpy and strcat here are much faster than sprintf */
strcat(prefix, "->");
strcat(prefix, kiter->attributes[i_curr_attribute]->name);
grib_context_free(kiter->current->context,kiter->prefix);
kiter->prefix=prefix;
kiter->attributes=kiter->attributes[i_curr_attribute]->attributes;
@ -143,6 +146,10 @@ static int next_attribute(bufr_keys_iterator* kiter)
int codes_bufr_keys_iterator_next(bufr_keys_iterator* kiter)
{
/* ECC-734: de-allocate last key name stored */
grib_context_free(kiter->handle->context, kiter->key_name);
kiter->key_name = NULL;
if(kiter->at_start)
{
kiter->current = kiter->handle->root->block->first;
@ -179,35 +186,28 @@ char* codes_bufr_keys_iterator_get_name(bufr_keys_iterator* kiter)
int *r=0;
char* ret=0;
grib_context* c = kiter->handle->context;
grib_string_list* sl = NULL;
DebugAssert(kiter->current);
if (kiter->prefix) {
int iattribute=kiter->i_curr_attribute-1;
ret=(char*)grib_context_malloc_clear(kiter->handle->context,strlen(kiter->prefix)+strlen(kiter->attributes[iattribute]->name)+10);
sprintf(ret,"%s->%s",kiter->prefix,kiter->attributes[iattribute]->name);
ret=(char*)grib_context_malloc_clear(c,strlen(kiter->prefix)+strlen(kiter->attributes[iattribute]->name)+10);
/*sprintf(ret,"%s->%s",kiter->prefix,kiter->attributes[iattribute]->name);*/
strcpy(ret, kiter->prefix); /* strcpy and strcat here are much faster than sprintf */
strcat(ret, "->");
strcat(ret, kiter->attributes[iattribute]->name);
} else {
ret=(char*)grib_context_malloc_clear(kiter->handle->context,strlen(kiter->current->name)+10);
ret=(char*)grib_context_malloc_clear(c,strlen(kiter->current->name)+10);
if (kiter->current->flags & GRIB_ACCESSOR_FLAG_BUFR_DATA) {
r=(int*)grib_trie_get(kiter->seen,kiter->current->name);
sprintf(ret,"#%d#%s",*r,kiter->current->name);
} else {
sprintf(ret,"%s",kiter->current->name);
strcpy(ret,kiter->current->name);
}
}
/* Store in list of names to be deleted later */
sl=(grib_string_list*)grib_context_malloc_clear(c, sizeof(grib_string_list));
sl->value = ret;
if (!kiter->names) {
kiter->names = sl;
} else {
/* Add to beginning of list for speed. Order doesn't matter */
grib_string_list* tmp = kiter->names;
kiter->names = sl;
sl->next = tmp;
}
kiter->key_name = ret; /*store reference to last key name*/
return ret;
}
@ -220,14 +220,7 @@ int codes_bufr_keys_iterator_delete(bufr_keys_iterator* kiter)
{
if (kiter) {
grib_context* c = kiter->handle->context;
grib_string_list* sl = kiter->names;
while(sl) {
grib_string_list* n = sl->next;
grib_context_free(c, sl->value);
grib_context_free(c, sl);
sl = n;
}
kiter->names=NULL;
kiter->key_name = NULL;
if(kiter->seen)
grib_trie_delete(kiter->seen);
grib_context_free(c,kiter);

View File

@ -115,7 +115,7 @@ int codes_bufr_copy_data(grib_handle* hin, grib_handle* hout)
identical and we want to copy what can be copied and skip what
cannot be copied because is not in the output handle
*/
err=codes_copy_key(hin, hout, name, 0);
err=codes_copy_key(hin, hout, name, GRIB_TYPE_UNDEFINED);
if (err==0) nkeys++;
}

View File

@ -34,7 +34,7 @@ static int find_next_group(const unsigned long* vals, size_t len, unsigned long
long lmax = 0;
size_t i = 0;
if (len <=0 ) return GRIB_ARRAY_TOO_SMALL;
if (len == 0 ) return GRIB_ARRAY_TOO_SMALL;
lmin = vals[0];
lmax = lmin;

View File

@ -16,6 +16,14 @@
#include "grib_api_internal.h"
/* Note: A fast cut-down version of strcmp which does NOT return -1 */
/* 0 means input strings are equal and 1 means not equal */
GRIB_INLINE static int grib_inline_strcmp(const char* a,const char* b) {
if (*a != *b) return 1;
while((*a!=0 && *b!=0) && *(a) == *(b) ) {a++;b++;}
return (*a==0 && *b==0) ? 0 : 1;
}
void grib_accessor_dump(grib_accessor* a, grib_dumper* f)
{
grib_accessor_class *c = a->cclass;
@ -606,7 +614,7 @@ int grib_compare_accessors(grib_accessor* a1,grib_accessor* a2,int compare_flags
int type_mismatch=0;
grib_accessor_class *c1=NULL;
if ((compare_flags & GRIB_COMPARE_NAMES) && strcmp(a1->name,a2->name))
if ((compare_flags & GRIB_COMPARE_NAMES) && grib_inline_strcmp(a1->name,a2->name))
return GRIB_NAME_MISMATCH;
if ( compare_flags & GRIB_COMPARE_TYPES ) {
@ -667,7 +675,9 @@ int grib_accessor_add_attribute(grib_accessor* a,grib_accessor* attr,int nest_if
grib_accessor* same=NULL;
grib_accessor* aloc=a;
same=_grib_accessor_get_attribute(a,attr->name,&id);
if(grib_accessor_has_attributes(a)) {
same=_grib_accessor_get_attribute(a,attr->name,&id);
}
if (same) {
if (nest_if_clash==0) return GRIB_ATTRIBUTE_CLASH;
@ -732,7 +742,7 @@ grib_accessor* _grib_accessor_get_attribute(grib_accessor* a,const char* name,in
{
int i=0;
while (i<MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) {
if (!strcmp(a->attributes[i]->name,name)) {
if (!grib_inline_strcmp(a->attributes[i]->name,name)) {
*index=i;
return a->attributes[i];
}

View File

@ -217,6 +217,7 @@ static void link_same_attributes(grib_accessor* a,grib_accessor* b)
int idx=0;
grib_accessor* bAttribute=NULL;
if (a==NULL || b==NULL) return;
if (!grib_accessor_has_attributes(b)) return;
while (i<MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) {
bAttribute=_grib_accessor_get_attribute(b,a->attributes[i]->name,&idx);
if (bAttribute) a->attributes[i]->same=bAttribute;

View File

@ -267,16 +267,6 @@ static int is_bitmap_start_defined(grib_accessor_bufr_data_array *self)
return self->bitmapStart==-1 ? 0 : 1;
}
int accessor_bufr_data_array_create_keys(grib_accessor* a,long onlySubset,long startSubset,long endSubset)
{
return create_keys(a,onlySubset,startSubset,endSubset);
}
int accessor_bufr_data_array_process_elements(grib_accessor* a,int flag,long onlySubset,long startSubset,long endSubset)
{
return process_elements(a,flag,onlySubset,startSubset,endSubset);
}
static size_t get_length(grib_accessor* a)
{
grib_accessor_bufr_data_array *self =(grib_accessor_bufr_data_array*)a;
@ -712,6 +702,19 @@ static void set_missing_long_to_double(grib_darray* dvalues)
}
}
/* ECC-750: The 'factor' argument is 10^-scale */
static int descriptor_get_min_max(bufr_descriptor* bd, long width, long reference, double factor,
double* minAllowed, double* maxAllowed)
{
/* Maximum value is allowed to be the largest number (all bits 1) which means it's MISSING */
unsigned long max1 = (1UL << width) - 1; /* Highest value for number with 'width' bits */
DebugAssert(width > 0 && width <= 32);
*maxAllowed = (max1 + reference) * factor;
*minAllowed = reference * factor;
return GRIB_SUCCESS;
}
static int encode_double_array(grib_context* c,grib_buffer* buff,long* pos, bufr_descriptor* bd,
grib_accessor_bufr_data_array* self,grib_darray* dvalues)
{
@ -721,7 +724,7 @@ static int encode_double_array(grib_context* c,grib_buffer* buff,long* pos, bufr
long localReference=0,localWidth=0,modifiedWidth,modifiedReference;
long reference,allone;
double localRange,modifiedFactor,inverseFactor;
size_t ii;
size_t ii, index_of_min, index_of_max;
int nvals = 0;
double min=0,max=0,maxAllowed,minAllowed;
double* v=NULL;
@ -741,8 +744,7 @@ static int encode_double_array(grib_context* c,grib_buffer* buff,long* pos, bufr
inverseFactor= grib_power(bd->scale,10);
modifiedWidth= bd->width;
maxAllowed=(grib_power(modifiedWidth,2)+modifiedReference)*modifiedFactor;
minAllowed=modifiedReference*modifiedFactor;
descriptor_get_min_max(bd, modifiedWidth, modifiedReference, modifiedFactor, &minAllowed, &maxAllowed);
nvals=grib_iarray_used_size(self->iss_list);
if (nvals<=0) return GRIB_NO_VALUES;
@ -759,10 +761,19 @@ static int encode_double_array(grib_context* c,grib_buffer* buff,long* pos, bufr
grib_set_bits_on(buff->data,pos,modifiedWidth);
} else {
if (*v > maxAllowed || *v < minAllowed) {
return GRIB_OUT_OF_RANGE; /* ECC-611 */
if (dont_fail_if_out_of_range) {
grib_context_log(c, GRIB_LOG_ERROR, "encode_double_array: %s. Value (%g) out of range (minAllowed=%g, maxAllowed=%g)."
"Setting it to missing value\n", bd->shortName, *v, minAllowed, maxAllowed);
grib_set_bits_on(buff->data,pos,modifiedWidth);
} else {
grib_context_log(c, GRIB_LOG_ERROR, "encode_double_array: %s. Value (%g) out of range (minAllowed=%g, maxAllowed=%g).",
bd->shortName, *v, minAllowed, maxAllowed);
return GRIB_OUT_OF_RANGE; /* ECC-611 */
}
} else {
lval=round(*v * inverseFactor)-modifiedReference;
grib_encode_unsigned_longb(buff->data,lval,pos,modifiedWidth);
}
lval=round(*v * inverseFactor)-modifiedReference;
grib_encode_unsigned_longb(buff->data,lval,pos,modifiedWidth);
}
grib_buffer_set_ulength_bits(c,buff,buff->ulength_bits+6);
grib_encode_unsigned_longb(buff->data,localWidth,pos,6);
@ -795,7 +806,7 @@ static int encode_double_array(grib_context* c,grib_buffer* buff,long* pos, bufr
}
ii=0;
while (*v==GRIB_MISSING_DOUBLE && ii<nvals) {
while (ii<nvals && *v==GRIB_MISSING_DOUBLE) {
thereIsAMissing=1;
v++;
ii++;
@ -823,19 +834,25 @@ static int encode_double_array(grib_context* c,grib_buffer* buff,long* pos, bufr
break;
}
}
ii=0;
ii=0; index_of_min=index_of_max=0;
v=values;
while (ii<nvals) {
if (*v<min && *v!=GRIB_MISSING_DOUBLE) min=*v;
if (*v>max && *v!=GRIB_MISSING_DOUBLE) max=*v;
if (*v<min && *v!=GRIB_MISSING_DOUBLE) { min=*v; index_of_min=ii; }
if (*v>max && *v!=GRIB_MISSING_DOUBLE) { max=*v; index_of_max=ii; }
if (*v == GRIB_MISSING_DOUBLE) thereIsAMissing=1;
ii++;
v++;
}
if (max>maxAllowed && max!=GRIB_MISSING_DOUBLE)
if (max>maxAllowed && max!=GRIB_MISSING_DOUBLE) {
grib_context_log(c, GRIB_LOG_ERROR, "encode_double_array: %s. Maximum value (value[%lu]=%g) out of range (maxAllowed=%g).",
bd->shortName, index_of_max, max, maxAllowed, index_of_max);
return GRIB_OUT_OF_RANGE;
if (min<minAllowed && min!=GRIB_MISSING_DOUBLE)
}
if (min<minAllowed && min!=GRIB_MISSING_DOUBLE) {
grib_context_log(c, GRIB_LOG_ERROR, "encode_double_array: %s. Minimum value (value[%lu]=%g) out of range (minAllowed=%g).",
bd->shortName, index_of_min, min, minAllowed);
return GRIB_OUT_OF_RANGE;
}
reference=round(min*inverseFactor);
localReference=reference-modifiedReference;
@ -898,8 +915,8 @@ static int encode_double_value(grib_context* c,grib_buffer* buff,long* pos,bufr_
modifiedReference= bd->reference;
modifiedFactor= bd->factor;
modifiedWidth= bd->width;
maxAllowed=(grib_power(modifiedWidth,2)+modifiedReference)*modifiedFactor;
minAllowed=modifiedReference*modifiedFactor;
descriptor_get_min_max(bd, modifiedWidth, modifiedReference, modifiedFactor, &minAllowed, &maxAllowed);
grib_buffer_set_ulength_bits(c,buff,buff->ulength_bits+modifiedWidth);
if (value==GRIB_MISSING_DOUBLE) {
@ -913,7 +930,7 @@ static int encode_double_value(grib_context* c,grib_buffer* buff,long* pos,bufr_
value = GRIB_MISSING_DOUBLE; /* Ignore the bad value and instead use 'missing' */
grib_set_bits_on(buff->data,pos,modifiedWidth);
} else {
grib_context_log(c, GRIB_LOG_DEBUG, "encode_double_value: %s. Value (%g) out of range (minAllowed=%g, maxAllowed=%g).",
grib_context_log(c, GRIB_LOG_ERROR, "encode_double_value: %s. Value (%g) out of range (minAllowed=%g, maxAllowed=%g).",
bd->shortName, value, minAllowed, maxAllowed);
return GRIB_OUT_OF_RANGE;
}
@ -1503,9 +1520,11 @@ static int build_bitmap_new_data(grib_accessor_bufr_data_array *self,unsigned ch
iDelayedReplication=iBitmapOperator+2;
switch (descriptors[iDelayedReplication]->code) {
case 31001:
if(!self->inputReplications) {grib_context_log(c,GRIB_LOG_ERROR,"build_bitmap_new_data: No inputReplications"); return GRIB_ENCODING_ERROR;}
bitmapSize=self->inputReplications[self->iInputReplications];
break;
case 31002:
if(!self->inputExtendedReplications) {grib_context_log(c,GRIB_LOG_ERROR,"build_bitmap_new_data: No inputExtendedReplications");return GRIB_ENCODING_ERROR;}
bitmapSize=self->inputExtendedReplications[self->iInputExtendedReplications];
break;
default :
@ -1731,12 +1750,23 @@ static void set_creator_name(grib_action* creator,int code)
}
}
/* See ECC-741 */
static int adding_extra_key_attributes(grib_handle* h)
{
long skip = 0; /* default is to add */
int err = 0;
err = grib_get_long(h,"skipExtraKeyAttributes",&skip);
if (err) return 1;
return (!skip);
}
static grib_accessor* create_accessor_from_descriptor(grib_accessor* a,grib_accessor* attribute,grib_section* section,long ide,long subset,int dump,int count)
{
grib_accessor_bufr_data_array *self =(grib_accessor_bufr_data_array*)a;
char code[10]={0,};
char* temp_str = NULL;
int idx=0;
int add_extra_attributes = 1;
unsigned long flags=GRIB_ACCESSOR_FLAG_READ_ONLY;
grib_action operatorCreator = {0, };
grib_accessor* elementAccessor=NULL;
@ -1751,6 +1781,8 @@ static grib_accessor* create_accessor_from_descriptor(grib_accessor* a,grib_acce
operatorCreator.set = 0;
operatorCreator.name="operator";
add_extra_attributes = adding_extra_key_attributes(grib_handle_of_accessor(a));
if(attribute) { DebugAssert(attribute->parent==NULL); }
if (dump) {
@ -1804,21 +1836,23 @@ static grib_accessor* create_accessor_from_descriptor(grib_accessor* a,grib_acce
grib_sarray_push(a->context, self->tempStrings, temp_str);/* ECC-325: store alloc'd string (due to strdup) for clean up later */
grib_accessor_add_attribute(elementAccessor,attribute,0);
attribute=create_attribute_variable("units",section,GRIB_TYPE_STRING,self->expanded->v[idx]->units,0,0,GRIB_ACCESSOR_FLAG_DUMP | flags);
if (!attribute) return NULL;
grib_accessor_add_attribute(elementAccessor,attribute,0);
if (add_extra_attributes) {
attribute=create_attribute_variable("units",section,GRIB_TYPE_STRING,self->expanded->v[idx]->units,0,0,GRIB_ACCESSOR_FLAG_DUMP | flags);
if (!attribute) return NULL;
grib_accessor_add_attribute(elementAccessor,attribute,0);
attribute=create_attribute_variable("scale",section,GRIB_TYPE_LONG,0,0,self->expanded->v[idx]->scale,flags);
if (!attribute) return NULL;
grib_accessor_add_attribute(elementAccessor,attribute,0);
attribute=create_attribute_variable("scale",section,GRIB_TYPE_LONG,0,0,self->expanded->v[idx]->scale,flags);
if (!attribute) return NULL;
grib_accessor_add_attribute(elementAccessor,attribute,0);
attribute=create_attribute_variable("reference",section,GRIB_TYPE_DOUBLE,0,self->expanded->v[idx]->reference,0,flags);
if (!attribute) return NULL;
grib_accessor_add_attribute(elementAccessor,attribute,0);
attribute=create_attribute_variable("reference",section,GRIB_TYPE_DOUBLE,0,self->expanded->v[idx]->reference,0,flags);
if (!attribute) return NULL;
grib_accessor_add_attribute(elementAccessor,attribute,0);
attribute=create_attribute_variable("width",section,GRIB_TYPE_LONG,0,0,self->expanded->v[idx]->width,flags);
if (!attribute) return NULL;
grib_accessor_add_attribute(elementAccessor,attribute,0);
attribute=create_attribute_variable("width",section,GRIB_TYPE_LONG,0,0,self->expanded->v[idx]->width,flags);
if (!attribute) return NULL;
grib_accessor_add_attribute(elementAccessor,attribute,0);
}
break;
case 2:
set_creator_name(&creator,self->expanded->v[idx]->code);
@ -1876,21 +1910,23 @@ static grib_accessor* create_accessor_from_descriptor(grib_accessor* a,grib_acce
if (!attribute) return NULL;
grib_accessor_add_attribute(elementAccessor,attribute,0);
attribute=create_attribute_variable("units",section,GRIB_TYPE_STRING,self->expanded->v[idx]->units,0,0,GRIB_ACCESSOR_FLAG_DUMP);
if (!attribute) return NULL;
grib_accessor_add_attribute(elementAccessor,attribute,0);
if (add_extra_attributes) {
attribute=create_attribute_variable("units",section,GRIB_TYPE_STRING,self->expanded->v[idx]->units,0,0,GRIB_ACCESSOR_FLAG_DUMP);
if (!attribute) return NULL;
grib_accessor_add_attribute(elementAccessor,attribute,0);
attribute=create_attribute_variable("scale",section,GRIB_TYPE_LONG,0,0,self->expanded->v[idx]->scale,flags);
if (!attribute) return NULL;
grib_accessor_add_attribute(elementAccessor,attribute,0);
attribute=create_attribute_variable("scale",section,GRIB_TYPE_LONG,0,0,self->expanded->v[idx]->scale,flags);
if (!attribute) return NULL;
grib_accessor_add_attribute(elementAccessor,attribute,0);
attribute=create_attribute_variable("reference",section,GRIB_TYPE_DOUBLE,0,self->expanded->v[idx]->reference,0,flags);
if (!attribute) return NULL;
grib_accessor_add_attribute(elementAccessor,attribute,0);
attribute=create_attribute_variable("reference",section,GRIB_TYPE_DOUBLE,0,self->expanded->v[idx]->reference,0,flags);
if (!attribute) return NULL;
grib_accessor_add_attribute(elementAccessor,attribute,0);
attribute=create_attribute_variable("width",section,GRIB_TYPE_LONG,0,0,self->expanded->v[idx]->width,flags);
if (!attribute) return NULL;
grib_accessor_add_attribute(elementAccessor,attribute,0);
attribute=create_attribute_variable("width",section,GRIB_TYPE_LONG,0,0,self->expanded->v[idx]->width,flags);
if (!attribute) return NULL;
grib_accessor_add_attribute(elementAccessor,attribute,0);
}
break;
}
@ -2144,7 +2180,7 @@ static int create_keys(grib_accessor* a,long onlySubset,long startSubset,long en
grib_sarray_delete (c, self->tempStrings);
self->tempStrings=NULL;
}
self->tempStrings = grib_sarray_new(c, self->numberOfSubsets, 10);
self->tempStrings = grib_sarray_new(c, self->numberOfSubsets, 500);
end= self->compressedData ? 1 : self->numberOfSubsets;
groupNumber=1;
@ -2289,9 +2325,7 @@ static int create_keys(grib_accessor* a,long onlySubset,long startSubset,long en
/* forceGroupClosure=1; */
/* reset_qualifiers(significanceQualifierGroup); */
} else if (descriptor->X==33 && !qualityPresent) {
if (c->bufr_quality_without_bitmap == 1) {
dump=1; /* ECC-690: percentConfidence WITHOUT a bitmap! e.g. NOAA GOES16 BUFR */
}
dump=1; /* ECC-690: percentConfidence WITHOUT a bitmap! e.g. NOAA GOES16 BUFR */
}
if (ide==0 && !self->compressedData) {
@ -2358,12 +2392,7 @@ static int create_keys(grib_accessor* a,long onlySubset,long startSubset,long en
if(descriptor->code==33007) {
add_key = 0; /* Standard behaviour */
if (!qualityPresent) {
if (c->bufr_quality_without_bitmap) {
add_key = 1;
} else {
grib_context_log(c, GRIB_LOG_WARNING,
"create_keys: descriptor=%6.6ld: Class 33 quality information without a bitmap!",descriptor->code);
}
add_key = 1;
}
}
if (add_key) {

View File

@ -181,16 +181,17 @@ static void init(grib_accessor* a, const long len , grib_arguments* args )
{
grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a;
int n=0;
self->tablesAccessorName=grib_arguments_get_name(grib_handle_of_accessor(a),args,n++);
self->expandedName=grib_arguments_get_name(grib_handle_of_accessor(a),args,n++);
self->rank=grib_arguments_get_long(grib_handle_of_accessor(a),args,n++);
grib_handle* hand=grib_handle_of_accessor(a);
self->tablesAccessorName=grib_arguments_get_name(hand,args,n++);
self->expandedName=grib_arguments_get_name(hand,args,n++);
self->rank=grib_arguments_get_long(hand,args,n++);
if (self->rank!=0) {
self->expandedAccessor=grib_find_accessor(grib_handle_of_accessor(a),self->expandedName);
self->expandedAccessor=grib_find_accessor(hand,self->expandedName);
} else {
self->expandedAccessor=0;
}
self->unexpandedDescriptors=grib_arguments_get_name(grib_handle_of_accessor(a),args,n++);
self->sequence=grib_arguments_get_name(grib_handle_of_accessor(a),args,n++);
self->unexpandedDescriptors=grib_arguments_get_name(hand,args,n++);
self->sequence=grib_arguments_get_name(hand,args,n++);
self->do_expand=1;
self->expanded=0;
a->length = 0;
@ -207,6 +208,8 @@ static bufr_descriptors_array* do_expand(grib_accessor* a,bufr_descriptors_array
static int global_depth=-1;
#endif
#define BUFR_DESCRIPTORS_ARRAY_USED_SIZE(v) ((v)->n)
static size_t __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, bufr_descriptors_array* expanded,
change_coding_params* ccp, int* err)
{
@ -228,7 +231,7 @@ static size_t __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, buf
int idepth;
#endif
if (grib_bufr_descriptors_array_used_size(unexpanded)==0) return 0;
if (BUFR_DESCRIPTORS_ARRAY_USED_SIZE(unexpanded)==0) return 0;
us=grib_bufr_descriptor_clone(grib_bufr_descriptors_array_get(unexpanded,0));
@ -253,6 +256,7 @@ static size_t __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, buf
v=(long*)grib_context_malloc_clear(c,sizeof(long)*size);
*err=grib_get_long_array(grib_handle_of_accessor(a),self->sequence,v,&size);
if (*err) return 0;
inner_unexpanded=grib_bufr_descriptors_array_new(c,DESC_SIZE_INIT,DESC_SIZE_INCR);
for (i=0;i<size;i++) {
vv=grib_bufr_descriptor_new(self->tablesAccessor,v[i],err);
@ -267,7 +271,7 @@ static size_t __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, buf
printf("+++ push %06ld\n",inner_expanded->v[i]->code);
}
#endif
size=grib_bufr_descriptors_array_used_size(inner_expanded);
size=BUFR_DESCRIPTORS_ARRAY_USED_SIZE(inner_expanded);
expanded=grib_bufr_descriptors_array_append(expanded,inner_expanded);
break;
@ -297,7 +301,7 @@ static size_t __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, buf
}
inner_expanded=do_expand(a,inner_unexpanded,ccp,err);
grib_bufr_descriptors_array_delete(inner_unexpanded);
size=grib_bufr_descriptors_array_used_size(inner_expanded);
size=BUFR_DESCRIPTORS_ARRAY_USED_SIZE(inner_expanded);
#if MYDEBUG
for (i=0;i<inner_expanded->n;i++) {
for (idepth=0;idepth<global_depth;idepth++) printf("\t");
@ -345,7 +349,7 @@ static size_t __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, buf
printf("+++ push %06ld\n",inner_expanded->v[i]->code);
}
#endif
size=grib_bufr_descriptors_array_used_size(inner_expanded);
size=BUFR_DESCRIPTORS_ARRAY_USED_SIZE(inner_expanded);
expanded=grib_bufr_descriptors_array_append(expanded,inner_expanded);
}
break;
@ -656,7 +660,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
ret=expand(a);
if (ret) return ret;
expandedSize=grib_bufr_descriptors_array_used_size(self->expanded);
expandedSize=BUFR_DESCRIPTORS_ARRAY_USED_SIZE(self->expanded);
if(*len < expandedSize)
{
grib_context_log(a->context, GRIB_LOG_ERROR,
@ -678,7 +682,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
size_t i;
ret=expand(a);
rlen=grib_bufr_descriptors_array_used_size(self->expanded);
rlen=BUFR_DESCRIPTORS_ARRAY_USED_SIZE(self->expanded);
if (ret) return ret;
if(*len < rlen)
@ -726,7 +730,7 @@ static int value_count(grib_accessor* a,long* rlen)
*rlen=0;
ret=expand(a);
*rlen=grib_bufr_descriptors_array_used_size(self->expanded);
*rlen=BUFR_DESCRIPTORS_ARRAY_USED_SIZE(self->expanded);
if (ret) {
grib_context_log(c,GRIB_LOG_ERROR,"%s unable to compute size",a->name);
return ret;

View File

@ -199,6 +199,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
NS=(MS+1)*(MS+2);
if ( bpv != 0 ) {
DebugAssert( offsetAfterData > offsetBeforeData );
*val =((offsetAfterData-offsetBeforeData)*8-unusedBits+NS*(bpv-32))/bpv;
} else {
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues,&numberOfValues)) != GRIB_SUCCESS)

View File

@ -176,6 +176,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
return ret;
if ( bpv != 0 ) {
DebugAssert( offsetAfterData > offsetBeforeData );
*val=((offsetAfterData-offsetBeforeData)*8-unusedBits)/bpv;
} else {
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues,&numberOfValues)) != GRIB_SUCCESS)

View File

@ -328,7 +328,7 @@ static int extra_set(grib_accessor* a,long val)
typeOfProcessedData=8;
typeOfGeneratingProcess=5;
break;
case 31: /* Bias-corrected Forecast (bf) */
case 31: /* Bias-corrected forecast (bf) */
typeOfProcessedData=1;
typeOfGeneratingProcess=3;
break;
@ -375,6 +375,7 @@ static int extra_set(grib_accessor* a,long val)
case 81: /* Forecast maximum (fcmax) */
case 82: /* Forecast minimum (fcmin) */
case 83: /* Forecast standard deviation (fcstdev) */
case 86: /* Hindcast climate mean (hcmean) */
case 87: /* Simulated satellite data */
case 88: /* Gridded satellite data */
case 89: /* GFAS analysis */

View File

@ -177,8 +177,9 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
return ret;
if ( bpv != 0 ) {
grib_context_log(a->context,GRIB_LOG_DEBUG,"grib_accessor_number_of_coded_values: offsetAfterData=%ld offsetBeforeData=%ld unusedBits=%ld bpv=%ld\n",
offsetAfterData,offsetBeforeData,unusedBits,bpv);
grib_context_log(a->context,GRIB_LOG_DEBUG,"grib_accessor_number_of_coded_values: offsetAfterData=%ld offsetBeforeData=%ld unusedBits=%ld bpv=%ld\n",
offsetAfterData,offsetBeforeData,unusedBits,bpv);
DebugAssert( offsetAfterData > offsetBeforeData );
*val=((offsetAfterData-offsetBeforeData)*8-unusedBits)/bpv;
} else {
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues,&numberOfValues)) != GRIB_SUCCESS)

View File

@ -170,13 +170,12 @@ static const long ones[] = {
static int unpack_long(grib_accessor* a, long* val, size_t *len)
{
grib_accessor_signed* self = (grib_accessor_signed*)a;
unsigned long rlen = 0;
int err=0;
long count=0;
unsigned long i = 0;
grib_handle* hand=grib_handle_of_accessor(a);
long pos = a->offset;
long missing = 0;
@ -184,22 +183,19 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
if (err) return err;
rlen=count;
if(*len < rlen)
{
if(*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR, " wrong size for %s it contains %d values ", a->name , rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
if(a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING)
{
if(a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) {
Assert(self->nbytes <= 4);
missing = ones[self->nbytes];
}
for(i=0; i< rlen;i++){
val[i] = (long)grib_decode_signed_long(grib_handle_of_accessor(a)->buffer->data , pos, self->nbytes);
val[i] = (long)grib_decode_signed_long(hand->buffer->data , pos, self->nbytes);
if(missing)
if(val[i] == missing)
val[i] = GRIB_MISSING_LONG;
@ -227,20 +223,18 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
if (err) return err;
rlen=count;
if(*len < 1)
{
if(*len < 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name , 1 );
len[0] = 0;
return GRIB_ARRAY_TOO_SMALL;
}
if(a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING)
{
if(a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) {
Assert(self->nbytes <= 4);
missing = ones[self->nbytes];
}
if (rlen == 1){
if (rlen == 1) {
long v = val[0];
if(missing)
if(v == GRIB_MISSING_LONG)
@ -260,7 +254,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
buf = (unsigned char*)grib_context_malloc(a->context,buflen);
for(i=0; i < *len;i++){
for(i=0; i < *len;i++) {
grib_encode_signed_long(buf, val[i] , off, a->length);
off+= a->length;
}
@ -275,7 +269,8 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
return ret;
}
static long byte_count(grib_accessor* a){
static long byte_count(grib_accessor* a)
{
return a->length;
}
@ -287,7 +282,8 @@ static int value_count(grib_accessor* a,long* len)
return grib_get_long_internal(grib_handle_of_accessor(a),grib_arguments_get_name(a->parent->h,self->arg,0),len);
}
static long byte_offset(grib_accessor* a){
static long byte_offset(grib_accessor* a)
{
return a->offset;
}
@ -297,14 +293,17 @@ static void update_size(grib_accessor* a,size_t s)
Assert(a->length>=0);
}
static long next_offset(grib_accessor* a){
static long next_offset(grib_accessor* a)
{
return grib_byte_offset(a)+grib_byte_count(a);
}
static int is_missing(grib_accessor* a){
static int is_missing(grib_accessor* a)
{
int i=0;
unsigned char ff=0xff;
unsigned long offset=a->offset;
grib_handle* hand=grib_handle_of_accessor(a);
if (a->length==0) {
Assert(a->vvalue!=NULL);
@ -312,7 +311,7 @@ static int is_missing(grib_accessor* a){
}
for (i=0;i<a->length;i++) {
if (grib_handle_of_accessor(a)->buffer->data[offset] != ff) return 0;
if (hand->buffer->data[offset] != ff) return 0;
offset++;
}

View File

@ -141,8 +141,9 @@ static void init(grib_accessor* a, const long len , grib_arguments* args )
{
grib_accessor_unexpanded_descriptors* self = (grib_accessor_unexpanded_descriptors*)a;
int n=0;
self->unexpandedDescriptorsEncoded=grib_find_accessor(grib_handle_of_accessor(a),grib_arguments_get_name(grib_handle_of_accessor(a),args,n++));
self->createNewData=grib_arguments_get_name(grib_handle_of_accessor(a),args,n++);
grib_handle* hand=grib_handle_of_accessor(a);
self->unexpandedDescriptorsEncoded=grib_find_accessor(hand,grib_arguments_get_name(hand,args,n++));
self->createNewData=grib_arguments_get_name(hand,args,n++);
a->length = 0;
}
@ -159,7 +160,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
long rlen =0;
long f,x,y;
long *v=val;
int i;
long i;
grib_handle* hand=grib_handle_of_accessor(a);
pos=accessor_raw_get_offset(self->unexpandedDescriptorsEncoded)*8;
@ -181,9 +183,9 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
}
for (i=0;i<rlen;i++) {
f=grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data,&pos,2);
x=grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data,&pos,6);
y=grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data,&pos,8);
f=grib_decode_unsigned_long(hand->buffer->data,&pos,2);
x=grib_decode_unsigned_long(hand->buffer->data,&pos,6);
y=grib_decode_unsigned_long(hand->buffer->data,&pos,8);
*v++=f*100000+x*1000+y;
}
*len = rlen;
@ -193,41 +195,44 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
static int pack_long(grib_accessor* a, const long* val, size_t *len)
{
grib_accessor_unexpanded_descriptors* self = (grib_accessor_unexpanded_descriptors*)a;
int ret=0,i;
int ret=0;
long pos = 0;
unsigned long f,x,y;
unsigned char* buf = NULL;
grib_accessor* expanded=NULL;
size_t buflen=*len*2;
size_t i = 0, length = *len;
long createNewData=1;
grib_handle* hand=grib_handle_of_accessor(a);
grib_get_long(grib_handle_of_accessor(a),self->createNewData,&createNewData);
grib_get_long(hand,self->createNewData,&createNewData);
buf=(unsigned char*)grib_context_malloc_clear(a->context,buflen);
for (i=0;i<*len;i++) {
for (i=0;i<length;i++) {
const long tmp = val[i]%100000;
f=val[i]/100000;
x=(val[i]%100000)/1000;
y=(val[i]%100000)%1000;
x=tmp/1000;
y=tmp%1000;
grib_encode_unsigned_longb(buf,f,&pos,2);
grib_encode_unsigned_longb(buf,x,&pos,6);
grib_encode_unsigned_longb(buf,y,&pos,8);
}
grib_pack_bytes(self->unexpandedDescriptorsEncoded,buf,&buflen);
grib_context_free(grib_handle_of_accessor(a)->context,buf);
grib_context_free(hand->context,buf);
if (createNewData==0) return ret;
expanded=grib_find_accessor(grib_handle_of_accessor(a),"expandedCodes");
expanded=grib_find_accessor(hand,"expandedCodes");
Assert(expanded!=NULL);
ret = grib_accessor_class_expanded_descriptors_set_do_expand(expanded,1);
if (ret != GRIB_SUCCESS) return ret;
ret = grib_set_long(grib_handle_of_accessor(a),"unpack",3);
ret = grib_set_long(hand,"unpack",3); /* BUFR new data */
if (ret != GRIB_SUCCESS) return ret;
ret = grib_set_long(grib_handle_of_accessor(a),"unpack",1);
ret = grib_set_long(hand,"unpack",1); /* Unpack structure */
return ret;
}

View File

@ -290,6 +290,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
long count=0;
int err = 0;
long pos = a->offset*8;
grib_handle* hand=grib_handle_of_accessor(a);
err=grib_value_count(a,&count);
if (err) return err;
@ -315,7 +316,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
}
for(i=0; i< rlen;i++){
val[i] = (long)grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data , &pos, self->nbytes*8);
val[i] = (long)grib_decode_unsigned_long(hand->buffer->data , &pos, self->nbytes*8);
if(missing)
if(val[i] == missing)
val[i] = GRIB_MISSING_LONG;
@ -363,6 +364,7 @@ static int is_missing(grib_accessor* a)
int i=0;
unsigned char ff=0xff;
unsigned long offset=a->offset;
grib_handle* hand=grib_handle_of_accessor(a);
if (a->length==0) {
Assert(a->vvalue!=NULL);
@ -370,7 +372,7 @@ static int is_missing(grib_accessor* a)
}
for (i=0;i<a->length;i++) {
if (grib_handle_of_accessor(a)->buffer->data[offset] != ff) {
if (hand->buffer->data[offset] != ff) {
return 0;
}
offset++;

View File

@ -1362,6 +1362,7 @@ void* wmo_read_any_from_stream_malloc(void* stream_data,long (*stream_proc)(void
void *wmo_read_any_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t *offset,int* err);
void *wmo_read_gts_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t *offset,int* err);
void *wmo_read_bufr_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t *offset,int* err);
void *wmo_read_grib_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t *offset,int* err);
int grib_get_message_offset ( grib_handle* h,off_t* offset);
int grib_get_message_size ( grib_handle* h,size_t* size);

View File

@ -1,94 +0,0 @@
integer grib_open_file
external grib_open_file
integer grib_close_file
external grib_close_file
integer grib_read_file
external grib_read_file
integer grib_new_from_message
external grib_new_from_message
integer grib_new_from_samples
external grib_new_from_samples
integer grib_clone
external grib_clone
integer grib_new_from_file
external grib_new_from_file
integer grib_multi_support_on
external grib_multi_support_on
integer grib_multi_support_off
external grib_multi_support_off
integer grib_gribex_mode_on
external grib_gribex_mode_on
integer grib_gribex_mode_off
external grib_gribex_mode_off
integer grib_release
external grib_release
integer grib_iterator_new
external grib_iterator_new
integer grib_iterator_next
external grib_iterator_next
integer grib_iterator_delete
external grib_iterator_delete
integer grib_dump
external grib_dump
integer grib_print
external grib_print
integer grib_get_error_string
external grib_get_error_string
integer grib_get_size
external grib_get_size
integer grib_get_int
external grib_get_int
integer grib_get_int_array
external grib_get_int_array
integer grib_set_int_array
external grib_set_int_array
integer grib_set_int
external grib_set_int
integer grib_set_real4
external grib_set_real4
integer grib_get_real4
external grib_get_real4
integer grib_get_real4_array
external grib_get_real4_array
integer grib_set_real4_array
external grib_set_real4_array
integer grib_set_real8
external grib_set_real8
integer grib_get_real8
external grib_get_real8
integer grib_get_real8_array
external grib_get_real8_array
integer grib_set_real8_array
external grib_set_real8_array
integer grib_get_string
external grib_get_string
integer grib_set_string
external grib_set_string
integer grib_get_message_size
external grib_get_message_size
integer grib_copy_message
external grib_copy_message
integer grib_write
external grib_write
integer grib_keys_iterator_new
external grib_keys_iterator_new
integer grib_keys_iterator_next
external grib_keys_iterator_next
integer grib_keys_iterator_delete
external grib_keys_iterator_delete
integer grib_skip_computed
external grib_skip_computed
integer grib_skip_coded
external grib_skip_coded
integer grib_skip_edition_specific
external grib_skip_edition_specific
integer grib_skip_duplicates
external grib_skip_duplicates
integer grib_skip_read_only
external grib_skip_read_only
integer grib_skip_function
external grib_skip_function
integer grib_keys_iterator_get_name
external grib_keys_iterator_get_name
integer grib_keys_iterator_rewind
external grib_keys_iterator_rewind

View File

@ -1054,7 +1054,6 @@ struct grib_context
int ieee_packing;
int bufrdc_mode;
int bufr_set_to_missing_if_out_of_range;
int bufr_quality_without_bitmap;
FILE* log_stream;
grib_trie* classes;
grib_trie* lists;
@ -1386,7 +1385,7 @@ struct bufr_keys_iterator{
unsigned long accessor_flags_skip;
unsigned long accessor_flags_only;
grib_accessor* current;
grib_string_list* names;
char* key_name;
int at_start;
int match;
int i_curr_attribute;

View File

@ -291,8 +291,6 @@ size_t grib_viarray_used_size(grib_viarray *v);
/* grib_accessor_class_bufr_clear_tables.c */
/* grib_accessor_class_bufr_data_array.c */
int accessor_bufr_data_array_create_keys(grib_accessor *a, long onlySubset, long startSubset, long endSubset);
int accessor_bufr_data_array_process_elements(grib_accessor *a, int flag, long onlySubset, long startSubset, long endSubset);
grib_vsarray *accessor_bufr_data_array_get_stringValues(grib_accessor *a);
grib_accessors_list *accessor_bufr_data_array_get_dataAccessors(grib_accessor *a);
grib_trie_with_rank *accessor_bufr_data_array_get_dataAccessorsTrie(grib_accessor *a);
@ -810,6 +808,7 @@ long accessor_raw_get_offset(grib_accessor *a);
void grib_get_reduced_row_wrapper(grib_handle *h, long pl, double lon_first, double lon_last, long *npoints, long *ilon_first, long *ilon_last);
void grib_get_reduced_row(long pl, double lon_first, double lon_last, long *npoints, long *ilon_first, long *ilon_last);
void grib_get_reduced_row2(long pl, double lon_first, double lon_last, long *npoints, long *ilon_first, long *ilon_last);
void grib_get_reduced_row3(long pl, double lon_first, double lon_last, long *npoints, double *olon_first, double *olon_last);
/* grib_accessor_class_abstract_vector.c */
@ -1455,7 +1454,7 @@ grib_string_list *grib_util_get_mars_param(const char *param_id);
grib_handle *grib_util_set_spec(grib_handle *h, const grib_util_grid_spec *spec, const grib_util_packing_spec *packing_spec, int flags, const double *data_values, size_t data_values_count, int *err);
grib_handle *grib_util_set_spec2(grib_handle *h, const grib_util_grid_spec2 *spec, const grib_util_packing_spec *packing_spec, int flags, const double *data_values, size_t data_values_count, int *err);
int grib_moments(grib_handle *h, double east, double north, double west, double south, int order, double *moments, long *count);
int parse_keyval_string(char *grib_tool, char *arg, int values_required, int default_type, grib_values values[], int *count);
int parse_keyval_string(const char *grib_tool, char *arg, int values_required, int default_type, grib_values values[], int *count);
int is_productDefinitionTemplateNumber_EPS(long productDefinitionTemplateNumber);
int is_productDefinitionTemplateNumber_Chemical(long productDefinitionTemplateNumber);
int is_productDefinitionTemplateNumber_Aerosol(long productDefinitionTemplateNumber);

View File

@ -266,10 +266,7 @@ int grib_encode_unsigned_long(unsigned char* p, unsigned long val ,long *bitp, l
return grib_encode_unsigned_long(p, val, bitp, bits);
}
if (s)
p += (*bitp >> 3); /* skip the bytes */
else
p += (*bitp >> 3); /* skip the bytes */
p += (*bitp >> 3); /* skip the bytes */
/* head */
if (s) {

View File

@ -10,6 +10,9 @@
#include "grib_api_internal.h"
#define DYN_ARRAY_SIZE_INIT 200 /* Initial size for grib_bufr_descriptors_array_new */
#define DYN_ARRAY_SIZE_INCR 400 /* Increment size for the above */
bufr_descriptors_array* grib_bufr_descriptors_array_new(grib_context* c,size_t size,size_t incsize)
{
bufr_descriptors_array* v=NULL;
@ -94,8 +97,8 @@ bufr_descriptors_array* grib_bufr_descriptors_array_resize(bufr_descriptors_arra
bufr_descriptors_array* grib_bufr_descriptors_array_push(bufr_descriptors_array* v,bufr_descriptor* val)
{
if (!v) {
size_t start_size=100;
size_t start_incsize=100;
size_t start_size=DYN_ARRAY_SIZE_INIT;
size_t start_incsize=DYN_ARRAY_SIZE_INCR;
v=grib_bufr_descriptors_array_new(0,start_size,start_incsize);
}
@ -113,8 +116,8 @@ bufr_descriptors_array* grib_bufr_descriptors_array_append(bufr_descriptors_arra
bufr_descriptor* vv=0;
if (!v) {
size_t start_size=100;
size_t start_incsize=100;
size_t start_size=DYN_ARRAY_SIZE_INIT;
size_t start_incsize=DYN_ARRAY_SIZE_INCR;
v=grib_bufr_descriptors_array_new(0,start_size,start_incsize);
}
@ -133,8 +136,8 @@ bufr_descriptors_array* grib_bufr_descriptors_array_push_front(bufr_descriptors_
{
int i;
if (!v) {
size_t start_size=100;
size_t start_incsize=100;
size_t start_size=DYN_ARRAY_SIZE_INIT;
size_t start_incsize=DYN_ARRAY_SIZE_INCR;
v=grib_bufr_descriptors_array_new(0,start_size,start_incsize);
}

View File

@ -336,7 +336,6 @@ static grib_context default_grib_context = {
0, /* ieee_packing */
0, /* bufrdc_mode */
0, /* bufr_set_to_missing_if_out_of_range */
0, /* bufr_quality_without_bitmap*/
0, /* log_stream */
0, /* classes */
0, /* lists */
@ -374,13 +373,11 @@ grib_context* grib_context_get_default()
const char* keep_matrix = NULL;
const char* bufrdc_mode = NULL;
const char* bufr_set_to_missing_if_out_of_range = NULL;
const char* bufr_quality_without_bitmap = NULL;
const char* file_pool_max_opened_files = NULL;
write_on_fail = codes_getenv("ECCODES_GRIB_WRITE_ON_FAIL");
bufrdc_mode = codes_getenv("ECCODES_BUFRDC_MODE_ON");
bufr_set_to_missing_if_out_of_range = codes_getenv("ECCODES_BUFR_SET_TO_MISSING_IF_OUT_OF_RANGE");
bufr_quality_without_bitmap = codes_getenv("ECCODES_BUFR_QUALITY_WITHOUT_BITMAP");
large_constant_fields = codes_getenv("ECCODES_GRIB_LARGE_CONSTANT_FIELDS");
no_abort = codes_getenv("ECCODES_NO_ABORT");
debug = codes_getenv("ECCODES_DEBUG");
@ -477,8 +474,6 @@ grib_context* grib_context_get_default()
default_grib_context.bufrdc_mode = bufrdc_mode ? atoi(bufrdc_mode) : 0;
default_grib_context.bufr_set_to_missing_if_out_of_range = bufr_set_to_missing_if_out_of_range ?
atoi(bufr_set_to_missing_if_out_of_range) : 0;
default_grib_context.bufr_quality_without_bitmap = bufr_quality_without_bitmap ?
atoi(bufr_quality_without_bitmap) : 0;
default_grib_context.file_pool_max_opened_files = file_pool_max_opened_files ?
atoi(file_pool_max_opened_files) : DEFAULT_FILE_POOL_MAX_OPENED_FILES;
}

View File

@ -26,16 +26,16 @@ grib_handle* grib_handle_of_accessor(grib_accessor* a)
static grib_handle* handle_of(grib_accessor* observed)
{
grib_handle *h=NULL ;
grib_handle *h=NULL;
DebugAssert(observed);
/* printf("+++++ %s->parent = %p\n",observed->name,observed->parent); */
/* printf("+++++ %s = %p\n",observed->name,observed); */
/* printf("+++++ h=%p\n",observed->h); */
/* special case for BUFR attributes parentless */
Assert(observed);
if (observed->parent==NULL) {
return observed->h;
}
h = grib_handle_of_accessor(observed);
h = observed->parent->h;
while(h->main) h = h->main;
return h;
}

View File

@ -40,14 +40,14 @@ grib_dumper* grib_dumper_factory(const char* op, grib_handle* h, FILE* out, unsi
d->depth = 0;
d->handle = h;
d->cclass = c;
d->option_flags = option_flags;
d->option_flags = option_flags;
d->arg = arg;
d->out = out;
grib_init_dumper(d);
grib_context_log(h->context,GRIB_LOG_DEBUG,"Creating dumper of type : %s ", op);
return d;
}
grib_context_log(h->context,GRIB_LOG_ERROR,"Unknown type : %s for dumper", op);
grib_context_log(h->context,GRIB_LOG_ERROR,"Unknown type : '%s' for dumper", op);
return NULL;
}

View File

@ -626,6 +626,7 @@ static void header(grib_dumper* d, grib_handle* h)
fprintf(self->dumper.out, "# Using ecCodes version: ");
grib_print_api_version(self->dumper.out);
fprintf(self->dumper.out, "\n\n");
fprintf(self->dumper.out,"from __future__ import print_function\n");
fprintf(self->dumper.out,"import traceback\n");
fprintf(self->dumper.out,"import sys\n");
fprintf(self->dumper.out,"from eccodes import *\n\n\n");
@ -633,7 +634,7 @@ static void header(grib_dumper* d, grib_handle* h)
fprintf(self->dumper.out," f = open(input_file)\n");
}
fprintf(self->dumper.out," # Message number %ld\n # -----------------\n", d->count);
fprintf(self->dumper.out," print 'Decoding message number %ld'\n", d->count);
fprintf(self->dumper.out," print ('Decoding message number %ld')\n", d->count);
fprintf(self->dumper.out," ibufr = codes_bufr_new_from_file(f)\n");
fprintf(self->dumper.out," codes_set(ibufr, 'unpack', 1)\n");

View File

@ -191,7 +191,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
fprintf(self->dumper.out," free(rvalues); rvalues = NULL;\n\n");
fprintf(self->dumper.out," size = %lu;\n", (unsigned long)size);
fprintf(self->dumper.out," rvalues = (double*)malloc(size * sizeof(double));\n");
fprintf(self->dumper.out," if (!rvalues) { fprintf(stderr, \"Failed to allocate memory (rvalues).\\n\"); return 1; }");
fprintf(self->dumper.out," if (!rvalues) { fprintf(stderr, \"Failed to allocate memory (%s).\\n\"); return 1; }",a->name);
icount=0;
for (i=0; i<size-1; ++i) {
@ -273,7 +273,7 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char*
fprintf(self->dumper.out," free(rvalues); rvalues = NULL;\n");
fprintf(self->dumper.out," size = %lu;\n", (unsigned long)size);
fprintf(self->dumper.out," rvalues = (double*)malloc(size * sizeof(double));\n");
fprintf(self->dumper.out," if (!rvalues) { fprintf(stderr, \"Failed to allocate memory (rvalues).\\n\"); return 1; }");
fprintf(self->dumper.out," if (!rvalues) { fprintf(stderr, \"Failed to allocate memory (%s).\\n\"); return 1; }",a->name);
icount=0;
for (i=0; i<size-1; ++i) {
@ -326,10 +326,12 @@ static void dump_long(grib_dumper* d,grib_accessor* a, const char* comment)
char* sval = NULL;
grib_context* c=a->context;
grib_handle* h=grib_handle_of_accessor(a);
int doing_unexpandedDescriptors=0;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 )
return;
doing_unexpandedDescriptors = (strcmp(a->name, "unexpandedDescriptors")==0);
grib_value_count(a,&count);
size=count;
@ -365,7 +367,7 @@ static void dump_long(grib_dumper* d,grib_accessor* a, const char* comment)
fprintf(self->dumper.out," free(ivalues); ivalues = NULL;\n\n");
fprintf(self->dumper.out," size = %lu;\n", (unsigned long)size);
fprintf(self->dumper.out," ivalues = (long*)malloc(size * sizeof(long));\n");
fprintf(self->dumper.out," if (!ivalues) { fprintf(stderr, \"Failed to allocate memory (ivalues).\\n\"); return 1; }");
fprintf(self->dumper.out," if (!ivalues) { fprintf(stderr, \"Failed to allocate memory (%s).\\n\"); return 1; }",a->name);
icount=0;
for (i=0;i<size-1;i++) {
@ -380,20 +382,23 @@ static void dump_long(grib_dumper* d,grib_accessor* a, const char* comment)
fprintf(self->dumper.out,"\n");
grib_context_free(a->context,values);
if ((r=compute_bufr_key_rank(h,self->keys,a->name))!=0)
if ((r=compute_bufr_key_rank(h,self->keys,a->name))!=0) {
fprintf(self->dumper.out," CODES_CHECK(codes_set_long_array(h, \"#%d#%s\", ivalues, size), 0);\n",r,a->name);
else
} else {
if (doing_unexpandedDescriptors) {
fprintf(self->dumper.out,"\n /* Create the structure of the data section */\n");
}
fprintf(self->dumper.out," CODES_CHECK(codes_set_long_array(h, \"%s\", ivalues, size), 0);\n",a->name);
if (doing_unexpandedDescriptors) fprintf(self->dumper.out,"\n");
}
} else {
int doing_unexpandedDescriptors=0;
r=compute_bufr_key_rank(h,self->keys,a->name);
sval=lval_to_string(c,value);
if (r!=0) {
fprintf(self->dumper.out," CODES_CHECK(codes_set_long(h, \"#%d#%s\", ", r,a->name);
} else {
if (strcmp(a->name, "unexpandedDescriptors")==0) {
doing_unexpandedDescriptors=1;
if (doing_unexpandedDescriptors) {
fprintf(self->dumper.out,"\n /* Create the structure of the data section */\n");
}
fprintf(self->dumper.out," CODES_CHECK(codes_set_long(h, \"%s\", ", a->name);
@ -401,8 +406,7 @@ static void dump_long(grib_dumper* d,grib_accessor* a, const char* comment)
fprintf(self->dumper.out,"%s), 0);\n",sval);
grib_context_free(c,sval);
if (doing_unexpandedDescriptors)
fprintf(self->dumper.out,"\n");
if (doing_unexpandedDescriptors) fprintf(self->dumper.out,"\n");
}
if (self->isLeaf==0) {
@ -452,7 +456,7 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
fprintf(self->dumper.out," free(ivalues); ivalues = NULL;\n");
fprintf(self->dumper.out," size = %lu;\n", (unsigned long)size);
fprintf(self->dumper.out," ivalues = (long*)malloc(size * sizeof(long));\n");
fprintf(self->dumper.out," if (!ivalues) { fprintf(stderr, \"Failed to allocate memory (ivalues).\\n\"); return 1; }");
fprintf(self->dumper.out," if (!ivalues) { fprintf(stderr, \"Failed to allocate memory (%s).\\n\"); return 1; }", a->name);
icount=0;
for (i=0;i<size-1;i++) {
@ -558,7 +562,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
fprintf(self->dumper.out," free(svalues);\n");
fprintf(self->dumper.out," size = %lu;\n", (unsigned long)size);
fprintf(self->dumper.out," svalues = (char**)malloc(size * sizeof(char*));\n");
fprintf(self->dumper.out," if (!svalues) { fprintf(stderr, \"Failed to allocate memory (svalues).\\n\"); return 1; }\n");
fprintf(self->dumper.out," if (!svalues) { fprintf(stderr, \"Failed to allocate memory (%s).\\n\"); return 1; }\n",a->name);
self->empty=0;
values=(char**)grib_context_malloc_clear(c,size*sizeof(char*));
@ -680,7 +684,7 @@ static void _dump_long_array(grib_handle* h, FILE* f, const char* key, const cha
fprintf(f," free(ivalues); ivalues = NULL;\n");
fprintf(f," size = %lu;\n", (unsigned long)size);
fprintf(f," ivalues = (long*)malloc(size * sizeof(long));\n");
fprintf(f," if (!ivalues) { fprintf(stderr, \"Failed to allocate memory (ivalues).\\n\"); return 1; }");
fprintf(f," if (!ivalues) { fprintf(stderr, \"Failed to allocate memory (%s).\\n\"); return 1; }",key);
val=(long*)grib_context_malloc_clear(h->context,sizeof(long)*size);
grib_get_long_array(h,key,val,&size);
@ -818,7 +822,7 @@ static void footer(grib_dumper* d, grib_handle* h)
/*fprintf(self->dumper.out," fout = fopen(\"outfile.bufr\", \"w\");");*/
fprintf(self->dumper.out," if (!fout) {\n");
fprintf(self->dumper.out," fprintf(stderr, \"Failed to open (create) output file.\\n\");\n");
fprintf(self->dumper.out," fprintf(stderr, \"Failed to open (%s) output file.\\n\");\n", (d->count==1?"create":"append"));
fprintf(self->dumper.out," return 1;\n");
fprintf(self->dumper.out," }\n");
fprintf(self->dumper.out," CODES_CHECK(codes_get_message(h,&buffer,&size),0);\n");
@ -832,7 +836,8 @@ static void footer(grib_dumper* d, grib_handle* h)
fprintf(self->dumper.out," }\n");
fprintf(self->dumper.out," \n");
fprintf(self->dumper.out," codes_handle_delete(h);\n");
fprintf(self->dumper.out," printf(\"Created output BUFR file 'outfile.bufr'.\\n\");\n");
if (d->count==1)
fprintf(self->dumper.out," printf(\"Created output BUFR file 'outfile.bufr'.\\n\");\n");
fprintf(self->dumper.out," free(ivalues); ivalues = NULL;\n");
fprintf(self->dumper.out," free(rvalues); rvalues = NULL;\n");
fprintf(self->dumper.out," free(svalues); svalues = NULL;\n\n");

View File

@ -174,12 +174,11 @@ static char* dval_to_string(grib_context* c, double v)
static char* break_line(grib_context* c, const char* input)
{
/* Break a long line using Fortran continuation characters */
char* result=NULL;
char* a_token = NULL;
int first = 1;
const size_t len = strlen(input);
/* Add a bit more for inserted newlines and continuation characters */
result = (char*)grib_context_malloc_clear(c,sizeof(char)*len+100);
char* result = (char*)grib_context_malloc_clear(c,sizeof(char)*len+100);
/* No need to alter input which is already too short or has newlines */
if (len < 70 || strchr(input, '\n')) {
@ -376,9 +375,11 @@ static void dump_long(grib_dumper* d,grib_accessor* a, const char* comment)
char* sval = NULL;
grib_context* c=a->context;
grib_handle* h=grib_handle_of_accessor(a);
int doing_unexpandedDescriptors=0;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 ) return;
doing_unexpandedDescriptors = (strcmp(a->name, "unexpandedDescriptors")==0);
grib_value_count(a,&count);
size=count;
@ -428,20 +429,23 @@ static void dump_long(grib_dumper* d,grib_accessor* a, const char* comment)
fprintf(self->dumper.out,"/)\n");
grib_context_free(a->context,values);
if ((r=compute_bufr_key_rank(h,self->keys,a->name))!=0)
if ((r=compute_bufr_key_rank(h,self->keys,a->name))!=0) {
fprintf(self->dumper.out," call codes_set(ibufr,'#%d#%s',ivalues)\n",r,a->name);
else
} else {
if (doing_unexpandedDescriptors) {
fprintf(self->dumper.out,"\n ! Create the structure of the data section\n");
}
fprintf(self->dumper.out," call codes_set(ibufr,'%s',ivalues)\n",a->name);
if (doing_unexpandedDescriptors) fprintf(self->dumper.out,"\n");
}
} else {
int doing_unexpandedDescriptors=0;
r=compute_bufr_key_rank(h,self->keys,a->name);
sval=lval_to_string(c,value);
if (r!=0) {
fprintf(self->dumper.out," call codes_set(ibufr,'#%d#%s',",r,a->name);
} else {
if (strcmp(a->name, "unexpandedDescriptors")==0) {
doing_unexpandedDescriptors=1;
if (doing_unexpandedDescriptors) {
fprintf(self->dumper.out,"\n ! Create the structure of the data section\n");
}
fprintf(self->dumper.out," call codes_set(ibufr,'%s',",a->name);
@ -449,8 +453,7 @@ static void dump_long(grib_dumper* d,grib_accessor* a, const char* comment)
fprintf(self->dumper.out,"%s)\n",sval);
grib_context_free(c,sval);
if (doing_unexpandedDescriptors)
fprintf(self->dumper.out,"\n");
if (doing_unexpandedDescriptors) fprintf(self->dumper.out,"\n");
}
if (self->isLeaf==0) {
@ -592,14 +595,12 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
grib_dumper_bufr_encode_fortran *self = (grib_dumper_bufr_encode_fortran*)d;
char **values;
size_t size = 0,i=0;
grib_context* c=NULL;
grib_context* c=a->context;
int err = 0;
long count=0;
int r = 0;
grib_handle* h=grib_handle_of_accessor(a);
c=a->context;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
return;
@ -662,12 +663,11 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
char *value=NULL;
char *p = NULL;
size_t size = 0;
grib_context* c=NULL;
grib_context* c=a->context;
int r;
int err = _grib_get_string_length(a,&size);
grib_handle* h=grib_handle_of_accessor(a);
c=a->context;
if (size==0) return;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
@ -874,7 +874,8 @@ static void footer(grib_dumper* d, grib_handle* h)
fprintf(self->dumper.out," call codes_write(ibufr,outfile)\n");
fprintf(self->dumper.out," call codes_close_file(outfile)\n");
fprintf(self->dumper.out," call codes_release(ibufr)\n");
fprintf(self->dumper.out," print *, \"Created output BUFR file 'outfile.bufr'\"\n");
if (d->count==1)
fprintf(self->dumper.out," print *, \"Created output BUFR file 'outfile.bufr'\"\n");
fprintf(self->dumper.out," if(allocated(ivalues)) deallocate(ivalues)\n");
fprintf(self->dumper.out," if(allocated(rvalues)) deallocate(rvalues)\n");
fprintf(self->dumper.out," if(allocated(svalues)) deallocate(svalues)\n");

View File

@ -323,9 +323,11 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
char* sval = NULL;
grib_context* c=a->context;
grib_handle* h=grib_handle_of_accessor(a);
int doing_unexpandedDescriptors=0;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 ) return;
doing_unexpandedDescriptors = (strcmp(a->name, "unexpandedDescriptors")==0);
grib_value_count(a,&count);
size=count;
@ -373,20 +375,22 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
fprintf(self->dumper.out,",)\n");
grib_context_free(a->context,values);
if ((r=compute_bufr_key_rank(h,self->keys,a->name))!=0)
if ((r=compute_bufr_key_rank(h,self->keys,a->name))!=0) {
fprintf(self->dumper.out," codes_set_array(ibufr, '#%d#%s', ivalues)\n",r,a->name);
else
} else {
if (doing_unexpandedDescriptors) {
fprintf(self->dumper.out,"\n # Create the structure of the data section\n");
}
fprintf(self->dumper.out," codes_set_array(ibufr, '%s', ivalues)\n",a->name);
if (doing_unexpandedDescriptors) fprintf(self->dumper.out,"\n");
}
} else {
int doing_unexpandedDescriptors=0;
r=compute_bufr_key_rank(h,self->keys,a->name);
sval=lval_to_string(c,value);
if (r!=0) {
fprintf(self->dumper.out," codes_set(ibufr, '#%d#%s', ",r,a->name);
} else {
if (strcmp(a->name, "unexpandedDescriptors")==0) {
doing_unexpandedDescriptors=1;
if (doing_unexpandedDescriptors) {
fprintf(self->dumper.out,"\n # Create the structure of the data section\n");
}
fprintf(self->dumper.out," codes_set(ibufr, '%s', ",a->name);
@ -394,8 +398,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
fprintf(self->dumper.out,"%s)\n",sval);
grib_context_free(c,sval);
if (doing_unexpandedDescriptors)
fprintf(self->dumper.out,"\n");
if (doing_unexpandedDescriptors) fprintf(self->dumper.out,"\n");
}
if (self->isLeaf==0) {
@ -445,11 +448,11 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
fprintf(self->dumper.out," ivalues = (");
icount=0;
for (i=0;i<size-1;i++) {
if (icount>cols || i==0) {fprintf(self->dumper.out," \n ");icount=0;}
if (icount>cols || i==0) {fprintf(self->dumper.out," \n ");icount=0;}
fprintf(self->dumper.out,"%ld, ",values[i]);
icount++;
}
if (icount>cols || i==0) {fprintf(self->dumper.out," \n ");icount=0;}
if (icount>cols || i==0) {fprintf(self->dumper.out," \n ");icount=0;}
fprintf(self->dumper.out,"%ld ",values[i]);
depth-=2;
@ -457,11 +460,11 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
fprintf(self->dumper.out,",)\n");
grib_context_free(a->context,values);
fprintf(self->dumper.out," codes_set_array(ibufr, '%s->%s' \n,ivalues)\n",prefix,a->name);
fprintf(self->dumper.out," codes_set_array(ibufr, '%s->%s', ivalues)\n",prefix,a->name);
} else {
char* sval=lval_to_string(c,value);
fprintf(self->dumper.out," codes_set(ibufr, '%s->%s'\n,",prefix,a->name);
fprintf(self->dumper.out," codes_set(ibufr, '%s->%s', ",prefix,a->name);
fprintf(self->dumper.out,"%s)\n",sval);
grib_context_free(c,sval);
}
@ -529,14 +532,12 @@ static void dump_string_array(grib_dumper* d,grib_accessor* a,const char* commen
grib_dumper_bufr_encode_python *self = (grib_dumper_bufr_encode_python*)d;
char **values;
size_t size = 0,i=0;
grib_context* c=NULL;
grib_context* c=a->context;
int err = 0;
long count=0;
int r=0;
grib_handle* h=grib_handle_of_accessor(a);
c=a->context;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0 )
return;
@ -596,12 +597,11 @@ static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
char *value=NULL;
char *p = NULL;
size_t size = 0;
grib_context* c=NULL;
grib_context* c=a->context;
int r;
int err = _grib_get_string_length(a,&size);
grib_handle* h=grib_handle_of_accessor(a);
c=a->context;
if (size==0) return;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
@ -675,11 +675,11 @@ static void _dump_long_array(grib_handle* h, FILE* f, const char* key, const cha
val=(long*)grib_context_malloc_clear(h->context,sizeof(long)*size);
grib_get_long_array(h,key,val,&size);
for (i=0;i<size-1;i++) {
if (icount>cols || i==0) {fprintf(f," \n ");icount=0;}
if (icount>cols || i==0) {fprintf(f," \n ");icount=0;}
fprintf(f,"%ld, ",val[i]);
icount++;
}
if (icount>cols) {fprintf(f," \n ");}
if (icount>cols) {fprintf(f," \n ");}
/* Note: In python to make a tuple with one element, you need the trailing comma */
fprintf(f,"%ld ,)\n",val[size-1]);
@ -776,6 +776,7 @@ static void header(grib_dumper* d, grib_handle* h)
fprintf(self->dumper.out, "# Using ecCodes version: ");
grib_print_api_version(self->dumper.out);
fprintf(self->dumper.out, "\n\n");
fprintf(self->dumper.out,"from __future__ import print_function\n");
fprintf(self->dumper.out,"import traceback\n");
fprintf(self->dumper.out,"import sys\n");
fprintf(self->dumper.out,"from eccodes import *\n\n\n");
@ -795,7 +796,8 @@ static void footer(grib_dumper* d, grib_handle* h)
fprintf(self->dumper.out," outfile = open('outfile.bufr', 'a')\n");
fprintf(self->dumper.out," codes_write(ibufr, outfile)\n");
fprintf(self->dumper.out," print \"Created output BUFR file 'outfile.bufr'.\"\n");
if (d->count==1)
fprintf(self->dumper.out," print (\"Created output BUFR file 'outfile.bufr'\")\n");
/*fprintf(self->dumper.out," codes_close_file(outfile)\n");*/
fprintf(self->dumper.out," codes_release(ibufr)\n");
}

View File

@ -110,8 +110,6 @@ struct string_count {
string_count* next;
};
static int depth=0;
static void init_class (grib_dumper_class* c){}
static int init(grib_dumper* d)
@ -188,7 +186,6 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
if (icount>cols || i==0) {fprintf(self->dumper.out,"\n ");icount=0;}
fprintf(self->dumper.out, "%g",values[i]);
depth-=2;
fprintf(self->dumper.out,"}\n");
grib_context_free(c,values);
} else {
@ -217,7 +214,6 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
dump_attributes(d,a,prefix);
if (dofree) grib_context_free(c,prefix);
depth-=2;
}
(void)err; /* TODO */
@ -260,7 +256,6 @@ static void dump_values_attribute(grib_dumper* d,grib_accessor* a, const char* p
if (icount>cols || i==0) {fprintf(self->dumper.out,"\n ");icount=0;}
fprintf(self->dumper.out,"%g", values[i]);
depth-=2;
fprintf(self->dumper.out,"}\n");
grib_context_free(c,values);
} else {
@ -281,7 +276,6 @@ static void dump_values_attribute(grib_dumper* d,grib_accessor* a, const char* p
dump_attributes(d,a,prefix1);
grib_context_free(c,prefix1);
depth-=2;
}
(void)err; /* TODO */
@ -319,7 +313,6 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
dump_attributes(d,a,prefix);
if (dofree) grib_context_free(c,prefix);
depth-=2;
}
return;
}
@ -360,7 +353,6 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
else
fprintf(self->dumper.out,"%ld ",values[i]);
depth-=2;
fprintf(self->dumper.out,"}\n");
grib_context_free(a->context,values);
} else {
@ -389,7 +381,6 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
dump_attributes(d,a,prefix);
if (dofree) grib_context_free(c,prefix);
depth-=2;
}
(void)err; /* TODO */
}
@ -430,7 +421,6 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
}
if (icount>cols || i==0) {fprintf(self->dumper.out,"\n ");icount=0;}
fprintf(self->dumper.out,"%ld ",values[i]);
depth-=2;
fprintf(self->dumper.out,"}\n");
grib_context_free(a->context,values);
@ -453,7 +443,6 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
dump_attributes(d,a,prefix1);
grib_context_free(c,prefix1);
depth-=2;
}
(void)err; /* TODO */
}
@ -502,7 +491,6 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment)
dump_attributes(d,a,prefix);
if (dofree) grib_context_free(c,prefix);
depth-=2;
}
}
@ -530,7 +518,6 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
self->begin=0;
if (self->isLeaf==0) {
depth+=2;
if ((r=compute_bufr_key_rank(h,self->keys,a->name))!=0)
fprintf(self->dumper.out,"#%d#%s=",r,a->name);
else
@ -548,14 +535,11 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
err = grib_unpack_string_array(a,values,&size);
fprintf(self->dumper.out, "{");
depth+=2;
for (i=0;i<size-1;i++) {
fprintf(self->dumper.out," \"%s\",\n",values[i]);
}
fprintf(self->dumper.out," \"%s\"\n",values[i]);
depth-=2;
fprintf(self->dumper.out, "}\n");
if (self->isLeaf==0) {
@ -570,7 +554,6 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
dump_attributes(d,a,prefix);
if (dofree) grib_context_free(c,prefix);
depth-=2;
}
grib_context_free(c,values);
@ -615,7 +598,6 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
while(*p) { if(!isprint(*p)) *p = '.'; p++; }
if (self->isLeaf==0) {
depth+=2;
if (r!=0)
fprintf(self->dumper.out,"#%d#%s=",r,a->name);
else
@ -636,7 +618,6 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
dump_attributes(d,a,prefix);
if (dofree) grib_context_free(c,prefix);
depth-=2;
}
grib_context_free(c,value);
@ -682,10 +663,8 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
!grib_inline_strcmp(a->name,"META")
) {
grib_handle* h=grib_handle_of_accessor(a);
depth=2;
self->begin=1;
self->empty=1;
depth+=2;
_dump_long_array(h,self->dumper.out,"dataPresentIndicator");
_dump_long_array(h,self->dumper.out,"delayedDescriptorReplicationFactor");
_dump_long_array(h,self->dumper.out,"shortDelayedDescriptorReplicationFactor");
@ -693,15 +672,12 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
/* Do not show the inputOverriddenReferenceValues array. That's more for ENCODING */
/*_dump_long_array(h,self->dumper.out,"inputOverriddenReferenceValues","inputOverriddenReferenceValues");*/
grib_dump_accessors_block(d,block);
depth-=2;
} else if (!grib_inline_strcmp(a->name,"groupNumber")) {
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return;
self->begin=1;
self->empty=1;
depth+=2;
grib_dump_accessors_block(d,block);
depth-=2;
} else {
grib_dump_accessors_block(d,block);
}

View File

@ -280,10 +280,9 @@ static void dump_bits(grib_dumper* d,grib_accessor* a,const char* comment)
static void dump_double(grib_dumper* d,grib_accessor* a,const char* comment)
{
grib_dumper_default *self = (grib_dumper_default*)d;
double value; size_t size = 1;
double value=0; size_t size = 1;
int err = grib_unpack_double(a,&value,&size);
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return;
@ -312,7 +311,6 @@ static void dump_double(grib_dumper* d,grib_accessor* a,const char* comment)
else
fprintf(self->dumper.out,"%s = %g;",a->name,value);
if(err) {
fprintf(self->dumper.out," ");
fprintf(self->dumper.out,"# *** ERR=%d (%s) [grib_dumper_default::dump_double]",err,grib_get_error_message(err));
@ -351,7 +349,6 @@ static void dump_string_array(grib_dumper* d,grib_accessor* a,const char* commen
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return;
print_offset(self->dumper.out,d,a);
if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) {
@ -531,7 +528,7 @@ static void dump_values(grib_dumper* d,grib_accessor* a)
grib_dumper_default *self = (grib_dumper_default*)d;
int k,err =0;
int more = 0;
double* buf = NULL;
double* buf = NULL;
size_t size=0;
long count=0;
@ -649,9 +646,7 @@ static void dump_section(grib_dumper* d,grib_accessor* a,grib_block_of_accessors
*q='\0';
sprintf(tmp,"%s ( length=%ld, padding=%ld )",upper,(long)s->length,(long)s->padding);
/*
fprintf(self->dumper.out,"#============== %-38s ==============\n",tmp);
*/
/* fprintf(self->dumper.out,"#============== %-38s ==============\n",tmp); */
free(upper);
self->section_offset=a->offset;
}

View File

@ -411,34 +411,38 @@ static void dump_string_array(grib_dumper* d,grib_accessor* a,const char* commen
(void)err; /* TODO */
}
# define MAX_STRING_SIZE 4096
static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
{
grib_dumper_json *self = (grib_dumper_json*)d;
char *value = NULL;
char value[MAX_STRING_SIZE] = {0,}; /* See ECC-710 */
char *p = NULL;
size_t size = 0;
size_t size = MAX_STRING_SIZE;
int is_missing = 0;
grib_context* c = NULL;
int err = _grib_get_string_length(a,&size);
int err = 0;
c = a->context;
if (size==0) return;
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return;
value=(char*)grib_context_malloc_clear(c,size);
if (!value) {
grib_context_log(c,GRIB_LOG_FATAL,"unable to allocate %d bytes",(int)size);
if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) {
return;
}
/* ECC-710: It is MUCH slower determining the string length here
* than using a maximum size (and no need for malloc).
* Specially for BUFR elements */
/*err = _grib_get_string_length(a,&size);
if (size==0) return;
value=(char*)grib_context_malloc_clear(a->context,size);
if (!value) {
grib_context_log(a->context,GRIB_LOG_FATAL,"unable to allocate %d bytes",(int)size);
return;
}*/
if (self->begin==0 && self->empty==0 && self->isAttribute==0) fprintf(self->dumper.out,",");
else self->begin=0;
self->empty=0;
err = grib_unpack_string(a,value,&size);
Assert(size < MAX_STRING_SIZE);
p=value;
if (grib_is_missing_string(a,(unsigned char *)value,size)) {
is_missing = 1;
@ -465,7 +469,7 @@ static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
fprintf(self->dumper.out,"\n%-*s}",depth," ");
}
grib_context_free(c,value);
/*grib_context_free(a->context,value);*/
(void)err; /* TODO */
}

View File

@ -144,6 +144,10 @@ static void dump_long(grib_dumper* d,grib_accessor* a,const char* comment)
int err = 0, i = 0;
long count = 0;
if( a->length == 0 &&
(d->option_flags & GRIB_DUMP_FLAG_CODED) != 0)
return;
grib_value_count(a,&count);
size=count;
@ -154,10 +158,6 @@ static void dump_long(grib_dumper* d,grib_accessor* a,const char* comment)
err=grib_unpack_long(a,&value,&size);
}
if( a->length == 0 &&
(d->option_flags & GRIB_DUMP_FLAG_CODED) != 0)
return;
if( (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0 &&
(d->option_flags & GRIB_DUMP_FLAG_READ_ONLY) == 0)
return;
@ -208,12 +208,13 @@ static void dump_bits(grib_dumper* d,grib_accessor* a,const char* comment)
grib_dumper_wmo *self = (grib_dumper_wmo*)d;
int i;
long value = 0; size_t size = 1;
int err = grib_unpack_long(a,&value,&size);
int err = 0;
if( a->length == 0 &&
(d->option_flags & GRIB_DUMP_FLAG_CODED) != 0)
return;
err = grib_unpack_long(a,&value,&size);
set_begin_end(d,a);
/*for(i = 0; i < d->depth ; i++) fprintf(self->dumper.out," ");*/
@ -249,13 +250,13 @@ static void dump_double(grib_dumper* d,grib_accessor* a,const char* comment)
{
grib_dumper_wmo *self = (grib_dumper_wmo*)d;
double value=0; size_t size = 1;
int err = grib_unpack_double(a,&value,&size);
int err = 0;
if( a->length == 0 &&
(d->option_flags & GRIB_DUMP_FLAG_CODED) != 0)
return;
err = grib_unpack_double(a,&value,&size);
set_begin_end(d,a);
/*for(i = 0; i < d->depth ; i++) fprintf(self->dumper.out," ");*/
@ -284,8 +285,14 @@ static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
size_t size=0;
char *value=NULL;
char *p=NULL;
int err = _grib_get_string_length(a,&size);
int err = 0;
if( a->length == 0 &&
(d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) {
return;
}
err = _grib_get_string_length(a,&size);
value=(char*)grib_context_malloc_clear(a->context,size);
if (!value) {
grib_context_log(a->context,GRIB_LOG_FATAL,"unable to allocate %d bytes",(int)size);
@ -294,12 +301,6 @@ static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
err=grib_unpack_string(a,value,&size);
p=value;
if( a->length == 0 &&
(d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) {
grib_context_free(a->context,value);
return;
}
set_begin_end(d,a);
while(*p) { if(!isprint(*p)) *p = '.'; p++; }

View File

@ -119,7 +119,7 @@ static string evaluate_string(grib_expression* g,grib_handle* h,char* buf,size_t
{
grib_expression_column* e = (grib_expression_column*)g;
Assert(buf);
if((err=grib_get_string_internal(h,e->name,buf,size)) != GRIB_SUCCESS)
if((*err=grib_get_string_internal(h,e->name,buf,size)) != GRIB_SUCCESS)
{
grib_context_log(h->context, GRIB_LOG_DEBUG,
"Error in evaluate_string %s : %s", e->name,grib_get_error_message(err));

View File

@ -43,15 +43,15 @@ static Fraction_value_type fraction_gcd(Fraction_value_type a, Fraction_value_ty
static Fraction_type fraction_construct(Fraction_value_type top, Fraction_value_type bottom)
{
Fraction_type result;
Assert(bottom != 0);
/* @note in theory we also assume that numerator and denominator are both representable in
* double without loss
* ASSERT(top == Fraction_value_type(double(top)));
* ASSERT(bottom == Fraction_value_type(double(bottom)));
*/
Fraction_value_type g;
Fraction_value_type sign = 1;
Assert(bottom != 0);
if (top < 0) {
top = -top;
sign = -sign;
@ -62,7 +62,7 @@ static Fraction_type fraction_construct(Fraction_value_type top, Fraction_value_
sign = -sign;
}
Fraction_value_type g = fraction_gcd(top, bottom);
g = fraction_gcd(top, bottom);
top = top / g;
bottom = bottom / g;
@ -75,24 +75,23 @@ static Fraction_type fraction_construct_from_double(double x)
{
Fraction_type result;
double value = x;
Fraction_value_type sign = 1;
Fraction_value_type m00 = 1, m11 = 1, m01 = 0, m10 = 0;
Fraction_value_type a = x;
Fraction_value_type t2, top, bottom, g;
size_t cnt = 0;
Assert(x != NAN);
/*Assert(x != NAN);*/
Assert(fabs(x) < 1e30);
Fraction_value_type sign = 1;
if (x < 0) {
sign = -sign;
x = -x;
}
Fraction_value_type m00 = 1, m11 = 1, m01 = 0, m10 = 0;
Fraction_value_type a = x;
Fraction_value_type t2 = m10 * a + m11;
size_t cnt = 0;
t2 = m10 * a + m11;
while (t2 <= MAX_DENOM) {
Fraction_value_type t1 = m00 * a + m01;
m01 = m00;
m00 = t1;
@ -123,10 +122,10 @@ static Fraction_type fraction_construct_from_double(double x)
m10 >>= 1;
}
Fraction_value_type top = m00;
Fraction_value_type bottom = m10;
top = m00;
bottom = m10;
Fraction_value_type g = fraction_gcd(top, bottom);
g = fraction_gcd(top, bottom);
top = top / g;
bottom = bottom / g;
@ -257,20 +256,23 @@ static void gaussian_reduced_row(
double* pLon1,
double* pLon2)
{
Assert(Ni_globe > 1);
Fraction_type inc = fraction_construct(360ll, Ni_globe);
Fraction_value_type Nw, Ne;
Fraction_type inc, Nw_inc, Ne_inc;
inc = fraction_construct(360ll, Ni_globe);
/* auto Nw = (w / inc).integralPart(); */
Fraction_value_type Nw = fraction_integralPart( fraction_operator_divide(w, inc) );
Fraction_type Nw_inc = fraction_operator_multiply_n_Frac(Nw, inc);
Nw = fraction_integralPart( fraction_operator_divide(w, inc) );
Nw_inc = fraction_operator_multiply_n_Frac(Nw, inc);
Assert(Ni_globe > 1);
/*if (Nw * inc < w) {*/
if (fraction_operator_less_than(Nw_inc, w)) {
Nw += 1;
}
/*auto Ne = (e / inc).integralPart();*/
Fraction_value_type Ne = fraction_integralPart( fraction_operator_divide(e, inc) );
Fraction_type Ne_inc = fraction_operator_multiply_n_Frac(Ne, inc);
Ne = fraction_integralPart( fraction_operator_divide(e, inc) );
Ne_inc = fraction_operator_multiply_n_Frac(Ne, inc);
/* if (Ne * inc > e) */
if (fraction_operator_greater_than(Ne_inc, e)) {
Ne -= 1;
@ -412,3 +414,27 @@ void grib_get_reduced_row2(long pl, double lon_first, double lon_last, long* npo
*ilon_first = (the_lon1*pl)/360.0;
*ilon_last = (the_lon2*pl)/360.0;
}
void grib_get_reduced_row3(long pl, double lon_first, double lon_last, long *npoints, double *olon_first, double *olon_last)
{
long long Ni_globe = pl;
Fraction_type west;
Fraction_type east;
long long the_count;
double the_lon1, the_lon2;
while (lon_last < lon_first) lon_last += 360;
west = fraction_construct_from_double(lon_first);
east = fraction_construct_from_double(lon_last);
gaussian_reduced_row(
Ni_globe, /*plj*/
west, /*lon_first*/
east, /*lon_last*/
&the_count,
&the_lon1,
&the_lon2);
*npoints = (long)the_count;
*olon_first = the_lon1;
*olon_last = the_lon2;
}

View File

@ -598,8 +598,6 @@ static grib_index_key* grib_read_index_keys(grib_context* c,FILE* fh,int *err)
if (*err) return NULL;
keys->values_count=values_count;
if (*err) return NULL;
keys->next=grib_read_index_keys(c,fh,err);
if (*err) return NULL;

View File

@ -694,6 +694,10 @@ static int read_BUFR(reader *r)
i++;
}
if(length==0) {
return GRIB_INVALID_MESSAGE;
}
/* Edition number */
if(r->read(r->read_data,&tmp[i],1,&err) != 1 || err)
return err;
@ -899,7 +903,7 @@ static int read_any_gts(reader *r)
unsigned long magic = 0;
unsigned long start = 0x010d0d0a;
unsigned long theEnd = 0x0d0d0a03;
unsigned char tmp[32]={0,}; /* Should be enough */
unsigned char tmp[128]={0,}; /* See ECC-735 */
size_t message_size=0;
size_t already_read=0;
int i=0;

View File

@ -126,6 +126,52 @@ static size_t count_subarea_points(grib_handle* h, get_reduced_row_proc get_redu
return result;
}
/* ECC-747 */
static int iterate_reduced_gaussian_subarea_algorithm2(grib_iterator* iter, grib_handle* h,
double lat_first, double lon_first,
double lat_last, double lon_last,
double* lats, long* pl, size_t plsize)
{
int err = 0;
int l = 0;
size_t j = 0;
long row_count=0, i=0;
double d=0;
double olon_first, olon_last;
grib_iterator_gaussian_reduced* self = (grib_iterator_gaussian_reduced*)iter;
get_reduced_row_proc get_reduced_row = &grib_get_reduced_row;
if (h->context->debug) {
const size_t np = count_subarea_points(h, get_reduced_row, pl, plsize, lon_first, lon_last);
printf("ECCODES DEBUG grib_iterator_class_gaussian_reduced: sub-area num points=%ld\n", (long)np);
}
/*find starting latitude */
d = fabs(lats[0] - lats[1]);
while (fabs(lat_first-lats[l]) > d ) {l++;}
iter->e=0;
for (j=0;j<plsize;j++) {
const double delta = 360.0/pl[j];
row_count=0;
grib_get_reduced_row3(pl[j],lon_first,lon_last, &row_count,&olon_first,&olon_last);
for(i=0; i<row_count; ++i) {
double lon2 = olon_first + i * delta;
if(iter->e >= iter->nv){
/* Only print error message on the second pass */
size_t np = count_subarea_points(h, get_reduced_row, pl, plsize, lon_first, lon_last);
grib_context_log(h->context,GRIB_LOG_ERROR,
"Reduced Gaussian iterator (sub-area). Num points=%ld, size(values)=%ld", np, iter->nv);
return GRIB_WRONG_GRID;
}
self->los[iter->e]=lon2;
self->las[iter->e]=lats[j+l];
iter->e++;
}
}
return err;
}
/* ECC-445: Try to compute the iterator latitude/longitude values. If algorithm2 is set, try a different point count */
static int iterate_reduced_gaussian_subarea(grib_iterator* iter, grib_handle* h,
double lat_first, double lon_first,
@ -146,7 +192,7 @@ static int iterate_reduced_gaussian_subarea(grib_iterator* iter, grib_handle* h,
if (h->context->debug) {
const size_t np = count_subarea_points(h, get_reduced_row, pl, plsize, lon_first, lon_last);
printf("ECCODES DEBUG grib_iterator_class_gaussian_reduced: sub-area num points=%ld\n", np);
printf("ECCODES DEBUG grib_iterator_class_gaussian_reduced: sub-area num points=%ld\n", (long)np);
}
/*find starting latitude */
@ -192,14 +238,14 @@ static int iterate_reduced_gaussian_subarea_wrapper(grib_iterator* iter, grib_ha
{
int err = 0;
if (expandedBoundingBox(h)) {
return iterate_reduced_gaussian_subarea(iter, h, lat_first, lon_first, lat_last, lon_last, lats, pl, plsize, 1);
return iterate_reduced_gaussian_subarea_algorithm2(iter, h, lat_first, lon_first, lat_last, lon_last, lats, pl, plsize);
}
/* Try legacy approach, if that fails try the next algorithm */
err = iterate_reduced_gaussian_subarea(iter, h, lat_first, lon_first, lat_last, lon_last, lats, pl, plsize, 0);
if (err == GRIB_WRONG_GRID) {
/* ECC-445: First attempt failed. Try again with a different algorithm */
err = iterate_reduced_gaussian_subarea(iter, h, lat_first, lon_first, lat_last, lon_last, lats, pl, plsize, 1);
err = iterate_reduced_gaussian_subarea_algorithm2(iter, h, lat_first, lon_first, lat_last, lon_last, lats, pl, plsize);
}
return err;
}
@ -282,7 +328,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
iter->e=0;
if (h->context->debug) {
const size_t np = count_global_points(pl, plsize);
printf("ECCODES DEBUG grib_iterator_class_gaussian_reduced: global num points=%ld\n", np);
printf("ECCODES DEBUG grib_iterator_class_gaussian_reduced: global num points=%ld\n", (long)np);
}
for (j=0;j<plsize;j++) {

View File

@ -97,7 +97,8 @@ static void init_class(grib_iterator_class* c)
/* END_CLASS_IMP */
static int next(grib_iterator* i, double *lat, double *lon, double *val){
static int next(grib_iterator* i, double *lat, double *lon, double *val)
{
grib_iterator_regular* self = (grib_iterator_regular*)i;
if((long)i->e >= (long)(i->nv-1)) return 0;
@ -111,7 +112,8 @@ static int next(grib_iterator* i, double *lat, double *lon, double *val){
return 1;
}
static int previous(grib_iterator* i, double *lat, double *lon, double *val){
static int previous(grib_iterator* i, double *lat, double *lon, double *val)
{
grib_iterator_regular* self = (grib_iterator_regular*)i;
if(i->e < 0) return 0;
@ -178,12 +180,11 @@ static int init(grib_iterator* i,grib_handle* h,grib_arguments* args)
if (self->iScansNegatively) {
idir=-idir;
} else {
const double epsilon = 1e-6;
if (lon1+(Ni-2)*idir>360) lon1-=360;
else if ( (lon1+(Ni-1)*idir)-360 > epsilon ){
/*See GRIB-396*/
/*See ECC-704, GRIB-396*/
/*else if ( (lon1+(Ni-1)*idir)-360 > epsilon ){
idir=360.0/(float)Ni;
}
}*/
}
self->nap = Ni;

View File

@ -340,7 +340,7 @@ static grib_trie* init_list(const char* name)
/* For debugging purposes */
static void print_values(grib_context* c, const grib_util_grid_spec2* spec,
const double* data_values, const size_t data_values_count, /* the data pay load */
const grib_values *values, const size_t count) /* keys and their values */
const grib_values *keyval_pairs, const size_t count) /* keys and their values */
{
size_t i=0;
int isConstant = 1;
@ -349,14 +349,14 @@ static void print_values(grib_context* c, const grib_util_grid_spec2* spec,
for(i=0; i<count; i++)
{
switch(values[i].type)
switch(keyval_pairs[i].type)
{
case GRIB_TYPE_LONG: printf("ECCODES DEBUG grib_util: => %s = %ld;\n"
,values[i].name,(long)values[i].long_value); break;
,keyval_pairs[i].name,(long)keyval_pairs[i].long_value); break;
case GRIB_TYPE_DOUBLE: printf("ECCODES DEBUG grib_util: => %s = %.16e;\n"
,values[i].name,values[i].double_value); break;
,keyval_pairs[i].name,keyval_pairs[i].double_value); break;
case GRIB_TYPE_STRING: printf("ECCODES DEBUG grib_util: => %s = \"%s\";\n"
,values[i].name,values[i].string_value); break;
,keyval_pairs[i].name,keyval_pairs[i].string_value); break;
}
}
@ -576,8 +576,8 @@ static int check_geometry(grib_handle* handle, const grib_util_grid_spec2* spec,
if (specified_as_global) strcpy(msg, "Specified to be global (in spec)");
sum = sum_of_pl_array(spec->pl, spec->pl_size);
if (sum != data_values_count) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Invalid reduced gaussian grid: %s but data_values_count != sum_of_pl_array (%lu!=%lu)\n",
msg, data_values_count, sum);
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Invalid reduced gaussian grid: %s but data_values_count != sum_of_pl_array (%ld!=%ld)\n",
msg, (long)data_values_count, (long)sum);
return GRIB_WRONG_GRID;
}
}
@ -1389,7 +1389,8 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
if (global_grid) {
size_t sum = sum_of_pl_array(spec->pl, spec->pl_size);
if (data_values_count != sum) {
printf("invalid reduced gaussian grid: specified as global, data_values_count=%lu but sum of pl array=%lu\n",data_values_count,sum);
printf("invalid reduced gaussian grid: specified as global, data_values_count=%ld but sum of pl array=%ld\n",
(long)data_values_count, (long)sum);
*err = GRIB_WRONG_GRID;
goto cleanup;
}
@ -1543,6 +1544,7 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
if (expandBoundingBox) {
int e = grib_set_long(outh, "expandedBoundingBox", 1);
Assert(e == 0);
Assert(!global_grid); /* ECC-576: "global" should not be set */
}
if ( (*err = check_geometry(outh, spec, data_values_count, global_grid)) != GRIB_SUCCESS)
@ -1749,7 +1751,7 @@ static void set_value(grib_values* value,char* str,int equal)
'values' The array we populate and return
'count' The number of elements
*/
int parse_keyval_string(char* grib_tool, char* arg, int values_required, int default_type, grib_values values[], int* count)
int parse_keyval_string(const char* grib_tool, char* arg, int values_required, int default_type, grib_values values[], int* count)
{
char* p;
int i=0;

View File

@ -20,7 +20,7 @@ list( APPEND test_bins
bufr_keys_iter
gauss_sub
grib_util_set_spec
local_MeteoFrance
grib_local_MeteoFrance
grib_2nd_order_numValues
optimize_scaling
optimize_scaling_sh
@ -53,8 +53,9 @@ list( APPEND tests_no_data_reqd
julian
bufr_ecc-359
bufr_ecc-517
bufr_subTypes
bufr_rdbSubTypes
grib_efas
grib_mars_types
)
# These tests do require data downloads
list( APPEND tests_data_reqd
@ -87,6 +88,7 @@ list( APPEND tests_data_reqd
bufr_ecc-379
bufr_ecc-393
bufr_ecc-433
bufr_ecc-750
grib_ecc-490
bufr_ecc-556
gts_get
@ -124,6 +126,7 @@ list( APPEND tests_data_reqd
grib_set
grib_iterator
grib_compare
grib_copy
grib_level
index
grib_bitmap
@ -136,7 +139,7 @@ list( APPEND tests_data_reqd
read_any
grib_dump
grib_dump_debug
local_MeteoFrance
grib_local_MeteoFrance
grib_neg_fctime
codes_split_file
)
@ -255,6 +258,14 @@ ecbuild_add_test( TARGET eccodes_t_grib_check_param_concepts
CONDITION ENABLE_EXTRA_TESTS
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_check_param_concepts.sh
)
ecbuild_add_test( TARGET eccodes_t_bufr_split_by_rdbSubtype
TYPE SCRIPT
CONDITION ENABLE_EXTRA_TESTS AND ECCODES_INSTALL_EXTRA_TOOLS
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bufr_split_by_rdbSubtype.sh
TEST_DEPENDS eccodes_download_bufrs
)
# Performance test. Must have -DENABLE_GRIB_TIMER=ON
ecbuild_add_test( TARGET eccodes_t_grib_ecc-386
TYPE SCRIPT

View File

@ -31,9 +31,8 @@ fBufrTmp=${label}".bufr.tmp"
cat syno_multi.bufr temp_101.bufr > $fBufrInput
#----------------------------------------------------
# Test: copy synop messages
# Test: copy synop messages
#----------------------------------------------------
rm -f $fBufrTmp
echo "Test: copy synop messages " >> $fLog
@ -45,9 +44,8 @@ for i in 1 2 3 ;do
done
#----------------------------------------------------
# Test: copy non-synop messages
# Test: copy non-synop messages
#----------------------------------------------------
rm -f $fBufrTmp
echo "Test: copy non-synop messages " >> $fLog
@ -55,11 +53,9 @@ ${tools_dir}/bufr_copy -w dataCategory!=0 $fBufrInput $fBufrTmp >> $fLog
[ `${tools_dir}/bufr_get -p dataCategory:l $fBufrTmp` = "2" ]
#-------------------------------------------------------------------
# Test: use the square brackets to insert the value of a key
#-------------------------------------------------------------------
rm -f ${fBufrTmp}
rm -f ${fBufrTmp}_*.bufr
@ -70,8 +66,28 @@ ${tools_dir}/bufr_copy $fBufrInput ${fBufrTmp}_[dataCategory].bufr >> $fLog
[ -s ${fBufrTmp}_2.bufr ]
rm -f ${fBufrTmp}_*.bufr
rm -f $fBufrInput
#Clean up
#-------------------------------------------------------------------
# Test: The -X option
#-------------------------------------------------------------------
echo "Test: use of -X option" >> $fLog
fBufrInput=aeolus_wmo_26.bufr
${tools_dir}/bufr_copy -w count=1 -X 0 $fBufrInput $fBufrTmp #First msg
r1=`${tools_dir}/bufr_get -w count=1 -n ls $fBufrInput`
r2=`${tools_dir}/bufr_get -n ls $fBufrTmp`
[ "$r1" = "$r2" ]
#${tools_dir}/bufr_copy -w count=1 -X 19449 $fBufrInput $fBufrTmp #Last msg
#r1=`${tools_dir}/bufr_get -w count=11 -n ls $fBufrInput`
#r2=`${tools_dir}/bufr_get -n ls $fBufrTmp`
#[ "$r1" = "$r2" ]
#${tools_dir}/bufr_copy -w count=1 -X 10972 $fBufrInput $fBufrTmp
#r=`${tools_dir}/bufr_get -p typicalTime,numberOfSubsets $fBufrTmp`
#[ "$r" = "000013 41" ]
# Clean up
#-----------
rm -f $fLog
rm -f $fBufrTmp
rm -f $fBufrInput

View File

@ -13,6 +13,11 @@
#Define a common label for all the tmp files
label="bufr_dump_test"
if [ $HAVE_MEMFS -eq 1 ]; then
unset ECCODES_DEFINITION_PATH
unset ECCODES_SAMPLES_PATH
fi
#Create log file
fLog=${label}".log"
rm -f $fLog

View File

@ -13,6 +13,11 @@
#Define a common label for all the tmp files
label="bufr_dump_decode_C_test"
if [ $HAVE_MEMFS -eq 1 ]; then
unset ECCODES_DEFINITION_PATH
unset ECCODES_SAMPLES_PATH
fi
#Create log file
fLog=${label}".log"
rm -f $fLog

View File

@ -34,7 +34,7 @@ fRules=${label}.filter
#-----------------------------------------------------------
files=`cat ${data_dir}/bufr/bufr_data_files.txt`
exclude="ias1_240.bufr syno_multi.bufr tropical_cyclone.bufr"
exclude="ias1_240.bufr syno_multi.bufr tropical_cyclone.bufr aeolus_wmo_26.bufr"
for f in $files
do

View File

@ -13,6 +13,11 @@
#Define a common label for all the tmp files
label="bufr_dump_encode_C_test"
if [ $HAVE_MEMFS -eq 1 ]; then
unset ECCODES_DEFINITION_PATH
unset ECCODES_SAMPLES_PATH
fi
#Create log file
fLog=${label}".log"
rm -f $fLog

View File

@ -41,10 +41,11 @@ files=`cat ${data_dir}/bufr/bufr_data_files.txt`
# ias1_240.bufr: Too large. The filter rules file generated is too big for the parser!
# tropical_cyclone.bufr: multi-message
# syno_multi.bufr: multi-message
# aeolus_wmo_26: multi-message
# israel_observations_2017041010.bufr: Suffers from a bug. In filter cannot do:
# set #1#3HourPressureChange=-1.6;
# The hash cannot be followed by a number!
exclude="ias1_240.bufr syno_multi.bufr tropical_cyclone.bufr israel_observations_2017041010.bufr"
exclude="ias1_240.bufr syno_multi.bufr tropical_cyclone.bufr aeolus_wmo_26.bufr israel_observations_2017041010.bufr "
for f in $files
do

View File

@ -36,6 +36,9 @@ do
# Generate Python code from BUFR file
${tools_dir}/bufr_dump -Epython $inputBufr > $tempSrc
#pylint --disable=E0602,R,C,W $tempSrc
# The python code always creates an output file called outfile.bufr
$PYTHON $tempSrc

View File

@ -22,7 +22,9 @@ tempOut=temp.${label}.bufr
tempText=temp.${label}.text
tempRef=temp.${label}.ref
# Test 1 --------------------------------------------------------
# --------------------------------------------------------
# Test 1
# --------------------------------------------------------
BufrFile=airs_57.bufr
cat > $tempRules <<EOF
set unpack=1;
@ -51,7 +53,30 @@ unset ECCODES_BUFR_SET_TO_MISSING_IF_OUT_OF_RANGE
#EOF
#diff $tempText $tempRef
# Test 2 --------------------------------------------------------
# --------------------------------------------------------
# Test 2
# --------------------------------------------------------
cat > $tempRules <<EOF
set unpack=1;
# All longitude values are out-of-range. This is a constant array
set longitude={500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500};
set pack=1;
write;
EOF
# Expect this to fail as all values are out-of-range
set +e
${tools_dir}/codes_bufr_filter -o $tempOut $tempRules $BufrFile 2>/dev/null
status=$?
set -e
[ $status -ne 0 ]
# Now set environment variable to turn out-of-range values into 'missing'
export ECCODES_BUFR_SET_TO_MISSING_IF_OUT_OF_RANGE=1
${tools_dir}/codes_bufr_filter -o $tempOut $tempRules $BufrFile
unset ECCODES_BUFR_SET_TO_MISSING_IF_OUT_OF_RANGE
# --------------------------------------------------------
# Test 3
# --------------------------------------------------------
BufrFile=airc_144.bufr
cat > $tempRules <<EOF
set unpack=1;

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