Merge branch 'develop' into feature/GRIB_lightweight_clone

This commit is contained in:
Shahram Najm 2023-12-19 15:04:36 +00:00
commit 7be67dc31b
51 changed files with 475 additions and 212 deletions

View File

@ -39,7 +39,7 @@
38 38 sgvv SIGMA COORD VERT VEL [sec/sec] 38 38 sgvv SIGMA COORD VERT VEL [sec/sec]
39 39 omeg OMEGA [Pa/s] 39 39 omeg OMEGA [Pa/s]
40 40 omg2 VERTICAL VELOCITY [m/s] 40 40 omg2 VERTICAL VELOCITY [m/s]
41 41 abvo ABSOLUTE VORTICITY [10**5/sec] 41 41 abvo ABSOLUTE VORTICITY [10**5/sec]
42 42 abdv ABSOLUTE DIVERGENCE [10**5/sec] 42 42 abdv ABSOLUTE DIVERGENCE [10**5/sec]
43 43 vort VORTICITY [1/s] 43 43 vort VORTICITY [1/s]
44 44 divg DIVERGENCE [1/s] 44 44 divg DIVERGENCE [1/s]
@ -54,17 +54,17 @@
53 53 hmxr HUMIDITY MIXING RATIO [kg/kg] 53 53 hmxr HUMIDITY MIXING RATIO [kg/kg]
54 54 agpl INST. PRECIPITABLE WATER [Kg/m2] 54 54 agpl INST. PRECIPITABLE WATER [Kg/m2]
55 55 vapp VAPOUR PRESSURE [Pa hpa] 55 55 vapp VAPOUR PRESSURE [Pa hpa]
56 56 sadf SATURATION DEFICIT [Pa hPa] 56 56 sadf SATURATION DEFICIT [Pa hPa]
57 57 evap EVAPORATION [Kg/m2/day] 57 57 evap EVAPORATION [Kg/m2/day]
58 58 var58 undefined 58 58 var58 undefined
59 59 prcr PRECIPITATION RATE [kg/m2/day] 59 59 prcr PRECIPITATION RATE [kg/m2/day]
60 60 thpb THUNDER PROBABILITY [%] 60 60 thpb THUNDER PROBABILITY [%]
61 61 prec TOTAL PRECIPITATION [Kg/m2/day] 61 61 prec TOTAL PRECIPITATION [Kg/m2/day]
62 62 prge LARGE SCALE PRECIPITATION [Kg/m2/day] 62 62 prge LARGE SCALE PRECIPITATION [Kg/m2/day]
63 63 prcv CONVECTIVE PRECIPITATION [Kg/m2/day] 63 63 prcv CONVECTIVE PRECIPITATION [Kg/m2/day]
64 64 neve SNOWFALL [Kg/m2/day] 64 64 neve SNOWFALL [Kg/m2/day]
65 65 wenv WAT EQUIV ACC SNOW DEPTH [kg/m2] 65 65 wenv WAT EQUIV ACC SNOW DEPTH [kg/m2]
66 66 nvde SNOW DEPTH [cm] 66 66 nvde SNOW DEPTH [cm]
67 67 mxld MIXED LAYER DEPTH [m cm] 67 67 mxld MIXED LAYER DEPTH [m cm]
68 68 tthd TRANS THERMOCLINE DEPTH [m cm] 68 68 tthd TRANS THERMOCLINE DEPTH [m cm]
69 69 mthd MAIN THERMOCLINE DEPTH [m cm] 69 69 mthd MAIN THERMOCLINE DEPTH [m cm]
@ -72,7 +72,7 @@
71 71 cbnv CLOUD COVER [0-1] 71 71 cbnv CLOUD COVER [0-1]
72 72 cvnv CONVECTIVE CLOUD COVER [0-1] 72 72 cvnv CONVECTIVE CLOUD COVER [0-1]
73 73 lwnv LOW CLOUD COVER [0-1] 73 73 lwnv LOW CLOUD COVER [0-1]
74 74 mdnv MEDIUM CLOUD COVER [0-1] 74 74 mdnv MEDIUM CLOUD COVER [0-1]
75 75 hinv HIGH CLOUD COVER [0-1] 75 75 hinv HIGH CLOUD COVER [0-1]
76 76 wtnv CLOUD WATER [kg/m2] 76 76 wtnv CLOUD WATER [kg/m2]
77 77 bli BEST LIFTED INDEX (TO 500 HPA) [K] 77 77 bli BEST LIFTED INDEX (TO 500 HPA) [K]
@ -85,17 +85,17 @@
84 84 albe ALBEDO [%] 84 84 albe ALBEDO [%]
85 85 dstp DEEP SOIL TEMPERATURE [K] 85 85 dstp DEEP SOIL TEMPERATURE [K]
86 86 soic SOIL MOISTURE CONTENT [Kg/m2] 86 86 soic SOIL MOISTURE CONTENT [Kg/m2]
87 87 vege VEGETATION [%] 87 87 vege VEGETATION [%]
88 88 var88 undefined 88 88 var88 undefined
89 89 dens DENSITY [kg/m3] 89 89 dens DENSITY [kg/m3]
90 90 var90 Undefined 90 90 var90 Undefined
91 91 icec ICE CONCENTRATION [fraction] 91 91 icec ICE CONCENTRATION [fraction]
92 92 icet ICE THICKNESS [m] 92 92 icet ICE THICKNESS [m]
93 93 iced DIRECTION OF ICE DRIFT [deg] 93 93 iced DIRECTION OF ICE DRIFT [deg]
94 94 ices SPEED OF ICE DRIFT [m/s] 94 94 ices SPEED OF ICE DRIFT [m/s]
95 95 iceu U-COMP OF ICE DRIFT [m/s] 95 95 iceu U-COMP OF ICE DRIFT [m/s]
96 96 icev V-COMP OF ICE DRIFT [m/s] 96 96 icev V-COMP OF ICE DRIFT [m/s]
97 97 iceg ICE GROWTH [m] 97 97 iceg ICE GROWTH [m]
98 98 icdv ICE DIVERGENCE [sec/sec] 98 98 icdv ICE DIVERGENCE [sec/sec]
99 99 var99 undefined 99 99 var99 undefined
100 100 shcw SIG HGT COM WAVE/SWELL [m] 100 100 shcw SIG HGT COM WAVE/SWELL [m]
@ -155,7 +155,7 @@
154 154 fdlt FLIGHT LEVELS TEMPERATURE [K] 154 154 fdlt FLIGHT LEVELS TEMPERATURE [K]
155 155 fdlu FLIGHT LEVELS U-WIND [m/s] 155 155 fdlu FLIGHT LEVELS U-WIND [m/s]
156 156 fdlv FLIGHT LEVELS V-WIND [m/s] 156 156 fdlv FLIGHT LEVELS V-WIND [m/s]
157 157 tppp TROPOPAUSE PRESSURE [hPa] 157 157 tppp TROPOPAUSE PRESSURE [hPa]
158 158 tppt TROPOPAUSE TEMPERATURE [K] 158 158 tppt TROPOPAUSE TEMPERATURE [K]
159 159 tppu TROPOPAUSE U-WIND COMPONENT [m/s] 159 159 tppu TROPOPAUSE U-WIND COMPONENT [m/s]
160 160 tppv TROPOPAUSE v-WIND COMPONENT [m/s] 160 160 tppv TROPOPAUSE v-WIND COMPONENT [m/s]
@ -170,16 +170,16 @@
169 169 vmfl VERT. INTEGRATED MOISTURE FLUX CONV. [kg/(m2*s)] 169 169 vmfl VERT. INTEGRATED MOISTURE FLUX CONV. [kg/(m2*s)]
170 170 vadv VERTICAL MOISTURE ADVECTION [kg/(kg*s)] 170 170 vadv VERTICAL MOISTURE ADVECTION [kg/(kg*s)]
171 171 nhcm NEG. HUM. CORR. MOISTURE SOURCE [kg/(kg*s)] 171 171 nhcm NEG. HUM. CORR. MOISTURE SOURCE [kg/(kg*s)]
172 172 lglh LARGE SCALE LATENT HEATING [K/s] 172 172 lglh LARGE SCALE LATENT HEATING [K/s]
173 173 lgms LARGE SCALE MOISTURE SOURCE [1/s] 173 173 lgms LARGE SCALE MOISTURE SOURCE [1/s]
174 174 smav SOIL MOISTURE AVAILABILITY [0-1] 174 174 smav SOIL MOISTURE AVAILABILITY [0-1]
175 175 tgrz SOIL TEMPERATURE OF ROOT ZONE [K] 175 175 tgrz SOIL TEMPERATURE OF ROOT ZONE [K]
176 176 bslh BARE SOIL LATENT HEAT [Ws/m2] 176 176 bslh BARE SOIL LATENT HEAT [Ws/m2]
177 177 evpp POTENTIAL SFC EVAPORATION [m] 177 177 evpp POTENTIAL SFC EVAPORATION [m]
178 178 rnof RUNOFF [kg/m2/s)] 178 178 rnof RUNOFF [kg/m2/s)]
179 179 pitp INTERCEPTION LOSS [W/m2] 179 179 pitp INTERCEPTION LOSS [W/m2]
180 180 vpca VAPOR PRESSURE OF CANOPY AIR SPACE [mb] 180 180 vpca VAPOR PRESSURE OF CANOPY AIR SPACE [mb]
181 181 qsfc SURFACE SPEC HUMIDITY [kg/kg] 181 181 qsfc SURFACE SPEC HUMIDITY [kg/kg]
182 182 ussl SOIL WETNESS OF SURFACE [0-1] 182 182 ussl SOIL WETNESS OF SURFACE [0-1]
183 183 uzrs SOIL WETNESS OF ROOT ZONE [0-1] 183 183 uzrs SOIL WETNESS OF ROOT ZONE [0-1]
184 184 uzds SOIL WETNESS OF DRAINAGE ZONE [0-1] 184 184 uzds SOIL WETNESS OF DRAINAGE ZONE [0-1]
@ -196,7 +196,7 @@
195 195 vsst SURFACE MERIDIONAL WIND STRESS [Pa] 195 195 vsst SURFACE MERIDIONAL WIND STRESS [Pa]
196 196 suvf SURFACE MOMENTUM FLUX [W/m2] 196 196 suvf SURFACE MOMENTUM FLUX [W/m2]
197 197 iswf INCIDENT SHORT WAVE FLUX [W/m2] 197 197 iswf INCIDENT SHORT WAVE FLUX [W/m2]
198 198 ghfl TIME AVE GROUND HT FLX [W/m2] 198 198 ghfl TIME AVE GROUND HT FLX [W/m2]
199 199 var199 undefined 199 199 var199 undefined
200 200 lwbc NET LONG WAVE AT BOTTOM (CLEAR) [W/m2] 200 200 lwbc NET LONG WAVE AT BOTTOM (CLEAR) [W/m2]
201 201 lwtc OUTGOING LONG WAVE AT TOP (CLEAR) [W/m2] 201 201 lwtc OUTGOING LONG WAVE AT TOP (CLEAR) [W/m2]

View File

@ -49,7 +49,7 @@ if(bitmapPresent) {
bitmap bitmap
): read_only; ): read_only;
alias data.packedValues = codedValues; alias data.packedValues = codedValues;
meta values data_apply_bitmap(codedValues,bitmap,missingValue,binaryScaleFactor) : dump; meta values data_apply_bitmap(codedValues,bitmap,missingValue,binaryScaleFactor) : dump;
} else { } else {

View File

@ -175,6 +175,6 @@ if(matrixOfValues == 0)
} }
meta packingError simple_packing_error(bitsPerValue,binaryScaleFactor,decimalScaleFactor,referenceValue,ibm) : no_copy; meta packingError simple_packing_error(bitsPerValue,binaryScaleFactor,decimalScaleFactor,referenceValue,ibm) : no_copy;
meta numberOfCodedValues number_of_coded_values(bitsPerValue,offsetBeforeData,offsetAfterData,halfByte,numberOfValues) : dump; meta numberOfCodedValues number_of_coded_values(bitsPerValue,offsetBeforeData,offsetAfterData,halfByte,numberOfValues) : dump;
template statistics "common/statistics_grid.def"; template statistics "common/statistics_grid.def";
template missing_values "common/missing_values_grid.def"; template missing_values "common/missing_values_grid.def";

View File

@ -38,7 +38,7 @@ flags[1] scanningModeForOneDiamond 'grib1/grid.192.78.3.10.table';
transient numberOfPoints= nd *(Ni + 1) * (Ni + 1); transient numberOfPoints= nd *(Ni + 1) * (Ni + 1);
alias numberOfDataPoints=numberOfPoints; alias numberOfDataPoints=numberOfPoints;
meta numberOfValues meta numberOfValues
number_of_values(values,bitsPerValue,numberOfDataPoints, number_of_values(values,bitsPerValue,numberOfDataPoints,
bitmapPresent,bitmap,numberOfCodedValues) : dump; bitmapPresent,bitmap,numberOfCodedValues) : dump;

View File

@ -1,16 +1,15 @@
# (C) Copyright 2005- ECMWF. # (C) Copyright 2005- ECMWF.
# # Description Octet Code Ksec1 Count
# Description Octet Code Ksec1 Count # ----------- ----- ---- ----- -----
# ----------- ----- ---- ----- ----- #localDefinitionNumber 41 I1 37 -
#localDefinitionNumber 41 I1 37 - #class 42 I1 38 -
#class 42 I1 38 - #type 43 I1 39 -
#type 43 I1 39 - #stream 44 I2 40 -
#stream 44 I2 40 - #experimentVersionNumber 46 A4 41 -
#experimentVersionNumber 46 A4 41 - #number 50 I1 42 -
#number 50 I1 42 - #total 51 I1 43 -
#total 51 I1 43 - #spareSetToZero 52 PAD n/a 1
#spareSetToZero 52 PAD n/a 1
# #
template mars_labeling "grib1/mars_labeling.def"; template mars_labeling "grib1/mars_labeling.def";

View File

@ -12,7 +12,7 @@
# #
# author: Sebastien Villaume # author: Sebastien Villaume
# created: 6 Oct 2011 # created: 6 Oct 2011
# modified: 13 May 2013 # modified: 13 May 2013
# #
# This piece of definition is common to all SMHI definitions # This piece of definition is common to all SMHI definitions

View File

@ -1,6 +1,6 @@
# #
# Definition for SMHI Swedish Meteorological and Hydrological Institut. # Definition for SMHI Swedish Meteorological and Hydrological Institut.
# #
# contact: sebastien.villaume@smhi.se # contact: sebastien.villaume@smhi.se
codetable[1] localDefinitionNumber 'grib1/localDefinitionNumber.82.table' = 82 : dump; codetable[1] localDefinitionNumber 'grib1/localDefinitionNumber.82.table' = 82 : dump;
@ -11,4 +11,4 @@ template ls_labeling "grib1/ls_labeling.82.def";
### MARS LABELING ### ### MARS LABELING ###
template mars_labeling "grib1/mars_labeling.82.def"; template mars_labeling "grib1/mars_labeling.82.def";
template_nofail marsKeywords "mars/eswi/grib1.[stream:s].[type:s].def"; template_nofail marsKeywords "mars/eswi/grib1.[stream:s].[type:s].def";

View File

@ -12,7 +12,7 @@ constant wrongPadding=1 : hidden;
unsigned[1] perturbationNumber : dump; unsigned[1] perturbationNumber : dump;
unsigned[1] numberOfForecastsInEnsemble : dump; unsigned[1] numberOfForecastsInEnsemble : dump;
alias totalNumber=numberOfForecastsInEnsemble; alias totalNumber=numberOfForecastsInEnsemble;
alias number = perturbationNumber; alias number = perturbationNumber;
unsigned[1] oceanAtmosphereCoupling : dump; unsigned[1] oceanAtmosphereCoupling : dump;

View File

@ -1,14 +1,14 @@
# #
# Description Octet Code Ksec1 Count # Description Octet Code Ksec1 Count
# ----------- ----- ---- ----- ----- # ----------- ----- ---- ----- -----
#localDefinitionNumber 41 I1 37 - #localDefinitionNumber 41 I1 37 -
#class 42 I1 38 - #class 42 I1 38 -
#type 43 I1 39 - #type 43 I1 39 -
#stream 44 I2 40 - #stream 44 I2 40 -
#experimentVersionNumber 46 A4 41 - #experimentVersionNumber 46 A4 41 -
#number 50 I1 42 - #number 50 I1 42 -
#total 51 I1 43 - #total 51 I1 43 -
#spareSetToZero 52 PAD n/a 1 #spareSetToZero 52 PAD n/a 1
# #
constant GRIBEXSection1Problem = 52 - section1Length ; constant GRIBEXSection1Problem = 52 - section1Length ;

View File

@ -1,36 +1,36 @@
# ECMWF concept type of level # ECMWF concept type of level
'surface' = {indicatorOfTypeOfLevel=1;} 'surface' = {indicatorOfTypeOfLevel=1;}
'cloudBase' = {indicatorOfTypeOfLevel=2;} 'cloudBase' = {indicatorOfTypeOfLevel=2;}
'cloudTop' = {indicatorOfTypeOfLevel=3;} 'cloudTop' = {indicatorOfTypeOfLevel=3;}
'isothermZero' = {indicatorOfTypeOfLevel=4;} 'isothermZero' = {indicatorOfTypeOfLevel=4;}
'adiabaticCondensation' = {indicatorOfTypeOfLevel=5;} 'adiabaticCondensation' = {indicatorOfTypeOfLevel=5;}
'maxWind' = {indicatorOfTypeOfLevel=6;} 'maxWind' = {indicatorOfTypeOfLevel=6;}
'tropopause' = {indicatorOfTypeOfLevel=7;} 'tropopause' = {indicatorOfTypeOfLevel=7;}
'nominalTop' = {indicatorOfTypeOfLevel=8;} 'nominalTop' = {indicatorOfTypeOfLevel=8;}
'seaBottom' = {indicatorOfTypeOfLevel=9;} 'seaBottom' = {indicatorOfTypeOfLevel=9;}
'isobaricInhPa' = {indicatorOfTypeOfLevel=100;} 'isobaricInhPa' = {indicatorOfTypeOfLevel=100;}
'isobaricInPa' = {indicatorOfTypeOfLevel=210;} 'isobaricInPa' = {indicatorOfTypeOfLevel=210;}
'isobaricLayer' = {indicatorOfTypeOfLevel=101;} 'isobaricLayer' = {indicatorOfTypeOfLevel=101;}
'meanSea' = {indicatorOfTypeOfLevel=102;} 'meanSea' = {indicatorOfTypeOfLevel=102;}
'isobaricLayerHighPrecision' = {indicatorOfTypeOfLevel=121;} 'isobaricLayerHighPrecision' = {indicatorOfTypeOfLevel=121;}
'isobaricLayerMixedPrecision' = {indicatorOfTypeOfLevel=141;} 'isobaricLayerMixedPrecision' = {indicatorOfTypeOfLevel=141;}
'heightAboveSea' = {indicatorOfTypeOfLevel=103;} 'heightAboveSea' = {indicatorOfTypeOfLevel=103;}
'heightAboveSeaLayer' = {indicatorOfTypeOfLevel=104;} 'heightAboveSeaLayer' = {indicatorOfTypeOfLevel=104;}
'heightAboveGroundHighPrecision' = {indicatorOfTypeOfLevel=125;} 'heightAboveGroundHighPrecision' = {indicatorOfTypeOfLevel=125;}
'heightAboveGround' = {indicatorOfTypeOfLevel=105;} 'heightAboveGround' = {indicatorOfTypeOfLevel=105;}
'heightAboveGroundLayer' = {indicatorOfTypeOfLevel=106;} 'heightAboveGroundLayer' = {indicatorOfTypeOfLevel=106;}
'sigma' = {indicatorOfTypeOfLevel=107;} 'sigma' = {indicatorOfTypeOfLevel=107;}
'sigmaLayer' = {indicatorOfTypeOfLevel=108;} 'sigmaLayer' = {indicatorOfTypeOfLevel=108;}
'sigmaLayerHighPrecision' = {indicatorOfTypeOfLevel=128;} 'sigmaLayerHighPrecision' = {indicatorOfTypeOfLevel=128;}
'hybrid' = {indicatorOfTypeOfLevel=109;} 'hybrid' = {indicatorOfTypeOfLevel=109;}
'hybridLayer' = {indicatorOfTypeOfLevel=110;} 'hybridLayer' = {indicatorOfTypeOfLevel=110;}
'depthBelowLand' = {indicatorOfTypeOfLevel=111;} 'depthBelowLand' = {indicatorOfTypeOfLevel=111;}
'depthBelowLandLayer' = {indicatorOfTypeOfLevel=112;} 'depthBelowLandLayer' = {indicatorOfTypeOfLevel=112;}
'theta' = {indicatorOfTypeOfLevel=113;} 'theta' = {indicatorOfTypeOfLevel=113;}
'thetaLayer' = {indicatorOfTypeOfLevel=114;} 'thetaLayer' = {indicatorOfTypeOfLevel=114;}
'pressureFromGround' = {indicatorOfTypeOfLevel=115;} 'pressureFromGround' = {indicatorOfTypeOfLevel=115;}
'pressureFromGroundLayer' = {indicatorOfTypeOfLevel=116;} 'pressureFromGroundLayer' = {indicatorOfTypeOfLevel=116;}
'potentialVorticity' = {indicatorOfTypeOfLevel=117;} 'potentialVorticity' = {indicatorOfTypeOfLevel=117;}
'depthBelowSea' = {indicatorOfTypeOfLevel=160;} 'depthBelowSea' = {indicatorOfTypeOfLevel=160;}
'entireAtmosphere' = {indicatorOfTypeOfLevel=200;} 'entireAtmosphere' = {indicatorOfTypeOfLevel=200;}
'entireOcean' = {indicatorOfTypeOfLevel=201;} 'entireOcean' = {indicatorOfTypeOfLevel=201;}

View File

@ -79,7 +79,8 @@ int main(int argc, char** argv)
} }
/* write multi-field handle to output file */ /* write multi-field handle to output file */
codes_grib_multi_handle_write(mh, of); err = codes_grib_multi_handle_write(mh, of);
if (err) return 1;
fclose(of); fclose(of);
/* release memory */ /* release memory */

View File

@ -11,6 +11,7 @@ if( HAVE_BUILD_TOOLS )
codes_ecc-1392 codes_ecc-1392
codes_datetime_julian codes_datetime_julian
codes_set_paths codes_set_paths
codes_f90_misc
grib_set_pv grib_set_pv
grib_set_data grib_set_data
bufr_ecc-1284 bufr_ecc-1284
@ -67,6 +68,7 @@ else()
grib_set_pv grib_set_pv
grib_set_data grib_set_data
codes_set_paths codes_set_paths
codes_f90_misc
get_native_type get_native_type
grib_ecc-671 ) grib_ecc-671 )
list( APPEND tests_extra list( APPEND tests_extra

View File

@ -0,0 +1,31 @@
! (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.
!
!
program codes_f90_misc
use eccodes
implicit none
integer :: array_of_error_codes(8), i, code
character(len=64) :: error_message = ''
call codes_gribex_mode_on()
call codes_gribex_mode_off()
call codes_bufr_multi_element_constant_arrays_on()
call codes_bufr_multi_element_constant_arrays_off()
array_of_error_codes = [0, -2, -14, -16, -26, -28, -38, -41]
do i = 1, size(array_of_error_codes)
error_message = ''
code = array_of_error_codes(i)
call codes_get_error_string(code, error_message)
write (*, *) 'error message: <', adjustl(trim(error_message)), '>'
end do
end program

13
examples/F90/codes_f90_misc.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
# (C) Copyright 2005- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
. ./include.ctest.sh
# export ECCODES_DEBUG=1
${examples_dir}/eccodes_f_codes_f90_misc

View File

@ -466,6 +466,11 @@ void codes_gts_header_off(grib_context* c)
{ {
grib_gts_header_off(c); grib_gts_header_off(c);
} }
void codes_gts_header_on(grib_context* c)
{
grib_gts_header_on(c);
}
void codes_gribex_mode_on(grib_context* c) void codes_gribex_mode_on(grib_context* c)
{ {
grib_gribex_mode_on(c); grib_gribex_mode_on(c);

View File

@ -1528,7 +1528,7 @@ Error codes returned by the eccodes functions.
#define CODES_WRONG_STEP_UNIT GRIB_WRONG_STEP_UNIT #define CODES_WRONG_STEP_UNIT GRIB_WRONG_STEP_UNIT
/** Invalid file id */ /** Invalid file id */
#define CODES_INVALID_FILE GRIB_INVALID_FILE #define CODES_INVALID_FILE GRIB_INVALID_FILE
/** Invalid grib id */ /** Invalid GRIB id */
#define CODES_INVALID_GRIB GRIB_INVALID_GRIB #define CODES_INVALID_GRIB GRIB_INVALID_GRIB
/** Invalid index id */ /** Invalid index id */
#define CODES_INVALID_INDEX GRIB_INVALID_INDEX #define CODES_INVALID_INDEX GRIB_INVALID_INDEX

View File

@ -727,6 +727,12 @@ static bool is_number(const char* s)
return true; return true;
} }
static bool strings_equal(const char* s1, const char* s2, bool case_sensitive)
{
if (case_sensitive) return (strcmp(s1, s2) == 0);
return (strcmp_nocase(s1, s2) == 0);
}
static int pack_string(grib_accessor* a, const char* buffer, size_t* len) static int pack_string(grib_accessor* a, const char* buffer, size_t* len)
{ {
long lValue = 0; long lValue = 0;
@ -742,14 +748,10 @@ static int pack_string(grib_accessor* a, const char* buffer, size_t* len)
} }
grib_accessor_codetable* self = (grib_accessor_codetable*)a; grib_accessor_codetable* self = (grib_accessor_codetable*)a;
grib_codetable* table; grib_codetable* table = NULL;
long i; long i = 0;
size_t size = 1; size_t size = 1;
typedef int (*cmpproc)(const char*, const char*);
cmpproc cmp = (a->flags & GRIB_ACCESSOR_FLAG_LOWERCASE) ? strcmp_nocase : strcmp;
if (!self->table_loaded) { if (!self->table_loaded) {
self->table = load_table(a); /* may return NULL */ self->table = load_table(a); /* may return NULL */
self->table_loaded = 1; self->table_loaded = 1;
@ -765,10 +767,18 @@ static int pack_string(grib_accessor* a, const char* buffer, size_t* len)
return err; return err;
} }
for (i = 0; i < table->size; i++) // If the key has the "lowercase" flag set, then the string comparison
if (table->entries[i].abbreviation) // should ignore the case
if (cmp(table->entries[i].abbreviation, buffer) == 0) bool case_sensitive = true;
if (a->flags & GRIB_ACCESSOR_FLAG_LOWERCASE) case_sensitive = false;
for (i = 0; i < table->size; i++) {
if (table->entries[i].abbreviation) {
if (strings_equal(table->entries[i].abbreviation, buffer, case_sensitive)) {
return grib_pack_long(a, &i, &size); return grib_pack_long(a, &i, &size);
}
}
}
if (a->flags & GRIB_ACCESSOR_FLAG_NO_FAIL) { if (a->flags & GRIB_ACCESSOR_FLAG_NO_FAIL) {
grib_action* act = (grib_action*)(a->creator); grib_action* act = (grib_action*)(a->creator);

View File

@ -446,7 +446,7 @@ static int get_native_type(grib_accessor* a)
static int compare(grib_accessor* a, grib_accessor* b) static int compare(grib_accessor* a, grib_accessor* b)
{ {
int retval = 0; int retval = GRIB_SUCCESS;
double* aval = 0; double* aval = 0;
double* bval = 0; double* bval = 0;
@ -475,10 +475,8 @@ static int compare(grib_accessor* a, grib_accessor* b)
grib_unpack_double(b, bval, &blen); grib_unpack_double(b, bval, &blen);
retval = GRIB_SUCCESS; retval = GRIB_SUCCESS;
while (alen != 0) { for (size_t i=0; i<alen && retval == GRIB_SUCCESS; ++i) {
if (*bval != *aval) if (aval[i] != bval[i]) retval = GRIB_DOUBLE_VALUE_MISMATCH;
retval = GRIB_DOUBLE_VALUE_MISMATCH;
alen--;
} }
grib_context_free(a->context, aval); grib_context_free(a->context, aval);

View File

@ -117,8 +117,7 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN;
self->number_of_elements = 6; self->number_of_elements = 6;
self->v = (double*)grib_context_malloc(a->context, self->v = (double*)grib_context_malloc(a->context, sizeof(double) * self->number_of_elements);
sizeof(double) * self->number_of_elements);
a->length = 0; a->length = 0;
a->dirty = 1; a->dirty = 1;
@ -127,8 +126,8 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
static int unpack_double(grib_accessor* a, double* val, size_t* len) static int unpack_double(grib_accessor* a, double* val, size_t* len)
{ {
grib_accessor_g1end_of_interval_monthly* self = (grib_accessor_g1end_of_interval_monthly*)a; grib_accessor_g1end_of_interval_monthly* self = (grib_accessor_g1end_of_interval_monthly*)a;
int ret = 0; int ret = 0;
char verifyingMonth[7] = {0,}; char verifyingMonth[7] = {0,};
size_t slen = 7; size_t slen = 7;
long year = 0, month = 0, date = 0; long year = 0, month = 0, date = 0;
const long mdays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; const long mdays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
@ -144,6 +143,9 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
return ret; return ret;
date = atoi(verifyingMonth); date = atoi(verifyingMonth);
if (date < 0) {
return GRIB_INVALID_ARGUMENT;
}
year = date / 100; year = date / 100;
month = date - year * 100; month = date - year * 100;
if (month == 2) { if (month == 2) {
@ -151,9 +153,10 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
days = 29; days = 29;
} }
else else {
if (month < 1 || month > 12) return GRIB_INVALID_ARGUMENT;
days = mdays[month - 1]; days = mdays[month - 1];
}
self->v[0] = year; self->v[0] = year;
self->v[1] = month; self->v[1] = month;
@ -217,13 +220,11 @@ static int compare(grib_accessor* a, grib_accessor* b)
b->dirty = 1; b->dirty = 1;
a->dirty = 1; a->dirty = 1;
grib_unpack_double(a, aval, &alen); err = grib_unpack_double(a, aval, &alen); if(err) return err;
grib_unpack_double(b, bval, &blen); err = grib_unpack_double(b, bval, &blen); if(err) return err;
while (alen != 0) { for(size_t i=0; i<alen && retval == GRIB_SUCCESS; ++i) {
if (*bval != *aval) if (aval[i] != bval[i]) retval = GRIB_DOUBLE_VALUE_MISMATCH;
retval = GRIB_DOUBLE_VALUE_MISMATCH;
alen--;
} }
grib_context_free(a->context, aval); grib_context_free(a->context, aval);

View File

@ -241,10 +241,8 @@ static int compare(grib_accessor* a, grib_accessor* b)
grib_unpack_long(b, bval, &blen); grib_unpack_long(b, bval, &blen);
retval = GRIB_SUCCESS; retval = GRIB_SUCCESS;
while (alen != 0) { for (size_t i=0; i<alen && retval == GRIB_SUCCESS; ++i) {
if (*bval != *aval) if (aval[i] != bval[i]) retval = GRIB_LONG_VALUE_MISMATCH;
retval = GRIB_LONG_VALUE_MISMATCH;
alen--;
} }
grib_context_free(a->context, aval); grib_context_free(a->context, aval);

View File

@ -313,10 +313,9 @@ static int compare(grib_accessor* a, grib_accessor* b)
grib_unpack_double(a, aval, &alen); grib_unpack_double(a, aval, &alen);
grib_unpack_double(b, bval, &blen); grib_unpack_double(b, bval, &blen);
while (alen != 0) { retval = GRIB_SUCCESS;
if (*bval != *aval) for (size_t i=0; i<alen && retval == GRIB_SUCCESS; ++i) {
retval = GRIB_DOUBLE_VALUE_MISMATCH; if (aval[i] != bval[i]) retval = GRIB_DOUBLE_VALUE_MISMATCH;
alen--;
} }
grib_context_free(a->context, aval); grib_context_free(a->context, aval);

View File

@ -266,10 +266,8 @@ static int compare(grib_accessor* a, grib_accessor* b)
grib_unpack_double(b, bval, &blen); grib_unpack_double(b, bval, &blen);
retval = GRIB_SUCCESS; retval = GRIB_SUCCESS;
while (alen != 0) { for (size_t i=0; i<alen && retval == GRIB_SUCCESS; ++i) {
if (*bval != *aval) if (aval[i] != bval[i]) retval = GRIB_DOUBLE_VALUE_MISMATCH;
retval = GRIB_DOUBLE_VALUE_MISMATCH;
alen--;
} }
grib_context_free(a->context, aval); grib_context_free(a->context, aval);

View File

@ -1659,7 +1659,7 @@ Error codes returned by the grib_api functions.
#define GRIB_WRONG_STEP_UNIT -26 #define GRIB_WRONG_STEP_UNIT -26
/** Invalid file id */ /** Invalid file id */
#define GRIB_INVALID_FILE -27 #define GRIB_INVALID_FILE -27
/** Invalid grib id */ /** Invalid GRIB id */
#define GRIB_INVALID_GRIB -28 #define GRIB_INVALID_GRIB -28
/** Invalid index id */ /** Invalid index id */
#define GRIB_INVALID_INDEX -29 #define GRIB_INVALID_INDEX -29

View File

@ -950,7 +950,7 @@ struct grib_multi_support
unsigned char* sections[8]; unsigned char* sections[8];
unsigned char* bitmap_section; unsigned char* bitmap_section;
size_t bitmap_section_length; size_t bitmap_section_length;
size_t sections_length[9]; size_t sections_length[9]; /* GRIB2 has 9 sections */
int section_number; int section_number;
grib_multi_support* next; grib_multi_support* next;
}; };

View File

@ -15,7 +15,7 @@
static void grib_get_buffer_ownership(const grib_context* c, grib_buffer* b) static void grib_get_buffer_ownership(const grib_context* c, grib_buffer* b)
{ {
unsigned char* newdata; unsigned char* newdata = NULL;
if (b->property == CODES_MY_BUFFER) if (b->property == CODES_MY_BUFFER)
return; return;
@ -78,11 +78,9 @@ void grib_buffer_delete(const grib_context* c, grib_buffer* b)
static void grib_grow_buffer_to(const grib_context* c, grib_buffer* b, size_t ns) static void grib_grow_buffer_to(const grib_context* c, grib_buffer* b, size_t ns)
{ {
unsigned char* newdata;
if (ns > b->length) { if (ns > b->length) {
grib_get_buffer_ownership(c, b); grib_get_buffer_ownership(c, b);
newdata = (unsigned char*)grib_context_malloc_clear(c, ns); unsigned char* newdata = (unsigned char*)grib_context_malloc_clear(c, ns);
memcpy(newdata, b->data, b->length); memcpy(newdata, b->data, b->length);
grib_context_free(c, b->data); grib_context_free(c, b->data);
b->data = newdata; b->data = newdata;
@ -159,7 +157,7 @@ static void update_offsets_after(grib_accessor* a, long len)
// plen = grib_get_next_position_offset(s->block->last); // plen = grib_get_next_position_offset(s->block->last);
// if((ret = grib_pack_long(s->aclength, &plen, &len)) != GRIB_SUCCESS) // if((ret = grib_pack_long(s->aclength, &plen, &len)) != GRIB_SUCCESS)
// ; // ;
// //
// if(s->h->context->debug) // if(s->h->context->debug)
// printf("SECTION updating length %ld .. %s\n",plen,s->owner->name); // printf("SECTION updating length %ld .. %s\n",plen,s->owner->name);
// } // }

View File

@ -40,7 +40,7 @@ static const char *errors[] = {
"Unable to set step", /* -25 GRIB_WRONG_STEP */ "Unable to set step", /* -25 GRIB_WRONG_STEP */
"Wrong units for step (step must be integer)", /* -26 GRIB_WRONG_STEP_UNIT */ "Wrong units for step (step must be integer)", /* -26 GRIB_WRONG_STEP_UNIT */
"Invalid file id", /* -27 GRIB_INVALID_FILE */ "Invalid file id", /* -27 GRIB_INVALID_FILE */
"Invalid grib id", /* -28 GRIB_INVALID_GRIB */ "Invalid GRIB id", /* -28 GRIB_INVALID_GRIB */
"Invalid index id", /* -29 GRIB_INVALID_INDEX */ "Invalid index id", /* -29 GRIB_INVALID_INDEX */
"Invalid iterator id", /* -30 GRIB_INVALID_ITERATOR */ "Invalid iterator id", /* -30 GRIB_INVALID_ITERATOR */
"Invalid keys iterator id", /* -31 GRIB_INVALID_KEYS_ITERATOR */ "Invalid keys iterator id", /* -31 GRIB_INVALID_KEYS_ITERATOR */

View File

@ -29,7 +29,7 @@ GRIB_WRONG_STEP Unable to set step
GRIB_WRONG_STEP_UNIT Wrong units for step (step must be integer) GRIB_WRONG_STEP_UNIT Wrong units for step (step must be integer)
/* some errors for the fortran interface */ /* some errors for the fortran interface */
GRIB_INVALID_FILE Invalid file id GRIB_INVALID_FILE Invalid file id
GRIB_INVALID_GRIB Invalid grib id GRIB_INVALID_GRIB Invalid GRIB id
GRIB_INVALID_INDEX Invalid index id GRIB_INVALID_INDEX Invalid index id
GRIB_INVALID_ITERATOR Invalid iterator id GRIB_INVALID_ITERATOR Invalid iterator id
GRIB_INVALID_KEYS_ITERATOR Invalid keys iterator id GRIB_INVALID_KEYS_ITERATOR Invalid keys iterator id

View File

@ -16,8 +16,8 @@
static grib_handle* grib_handle_new_from_file_no_multi(grib_context* c, FILE* f, int headers_only, int* error); static grib_handle* grib_handle_new_from_file_no_multi(grib_context* c, FILE* f, int headers_only, int* error);
static grib_handle* grib_handle_new_from_file_multi(grib_context* c, FILE* f, int* error); static grib_handle* grib_handle_new_from_file_multi(grib_context* c, FILE* f, int* error);
static int grib2_get_next_section(unsigned char* msgbegin, size_t msglen, unsigned char** secbegin, size_t* seclen, int* secnum, int* err); static bool grib2_get_next_section(unsigned char* msgbegin, size_t msglen, unsigned char** secbegin, size_t* seclen, int* secnum, int* err);
static int grib2_has_next_section(unsigned char* msgbegin, size_t msglen, unsigned char* secbegin, size_t seclen, int* err); static bool grib2_has_next_section(unsigned char* msgbegin, size_t msglen, unsigned char* secbegin, size_t seclen, int* err);
static void grib2_build_message(grib_context* context, unsigned char* sections[], size_t sections_len[], void** data, size_t* msglen); static void grib2_build_message(grib_context* context, unsigned char* sections[], size_t sections_len[], void** data, size_t* msglen);
static grib_multi_support* grib_get_multi_support(grib_context* c, FILE* f); static grib_multi_support* grib_get_multi_support(grib_context* c, FILE* f);
static grib_multi_support* grib_multi_support_new(grib_context* c); static grib_multi_support* grib_multi_support_new(grib_context* c);
@ -1259,11 +1259,10 @@ grib_multi_handle* grib_multi_handle_new(grib_context* c)
int grib_multi_handle_delete(grib_multi_handle* h) int grib_multi_handle_delete(grib_multi_handle* h)
{ {
if (h == NULL) if (h != NULL) {
return GRIB_SUCCESS; grib_buffer_delete(h->context, h->buffer);
grib_context_free(h->context, h);
grib_buffer_delete(h->context, h->buffer); }
grib_context_free(h->context, h);
return GRIB_SUCCESS; return GRIB_SUCCESS;
} }
@ -1325,11 +1324,11 @@ int grib_multi_handle_write(grib_multi_handle* h, FILE* f)
return GRIB_INVALID_GRIB; return GRIB_INVALID_GRIB;
if (fwrite(h->buffer->data, 1, h->buffer->ulength, f) != h->buffer->ulength) { if (fwrite(h->buffer->data, 1, h->buffer->ulength, f) != h->buffer->ulength) {
grib_context_log(h->context, GRIB_LOG_PERROR, "grib_multi_handle_write writing on file"); grib_context_log(h->context, GRIB_LOG_PERROR, "%s failed", __func__);
return GRIB_IO_PROBLEM; return GRIB_IO_PROBLEM;
} }
return 0; return GRIB_SUCCESS;
} }
int grib_get_partial_message(grib_handle* h, const void** msg, size_t* len, int start_section) int grib_get_partial_message(grib_handle* h, const void** msg, size_t* len, int start_section)
@ -1393,9 +1392,9 @@ int grib_get_message_offset(const grib_handle* h, off_t* offset)
if (h) if (h)
*offset = h->offset; *offset = h->offset;
else else
return GRIB_INTERNAL_ERROR; return GRIB_NULL_HANDLE;
return 0; return GRIB_SUCCESS;
} }
int codes_get_product_kind(const grib_handle* h, ProductKind* product_kind) int codes_get_product_kind(const grib_handle* h, ProductKind* product_kind)
@ -1566,10 +1565,10 @@ int grib_handle_apply_action(grib_handle* h, grib_action* a)
// return GRIB_SUCCESS; // return GRIB_SUCCESS;
// } // }
static int grib2_get_next_section(unsigned char* msgbegin, size_t msglen, unsigned char** secbegin, size_t* seclen, int* secnum, int* err) static bool grib2_get_next_section(unsigned char* msgbegin, size_t msglen, unsigned char** secbegin, size_t* seclen, int* secnum, int* err)
{ {
if (!grib2_has_next_section(msgbegin, msglen, *secbegin, *seclen, err)) if (!grib2_has_next_section(msgbegin, msglen, *secbegin, *seclen, err))
return 0; return false;
*secbegin += *seclen; *secbegin += *seclen;
*seclen = grib_decode_unsigned_byte_long(*secbegin, 0, 4); *seclen = grib_decode_unsigned_byte_long(*secbegin, 0, 4);
@ -1577,12 +1576,12 @@ static int grib2_get_next_section(unsigned char* msgbegin, size_t msglen, unsign
if (*secnum < 1 || *secnum > 7) { if (*secnum < 1 || *secnum > 7) {
*err = GRIB_INVALID_SECTION_NUMBER; *err = GRIB_INVALID_SECTION_NUMBER;
return 0; return false;
} }
return 1; return true;
} }
static int grib2_has_next_section(unsigned char* msgbegin, size_t msglen, unsigned char* secbegin, size_t seclen, int* err) static bool grib2_has_next_section(unsigned char* msgbegin, size_t msglen, unsigned char* secbegin, size_t seclen, int* err)
{ {
long next_seclen; long next_seclen;
*err = 0; *err = 0;
@ -1594,12 +1593,12 @@ static int grib2_has_next_section(unsigned char* msgbegin, size_t msglen, unsign
*err = GRIB_SUCCESS; *err = GRIB_SUCCESS;
else else
*err = GRIB_7777_NOT_FOUND; *err = GRIB_7777_NOT_FOUND;
return 0; return false;
} }
/*secbegin += seclen;*/ /*secbegin += seclen;*/
return 1; return true;
} }
static void grib2_build_message(grib_context* context, unsigned char* sections[], size_t sections_len[], void** data, size_t* len) static void grib2_build_message(grib_context* context, unsigned char* sections[], size_t sections_len[], void** data, size_t* len)
@ -1714,6 +1713,8 @@ void grib_multi_support_reset(grib_context* c)
static grib_multi_support* grib_multi_support_new(grib_context* c) static grib_multi_support* grib_multi_support_new(grib_context* c)
{ {
// GRIB edition 2 has 9 sections ( 0 to 8 )
const int GRIB2_END_SECTION = 8;
int i = 0; int i = 0;
grib_multi_support* gm = grib_multi_support* gm =
(grib_multi_support*)grib_context_malloc_clear(c, sizeof(grib_multi_support)); (grib_multi_support*)grib_context_malloc_clear(c, sizeof(grib_multi_support));
@ -1725,9 +1726,10 @@ static grib_multi_support* grib_multi_support_new(grib_context* c)
gm->section_number = 0; gm->section_number = 0;
gm->next = 0; gm->next = 0;
gm->sections_length[0] = 16; gm->sections_length[0] = 16;
for (i = 1; i < 8; i++)
for (i = 1; i < GRIB2_END_SECTION; i++)
gm->sections_length[i] = 0; gm->sections_length[i] = 0;
gm->sections_length[8] = 4; gm->sections_length[GRIB2_END_SECTION] = 4; // The 7777
return gm; return gm;
} }

View File

@ -52,6 +52,17 @@ if [ $? -eq 0 ]; then
fi fi
set -e set -e
# Namespace options
set +e
${tools_dir}/bufr_compare -c ls:n $f1 $f2 >> $fLog
statusA=$?
${tools_dir}/bufr_compare -a -c ls:n $f1 $f2 >> $fLog
statusB=$?
set -e
[ $statusA -ne 0 ]
[ $statusB -ne 0 ]
#---------------------------------------------------- #----------------------------------------------------
# Test: comparing with and without the -b switch # Test: comparing with and without the -b switch
#---------------------------------------------------- #----------------------------------------------------

View File

@ -16,6 +16,8 @@ cd ${data_dir}/bufr
# Define a common label for all the tmp files # Define a common label for all the tmp files
label="bufr_filter_misc_test" label="bufr_filter_misc_test"
tempErr=temp.$label.err
# Create log file # Create log file
fLog=${label}".log" fLog=${label}".log"
rm -f $fLog rm -f $fLog
@ -1337,5 +1339,16 @@ EOF
diff $fRef $fLog diff $fRef $fLog
rm -f $fRef rm -f $fRef
# Bad filter
set +e
${tools_dir}/bufr_filter a_non_existent_filter_file $ECCODES_SAMPLES_PATH/BUFR4.tmpl > $tempErr 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Cannot include file" $tempErr
# Clean up # Clean up
rm -f ${f}.log ${f}.log.ref ${f}.out $fLog $fRules rm -f ${f}.log ${f}.log.ref ${f}.out $fLog $fRules
rm -f $tempErr

View File

@ -71,5 +71,19 @@ ${tools_dir}/codes_bufr_filter $fRules $f
f="$ECCODES_SAMPLES_PATH/BUFR4.tmpl" f="$ECCODES_SAMPLES_PATH/BUFR4.tmpl"
echo 'print "[expandedOriginalReferences:i]";' | ${tools_dir}/codes_bufr_filter - $f echo 'print "[expandedOriginalReferences:i]";' | ${tools_dir}/codes_bufr_filter - $f
# Error decoding 'pack'
# ----------------------
f="$ECCODES_SAMPLES_PATH/BUFR4.tmpl"
set +e
echo 'print "[pack]";' | ${tools_dir}/codes_bufr_filter - $f 2>$temp
status=$?
set -e
grep -q "Function not yet implemented" $temp
# Pack using a double
f=nos6_208.bufr
${tools_dir}/bufr_set -s unpack=1,satelliteIdentifier=666,pack:d=1 $f $temp
${tools_dir}/bufr_compare -b satelliteIdentifier $f $temp
# Clean up # Clean up
rm -f $fRules $fLog $temp rm -f $fRules $fLog $temp

View File

@ -183,6 +183,22 @@ ${tools_dir}/bufr_set -s messageLength:s=333 $ECCODES_SAMPLES_PATH/BUFR4_local.t
result=`${tools_dir}/bufr_get -p messageLength $fBufrTmp` result=`${tools_dir}/bufr_get -p messageLength $fBufrTmp`
[ "$result" = "333" ] [ "$result" = "333" ]
#-----------------------------------------------------------
# Invalid masterTablesVersionNumber
#-----------------------------------------------------------
${tools_dir}/bufr_set -s masterTablesVersionNumber=255 $ECCODES_SAMPLES_PATH/BUFR4.tmpl $fBufrTmp
set +e
${tools_dir}/bufr_dump -p $fBufrTmp 2>>$fLog 1>>$fLog
if [ $? -eq 0 ]; then
echo "bufr_dump should have failed" >&2
exit 1
fi
set -e
grep -q "unable to find definition file sequence.def.*bufr/tables/0/local/0/98/0/sequence.def" $fLog
grep -q "ECCODES ERROR.*unable to get hash value for sequences" $fLog
# Clean up # Clean up
rm -f $fLog rm -f $fLog
rm -f $fBufrTmp rm -f $fBufrTmp

View File

@ -17,13 +17,19 @@ int main(int argc, char* argv[])
grib_handle* h1 = NULL; grib_handle* h1 = NULL;
grib_handle* h2 = NULL; grib_handle* h2 = NULL;
int err = 0; int err = 0;
size_t count = 0; size_t num_diffs = 0, i = 0;
char** list_provided_keys = NULL;
Assert(argc == 3);
f1 = fopen(argv[1], "rb"); f1 = fopen(argv[1], "rb");
f2 = fopen(argv[2], "rb"); f2 = fopen(argv[2], "rb");
Assert(f1 && f2); Assert(f1 && f2);
if (argc == 4) {
// List of keys is also given on the command line
char* input = argv[3];
list_provided_keys = string_split(input, ",");
}
while ((h1 = grib_handle_new_from_file(0, f1, &err)) != NULL && (h2 = grib_handle_new_from_file(0, f2, &err)) != NULL) { while ((h1 = grib_handle_new_from_file(0, f1, &err)) != NULL && (h2 = grib_handle_new_from_file(0, f2, &err)) != NULL) {
grib_keys_iterator* kiter = NULL; grib_keys_iterator* kiter = NULL;
@ -39,7 +45,7 @@ int main(int argc, char* argv[])
err = codes_compare_key(h1, h2, name, 0); err = codes_compare_key(h1, h2, name, 0);
if (err) { if (err) {
fprintf(stderr, "key: %s (%s)\n", name, grib_get_error_message(err)); fprintf(stderr, "key: %s (%s)\n", name, grib_get_error_message(err));
++count; ++num_diffs;
} }
} }
@ -49,14 +55,33 @@ int main(int argc, char* argv[])
codes_compare_key(h1, h2, "paramId", 0); // concept codes_compare_key(h1, h2, "paramId", 0); // concept
codes_compare_key(h1, h2, "identifier", 0); // ascii codes_compare_key(h1, h2, "identifier", 0); // ascii
if (list_provided_keys) {
for (i = 0; list_provided_keys[i] != NULL; ++i) {
const char* pkey = list_provided_keys[i];
//printf("Comparing provided key %s ...\n", list_provided_keys[i]);
err = codes_compare_key(h1, h2, pkey, 0);
if (err) {
fprintf(stderr, "key: %s (%s)\n", pkey, grib_get_error_message(err));
++num_diffs;
}
}
}
grib_keys_iterator_delete(kiter); grib_keys_iterator_delete(kiter);
grib_handle_delete(h1); grib_handle_delete(h1);
grib_handle_delete(h2); grib_handle_delete(h2);
} }
fclose(f1); fclose(f1);
fclose(f2); fclose(f2);
if (count > 0) {
fprintf(stderr, "\nComparison failed: %zu differences\n", count); if (list_provided_keys) {
for (i = 0; list_provided_keys[i] != NULL; ++i) free(list_provided_keys[i]);
free(list_provided_keys);
}
if (num_diffs > 0) {
fprintf(stderr, "\nComparison failed: %zu differences\n", num_diffs);
return 1; return 1;
} }
return 0; return 0;

View File

@ -63,5 +63,27 @@ EOF
diff $tempRef $tempLog diff $tempRef $tempLog
# Spectral
# ----------
sample_spectral=$ECCODES_SAMPLES_PATH/sh_ml_grib2.tmpl
${test_dir}/codes_compare_keys $sample_spectral $sample_spectral enorm,avg
# Local definitions
# ----------------------
sample1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
tempGribA=temp.${label}.A.grib
tempGribB=temp.${label}.B.grib
${tools_dir}/grib_set -s localDefinitionNumber=16,verifyingMonth=6 $sample1 $tempGribA
${tools_dir}/grib_set -s localDefinitionNumber=16,verifyingMonth=5 $sample1 $tempGribB
set +e
${test_dir}/codes_compare_keys $tempGribA $tempGribB endOfInterval > $tempLog 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "2 differences" $tempLog
rm -f $tempGribA $tempGribB
# Clean up # Clean up
rm -f $tempLog $tempRef $tempGrib rm -f $tempLog $tempRef $tempGrib

View File

@ -13,11 +13,18 @@
label="codes_dump_content_test" label="codes_dump_content_test"
temp=temp.$label.txt temp=temp.$label.txt
infile=$data_dir/sample.grib2 infiles="
sample.grib2
test_uuid.grib2
"
modes="default wmo json serialize debug grib_encode_C" modes="default wmo json serialize debug grib_encode_C"
for mode in $modes; do for mode in $modes; do
$EXEC ${test_dir}/codes_dump_content $mode $infile for gf in $infiles; do
echo Doing $gf
infile=$data_dir/$gf
$EXEC ${test_dir}/codes_dump_content $mode $infile > $temp
done
done done
${test_dir}/codes_dump_content rubbish $infile > $temp 2>&1 ${test_dir}/codes_dump_content rubbish $infile > $temp 2>&1

View File

@ -10,12 +10,12 @@
. ./include.ctest.sh . ./include.ctest.sh
label="grib_calendar_test"
temp1=temp1.calendar.$$ temp1=temp1.$label.$$
temp2=temp2.calendar.$$ temp2=temp2.$label.$$
sample=$ECCODES_SAMPLES_PATH/GRIB2.tmpl sample=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
${tools_dir}/grib_set -s tablesVersion=13,setCalendarId=1,typeOfCalendar=0 $sample $temp1 ${tools_dir}/grib_set -s tablesVersion=13,setCalendarId=1,typeOfCalendar=0 $sample $temp1
grib_check_key_equals $temp1 calendarIdPresent 1 grib_check_key_equals $temp1 calendarIdPresent 1
grib_check_key_equals $temp1 section1Length 24 grib_check_key_equals $temp1 section1Length 24

View File

@ -30,7 +30,11 @@ set -e
infile1=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl infile1=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl
${tools_dir}/grib_set -s year=2019 $infile1 $outfile ${tools_dir}/grib_set -s year=2019 $infile1 $outfile
${tools_dir}/grib_compare -c data:n $infile1 $outfile ${tools_dir}/grib_compare -c data:n $infile1 $outfile
set +e
${tools_dir}/grib_compare -a -c data:n $infile1 $outfile
status=$?
set -e
[ $status -eq 1 ]
# Header (meta-data) keys # Header (meta-data) keys
infile=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl infile=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl

View File

@ -106,6 +106,7 @@ grep -q "dataDate = 19090206" $temp
# Skip handle # Skip handle
${tools_dir}/grib_dump -w count=4 $file > $temp 2>&1 ${tools_dir}/grib_dump -w count=4 $file > $temp 2>&1
ECCODES_DEBUG=1 ${tools_dir}/grib_dump $data_dir/sample.grib2
# Clean up # Clean up
rm -f $temp rm -f $temp

View File

@ -406,6 +406,15 @@ EOF
${tools_dir}/grib_filter $tempFilt $ECCODES_SAMPLES_PATH/GRIB2.tmpl ${tools_dir}/grib_filter $tempFilt $ECCODES_SAMPLES_PATH/GRIB2.tmpl
# Bad filter
set +e
${tools_dir}/grib_filter a_non_existent_filter_file $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Cannot include file" $tempOut
# Clean up # Clean up
rm -f $tempGrib $tempFilt $tempOut $tempRef rm -f $tempGrib $tempFilt $tempOut $tempRef
rm -f ${data_dir}/formatint.rules ${data_dir}/binop.rules rm -f ${data_dir}/formatint.rules ${data_dir}/binop.rules

View File

@ -9,22 +9,23 @@
. ./include.ctest.sh . ./include.ctest.sh
label="grib_grid_lamb_az_eq_area_test"
GRIB_INFILE=${data_dir}/regular_gaussian_pressure_level_constant.grib2 GRIB_INFILE=${data_dir}/regular_gaussian_pressure_level_constant.grib2
REF_FILE=grib_lamb_az_eq_area.ref REF_FILE=grib_lamb_az_eq_area.ref
# Temporary files created for this test # Temporary files created for this test
FILTER_FILE=lamb_az_eq_area.filter FILTER_FILE=temp.$label.filter
GRIB_OUTFILE=lamb_az_eq_area.grib2 GRIB_OUTFILE=temp.$label.grib2
DATA_OUTFILE=lamb_data.txt DATA_OUTFILE=temp.$label.txt
rm -f $FILTER_FILE $GRIB_OUTFILE $DATA_OUTFILE rm -f $FILTER_FILE $GRIB_OUTFILE $DATA_OUTFILE
# --------------------
# Spherical Earth # Spherical Earth
# ---------------- # --------------------
# Create a filter # Create a filter
cat > $FILTER_FILE<<EOF cat > $FILTER_FILE<<EOF
set edition = 2;
set gridType = "lambert_azimuthal_equal_area"; set gridType = "lambert_azimuthal_equal_area";
set Nx = 10; set Nx = 10;
set Ny = 10; set Ny = 10;
@ -53,7 +54,7 @@ ${tools_dir}/grib_filter -o $GRIB_OUTFILE $FILTER_FILE $GRIB_INFILE
${tools_dir}/grib_get_data $GRIB_OUTFILE > $DATA_OUTFILE ${tools_dir}/grib_get_data $GRIB_OUTFILE > $DATA_OUTFILE
# Compare output with reference. If the diff fails, script will immediately exit with status 1 # Compare output with reference. If the diff fails, script will immediately exit with status 1
diff $DATA_OUTFILE $REF_FILE diff $REF_FILE $DATA_OUTFILE
grib_check_key_equals $GRIB_OUTFILE standardParallelInDegrees,centralLongitudeInDegrees '48 9' grib_check_key_equals $GRIB_OUTFILE standardParallelInDegrees,centralLongitudeInDegrees '48 9'
grib_check_key_equals $GRIB_OUTFILE xDirectionGridLengthInMetres,yDirectionGridLengthInMetres '5000 5000' grib_check_key_equals $GRIB_OUTFILE xDirectionGridLengthInMetres,yDirectionGridLengthInMetres '5000 5000'
@ -62,8 +63,20 @@ grib_check_key_equals $GRIB_OUTFILE xDirectionGridLengthInMetres,yDirectionGridL
${tools_dir}/grib_ls -l 67,-33,1 $GRIB_OUTFILE ${tools_dir}/grib_ls -l 67,-33,1 $GRIB_OUTFILE
# jPointsAreConsecutive # jPointsAreConsecutive
${tools_dir}/grib_get_data -s jPointsAreConsecutive=1 $GRIB_OUTFILE > $DATA_OUTFILE tempOutA=temp.$label.A.txt
tempOutB=temp.$label.B.txt
${tools_dir}/grib_get_data -s jPointsAreConsecutive=0 $GRIB_OUTFILE > $tempOutA
${tools_dir}/grib_get_data -s jPointsAreConsecutive=1 $GRIB_OUTFILE > $tempOutB
# Results should be different.
set +e
diff $tempOutA $tempOutB > /dev/null
status=$?
set -e
[ $status -ne 0 ]
rm -f $tempOutA $tempOutB
# --------------------
# Oblate spheroid # Oblate spheroid
# -------------------- # --------------------

View File

@ -13,8 +13,16 @@
label="grib_mars_keys2_test" label="grib_mars_keys2_test"
tempGrib=temp.${label}.grib tempGrib=temp.${label}.grib
grib1_sample=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
grib2_sample=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl grib2_sample=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl
# Check lowercase/uppercase
${tools_dir}/grib_set -s class=YT,type=EM,stream=DCWV $grib1_sample $tempGrib
grib_check_key_equals $tempGrib mars.class,mars.type,mars.stream 'yt em dcwv'
grib_check_key_equals $tempGrib marsClass:i,marsType:i,marsStream:i '18 17 1029'
# Check all combinations # Check all combinations
# ------------------------ # ------------------------
i=0 i=0
@ -31,4 +39,5 @@ for cfg in $ECCODES_DEFINITION_PATH/mars/grib.*.*.def; do
done done
echo "Checked $i files" echo "Checked $i files"
# Clean up
rm -f $tempGrib rm -f $tempGrib

View File

@ -10,13 +10,13 @@
. ./include.ctest.sh . ./include.ctest.sh
tmpdata=grib_multi.$$.grib label="grib_multi_test"
tmpdata=temp.$label.$$.grib
rm -f $tmpdata rm -f $tmpdata
parameterNumber=`${tools_dir}/grib_get -p parameterNumber -w parameterCategory=2,parameterNumber=3 ${data_dir}/multi.grib2` parameterNumber=`${tools_dir}/grib_get -p parameterNumber -w parameterCategory=2,parameterNumber=3 ${data_dir}/multi.grib2`
if [ -z "$parameterNumber" ] if [ -z "$parameterNumber" ]; then
then echo '---------- grib_get failure'
echo ---------- grib_get failure
exit 1 exit 1
fi fi
@ -24,15 +24,14 @@ ${tools_dir}/grib_copy -w parameterCategory=2,parameterNumber=3 ${data_dir}/mult
${tools_dir}/grib_compare ${data_dir}/v.grib2 $tmpdata.1 ${tools_dir}/grib_compare ${data_dir}/v.grib2 $tmpdata.1
cat > $tmpdata.rules <<EOF cat > $tmpdata.rules <<EOF
if ( parameterCategory==2 && parameterNumber==3) { if ( parameterCategory==2 && parameterNumber==3) {
print "[parameterNumber]"; print "[parameterNumber]";
} }
EOF EOF
parameterNumber=`${tools_dir}/grib_filter $tmpdata.rules ${data_dir}/multi.grib2` parameterNumber=`${tools_dir}/grib_filter $tmpdata.rules ${data_dir}/multi.grib2`
if [ -z "$parameterNumber" ] if [ -z "$parameterNumber" ]; then
then echo '---------- grib_filter failure'
echo ---------- grib_filter failure
exit 1 exit 1
fi fi

View File

@ -10,11 +10,13 @@
. ./include.ctest.sh . ./include.ctest.sh
label="grib_padding_test"
REDIRECT=/dev/null REDIRECT=/dev/null
temp=loc.padding.grib1 tempGrib=temp.local.$label.grib1
tempFilt=temp.local.$label.filt
${tools_dir}/grib_set -s setLocalDefinition=1 ${data_dir}/regular_latlon_surface.grib1 $temp ${tools_dir}/grib_set -s setLocalDefinition=1 ${data_dir}/regular_latlon_surface.grib1 $tempGrib
cat > $$_f <<EOF cat > $tempFilt <<EOF
if (GRIBEXSection1Problem ) { if (GRIBEXSection1Problem ) {
print "localDefinitionNumber=[localDefinitionNumber] size(GRIBEX-section1)=[GRIBEXSection1Problem] section1Length=[section1Length]"; print "localDefinitionNumber=[localDefinitionNumber] size(GRIBEX-section1)=[GRIBEXSection1Problem] section1Length=[section1Length]";
write "problem.grib"; write "problem.grib";
@ -24,27 +26,32 @@ EOF
# Note: we cannot use -printf "%f\n" as on some unix platforms -printf is not an option # Note: we cannot use -printf "%f\n" as on some unix platforms -printf is not an option
# for find. So instead we use sed to get to the filename without the fullpath # for find. So instead we use sed to get to the filename without the fullpath
localDefinitions=`find ${def_dir}/grib1/ -name 'local.98.*def' | sed -e 's:.*/::' |\ localDefinitions=`find ${def_dir}/grib1/ -name 'local.98.*.def' | sed -e 's:.*/::' |\
awk 'BEGIN {FS=".";} {print $3;}' |\ awk 'BEGIN {FS=".";} {print $3;}' |\
grep -v def |\ grep -v def |\
sed '/245/d' |\ sed '/245/d' |\
sed '/12/d' |\ sed '/12/d' |\
sed '/50/d' |\
sed '/244/d' |\ sed '/244/d' |\
sed '/190/d' |\
sed '/191/d' |\
sed '/192/d' |\ sed '/192/d' |\
xargs` xargs`
count=0
for l1 in $localDefinitions for l1 in $localDefinitions
do do
${tools_dir}/grib_set -M -s localDefinitionNumber=$l1 $temp locx.grib1 ${tools_dir}/grib_set -M -s localDefinitionNumber=$l1 $tempGrib locx.grib1
${tools_dir}/grib_filter -M $$_f locx.grib1 ${tools_dir}/grib_filter -M $tempFilt locx.grib1
for l2 in $localDefinitions for l2 in $localDefinitions
do do
if [ $l1 -ne $l2 ]; then if [ $l1 -ne $l2 ]; then
#echo "$l1 -> $l2" #echo "$l1 -> $l2"
${tools_dir}/grib_set -M -s localDefinitionNumber=$l2 locx.grib1 locy.grib1 ${tools_dir}/grib_set -M -s localDefinitionNumber=$l2 locx.grib1 locy.grib1
${tools_dir}/grib_filter -M $$_f locy.grib1 ${tools_dir}/grib_filter -M $tempFilt locy.grib1
count=$((count+1))
fi fi
done done
done done
echo Did $count iterations
rm -f $$_f locx.grib1 locy.grib1 $temp rm -f locx.grib1 locy.grib1 $tempGrib $tempFilt

View File

@ -225,6 +225,14 @@ set -e
[ $status -ne 0 ] [ $status -ne 0 ]
grep -q "stepUnits: No such code table entry.*Did you mean" $temp grep -q "stepUnits: No such code table entry.*Did you mean" $temp
set +e
${tools_dir}/grib_set -s centre=ECMF $input $outfile > $temp 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "centre: No such code table entry.*Did you mean.*ecmf" $temp
# ------------------------ # ------------------------
# Unreadable message # Unreadable message
# ------------------------ # ------------------------

View File

@ -20,7 +20,7 @@ int main(int argc, char** argv)
FILE* in = NULL; FILE* in = NULL;
const char* infile = "../data/test_uuid.grib2"; const char* infile = "../data/test_uuid.grib2";
FILE* out = NULL; FILE* out = NULL;
const char* outfile = "temp.grib_set_bytes.grib"; const char* outfile = "temp.grib_set_bytes_test.grib";
grib_handle* h = NULL; grib_handle* h = NULL;
const void* buffer = NULL; const void* buffer = NULL;

View File

@ -9,14 +9,17 @@
# #
. ./include.ctest.sh . ./include.ctest.sh
TEMP_ERR=temp.grib_set_bytes.log
TEMP_OUT=temp.grib_set_bytes.grib
$EXEC ${test_dir}/grib_set_bytes 2>$TEMP_ERR label="grib_set_bytes_test"
grep -q "Wrong size.*for uuidOfVGrid. It is 16 bytes long" $TEMP_ERR tempErr=temp.$label.log
tempOut=temp.$label.grib
uuid=`${tools_dir}/grib_get -p uuidOfVGrid $TEMP_OUT` $EXEC ${test_dir}/grib_set_bytes 2>$tempErr
grep -q "Wrong size.*for uuidOfVGrid. It is 16 bytes long" $tempErr
uuid=`${tools_dir}/grib_get -p uuidOfVGrid $tempOut`
[ "$uuid" = "07204051072040510720405207204053" ] [ "$uuid" = "07204051072040510720405207204053" ]
rm -f $TEMP_OUT $TEMP_ERR rm -f $tempOut $tempErr

View File

@ -10,7 +10,10 @@
. ./include.ctest.sh . ./include.ctest.sh
TEMP=output.grib_sh_imag.grib # Check that first coefficient have an imaginary part equal to zero.
$EXEC ${test_dir}/grib_sh_imag $TEMP # philippe.marguinaud@meteo.fr, 2016/02
rm -f $TEMP tempGrib=output.grib_sh_imag.grib
$EXEC ${test_dir}/grib_sh_imag $tempGrib
rm -f $tempGrib

View File

@ -10,24 +10,24 @@
. ./include.ctest.sh . ./include.ctest.sh
label="grib_statistics_test"
temp1=temp1.$label.grib
temp2=temp2.$label.grib
files="regular_latlon_surface.grib2 regular_latlon_surface.grib1" files="regular_latlon_surface.grib2 regular_latlon_surface.grib1"
for file in $files for file in $files; do
do
cat >statistics.filter<<EOF cat >statistics.filter<<EOF
set Ni=2; set Ni=2;
set Nj=2; set Nj=2;
set decimalPrecision=4;
set decimalPrecision=4; set values={2.0,2.0,2.0,2.0};
set values={2.0,2.0,2.0,2.0}; print "values=[values]";
print "values=[values]"; print "max=[max] min=[min] average=[average]";
print "max=[max] min=[min] average=[average]"; set values={2.0,5.0,2.0,2.0};
print "values=[values]";
set values={2.0,5.0,2.0,2.0}; print "max=[max] min=[min] average=[average]";
print "values=[values]";
print "max=[max] min=[min] average=[average]";
EOF EOF
${tools_dir}/grib_filter statistics.filter ${data_dir}/$file > statistics.out ${tools_dir}/grib_filter statistics.filter ${data_dir}/$file > statistics.out
@ -42,8 +42,6 @@ rm -f statistics.out statistics.filter
# See ECC-478 # See ECC-478
# --------------------------------------------------- # ---------------------------------------------------
input=${data_dir}/lfpw.grib1 input=${data_dir}/lfpw.grib1
temp1=temp1.statistics.grib
temp2=temp2.statistics.grib
stats=`${tools_dir}/grib_get -w count=50 -F%.2f -n statistics $input` stats=`${tools_dir}/grib_get -w count=50 -F%.2f -n statistics $input`
[ "$stats" = "10098.00 0.00 1064.19 3066.07 2.57 4.61 0.00" ] [ "$stats" = "10098.00 0.00 1064.19 3066.07 2.57 4.61 0.00" ]

View File

@ -9,6 +9,7 @@
*/ */
#include "grib_api_internal.h" #include "grib_api_internal.h"
#include "eccodes.h"
#define EPSILON 1e-12 #define EPSILON 1e-12
#define DBL_EQUAL(a, b) (fabs((a) - (b)) <= (EPSILON)*fabs((a))) #define DBL_EQUAL(a, b) (fabs((a) - (b)) <= (EPSILON)*fabs((a)))
@ -34,10 +35,10 @@ static void TestDateTime(const long year, const long month, const long day, cons
long jdlong1, jdlong2, date; long jdlong1, jdlong2, date;
/* Convert the input values to a double */ /* Convert the input values to a double */
grib_datetime_to_julian(year, month, day, hour, min, sec, &jd); codes_datetime_to_julian(year, month, day, hour, min, sec, &jd);
/* Convert the double back to the input values and compare */ /* Convert the double back to the input values and compare */
grib_julian_to_datetime(jd, &year1, &month1, &day1, &hour1, &min1, &sec1); codes_julian_to_datetime(jd, &year1, &month1, &day1, &hour1, &min1, &sec1);
if (!Check(year, month, day, hour, min, sec, year1, month1, day1, hour1, min1, sec1)) { if (!Check(year, month, day, hour, min, sec, year1, month1, day1, hour1, min1, sec1)) {
fprintf(stderr, fprintf(stderr,
@ -73,7 +74,7 @@ static void Test0()
min = 26; min = 26;
sec = 24; sec = 24;
grib_datetime_to_julian(year, month, day, hour, min, sec, &jd); codes_datetime_to_julian(year, month, day, hour, min, sec, &jd);
Assert(DBL_EQUAL(jd, 2378891.268333)); Assert(DBL_EQUAL(jd, 2378891.268333));
printf("%ld %ld %ld %ld:%ld:%ld -> %f\n", year, month, day, hour, min, sec, jd); printf("%ld %ld %ld %ld:%ld:%ld -> %f\n", year, month, day, hour, min, sec, jd);
@ -153,9 +154,9 @@ static void Test2()
} }
jdl = (long)(jd + 0.5); jdl = (long)(jd + 0.5);
date = grib_julian_to_date(jdl); date = codes_julian_to_date(jdl);
printf("+ %ld -> %ld\n", date, jdl); printf("+ %ld -> %ld\n", date, jdl);
jdl = grib_date_to_julian(date); jdl = codes_date_to_julian(date);
printf("- %ld -> %ld\n", date, jdl); printf("- %ld -> %ld\n", date, jdl);
printf("\n"); printf("\n");
} }

View File

@ -45,6 +45,23 @@ if [ $status -eq 0 ]; then
exit 1 exit 1
fi fi
# Compare using a namespace
set +e
${tools_dir}/metar_compare -c ls:n $metar_file $fMetarTmp > $fLog 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "DIFFERENCE == string.*dateTime" $fLog
set +e
${tools_dir}/metar_compare -a -c ls:n $metar_file $fMetarTmp > $fLog 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "DIFFERENCE == string.*dateTime" $fLog
grep -q "DIFFERENCE == string.*theMessage" $fLog
# The -d option should have created these files # The -d option should have created these files
rm -f error1_1.metar error2_1.metar error1_2.metar error2_2.metar rm -f error1_1.metar error2_1.metar error1_2.metar error2_2.metar

View File

@ -9,6 +9,7 @@
*/ */
#include "grib_api_internal.h" #include "grib_api_internal.h"
#include "eccodes.h"
#define NUMBER(x) (sizeof(x) / sizeof(x[0])) #define NUMBER(x) (sizeof(x) / sizeof(x[0]))
@ -91,7 +92,7 @@ static void test_gaussian_latitudes(int order)
double lat1 = 0, lat2 = 0; double lat1 = 0, lat2 = 0;
double* lats = (double*)malloc(sizeof(double) * num); double* lats = (double*)malloc(sizeof(double) * num);
ret = grib_get_gaussian_latitudes(order, lats); ret = codes_get_gaussian_latitudes(order, lats);
Assert(ret == GRIB_SUCCESS); Assert(ret == GRIB_SUCCESS);
lat1 = lats[0]; lat1 = lats[0];
@ -112,7 +113,7 @@ static void test_gaussian_latitude_640()
int ret = 0; int ret = 0;
const double tolerance = 1e-6; const double tolerance = 1e-6;
double* lats = (double*)malloc(sizeof(double) * num); double* lats = (double*)malloc(sizeof(double) * num);
ret = grib_get_gaussian_latitudes(order, lats); ret = codes_get_gaussian_latitudes(order, lats);
Assert(ret == GRIB_SUCCESS); Assert(ret == GRIB_SUCCESS);
compare_doubles(lats[0], 89.892396, tolerance); compare_doubles(lats[0], 89.892396, tolerance);
@ -378,9 +379,34 @@ static void test_gribex_mode()
Assert( grib_get_gribex_mode(c) == 0 ); /* default is OFF */ Assert( grib_get_gribex_mode(c) == 0 ); /* default is OFF */
grib_gribex_mode_on(c); grib_gribex_mode_on(c);
codes_gribex_mode_on(c);
Assert( grib_get_gribex_mode(c) == 1 ); Assert( grib_get_gribex_mode(c) == 1 );
grib_gribex_mode_off(c); grib_gribex_mode_off(c);
codes_gribex_mode_off(c);
Assert( grib_get_gribex_mode(c) == 0 ); Assert( grib_get_gribex_mode(c) == 0 );
Assert( codes_get_gribex_mode(c) == 0 );
}
static void test_gts_header_mode()
{
grib_context* c = grib_context_get_default();
printf("Running %s ...\n", __func__);
grib_gts_header_on(c);
codes_gts_header_on(c);
Assert(c->gts_header_on == 1);
grib_gts_header_off(c);
codes_gts_header_off(c);
Assert(c->gts_header_on == 0);
}
static void test_bufr_multi_element_constant_arrays()
{
grib_context* c = grib_context_get_default();
printf("Running %s ...\n", __func__);
codes_bufr_multi_element_constant_arrays_on(c);
codes_bufr_multi_element_constant_arrays_off(c);
} }
static void test_grib_binary_search() static void test_grib_binary_search()
@ -649,6 +675,8 @@ int main(int argc, char** argv)
test_get_git_sha1(); test_get_git_sha1();
test_get_build_date(); test_get_build_date();
test_gribex_mode(); test_gribex_mode();
test_gts_header_mode();
test_bufr_multi_element_constant_arrays();
test_concept_condition_strings(); test_concept_condition_strings();