mirror of https://github.com/ecmwf/eccodes.git
Merge remote-tracking branch 'origin/develop' into feature/ECC-1766-EERIE
This commit is contained in:
commit
eff55b72bc
|
@ -3,7 +3,7 @@ build:
|
|||
- ecbuild
|
||||
- ninja
|
||||
- aec
|
||||
- netcdf4/new
|
||||
- netcdf4
|
||||
parallel: 64
|
||||
cmake_options:
|
||||
- -DENABLE_EXTRA_TESTS=1
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ jobs:
|
|||
ecbuild
|
||||
ninja
|
||||
aec
|
||||
netcdf4/new
|
||||
netcdf4
|
||||
--parallel: 64
|
||||
--cmake-options: |
|
||||
-DENABLE_EXTRA_TESTS=1
|
||||
|
|
3
AUTHORS
3
AUTHORS
|
@ -1,6 +1,7 @@
|
|||
Enrico Fucile
|
||||
Shahram Najm
|
||||
Eugen Betke
|
||||
Enrico Fucile
|
||||
Pedro Maciel
|
||||
Sandor Kertesz
|
||||
Sebastien Villaume
|
||||
Florian Rathgeber
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
SET(ENABLE_EXTRA_TESTS ON CACHE BOOL "Enable extra tests")
|
||||
SET(ENABLE_ECCODES_THREADS ON CACHE BOOL "Enable POSIX threads")
|
||||
SET(ENABLE_MEMFS ON CACHE BOOL "Enable MEMFS")
|
||||
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")
|
||||
|
|
|
@ -62,4 +62,6 @@ Test2...
|
|||
- -47120001 -> 6
|
||||
|
||||
Test3...
|
||||
Test4...
|
||||
Test5...
|
||||
All OK
|
||||
|
|
|
@ -18,12 +18,12 @@ constant defaultTypeOfLevel="unknown" : hidden;
|
|||
|
||||
gribDataQualityChecks = getenv("ECCODES_GRIB_DATA_QUALITY_CHECKS","0") : hidden;
|
||||
if (gribDataQualityChecks) {
|
||||
template LIMITS "param_limits.def";
|
||||
template LIMITS "param_limits.def";
|
||||
}
|
||||
|
||||
# GRIBEX special boustrophedonic mode. See GRIB-472
|
||||
# If the environment variable is not defined, the key will be 0
|
||||
GRIBEX_boustrophedonic = getenv("ECCODES_GRIBEX_BOUSTROPHEDONIC","0") :hidden;
|
||||
GRIBEX_boustrophedonic = getenv("ECCODES_GRIBEX_BOUSTROPHEDONIC","0") :hidden;
|
||||
|
||||
constant zero=0 : hidden;
|
||||
constant one=1 : hidden;
|
||||
|
@ -61,65 +61,65 @@ transient produceLargeConstantFields = 0 : hidden;
|
|||
|
||||
meta libraryVersion library_version() : hidden;
|
||||
|
||||
lookup[4] kindOfProduct (0,identifier) : hidden;
|
||||
lookup[4] kindOfProduct (0,identifier) : hidden;
|
||||
# grib templates
|
||||
# `ABCD` is a number, each letter being a byte
|
||||
|
||||
if(kindOfProduct == `GRIB`){
|
||||
lookup[1] GRIBEditionNumber (7,editionNumber) : edition_specific ;
|
||||
template GRIB "grib[GRIBEditionNumber:l]/boot.def" ;
|
||||
lookup[1] GRIBEditionNumber (7,editionNumber) : edition_specific;
|
||||
template GRIB "grib[GRIBEditionNumber:l]/boot.def" ;
|
||||
}
|
||||
|
||||
if(kindOfProduct == `BUDG` ){
|
||||
template BUDG "budg/boot.def" ;
|
||||
template BUDG "budg/boot.def" ;
|
||||
}
|
||||
|
||||
if(kindOfProduct == `DIAG`){
|
||||
template DIAG "diag/boot.def" ;
|
||||
template DIAG "diag/boot.def" ;
|
||||
}
|
||||
|
||||
if(kindOfProduct == `TIDE`){
|
||||
template TIDE "tide/boot.def" ;
|
||||
template TIDE "tide/boot.def" ;
|
||||
}
|
||||
|
||||
if(kindOfProduct == `BUFR`){
|
||||
template BUFR "bufr/boot.def" ;
|
||||
#constant BUFRstr="BUFR"; #ECC-742
|
||||
template BUFR "bufr/boot.def" ;
|
||||
#constant BUFRstr="BUFR"; #ECC-742
|
||||
#alias identifier=BUFRstr;
|
||||
}
|
||||
|
||||
if(kindOfProduct == `CDFX`){
|
||||
template CDF "cdf/boot.def" ;
|
||||
constant CDFstr="netCDF";
|
||||
template CDF "cdf/boot.def" ;
|
||||
constant CDFstr="netCDF";
|
||||
alias ls.identifier=CDFstr;
|
||||
}
|
||||
|
||||
if(kindOfProduct == 17632522 ){
|
||||
template GTS "gts/boot.def" ;
|
||||
template GTS "gts/boot.def" ;
|
||||
constant GTSstr="GTS";
|
||||
alias ls.identifier=GTSstr;
|
||||
}
|
||||
|
||||
if(kindOfProduct == `META` ){
|
||||
template METAR "metar/boot.def" ;
|
||||
template METAR "metar/boot.def" ;
|
||||
constant METARstr="METAR";
|
||||
alias identifier=METARstr;
|
||||
}
|
||||
|
||||
if(kindOfProduct == `TAF ` ){
|
||||
template TAF "taf/boot.def" ;
|
||||
template TAF "taf/boot.def" ;
|
||||
constant TAFstr="TAF";
|
||||
alias ls.identifier=TAFstr;
|
||||
}
|
||||
|
||||
if(kindOfProduct == 2303214662){
|
||||
template HDF5 "hdf5/boot.def" ;
|
||||
constant HDF5str="HDF5";
|
||||
template HDF5 "hdf5/boot.def" ;
|
||||
constant HDF5str="HDF5";
|
||||
alias ls.identifier=HDF5str;
|
||||
}
|
||||
|
||||
if(kindOfProduct == `WRAP`){
|
||||
template WRAP "wrap/boot.def" ;
|
||||
constant WRAPstr="WRAP";
|
||||
template WRAP "wrap/boot.def" ;
|
||||
constant WRAPstr="WRAP";
|
||||
alias ls.identifier=WRAPstr;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -89,7 +89,7 @@ if (horizontalCoordinateDefinition == 0) {
|
|||
{
|
||||
meta coordinateIndexNumber evaluate(coordinate4Flag+coordinate3Flag);
|
||||
|
||||
# levelist latitude longitude
|
||||
# levelist latitude longitude
|
||||
if (coordinateIndexNumber== 3) {
|
||||
meta marsLatitude divdouble( coordinate1Start,1000000);
|
||||
meta marsLongitude divdouble( coordinate2Start,1000000);
|
||||
|
@ -145,15 +145,15 @@ if (horizontalCoordinateDefinition == 0) {
|
|||
alias mars.range = marsRange;
|
||||
}
|
||||
}
|
||||
# product
|
||||
alias mars.product = coordAveragingTims;
|
||||
# date
|
||||
if (marsType == TYPE_OR && averaging1Flag == P_INST) {
|
||||
#remove mars.date;
|
||||
alias mars.date = verificationDate;
|
||||
#remove mars.step;
|
||||
constant stepZero = 0;
|
||||
alias mars.step =stepZero;
|
||||
}
|
||||
# product
|
||||
alias mars.product = coordAveragingTims;
|
||||
# date
|
||||
if (marsType == TYPE_OR && averaging1Flag == P_INST) {
|
||||
#remove mars.date;
|
||||
alias mars.date = verificationDate;
|
||||
#remove mars.step;
|
||||
constant stepZero = 0;
|
||||
alias mars.step =stepZero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,9 @@ constant tablesVersionLatest = 32 : edition_specific;
|
|||
constant false = 0 : hidden;
|
||||
constant true = 1 : hidden;
|
||||
constant million = 1000000 : hidden;
|
||||
constant grib2divider = 1000000;
|
||||
alias extraDimensionPresent=zero;
|
||||
transient angleSubdivisions=grib2divider; # micro degrees
|
||||
constant grib2divider = 1000000;
|
||||
alias extraDimensionPresent = zero;
|
||||
transient angleSubdivisions = grib2divider; # micro degrees
|
||||
transient forceStepUnits = 255 : hidden;
|
||||
|
||||
meta gts_header gts_header() : no_copy,hidden,read_only;
|
||||
|
@ -26,8 +26,8 @@ meta gts_TTAAii gts_header(20,6) : no_copy,hidden,read_only;
|
|||
meta gts_CCCC gts_header(27,4) : no_copy,hidden,read_only;
|
||||
meta gts_ddhh00 gts_header(32,6) : no_copy,hidden,read_only;
|
||||
|
||||
transient missingValue = 9999;
|
||||
constant ieeeFloats = 1 : edition_specific;
|
||||
transient missingValue = 9999;
|
||||
constant ieeeFloats = 1 : edition_specific;
|
||||
constant isHindcast = 0;
|
||||
|
||||
include "grib2/section.0.def"
|
||||
|
@ -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; }
|
||||
}
|
||||
|
|
|
@ -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 ;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -182,4 +182,11 @@
|
|||
scaledValueOfSecondFixedSurface = missing() ;
|
||||
scaleFactorOfSecondFixedSurface = missing() ;
|
||||
typeOfStatisticalProcessing = 0 ;
|
||||
}
|
||||
#Snow depth water equivalent
|
||||
'sd' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 60 ;
|
||||
typeOfStatisticalProcessing = 0 ;
|
||||
}
|
||||
|
|
|
@ -182,4 +182,11 @@
|
|||
scaledValueOfSecondFixedSurface = missing() ;
|
||||
scaleFactorOfSecondFixedSurface = missing() ;
|
||||
typeOfStatisticalProcessing = 0 ;
|
||||
}
|
||||
#Snow depth water equivalent
|
||||
'Snow depth water equivalent' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 60 ;
|
||||
typeOfStatisticalProcessing = 0 ;
|
||||
}
|
||||
|
|
|
@ -182,4 +182,11 @@
|
|||
scaledValueOfSecondFixedSurface = missing() ;
|
||||
scaleFactorOfSecondFixedSurface = missing() ;
|
||||
typeOfStatisticalProcessing = 0 ;
|
||||
}
|
||||
#Snow depth water equivalent
|
||||
'228141' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 60 ;
|
||||
typeOfStatisticalProcessing = 0 ;
|
||||
}
|
||||
|
|
|
@ -182,4 +182,11 @@
|
|||
scaledValueOfSecondFixedSurface = missing() ;
|
||||
scaleFactorOfSecondFixedSurface = missing() ;
|
||||
typeOfStatisticalProcessing = 0 ;
|
||||
}
|
||||
#Snow depth water equivalent
|
||||
'sd' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 60 ;
|
||||
typeOfStatisticalProcessing = 0 ;
|
||||
}
|
||||
|
|
|
@ -182,4 +182,11 @@
|
|||
scaledValueOfSecondFixedSurface = missing() ;
|
||||
scaleFactorOfSecondFixedSurface = missing() ;
|
||||
typeOfStatisticalProcessing = 0 ;
|
||||
}
|
||||
#Snow depth water equivalent
|
||||
'kg m**-2' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 60 ;
|
||||
typeOfStatisticalProcessing = 0 ;
|
||||
}
|
||||
|
|
|
@ -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 ;
|
||||
|
|
|
@ -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 ;
|
||||
|
|
|
@ -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 ;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# (C) Copyright 2005- ECMWF.
|
||||
|
||||
# TEMPLATE 7.1, Matrix values at grid point -simple packing
|
||||
# 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,
|
||||
|
|
|
@ -6,13 +6,13 @@ 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;
|
||||
|
||||
position offsetBeforeData;
|
||||
|
||||
if(bitmapPresent) {
|
||||
if(bitmapPresent) {
|
||||
meta codedValues data_g1second_order_general_extended_packing(
|
||||
#simple_packing args
|
||||
section7Length,
|
||||
|
@ -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;
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
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;
|
||||
|
||||
if(bitmapPresent) {
|
||||
if(bitmapPresent) {
|
||||
meta codedValues data_g1second_order_general_extended_packing(
|
||||
#simple_packing args
|
||||
section7Length,
|
||||
|
@ -47,7 +47,6 @@ if(bitmapPresent) {
|
|||
widthOfSPD,
|
||||
orderOfSPD,
|
||||
numberOfPoints
|
||||
|
||||
): read_only;
|
||||
alias data.packedValues = codedValues;
|
||||
|
||||
|
@ -96,8 +95,7 @@ if(bitmapPresent) {
|
|||
widthOfSPD,
|
||||
orderOfSPD,
|
||||
numberOfPoints
|
||||
|
||||
) : dump;
|
||||
) : 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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 ;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
alias mars.step = endStep;
|
||||
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; }
|
||||
|
||||
|
|
|
@ -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") {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,19 +1942,18 @@ 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){
|
||||
if (!h){
|
||||
return GRIB_INVALID_GRIB;
|
||||
}else{
|
||||
err = grib_index_get_size(h, cast_char(buf,key,len), &tsize);
|
||||
} else{
|
||||
int err = grib_index_get_size(h, cast_char(buf,key,len), &tsize);
|
||||
*val = tsize;
|
||||
return err;
|
||||
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,23 +2101,23 @@ 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;
|
||||
|
||||
if(!h) return GRIB_INVALID_GRIB;
|
||||
if (!h) return GRIB_INVALID_GRIB;
|
||||
err = grib_index_get_long(h, cast_char(buf,key,len), val, &lsize);
|
||||
*size = lsize;
|
||||
return err;
|
||||
return err;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
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,17 +2137,17 @@ 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;
|
||||
|
||||
if(!h) return GRIB_INVALID_GRIB;
|
||||
if (!h) return GRIB_INVALID_GRIB;
|
||||
err = grib_index_get_double(h, cast_char(buf,key,len), val, &lsize);
|
||||
*size = lsize;
|
||||
return err;
|
||||
return err;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -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.
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -114,8 +114,8 @@ 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;
|
||||
int i = 0;
|
||||
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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
int i = 0;
|
||||
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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,8 +122,8 @@ 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;
|
||||
int i = 0;
|
||||
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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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));
|
|
@ -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; */
|
|
@ -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,10 +1095,10 @@ 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_dependency.cc */
|
||||
grib_handle* grib_handle_of_accessor(const grib_accessor* a);
|
||||
void grib_dependency_add(grib_accessor* observer, grib_accessor* observed);
|
||||
void grib_dependency_remove_observed(grib_accessor* observed);
|
||||
|
@ -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);
|
||||
|
|
|
@ -1,20 +1,14 @@
|
|||
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*);
|
||||
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*);
|
||||
|
||||
typedef struct grib_expression_NAME{
|
||||
grib_expression base;
|
||||
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -191,61 +191,61 @@ static grib_accessor* make_clone(grib_accessor* a, grib_section* s, int* err)
|
|||
void accessor_bufr_data_element_set_index(grib_accessor* a, long index)
|
||||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
self->index = index;
|
||||
self->index = index;
|
||||
}
|
||||
|
||||
void accessor_bufr_data_element_set_type(grib_accessor* a, int type)
|
||||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
self->type = type;
|
||||
self->type = type;
|
||||
}
|
||||
|
||||
void accessor_bufr_data_element_set_numberOfSubsets(grib_accessor* a, long numberOfSubsets)
|
||||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
self->numberOfSubsets = numberOfSubsets;
|
||||
self->numberOfSubsets = numberOfSubsets;
|
||||
}
|
||||
|
||||
void accessor_bufr_data_element_set_subsetNumber(grib_accessor* a, long subsetNumber)
|
||||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
self->subsetNumber = subsetNumber;
|
||||
self->subsetNumber = subsetNumber;
|
||||
}
|
||||
|
||||
void accessor_bufr_data_element_set_compressedData(grib_accessor* a, int compressedData)
|
||||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
self->compressedData = compressedData;
|
||||
self->compressedData = compressedData;
|
||||
}
|
||||
|
||||
void accessor_bufr_data_element_set_descriptors(grib_accessor* a, bufr_descriptors_array* descriptors)
|
||||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
self->descriptors = descriptors;
|
||||
self->descriptors = descriptors;
|
||||
}
|
||||
|
||||
void accessor_bufr_data_element_set_numericValues(grib_accessor* a, grib_vdarray* numericValues)
|
||||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
self->numericValues = numericValues;
|
||||
self->numericValues = numericValues;
|
||||
}
|
||||
|
||||
void accessor_bufr_data_element_set_stringValues(grib_accessor* a, grib_vsarray* stringValues)
|
||||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
self->stringValues = stringValues;
|
||||
self->stringValues = stringValues;
|
||||
}
|
||||
|
||||
void accessor_bufr_data_element_set_elementsDescriptorsIndex(grib_accessor* a, grib_viarray* elementsDescriptorsIndex)
|
||||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
self->elementsDescriptorsIndex = elementsDescriptorsIndex;
|
||||
self->elementsDescriptorsIndex = elementsDescriptorsIndex;
|
||||
}
|
||||
|
||||
static void init(grib_accessor* a, const long len, grib_arguments* params)
|
||||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
a->length = 0;
|
||||
a->length = 0;
|
||||
a->flags |= GRIB_ACCESSOR_FLAG_BUFR_DATA;
|
||||
/* a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; */
|
||||
self->cname = NULL;
|
||||
|
@ -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) {
|
||||
|
@ -289,7 +289,7 @@ static int unpack_string_array(grib_accessor* a, char** val, size_t* len)
|
|||
else {
|
||||
DEBUG_ASSERT(self->subsetNumber < self->numericValues->n);
|
||||
DEBUG_ASSERT(self->index < self->numericValues->v[self->subsetNumber]->n);
|
||||
idx = (int)self->numericValues->v[self->subsetNumber]->v[self->index] / 1000 - 1;
|
||||
idx = (int)self->numericValues->v[self->subsetNumber]->v[self->index] / 1000 - 1;
|
||||
val[0] = grib_context_strdup(c, self->stringValues->v[idx]->v[0]);
|
||||
*len = 1;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -343,8 +343,8 @@ static int pack_string_array(grib_accessor* a, const char** v, size_t* len)
|
|||
static int unpack_string(grib_accessor* a, char* val, size_t* len)
|
||||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
char* str = NULL;
|
||||
char* p = 0;
|
||||
char* str = NULL;
|
||||
char* p = 0;
|
||||
size_t slen = 0;
|
||||
double dval = 0;
|
||||
size_t dlen = 1;
|
||||
|
@ -413,8 +413,8 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len)
|
|||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
|
||||
int ret = GRIB_SUCCESS, idx = 0;
|
||||
char* s = NULL;
|
||||
int ret = GRIB_SUCCESS, idx = 0;
|
||||
char* s = NULL;
|
||||
grib_context* c = a->context;
|
||||
|
||||
if (self->compressedData) {
|
||||
|
@ -426,7 +426,7 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len)
|
|||
grib_sarray_delete_content(c, self->stringValues->v[idx]); /* ECC-1172 */
|
||||
grib_sarray_delete(c, self->stringValues->v[idx]);
|
||||
self->stringValues->v[idx] = grib_sarray_new(c, 1, 1);
|
||||
s = grib_context_strdup(c, val);
|
||||
s = grib_context_strdup(c, val);
|
||||
grib_sarray_push(c, self->stringValues->v[idx], s);
|
||||
|
||||
return ret;
|
||||
|
@ -435,7 +435,7 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len)
|
|||
static int unpack_long(grib_accessor* a, long* val, size_t* len)
|
||||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
int ret = GRIB_SUCCESS;
|
||||
int ret = GRIB_SUCCESS;
|
||||
long count = 0, i = 0;
|
||||
|
||||
value_count(a, &count);
|
||||
|
@ -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;
|
||||
|
@ -514,7 +514,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
|||
}
|
||||
else {
|
||||
self->numericValues->v[self->subsetNumber]->v[self->index] = val[0];
|
||||
*len = 1;
|
||||
*len = 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -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;
|
||||
grib_context* c = a->context;
|
||||
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;
|
||||
}
|
||||
|
@ -544,7 +544,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
|||
}
|
||||
else {
|
||||
self->numericValues->v[self->subsetNumber]->v[self->index] = val[0] == GRIB_MISSING_LONG ? GRIB_MISSING_DOUBLE : val[0];
|
||||
*len = 1;
|
||||
*len = 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -552,7 +552,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
|||
|
||||
static int value_count(grib_accessor* a, long* count)
|
||||
{
|
||||
int ret = 0, type = 0, idx = 0;
|
||||
int ret = 0, type = 0, idx = 0;
|
||||
size_t size = 0;
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
|
||||
|
@ -581,8 +581,8 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val)
|
|||
{
|
||||
/* ECC-415 */
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
int ret = GRIB_SUCCESS;
|
||||
long count = 0;
|
||||
int ret = GRIB_SUCCESS;
|
||||
long count = 0;
|
||||
|
||||
value_count(a, &count);
|
||||
if (idx >= (size_t)count) {
|
||||
|
@ -601,7 +601,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val)
|
|||
static int get_native_type(grib_accessor* a)
|
||||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
int ret = GRIB_TYPE_DOUBLE;
|
||||
int ret = GRIB_TYPE_DOUBLE;
|
||||
DEBUG_ASSERT(self);
|
||||
switch (self->type) {
|
||||
case BUFR_DESCRIPTOR_TYPE_STRING:
|
||||
|
@ -627,7 +627,7 @@ static int get_native_type(grib_accessor* a)
|
|||
static void destroy(grib_context* ct, grib_accessor* a)
|
||||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
int i = 0;
|
||||
int i = 0;
|
||||
if (self->cname)
|
||||
grib_context_free(ct, self->cname); /* ECC-765 */
|
||||
while (i < MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) {
|
||||
|
@ -650,14 +650,14 @@ static int is_missing(grib_accessor* a)
|
|||
grib_context* c = a->context;
|
||||
|
||||
if (ktype == GRIB_TYPE_LONG) {
|
||||
long* values = NULL;
|
||||
long value = 0;
|
||||
long* values = NULL;
|
||||
long value = 0;
|
||||
|
||||
value_count(a, &count);
|
||||
size = size2 = count;
|
||||
if (size > 1) {
|
||||
values = (long*)grib_context_malloc_clear(c, sizeof(long) * size);
|
||||
err = grib_unpack_long(a, values, &size2);
|
||||
err = grib_unpack_long(a, values, &size2);
|
||||
}
|
||||
else {
|
||||
err = grib_unpack_long(a, &value, &size2);
|
||||
|
@ -677,14 +677,14 @@ static int is_missing(grib_accessor* a)
|
|||
}
|
||||
}
|
||||
else if (ktype == GRIB_TYPE_DOUBLE) {
|
||||
double value = 0;
|
||||
double* values = NULL;
|
||||
double value = 0;
|
||||
double* values = NULL;
|
||||
|
||||
value_count(a, &count);
|
||||
size = size2 = count;
|
||||
if (size > 1) {
|
||||
values = (double*)grib_context_malloc_clear(c, sizeof(double) * size);
|
||||
err = grib_unpack_double(a, values, &size2);
|
||||
err = grib_unpack_double(a, values, &size2);
|
||||
}
|
||||
else {
|
||||
err = grib_unpack_double(a, &value, &size2);
|
||||
|
@ -705,7 +705,7 @@ static int is_missing(grib_accessor* a)
|
|||
}
|
||||
}
|
||||
else if (ktype == GRIB_TYPE_STRING) {
|
||||
char** values = NULL;
|
||||
char** values = NULL;
|
||||
value_count(a, &count);
|
||||
size = count;
|
||||
if (size > 1) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -119,7 +119,7 @@ grib_accessor_class* grib_accessor_class_data_apply_boustrophedonic = &_grib_acc
|
|||
|
||||
static void init(grib_accessor* a, const long v, grib_arguments* args)
|
||||
{
|
||||
int n = 0;
|
||||
int n = 0;
|
||||
grib_accessor_data_apply_boustrophedonic* self = (grib_accessor_data_apply_boustrophedonic*)a;
|
||||
|
||||
self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++);
|
||||
|
@ -138,10 +138,10 @@ static void dump(grib_accessor* a, grib_dumper* dumper)
|
|||
static int value_count(grib_accessor* a, long* numberOfPoints)
|
||||
{
|
||||
grib_accessor_data_apply_boustrophedonic* self = (grib_accessor_data_apply_boustrophedonic*)a;
|
||||
int ret = 0;
|
||||
int ret = 0;
|
||||
|
||||
*numberOfPoints = 0;
|
||||
ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, numberOfPoints);
|
||||
ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, numberOfPoints);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -150,12 +150,13 @@ 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;
|
||||
double* pvalues = 0;
|
||||
T* pval = 0;
|
||||
size_t valuesSize = 0;
|
||||
|
||||
size_t plSize = 0;
|
||||
long* pl = 0;
|
||||
double* values = 0;
|
||||
double* pvalues = 0;
|
||||
T* pval = 0;
|
||||
size_t valuesSize = 0;
|
||||
long i, j;
|
||||
int ret;
|
||||
long numberOfPoints, numberOfRows, numberOfColumns;
|
||||
|
@ -306,12 +307,13 @@ 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;
|
||||
double* pvalues = 0;
|
||||
double* pval = 0;
|
||||
size_t valuesSize = 0;
|
||||
|
||||
size_t plSize = 0;
|
||||
long* pl = 0;
|
||||
double* values = 0;
|
||||
double* pvalues = 0;
|
||||
double* pval = 0;
|
||||
size_t valuesSize = 0;
|
||||
long i, j;
|
||||
int ret;
|
||||
long numberOfPoints, numberOfRows, numberOfColumns;
|
||||
|
|
|
@ -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) */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -108,7 +103,7 @@ grib_accessor_class* grib_accessor_class_divdouble = &_grib_accessor_class_divdo
|
|||
static void init(grib_accessor* a, const long l, grib_arguments* c)
|
||||
{
|
||||
grib_accessor_divdouble* self = (grib_accessor_divdouble*)a;
|
||||
int n = 0;
|
||||
int n = 0;
|
||||
|
||||
self->val = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++);
|
||||
self->divisor = grib_arguments_get_double(grib_handle_of_accessor(a), c, n++);
|
||||
|
@ -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;
|
||||
int ret = GRIB_SUCCESS;
|
||||
double value = 0;
|
||||
|
||||
if (*len < 1) {
|
||||
*len = 1;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
const grib_accessor_divdouble* self = (grib_accessor_divdouble*)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;
|
||||
|
||||
/* 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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
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, ¢ury)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
|
@ -165,25 +156,20 @@ 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);
|
||||
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));
|
||||
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;
|
||||
}
|
||||
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;
|
||||
|
@ -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, ¢ury)) != 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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue