Merge branch 'eccodes' of ssh://software.ecmwf.int:7999/GRIB/grib_api into eccodes

This commit is contained in:
Shahram Najm 2014-08-07 13:06:38 +01:00
commit 6e37fd6baa
20 changed files with 1179 additions and 513 deletions

8
.gitignore vendored
View File

@ -178,6 +178,13 @@ ehthumbs.db
Thumbs.db
.directory
src/tags
data/exp
data/bufr/*.ref
data/bufr/*.test
data/bufr/*.json
data/bufr/*.no
data/.downloaded
data/budg
data/*.grib
@ -185,6 +192,7 @@ data/*.grib2
data/*.grib1
data/tigge/tigge*.grib
data/bufr/*.bufr
data/exp/
CMakeLists.txt.user*

9
data/bufr/make_bufrdc_ref.ksh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/ksh
set -ex
decode=/var/tmp/mac/p4/bufrdc/releases/000402/examples/bufr_decode_data
for f in *.bufr
do
$decode -i $f | sed 's/MISSING/-1.00000000000000e+100/g' | sed -e '/ECMWF/,+8d' > $f.ref
done

View File

@ -10,6 +10,7 @@
constant defaultSequence=0;
constant tablesMasterDir="bufr/tables/[masterTableNumber]/wmo/[masterTablesVersionNumber]" : hidden;
constant tablesLocalDir="bufr/tables/[masterTableNumber]/local/[localTablesVersionNumber]/[centre:l]/[subCentre]" : hidden;
constant rootTablesDir="bufr/tables" : hidden;
transient tableNumber=0;
codetable[24] codeTablesMaster '[tablesMasterDir]/codetables/[tableNumber].table' : string_type,transient;
@ -68,31 +69,18 @@ meta unexpandedDescriptors unexpanded_descriptors(numberOfUnexpandedDescriptors)
meta expandedDescriptors expanded_descriptors(unexpandedDescriptors,sequences) ;
#smart_table NAME (VALUES,FILE_NAME,MASTER_DIRECTORY,LOCAL_DIRECTORY,WIDTH_OF_CODE_IN_BITS);
smart_table elements (expandedDescriptors,"element.table",tablesMasterDir,tablesLocalDir,16) ;
meta abbreviation smart_table_column(elements,0,1) : string_type;
meta type smart_table_column(elements,1,0) : string_type;
meta name smart_table_column(elements,2,0) : string_type;
meta unit smart_table_column(elements,3,0) : string_type;
meta scale smart_table_column(elements,4,0) : long_type;
meta reference smart_table_column(elements,5,0) : long_type;
meta width smart_table_column(elements,6,0) : long_type;
meta crex_unit smart_table_column(elements,7,0) : long_type;
meta crex_scale smart_table_column(elements,8,0) : long_type;
meta crex_width smart_table_column(elements,9,0) : long_type;
meta expandedDescriptorsAfterOperators apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,0) : read_only;
meta scaleAfterOperators apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,1) :read_only;
meta referenceAfterOperators apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,2) :read_only;
meta widthAfterOperators apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,3) :read_only;
meta bitmapNumber apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,4) :read_only;
meta associatedBitmapNumber apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,5) :read_only;
meta associatedBitmapIndex apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,6) :read_only;
meta abbreviationAfterOperators apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,7) :read_only,string_type;
meta typeAfterOperators apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,8) :read_only,string_type;
meta nameAfterOperators apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,9) :read_only,string_type;
meta unitAfterOperators apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,10) :read_only,string_type;
meta associatedInfoNumber apply_operators(expandedDescriptors,abbreviation,type,name,unit,scale,reference,width,11) :read_only;
#smart_table NAME (VALUES,FILE_NAME,MASTER_DIRECTORY,LOCAL_DIRECTORY,WIDTH_OF_CODE_IN_BITS,EXTRA_DIRECTORY,EXTRA_FILE_NAME);
smart_table expanded (expandedDescriptors,"element.table",tablesMasterDir,tablesLocalDir,18,rootTablesDir,"operators.table") ;
meta abbreviation smart_table_column(expanded,0,1) : string_type;
meta type smart_table_column(expanded,1,0) : string_type;
meta name smart_table_column(expanded,2,0) : string_type;
meta unit smart_table_column(expanded,3,0) : string_type;
meta scale smart_table_column(expanded,4,0) : long_type;
meta reference smart_table_column(expanded,5,0) : long_type;
meta width smart_table_column(expanded,6,0) : long_type;
meta crex_unit smart_table_column(expanded,7,0) : long_type;
meta crex_scale smart_table_column(expanded,8,0) : long_type;
meta crex_width smart_table_column(expanded,9,0) : long_type;
meta hasDelayedReplication bufr_has_delayed_replication(expandedDescriptorsAfterOperators);

View File

@ -17,22 +17,15 @@ meta selectGroupNumber bufr_group_number();
transient subsetNumber=0;
if (compressedData) {
meta values bufr_data(offsetSection4,offsetBeforeData,offsetEndSection4,section4Length,
numberOfDataSubsets,subsetNumber,
expandedDescriptorsAfterOperators,abbreviationAfterOperators,
typeAfterOperators,nameAfterOperators,unitAfterOperators,
referenceAfterOperators,scaleAfterOperators,widthAfterOperators,codeFlags,
bitmapNumber,associatedBitmapNumber,associatedBitmapIndex,associatedInfoNumber) : dump;
meta numericValues bufr_data_array(offsetSection4,offsetBeforeData,offsetEndSection4,section4Length,
numberOfDataSubsets,subsetNumber,
expandedDescriptors,type,reference,scale,width,
stringValues,elementsFXY,compressedData) ;
} else {
meta values bufr_uncompressed_data(offsetSection4,offsetBeforeData,offsetEndSection4,section4Length,
numberOfDataSubsets,subsetNumber,
expandedDescriptorsAfterOperators,abbreviationAfterOperators,
typeAfterOperators,nameAfterOperators,unitAfterOperators,
referenceAfterOperators,scaleAfterOperators,widthAfterOperators,codeFlags,
bitmapNumber,associatedBitmapNumber,associatedBitmapIndex) : dump;
assert(0);
}
meta unpack unpack_bufr_values(values);
meta unpack unpack_bufr_values(numericValues);
section_padding section4Padding;
position offsetEndSection4;

View File

@ -0,0 +1,15 @@
#code|abbreviation|type|name|unit|scale|reference|width|crex_unit|crex_scale|crex_width
222000|qualityInformationFollows|long|The values of class 33 elements which follow relate to the data defined by the data present bit-map|OPERATOR|0|0|0|0|0|
223000|substitutedValuesOperator|long|The substituted values which follow relate to the data defined by the data present bit-map|OPERATOR|0|0|0|0|0|
223255|substitutedValuesMarkerOperator|long|This operator shall signify a data item containing a substituted value; the element descriptor for the substituted value is obtained by the application of the data present bit-map associated with the substituted values operator|OPERATOR|0|0|0|0|0|
224000|firstOrderStatisticalValuesFollow|long|The statistical values which follow relate to the data defined by the data present bit-map|OPERATOR|0|0|0|0|0|
224555|firstOrderStatisticalValuesMarkerOperator|long|This operator shall signify a data item containing a first-order statistical value of the type indicated by the preceding 0 08 023 element descriptor; the element descriptor to which the fi-rosrtder statistic relates is obtained by the application of the data present bit-map associated with the first-order statistical values follow operator; first-order statistical values shall be represented as defined by this element descriptor |OPERATOR|0|0|0|0|0|
225000|differenceStatisticalValuesFollow|long|The statistical values which follow relate to the data defined by the data present bit-map|OPERATOR|0|0|0|0|0|
225255|differenceStatisticalValuesMarkerOperator|long|This operator shall signify a data item containing a difference statistical value of the type indicated by the preceding 0 08 024 element descriptor; the element descriptor to which the difference statistical value relates is obtained by the application of the data present bit-map associated with the difference statistical values follow operator; difference statistical values shall be represented as defined by this element descriptor, but with a reference value of 2n and a data width of (n+1), where n is the data width given by the original descriptor. This special reference value allows the statistical difference values to be centred around zero|OPERATOR|0|0|0|0|0|
232000|replacedRetainedValuesFollow|long|The replaced/retained values which follow relate to the data defined by the data present bit-map|OPERATOR|0|0|0|0|0|
232255|replacedRetainedValuesMarkerOperator|long|This operator shall signify a data item containing the original of an element which has been replaced by a substituted value. The element descriptor for the retained value is obtained by the application of the data present bit-map associated with the substituted values operator|OPERATOR|0|0|0|0|0|
236000|defineDataPresentBitmap|long|This operator defines the data present bit-map which follows for possible re-use; only one data present bitmap may be defined between this operator and the cancel use defined data present bit-map operator|OPERATOR|0|0|0|0|0|
236000|defineDataPresentBitmap|long|This operator defines the data present bit-map which follows for possible re-use; only one data present bitmap may be defined between this operator and the cancel use defined data present bit-map operator |OPERATOR|0|0|0|0|0|
237000|useDefinedDataPresentBitmap|long|This operator causes the defined data present bit-map to be used again|OPERATOR|0|0|0|0|0|
237255|cancelUseDefinedDataPresentBitmap|long|This operator cancels the re-use of the defined data present bit-map|OPERATOR|0|0|0|0|0|
001192|modelVersionNumber|long|MODEL VERSION NUMBER|CODE TABLE 1192|0|0|8|0|0|

View File

@ -1,4 +1,347 @@
list( APPEND grib_api_srcs
<<<<<<< HEAD
grib_api.h
action.c
action_class_alias.c
action_class_gen.c
action_class_if.c
action_class_switch.c
grib_accessor_class_g1fcperiod.c
grib_accessor_class_g1end_of_interval_monthly.c
grib_accessor_class_mars_param.c
action_class_section.c
action_class_list.c
action_class_while.c
action_class_put.c
action_class_meta.c
action_class_remove.c
action_class_rename.c
action_class_assert.c
action_class_template.c
action_class_trigger.c
action_class_when.c
action_class_concept.c
action_class_hash_array.c
action_class_assert.c
action_class_template.c
action_class_trigger.c
action_class_when.c
action_class_hash_array.c
action_class_set.c
action_class_set_darray.c
action_class_set_iarray.c
action_class_noop.c
action_class_write.c
action_class_print.c
action_class_close.c
action_class_variable.c
action_class_modify.c
grib_accessor.c
grib_concept.c
grib_hash_array.c
grib_darray.c
grib_vdarray.c
grib_sarray.c
grib_vsarray.c
grib_iarray.c
grib_viarray.c
grib_accessor_class_array.c
grib_accessor_class_assert.c
grib_accessor_class_ascii.c
grib_accessor_class_bit.c
grib_accessor_class_bitmap.c
grib_accessor_class_bits.c
grib_accessor_class_bits_per_value.c
grib_accessor_class_bufr_data.c
grib_accessor_class_bufr_data_element.c
grib_accessor_class_bufr_group.c
grib_accessor_class_unpack_bufr_values.c
grib_accessor_class_bufr_uncompressed_data.c
grib_accessor_class_bufr_element.c
grib_accessor_class_bufr_has_delayed_replication.c
grib_accessor_class_bufr_subset_number.c
grib_accessor_class_bufr_group_number.c
grib_accessor_class_apply_operators.c
grib_accessor_class_group.c
grib_accessor_class_non_alpha.c
grib_accessor_class_g1bitmap.c
grib_accessor_class_g2bitmap.c
grib_accessor_class_concept.c
grib_accessor_class_hash_array.c
grib_accessor_class_decimal_precision.c
grib_accessor_class_divdouble.c
grib_accessor_class_budgdate.c
grib_accessor_class_validity_date.c
grib_accessor_class_validity_time.c
grib_accessor_class_bytes.c
grib_accessor_class.c
grib_accessor_class_change_scanning_direction.c
grib_accessor_class_codeflag.c
grib_accessor_class_smart_table.c
grib_accessor_class_smart_table_column.c
grib_accessor_class_codetable.c
grib_accessor_class_codetable_units.c
grib_accessor_class_codetable_title.c
grib_accessor_class_count_file.c
grib_accessor_class_count_total.c
grib_accessor_class_double.c
grib_accessor_class_element.c
grib_accessor_class_evaluate.c
grib_accessor_class_g1area.c
grib_accessor_class_g1date.c
grib_accessor_class_g1monthlydate.c
grib_accessor_class_library_version.c
grib_accessor_class_when.c
grib_accessor_class_g1verificationdate.c
grib_accessor_class_g1day_of_the_year_date.c
grib_accessor_class_g1_half_byte_codeflag.c
grib_accessor_class_g1forecastmonth.c
grib_accessor_class_g1step_range.c
grib_accessor_class_g2step_range.c
grib_accessor_class_data_g22order_packing.c
grib_accessor_class_mars_step.c
grib_accessor_class_message_copy.c
grib_accessor_class_dictionary.c
grib_accessor_class_g1param.c
grib_accessor_class_g1p1p2.c
grib_accessor_class_g1_increment.c
grib_accessor_class_latlon_increment.c
grib_accessor_class_g2date.c
grib_accessor_class_g2level.c
grib_accessor_class_g2step.c
grib_accessor_class_g2end_step.c
grib_accessor_class_g2latlon.c
grib_accessor_class_g2lon.c
grib_accessor_class_global_gaussian.c
grib_accessor_class_gen.c
grib_accessor_class_getenv.c
grib_accessor_class_gts_header.c
grib_accessor_class_ifs_param.c
grib_accessor_class_julian_day.c
grib_accessor_class_latlonvalues.c
grib_accessor_class_latitudes.c
grib_accessor_class_longitudes.c
grib_accessor_class_missing.c
grib_accessor_class_offset_file.c
grib_accessor_class_scale.c
grib_accessor_class_from_scale_factor_scaled_value.c
grib_accessor_class_times.c
grib_accessor_class_forward.c
grib_accessor_class_g2bitmap_present.c
grib_accessor_class_ibmfloat.c
grib_accessor_class_ieeefloat.c
grib_accessor_class_constant.c
grib_accessor_class_iterator.c
grib_accessor_class_message.c
grib_accessor_class_nearest.c
grib_accessor_class_box.c
grib_accessor_class_ksec1expver.c
grib_accessor_class_laplacian.c
grib_accessor_class_label.c
grib_accessor_class_long.c
grib_accessor_class_lookup.c
grib_accessor_class_octect_number.c
grib_accessor_class_headers_only.c
grib_accessor_class_padding.c
grib_accessor_class_pad.c
grib_accessor_class_padto.c
grib_accessor_class_padtoeven.c
grib_accessor_class_padtomultiple.c
grib_accessor_class_section_padding.c
grib_accessor_class_section_pointer.c
grib_accessor_class_position.c
grib_accessor_class_signed.c
grib_accessor_class_signed_bits.c
grib_accessor_class_section.c
grib_accessor_class_step_in_units.c
grib_accessor_class_section_length.c
grib_accessor_class_g1_message_length.c
grib_accessor_class_g1_section4_length.c
grib_accessor_class_size.c
grib_accessor_class_scale_values.c
grib_accessor_class_offset_values.c
grib_accessor_class_sprintf.c
grib_accessor_class_round.c
grib_accessor_class_spectral_truncation.c
grib_accessor_class_time.c
grib_accessor_class_transient.c
grib_accessor_class_g1_half_byte_codeflag.c
grib_accessor_class_values.c
grib_accessor_class_simple_packing_error.c
grib_accessor_class_data_simple_packing.c
grib_accessor_class_count_missing.c
grib_accessor_class_data_sh_packed.c
grib_accessor_class_data_sh_unpacked.c
grib_accessor_class_number_of_values_data_raw_packing.c
grib_accessor_class_data_g1simple_packing.c
grib_accessor_class_data_g1shsimple_packing.c
grib_accessor_class_data_shsimple_packing.c
grib_accessor_class_data_constant_field.c
grib_accessor_class_data_dummy_field.c
grib_2order_packer_simple.c
grib_accessor_class_variable.c
grib_accessor_class_second_order_bits_per_value.c
grib_accessor_class_data_g2simple_packing.c
grib_accessor_class_data_g2simple_packing_with_preprocessing.c
grib_accessor_class_data_g2shsimple_packing.c
grib_accessor_class_data_g2complex_packing.c
grib_accessor_class_data_2order_packing.c
grib_accessor_class_data_2order_packing_count.c
grib_accessor_class_data_g1second_order_row_by_row_packing.c
grib_accessor_class_data_g1second_order_constant_width_packing.c
grib_accessor_class_data_g1second_order_general_packing.c
grib_accessor_class_data_g1second_order_general_extended_packing.c
grib_accessor_class_g2grid.c
grib_accessor_class_unexpanded_descriptors.c
grib_accessor_class_expanded_descriptors.c
grib_accessor_class_data_apply_bitmap.c
grib_accessor_class_data_apply_boustrophedonic.c
grib_accessor_class_data_apply_boustrophedonic_bitmap.c
grib_accessor_class_data_secondary_bitmap.c
grib_accessor_class_data_g1secondary_bitmap.c
grib_accessor_class_data_g2secondary_bitmap.c
grib_accessor_class_data_jpeg2000_packing.c
grib_accessor_class_data_png_packing.c
grib_accessor_class_data_szip_packing.c
grib_accessor_class_data_raw_packing.c
grib_accessor_class_data_complex_packing.c
grib_accessor_class_data_g1complex_packing.c
grib_accessor_class_gds_not_present_bitmap.c
grib_accessor_class_data_apply_gdsnotpresent.c
grib_accessor_class_gds_is_present.c
grib_accessor_class_select_step_template.c
grib_accessor_class_local_definition.c
grib_accessor_class_g2_eps.c
grib_accessor_class_g2_chemical.c
grib_accessor_class_g2_mars_labeling.c
grib_accessor_class_md5.c
grib_jasper_encoding.c
grib_openjpeg_encoding.c
action_class_set_missing.c
grib_accessor_class_number_of_points.c
grib_accessor_class_suppressed.c
grib_index.c
grib_accessor_class_number_of_points_gaussian.c
grib_accessor_class_number_of_values.c
grib_accessor_class_number_of_coded_values.c
grib_accessor_class_g1number_of_coded_values_sh_complex.c
grib_accessor_class_g1number_of_coded_values_sh_simple.c
grib_accessor_class_dirty.c
grib_accessor_class_statistics.c
grib_accessor_class_statistics_spectral.c
grib_accessor_class_unsigned.c
grib_accessor_class_unsigned_bits.c
grib_accessor_class_spd.c
grib_accessor_class_sum.c
grib_accessor_class_to_integer.c
grib_accessor_class_to_double.c
grib_accessor_class_to_string.c
grib_accessor_class_sexagesimal2decimal.c
grib_accessor_class_vector.c
grib_accessor_class_long_vector.c
grib_gaussian_reduced.c
grib_accessor_class_abstract_vector.c
grib_accessor_class_abstract_long_vector.c
grib_loader_from_handle.c
grib_bits.c
grib_timer.c
grib_ibmfloat.c
grib_ieeefloat.c
grib_accessor_class_reference_value_error.c
grib_memory.c
grib_buffer.c
grib_dumper.c
grib_dumper_class_serialize.c
grib_dumper_class_debug.c
grib_dumper_class_default.c
grib_dumper_class_keys.c
grib_dumper_class_json.c
grib_dumper_class_xml.c
grib_dumper_class_c_code.c
grib_dumper_class_wmo.c
grib_dumper_class.c
grib_context.c
grib_date.c
grib_fieldset.c
grib_filepool.c
grib_geography.c
grib_handle.c
grib_header_compute.c
grib_hash_keys.c
grib_io.c
grib_trie.c
grib_itrie.c
grib_rules.c
grib_keys_iterator.c
grib_parse_utils.c
grib_query.c
grib_scaling.c
grib_templates.c
grib_dependency.c
grib_value.c
grib_errors.c
grib_expression_class_binop.c
grib_expression_class_is_in_dict.c
grib_expression_class_true.c
grib_expression_class_string_compare.c
grib_expression_class_unop.c
grib_expression_class_functor.c
grib_expression_class_accessor.c
grib_expression_class_is_in_list.c
grib_expression_class_is_integer.c
grib_expression_class_length.c
grib_expression_class_long.c
grib_expression_class_double.c
grib_expression_class_string.c
grib_expression_class_sub_string.c
grib_box.c
grib_box_class.c
grib_box_class_gen.c
grib_box_class_regular_gaussian.c
grib_box_class_reduced_gaussian.c
grib_nearest.c
grib_nearest_class.c
grib_nearest_class_gen.c
grib_nearest_class_regular.c
grib_nearest_class_reduced.c
grib_nearest_class_latlon_reduced.c
grib_nearest_class_sh.c
grib_nearest_class_lambert_conformal.c
grib_iterator_class_polar_stereographic.c
grib_iterator_class_lambert_azimuthal_equal_area.c
grib_iterator_class_lambert_conformal.c
grib_iterator.c
grib_iterator_class.c
grib_iterator_class_gaussian.c
grib_iterator_class_gaussian_reduced.c
grib_iterator_class_latlon_reduced.c
grib_iterator_class_gen.c
grib_iterator_class_latlon.c
grib_iterator_class_regular.c
grib_expression.c
grib_util.c
compile.c
functions.c
grib_accessor_class.h
grib_accessor_factory.h
grib_api.h
grib_api_internal.h
grib_api_prototypes.h
grib_box_class.h
grib_box_factory.h
grib_dumper_class.h
grib_dumper_factory.h
grib_emoslib.h
grib_expression.h
grib_iterator_class.h
grib_iterator_factory.h
grib_nearest_class.h
grib_nearest_factory.h
grib_templates.h
grib_yacc.h
md5.h
md5.c
=======
grib_api.h
action.c
action_class_alias.c
@ -338,6 +681,7 @@ list( APPEND grib_api_srcs
grib_yacc.h
md5.h
md5.c
>>>>>>> 25e8f0ed91902a8ccb113de6b71a09ecc73f8e01
# Ship our generated lex/yacc C files
grib_yacc.c grib_lex.c
grib_windef.h

View File

@ -50,6 +50,9 @@ libgrib_api_la_prototypes= \
grib_darray.c \
grib_sarray.c \
grib_iarray.c \
grib_vdarray.c \
grib_vsarray.c \
grib_viarray.c \
grib_accessor_class_array.c \
grib_accessor_class_assert.c \
grib_accessor_class_ascii.c \

File diff suppressed because it is too large Load Diff

View File

@ -27,6 +27,8 @@
MEMBERS = const char* tablename
MEMBERS = const char* masterDir
MEMBERS = const char* localDir
MEMBERS = const char* extraDir
MEMBERS = const char* extraTable
MEMBERS = int widthOfCode
MEMBERS = long* tableCodes
MEMBERS = size_t tableCodesSize
@ -67,6 +69,8 @@ typedef struct grib_accessor_smart_table {
const char* tablename;
const char* masterDir;
const char* localDir;
const char* extraDir;
const char* extraTable;
int widthOfCode;
long* tableCodes;
size_t tableCodesSize;
@ -181,6 +185,8 @@ static void init(grib_accessor* a, const long len, grib_arguments* params) {
self->masterDir = grib_arguments_get_name(a->parent->h,params,n++);
self->localDir = grib_arguments_get_name(a->parent->h,params,n++);
self->widthOfCode = grib_arguments_get_long(a->parent->h,params,n++);
self->extraDir = grib_arguments_get_name(a->parent->h,params,n++);
self->extraTable = grib_arguments_get_string(a->parent->h,params,n++);
a->length = 0;
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
@ -202,17 +208,28 @@ static grib_smart_table* load_table(grib_accessor_smart_table* self)
char recomposed[1024]={0,};
char localRecomposed[1024]={0,};
char *localFilename=0;
char extraRecomposed[1024]={0,};
char *extraFilename=0;
char localName[1024]={0,};
char masterDir[1024]={0,};
char localDir[1024]={0,};
char extraDir[1024]={0,};
char extraTable[1024]={0,};
size_t len=1024;
if (self->masterDir != NULL)
if (self->masterDir != NULL) {
grib_get_string(h,self->masterDir,masterDir,&len);
}
len=1024;
if (self->localDir != NULL)
if (self->localDir != NULL) {
grib_get_string(h,self->localDir,localDir,&len);
}
len=1024;
if (self->extraDir != NULL && self->extraTable!=NULL) {
grib_get_string(h,self->extraDir,extraDir,&len);
}
if (*masterDir!=0) {
sprintf(name,"%s/%s",masterDir,self->tablename);
@ -229,6 +246,12 @@ static grib_smart_table* load_table(grib_accessor_smart_table* self)
localFilename=grib_context_full_defs_path(c,localRecomposed);
}
if (*extraDir!=0) {
sprintf(extraTable,"%s/%s",extraDir,self->extraTable);
grib_recompose_name(h, NULL,extraTable, extraRecomposed,0);
extraFilename=grib_context_full_defs_path(c,extraRecomposed);
}
next=c->smart_table;
while(next) {
if((filename && next->filename[0] && strcmp(filename,next->filename[0]) == 0) &&
@ -249,6 +272,8 @@ static grib_smart_table* load_table(grib_accessor_smart_table* self)
if (localFilename!=0) grib_load_smart_table(c,localFilename,localRecomposed,size,t);
if (extraFilename!=0) grib_load_smart_table(c,extraFilename,extraRecomposed,size,t);
if (t->filename[0]==NULL && t->filename[1]==NULL) {
grib_context_free_persistent(c,t);
return NULL;

View File

@ -148,6 +148,8 @@ typedef struct grib_accessor_smart_table {
const char* tablename;
const char* masterDir;
const char* localDir;
const char* extraDir;
const char* extraTable;
int widthOfCode;
long* tableCodes;
size_t tableCodesSize;

View File

@ -202,6 +202,9 @@ typedef struct grib_where grib_where;
typedef struct grib_sarray grib_sarray;
typedef struct grib_darray grib_darray;
typedef struct grib_iarray grib_iarray;
typedef struct grib_vdarray grib_vdarray;
typedef struct grib_vsarray grib_vsarray;
typedef struct grib_viarray grib_viarray;
grib_fieldset *grib_fieldset_new_from_files(grib_context *c, char *filenames[], int nfiles, char **keys, int nkeys, char *where_string, char *order_by_string, int *err);

View File

@ -714,6 +714,29 @@ struct grib_iarray {
grib_context* context;
} ;
struct grib_vdarray {
grib_darray** v;
size_t size;
size_t n;
size_t incsize;
grib_context* context;
} ;
struct grib_vsarray {
grib_sarray** v;
size_t size;
size_t n;
size_t incsize;
grib_context* context;
} ;
struct grib_viarray {
grib_iarray** v;
size_t size;
size_t n;
size_t incsize;
grib_context* context;
} ;
#define MAX_SET_VALUES 10
#define MAX_ACCESSOR_CACHE 100

View File

@ -150,12 +150,17 @@ grib_darray *grib_darray_new(grib_context *c, size_t size, size_t incsize);
grib_darray *grib_darray_resize(grib_context *c, grib_darray *v);
grib_darray *grib_darray_push(grib_context *c, grib_darray *v, double val);
void grib_darray_delete(grib_context *c, grib_darray *v);
double *grib_darray_get_array(grib_context *c, grib_darray *v);
size_t grib_darray_used_size(grib_darray *v);
/* grib_sarray.c */
grib_sarray *grib_sarray_new(grib_context *c, size_t size, size_t incsize);
grib_sarray *grib_sarray_resize(grib_context *c, grib_sarray *v);
grib_sarray *grib_sarray_push(grib_context *c, grib_sarray *v, char *val);
void grib_sarray_delete(grib_context *c, grib_sarray *v);
void grib_sarray_delete_content(grib_context *c, grib_sarray *v);
char **grib_sarray_get_array(grib_context *c, grib_sarray *v);
size_t grib_sarray_used_size(grib_sarray *v);
/* grib_iarray.c */
grib_iarray *grib_iarray_new_from_array(grib_context *c, long *a, size_t size);
@ -174,6 +179,33 @@ void grib_iarray_delete_array(grib_iarray *v);
long *grib_iarray_get_array(grib_iarray *v);
size_t grib_iarray_get_used_size(grib_iarray *v);
/* grib_vdarray.c */
grib_vdarray *grib_vdarray_new(grib_context *c, size_t size, size_t incsize);
grib_vdarray *grib_vdarray_resize(grib_context *c, grib_vdarray *v);
grib_vdarray *grib_vdarray_push(grib_context *c, grib_vdarray *v, grib_darray *val);
void grib_vdarray_delete(grib_context *c, grib_vdarray *v);
void grib_vdarray_delete_content(grib_context *c, grib_vdarray *v);
grib_darray **grib_vdarray_get_array(grib_context *c, grib_vdarray *v);
size_t grib_vdarray_used_size(grib_vdarray *v);
/* grib_vsarray.c */
grib_vsarray *grib_vsarray_new(grib_context *c, size_t size, size_t incsize);
grib_vsarray *grib_vsarray_resize(grib_context *c, grib_vsarray *v);
grib_vsarray *grib_vsarray_push(grib_context *c, grib_vsarray *v, grib_sarray *val);
void grib_vsarray_delete(grib_context *c, grib_vsarray *v);
void grib_vsarray_delete_content(grib_context *c, grib_vsarray *v);
grib_sarray **grib_vsarray_get_array(grib_context *c, grib_vsarray *v);
size_t grib_vsarray_used_size(grib_vsarray *v);
/* grib_viarray.c */
grib_viarray *grib_viarray_new(grib_context *c, size_t size, size_t incsize);
grib_viarray *grib_viarray_resize(grib_context *c, grib_viarray *v);
grib_viarray *grib_viarray_push(grib_context *c, grib_viarray *v, grib_iarray *val);
void grib_viarray_delete(grib_context *c, grib_viarray *v);
void grib_viarray_delete_content(grib_context *c, grib_viarray *v);
grib_iarray **grib_viarray_get_array(grib_context *c, grib_viarray *v);
size_t grib_viarray_used_size(grib_viarray *v);
/* grib_accessor_class_array.c */
/* grib_accessor_class_assert.c */
@ -190,6 +222,8 @@ size_t grib_iarray_get_used_size(grib_iarray *v);
/* grib_accessor_class_bufr_data.c */
/* grib_accessor_class_bufr_data_array.c */
/* grib_accessor_class_bufr_data_element.c */
/* grib_accessor_class_bufr_group.c */

View File

@ -70,3 +70,13 @@ void grib_darray_delete(grib_context* c,grib_darray* v) {
grib_context_free(c,v);
}
double* grib_darray_get_array(grib_context* c,grib_darray* v) {
double* ret;
int i;
if (!v) return NULL;
ret=grib_context_malloc_clear(c,sizeof(double)*v->n);
for (i=0;i<v->n;i++) ret[i]=v->v[i];
return ret;
}
size_t grib_darray_used_size(grib_darray* v) { return v->n;}

View File

@ -70,3 +70,25 @@ void grib_sarray_delete(grib_context* c,grib_sarray* v) {
grib_context_free(c,v);
}
void grib_sarray_delete_content(grib_context* c,grib_sarray* v) {
int i;
if (!v | !v->v) return;
if (!c) grib_context_get_default();
for (i=0;i<v->n;i++) {
grib_context_free(c,v->v[i]);
v->v[i]=0;
}
v->n=0;
}
char** grib_sarray_get_array(grib_context* c,grib_sarray* v) {
char** ret;
int i;
if (!v) return NULL;
ret=grib_context_malloc_clear(c,sizeof(char*)*v->n);
for (i=0;i<v->n;i++) ret[i]=v->v[i];
return ret;
}
size_t grib_sarray_used_size(grib_sarray* v) { return v->n;}

93
src/grib_vdarray.c Normal file
View File

@ -0,0 +1,93 @@
/*
* Copyright 2005-2014 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.
*/
/***************************************************************************
*
* Enrico Fucile
*
***************************************************************************/
#include "grib_api_internal.h"
grib_vdarray* grib_vdarray_new(grib_context* c,size_t size,size_t incsize) {
grib_vdarray* v=NULL;
if (!c) c=grib_context_get_default();
v=(grib_vdarray*)grib_context_malloc_clear(c,sizeof(grib_vdarray));
if (!v) {
grib_context_log(c,GRIB_LOG_ERROR,
"grib_vdarray_new unable to allocate %d bytes\n",sizeof(grib_vdarray));
return NULL;
}
v->size=size;
v->n=0;
v->incsize=incsize;
v->v=(grib_darray**)grib_context_malloc_clear(c,sizeof(grib_darray*)*size);
if (!v->v) {
grib_context_log(c,GRIB_LOG_ERROR,
"grib_vdarray_new unable to allocate %d bytes\n",sizeof(grib_darray*)*size);
return NULL;
}
return v;
}
grib_vdarray* grib_vdarray_resize(grib_context* c,grib_vdarray* v) {
int newsize=v->incsize+v->size;
if (!c) c=grib_context_get_default();
v->v=grib_context_realloc(c,v->v,newsize*sizeof(grib_darray*));
v->size=newsize;
if (!v->v) {
grib_context_log(c,GRIB_LOG_ERROR,
"grib_vdarray_resize unable to allocate %d bytes\n",sizeof(grib_darray*)*newsize);
return NULL;
}
return v;
}
grib_vdarray* grib_vdarray_push(grib_context* c,grib_vdarray* v,grib_darray* val) {
size_t start_size=100;
size_t start_incsize=100;
if (!v) v=grib_vdarray_new(c,start_size,start_incsize);
if (v->n >= v->size) v=grib_vdarray_resize(c,v);
v->v[v->n]=val;
v->n++;
return v;
}
void grib_vdarray_delete(grib_context* c,grib_vdarray* v) {
if (!v) return;
if (!c) grib_context_get_default();
if (v->v) grib_context_free(c,v->v);
grib_context_free(c,v);
}
void grib_vdarray_delete_content(grib_context* c,grib_vdarray* v) {
int i;
if (!v | !v->v) return;
if (!c) grib_context_get_default();
for (i=0;i<v->n;i++) {
grib_darray_delete(c,v->v[i]);
v->v[i]=0;
}
v->n=0;
}
grib_darray** grib_vdarray_get_array(grib_context* c,grib_vdarray* v) {
grib_darray** ret;
int i;
if (!v) return NULL;
ret=grib_context_malloc_clear(c,sizeof(grib_darray*)*v->n);
for (i=0;i<v->n;i++) ret[i]=v->v[i];
return ret;
}
size_t grib_vdarray_used_size(grib_vdarray* v) { return v->n;}

93
src/grib_viarray.c Normal file
View File

@ -0,0 +1,93 @@
/*
* Copyright 2005-2014 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.
*/
/***************************************************************************
*
* Enrico Fucile
*
***************************************************************************/
#include "grib_api_internal.h"
grib_viarray* grib_viarray_new(grib_context* c,size_t size,size_t incsize) {
grib_viarray* v=NULL;
if (!c) c=grib_context_get_default();
v=(grib_viarray*)grib_context_malloc_clear(c,sizeof(grib_viarray));
if (!v) {
grib_context_log(c,GRIB_LOG_ERROR,
"grib_viarray_new unable to allocate %d bytes\n",sizeof(grib_viarray));
return NULL;
}
v->size=size;
v->n=0;
v->incsize=incsize;
v->v=(grib_iarray**)grib_context_malloc_clear(c,sizeof(grib_iarray*)*size);
if (!v->v) {
grib_context_log(c,GRIB_LOG_ERROR,
"grib_viarray_new unable to allocate %d bytes\n",sizeof(grib_iarray*)*size);
return NULL;
}
return v;
}
grib_viarray* grib_viarray_resize(grib_context* c,grib_viarray* v) {
int newsize=v->incsize+v->size;
if (!c) c=grib_context_get_default();
v->v=grib_context_realloc(c,v->v,newsize*sizeof(grib_iarray*));
v->size=newsize;
if (!v->v) {
grib_context_log(c,GRIB_LOG_ERROR,
"grib_viarray_resize unable to allocate %d bytes\n",sizeof(grib_iarray*)*newsize);
return NULL;
}
return v;
}
grib_viarray* grib_viarray_push(grib_context* c,grib_viarray* v,grib_iarray* val) {
size_t start_size=100;
size_t start_incsize=100;
if (!v) v=grib_viarray_new(c,start_size,start_incsize);
if (v->n >= v->size) v=grib_viarray_resize(c,v);
v->v[v->n]=val;
v->n++;
return v;
}
void grib_viarray_delete(grib_context* c,grib_viarray* v) {
if (!v) return;
if (!c) grib_context_get_default();
if (v->v) grib_context_free(c,v->v);
grib_context_free(c,v);
}
void grib_viarray_delete_content(grib_context* c,grib_viarray* v) {
int i;
if (!v | !v->v) return;
if (!c) grib_context_get_default();
for (i=0;i<v->n;i++) {
grib_iarray_delete(v->v[i]);
v->v[i]=0;
}
v->n=0;
}
grib_iarray** grib_viarray_get_array(grib_context* c,grib_viarray* v) {
grib_iarray** ret;
int i;
if (!v) return NULL;
ret=grib_context_malloc_clear(c,sizeof(grib_iarray*)*v->n);
for (i=0;i<v->n;i++) ret[i]=v->v[i];
return ret;
}
size_t grib_viarray_used_size(grib_viarray* v) { return v->n;}

94
src/grib_vsarray.c Normal file
View File

@ -0,0 +1,94 @@
/*
* Copyright 2005-2014 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.
*/
/***************************************************************************
*
* Enrico Fucile
*
***************************************************************************/
#include "grib_api_internal.h"
grib_vsarray* grib_vsarray_new(grib_context* c,size_t size,size_t incsize) {
grib_vsarray* v=NULL;
if (!c) c=grib_context_get_default();
v=(grib_vsarray*)grib_context_malloc_clear(c,sizeof(grib_vsarray));
if (!v) {
grib_context_log(c,GRIB_LOG_ERROR,
"grib_vsarray_new unable to allocate %d bytes\n",sizeof(grib_vsarray));
return NULL;
}
v->size=size;
v->n=0;
v->incsize=incsize;
v->v=(grib_sarray**)grib_context_malloc_clear(c,sizeof(grib_sarray*)*size);
if (!v->v) {
grib_context_log(c,GRIB_LOG_ERROR,
"grib_vsarray_new unable to allocate %d bytes\n",sizeof(grib_sarray*)*size);
return NULL;
}
return v;
}
grib_vsarray* grib_vsarray_resize(grib_context* c,grib_vsarray* v) {
int newsize=v->incsize+v->size;
if (!c) c=grib_context_get_default();
v->v=grib_context_realloc(c,v->v,newsize*sizeof(grib_sarray*));
v->size=newsize;
if (!v->v) {
grib_context_log(c,GRIB_LOG_ERROR,
"grib_vsarray_resize unable to allocate %d bytes\n",sizeof(grib_sarray*)*newsize);
return NULL;
}
return v;
}
grib_vsarray* grib_vsarray_push(grib_context* c,grib_vsarray* v,grib_sarray* val) {
size_t start_size=100;
size_t start_incsize=100;
if (!v) v=grib_vsarray_new(c,start_size,start_incsize);
if (v->n >= v->size) v=grib_vsarray_resize(c,v);
v->v[v->n]=val;
v->n++;
return v;
}
void grib_vsarray_delete(grib_context* c,grib_vsarray* v) {
if (!v) return;
if (!c) grib_context_get_default();
if (v->v) grib_context_free(c,v->v);
grib_context_free(c,v);
}
void grib_vsarray_delete_content(grib_context* c,grib_vsarray* v) {
int i;
if (!v | !v->v) return;
if (!c) grib_context_get_default();
for (i=0;i<v->n;i++) {
grib_sarray_delete_content(c,v->v[i]);
grib_sarray_delete(c,v->v[i]);
v->v[i]=0;
}
v->n=0;
}
grib_sarray** grib_vsarray_get_array(grib_context* c,grib_vsarray* v) {
grib_sarray** ret;
int i;
if (!v) return NULL;
ret=grib_context_malloc_clear(c,sizeof(grib_sarray*)*v->n);
for (i=0;i<v->n;i++) ret[i]=v->v[i];
return ret;
}
size_t grib_vsarray_used_size(grib_vsarray* v) { return v->n;}

View File

@ -9,7 +9,7 @@ TESTS = definitions.sh \
bitmap.sh list.sh second_order.sh \
multi_from_message.sh change_scanning.sh \
julian.sh statistics.sh tigge.sh tigge_conversions.sh \
read_any.sh padding.sh lamb_az_eq_area.sh grib_to_netcdf.sh bufr_dump.sh debug.sh $(JPEG_TEST)
read_any.sh padding.sh lamb_az_eq_area.sh grib_to_netcdf.sh bufrdc_ref.sh bufr_dump.sh debug.sh $(JPEG_TEST)
noinst_PROGRAMS = packing_check gauss_sub read_any double_cmp packing pack_unpack \
multi_from_message julian read_index index gribex_perf\

31
tests/bufrdc_ref.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/sh
# Copyright 2005-2014 ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#
. ./include.sh
REDIRECT=/dev/null
cat > bufrdc_ref.filter<<EOF
set subsetNumber=0;
print "[numericValues!1%23.14e]";
EOF
for file in ${data_dir}/bufr/*.bufr
do
REDIRECT=stdout
${tools_dir}bufr_filter bufrdc_ref.filter $file 2> $REDIRECT > $file.test
numdiff $file.ref $file.test
done