Merge remote-tracking branch 'origin/develop' into feature/ECC-1766-EERIE

This commit is contained in:
Matthew Griffith 2024-03-11 12:31:10 +00:00
commit eff55b72bc
244 changed files with 3071 additions and 2239 deletions

View File

@ -3,7 +3,7 @@ build:
- ecbuild
- ninja
- aec
- netcdf4/new
- netcdf4
parallel: 64
cmake_options:
- -DENABLE_EXTRA_TESTS=1

View File

@ -8,7 +8,7 @@ module unload ecmwf-toolbox
module load cdo/new
module load numdiff
module load nccmp
module load netcdf4/new
module load netcdf4
module load gnuparallel/new
module load python3

View File

@ -23,7 +23,7 @@ jobs:
ecbuild
ninja
aec
netcdf4/new
netcdf4
--parallel: 64
--cmake-options: |
-DENABLE_EXTRA_TESTS=1

View File

@ -1,6 +1,7 @@
Enrico Fucile
Shahram Najm
Eugen Betke
Enrico Fucile
Pedro Maciel
Sandor Kertesz
Sebastien Villaume
Florian Rathgeber

View File

@ -73,17 +73,11 @@ endif()
###############################################################################
# some variables/options of this project
if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
ecbuild_add_cxx_flags("-Wno-write-strings")
ecbuild_add_cxx_flags("-Wno-deprecated")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
ecbuild_add_cxx_flags("-Wno-write-strings")
ecbuild_add_cxx_flags("-Wno-deprecated")
else()
ecbuild_add_cxx_flags("-Wno-writable-strings")
endif()
elseif( CMAKE_CXX_COMPILER_ID STREQUAL "Cray" )
# ecbuild_add_cxx_flags("-Wno-write-strings" NO_FAIL)
# ecbuild_add_cxx_flags("-Wno-writable-strings" NO_FAIL)
# ecbuild_add_cxx_flags("-Wno-deprecated" NO_FAIL)
if( CMAKE_CXX_COMPILER_ID STREQUAL "Cray" )
set(CMAKE_CXX_FLAGS "-hstd=c++11 ${CMAKE_CXX_FLAGS}")
endif()

View File

@ -1,3 +1,5 @@
SET(ENABLE_EXTRA_TESTS ON CACHE BOOL "Enable extra tests")
SET(ECCODES_INSTALL_EXTRA_TOOLS ON CACHE BOOL "Install extra tools")
SET(ENABLE_ECCODES_THREADS ON CACHE BOOL "Enable POSIX threads")
SET(ENABLE_MEMFS ON CACHE BOOL "Enable MEMFS")
# SET(ENABLE_JPG_LIBOPENJPEG OFF CACHE BOOL "Disable OpenJPEG")

View File

@ -62,4 +62,6 @@ Test2...
- -47120001 -> 6
Test3...
Test4...
Test5...
All OK

View File

@ -2,19 +2,26 @@
0 0 WMO Secretariat
1 ammc Melbourne (WMC)
2 2 Melbourne (WMC)
3 3 Melbourne (WMC)
4 rums Moscow (WMC)
5 5 Moscow (WMC)
6 6 Moscow (WMC)
7 kwbc US National Weather Service - NCEP (WMC)
8 8 US National Weather Service - NWSTG (WMC)
9 9 US National Weather Service - Other (WMC)
10 10 Cairo (RSMC/RAFC)
11 11 Cairo (RSMC/RAFC)
12 12 Dakar (RSMC/RAFC)
13 13 Dakar (RSMC/RAFC)
14 14 Nairobi (RSMC/RAFC)
16 16 Atananarivo (RSMC)
15 15 Nairobi (RSMC/RAFC)
16 16 Casablanca (RSMC)
17 17 Tunis (RSMC)
18 18 Tunis-Casablanca (RSMC)
20 20 Las Palmas (RAFC)
21 21 Algiers (RSMC)
22 22 Lagos (RSMC)
22 22 ACMAD
23 23 Mozambique (NMC)
24 fapr Pretoria (RSMC)
26 26 Khabarovsk (RSMC)
28 vabb New Delhi (IMD)
@ -23,27 +30,38 @@
32 32 Tashkent (RSMC)
33 33 Jeddah (RSMC)
34 rjtd Japanese Meteorological Agency - Tokyo (RSMC)
36 36 Bankok
37 37 Ulan Bator
36 36 Bangkok
37 37 Ulaanbaatar
38 babj Beijing (RSMC)
40 rksl Seoul
41 sabm Buenos Aires (RSMC/RAFC)
43 43 Brasilia (RSMC/RAFC)
45 45 Santiago
46 sbsj Brasilian Space Agency - INPE
47 47 Colombia (NMC)
48 48 Ecuador (NMC)
49 49 Peru (NMC)
50 50 Venezuela (Bolivarian Republic of) (NMC)
51 51 Miami (RSMC/RAFC)
52 52 National Hurricane Center, Miami
53 53 Canadian Meteorological Service - Montreal (RSMC)
54 cwao Canadian Meteorological Service - Montreal (RSMC)
55 55 San Francisco
56 56 ARINC Centre
57 57 U.S. Air Force - Global Weather Center
58 fnmo US Navy - Fleet Numerical Oceanography Center
59 59 NOAA Forecast Systems Lab, Boulder CO
60 60 National Center for Atmospheric Research (NCAR), Boulder, CO
61 61 Service ARGOS - Landover
62 62 US Naval Oceanographic Office
63 63 International Research Institute for Climate and Society (IRI)
64 64 Honolulu
65 65 Darwin (RSMC)
67 67 Melbourne (RSMC)
69 nzkl Wellington (RSMC/RAFC)
71 71 Nadi (RSMC)
72 72 Singapore
73 73 Malaysia (NMC)
74 egrr U.K. Met Office - Exeter
76 76 Moscow (RSMC/RAFC)
78 edzw Offenbach (RSMC)
@ -65,9 +83,34 @@
97 97 European Space Agency (ESA)
98 ecmf European Centre for Medium-Range Weather Forecasts
99 99 DeBilt, Netherlands
100 100 Brazzaville
101 101 Abidjan
102 102 Libya (NMC)
103 103 Madagascar (NMC)
104 104 Mauritius (NMC)
105 105 Niger (NMC)
106 106 Seychelles (NMC)
107 107 Uganda (NMC)
108 108 United Republic of Tanzania (NMC)
109 109 Zimbabwe (NMC)
110 110 Hong-Kong
145 145 French Guiana
146 146 Brazilian Navy Hydrographic Centre
147 147 National Commission on Space Activities (CONAE) - Argentina
148 148 Brazilian Department of Airspace Control - DECEA
160 160 US NOAA/NESDIS
161 161 US NOAA Office of Oceanic and Atmospheric Research
173 nasa US National Aeronautics and Space Administration (NASA)
174 174 Integrated Science Data Management/Marine Environmental Data Service (ISDM/MEDS - Canada)
175 175 University Corporation for Atmospheric Research (UCAR) - United States
176 176 Cooperative Institute for Meteorological Satellite Studies (CIMSS) - United States
177 177 NOAA National Ocean Service - United States
178 178 Spire Global, Inc.
179 179 GeoOptics, Inc.
180 180 PlanetiQ
181 181 Atmospheric and Environmental Research (AER)
195 wiix Indonesia (NMC)
204 niwa National Institute of Water and Atmospheric Research (NIWA - New Zealand)
210 210 Frascati (ESA/ESRIN)
@ -85,6 +128,8 @@
222 222 Albania (NMC)
223 223 Armenia (NMC)
224 lowm Austria
225 225 Azerbaijan (NMC)
226 226 Belarus (NMC)
227 ebum Belgium (NMC)
228 228 Bosnia and Herzegovina (NMC)
229 229 Bulgaria (NMC)
@ -94,6 +139,7 @@
233 eidb Dublin
234 234 Israel (NMC)
235 ingv INGV
238 238 Lithuania (NMC)
239 crfc CERFAX
240 240 Malta (NMC)
241 241 Monaco

View File

@ -43,3 +43,13 @@ template core "grib2/sections.def";
#}
template section_8 "grib2/section.8.def";
# ECC-1779: Add keys to identify experimental and deprecated templates
# The low-level transient keys template_is_XXX
# are set inside the template definition files
concept isTemplateDeprecated(false) {
1 = { template_is_deprecated = 1; }
}
concept isTemplateExperimental(false) {
1 = { template_is_experimental = 1; }
}

View File

@ -3786,6 +3786,22 @@
typeOfFirstFixedSurface = 187 ;
typeOfSecondFixedSurface = 185 ;
}
#Convective snowfall water equivalent
'csfwe' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 55 ;
typeOfFirstFixedSurface = 1 ;
typeOfStatisticalProcessing = 1 ;
}
#Large-scale snowfall water equivalent
'lsfwe' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 56 ;
typeOfFirstFixedSurface = 1 ;
typeOfStatisticalProcessing = 1 ;
}
#Burned area
'fba' = {
discipline = 2 ;

View File

@ -2,4 +2,5 @@
1 CMIP6 Coupled Model Intercomparison Project Phase 6
2 ScenarioMIP Scenario Model Intercomparison Project
3 HighResMIP High Resolution Model Intercomparison Project
4 story-nudging Climate storylines by nudging to reanalysis
65535 65535 Missing

View File

@ -7,4 +7,8 @@
6 SSP2-4.5 Shared Socio-economic Pathways 2-4.5
7 SSP3-7.0 Shared Socio-economic Pathways 3-7.0
8 SSP5-8.5 Shared Socio-economic Pathways 5-8.5
9 Tplus1.5K Warmer world at 1.5 degrees K above pre-industrial temperatures
10 Tplus2.0K Warmer world at 2.0 degrees K above pre-industrial temperatures
11 Tplus3.0K Warmer world at 3.0 degrees K above pre-industrial temperatures
12 Tplus4.0K Warmer world at 4.0 degrees K above pre-industrial temperatures
65535 65535 Missing

View File

@ -183,3 +183,10 @@
scaleFactorOfSecondFixedSurface = missing() ;
typeOfStatisticalProcessing = 0 ;
}
#Snow depth water equivalent
'sd' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 60 ;
typeOfStatisticalProcessing = 0 ;
}

View File

@ -183,3 +183,10 @@
scaleFactorOfSecondFixedSurface = missing() ;
typeOfStatisticalProcessing = 0 ;
}
#Snow depth water equivalent
'Snow depth water equivalent' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 60 ;
typeOfStatisticalProcessing = 0 ;
}

View File

@ -183,3 +183,10 @@
scaleFactorOfSecondFixedSurface = missing() ;
typeOfStatisticalProcessing = 0 ;
}
#Snow depth water equivalent
'228141' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 60 ;
typeOfStatisticalProcessing = 0 ;
}

View File

@ -183,3 +183,10 @@
scaleFactorOfSecondFixedSurface = missing() ;
typeOfStatisticalProcessing = 0 ;
}
#Snow depth water equivalent
'sd' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 60 ;
typeOfStatisticalProcessing = 0 ;
}

View File

@ -183,3 +183,10 @@
scaleFactorOfSecondFixedSurface = missing() ;
typeOfStatisticalProcessing = 0 ;
}
#Snow depth water equivalent
'kg m**-2' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 60 ;
typeOfStatisticalProcessing = 0 ;
}

View File

@ -3786,6 +3786,22 @@
typeOfFirstFixedSurface = 187 ;
typeOfSecondFixedSurface = 185 ;
}
#Convective snowfall water equivalent
'Convective snowfall water equivalent' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 55 ;
typeOfFirstFixedSurface = 1 ;
typeOfStatisticalProcessing = 1 ;
}
#Large-scale snowfall water equivalent
'Large-scale snowfall water equivalent' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 56 ;
typeOfFirstFixedSurface = 1 ;
typeOfStatisticalProcessing = 1 ;
}
#Burned area
'Burned area' = {
discipline = 2 ;

View File

@ -3786,6 +3786,22 @@
typeOfFirstFixedSurface = 187 ;
typeOfSecondFixedSurface = 185 ;
}
#Convective snowfall water equivalent
'231057' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 55 ;
typeOfFirstFixedSurface = 1 ;
typeOfStatisticalProcessing = 1 ;
}
#Large-scale snowfall water equivalent
'231058' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 56 ;
typeOfFirstFixedSurface = 1 ;
typeOfStatisticalProcessing = 1 ;
}
#Burned area
'232000' = {
discipline = 2 ;

View File

@ -3786,6 +3786,22 @@
typeOfFirstFixedSurface = 187 ;
typeOfSecondFixedSurface = 185 ;
}
#Convective snowfall water equivalent
'csfwe' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 55 ;
typeOfFirstFixedSurface = 1 ;
typeOfStatisticalProcessing = 1 ;
}
#Large-scale snowfall water equivalent
'lsfwe' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 56 ;
typeOfFirstFixedSurface = 1 ;
typeOfStatisticalProcessing = 1 ;
}
#Burned area
'fba' = {
discipline = 2 ;

View File

@ -4,7 +4,8 @@
# template_nofail default_step_units "grib2/localConcepts/[centre:s]/default_step_units.def";
# codetable[1] stepUnits 'stepUnits.table' = defaultStepUnits : transient,dump,no_copy;
meta stepUnits optimal_step_units(forecastTime,indicatorOfUnitOfTimeRange,lengthOfTimeRange,indicatorOfUnitForTimeRange) : transient,dump;
# See ECC-1768 re why no_copy is needed
meta stepUnits optimal_step_units(forecastTime,indicatorOfUnitOfTimeRange,lengthOfTimeRange,indicatorOfUnitForTimeRange) : dump,no_copy;
transient startStepUnit = 255 : hidden; # 255 means MISSING. See code table 4.4
transient endStepUnit = 255 : hidden;
# The lowercase version is to unify it with the helper key in the MARS language

View File

@ -1,7 +1,7 @@
# Code table 4.2 - discipline=0 category=1 for ECMWF
192 192 Snow evaporation rate (kg m-2 s-1)
193 193 Total precipitation rate (m s-1)
194 194 Accumulated freezing rain (m)
194 194 Freezing rain precipitation rate (m s-1)
195 195 Convective precipitation rate (m s-1)
196 196 Large-scale precipitation rate (m s-1)
197 197 Snow evaporation rate (m of water equivalent s-1)

View File

@ -1,6 +1,11 @@
# (C) Copyright 2005- ECMWF.
# TEMPLATE 3.1000, Cross-section grid, with points equally spaced on the horizontal
# This template is simply experimental, was not validated at the time of publication
# and should be used only for bilateral previously agreed tests
transient template_is_experimental = 1 : hidden ;
include "grib2/template.3.shape_of_the_earth.def"
constant isGridded = true;

View File

@ -1,6 +1,11 @@
# (C) Copyright 2005- ECMWF.
# TEMPLATE 3.1100, Hovmoller diagram grid with points equally spaced on the horizontal
# This template is simply experimental, was not validated at the time of publication
# and should be used only for bilateral previously agreed tests
transient template_is_experimental = 1 : hidden;
include "grib2/template.3.shape_of_the_earth.def"
constant isGridded = true;

View File

@ -1,6 +1,10 @@
# (C) Copyright 2005- ECMWF.
# TEMPLATE 3.1200, Time section grid
# This template is simply experimental, was not validated at the time of publication
# and should be used only for bilateral previously agreed tests
transient template_is_experimental = 1 : hidden;
constant isGridded = true;
# NT - Number of time steps

View File

@ -62,12 +62,12 @@ include "grib2/template.3.scanning_mode.def"
# Latin 1 - first latitude from the pole at which the secant cone cuts the sphere
signed[4] Latin1 : edition_specific;
alias FirstLatitude=Latin1;
alias firstLatitude=Latin1;
meta geography.Latin1InDegrees scale(Latin1,one,grib2divider,truncateDegrees) : dump;
# Latin 2 - second latitude from the pole at which the secant cone cuts the sphere
signed[4] Latin2 : dump;
alias SecondLatitude=Latin2;
alias secondLatitude=Latin2;
meta geography.Latin2InDegrees scale(Latin2,one,grib2divider,truncateDegrees) : dump;
# Latitude of the southern pole of projection

View File

@ -38,12 +38,12 @@ flags[1] projectionCentreFlag 'grib2/tables/[tablesVersion]/3.5.table' : dump;
# Latin 1 - first latitude from the pole at which the secant cone cuts the sphere
signed[4] Latin1 : edition_specific;
alias FirstLatitude=Latin1;
alias firstLatitude=Latin1;
meta geography.Latin1InDegrees scale(Latin1,one,grib2divider,truncateDegrees) : dump;
# Latin 2 - second latitude from the pole at which the secant cone cuts the sphere
signed[4] Latin2 : dump;
alias SecondLatitude=Latin2;
alias secondLatitude=Latin2;
meta geography.Latin2InDegrees scale(Latin2,one,grib2divider,truncateDegrees) : dump;
# Latitude of the southern pole of projection

View File

@ -27,7 +27,7 @@ concept orderingConvention(unknown) {
"ring" = { ordering = 0; }
"nested" = { ordering = 1; }
} : dump;
alias geography.pointsOrdering = orderingConvention;
alias geography.orderingConvention = orderingConvention;
flags[1] scanningMode 'grib2/tables/[tablesVersion]/3.13.table';
flagbit iScansNegatively(scanningMode,7) : dump; # WMO bit 1

View File

@ -73,12 +73,12 @@ _if (shapeOfTheEarth == 3){
# ECC-979
# The 'scale' accessor works with integers so rounds its first argument
# which is not what we want because the inputs are doubles with decimal
# expansions. So use the trick of dividing by 0.001 to multiply by 1000
# expansions.
#
# meta earthMajorAxisInMetres scale(earthMajorAxis, thousand, one, zero);
# meta earthMinorAxisInMetres scale(earthMinorAxis, thousand, one, zero);
meta earthMajorAxisInMetres divdouble(earthMajorAxis, 0.001);
meta earthMinorAxisInMetres divdouble(earthMinorAxis, 0.001);
meta earthMajorAxisInMetres multdouble(earthMajorAxis, 1000);
meta earthMinorAxisInMetres multdouble(earthMinorAxis, 1000);
}
_if (shapeOfTheEarth == 7){
# Major and minor axes specified (in m) by data producer

View File

@ -2,6 +2,9 @@
# TEMPLATE 4.10, Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval
# This template was not validated at the time of publication and should be used with caution.
transient template_is_experimental = 1 : hidden;
include "grib2/template.4.parameter.def"
include "grib2/template.4.generating_process.def"
include "grib2/template.4.forecast_time.def"

View File

@ -1,6 +1,9 @@
# (C) Copyright 2005- ECMWF.
# TEMPLATE 4.1000, Cross section of analysis and forecast at a point in time
# This template is experimental, was not validated at the time of publication
# and should be used only for bilateral previously agreed tests
transient template_is_experimental = 1 : hidden;
include "grib2/template.4.parameter.def"
include "grib2/template.4.generating_process.def"

View File

@ -1,6 +1,9 @@
# (C) Copyright 2005- ECMWF.
# TEMPLATE 4.1001, Cross section of averaged or otherwise statistically processed analysis or forecast over a range of time
# This template is experimental, was not validated at the time of publication
# and should be used only for bilateral previously agreed tests
transient template_is_experimental = 1 : hidden;
include "grib2/template.4.parameter.def"
include "grib2/template.4.generating_process.def"

View File

@ -1,6 +1,9 @@
# (C) Copyright 2005- ECMWF.
# TEMPLATE 4.1100, Hovmoller-type grid with no averaging or other statistical processing
# This template is experimental, was not validated at the time of publication
# and should be used only for bilateral previously agreed tests
transient template_is_experimental = 1 : hidden;
include "grib2/template.4.parameter.def"
include "grib2/template.4.generating_process.def"

View File

@ -2,8 +2,27 @@
# TEMPLATE 4.1101, Hovmoller-type grid with averaging or other statistical processing
# This template is experimental, was not validated at the time of publication and should be used only for bilateral previously agreed tests.
# (Octets 35-50 are very similar to octets 43-58 of product definition template 4.8, but the meaning of some fields differs slightly)
transient template_is_experimental = 1 : hidden;
include "grib2/template.4.parameter.def"
include "grib2/template.4.generating_process.def"
include "grib2/template.4.forecast_time.def"
include "grib2/template.4.horizontal.def"
include "grib2/template.4.statistical.def"
unsigned[4] numberOfMissingInStatisticalProcess = 0 : edition_specific;
alias totalNumberOfDataValuesMissingInStatisticalProcess=numberOfMissingInStatisticalProcess;
codetable[1] typeOfStatisticalProcessing ('4.10.table',masterDir,localDir) : edition_specific;
codetable[1] typeOfTimeIncrement ('4.11.table',masterDir,localDir) = 2 : edition_specific;
alias typeOfTimeIncrementBetweenSuccessiveFieldsUsedInTheStatisticalProcessing=typeOfTimeIncrement;
codetable[1] indicatorOfUnitForTimeRange ('4.4.table',masterDir,localDir) =1 ;
unsigned[4] lengthOfTimeRange=0 ;
codetable[1] indicatorOfUnitForTimeIncrement ('4.4.table',masterDir,localDir)=255 ;
unsigned[4] timeIncrement=0 ;
alias timeIncrementBetweenSuccessiveFields=timeIncrement;
# include "grib2/template.4.statistical.def"

View File

@ -2,6 +2,7 @@
# TEMPLATE 4.44, Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol
# It is recommended not to use this template. PDT 4.48 should be used instead with optical wave length range set to missing
transient template_is_deprecated = 1 : hidden;
# GRIB-530: Special case for aerosol thanks to WMO error

View File

@ -1,7 +1,9 @@
# (C) Copyright 2005- ECMWF.
# TEMPLATE 4.83, Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval with source/sink
# Note: This template is deprecated. Template 4.84 should be used instead.
# It is recommended not to use this template. Product definition template 4.84 should be used instead because it contains an additional octet to specify the type of generating process
transient template_is_deprecated = 1 : hidden;
include "grib2/template.4.parameter.def"
include "grib2/template.4.aerosol.def"

View File

@ -8,3 +8,12 @@ signed[1] scaleFactorOfFirstWavelength : dump;
signed[4] scaledValueOfFirstWavelength : dump;
signed[1] scaleFactorOfSecondWavelength = missing(): can_be_missing,dump;
signed[4] scaledValueOfSecondWavelength = missing(): can_be_missing,dump;
meta firstWavelength from_scale_factor_scaled_value(scaleFactorOfFirstWavelength, scaledValueOfFirstWavelength);
meta secondWavelength from_scale_factor_scaled_value(scaleFactorOfSecondWavelength, scaledValueOfSecondWavelength);
alias firstWavelengthInMetres = firstWavelength;
alias secondWavelengthInMetres = secondWavelength;
constant billion = 1000000000 : hidden;
meta firstWavelengthInNanometres multdouble(firstWavelength, billion) : read_only;
meta secondWavelengthInNanometres multdouble(secondWavelength, billion) : read_only;

View File

@ -1,8 +1,9 @@
# (C) Copyright 2005- ECMWF.
# TEMPLATE 5.1, Matrix values at grid point - simple packing
# Preliminary note:
# This template was not validated at the time of publication and should be used with caution
transient template_is_experimental = 1 : hidden;
include "grib2/template.5.packing.def"

View File

@ -2,8 +2,9 @@
# TEMPLATE 5.61, Grid point data - Simple packing with logarithmic preprocessing
# Note from WMO document:
# This template is experimental, was not validated at the time of publication and should be used only for bilateral previously agreed tests
transient template_is_experimental = 1 : hidden;
constant typeOfPreProcessing = 1;
include "grib2/template.5.packing.def"

View File

@ -1,6 +1,8 @@
# (C) Copyright 2005- ECMWF.
# TEMPLATE 7.1, Matrix values at grid point - simple packing
# This template was not validated at the time of publication and should be used with caution
transient template_is_experimental = 1 : hidden;
meta codedValues data_g2simple_packing(
section7Length,

View File

@ -6,7 +6,7 @@ if (bitsPerValue) {
meta groupWidths unsigned_bits(widthOfWidths,numberOfGroups) : read_only;
meta groupLengths unsigned_bits(widthOfLengths,numberOfGroups) : read_only;
meta firstOrderValues unsigned_bits(widthOfFirstOrderValues,numberOfGroups) : read_only;
meta countOfGroupLengths sum(groupLengths);
# meta countOfGroupLengths sum(groupLengths);
}
transient halfByte=0;
@ -49,7 +49,6 @@ if(bitmapPresent) {
widthOfSPD,
orderOfSPD,
numberOfPoints
): read_only;
alias data.packedValues = codedValues;
@ -91,7 +90,6 @@ if(bitmapPresent) {
widthOfSPD,
orderOfSPD,
numberOfPoints
) : dump;
alias codedValues=values;
alias data.packedValues = values;

View File

@ -5,7 +5,7 @@
meta groupWidths unsigned_bits(widthOfWidths,numberOfGroups) : read_only;
meta groupLengths unsigned_bits(widthOfLengths,numberOfGroups) : read_only;
meta firstOrderValues unsigned_bits(widthOfFirstOrderValues,numberOfGroups) : read_only;
meta countOfGroupLengths sum(groupLengths);
# meta countOfGroupLengths sum(groupLengths);
transient halfByte=0;
position offsetBeforeData;
@ -47,7 +47,6 @@ if(bitmapPresent) {
widthOfSPD,
orderOfSPD,
numberOfPoints
): read_only;
alias data.packedValues = codedValues;
@ -96,7 +95,6 @@ if(bitmapPresent) {
widthOfSPD,
orderOfSPD,
numberOfPoints
) : dump;
meta values data_apply_boustrophedonic(codedValues,numberOfRows,numberOfColumns,numberOfPoints,pl) : dump;
@ -138,7 +136,6 @@ if(bitmapPresent) {
widthOfSPD,
orderOfSPD,
numberOfPoints
) : dump;
alias codedValues=values;
}

View File

@ -4,6 +4,7 @@
# Note from WMO document:
# This template is experimental, was not validated at the time of publication and should be used only for bilateral previously agreed tests
transient template_is_deprecated = 1 : hidden;
meta codedValues data_g2simple_packing_with_preprocessing(
section7Length,

View File

@ -3786,6 +3786,22 @@
typeOfFirstFixedSurface = 187 ;
typeOfSecondFixedSurface = 185 ;
}
#Convective snowfall water equivalent
'kg m**-2' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 55 ;
typeOfFirstFixedSurface = 1 ;
typeOfStatisticalProcessing = 1 ;
}
#Large-scale snowfall water equivalent
'kg m**-2' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 56 ;
typeOfFirstFixedSurface = 1 ;
typeOfStatisticalProcessing = 1 ;
}
#Burned area
'%' = {
discipline = 2 ;

View File

@ -73,12 +73,12 @@ _if (shapeOfTheEarth == 3){
# ECC-979
# The 'scale' accessor works with integers so rounds its first argument
# which is not what we want because the inputs are doubles with decimal
# expansions. So use the trick of dividing by 0.001 to multiply by 1000
# expansions.
#
# meta earthMajorAxisInMetres scale(earthMajorAxis, thousand, one, zero);
# meta earthMinorAxisInMetres scale(earthMinorAxis, thousand, one, zero);
meta earthMajorAxisInMetres divdouble(earthMajorAxis, 0.001);
meta earthMinorAxisInMetres divdouble(earthMinorAxis, 0.001);
meta earthMajorAxisInMetres multdouble(earthMajorAxis, 1000);
meta earthMinorAxisInMetres multdouble(earthMinorAxis, 1000);
}
_if (shapeOfTheEarth == 7){
# Major and minor axes specified (in m) by data producer

View File

@ -1,8 +1,14 @@
if (levtype is "o2d" || levtype is "o3d") {
alias mars.step = stepRange;
} else {
alias mars.step = endStep;
}
if (class is "od") { alias mars.system = systemNumber; }
if (class is "me") { alias mars.system = systemNumber; }
if (class is "en") { alias mars.system = systemNumber; }
if (class is "c3") { alias mars.system = systemNumber; }
if (class is "ci") { alias mars.system = systemNumber; }
alias mars.number = perturbationNumber;
alias mars.method = methodNumber;
@ -17,3 +23,4 @@ if (centre == 80 && subCentre == 98 && class is "c3") {
}
if (class is "ci") { unalias mars.method; }

View File

@ -10,6 +10,7 @@ if (class is "od") { alias mars.system = systemNumber; }
if (class is "me") { alias mars.system = systemNumber; }
if (class is "en") { alias mars.system = systemNumber; }
if (class is "c3") { alias mars.system = systemNumber; }
if (class is "ci") { alias mars.system = systemNumber; }
# See ECC-624
if (centre == 80 && subCentre == 98 && class is "c3") {

View File

@ -30,12 +30,12 @@ int main(int argc, char** argv)
codes_handle* h = NULL;
int mcount = 0;
/* turn off support for GRIB2 multi-field messages */
codes_grib_multi_support_off(NULL);
/* turn on support for GRIB2 multi-field messages */
codes_grib_multi_support_on(NULL);
/* turn off support for GRIB2 multi-field messages */
/* codes_multi_support_off(NULL); */
in = fopen(filename, "rb");
if (!in) {
fprintf(stderr, "Error: unable to open file %s\n", filename);

View File

@ -72,7 +72,7 @@ int main(int argc, char** argv)
}
/* open output file */
of = fopen(ofilename, "w");
of = fopen(ofilename, "wb");
if (!of) {
fprintf(stderr, "ERROR: unable to open output file %s\n", ofilename);
exit(1);

View File

@ -9,20 +9,20 @@
. ./include.ctest.sh
#if [ ! -f "${data_dir}/sample.grib2" ]
#then
# echo SKIP: $0
# exit
#fi
label="grib_multi_write_c"
tempGrib=temp.$label.grib
tempText=temp.$label.txt
${examples_dir}/c_grib_multi_write ${data_dir}/sample.grib2 ${data_dir}/multi_sample.grib2 > /dev/null
${examples_dir}/c_grib_multi_write ${data_dir}/sample.grib2 $tempGrib > /dev/null
${tools_dir}/grib_get -p step ${data_dir}/multi_sample.grib2 > ${data_dir}/multi_step.test
${tools_dir}/grib_get -p step $tempGrib > $tempText
diff ${data_dir}/multi_step.test ${data_dir}/multi_step.txt
step=`${tools_dir}/grib_get -M -p step ${data_dir}/multi_sample.grib2`
reference=${data_dir}/multi_step.txt
diff $reference $tempText
# -M = Turn multi-field support off
step=`${tools_dir}/grib_get -M -p step $tempGrib`
[ $step -eq 12 ]
rm -f ${data_dir}/multi_sample.grib2 ${data_dir}/multi_step.test
# Clean up
rm -f $tempGrib $tempText

View File

@ -18,7 +18,6 @@ program operator_3_test
call codes_bufr_new_from_samples(ibufr,'BUFR4',iret)
if (iret /= CODES_SUCCESS) then
print *,'ERROR creating BUFR from BUFR4'
stop 1
endif

View File

@ -22,7 +22,6 @@ program bufr_encode
call codes_bufr_new_from_samples(ibufr,'BUFR4',iret)
if (iret/=CODES_SUCCESS) then
print *,'ERROR creating BUFR from BUFR4'
stop 1
endif
call codes_set(ibufr,'masterTableNumber',0)

View File

@ -25,9 +25,9 @@ program bufr_read_tempf
integer :: ibufr
integer :: i, count = 0
integer :: iflag
integer :: status_id, status_ht, status_time = 0, status_p
integer :: status_airt, status_dewt
integer :: status_rsno, status_rssoft, status_balloonwt
integer :: status_id, status_bl, status_num, status_ht, status_time = 0, status_p
integer :: status_airt, status_dewt, status_wdir, status_wsp
integer :: status_rsno, status_rssoft, status_balloonwt, statid_missing
integer(kind=4) :: sizews
integer(kind=4) :: blockNumber, stationNumber
integer(kind=4) :: ymd, hms
@ -74,9 +74,10 @@ program bufr_read_tempf
IF (status_id /= CODES_SUCCESS) statid = dropid
! call codes_is_missing(ibufr, 'shipOrMobileLandStationIdentifier', statid_missing)
! IF (statid_missing == 1) statid = "MISSING"
call codes_get(ibufr, 'blockNumber', blockNumber)
call codes_get(ibufr, 'stationNumber', stationNumber)
IF (blockNumber <= 99.0 .AND. stationNumber <= 1000) write (statid, '(I2.2,I3.3,3X)') blockNumber, stationNumber
blockNumber = 9999
call codes_get(ibufr, 'blockNumber', blockNumber, status_bl)
call codes_get(ibufr, 'stationNumber', stationNumber, status_num)
IF (blockNumber <= 99 .AND. stationNumber <= 1000) write (statid, '(I2.2,I3.3,3X)') blockNumber, stationNumber
call codes_get(ibufr, 'year', year)
call codes_get(ibufr, 'month', month)
@ -118,8 +119,8 @@ program bufr_read_tempf
call codes_get(ibufr, 'extendedVerticalSoundingSignificance', vssVal)
call codes_get(ibufr, 'airTemperature', tVal, status_airt)
call codes_get(ibufr, 'dewpointTemperature', tdVal, status_dewt)
call codes_get(ibufr, 'windDirection', wdirVal)
call codes_get(ibufr, 'windSpeed', wspVal)
call codes_get(ibufr, 'windDirection', wdirVal, status_wdir)
call codes_get(ibufr, 'windSpeed', wspVal, status_wsp)
! ---- Array sizes (pressure size can be larger - wind shear levels)
sizews = size(wspVal)
@ -140,13 +141,21 @@ program bufr_read_tempf
allocate(tdVal(sizews))
tdVal(:) = -999999999.0
END IF
IF (status_wdir /= CODES_SUCCESS) THEN
allocate(wdirVal(sizews))
wdirVal(:) = -999999999.0
END IF
IF (status_wsp /= CODES_SUCCESS) THEN
allocate(wspVal(sizews))
wspVal(:) = -999999999.0
END IF
! ---- Print the values --------------------------------
write (*, '(A,I7,A,A8,I9,I7.6,F9.3,F10.3,2F7.1,I4,I5)') 'Ob: ', count, &
' ', statid, ymd, hms, lat(1), lon(1), htg, htp, INT(sondeType), sizews
IF (status_rsno == CODES_SUCCESS) write (*, '(A,A,A,F7.3)') &
'RS number/software/balloonwt: ', rsnumber, rssoftware, balloonwt
IF (status_ht == CODES_SUCCESS .AND. SIZE(lat) > 1) write (*, '(A,A,F9.3,F10.3,F7.1)') &
IF (status_ht == CODES_SUCCESS .AND. SIZE(lat) > 1) write (*, '(A,A10,F9.3,F10.3,F7.1)') &
'WMO list lat, lon, ht: ', statid, lat(2), lon(2), htec
write (*, '(A)') 'level dtime dlat dlon pressure geopotH airTemp dewPtT windDir windSp signif'
do i = 1, sizews

View File

@ -1604,9 +1604,8 @@ int any_f_new_from_loaded_(int* msgid, int* gid)
/*****************************************************************************/
int codes_f_clear_loaded_from_file_(void)
{
grib_context* c = grib_context_get_default();
/* grib_oarray_delete_content(c,binary_messages); */
grib_oarray_delete(c, binary_messages);
grib_oarray_delete(grib_context_get_default(), binary_messages);
return GRIB_SUCCESS;
}
@ -1711,10 +1710,10 @@ int grib_f_headers_only_new_from_file_(int* fid, int* gid)
}
/*****************************************************************************/
int grib_f_new_from_index_(int* iid, int* gid)
int grib_f_new_from_index_(int* index_id, int* gid)
{
int err = 0;
grib_index* i = get_index(*iid);
grib_index* i = get_index(*index_id);
grib_handle *h = NULL;
if (i) {
@ -1757,16 +1756,15 @@ int grib_f_index_new_from_file_(char* file, char* keys, int* gid, int lfile, int
}
/*****************************************************************************/
int grib_f_index_add_file_(int* iid, char* file, int lfile)
int grib_f_index_add_file_(int* index_id, char* file, int lfile)
{
grib_index *i = get_index(*iid);
int err = GRIB_SUCCESS;
grib_index *i = get_index(*index_id);
char buf[1024];
if (!i) {
return GRIB_INVALID_INDEX;
} else {
err = grib_index_add_file(i,cast_char(buf,file,lfile));
int err = grib_index_add_file(i,cast_char(buf,file,lfile));
return err;
}
}
@ -1928,9 +1926,9 @@ int grib_f_get_size_long_(int* gid, char* key, long* val, int len)
}
/*****************************************************************************/
int grib_f_index_get_size_int_(int* gid, char* key, int* val, int len)
int grib_f_index_get_size_int_(int* index_id, char* key, int* val, int len)
{
grib_index *h = get_index(*gid);
grib_index *h = get_index(*index_id);
int err = GRIB_SUCCESS;
char buf[1024];
size_t tsize = 0;
@ -1944,17 +1942,16 @@ int grib_f_index_get_size_int_(int* gid, char* key, int* val, int len)
}
}
int grib_f_index_get_size_long_(int* gid, char* key, long* val, int len)
int grib_f_index_get_size_long_(int* index_id, char* key, long* val, int len)
{
grib_index *h = get_index(*gid);
int err = GRIB_SUCCESS;
grib_index *h = get_index(*index_id);
char buf[1024];
size_t tsize = 0;
if (!h){
return GRIB_INVALID_GRIB;
} else{
err = grib_index_get_size(h, cast_char(buf,key,len), &tsize);
int err = grib_index_get_size(h, cast_char(buf,key,len), &tsize);
*val = tsize;
return err;
}
@ -2063,9 +2060,9 @@ int grib_f_get_byte_array_(int* gid, char* key, unsigned char *val, int* size, i
}
/*****************************************************************************/
int grib_f_index_get_string_(int* gid, char* key, char* val, int *eachsize,int* size, int len)
int grib_f_index_get_string_(int* index_id, char* key, char* val, int *eachsize,int* size, int len)
{
grib_index *h = get_index(*gid);
grib_index *h = get_index(*index_id);
int err = GRIB_SUCCESS;
int i;
char buf[1024];
@ -2104,10 +2101,10 @@ int grib_f_index_get_string_(int* gid, char* key, char* val, int *eachsize,int*
}
/*****************************************************************************/
int grib_f_index_get_long_(int* gid, char* key, long *val, int* size, int len)
int grib_f_index_get_long_(int* index_id, char* key, long *val, int* size, int len)
{
grib_index *h = get_index(*gid);
int err = GRIB_SUCCESS;
int err = 0;
grib_index* h = get_index(*index_id);
char buf[1024];
size_t lsize = *size;
@ -2118,9 +2115,9 @@ int grib_f_index_get_long_(int* gid, char* key, long *val, int* size, int len)
}
/*****************************************************************************/
int grib_f_index_get_int_(int* gid, char* key, int *val, int* size, int len)
int grib_f_index_get_int_(int* index_id, char* key, int *val, int* size, int len)
{
grib_index *h = get_index(*gid);
grib_index *h = get_index(*index_id);
int err = GRIB_SUCCESS;
char buf[1024];
size_t lsize = *size, i = 0;
@ -2140,10 +2137,10 @@ int grib_f_index_get_int_(int* gid, char* key, int *val, int* size, int len)
}
/*****************************************************************************/
int grib_f_index_get_real8_(int* gid, char* key, double *val, int* size, int len)
int grib_f_index_get_real8_(int* index_id, char* key, double *val, int* size, int len)
{
grib_index *h = get_index(*gid);
int err = GRIB_SUCCESS;
int err = 0;
grib_index* h = get_index(*index_id);
char buf[1024];
size_t lsize = *size;
@ -2438,9 +2435,9 @@ int grib_f_set_real4_array_(int* gid, char* key, float* val, int* size, int len)
}
/*****************************************************************************/
int grib_f_index_select_real8_(int* gid, char* key, double* val, int len)
int grib_f_index_select_real8_(int* index_id, char* key, double* val, int len)
{
grib_index *h = get_index(*gid);
grib_index *h = get_index(*index_id);
char buf[1024];
if(!h) return GRIB_INVALID_GRIB;
@ -2448,9 +2445,9 @@ int grib_f_index_select_real8_(int* gid, char* key, double* val, int len)
}
/*****************************************************************************/
int grib_f_index_select_string_(int* gid, char* key, char* val, int len, int vallen)
int grib_f_index_select_string_(int* index_id, char* key, char* val, int len, int vallen)
{
grib_index *h = get_index(*gid);
grib_index *h = get_index(*index_id);
char buf[1024];
char bufval[1024];
@ -2465,9 +2462,9 @@ int grib_f_index_select_string_(int* gid, char* key, char* val, int len, int val
}
/*****************************************************************************/
int grib_f_index_select_int_(int* gid, char* key, int* val, int len)
int grib_f_index_select_int_(int* index_id, char* key, int* val, int len)
{
grib_index *h = get_index(*gid);
grib_index *h = get_index(*index_id);
long lval = *val;
char buf[1024] = {0,};
@ -2476,9 +2473,9 @@ int grib_f_index_select_int_(int* gid, char* key, int* val, int len)
}
/*****************************************************************************/
int grib_f_index_select_long_(int* gid, char* key, long* val, int len)
int grib_f_index_select_long_(int* index_id, char* key, long* val, int len)
{
grib_index *h = get_index(*gid);
grib_index *h = get_index(*index_id);
char buf[1024] = {0,};
if (!h) return GRIB_INVALID_GRIB;

Binary file not shown.

View File

@ -80,6 +80,7 @@ list( APPEND eccodes_src_files
grib_accessor_class_hash_array.cc
grib_accessor_class_decimal_precision.cc
grib_accessor_class_divdouble.cc
grib_accessor_class_multdouble.cc
grib_accessor_class_budgdate.cc
grib_accessor_class_validity_date.cc
grib_accessor_class_validity_time.cc

View File

@ -128,7 +128,7 @@ grib_concept_value* action_concept_get_concept(grib_accessor* a)
int action_concept_get_nofail(grib_accessor* a)
{
grib_action_concept* self = (grib_action_concept*)a->creator;
const grib_action_concept* self = (grib_action_concept*)a->creator;
return self->nofail;
}
@ -397,9 +397,9 @@ int get_concept_condition_string(grib_handle* h, const char* key, const char* va
grib_concept_condition* concept_condition = concept_value->conditions;
if (strcmp(pValue, concept_value->name) == 0) {
while (concept_condition) {
grib_expression* expression = concept_condition->expression;
//grib_expression* expression = concept_condition->expression;
const char* condition_name = concept_condition->name;
Assert(expression);
//Assert(expression);
if (concept_condition_expression_true(h, concept_condition, exprVal) && strcmp(condition_name, "one") != 0) {
length += snprintf(result + length, 2048, "%s%s=%s",
(length == 0 ? "" : ","), condition_name, exprVal);

View File

@ -168,13 +168,14 @@ grib_action* grib_action_create_hash_array(grib_context* context,
a->hash_array = hash_array;
if (hash_array) {
grib_hash_array_value* ha = hash_array;
grib_trie* index = grib_trie_new(context);
while (ha) {
ha->index = index;
grib_trie_insert_no_replace(index, ha->name, ha);
ha = ha->next;
}
grib_context_log(context, GRIB_LOG_FATAL, "%s: 'hash_array_list' not implemented", __func__);
// grib_hash_array_value* ha = hash_array;
// grib_trie* index = grib_trie_new(context);
// while (ha) {
// ha->index = index;
// grib_trie_insert_no_replace(index, ha->name, ha);
// ha = ha->next;
// }
}
act->name = grib_context_strdup_persistent(context, name);
@ -185,17 +186,12 @@ grib_action* grib_action_create_hash_array(grib_context* context,
static void dump(grib_action* act, FILE* f, int lvl)
{
int i = 0;
for (i = 0; i < lvl; i++)
grib_context_print(act->context, f, " ");
printf("hash_array(%s) { ", act->name);
printf("\n");
for (i = 0; i < lvl; i++)
grib_context_print(act->context, f, " ");
printf("}\n");
// for (int i = 0; i < lvl; i++)
// grib_context_print(act->context, f, " ");
// printf("hash_array(%s) { \n", act->name);
// for (int i = 0; i < lvl; i++)
// grib_context_print(act->context, f, " ");
// printf("}\n");
}
@ -203,14 +199,16 @@ static void destroy(grib_context* context, grib_action* act)
{
grib_action_hash_array* self = (grib_action_hash_array*)act;
grib_hash_array_value* v = self->hash_array;
if (v)
grib_trie_delete(v->index);
while (v) {
grib_hash_array_value* n = v->next;
grib_hash_array_value_delete(context, v);
v = n;
}
// This is currently unset. So assert that it is NULL
const grib_hash_array_value* v = self->hash_array;
Assert(v == NULL);
// if (v)
// grib_trie_delete(v->index);
// while (v) {
// grib_hash_array_value* n = v->next;
// grib_hash_array_value_delete(context, v);
// v = n;
// }
grib_context_free_persistent(context, self->masterDir);
grib_context_free_persistent(context, self->localDir);
@ -338,6 +336,6 @@ grib_hash_array_value* get_hash_array(grib_handle* h, grib_action* a)
const char* get_hash_array_full_path(grib_action* a)
{
grib_action_hash_array* self = (grib_action_hash_array*)a;
const grib_action_hash_array* self = (grib_action_hash_array*)a;
return self->full_path;
}

View File

@ -10,7 +10,6 @@
/***************************************************************************
* Jean Baptiste Filippi - 01.11.2005 *
* Enrico Fucile *
***************************************************************************/
#include "grib_api_internal.h"
/*
@ -107,7 +106,7 @@ static int create_accessor(grib_section* p, grib_action* act, grib_loader* h)
long val = 0;
if ((ret = grib_expression_evaluate_long(p->h, a->expression, &val)) != GRIB_SUCCESS) {
grib_context_log(p->h->context, GRIB_LOG_DEBUG, "List %s creating %d values unable to evaluate long", act->name, val);
grib_context_log(p->h->context, GRIB_LOG_DEBUG, "List %s creating %ld values: Unable to evaluate long", act->name, val);
return ret;
}
@ -166,7 +165,7 @@ static grib_action* reparse(grib_action* a, grib_accessor* acc, int* doit)
if ((ret = grib_expression_evaluate_long(grib_handle_of_accessor(acc), self->expression, &val)) != GRIB_SUCCESS) {
grib_context_log(acc->context, GRIB_LOG_ERROR,
"List %s creating %ld values, unable to evaluate long", acc->name, val);
"List %s creating %ld values: Unable to evaluate long", acc->name, val);
}
*doit = (val != acc->loop);

View File

@ -73,16 +73,15 @@ grib_action* grib_action_create_noop(grib_context* context, const char* fname)
{
char buf[1024];
grib_action_noop* a;
grib_action_class* c = grib_action_class_noop;
grib_action* act = (grib_action*)grib_context_malloc_clear_persistent(context, c->size);
act->op = grib_context_strdup_persistent(context, "section");
act->cclass = c;
a = (grib_action_noop*)act;
grib_action_noop* a = (grib_action_noop*)act;
act->context = context;
snprintf(buf, 1024, "_noop%p", (void*)a);
snprintf(buf, sizeof(buf), "_noop%p", (void*)a);
act->name = grib_context_strdup_persistent(context, buf);

View File

@ -111,17 +111,13 @@ static void remove_accessor(grib_accessor* a)
a->next->previous = a->previous;
grib_accessor_delete(s->h->context, a);
return;
}
static int create_accessor(grib_section* p, grib_action* act, grib_loader* h)
{
grib_action_remove* a = (grib_action_remove*)act;
grib_accessor* ga = NULL;
ga = grib_find_accessor(p->h, grib_arguments_get_name(p->h, a->args, 0));
grib_accessor* ga = grib_find_accessor(p->h, grib_arguments_get_name(p->h, a->args, 0));
if (ga) {
remove_accessor(ga);
@ -134,15 +130,15 @@ static int create_accessor(grib_section* p, grib_action* act, grib_loader* h)
static void dump(grib_action* act, FILE* f, int lvl)
{
grib_action_remove* a = (grib_action_remove*)act;
int i = 0;
for (i = 0; i < lvl; i++)
grib_context_print(act->context, f, " ");
grib_context_print(act->context, f, "remove %s as %s in %s\n", grib_arguments_get_name(0, a->args, 0), act->name, grib_arguments_get_name(0, a->args, 1));
grib_context_log(act->context, GRIB_LOG_ERROR, "%s: dump not implemented", act->name);
// grib_action_remove* a = (grib_action_remove*)act;
// int i = 0;
// for (i = 0; i < lvl; i++)
// grib_context_print(act->context, f, " ");
// grib_context_print(act->context, f, "remove %s as %s in %s\n",
// grib_arguments_get_name(0, a->args, 0), act->name, grib_arguments_get_name(0, a->args, 1));
}
static void destroy(grib_context* context, grib_action* act)
{
grib_action_remove* a = (grib_action_remove*)act;
@ -151,4 +147,3 @@ static void destroy(grib_context* context, grib_action* act)
grib_context_free_persistent(context, act->name);
grib_context_free_persistent(context, act->op);
}

View File

@ -115,7 +115,7 @@ static int execute(grib_action* a, grib_handle* h)
static void dump(grib_action* act, FILE* f, int lvl)
{
int i = 0;
grib_action_set* self = (grib_action_set*)act;
const grib_action_set* self = (grib_action_set*)act;
for (i = 0; i < lvl; i++)
grib_context_print(act->context, f, " ");
grib_context_print(act->context, f, self->name);

View File

@ -98,15 +98,14 @@ grib_action* grib_action_create_set_darray(grib_context* context,
static int execute(grib_action* a, grib_handle* h)
{
grib_action_set_darray* self = (grib_action_set_darray*)a;
const grib_action_set_darray* self = (grib_action_set_darray*)a;
return grib_set_double_array(h, self->name, self->darray->v, self->darray->n);
}
static void dump(grib_action* act, FILE* f, int lvl)
{
int i = 0;
grib_action_set_darray* self = (grib_action_set_darray*)act;
const grib_action_set_darray* self = (grib_action_set_darray*)act;
for (i = 0; i < lvl; i++)
grib_context_print(act->context, f, " ");
grib_context_print(act->context, f, self->name);

View File

@ -8,9 +8,6 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
/***************************************************************************
* Enrico Fucile *
***************************************************************************/
#include "grib_api_internal.h"
/*
This is used by make_class.pl
@ -73,8 +70,7 @@ static void init_class(grib_action_class* c)
}
/* END_CLASS_IMP */
grib_action* grib_action_create_set_missing(grib_context* context,
const char* name)
grib_action* grib_action_create_set_missing(grib_context* context, const char* name)
{
char buf[1024];
@ -98,19 +94,19 @@ grib_action* grib_action_create_set_missing(grib_context* context,
static int execute(grib_action* a, grib_handle* h)
{
grib_action_set_missing* self = (grib_action_set_missing*)a;
const grib_action_set_missing* self = (grib_action_set_missing*)a;
return grib_set_missing(h, self->name);
}
static void dump(grib_action* act, FILE* f, int lvl)
{
int i = 0;
grib_action_set_missing* self = (grib_action_set_missing*)act;
for (i = 0; i < lvl; i++)
grib_context_print(act->context, f, " ");
grib_context_print(act->context, f, self->name);
printf("\n");
grib_context_log(act->context, GRIB_LOG_ERROR, "%s %s(): Not implemented", __FILE__, __func__);
// int i = 0;
// const grib_action_set_missing* self = (grib_action_set_missing*)act;
// for (i = 0; i < lvl; i++)
// grib_context_print(act->context, f, " ");
// grib_context_print(act->context, f, self->name);
// printf("\n");
}
static void destroy(grib_context* context, grib_action* act)

View File

@ -72,9 +72,7 @@ static void init_class(grib_action_class* c)
}
/* END_CLASS_IMP */
grib_action* grib_action_create_set_sarray(grib_context* context,
const char* name,
grib_sarray* sarray)
grib_action* grib_action_create_set_sarray(grib_context* context, const char* name, grib_sarray* sarray)
{
char buf[1024];
@ -100,14 +98,13 @@ grib_action* grib_action_create_set_sarray(grib_context* context,
static int execute(grib_action* a, grib_handle* h)
{
grib_action_set_sarray* self = (grib_action_set_sarray*)a;
return grib_set_string_array(h, self->name, (const char**)self->sarray->v, self->sarray->n);
}
static void dump(grib_action* act, FILE* f, int lvl)
{
int i = 0;
grib_action_set_sarray* self = (grib_action_set_sarray*)act;
const grib_action_set_sarray* self = (grib_action_set_sarray*)act;
for (i = 0; i < lvl; i++)
grib_context_print(act->context, f, " ");
grib_context_print(act->context, f, self->name);

View File

@ -10,7 +10,6 @@
/***************************************************************************
* Jean Baptiste Filippi - 01.11.2005 *
* Enrico Fucile *
***************************************************************************/
#include "grib_api_internal.h"
@ -115,19 +114,17 @@ static void dump(grib_action* act, FILE* f, int lvl)
grib_context_print(act->context, f, "Template %s %s\n", act->name, a->arg);
}
grib_action* get_empty_template(grib_context* c, int* err)
static grib_action* get_empty_template(grib_context* c, int* err)
{
char fname[] = "empty_template.def";
char* path = 0;
path = grib_context_full_defs_path(c, fname);
const char* path = grib_context_full_defs_path(c, fname);
if (path) {
*err = GRIB_SUCCESS;
return grib_parse_file(c, path);
}
else {
*err = GRIB_INTERNAL_ERROR;
grib_context_log(c, GRIB_LOG_ERROR, "get_empty_template: unable to get template %s", fname);
grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to get template %s", __func__, fname);
return NULL;
}
}

View File

@ -123,7 +123,7 @@ static int execute(grib_action* act, grib_handle* h)
static void dump(grib_action* act, FILE* f, int lvl)
{
int i = 0;
grib_action_transient_darray* self = (grib_action_transient_darray*)act;
const grib_action_transient_darray* self = (grib_action_transient_darray*)act;
for (i = 0; i < lvl; i++)
grib_context_print(act->context, f, " ");
grib_context_print(act->context, f, self->name);

View File

@ -213,6 +213,37 @@ int is_date_valid(long year, long month, long day, long hour, long minute, doubl
return 1;
}
// Return 1 if input date is valid. Otherwise 0
// Note: In the 24-hour time notation, the day begins at midnight, 00:00 or 0:00,
// and the last minute of the day begins at 23:59.
// Where convenient, the notation 24:00 may also be used to refer to midnight
// at the end of a given date — that is, 24:00 of one day is the same time
// as 00:00 of the following day
int is_time_valid(long number)
{
// Number should be 4 digits i.e., HHMM
if (number < 0 || number > 9999) {
return 0;
}
// Extract hours and minutes
long hours = number / 100; // Get the first two digits as hours
long minutes = number % 100; // Get the last two digits as minutes
// Check if hours are within the valid range (00-24)
if (hours < 0 || hours > 24) {
return 0;
}
// Check if minutes are within the valid range (00-59)
if (minutes < 0 || minutes > 59) {
return 0;
}
// All checks pass
return 1;
}
static float float_epsilon(void)
{
float floatEps = 1.0;

View File

@ -1,30 +1,49 @@
/*
* (C) Copyright 2005- ECMWF.
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
*
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
/*
* Description: concept index
*
*/
#include "grib_api_internal.h"
typedef struct grib_concept_index_keys grib_concept_index_keys;
typedef struct grib_concept_index grib_concept_index;
typedef struct grib_conditions_tree grib_conditions_tree;
typedef struct grib_concept_index_entry grib_concept_index_entry;
typedef struct grib_concept_index_keys grib_concept_index_keys;
struct grib_concept_index_entry {
char* name;
char* value;
int type;
grib_concept_index_entry* next;
};
struct grib_concept_index_keys {
char* name;
int type;
grib_concept_index_keys* next;
};
struct grib_concept_index {
grib_context* context;
grib_concept_index_keys* keys;
grib_conditions_tree* conditions;
};
struct grib_conditions_tree {
char* value;
void* object;
grib_conditions_tree* next;
grib_conditions_tree* next_key;
};
static grib_concept_index_entry* index_entry_new(grib_context* c, grib_concept_index_keys* keys)
{
grib_concept_index_entry* entry = NULL;
grib_concept_index_entry* e;
Assert(keys);
if (!c)
c = grib_context_get_default();
entry = grib_context_malloc_clear(c, sizeof(grib_concept_index_entry));
entry = (grib_concept_index_entry*)grib_context_malloc_clear(c, sizeof(grib_concept_index_entry));
if (!entry)
grib_context_log(c, GRIB_LOG_FATAL, "grib_concept_index_entry unable to allocate");
e = entry;
@ -32,7 +51,7 @@ static grib_concept_index_entry* index_entry_new(grib_context* c, grib_concept_i
while (keys && keys->name) {
e->name = grib_context_strdup(c, keys->name);
e->type = keys->type;
e->next = grib_context_malloc_clear(c, sizeof(grib_concept_index_entry));
e->next = (grib_concept_index_entry*)grib_context_malloc_clear(c, sizeof(grib_concept_index_entry));
if (!e->next)
grib_context_log(c, GRIB_LOG_FATAL, "grib_concept_index_entry unable to allocate");
@ -65,17 +84,17 @@ static int index_insert_entry(grib_concept_index* index, grib_concept_index_entr
while (keys->name) {
if (!cur) {
cur = grib_context_malloc_clear_persistent(index->context, sizeof(grib_conditions_tree));
cur = (grib_conditions_tree*)grib_context_malloc_clear_persistent(index->context, sizeof(grib_conditions_tree));
if (!cur)
grib_context_log(index->context, GRIB_LOG_FATAL, "index_insert_entry unable to allocate");
prev->next = cur;
}
value = entry->value ? entry->value : "*";
char* value = entry->value ? entry->value : (char*)"*";
while (cur && (!cur->value || (found = !strcmp(cur->value, value)) == 0))
cur = cur->next;
if (!found) {
cur->next = grib_context_malloc_clear_persistent(index->context, sizeof(grib_conditions_tree));
cur->next = (grib_conditions_tree*)grib_context_malloc_clear_persistent(index->context, sizeof(grib_conditions_tree));
Assert(cur->next);
cur = cur->next;
}
@ -103,6 +122,9 @@ static void index_add_conditions(grib_concept_index* index, grib_concept_conditi
char s[512] = {0,};
grib_concept_index_entry* e;
grib_concept_index_entry* entry = index_entry_new(index->context, index->keys);
long lres;
double dres;
int err = 0;
while (c) {
size_t size = 512;
@ -136,7 +158,7 @@ static void index_add_conditions(grib_concept_index* index, grib_concept_conditi
e->value = grib_context_strdup(index->context, s);
if (!e->name) {
e->name = grib_context_strdup(index->context, c->name);
e->next = grib_context_malloc_clear_persistent(index->context, sizeof(grib_concept_index_entry));
e->next = (grib_concept_index_entry*)grib_context_malloc_clear_persistent(index->context, sizeof(grib_concept_index_entry));
if (!e->next)
grib_context_log(index->context, GRIB_LOG_FATAL, "index_add_conditions unable to allocate");
}
@ -156,14 +178,13 @@ grib_concept_index* grib_concept_index_new_from_concept(grib_context* c, grib_co
if (!c)
c = grib_context_get_default();
index = grib_context_malloc_clear_persistent(c, sizeof(grib_concept_index));
index->keys = grib_context_malloc_clear_persistent(c, sizeof(grib_concept_index_key));
index->conditions = grib_context_malloc_clear_persistent(c, sizeof(grib_conditions_tree));
index->conditions = grib_context_malloc_clear_persistent(c, sizeof(grib_conditions_tree));
index = (grib_concept_index*)grib_context_malloc_clear_persistent(c, sizeof(grib_concept_index));
index->keys = (grib_concept_index_keys*)grib_context_malloc_clear_persistent(c, sizeof(grib_concept_index_keys));
index->conditions = (grib_conditions_tree*)grib_context_malloc_clear_persistent(c, sizeof(grib_conditions_tree));
index->context = c;
while (concept) {
index_add_conditions(index, concept->conditions, err);
index_add_conditions(index, concept->conditions);
concept = concept->next;
}

View File

@ -8,11 +8,6 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
/**************************************
* Enrico Fucile
**************************************/
#include "grib_api_internal.h"
/*
@ -89,7 +84,7 @@ static void init_class(grib_expression_class* c)
static const char* get_name(grib_expression* g)
{
grib_expression_column* e = (grib_expression_column*)g;
const grib_expression_column* e = (grib_expression_column*)g;
return e->name;
}
@ -131,7 +126,6 @@ static void destroy(grib_context* c, grib_expression* g)
grib_context_free_persistent(c, e->name);
}
grib_expression* new_column_expression(grib_context* c, const char* name)
{
grib_expression_column* e = grib_context_malloc_clear_persistent(c, sizeof(grib_expression_column));

View File

@ -8,11 +8,6 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
/**************************************
* Enrico Fucile
**************************************/
#include "grib_api_internal.h"
/*
@ -22,7 +17,7 @@
CLASS = expression
IMPLEMENTS = destroy
IMPLEMENTS = native_type
IMPLEMENTS = evaluate;print
IMPLEMENTS = print
IMPLEMENTS = add_dependency
MEMBERS = long value
END_CLASS_DEF
@ -83,15 +78,9 @@ static void init_class(grib_expression_class* c)
}
/* END_CLASS_IMP */
static long evaluate(grib_expression* g, grib_handle* h)
{
grib_expression_constant* e = (grib_expression_constant*)g;
return e->value;
}
static void print(grib_context* c, grib_expression* g, grib_handle* f)
{
grib_expression_constant* e = (grib_expression_constant*)g;
const grib_expression_constant* e = (grib_expression_constant*)g;
printf("constant(%ld)", e->value);
}
@ -100,7 +89,6 @@ static void destroy(grib_context* c, grib_expression* g)
/* grib_expression_constant* e = (grib_expression_constant*)g; */
}
static void add_dependency(grib_expression* g, grib_accessor* observer)
{
/* grib_expression_constant* e = (grib_expression_constant*)g; */

View File

@ -57,7 +57,6 @@ grib_action* grib_action_create_assert(grib_context* context, grib_expression* e
/* action_class_template.cc*/
grib_action* grib_action_create_template(grib_context* context, int nofail, const char* name, const char* arg1);
grib_action* get_empty_template(grib_context* c, int* err);
/* action_class_trigger.cc*/
grib_action* grib_action_create_trigger(grib_context* context, grib_arguments* args, grib_action* block);
@ -109,7 +108,6 @@ grib_action* grib_action_create_transient_darray(grib_context* context, const ch
/* grib_accessor.cc*/
void grib_accessor_dump(grib_accessor* a, grib_dumper* f);
int grib_pack_missing(grib_accessor* a);
int grib_pack_zero(grib_accessor* a);
int grib_is_missing_internal(grib_accessor* a);
int grib_pack_double(grib_accessor* a, const double* v, size_t* len);
int grib_pack_float(grib_accessor* a, const float* v, size_t* len);
@ -151,17 +149,12 @@ grib_accessor* grib_next_accessor(grib_accessor* a);
void grib_resize(grib_accessor* a, size_t new_size);
int grib_compare_accessors(grib_accessor* a1, grib_accessor* a2, int compare_flags);
int grib_accessor_add_attribute(grib_accessor* a, grib_accessor* attr, int nest_if_clash);
int grib_accessor_replace_attribute(grib_accessor* a, grib_accessor* attr);
int grib_accessor_delete_attribute(grib_accessor* a, const char* name);
grib_accessor* grib_accessor_get_attribute_by_index(grib_accessor* a, int index);
const char* grib_accessor_get_name(grib_accessor* a);
grib_accessor* grib_accessor_get_attribute_index(grib_accessor* a, const char* name, int* index);
int grib_accessor_has_attributes(grib_accessor* a);
grib_accessor* grib_accessor_get_attribute(grib_accessor* a, const char* name);
grib_accessors_list* grib_accessors_list_create(grib_context* c);
void grib_accessors_list_push(grib_accessors_list* al, grib_accessor* a, int rank);
grib_accessors_list* grib_accessors_list_last(grib_accessors_list* al);
grib_accessors_list* grib_accessors_list_find(grib_accessors_list* al, const grib_accessor* a);
void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al);
/* grib_concept.cc*/
@ -172,7 +165,6 @@ void grib_concept_condition_delete(grib_context* c, grib_concept_condition* v);
/* grib_hash_array.cc*/
grib_hash_array_value* grib_integer_hash_array_value_new(grib_context* c, const char* name, grib_iarray* array);
void grib_hash_array_value_delete(grib_context* c, grib_hash_array_value* v);
/* grib_bufr_descriptor.cc*/
bufr_descriptor* grib_bufr_descriptor_new(grib_accessor* tables_accessor, int code, int silent, int* err);
@ -656,7 +648,6 @@ void grib_index_dump(FILE* fout, grib_index* index, unsigned long flags);
char* grib_get_field_file(grib_index* index, off_t* offset);
grib_handle* grib_handle_new_from_index(grib_index* index, int* err);
grib_handle* codes_new_from_index(grib_index* index, int message_type, int* err);
void grib_index_rewind(grib_index* index);
int codes_index_set_product_kind(grib_index* index, ProductKind product_kind);
int codes_index_set_unpack_bufr(grib_index* index, int unpack);
int is_index_file(const char* filename);
@ -1104,8 +1095,8 @@ double grib_power(long s, long n);
long grib_get_binary_scale_fact(double max, double min, long bpval, int* error);
/* grib_templates.cc*/
grib_handle* codes_external_template(grib_context* c, ProductKind product_kind, const char* name);
char* get_external_template_path(grib_context* c, const char* name);
grib_handle* codes_external_sample(grib_context* c, ProductKind product_kind, const char* name);
char* get_external_sample_path(grib_context* c, const char* name);
/* grib_dependency.cc */
grib_handle* grib_handle_of_accessor(const grib_accessor* a);
@ -1311,7 +1302,6 @@ const char* grib_expression_get_name(grib_expression* g);
void grib_expression_print(grib_context* ctx, grib_expression* g, grib_handle* f);
void grib_expression_free(grib_context* ctx, grib_expression* g);
void grib_expression_add_dependency(grib_expression* e, grib_accessor* observer);
int grib_expression_set_value(grib_handle* h, grib_expression* g, grib_values* v);
grib_arguments* grib_arguments_new(grib_context* c, grib_expression* g, grib_arguments* n);
void grib_arguments_free(grib_context* c, grib_arguments* g);
void grib_arguments_print(grib_context* c, grib_arguments* g, grib_handle* f);
@ -1331,6 +1321,7 @@ char* codes_getenv(const char* name);
int codes_check_grib_ieee_packing_value(int value);
int codes_flush_sync_close_file(FILE* f);
int is_date_valid(long year, long month, long day, long hour, long minute, double second);
int is_time_valid(long number); // number is HHMM
int compute_scaled_value_and_scale_factor(double input, int64_t scaled_value_max, int64_t scale_factor_max, int64_t* ret_value, int64_t* ret_factor);
/* grib_util.cc*/
@ -1347,9 +1338,9 @@ int grib2_is_PDTN_Aerosol(long productDefinitionTemplateNumber);
int grib2_is_PDTN_AerosolOptical(long productDefinitionTemplateNumber);
int grib2_select_PDTN(int is_eps, int is_instant, int is_chemical, int is_chemical_srcsink, int is_chemical_distfn, int is_aerosol, int is_aerosol_optical);
size_t sum_of_pl_array(const long* pl, size_t plsize);
int grib_is_earth_oblate(grib_handle* h);
int grib_is_earth_oblate(const grib_handle* h);
int grib_check_data_values_minmax(grib_handle* h, const double min_val, const double max_val);
int grib_producing_large_constant_fields(grib_handle* h, int edition);
int grib_producing_large_constant_fields(const grib_handle* h, int edition);
int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max_val);
/* bufr_util.cc*/
@ -1381,8 +1372,6 @@ long grib_op_eq(long a, long b);
long grib_op_ne(long a, long b);
long grib_op_lt(long a, long b);
long grib_op_gt(long a, long b);
long grib_op_and(long a, long b);
long grib_op_or(long a, long b);
long grib_op_ge(long a, long b);
long grib_op_le(long a, long b);
long grib_op_bit(long a, long b);

View File

@ -1,17 +1,11 @@
typedef const char* string; /* to keep make_class.pl happy */
static void init_class (grib_expression_class*);
static void init(grib_expression* e);
static void destroy(grib_context*,grib_expression* e);
static void print(grib_context*,grib_expression*,grib_handle*);
static void add_dependency(grib_expression* e, grib_accessor* observer);
static string get_name(grib_expression* e);
static int native_type(grib_expression*,grib_handle*);
static int evaluate_long(grib_expression*,grib_handle*,long*);
static int evaluate_double(grib_expression*,grib_handle*,double*);
static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*);
@ -28,7 +22,6 @@ static grib_expression_class _grib_expression_class_NAME = {
"NAME", /* name */
sizeof(grib_expression_NAME),/* size of instance */
0, /* inited */
&init_class, /* init_class */
&init, /* constructor */
&destroy, /* destructor */
&print,
@ -44,8 +37,3 @@ grib_expression_class* grib_expression_class_NAME = &_grib_expression_class_NAME
ADD_TO_FILE grib_expression_class.h extern grib_expression_class* grib_expression_class_NAME;
ADD_TO_FILE grib_expression_factory.h { "NAME", &grib_expression_class_NAME, },
static void init_class(grib_expression_class* c)
{
INIT
}

View File

@ -27,14 +27,14 @@ long grib_op_gt(long a, long b)
{
return a > b;
}
long grib_op_and(long a, long b)
{
return a && b;
}
long grib_op_or(long a, long b)
{
return a || b;
}
// long grib_op_and(long a, long b)
// {
// return a && b;
// }
// long grib_op_or(long a, long b)
// {
// return a || b;
// }
long grib_op_ge(long a, long b)
{
return a >= b;
@ -43,7 +43,6 @@ long grib_op_le(long a, long b)
{
return a <= b;
}
long grib_op_bit(long a, long b)
{
return a & (1 << b);
@ -52,7 +51,6 @@ long grib_op_bitoff(long a, long b)
{
return !grib_op_bit(a, b);
}
long grib_op_not(long a)
{
return !a;
@ -61,15 +59,14 @@ long grib_op_neg(long a)
{
return -a;
}
double grib_op_neg_d(double a)
{
return -a;
}
// Note: This is actually 'a' to the power 'b'
long grib_op_pow(long a, long b)
{
/* Note: This is actually 'a' to the power 'b' */
return codes_power<double>(b, a);
}
@ -93,7 +90,6 @@ long grib_op_modulo(long a, long b)
{
return a % b;
}
double grib_op_mul_d(double a, double b)
{
return a * b;
@ -102,7 +98,6 @@ double grib_op_div_d(double a, double b)
{
return a / b;
}
double grib_op_add_d(double a, double b)
{
return a + b;
@ -111,7 +106,6 @@ double grib_op_sub_d(double a, double b)
{
return a - b;
}
double grib_op_eq_d(double a, double b)
{
return a == b;

View File

@ -10,13 +10,12 @@
/***************************************************************************
* Jean Baptiste Filippi - 01.11.2005
* Enrico Fucile
***************************************************************************/
#include "grib_accessor.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 */
// 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)
@ -44,7 +43,7 @@ void grib_accessor_dump(grib_accessor* a, grib_dumper* f)
int grib_pack_missing(grib_accessor* a)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0);
while (c) {
if (c->pack_missing) {
return c->pack_missing(a);
@ -55,24 +54,24 @@ int grib_pack_missing(grib_accessor* a)
return 0;
}
int grib_pack_zero(grib_accessor* a)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
while (c) {
if (c->clear) {
return c->clear(a);
}
c = c->super ? *(c->super) : NULL;
}
DEBUG_ASSERT(0);
return 0;
}
// int grib_pack_zero(grib_accessor* a)
// {
// grib_accessor_class* c = a->cclass;
// while (c) {
// if (c->clear) {
// return c->clear(a);
// }
// c = c->super ? *(c->super) : NULL;
// }
// DEBUG_ASSERT(0);
// return 0;
// }
int grib_is_missing_internal(grib_accessor* a)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
// grib_context_log(a->context, GRIB_LOG_DEBUG,
// "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0);
while (c) {
if (c->is_missing) {
return c->is_missing(a);
@ -86,7 +85,7 @@ int grib_is_missing_internal(grib_accessor* a)
int grib_pack_double(grib_accessor* a, const double* v, size_t* len)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0);
while (c) {
if (c->pack_double) {
return c->pack_double(a, v, len);
@ -113,7 +112,7 @@ int grib_pack_float(grib_accessor* a, const float* v, size_t* len)
int grib_pack_expression(grib_accessor* a, grib_expression* e)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0);
while (c) {
if (c->pack_expression) {
return c->pack_expression(a, e);
@ -127,7 +126,7 @@ int grib_pack_expression(grib_accessor* a, grib_expression* e)
int grib_pack_string(grib_accessor* a, const char* v, size_t* len)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (string) %s",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?v:"(null)");*/
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (string) %s",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?v:"(null)");
while (c) {
if (c->pack_string) {
return c->pack_string(a, v, len);
@ -141,7 +140,7 @@ int grib_pack_string(grib_accessor* a, const char* v, size_t* len)
int grib_pack_string_array(grib_accessor* a, const char** v, size_t* len)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (string) %s",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?v:"(null)");*/
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (string) %s",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?v:"(null)");
while (c) {
if (c->pack_string_array) {
return c->pack_string_array(a, v, len);
@ -155,7 +154,7 @@ int grib_pack_string_array(grib_accessor* a, const char** v, size_t* len)
int grib_pack_long(grib_accessor* a, const long* v, size_t* len)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0);
while (c) {
if (c->pack_long) {
return c->pack_long(a, v, len);
@ -169,7 +168,7 @@ int grib_pack_long(grib_accessor* a, const long* v, size_t* len)
int grib_pack_bytes(grib_accessor* a, const unsigned char* v, size_t* len)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (bytes) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (bytes) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0);
while (c) {
if (c->pack_bytes) {
return c->pack_bytes(a, v, len);
@ -183,7 +182,7 @@ int grib_pack_bytes(grib_accessor* a, const unsigned char* v, size_t* len)
int grib_unpack_bytes(grib_accessor* a, unsigned char* v, size_t* len)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (bytes)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (bytes)",(a->parent->owner)?(a->parent->owner->name):"root", a->name);
while (c) {
if (c->unpack_bytes) {
return c->unpack_bytes(a, v, len);
@ -210,7 +209,7 @@ int grib_unpack_double_subarray(grib_accessor* a, double* v, size_t start, size_
int grib_unpack_double(grib_accessor* a, double* v, size_t* len)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (double)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (double)",(a->parent->owner)?(a->parent->owner->name):"root", a->name);
while (c) {
if (c->unpack_double) {
return c->unpack_double(a, v, len);
@ -225,7 +224,7 @@ int grib_unpack_float(grib_accessor* a, float* v, size_t* len)
{
grib_accessor_class* c = a->cclass;
while (c) {
/* printf("grib_accessor.c grib_unpack_float:: c->name=%s\n",c->name); */
//printf("grib_accessor.c grib_unpack_float:: c->name=%s\n",c->name);
if (c->unpack_float) {
return c->unpack_float(a, v, len);
}
@ -260,20 +259,19 @@ int grib_unpack_double_element(grib_accessor* a, size_t i, double* v)
}
int grib_unpack_float_element(grib_accessor* a, size_t i, float* v)
{
/* grib_accessor_class* c = a->cclass;
* while (c) {
* if (c->unpack_float_element) {
* return c->unpack_float_element(a, i, v);
* }
* c = c->super ? *(c->super) : NULL;
* }
*/
// grib_accessor_class* c = a->cclass;
// while (c) {
// if (c->unpack_float_element) {
// return c->unpack_float_element(a, i, v);
// }
// c = c->super ? *(c->super) : NULL;
//}
return GRIB_NOT_IMPLEMENTED;
}
/* Get the values for the indices passed in.
* The length of the 'index_array' argument should be 'len' and 'val_array' should also contain at least 'len' elements
*/
// Get the values for the indices passed in.
// The length of the 'index_array' argument should be 'len' and 'val_array' should also contain at least 'len' elements
int grib_unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array)
{
grib_accessor_class* c = a->cclass;
@ -288,23 +286,22 @@ int grib_unpack_double_element_set(grib_accessor* a, const size_t* index_array,
}
int grib_unpack_float_element_set(grib_accessor* a, const size_t* index_array, size_t len, float* val_array)
{
/*
*grib_accessor_class* c = a->cclass;
*DEBUG_ASSERT(len > 0);
*while (c) {
* if (c->unpack_float_element_set) {
* return c->unpack_float_element_set(a, index_array, len, val_array);
* }
* c = c->super ? *(c->super) : NULL;
*}
*/
// grib_accessor_class* c = a->cclass;
// DEBUG_ASSERT(len > 0);
// while (c) {
// if (c->unpack_float_element_set) {
// return c->unpack_float_element_set(a, index_array, len, val_array);
// }
// c = c->super ? *(c->super) : NULL;
// }
return GRIB_NOT_IMPLEMENTED;
}
int grib_unpack_string(grib_accessor* a, char* v, size_t* len)
{
grib_accessor_class* c = a->cclass;
/* grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (string)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (string)",(a->parent->owner)?(a->parent->owner->name):"root", a->name );
while (c) {
if (c->unpack_string) {
return c->unpack_string(a, v, len);
@ -399,7 +396,7 @@ int grib_accessors_list_unpack_string(grib_accessors_list* al, char** val, size_
int grib_unpack_long(grib_accessor* a, long* v, size_t* len)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (long)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
//grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (long)",(a->parent->owner)?(a->parent->owner->name):"root", a->name );
while (c) {
if (c->unpack_long) {
return c->unpack_long(a, v, len);
@ -428,7 +425,8 @@ long grib_accessor_get_native_type(grib_accessor* a)
long grib_get_next_position_offset(grib_accessor* a)
{
grib_accessor_class* c = NULL;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is checking next (long)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); */
//grib_context_log(a->context, GRIB_LOG_DEBUG,
// "(%s)%s is checking next (long)",(a->parent->owner)?(a->parent->owner->name):"root", a->name );
if (a)
c = a->cclass;
@ -528,13 +526,12 @@ int grib_accessor_notify_change(grib_accessor* a, grib_accessor* changed)
c = c->super ? *(c->super) : NULL;
}
if (a && a->cclass)
printf("notify_change not implemented for %s %s\n", a->cclass->name, a->name);
fprintf(stderr, "Error: notify_change not implemented for %s %s\n", a->cclass->name, a->name);
DEBUG_ASSERT(0);
return 0;
}
/* For this one, ALL init are called */
// For this one, ALL init are called
static void init_accessor(grib_accessor_class* c, grib_accessor* a, const long len, grib_arguments* args)
{
if (c) {
@ -550,27 +547,26 @@ void grib_init_accessor(grib_accessor* a, const long len, grib_arguments* args)
init_accessor(a->cclass, a, len, args);
}
/* For this one, ALL destroy are called */
// For this one, ALL destroy are called
void grib_accessor_delete(grib_context* ct, grib_accessor* a)
{
grib_accessor_class* c = a->cclass;
while (c) {
grib_accessor_class* s = c->super ? *(c->super) : NULL;
/*printf("grib_accessor_delete: before destroy a=%p c->name=%s ==> a->name=%s\n", (void*)a, c->name, a->name);*/
//printf("grib_accessor_delete: before destroy a=%p c->name=%s ==> a->name=%s\n", (void*)a, c->name, a->name);
if (c->destroy) {
c->destroy(ct, a);
}
c = s;
}
/*printf("grib_accessor_delete before free a=%p\n", (void*)a);*/
// printf("grib_accessor_delete before free a=%p\n", (void*)a);
grib_context_free(ct, a);
}
grib_accessor* grib_accessor_clone(grib_accessor* a, grib_section* s, int* err)
{
grib_accessor_class* c = a->cclass;
grib_context* ct = a->context;
const grib_context* ct = a->context;
while (c) {
grib_accessor_class* super = c->super ? *(c->super) : NULL;
grib_context_log(ct, GRIB_LOG_DEBUG, "clone %s ==> %s", c->name, a->name);
@ -585,7 +581,8 @@ grib_accessor* grib_accessor_clone(grib_accessor* a, grib_section* s, int* err)
void grib_update_size(grib_accessor* a, size_t len)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
//grib_context_log(a->context, GRIB_LOG_DEBUG,
// "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0);
while (c) {
if (c->update_size) {
c->update_size(a, len);
@ -613,7 +610,8 @@ int grib_nearest_smaller_value(grib_accessor* a, double val, double* nearest)
size_t grib_preferred_size(grib_accessor* a, int from_handle)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
// grib_context_log(a->context, GRIB_LOG_DEBUG,
// "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0);
while (c) {
if (c->preferred_size) {
return c->preferred_size(a, from_handle);
@ -640,7 +638,8 @@ grib_accessor* grib_next_accessor(grib_accessor* a)
void grib_resize(grib_accessor* a, size_t new_size)
{
grib_accessor_class* c = a->cclass;
/*grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); */
//grib_context_log(a->context, GRIB_LOG_DEBUG,
// "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0);
while (c) {
if (c->resize) {
c->resize(a, new_size);
@ -714,7 +713,7 @@ int grib_accessor_add_attribute(grib_accessor* a, grib_accessor* attr, int nest_
for (id = 0; id < MAX_ACCESSOR_ATTRIBUTES; id++) {
if (aloc->attributes[id] == NULL) {
/* attr->parent=a->parent; */
// attr->parent=a->parent;
aloc->attributes[id] = attr;
attr->parent_as_attribute = aloc;
if (aloc->same)
@ -727,48 +726,47 @@ int grib_accessor_add_attribute(grib_accessor* a, grib_accessor* attr, int nest_
return GRIB_TOO_MANY_ATTRIBUTES;
}
int grib_accessor_replace_attribute(grib_accessor* a, grib_accessor* attr)
{
int id = 0;
int idx = 0;
if (grib_accessor_get_attribute_index(a, attr->name, &id) != NULL) {
grib_accessor_delete(a->context, a->attributes[id]);
a->attributes[id] = attr;
attr->parent_as_attribute = a;
if (a->same)
attr->same = grib_accessor_get_attribute_index(a->same, attr->name, &idx);
}
else {
grib_accessor_add_attribute(a, attr, 0);
}
return GRIB_SUCCESS;
}
// int grib_accessor_replace_attribute(grib_accessor* a, grib_accessor* attr)
// {
// int id = 0;
// int idx = 0;
// if (grib_accessor_get_attribute_index(a, attr->name, &id) != NULL) {
// grib_accessor_delete(a->context, a->attributes[id]);
// a->attributes[id] = attr;
// attr->parent_as_attribute = a;
// if (a->same)
// attr->same = grib_accessor_get_attribute_index(a->same, attr->name, &idx);
// }
// else {
// grib_accessor_add_attribute(a, attr, 0);
// }
// return GRIB_SUCCESS;
// }
int grib_accessor_delete_attribute(grib_accessor* a, const char* name)
{
int id = 0;
if (grib_accessor_get_attribute_index(a, name, &id) != NULL) {
grib_accessor_delete(a->context, a->attributes[id]);
a->attributes[id] = NULL;
return GRIB_SUCCESS;
}
else {
return GRIB_NOT_FOUND;
}
}
// int grib_accessor_delete_attribute(grib_accessor* a, const char* name)
// {
// int id = 0;
// if (grib_accessor_get_attribute_index(a, name, &id) != NULL) {
// grib_accessor_delete(a->context, a->attributes[id]);
// a->attributes[id] = NULL;
// return GRIB_SUCCESS;
// }
// else {
// return GRIB_NOT_FOUND;
// }
// }
grib_accessor* grib_accessor_get_attribute_by_index(grib_accessor* a, int index)
{
if (index < MAX_ACCESSOR_ATTRIBUTES)
return a->attributes[index];
// grib_accessor* grib_accessor_get_attribute_by_index(grib_accessor* a, int index)
// {
// if (index < MAX_ACCESSOR_ATTRIBUTES)
// return a->attributes[index];
// return NULL;
// }
return NULL;
}
const char* grib_accessor_get_name(grib_accessor* a)
{
return a->name;
}
// const char* grib_accessor_get_name(grib_accessor* a)
// {
// return a->name;
// }
grib_accessor* grib_accessor_get_attribute_index(grib_accessor* a, const char* name, int* index)
{
@ -823,7 +821,7 @@ grib_accessors_list* grib_accessors_list_create(grib_context* c)
void grib_accessors_list_push(grib_accessors_list* al, grib_accessor* a, int rank)
{
grib_accessors_list* last;
grib_context* c = a->context;
const grib_context* c = a->context;
last = grib_accessors_list_last(al);
if (last && last->accessor) {
@ -842,32 +840,27 @@ void grib_accessors_list_push(grib_accessors_list* al, grib_accessor* a, int ran
grib_accessors_list* grib_accessors_list_last(grib_accessors_list* al)
{
/*grib_accessors_list* last=al;*/
/*grib_accessors_list* next=al->next;*/
/*
while(next) {
last=next;
next=last->next;
}
*/
// grib_accessors_list* last=al;
// grib_accessors_list* next=al->next;
// while(next) {
// last=next;
// next=last->next;
// }
return al->last;
}
grib_accessors_list* grib_accessors_list_find(grib_accessors_list* al, const grib_accessor* a)
{
grib_accessors_list* last = al;
grib_accessors_list* next = al->next;
while (next) {
if (last->accessor == a)
return last;
last = next;
next = last->next;
}
return NULL;
}
// grib_accessors_list* grib_accessors_list_find(grib_accessors_list* al, const grib_accessor* a)
// {
// grib_accessors_list* last = al;
// grib_accessors_list* next = al->next;
// while (next) {
// if (last->accessor == a)
// return last;
// last = next;
// next = last->next;
// }
// return NULL;
// }
void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al)
{
@ -875,7 +868,7 @@ void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al)
while (al) {
tmp = al->next;
/*grib_accessor_delete(c, al->accessor);*/
//grib_accessor_delete(c, al->accessor);
grib_context_free(c, al);
al = tmp;
}

View File

@ -131,6 +131,7 @@ extern grib_accessor_class* grib_accessor_class_mars_step;
extern grib_accessor_class* grib_accessor_class_md5;
extern grib_accessor_class* grib_accessor_class_message;
extern grib_accessor_class* grib_accessor_class_message_copy;
extern grib_accessor_class* grib_accessor_class_multdouble;
extern grib_accessor_class* grib_accessor_class_nearest;
extern grib_accessor_class* grib_accessor_class_non_alpha;
extern grib_accessor_class* grib_accessor_class_number_of_coded_values;

View File

@ -17,7 +17,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
MEMBERS = const char* owner
MEMBERS = int bit_index
END_CLASS_DEF
@ -36,7 +36,6 @@ or edit "accessor.class" and rerun ./make_class.pl
static int pack_long(grib_accessor*, const long* val, size_t* len);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_bit
@ -60,7 +59,7 @@ static grib_accessor_class _grib_accessor_class_bit = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -112,10 +111,6 @@ static void init(grib_accessor* a, const long len, grib_arguments* arg)
self->bit_index = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1);
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{

View File

@ -272,8 +272,8 @@ static int unpack_string_array(grib_accessor* a, char** val, size_t* len)
{
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
int ret = 0, i, idx;
long count = 0;
int ret = 0, idx = 0;
size_t count = 0, i = 0;
grib_context* c = a->context;
if (self->compressedData) {
@ -308,7 +308,7 @@ static int pack_string_array(grib_accessor* a, const char** v, size_t* len)
if (self->compressedData) {
idx = ((int)self->numericValues->v[self->index]->v[0] / 1000 - 1) / self->numberOfSubsets;
if (*len != 1 && *len != self->numberOfSubsets) {
if (*len != 1 && *len != (size_t)self->numberOfSubsets) {
grib_context_log(c, GRIB_LOG_ERROR, "Number of values mismatch for '%s': %ld strings provided but expected %ld (=number of subsets)",
self->descriptors->v[self->elementsDescriptorsIndex->v[0]->v[idx]]->shortName, *len, self->numberOfSubsets);
return GRIB_ARRAY_TOO_SMALL;
@ -323,7 +323,7 @@ static int pack_string_array(grib_accessor* a, const char** v, size_t* len)
}
else {
//ECC-1623
if (*len != self->numberOfSubsets) {
if (*len != (size_t)self->numberOfSubsets) {
grib_context_log(c, GRIB_LOG_ERROR,
"Number of values mismatch for '%s': %zu strings provided but expected %ld (=number of subsets)",
a->name, *len, self->numberOfSubsets);
@ -494,12 +494,12 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
{
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
int ret = GRIB_SUCCESS;
long count = 1, i = 0;
size_t count = 1, i = 0;
grib_context* c = a->context;
if (self->compressedData) {
count = *len;
if (count != 1 && count != self->numberOfSubsets) {
if (count != 1 && count != (size_t)self->numberOfSubsets) {
grib_context_log(c, GRIB_LOG_ERROR, "Number of values mismatch for '%s': %ld doubles provided but expected %ld (=number of subsets)",
self->descriptors->v[self->elementsDescriptorsIndex->v[0]->v[self->index]]->shortName, count, self->numberOfSubsets);
return GRIB_ARRAY_TOO_SMALL;
@ -523,14 +523,14 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
static int pack_long(grib_accessor* a, const long* val, size_t* len)
{
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
int ret = 0, i;
long count = 1;
int ret = 0;
size_t count = 1, i = 0;
grib_context* c = a->context;
if (self->compressedData) {
count = *len;
if (count != 1 && count != self->numberOfSubsets) {
grib_context_log(c, GRIB_LOG_ERROR, "Number of values mismatch for '%s': %ld integers provided but expected %ld (=number of subsets)",
if (count != 1 && count != (size_t)self->numberOfSubsets) {
grib_context_log(c, GRIB_LOG_ERROR, "Number of values mismatch for '%s': %zu integers provided but expected %ld (=number of subsets)",
self->descriptors->v[self->elementsDescriptorsIndex->v[0]->v[self->index]]->shortName, count, self->numberOfSubsets);
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -379,8 +379,7 @@ bufr_descriptor* accessor_bufr_elements_table_get_descriptor(grib_accessor* a, i
DEBUG_ASSERT(c);
v = (bufr_descriptor*)grib_context_malloc_clear(c, sizeof(bufr_descriptor));
if (!v) {
grib_context_log(c, GRIB_LOG_ERROR,
"accessor_bufr_elements_table_get_descriptor: unable to allocate %ld bytes\n", sizeof(bufr_descriptor));
grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(bufr_descriptor));
*err = GRIB_OUT_OF_MEMORY;
return NULL;
}

View File

@ -24,7 +24,7 @@ CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long
IMPLEMENTS = unpack_string_array
IMPLEMENTS = init;dump;destroy
IMPLEMENTS = init;destroy
IMPLEMENTS = value_count
MEMBERS = const char* expandedDescriptors
MEMBERS = grib_accessor* expandedDescriptorsAccessor
@ -47,7 +47,6 @@ static int unpack_long(grib_accessor*, long* val, size_t* len);
static int unpack_string_array(grib_accessor*, char**, size_t* len);
static int value_count(grib_accessor*, long*);
static void destroy(grib_context*, grib_accessor*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_bufrdc_expanded_descriptors
@ -71,7 +70,7 @@ static grib_accessor_class _grib_accessor_class_bufrdc_expanded_descriptors = {
&init, /* init */
0, /* post_init */
&destroy, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
&value_count, /* get number of values */
@ -125,11 +124,6 @@ static void init(grib_accessor* a, const long len, grib_arguments* args)
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static grib_accessor* get_accessor(grib_accessor* a)
{
grib_accessor_bufrdc_expanded_descriptors* self = (grib_accessor_bufrdc_expanded_descriptors*)a;

View File

@ -150,6 +150,7 @@ template <typename T>
static int unpack(grib_accessor* a, T* val, size_t* len)
{
grib_accessor_data_apply_boustrophedonic* self = (grib_accessor_data_apply_boustrophedonic*)a;
size_t plSize = 0;
long* pl = 0;
double* values = 0;
@ -306,6 +307,7 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array
static int pack_double(grib_accessor* a, const double* val, size_t* len)
{
grib_accessor_data_apply_boustrophedonic* self = (grib_accessor_data_apply_boustrophedonic*)a;
size_t plSize = 0;
long* pl = 0;
double* values = 0;

View File

@ -194,16 +194,22 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len)
}
if (units_factor != 1.0) {
if (units_bias != 0.0)
for (i = 0; i < n_vals; i++)
if (units_bias != 0.0) {
for (i = 0; i < n_vals; i++) {
val[i] = val[i] * units_factor + units_bias;
else
for (i = 0; i < n_vals; i++)
}
}
else {
for (i = 0; i < n_vals; i++) {
val[i] *= units_factor;
}
else if (units_bias != 0.0)
for (i = 0; i < n_vals; i++)
}
}
else if (units_bias != 0.0) {
for (i = 0; i < n_vals; i++) {
val[i] += units_bias;
}
}
if (c->ieee_packing && self->ieee_packing) {
long precision = 0; /* Either 1(=32 bits) or 2(=64 bits) */

View File

@ -1772,7 +1772,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
unsigned char* sec7 = reinterpret_cast<unsigned char*>(grib_context_malloc(a->context, size_sec7));
if (sec7 == NULL) {
grib_context_log(a->context, GRIB_LOG_ERROR, "%s packing: unable to allocate %d bytes", cclass_name, size_sec7);
grib_context_log(a->context, GRIB_LOG_ERROR, "%s: Unable to allocate %d bytes", cclass_name, size_sec7);
return GRIB_OUT_OF_MEMORY;
}

View File

@ -177,16 +177,21 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len)
}
if (units_factor != 1.0) {
if (units_bias != 0.0)
for (i = 0; i < n_vals; i++)
if (units_bias != 0.0) {
for (i = 0; i < n_vals; i++) {
val[i] = val[i] * units_factor + units_bias;
else
for (i = 0; i < n_vals; i++)
}
} else {
for (i = 0; i < n_vals; i++) {
val[i] *= units_factor;
}
else if (units_bias != 0.0)
for (i = 0; i < n_vals; i++)
}
}
else if (units_bias != 0.0) {
for (i = 0; i < n_vals; i++) {
val[i] += units_bias;
}
}
/* IEEE packing */
if (c->ieee_packing) {

View File

@ -225,7 +225,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
grib_accessor_data_jpeg2000_packing* self = (grib_accessor_data_jpeg2000_packing*)a;
int err = GRIB_SUCCESS;
int i;
size_t i = 0;
size_t buflen = grib_byte_count(a);
double bscale = 0;
@ -304,16 +304,21 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
val[i] = (val[i] * bscale + reference_value) * dscale;
}
if (units_factor != 1.0) {
if (units_bias != 0.0)
for (i = 0; i < n_vals; i++)
if (units_bias != 0.0) {
for (i = 0; i < n_vals; i++) {
val[i] = val[i] * units_factor + units_bias;
else
for (i = 0; i < n_vals; i++)
}
} else {
for (i = 0; i < n_vals; i++) {
val[i] *= units_factor;
}
else if (units_bias != 0.0)
for (i = 0; i < n_vals; i++)
}
}
else if (units_bias != 0.0) {
for (i = 0; i < n_vals; i++) {
val[i] += units_bias;
}
}
return err;
}

View File

@ -406,16 +406,21 @@ static int unpack(grib_accessor* a, T* val, size_t* len)
*len = (long)n_vals;
if (units_factor != 1.0) {
if (units_bias != 0.0)
for (i = 0; i < n_vals; i++)
if (units_bias != 0.0) {
for (i = 0; i < n_vals; i++) {
val[i] = val[i] * units_factor + units_bias;
else
for (i = 0; i < n_vals; i++)
}
} else {
for (i = 0; i < n_vals; i++) {
val[i] *= units_factor;
}
else if (units_bias != 0.0)
for (i = 0; i < n_vals; i++)
}
}
else if (units_bias != 0.0) {
for (i = 0; i < n_vals; i++) {
val[i] += units_bias;
}
}
return err;
}

View File

@ -7,11 +7,6 @@
* 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.
*/
/*****************************************
* Enrico Fucile
****************************************/
#include "grib_api_internal.h"
/*
This is used by make_class.pl
@ -116,22 +111,17 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
static int unpack_double(grib_accessor* a, double* val, size_t* len)
{
grib_accessor_divdouble* self = (grib_accessor_divdouble*)a;
const grib_accessor_divdouble* self = (grib_accessor_divdouble*)a;
int ret = GRIB_SUCCESS;
double value = 0;
if (*len < 1) {
*len = 1;
return GRIB_ARRAY_TOO_SMALL;
}
ret = grib_get_double_internal(grib_handle_of_accessor(a), self->val, &value);
if (ret != GRIB_SUCCESS)
return ret;
/* fprintf(stdout,"\nname %s %s %g/%g\n",a->name ,self->val,value,divisor);*/
Assert(self->divisor != 0);
if (self->divisor == 0) {
return GRIB_INVALID_ARGUMENT;
}
*val = value / self->divisor;
*len = 1;

View File

@ -26,7 +26,7 @@ SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long
IMPLEMENTS = unpack_double
IMPLEMENTS = unpack_string_array
IMPLEMENTS = init;dump;destroy
IMPLEMENTS = init;destroy
IMPLEMENTS = value_count; get_native_type
MEMBERS = const char* unexpandedDescriptors
MEMBERS = const char* sequence
@ -59,7 +59,6 @@ static int unpack_long(grib_accessor*, long* val, size_t* len);
static int unpack_string_array(grib_accessor*, char**, size_t* len);
static int value_count(grib_accessor*, long*);
static void destroy(grib_context*, grib_accessor*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_expanded_descriptors
@ -90,7 +89,7 @@ static grib_accessor_class _grib_accessor_class_expanded_descriptors = {
&init, /* init */
0, /* post_init */
&destroy, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
&value_count, /* get number of values */
@ -180,11 +179,6 @@ static void init(grib_accessor* a, const long len, grib_arguments* args)
a->length = 0;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static bufr_descriptors_array* do_expand(grib_accessor* a, bufr_descriptors_array* unexpanded, change_coding_params* ccp, int* err);
#define BUFR_DESCRIPTORS_ARRAY_USED_SIZE(v) ((v)->n)
@ -223,7 +217,7 @@ static void __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, bufr_
* Its max size is X (from FXY) which is 6 bits so no need for malloc */
bufr_descriptor* ur[65] = {0,};
bufr_descriptor* urc = NULL;
int idx;
size_t idx = 0;
bufr_descriptor* u0 = NULL;
grib_context* c = a->context;
bufr_descriptor* us = NULL;

View File

@ -17,7 +17,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long;unpack_string
IMPLEMENTS = init;dump;value_count
IMPLEMENTS = init;value_count
MEMBERS=const char* century
MEMBERS=const char* year
MEMBERS=const char* month
@ -40,7 +40,6 @@ static int pack_long(grib_accessor*, const long* val, size_t* len);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static int unpack_string(grib_accessor*, char*, size_t* len);
static int value_count(grib_accessor*, long*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_g1date
@ -66,7 +65,7 @@ static grib_accessor_class _grib_accessor_class_g1date = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
&value_count, /* get number of values */
@ -122,21 +121,13 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
self->day = grib_arguments_get_name(hand, c, n++);
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
int ret = 0;
grib_accessor_g1date* self = (grib_accessor_g1date*)a;
grib_handle* hand = grib_handle_of_accessor(a);
long year = 0;
long century = 0;
long month = 0;
long day = 0;
int ret = 0;
long year = 0, century = 0, month = 0, day = 0;
if ((ret = grib_get_long_internal(hand, self->century, &century)) != GRIB_SUCCESS)
return ret;
@ -165,26 +156,21 @@ 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)
{
int ret = 0;
long v = val[0];
grib_accessor_g1date* self = (grib_accessor_g1date*)a;
grib_handle* hand = grib_handle_of_accessor(a);
long year = 0;
long century = 0;
long month = 0;
long day = 0;
int ret = 0;
long v = val[0];
long year = 0, century = 0, month = 0, day = 0;
if (*len != 1)
return GRIB_WRONG_ARRAY_SIZE;
{
long d = grib_julian_to_date((long)grib_date_to_julian(v));
long d = grib_julian_to_date(grib_date_to_julian(v));
if (v != d) {
grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_g1date: pack_long invalid date %ld, changed to %ld", v, d);
return GRIB_ENCODING_ERROR;
}
}
century = v / 1000000;
v %= 1000000;
@ -228,15 +214,12 @@ static const char* months[] = {
static int unpack_string(grib_accessor* a, char* val, size_t* len)
{
int ret = 0;
char tmp[1024];
grib_accessor_g1date* self = (grib_accessor_g1date*)a;
grib_handle* hand = grib_handle_of_accessor(a);
long year = 0;
long century = 0;
long month = 0;
long day = 0;
size_t l;
int ret = 0;
char tmp[1024];
long year = 0, century = 0, month = 0, day = 0;
if ((ret = grib_get_long_internal(hand, self->century, &century)) != GRIB_SUCCESS)
return ret;
@ -261,7 +244,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
snprintf(tmp, sizeof(tmp), "%ld", x);
}
l = strlen(tmp) + 1;
size_t l = strlen(tmp) + 1;
if (*len < l) {
*len = l;
return GRIB_BUFFER_TOO_SMALL;

View File

@ -22,7 +22,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
MEMBERS=const char* date
END_CLASS_DEF
@ -39,7 +39,6 @@ or edit "accessor.class" and rerun ./make_class.pl
*/
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_g1monthlydate
@ -62,7 +61,7 @@ static grib_accessor_class _grib_accessor_class_g1monthlydate = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -115,11 +114,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_g1monthlydate* self = (grib_accessor_g1monthlydate*)a;

View File

@ -17,7 +17,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
MEMBERS=const char* date
MEMBERS=const char* time
MEMBERS=const char* step
@ -36,7 +36,6 @@ or edit "accessor.class" and rerun ./make_class.pl
*/
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_g1verificationdate
@ -61,7 +60,7 @@ static grib_accessor_class _grib_accessor_class_g1verificationdate = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -117,11 +116,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_g1verificationdate* self = (grib_accessor_g1verificationdate*)a;

View File

@ -16,7 +16,7 @@
START_CLASS_DEF
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long;init;dump
IMPLEMENTS = unpack_long;pack_long;init
MEMBERS=const char* century
MEMBERS=const char* year
MEMBERS=const char* month
@ -37,7 +37,6 @@ or edit "accessor.class" and rerun ./make_class.pl
static int pack_long(grib_accessor*, const long* val, size_t* len);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_g2date
@ -63,7 +62,7 @@ static grib_accessor_class _grib_accessor_class_g2date = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -116,16 +115,11 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
self->day = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++);
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
int ret = 0;
grib_accessor_g2date* self = (grib_accessor_g2date*)a;
const grib_accessor_g2date* self = (grib_accessor_g2date*)a;
int ret = 0;
long year = 0;
long month = 0;
long day = 0;
@ -145,13 +139,12 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
return GRIB_SUCCESS;
}
/* TODO: Check for a valid date */
static int pack_long(grib_accessor* a, const long* val, size_t* len)
{
int ret;
long v = val[0];
grib_accessor_g2date* self = (grib_accessor_g2date*)a;
const grib_accessor_g2date* self = (grib_accessor_g2date*)a;
int ret = GRIB_SUCCESS;
long v = val[0];
long year = 0;
long month = 0;
long day = 0;
@ -165,6 +158,12 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
v %= 100;
day = v;
if (!is_date_valid(year, month, day, 0, 0, 0)) {
// ECC-1777: For now just a warning. Will later change to an error
fprintf(stderr, "ECCODES WARNING : %s:%s: Date is not valid! year=%ld month=%ld day=%ld\n",
a->cclass->name, __func__, year, month, day);
}
if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->day, day)) != GRIB_SUCCESS)
return ret;
if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->month, month)) != GRIB_SUCCESS)

View File

@ -17,7 +17,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_double;pack_double
IMPLEMENTS = unpack_long;pack_long;init;dump;is_missing
IMPLEMENTS = unpack_long;pack_long;init;is_missing
MEMBERS=const char* type_first
MEMBERS=const char* scale_first
MEMBERS=const char* value_first
@ -41,7 +41,6 @@ static int pack_double(grib_accessor*, const double* val, size_t* len);
static int pack_long(grib_accessor*, const long* val, size_t* len);
static int unpack_double(grib_accessor*, double* val, size_t* len);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_g2level
@ -67,7 +66,7 @@ static grib_accessor_class _grib_accessor_class_g2level = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -126,11 +125,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
a->flags |= GRIB_ACCESSOR_FLAG_COPY_IF_CHANGING_EDITION;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static bool is_tigge(grib_handle* h)
{
long productionStatus = 0;

View File

@ -455,16 +455,14 @@ static int pack_long(grib_accessor* a, const long* v, size_t* len)
{
grib_context* c = a->context;
if (a->cclass->pack_double && a->cclass->pack_double != &pack_double) {
int i = 0, ret = 0;
double* val = (double*)grib_context_malloc(c, *len * (sizeof(double)));
if (!val) {
grib_context_log(c, GRIB_LOG_ERROR,
"Unable to allocate %zu bytes", *len * (sizeof(double)));
grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %zu bytes", *len * (sizeof(double)));
return GRIB_OUT_OF_MEMORY;
}
for (i = 0; i < *len; i++)
val[i] = (long)v[i];
ret = grib_pack_double(a, val, len);
for (size_t i = 0; i < *len; i++)
val[i] = v[i];
int ret = grib_pack_double(a, val, len);
grib_context_free(c, val);
return ret;
}
@ -479,14 +477,13 @@ static int pack_double_array_as_long(grib_accessor* a, const double* v, size_t*
{
grib_context* c = a->context;
int ret = GRIB_SUCCESS;
size_t i = 0;
size_t numBytes = *len * (sizeof(long));
long* lValues = (long*)grib_context_malloc(c, numBytes);
if (!lValues) {
grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %ld bytes", numBytes);
return GRIB_OUT_OF_MEMORY;
}
for (i = 0; i < *len; i++)
for (size_t i = 0; i < *len; i++)
lValues[i] = (long)v[i]; /* convert from double to long */
ret = grib_pack_long(a, lValues, len);
grib_context_free(c, lValues);

View File

@ -238,42 +238,32 @@ static int unpack_double(grib_accessor* a, double* v, size_t* len)
static int compare(grib_accessor* a, grib_accessor* b)
{
int retval = 0;
char* aval = 0;
char* bval = 0;
int err = 0;
grib_context_log(a->context, GRIB_LOG_ERROR, "%s:%s not implemented", __func__, a->name);
return GRIB_NOT_IMPLEMENTED;
size_t alen = 0;
size_t blen = 0;
long count = 0;
err = grib_value_count(a, &count);
if (err)
return err;
alen = count;
err = grib_value_count(b, &count);
if (err)
return err;
blen = count;
if (alen != blen)
return GRIB_COUNT_MISMATCH;
aval = (char*)grib_context_malloc(a->context, alen * sizeof(char));
bval = (char*)grib_context_malloc(b->context, blen * sizeof(char));
grib_unpack_string(a, aval, &alen);
grib_unpack_string(b, bval, &blen);
retval = GRIB_SUCCESS;
if (strcmp(aval, bval))
retval = GRIB_STRING_VALUE_MISMATCH;
grib_context_free(a->context, aval);
grib_context_free(b->context, bval);
return retval;
// int retval = 0;
// char* aval = 0;
// char* bval = 0;
// int err = 0;
// size_t alen = 0;
// size_t blen = 0;
// long count = 0;
// err = grib_value_count(a, &count);
// if (err) return err;
// alen = count;
// err = grib_value_count(b, &count);
// if (err) return err;
// blen = count;
// if (alen != blen) return GRIB_COUNT_MISMATCH;
// aval = (char*)grib_context_malloc(a->context, alen * sizeof(char));
// bval = (char*)grib_context_malloc(b->context, blen * sizeof(char));
// grib_unpack_string(a, aval, &alen);
// grib_unpack_string(b, bval, &blen);
// retval = GRIB_SUCCESS;
// if (strcmp(aval, bval)) retval = GRIB_STRING_VALUE_MISMATCH;
// grib_context_free(a->context, aval);
// grib_context_free(b->context, bval);
// return retval;
}
static long next_offset(grib_accessor* a)

View File

@ -183,7 +183,7 @@ static int unpack_string(grib_accessor* a, char* v, size_t* len)
if (*len < 32) {
const char* cclass_name = a->cclass->name;
grib_context_log(a->context, GRIB_LOG_ERROR,
"%s: Buffer too small for %s. It is %zu bytes long (len=%zu)",
"%s: Buffer too small for %s. It is %d bytes long (len=%zu)",
cclass_name, a->name, 32, *len);
*len = 32;
return GRIB_BUFFER_TOO_SMALL;

View File

@ -142,7 +142,7 @@ static int value_count(grib_accessor* a, long* count)
static int unpack_string(grib_accessor* a, char* val, size_t* len)
{
long i = 0;
size_t l = a->length + 1;
size_t l = string_length(a) + 1;
grib_handle* h = grib_handle_of_accessor(a);
if (*len < l) {

View File

@ -0,0 +1,127 @@
/*
* (C) Copyright 2005- ECMWF.
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
*
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
#include "grib_api_internal.h"
/*
This is used by make_class.pl
START_CLASS_DEF
CLASS = accessor
SUPER = grib_accessor_class_double
IMPLEMENTS = unpack_double
IMPLEMENTS = init
MEMBERS = const char* val
MEMBERS = double multiplier
END_CLASS_DEF
*/
/* START_CLASS_IMP */
/*
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
or edit "accessor.class" and rerun ./make_class.pl
*/
static int unpack_double(grib_accessor*, double* val, size_t* len);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_multdouble
{
grib_accessor att;
/* Members defined in gen */
/* Members defined in double */
/* Members defined in multdouble */
const char* val;
double multiplier;
} grib_accessor_multdouble;
extern grib_accessor_class* grib_accessor_class_double;
static grib_accessor_class _grib_accessor_class_multdouble = {
&grib_accessor_class_double, /* super */
"multdouble", /* name */
sizeof(grib_accessor_multdouble), /* size */
0, /* inited */
0, /* init_class */
&init, /* init */
0, /* post_init */
0, /* destroy */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
0, /* get number of bytes */
0, /* get offset to bytes */
0, /* get native type */
0, /* get sub_section */
0, /* pack_missing */
0, /* is_missing */
0, /* pack_long */
0, /* unpack_long */
0, /* pack_double */
0, /* pack_float */
&unpack_double, /* unpack_double */
0, /* unpack_float */
0, /* pack_string */
0, /* unpack_string */
0, /* pack_string_array */
0, /* unpack_string_array */
0, /* pack_bytes */
0, /* unpack_bytes */
0, /* pack_expression */
0, /* notify_change */
0, /* update_size */
0, /* preferred_size */
0, /* resize */
0, /* nearest_smaller_value */
0, /* next accessor */
0, /* compare vs. another accessor */
0, /* unpack only ith value (double) */
0, /* unpack only ith value (float) */
0, /* unpack a given set of elements (double) */
0, /* unpack a given set of elements (float) */
0, /* unpack a subarray */
0, /* clear */
0, /* clone accessor */
};
grib_accessor_class* grib_accessor_class_multdouble = &_grib_accessor_class_multdouble;
/* END_CLASS_IMP */
static void init(grib_accessor* a, const long l, grib_arguments* c)
{
grib_accessor_multdouble* self = (grib_accessor_multdouble*)a;
int n = 0;
self->val = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++);
self->multiplier = grib_arguments_get_double(grib_handle_of_accessor(a), c, n++);
}
static int unpack_double(grib_accessor* a, double* val, size_t* len)
{
const grib_accessor_multdouble* self = (grib_accessor_multdouble*)a;
int ret = GRIB_SUCCESS;
double value = 0;
ret = grib_get_double_internal(grib_handle_of_accessor(a), self->val, &value);
if (ret != GRIB_SUCCESS)
return ret;
*val = value * self->multiplier;
*len = 1;
return GRIB_SUCCESS;
}

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